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 20 #ifndef __MBR_H__ 21 #define __MBR_H__ 22 23 // #include <mod_defs.h> 24 25 #define MAX_PART_COUNT 8 // max part count 26 #define MBR_COPY_NUM 4 // mbr backup count 27 28 #define MBR_START_ADDRESS 0x0 // mbr start address 29 #define MBR_SIZE 1024 // mbr size 30 #define MBR_RESERVED (MBR_SIZE - 20 - (MAX_PART_COUNT * 64)) // mbr reserved space 31 32 // part information 33 typedef struct tag_PARTITION 34 { 35 __u32 addrhi; // start address high 32 bit 36 __u32 addrlo; // start address low 32 bit 37 __u32 lenhi; // size high 32 bit 38 __u32 lenlo; // size low 32 bit 39 __u8 classname[12]; // major device name 40 __u8 name[12]; // minor device name 41 __u8 res[24]; // reserved 42 } PARTITION; // 64 bytes 应该使用 pack 43 44 // mbr information 45 typedef struct tag_MBR 46 { 47 __u32 crc32; // crc, from byte 4 to mbr tail 48 __u32 version; // version 49 __u8 magic[8]; // magic number 50 __u8 copy; // mbr backup count 51 __u8 index; // current part no 52 __u16 PartCount; // part counter 53 PARTITION array[MAX_PART_COUNT]; // part info 54 __u8 res[MBR_RESERVED]; // reserved space 55 } MBR; 56 57 #define SUNXI_MBR_SIZE (16 * 1024) 58 #define SUNXI_MBR_MAX_PART_COUNT 120 59 /* partition information */ 60 typedef struct sunxi_partition_t 61 { 62 unsigned int addrhi; 63 unsigned int addrlo; 64 unsigned int lenhi; 65 unsigned int lenlo; 66 unsigned char classname[16]; 67 unsigned char name[16]; 68 unsigned int user_type; 69 unsigned int keydata; 70 unsigned int ro; 71 unsigned int sig_verify; 72 unsigned int sig_erase; 73 unsigned int sig_value[4]; 74 unsigned int sig_pubkey; 75 unsigned int sig_pbumode; 76 unsigned char reserved2[36]; 77 }__attribute__ ((packed))sunxi_partition; 78 79 /* mbr information */ 80 typedef struct sunxi_mbr 81 { 82 unsigned int crc32; // crc 1k - 4 83 unsigned int version; // 版本信息, 0x00000100 84 unsigned char magic[8]; //"softw311" 85 unsigned int copy; //分数 86 unsigned int index; //第几个MBR备份 87 unsigned int PartCount; //分区个数 88 unsigned int stamp[1]; //对齐 89 sunxi_partition array[SUNXI_MBR_MAX_PART_COUNT]; // 90 unsigned int lockflag; 91 unsigned char res[(SUNXI_MBR_SIZE - 32 - 4 - (SUNXI_MBR_MAX_PART_COUNT * sizeof(sunxi_partition)))]; 92 }__attribute__ ((packed)) sunxi_mbr_t; 93 94 #endif // __MBR_H__ 95