1 /* 2 * drivers/block/sun4i_nand/nfd/mbr.h 3 * 4 * (C) Copyright 2007-2012 5 * Allwinner Technology Co., Ltd. <www.allwinnertech.com> 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License as 9 * published by the Free Software Foundation; either version 2 of 10 * the License, or (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 20 * MA 02111-1307 USA 21 */ 22 23 #ifndef __MBR_H__ 24 #define __MBR_H__ 25 26 #include "types.h" 27 28 #define MBR_MAGIC "softw311" 29 #define MBR_VERSION 0x100 30 #define nand_part nand_part_a10 31 #define checkmbrs checkmbrs_a10 32 33 #define MAX_PART_COUNT 15 //max part count 34 #define MBR_COPY_NUM 4 //mbr backup count 35 36 #define MBR_START_ADDRESS 0x0 //mbr start address 37 #define MBR_SIZE 1024 //mbr size 38 #define MBR_RESERVED (MBR_SIZE - 20 - (MAX_PART_COUNT * 64)) //mbr reserved space 39 40 // extern struct __NandDriverGlobal_t NandDriverInfo; 41 42 // extern struct __NandStorageInfo_t NandStorageInfo; 43 44 #define DiskSize (SECTOR_CNT_OF_SINGLE_PAGE * PAGE_CNT_OF_PHY_BLK * BLOCK_CNT_OF_DIE * \ 45 DIE_CNT_OF_CHIP * NandStorageInfo.ChipCnt / 1024 * DATA_BLK_CNT_OF_ZONE) 46 47 48 struct nand_disk{ 49 unsigned long size; 50 unsigned long offset; 51 unsigned char type; 52 }; 53 54 /* part info */ 55 typedef struct tag_PARTITION{ 56 __u32 addrhi; //start address high 32 bit 57 __u32 addrlo; //start address low 32 bit 58 __u32 lenhi; //size high 32 bit 59 __u32 lenlo; //size low 32 bit 60 __u8 classname[12]; //major device name 61 __u8 name[12]; //minor device name 62 unsigned int user_type; //标志当前盘符所属于的用户 63 unsigned int ro; //标志当前盘符的读写属性 64 __u8 res[16]; //reserved 65 }PARTITION; 66 67 /* mbr info */ 68 typedef struct tag_MBR{ 69 __u32 crc32; // crc, from byte 4 to mbr tail 70 __u32 version; // version 71 __u8 magic[8]; // magic number 72 __u8 copy; // mbr backup count 73 __u8 index; // current part no 74 __u16 PartCount; // part counter 75 PARTITION array[MAX_PART_COUNT];// part info 76 __u8 res[MBR_RESERVED]; // reserved space 77 }MBR; 78 79 int mbr2disks(struct nand_disk* disk_array); 80 81 #endif //__MBR_H__ 82