]> git.sur5r.net Git - u-boot/blobdiff - include/part.h
net: pcnet: refactor mapping of virtual addresses to physical ones
[u-boot] / include / part.h
index 8ea9b3049a4989daa02fa06dda99f3f00232f47b..4d00e220e4c8867c6312044c05a497ec77aaf262 100644 (file)
 #include <ide.h>
 #include <common.h>
 
-typedef struct block_dev_desc {
+typedef struct block_dev_desc block_dev_desc_t;
+
+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   hwpart;         /* HW partition, e.g. for eMMC */
        unsigned char   type;           /* device type */
        unsigned char   removable;      /* removable device */
 #ifdef CONFIG_LBA48
@@ -27,19 +30,19 @@ typedef struct block_dev_desc {
        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   (*block_read)(block_dev_desc_t *block_dev,
                                      lbaint_t start,
                                      lbaint_t blkcnt,
                                      void *buffer);
-       unsigned long   (*block_write)(int dev,
+       unsigned long   (*block_write)(block_dev_desc_t *block_dev,
                                       lbaint_t start,
                                       lbaint_t blkcnt,
                                       const void *buffer);
-       unsigned long   (*block_erase)(int dev,
+       unsigned long   (*block_erase)(block_dev_desc_t *block_dev,
                                       lbaint_t start,
                                       lbaint_t blkcnt);
        void            *priv;          /* driver private struct pointer */
-}block_dev_desc_t;
+};
 
 #define BLOCK_CNT(size, block_dev_desc) (PAD_COUNT(size, block_dev_desc->blksz))
 #define PAD_TO_BLOCKSIZE(size, block_dev_desc) \
@@ -93,6 +96,9 @@ typedef struct disk_partition {
 #ifdef CONFIG_PARTITION_UUIDS
        char    uuid[37];       /* filesystem UUID as string, if exists */
 #endif
+#ifdef CONFIG_PARTITION_TYPE_GUID
+       char    type_guid[37];  /* type GUID as string, if exists       */
+#endif
 } disk_partition_t;
 
 /* Misc _get_dev functions */
@@ -264,6 +270,41 @@ int is_valid_gpt_buf(block_dev_desc_t *dev_desc, void *buf);
  * @return - '0' on success, otherwise error
  */
 int write_mbr_and_gpt_partitions(block_dev_desc_t *dev_desc, void *buf);
+
+/**
+ * gpt_verify_headers() - Function to read and CRC32 check of the GPT's header
+ *                        and partition table entries (PTE)
+ *
+ * As a side effect if sets gpt_head and gpt_pte so they point to GPT data.
+ *
+ * @param dev_desc - block device descriptor
+ * @param gpt_head - pointer to GPT header data read from medium
+ * @param gpt_pte - pointer to GPT partition table enties read from medium
+ *
+ * @return - '0' on success, otherwise error
+ */
+int gpt_verify_headers(block_dev_desc_t *dev_desc, gpt_header *gpt_head,
+                      gpt_entry **gpt_pte);
+
+/**
+ * gpt_verify_partitions() - Function to check if partitions' name, start and
+ *                           size correspond to '$partitions' env variable
+ *
+ * This function checks if on medium stored GPT data is in sync with information
+ * provided in '$partitions' environment variable. Specificially, name, start
+ * and size of the partition is checked.
+ *
+ * @param dev_desc - block device descriptor
+ * @param partitions - partition data read from '$partitions' env variable
+ * @param parts - number of partitions read from '$partitions' env variable
+ * @param gpt_head - pointer to GPT header data read from medium
+ * @param gpt_pte - pointer to GPT partition table enties read from medium
+ *
+ * @return - '0' on success, otherwise error
+ */
+int gpt_verify_partitions(block_dev_desc_t *dev_desc,
+                         disk_partition_t *partitions, int parts,
+                         gpt_header *gpt_head, gpt_entry **gpt_pte);
 #endif
 
 #endif /* _PART_H */