usb_massstorage.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. #ifndef __USB_MASS_STORAGE_H
  2. #define __USB_MASS_STORAGE_H
  3. /* Part types */
  4. #define PART_TYPE_UNKNOWN 0x00
  5. #define PART_TYPE_MAC 0x01
  6. #define PART_TYPE_DOS 0x02
  7. #define PART_TYPE_ISO 0x03
  8. #define PART_TYPE_AMIGA 0x04
  9. #define PART_TYPE_EFI 0x05
  10. /* device types */
  11. #define DEV_TYPE_UNKNOWN 0xff /* not connected */
  12. #define DEV_TYPE_HARDDISK 0x00 /* harddisk */
  13. #define DEV_TYPE_TAPE 0x01 /* Tape */
  14. #define DEV_TYPE_CDROM 0x05 /* CD-ROM */
  15. #define DEV_TYPE_OPDISK 0x07 /* optical disk */
  16. #define PART_NAME_LEN 32
  17. #define PART_TYPE_LEN 32
  18. #define MAX_SEARCH_PARTITIONS 64
  19. typedef unsigned long lbaint_t;
  20. typedef struct {
  21. u8 b[16];
  22. } efi_guid_t;
  23. /* Interface types: */
  24. enum if_type {
  25. IF_TYPE_UNKNOWN = 0,
  26. IF_TYPE_IDE,
  27. IF_TYPE_SCSI,
  28. IF_TYPE_ATAPI,
  29. IF_TYPE_USB,
  30. IF_TYPE_DOC,
  31. IF_TYPE_MMC,
  32. IF_TYPE_SD,
  33. IF_TYPE_SATA,
  34. IF_TYPE_HOST,
  35. IF_TYPE_NVME,
  36. IF_TYPE_EFI,
  37. IF_TYPE_COUNT, /* Number of interface types */
  38. };
  39. #define BLK_VEN_SIZE 40
  40. #define BLK_PRD_SIZE 20
  41. #define BLK_REV_SIZE 8
  42. /*
  43. * Identifies the partition table type (ie. MBR vs GPT GUID) signature
  44. */
  45. enum sig_type {
  46. SIG_TYPE_NONE,
  47. SIG_TYPE_MBR,
  48. SIG_TYPE_GUID,
  49. SIG_TYPE_COUNT /* Number of signature types */
  50. };
  51. /*
  52. * With driver model (CONFIG_BLK) this is uclass platform data, accessible
  53. * with dev_get_uclass_platdata(dev)
  54. */
  55. struct blk_desc {
  56. /*
  57. * TODO: With driver model we should be able to use the parent
  58. * device's uclass instead.
  59. */
  60. enum if_type if_type; /* type of the interface */
  61. int devnum; /* device number */
  62. unsigned char part_type; /* partition type */
  63. unsigned char target; /* target SCSI ID */
  64. unsigned char lun; /* target LUN */
  65. unsigned char hwpart; /* HW partition, e.g. for eMMC */
  66. unsigned char type; /* device type */
  67. unsigned char removable; /* removable device */
  68. lbaint_t lba; /* number of blocks */
  69. unsigned long blksz; /* block size */
  70. int log2blksz; /* for convenience: log2(blksz) */
  71. char vendor[BLK_VEN_SIZE + 1]; /* device vendor string */
  72. char product[BLK_PRD_SIZE + 1]; /* device product number */
  73. char revision[BLK_REV_SIZE + 1]; /* firmware revision */
  74. enum sig_type sig_type; /* Partition table signature type */
  75. union {
  76. u32 mbr_sig; /* MBR integer signature */
  77. efi_guid_t guid_sig; /* GPT GUID Signature */
  78. };
  79. unsigned long (*block_read)(struct blk_desc *block_dev,
  80. lbaint_t start,
  81. lbaint_t blkcnt,
  82. void *buffer);
  83. unsigned long (*block_write)(struct blk_desc *block_dev,
  84. lbaint_t start,
  85. lbaint_t blkcnt,
  86. const void *buffer);
  87. unsigned long (*block_erase)(struct blk_desc *block_dev,
  88. lbaint_t start,
  89. lbaint_t blkcnt);
  90. void *priv; /* driver private struct pointer */
  91. void *disk_priv;
  92. };
  93. extern struct blk_desc usb_dev_desc[6];
  94. #endif