Fix cross compilation (e.g. on Darwin). Following changes to make.tmpl,
[AROS.git] / arch / all-pc / boot / grub2-aros / include / grub / partition.h
blob7adb7ec6eaa2df725c9ba23a61c3cf7fdde5dc6f
1 /*
2 * GRUB -- GRand Unified Bootloader
3 * Copyright (C) 1999,2000,2001,2002,2004,2006,2007 Free Software Foundation, Inc.
5 * GRUB is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * GRUB is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
19 #ifndef GRUB_PART_HEADER
20 #define GRUB_PART_HEADER 1
22 #include <grub/dl.h>
23 #include <grub/list.h>
25 struct grub_disk;
27 typedef struct grub_partition *grub_partition_t;
29 #ifdef GRUB_UTIL
30 typedef enum
32 GRUB_EMBED_PCBIOS
33 } grub_embed_type_t;
34 #endif
36 typedef int (*grub_partition_iterate_hook_t) (struct grub_disk *disk,
37 const grub_partition_t partition,
38 void *data);
40 /* Partition map type. */
41 struct grub_partition_map
43 /* The next partition map type. */
44 struct grub_partition_map *next;
45 struct grub_partition_map **prev;
47 /* The name of the partition map type. */
48 const char *name;
50 /* Call HOOK with each partition, until HOOK returns non-zero. */
51 grub_err_t (*iterate) (struct grub_disk *disk,
52 grub_partition_iterate_hook_t hook, void *hook_data);
53 #ifdef GRUB_UTIL
54 /* Determine sectors available for embedding. */
55 grub_err_t (*embed) (struct grub_disk *disk, unsigned int *nsectors,
56 unsigned int max_nsectors,
57 grub_embed_type_t embed_type,
58 grub_disk_addr_t **sectors);
59 #endif
61 typedef struct grub_partition_map *grub_partition_map_t;
63 /* Partition description. */
64 struct grub_partition
66 /* The partition number. */
67 int number;
69 /* The start sector (relative to parent). */
70 grub_disk_addr_t start;
72 /* The length in sector units. */
73 grub_uint64_t len;
75 /* The offset of the partition table. */
76 grub_disk_addr_t offset;
78 /* The index of this partition in the partition table. */
79 int index;
81 /* Parent partition (physically contains this partition). */
82 struct grub_partition *parent;
84 /* The type partition map. */
85 grub_partition_map_t partmap;
87 /* The type of partition whne it's on MSDOS.
88 Used for embedding detection. */
89 grub_uint8_t msdostype;
92 grub_partition_t EXPORT_FUNC(grub_partition_probe) (struct grub_disk *disk,
93 const char *str);
94 int EXPORT_FUNC(grub_partition_iterate) (struct grub_disk *disk,
95 grub_partition_iterate_hook_t hook,
96 void *hook_data);
97 char *EXPORT_FUNC(grub_partition_get_name) (const grub_partition_t partition);
100 extern grub_partition_map_t EXPORT_VAR(grub_partition_map_list);
102 #ifndef GRUB_LST_GENERATOR
103 static inline void
104 grub_partition_map_register (grub_partition_map_t partmap)
106 grub_list_push (GRUB_AS_LIST_P (&grub_partition_map_list),
107 GRUB_AS_LIST (partmap));
109 #endif
111 static inline void
112 grub_partition_map_unregister (grub_partition_map_t partmap)
114 grub_list_remove (GRUB_AS_LIST (partmap));
117 #define FOR_PARTITION_MAPS(var) FOR_LIST_ELEMENTS((var), (grub_partition_map_list))
120 static inline grub_disk_addr_t
121 grub_partition_get_start (const grub_partition_t p)
123 grub_partition_t part;
124 grub_uint64_t part_start = 0;
126 for (part = p; part; part = part->parent)
127 part_start += part->start;
129 return part_start;
132 static inline grub_uint64_t
133 grub_partition_get_len (const grub_partition_t p)
135 return p->len;
138 #endif /* ! GRUB_PART_HEADER */