mbr.h 3.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /*
  2. ****************************************************************************************************
  3. * MELIS
  4. * the Easy Portable/Player Develop Kits
  5. * SDMMC Module
  6. *
  7. * (c) Copyright 2011-2014, All winners Co,Ld.
  8. * All Rights Reserved
  9. *
  10. * File : mbr.h
  11. * By : james.deng
  12. * Version : 1.0.0
  13. * Date : 2011-11-28
  14. * Descript:
  15. * Update : <date> <author> <version> <notes>
  16. * 2011-11-28 james.deng 1.0.0 build the file.
  17. ****************************************************************************************************
  18. */
  19. #ifndef __MBR_H__
  20. #define __MBR_H__
  21. // #include <mod_defs.h>
  22. #define MAX_PART_COUNT 8 // max part count
  23. #define MBR_COPY_NUM 4 // mbr backup count
  24. #define MBR_START_ADDRESS 0x0 // mbr start address
  25. #define MBR_SIZE 1024 // mbr size
  26. #define MBR_RESERVED (MBR_SIZE - 20 - (MAX_PART_COUNT * 64)) // mbr reserved space
  27. // part information
  28. typedef struct tag_PARTITION
  29. {
  30. __u32 addrhi; // start address high 32 bit
  31. __u32 addrlo; // start address low 32 bit
  32. __u32 lenhi; // size high 32 bit
  33. __u32 lenlo; // size low 32 bit
  34. __u8 classname[12]; // major device name
  35. __u8 name[12]; // minor device name
  36. __u8 res[24]; // reserved
  37. } PARTITION; // 64 bytes 应该使用 pack
  38. // mbr information
  39. typedef struct tag_MBR
  40. {
  41. __u32 crc32; // crc, from byte 4 to mbr tail
  42. __u32 version; // version
  43. __u8 magic[8]; // magic number
  44. __u8 copy; // mbr backup count
  45. __u8 index; // current part no
  46. __u16 PartCount; // part counter
  47. PARTITION array[MAX_PART_COUNT]; // part info
  48. __u8 res[MBR_RESERVED]; // reserved space
  49. } MBR;
  50. #define SUNXI_MBR_SIZE (16 * 1024)
  51. #define SUNXI_MBR_MAX_PART_COUNT 120
  52. /* partition information */
  53. typedef struct sunxi_partition_t
  54. {
  55. unsigned int addrhi;
  56. unsigned int addrlo;
  57. unsigned int lenhi;
  58. unsigned int lenlo;
  59. unsigned char classname[16];
  60. unsigned char name[16];
  61. unsigned int user_type;
  62. unsigned int keydata;
  63. unsigned int ro;
  64. unsigned int sig_verify;
  65. unsigned int sig_erase;
  66. unsigned int sig_value[4];
  67. unsigned int sig_pubkey;
  68. unsigned int sig_pbumode;
  69. unsigned char reserved2[36];
  70. }__attribute__ ((packed))sunxi_partition;
  71. /* mbr information */
  72. typedef struct sunxi_mbr
  73. {
  74. unsigned int crc32; // crc 1k - 4
  75. unsigned int version; // 版本信息, 0x00000100
  76. unsigned char magic[8]; //"softw311"
  77. unsigned int copy; //分数
  78. unsigned int index; //第几个MBR备份
  79. unsigned int PartCount; //分区个数
  80. unsigned int stamp[1]; //对齐
  81. sunxi_partition array[SUNXI_MBR_MAX_PART_COUNT]; //
  82. unsigned int lockflag;
  83. unsigned char res[(SUNXI_MBR_SIZE - 32 - 4 - (SUNXI_MBR_MAX_PART_COUNT * sizeof(sunxi_partition)))];
  84. }__attribute__ ((packed)) sunxi_mbr_t;
  85. #endif // __MBR_H__