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 "softw411" 29 #define MBR_VERSION 0x200 30 #define nand_part nand_part_a20 31 #define checkmbrs checkmbrs_a20 32 33 #define MAX_PART_COUNT 120 //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*16 //mbr size 38 #define MBR_RESERVED (MBR_SIZE - 32 - (MAX_PART_COUNT * 128)) //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 nand_tag_PARTITION{ 56 unsigned int addrhi; //起始地址, 以扇区为单位 57 unsigned int addrlo; // 58 unsigned int lenhi; //长度 59 unsigned int lenlo; // 60 unsigned char classname[16]; //次设备名 61 unsigned char name[16]; //主设备名 62 unsigned int user_type; //用户类型 63 unsigned int keydata; //关键数据,要求量产不丢失 64 unsigned int ro; //读写属性 65 unsigned char res[68]; //保留数据,匹配分区信息128字节 66 }__attribute__ ((packed))PARTITION; 67 68 /* mbr info */ 69 typedef struct nand_tag_MBR{ 70 unsigned int crc32; // crc 1k - 4 71 unsigned int version; // 版本信息, 0x00000100 72 unsigned char magic[8]; //"softw411" 73 unsigned int copy; //分数 74 unsigned int index; //第几个MBR备份 75 unsigned int PartCount; //分区个数 76 unsigned int stamp[1]; //对齐 77 PARTITION array[MAX_PART_COUNT]; // 78 unsigned char res[MBR_RESERVED]; 79 }__attribute__ ((packed)) MBR; 80 81 int mbr2disks(struct nand_disk* disk_array); 82 83 #endif //__MBR_H__ 84