]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - include/part.h
Merge branch 'u-boot-tegra/master' into 'u-boot-arm/master'
[karo-tx-uboot.git] / include / part.h
index e43978c658dddf147d98dc1fbb9365519edef588..c58a734ada0196fce6c75af2a195f660c98f10b6 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * (C) Copyright 2000, 2001
+ * (C) Copyright 2000-2004
  * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  *
  * See file CREDITS for list of people who contributed to this
@@ -12,7 +12,7 @@
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.         See the
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
 #ifndef _PART_H
 #define _PART_H
 
+#include <ide.h>
 
 typedef struct block_dev_desc {
-       int           if_type;    /* type of the interface */
-       int           dev;        /* device number */
-       unsigned char part_type;  /* partition type */
-       unsigned char target;                   /* target SCSI ID */
-       unsigned char lun;                              /* target LUN */
-       unsigned char type;                             /* device type */
-       unsigned long lba;        /* number of blocks */
-       unsigned long blksz;                    /* block size */
-       unsigned char vendor[40]; /* IDE model, SCSI Vendor */
-       unsigned char product[20];/* IDE Serial no, SCSI product */
-       unsigned char revision[8];/* firmware revision */
-       unsigned char removable;        /* removable device */
-       unsigned long (*block_read)(int dev,unsigned long start,unsigned long blkcnt, unsigned long *buffer);
+       int             if_type;        /* type of the interface */
+       int             dev;            /* device number */
+       unsigned char   part_type;      /* partition type */
+       unsigned char   target;         /* target SCSI ID */
+       unsigned char   lun;            /* target LUN */
+       unsigned char   type;           /* device type */
+       unsigned char   removable;      /* removable device */
+#ifdef CONFIG_LBA48
+       unsigned char   lba48;          /* device can use 48bit addr (ATA/ATAPI v7) */
+#endif
+       lbaint_t        lba;            /* number of blocks */
+       unsigned long   blksz;          /* block size */
+       char            vendor [40+1];  /* IDE model, SCSI Vendor */
+       char            product[20+1];  /* IDE Serial no, SCSI product */
+       char            revision[8+1];  /* firmware revision */
+       unsigned long   (*block_read)(int dev,
+                                     unsigned long start,
+                                     lbaint_t blkcnt,
+                                     void *buffer);
+       unsigned long   (*block_write)(int dev,
+                                      unsigned long start,
+                                      lbaint_t blkcnt,
+                                      const void *buffer);
+       unsigned long   (*block_erase)(int dev,
+                                      unsigned long start,
+                                      lbaint_t blkcnt);
+       void            *priv;          /* driver private struct pointer */
 }block_dev_desc_t;
+
 /* Interface types: */
-#define IF_TYPE_UNKNOWN        0
-#define IF_TYPE_IDE                    1
+#define IF_TYPE_UNKNOWN                0
+#define IF_TYPE_IDE            1
 #define IF_TYPE_SCSI           2
 #define IF_TYPE_ATAPI          3
-#define IF_TYPE_USB                    4
-#define IF_TYPE_DOC                    5
+#define IF_TYPE_USB            4
+#define IF_TYPE_DOC            5
+#define IF_TYPE_MMC            6
+#define IF_TYPE_SD             7
+#define IF_TYPE_SATA           8
+
 /* Part types */
-#define        PART_TYPE_UNKNOWN       0x00
+#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
+
+/*
+ * Type string for U-Boot bootable partitions
+ */
+#define BOOT_PART_TYPE "U-Boot"        /* primary boot partition type  */
+#define BOOT_PART_COMP "PPCBoot"       /* PPCBoot compatibility type   */
+
 /* device types */
-#define DEV_TYPE_UNKNOWN 0xff /* not connected */
-#define DEV_TYPE_HARDDISK 0x00 /* harddisk */
-#define DEV_TYPE_TAPE          0x01 /* Tape */
-#define DEV_TYPE_CDROM                 0x05 /* CD-ROM */
-#define DEV_TYPE_OPDISK        0x07 /* optical disk */
+#define DEV_TYPE_UNKNOWN       0xff    /* not connected */
+#define DEV_TYPE_HARDDISK      0x00    /* harddisk */
+#define DEV_TYPE_TAPE          0x01    /* Tape */
+#define DEV_TYPE_CDROM         0x05    /* CD-ROM */
+#define DEV_TYPE_OPDISK                0x07    /* optical disk */
 
