File: nand-part-a20.h

package info (click to toggle)
sunxi-tools 1.4.1-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 520 kB
  • ctags: 959
  • sloc: ansic: 6,136; makefile: 133; asm: 120; sh: 67
file content (83 lines) | stat: -rw-r--r-- 3,357 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/*
 * drivers/block/sun4i_nand/nfd/mbr.h
 *
 * (C) Copyright 2007-2012
 * Allwinner Technology Co., Ltd. <www.allwinnertech.com>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of
 * the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 * MA 02111-1307 USA
 */

#ifndef    __MBR_H__
#define    __MBR_H__

#include "types.h"

#define MBR_MAGIC "softw411"
#define MBR_VERSION 0x200
#define nand_part nand_part_a20
#define checkmbrs checkmbrs_a20

#define MAX_PART_COUNT		120	 									//max part count
#define MBR_COPY_NUM        4    									//mbr backup count

#define MBR_START_ADDRESS	0x0										//mbr start address
#define MBR_SIZE			1024*16									//mbr size
#define MBR_RESERVED        (MBR_SIZE - 32 - (MAX_PART_COUNT * 128)) //mbr reserved space

// extern struct __NandDriverGlobal_t NandDriverInfo;

// extern struct __NandStorageInfo_t  NandStorageInfo;

#define DiskSize  (SECTOR_CNT_OF_SINGLE_PAGE * PAGE_CNT_OF_PHY_BLK * BLOCK_CNT_OF_DIE * \
            DIE_CNT_OF_CHIP * NandStorageInfo.ChipCnt  / 1024 * DATA_BLK_CNT_OF_ZONE)


struct nand_disk{
	unsigned long size;
	unsigned long offset;
	unsigned char type;
};

/* part info */
typedef struct nand_tag_PARTITION{
        unsigned  int       addrhi;                             //起始地址, 以扇区为单位       
        unsigned  int       addrlo;                             //     
        unsigned  int       lenhi;                              //长度 
        unsigned  int       lenlo;                              //     
        unsigned  char      classname[16];              //次设备名     
        unsigned  char      name[16];                   //主设备名     
        unsigned  int       user_type;          //用户类型     
        unsigned  int       keydata;            //关键数据,要求量产不丢失     
        unsigned  int       ro;                 //读写属性     
        unsigned  char      res[68];               //保留数据,匹配分区信息128字节
}__attribute__ ((packed))PARTITION;

/* mbr info */
typedef struct nand_tag_MBR{
        unsigned  int       crc32;                      // crc 1k - 4
        unsigned  int       version;                    // 版本信息, 0x00000100
        unsigned  char      magic[8];                   //"softw411"
        unsigned  int       copy;                       //分数
        unsigned  int       index;                      //第几个MBR备份
        unsigned  int       PartCount;                  //分区个数
        unsigned  int       stamp[1];                   //对齐
        PARTITION        array[MAX_PART_COUNT];  //
        unsigned  char      res[MBR_RESERVED];
}__attribute__ ((packed)) MBR;

int mbr2disks(struct nand_disk* disk_array);

#endif    //__MBR_H__