Upgraded GRUB2 to 2.00 release.
[AROS.git] / arch / all-pc / boot / grub2-aros / include / grub / partition.h
blobec0a667d2bc1e9011acecd04c57f242cf3063367
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 /* Partition map type. */
37 struct grub_partition_map
39 /* The next partition map type. */
40 struct grub_partition_map *next;
41 struct grub_partition_map **prev;
43 /* The name of the partition map type. */
44 const char *name;
46 /* Call HOOK with each partition, until HOOK returns non-zero. */
47 grub_err_t (*iterate) (struct grub_disk *disk,
48 int (*hook) (struct grub_disk *disk,
49 const grub_partition_t partition));
50 #ifdef GRUB_UTIL
51 /* Determine sectors available for embedding. */
52 grub_err_t (*embed) (struct grub_disk *disk, unsigned int *nsectors,
53 unsigned int max_nsectors,
54 grub_embed_type_t embed_type,
55 grub_disk_addr_t **sectors);
56 #endif
58 typedef struct grub_partition_map *grub_partition_map_t;
60 /* Partition description. */
61 struct grub_partition
63 /* The partition number. */
64 int number;
66 /* The start sector (relative to parent). */
67 grub_disk_addr_t start;
69 /* The length in sector units. */
70 grub_uint64_t len;
72 /* The offset of the partition table. */
73 grub_disk_addr_t offset;
75 /* The index of this partition in the partition table. */
76 int index;
78 /* Parent partition (physically contains this partition). */
79 struct grub_partition *parent;
81 /* The type partition map. */
82 grub_partition_map_t partmap;
84 /* The type of partition whne it's on MSDOS.
85 Used for embedding detection. */
86 grub_uint8_t msdostype;
89 grub_partition_t EXPORT_FUNC(grub_partition_probe) (struct grub_disk *disk,
90 const char *str);
91 int EXPORT_FUNC(grub_partition_iterate) (struct grub_disk *disk,
92 int (*hook) (struct grub_disk *disk,
93 const grub_partition_t partition));
94 char *EXPORT_FUNC(grub_partition_get_name) (const grub_partition_t partition);
97 extern grub_partition_map_t EXPORT_VAR(grub_partition_map_list);
99 #ifndef GRUB_LST_GENERATOR
100 static inline void
101 grub_partition_map_register (grub_partition_map_t partmap)
103 grub_list_push (GRUB_AS_LIST_P (&grub_partition_map_list),
104 GRUB_AS_LIST (partmap));
106 #endif
108 static inline void
109 grub_partition_map_unregister (grub_partition_map_t partmap)
111 grub_list_remove (GRUB_AS_LIST (partmap));
114 #define FOR_PARTITION_MAPS(var) FOR_LIST_ELEMENTS((var), (grub_partition_map_list))
117 static inline grub_disk_addr_t
118 grub_partition_get_start (const grub_partition_t p)
120 grub_partition_t part;
121 grub_uint64_t part_start = 0;
123 for (part = p; part; part = part->parent)
124 part_start += part->start;
126 return part_start;
129 static inline grub_uint64_t
130 grub_partition_get_len (const grub_partition_t p)
132 return p->len;
135 #endif /* ! GRUB_PART_HEADER */