-typedef        struct disk_partition {
+typedef struct disk_partition {
        ulong   start;          /* # of first block in partition        */
        ulong   size;           /* number of blocks in partition        */
        ulong   blksz;          /* block size in bytes                  */
        uchar   name[32];       /* partition name                       */
        uchar   type[32];       /* string type description              */
+       int     bootable;       /* Active/Bootable flag is set          */
+#ifdef CONFIG_PARTITION_UUIDS
+       char    uuid[37];       /* filesystem UUID as string, if exists */
+#endif
 } disk_partition_t;
 
+/* Misc _get_dev functions */
+#ifdef CONFIG_PARTITIONS
+block_dev_desc_t *get_dev(const char *ifname, int dev);
+block_dev_desc_t* ide_get_dev(int dev);
+block_dev_desc_t* sata_get_dev(int dev);
+block_dev_desc_t* scsi_get_dev(int dev);
+block_dev_desc_t* usb_stor_get_dev(int dev);
+block_dev_desc_t* mmc_get_dev(int dev);
+block_dev_desc_t* systemace_get_dev(int dev);
+block_dev_desc_t* mg_disk_get_dev(int dev);
+
 /* disk/part.c */
 int get_partition_info (block_dev_desc_t * dev_desc, int part, disk_partition_t *info);
 void print_part (block_dev_desc_t *dev_desc);
 void  init_part (block_dev_desc_t *dev_desc);
 void dev_print(block_dev_desc_t *dev_desc);
+int get_device(const char *ifname, const char *dev_str,
+              block_dev_desc_t **dev_desc);
+int get_device_and_partition(const char *ifname, const char *dev_part_str,
+                            block_dev_desc_t **dev_desc,
+                            disk_partition_t *info, int allow_whole_dev);
+#else
+static inline block_dev_desc_t *get_dev(const char *ifname, int dev)
+{ return NULL; }
+static inline block_dev_desc_t* ide_get_dev(int dev) { return NULL; }
+static inline block_dev_desc_t* sata_get_dev(int dev) { return NULL; }
+static inline block_dev_desc_t* scsi_get_dev(int dev) { return NULL; }
+static inline block_dev_desc_t* usb_stor_get_dev(int dev) { return NULL; }
+static inline block_dev_desc_t* mmc_get_dev(int dev) { return NULL; }
+static inline block_dev_desc_t* systemace_get_dev(int dev) { return NULL; }
+static inline block_dev_desc_t* mg_disk_get_dev(int dev) { return NULL; }
 
+static inline int get_partition_info (block_dev_desc_t * dev_desc, int part,
+       disk_partition_t *info) { return -1; }
+static inline void print_part (block_dev_desc_t *dev_desc) {}
+static inline void  init_part (block_dev_desc_t *dev_desc) {}
+static inline void dev_print(block_dev_desc_t *dev_desc) {}
+static inline int get_device(const char *ifname, const char *dev_str,
+              block_dev_desc_t **dev_desc)
+{ return -1; }
+static inline int get_device_and_partition(const char *ifname,
+                                          const char *dev_part_str,
+                                          block_dev_desc_t **dev_desc,
+                                          disk_partition_t *info,
+                                          int allow_whole_dev)
+{ *dev_desc = NULL; return -1; }
+#endif
 
 #ifdef CONFIG_MAC_PARTITION
 /* disk/part_mac.c */
@@ -94,6 +168,70 @@ void print_part_iso (block_dev_desc_t *dev_desc);
 int   test_part_iso (block_dev_desc_t *dev_desc);
 #endif
 
-#endif /* _PART_H */
+#ifdef CONFIG_AMIGA_PARTITION
+/* disk/part_amiga.c */
+int get_partition_info_amiga (block_dev_desc_t * dev_desc, int part, disk_partition_t *info);
+void print_part_amiga (block_dev_desc_t *dev_desc);
+int   test_part_amiga (block_dev_desc_t *dev_desc);
+#endif
+
+#ifdef CONFIG_EFI_PARTITION
+#include <part_efi.h>
+/* disk/part_efi.c */
+int get_partition_info_efi (block_dev_desc_t * dev_desc, int part, disk_partition_t *info);
+void print_part_efi (block_dev_desc_t *dev_desc);
+int   test_part_efi (block_dev_desc_t *dev_desc);
+
+/**
+ * write_gpt_table() - Write the GUID Partition Table to disk
+ *
+ * @param dev_desc - block device descriptor
+ * @param gpt_h - pointer to GPT header representation
+ * @param gpt_e - pointer to GPT partition table entries
+ *
+ * @return - zero on success, otherwise error
+ */
+int write_gpt_table(block_dev_desc_t *dev_desc,
+                 gpt_header *gpt_h, gpt_entry *gpt_e);
 
+/**
+ * gpt_fill_pte(): Fill the GPT partition table entry
+ *
+ * @param gpt_h - GPT header representation
+ * @param gpt_e - GPT partition table entries
+ * @param partitions - list of partitions
+ * @param parts - number of partitions
+ *
+ * @return zero on success
+ */
+int gpt_fill_pte(gpt_header *gpt_h, gpt_entry *gpt_e,
+               disk_partition_t *partitions, int parts);
 
+/**
+ * gpt_fill_header(): Fill the GPT header
+ *
+ * @param dev_desc - block device descriptor
+ * @param gpt_h - GPT header representation
+ * @param str_guid - disk guid string representation
+ * @param parts_count - number of partitions
+ *
+ * @return - error on str_guid conversion error
+ */
+int gpt_fill_header(block_dev_desc_t *dev_desc, gpt_header *gpt_h,
+               char *str_guid, int parts_count);
+
+/**
+ * gpt_restore(): Restore GPT partition table
+ *
+ * @param dev_desc - block device descriptor
+ * @param str_disk_guid - disk GUID
+ * @param partitions - list of partitions
+ * @param parts - number of partitions
+ *
+ * @return zero on success
+ */
+int gpt_restore(block_dev_desc_t *dev_desc, char *str_disk_guid,
+               disk_partition_t *partitions, const int parts_count);
+#endif
+
+#endif /* _PART_H */