123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407 |
- #ifndef _PART_H
- #define _PART_H
- #include <blk.h>
- #include <ide.h>
- struct block_drvr {
- char *name;
- int (*select_hwpart)(int dev_num, int hwpart);
- };
- #define LOG2(x) (((x & 0xaaaaaaaa) ? 1 : 0) + ((x & 0xcccccccc) ? 2 : 0) + \
- ((x & 0xf0f0f0f0) ? 4 : 0) + ((x & 0xff00ff00) ? 8 : 0) + \
- ((x & 0xffff0000) ? 16 : 0))
- #define LOG2_INVALID(type) ((type)((sizeof(type)<<3)-1))
- #define PART_TYPE_UNKNOWN 0x00
- #define PART_TYPE_MAC 0x01
- #define PART_TYPE_DOS 0x02
- #define PART_TYPE_ISO 0x03
- #define PART_TYPE_AMIGA 0x04
- #define PART_TYPE_EFI 0x05
- #define DOS_ENTRY_NUMBERS 8
- #define ISO_ENTRY_NUMBERS 64
- #define MAC_ENTRY_NUMBERS 64
- #define AMIGA_ENTRY_NUMBERS 8
- #define BOOT_PART_TYPE "U-Boot"
- #define BOOT_PART_COMP "PPCBoot"
- #define DEV_TYPE_UNKNOWN 0xff
- #define DEV_TYPE_HARDDISK 0x00
- #define DEV_TYPE_TAPE 0x01
- #define DEV_TYPE_CDROM 0x05
- #define DEV_TYPE_OPDISK 0x07
- typedef struct disk_partition {
- lbaint_t start;
- lbaint_t size;
- ulong blksz;
- uchar name[32];
- uchar type[32];
- int bootable;
- #ifdef CONFIG_PARTITION_UUIDS
- char uuid[37];
- #endif
- #ifdef CONFIG_PARTITION_TYPE_GUID
- char type_guid[37];
- #endif
- } disk_partition_t;
- #ifdef CONFIG_PARTITIONS
- struct blk_desc *blk_get_dev(const char *ifname, int dev);
- struct blk_desc *mg_disk_get_dev(int dev);
- int host_get_dev_err(int dev, struct blk_desc **blk_devp);
- int part_get_info(struct blk_desc *dev_desc, int part, disk_partition_t *info);
- void part_print(struct blk_desc *dev_desc);
- void part_init(struct blk_desc *dev_desc);
- void dev_print(struct blk_desc *dev_desc);
- int blk_get_device_by_str(const char *ifname, const char *dev_str,
- struct blk_desc **dev_desc);
- int blk_get_device_part_str(const char *ifname, const char *dev_part_str,
- struct blk_desc **dev_desc,
- disk_partition_t *info, int allow_whole_dev);
- int part_get_info_by_name_type(struct blk_desc *dev_desc, const char *name,
- disk_partition_t *info, int part_type);
- int part_get_info_by_name(struct blk_desc *dev_desc,
- const char *name, disk_partition_t *info);
- void part_set_generic_name(const struct blk_desc *dev_desc,
- int part_num, char *name);
- extern const struct block_drvr block_drvr[];
- #else
- static inline struct blk_desc *blk_get_dev(const char *ifname, int dev)
- { return NULL; }
- static inline struct blk_desc *mg_disk_get_dev(int dev) { return NULL; }
- static inline int part_get_info(struct blk_desc *dev_desc, int part,
- disk_partition_t *info) { return -1; }
- static inline void part_print(struct blk_desc *dev_desc) {}
- static inline void part_init(struct blk_desc *dev_desc) {}
- static inline void dev_print(struct blk_desc *dev_desc) {}
- static inline int blk_get_device_by_str(const char *ifname, const char *dev_str,
- struct blk_desc **dev_desc)
- { return -1; }
- static inline int blk_get_device_part_str(const char *ifname,
- const char *dev_part_str,
- struct blk_desc **dev_desc,
- disk_partition_t *info,
- int allow_whole_dev)
- { *dev_desc = NULL; return -1; }
- #endif
- #ifdef CONFIG_SPL_BUILD
- # define part_print_ptr(x) NULL
- # if defined(CONFIG_SPL_EXT_SUPPORT) || defined(CONFIG_SPL_FAT_SUPPORT) || \
- defined(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION)
- # define part_get_info_ptr(x) x
- # else
- # define part_get_info_ptr(x) NULL
- # endif
- #else
- #define part_print_ptr(x) x
- #define part_get_info_ptr(x) x
- #endif
- struct part_driver {
- const char *name;
- int part_type;
- const int max_entries;
-
- int (*get_info)(struct blk_desc *dev_desc, int part,
- disk_partition_t *info);
-
- void (*print)(struct blk_desc *dev_desc);
-
- int (*test)(struct blk_desc *dev_desc);
- };
- #define U_BOOT_PART_TYPE(__name) \
- ll_entry_declare(struct part_driver, __name, part_driver)
- #ifdef CONFIG_EFI_PARTITION
- #include <part_efi.h>
- int write_gpt_table(struct blk_desc *dev_desc,
- gpt_header *gpt_h, gpt_entry *gpt_e);
- int gpt_fill_pte(gpt_header *gpt_h, gpt_entry *gpt_e,
- disk_partition_t *partitions, int parts);
- int gpt_fill_header(struct blk_desc *dev_desc, gpt_header *gpt_h,
- char *str_guid, int parts_count);
- int gpt_restore(struct blk_desc *dev_desc, char *str_disk_guid,
- disk_partition_t *partitions, const int parts_count);
- int is_valid_gpt_buf(struct blk_desc *dev_desc, void *buf);
- int write_mbr_and_gpt_partitions(struct blk_desc *dev_desc, void *buf);
- int gpt_verify_headers(struct blk_desc *dev_desc, gpt_header *gpt_head,
- gpt_entry **gpt_pte);
- int gpt_verify_partitions(struct blk_desc *dev_desc,
- disk_partition_t *partitions, int parts,
- gpt_header *gpt_head, gpt_entry **gpt_pte);
- #endif
- #ifdef CONFIG_DOS_PARTITION
- int is_valid_dos_buf(void *buf);
- int write_mbr_partition(struct blk_desc *dev_desc, void *buf);
- #endif
- #endif
|