1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23#ifndef _PART_H
24#define _PART_H
25
26#include <ide.h>
27
28typedef struct block_dev_desc {
29 int if_type;
30 int dev;
31 unsigned char part_type;
32 unsigned char target;
33 unsigned char lun;
34 unsigned char type;
35 unsigned char removable;
36#ifdef CONFIG_LBA48
37 unsigned char lba48;
38#endif
39 lbaint_t lba;
40 unsigned long blksz;
41 char vendor [40+1];
42 char product[20+1];
43 char revision[8+1];
44 unsigned long (*block_read)(int dev,
45 unsigned long start,
46 lbaint_t blkcnt,
47 void *buffer);
48 unsigned long (*block_write)(int dev,
49 unsigned long start,
50 lbaint_t blkcnt,
51 const void *buffer);
52 unsigned long (*block_erase)(int dev,
53 unsigned long start,
54 lbaint_t blkcnt);
55 void *priv;
56}block_dev_desc_t;
57
58
59#define IF_TYPE_UNKNOWN 0
60#define IF_TYPE_IDE 1
61#define IF_TYPE_SCSI 2
62#define IF_TYPE_ATAPI 3
63#define IF_TYPE_USB 4
64#define IF_TYPE_DOC 5
65#define IF_TYPE_MMC 6
66#define IF_TYPE_SD 7
67#define IF_TYPE_SATA 8
68
69
70#define PART_TYPE_UNKNOWN 0x00
71#define PART_TYPE_MAC 0x01
72#define PART_TYPE_DOS 0x02
73#define PART_TYPE_ISO 0x03
74#define PART_TYPE_AMIGA 0x04
75#define PART_TYPE_EFI 0x05
76
77
78
79
80#define BOOT_PART_TYPE "U-Boot"
81#define BOOT_PART_COMP "PPCBoot"
82
83
84#define DEV_TYPE_UNKNOWN 0xff
85#define DEV_TYPE_HARDDISK 0x00
86#define DEV_TYPE_TAPE 0x01
87#define DEV_TYPE_CDROM 0x05
88#define DEV_TYPE_OPDISK 0x07
89
90typedef struct disk_partition {
91 ulong start;
92 ulong size;
93 ulong blksz;
94 uchar name[32];
95 uchar type[32];
96 int bootable;
97#ifdef CONFIG_PARTITION_UUIDS
98 char uuid[37];
99#endif
100} disk_partition_t;
101
102
103#ifdef CONFIG_PARTITIONS
104block_dev_desc_t *get_dev(const char *ifname, int dev);
105block_dev_desc_t* ide_get_dev(int dev);
106block_dev_desc_t* sata_get_dev(int dev);
107block_dev_desc_t* scsi_get_dev(int dev);
108block_dev_desc_t* usb_stor_get_dev(int dev);
109block_dev_desc_t* mmc_get_dev(int dev);
110block_dev_desc_t* systemace_get_dev(int dev);
111block_dev_desc_t* mg_disk_get_dev(int dev);
112
113
114int get_partition_info (block_dev_desc_t * dev_desc, int part, disk_partition_t *info);
115void print_part (block_dev_desc_t *dev_desc);
116void init_part (block_dev_desc_t *dev_desc);
117void dev_print(block_dev_desc_t *dev_desc);
118int get_device(const char *ifname, const char *dev_str,
119 block_dev_desc_t **dev_desc);
120int get_device_and_partition(const char *ifname, const char *dev_part_str,
121 block_dev_desc_t **dev_desc,
122 disk_partition_t *info, int allow_whole_dev);
123#else
124static inline block_dev_desc_t *get_dev(const char *ifname, int dev)
125{ return NULL; }
126static inline block_dev_desc_t* ide_get_dev(int dev) { return NULL; }
127static inline block_dev_desc_t* sata_get_dev(int dev) { return NULL; }
128static inline block_dev_desc_t* scsi_get_dev(int dev) { return NULL; }
129static inline block_dev_desc_t* usb_stor_get_dev(int dev) { return NULL; }
130static inline block_dev_desc_t* mmc_get_dev(int dev) { return NULL; }
131static inline block_dev_desc_t* systemace_get_dev(int dev) { return NULL; }
132static inline block_dev_desc_t* mg_disk_get_dev(int dev) { return NULL; }
133
134static inline int get_partition_info (block_dev_desc_t * dev_desc, int part,
135 disk_partition_t *info) { return -1; }
136static inline void print_part (block_dev_desc_t *dev_desc) {}
137static inline void init_part (block_dev_desc_t *dev_desc) {}
138static inline void dev_print(block_dev_desc_t *dev_desc) {}
139static inline int get_device(const char *ifname, const char *dev_str,
140 block_dev_desc_t **dev_desc)
141{ return -1; }
142static inline int get_device_and_partition(const char *ifname,
143 const char *dev_part_str,
144 block_dev_desc_t **dev_desc,
145 disk_partition_t *info,
146 int allow_whole_dev)
147{ *dev_desc = NULL; return -1; }
148#endif
149
150#ifdef CONFIG_MAC_PARTITION
151
152int get_partition_info_mac (block_dev_desc_t * dev_desc, int part, disk_partition_t *info);
153void print_part_mac (block_dev_desc_t *dev_desc);
154int test_part_mac (block_dev_desc_t *dev_desc);
155#endif
156
157#ifdef CONFIG_DOS_PARTITION
158
159int get_partition_info_dos (block_dev_desc_t * dev_desc, int part, disk_partition_t *info);
160void print_part_dos (block_dev_desc_t *dev_desc);
161int test_part_dos (block_dev_desc_t *dev_desc);
162#endif
163
164#ifdef CONFIG_ISO_PARTITION
165
166int get_partition_info_iso (block_dev_desc_t * dev_desc, int part, disk_partition_t *info);
167void print_part_iso (block_dev_desc_t *dev_desc);
168int test_part_iso (block_dev_desc_t *dev_desc);
169#endif
170
171#ifdef CONFIG_AMIGA_PARTITION
172
173int get_partition_info_amiga (block_dev_desc_t * dev_desc, int part, disk_partition_t *info);
174void print_part_amiga (block_dev_desc_t *dev_desc);
175int test_part_amiga (block_dev_desc_t *dev_desc);
176#endif
177
178#ifdef CONFIG_EFI_PARTITION
179#include <part_efi.h>
180
181int get_partition_info_efi (block_dev_desc_t * dev_desc, int part, disk_partition_t *info);
182void print_part_efi (block_dev_desc_t *dev_desc);
183int test_part_efi (block_dev_desc_t *dev_desc);
184
185
186
187
188
189
190
191
192
193
194int write_gpt_table(block_dev_desc_t *dev_desc,
195 gpt_header *gpt_h, gpt_entry *gpt_e);
196
197
198
199
200
201
202
203
204
205
206
207int gpt_fill_pte(gpt_header *gpt_h, gpt_entry *gpt_e,
208 disk_partition_t *partitions, int parts);
209
210
211
212
213
214
215
216
217
218
219
220int gpt_fill_header(block_dev_desc_t *dev_desc, gpt_header *gpt_h,
221 char *str_guid, int parts_count);
222
223
224
225
226
227
228
229
230
231
232
233int gpt_restore(block_dev_desc_t *dev_desc, char *str_disk_guid,
234 disk_partition_t *partitions, const int parts_count);
235#endif
236
237#endif
238