⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 _dochapi.h

📁 H3 M-system NAND flash driver in Linux OS, M-DOC driver
💻 H
📖 第 1 页 / 共 5 页
字号:

/*Partition Attribute1 Bits*/
#define	DOCH_PA1B_PARTITION_TYPE	0x000000FF
#define	DOCH_PA1B_PERFORMANCE_CTRL	0x00000F00
#define	DOCH_PA1B_PAGE_SIZE_EXP		0x000F0000
#define	DOCH_PA1B_HASH_TYPE			0x3F000000

/*Partition Attribute2 Offsets*/
#define	DOCH_PA2O_PROTECTION_TYPE	0
#define	DOCH_PA2O_USER_MODE			6
#define	DOCH_PA2O_GUEST_MODE		9
#define	DOCH_PA2O_MASTER_CTRL		12
#define	DOCH_PA2O_ENCRYPT_TYPE		15
#define	DOCH_PA2O_OTP_BIT			21
#define	DOCH_PA2O_LOCK_CTRL			22
#define	DOCH_PA2O_MAX_AUTH_ATTEMPTS 24

/*Partition Attribute2 Bits*/
#define	DOCH_PA2B_PROTECTION_TYPE	0x00000007		/*DOCH_ProtectionType*/
#define	DOCH_PA2B_USER_MODE			0x000001C0		/*DOCH_PartitionAccessMode*/
#define	DOCH_PA2B_GUEST_MODE		0x00000E00		/*DOCH_PartitionAccessMode*/
#define	DOCH_PA2B_MASTER_CTRL		0x00007000		/*DOCH_PartitionAccessMode*/
#define	DOCH_PA2B_ENCRYPT_TYPE		0x00038000		/*DOCH_EncryptType*/
#define	DOCH_PA2B_OTP_BIT			0x00200000
#define	DOCH_PA2B_LOCK_CTRL			0x00C00000		/*DOCH_LockControl*/
#define	DOCH_PA2B_MAX_AUTH_ATTEMPTS	0x0F000000

/*	Structure that holds various partition data*/
typedef struct {
	FLByte  bDevice;		/*On which device (0/1) the partition reside*/
} DOCH_PartitionAttr;

/*Partition formatting info*/

/*API exported for partition preporties*/
typedef struct {
	FLDword		dwProtectionType;		/*DOCH_ProtectionType*/
	FLDword		dwUserAccessMode;		/*DOCH_PartitionAccessMode*/
	FLDword		dwGuestAccessMode;		/*DOCH_PartitionAccessMode*/
	FLDword		dwMasterControl;		/*DOCH_PartitionAccessMode*/
	FLDword		dwEncryptionType;		/*DOCH_EncryptType*/
	FLDword		dwLockControl;			/*DOCH_LockControl*/
	FLDword		dwMaxNumOfAuthAttempts;	/*0 = Unlimited number*/
	FLByte		bPasskey[0x80];			/*ASCII*/
} DOCH_PartitionProtectionAPI;

typedef enum {
	DOCH_PASSKEY_VALID		= 0x01,		/* Passkey in DOCH_PartitionProtectionAPI is valid */
	DOCH_ATTRIBUTES_VALID	= 0x02,		/* All attributes in DOCH_PartitionProtectionAPI besides passkey are valid */
	DOCH_LOCK_AS_OTP		= 0x04		/* Lock the partition for writing */
} DOCH_PartitionProtectioValidity;

/*Partition Info structure*/

typedef struct {
	FLByte			bReserved1[0x4];
	FLDword			dwCommandFlagsOrStatuses;			/*Dynamic info*/
	FLDword			partitionAttributes1;
	FLDword			partitionAttributes2;
	FLDword			nPartitionSize;						/*In Sectors*/
	FLDword			nFastAreaSize;						/*In Sectors or Percent. for IPL partition: size reported in XIP*/
	FLWord			wFastAreaFactor;					/*Exponent*/
	FLByte			bReserved2[0x2];
	FLDword			wPartitionStartSector;
	FLWord			wCurrentSectorsPerTrack;
	FLWord			wDefaultSectorsPerTrack;
	FLWord			wCurrentCylinders;
	FLWord			wDefaultCylinders;
	FLWord			wCurrentHeads;
	FLWord			wDefaultHeads;
	FLByte			bReserved3[0x14];
	FLWord			wFastAreaSectorsInErasableUnit;		/*Exponent*/
	FLWord			wNormalAreaSectorsInErasableUnit;	/*Exponent*/
	FLWord			wRecommendedSectorsPerCluster;
	FLWord			wFastMaxRelatedSectors;
	FLWord			wNormalMaxRelatedSectors;
	FLByte			bReserved4[0xB6];
	FLByte			bPartitionKey[0x80];
	FLByte			bReserved5[0x80];
} DOCH_PartitionInfo;

typedef struct {
	FLDword		dwPartitionType;		/*DCOH_PartitionType*/
	FLDword		dwPerformanceControl;	/*DOCH_PerformanceControl*/
	FLDword		dwPageSizeExp;			/*DOCH_PageSizeExp*/
	FLDword		dwHashType;				/*DOCH_HashType*/
	FLDword		dwFastAreaSizeType;		/*DOCH_FastAreaType*/
	FLDword		dwProtectionType;		/*DOCH_ProtectionType*/
	FLDword		dwUserAccessMode;		/*DOCH_PartitionAccessMode*/
	FLDword		dwGuestAccessMode;		/*DOCH_PartitionAccessMode*/
	FLDword		dwMasterControl;		/*DOCH_PartitionAccessMode*/
	FLDword		dwEncryptionType;		/*DOCH_EncryptType*/
	FLDword		dwLockControl;			/*DOCH_LockControl*/
	FLDword		dwOtpEnabled;			/*DOCH_OTPBit*/
	FLDword		dwMaxNumOfAuthAttempts;	/*0 = Unlimited number*/
	FLNative	nPartitionSize;			/*In Sectors*/
	FLNative	nFastAreaSize;			/*In Sectors or Percent**/
	FLWord		wFastAreaFactor;		/*Exponent*/
	FLByte		bPasskey[0x80];			/*ASCII*/
} DOCH_PartitionFormatInfoAPI;

/*Partition formatting info*/
typedef struct {
	FLByte			bReserved1[0x4];
	FLDword			dwCommandFlagsOrStatuses;
	FLDword			partitionAttributes1;
	FLDword			partitionAttributes2;
	FLDword			nPartitionSize;					/*In Sectors*/
	FLDword			nFastAreaSize;					/*In Sectors or Percent*/
	FLWord			wFastAreaFactor;				/*Exponent*/
	FLByte			bReserved2[0x12];
	FLDword			dwValidity;						/*DOCH_PartitionProtectioValidity*/
	FLByte			bReserved3[0xD0];
	FLByte			bPasskey[0x80];
	FLByte			bReserved4[0x80];
} DOCH_PartitionFormatInfo;

/*Device dwCommandFlagsOrStatuses Offsets*/
#define	DOCH_DCFSO_CURRENT_XFER_MODE	0
#define	DOCH_DCFSO_CURRENT_MULTI_SECTOR	8
#define	DOCH_DCFSO_HW_LOCK_ASSERTED		30
#define	DOCH_DCFSO_SW_LOCK_ASSERTED		31

/*Device dwCommandFlagsOrStatuses Bits*/
#define	DOCH_DCFSB_CURRENT_XFER_MODE	0x00000007
#define	DOCH_DCFSB_CURRENT_MULTI_SECTOR	0x00000F00
#define	DOCH_DCFSB_HW_LOCK_ASSERTED		0x40000000
#define	DOCH_DCFSB_SW_LOCK_ASSERTED		0x80000000

/*Device Attributes1 Offsets*/
#define	DOCH_DA1O_SUPPORTED_XFER_MODES_BMP	0
#define	DOCH_DA1O_MAX_MULTI_SEC_XFER_SIZE	8
#define	DOCH_DA1O_SUPPORT_48_BITS			31

/*Device Attributes1 Bits*/
#define	DOCH_DA1B_SUPPORTED_XFER_MODES_BMP	0x000000FF
#define	DOCH_DA1B_MAX_MULTI_SEC_XFER_SIZE	0x00000F00
#define	DOCH_DA1B_SUPPORT_48_BITS			0x80000000

/*Gate Keeper Attributes Offsets*/
#define	DOCH_DA2O_AUTH_TYPE			0		/*DOCH_DeviceAuthType*/
#define	DOCH_DA2O_GUEST_ACCESS_MODE	9		/*DOCH_DeviceAccessMode*/
#define	DOCH_DA2O_MASTER_CONTROL	12		/*DOCH_DeviceAccessMode*/
#define	DOCH_DA2O_MAX_AUTH_ATTEMPTS	24

/*Gate Keeper Attributes Bits*/
#define	DOCH_DA2B_AUTH_TYPE			0x00000003
#define	DOCH_DA2B_GUEST_ACCESS_MODE	0x00000E00
#define	DOCH_DA2B_MASTER_CONTROL	0x00007000
#define	DOCH_DA2B_MAX_AUTH_ATTEMPTS	0x0F000000

/*Authentication types*/
typedef enum {
	DOCH_DEVICE_AUTH_NONE	= 0,
	DOCH_DEVICE_AUTH_PWD	= 1,
	DOCH_DEVICE_AUTH_RSA	= 2
} DOCH_DeviceAuthType;
/*Access modes*/
typedef enum {
	DOCH_DEVICE_ACCESS_MODE_FULL	= 0,
	DOCH_DEVICE_ACCESS_MODE_RO		= 1,
	DOCH_DEVICE_ACCESS_MODE_NONE	= 2
} DOCH_DeviceAccessMode;

#define DOCH_CONFIGURATION_EXISTS_SIGN	0x1F2E3D4C

typedef struct {
	FLWord		wVersion;
	FLWord		wVersionCompatability;
	FLDword		dwCommandFlagsOrStatuses;
	FLDword		dwDiskAttributes1;
	FLDword		dwRservedGateKeeperAttr;
	FLDword		dwMiscFlags;
	FLByte		bReserved2[0xC];
	FLByte		bUniqueID[0x10];
	FLByte		bReserved3[0x10];
	FLByte		bSerialNumber[0x14];
	FLByte		bModelNumber[0x28];
	FLWord		wTotalNumOfPartitions;			/*0=IPL not present, 1=Only IPL Present, ... 16=IPL partition + 15 user partitions (MAX)*/
	FLWord		wDefaultPartitionNumber;
	FLDword		dwUnformattedCapacity;			/*In Sectors*/
	FLDword		dwConfigurationPartitionExistsSign;
	FLDword		dwETFFSVER;
	FLDword		dwReservedConfigPartitionSize;	/*In Sectors*/
	FLByte		bProgrammerName[0x10];
	FLByte		bProgrammerVersion[0x8];
	FLDword		dwUnitSize;						/* In Sectors */
	FLByte		bReserved5[0x54];				/*In Sectors*/
	FLByte		bReservedGateKeeperKey[0x80];
	FLByte		bReserved6[0x80];
} DOCH_DeviceInfo;

/*Enums*/
/*=====*/
typedef enum { DOCH_PRT_TYPE_NORMAL					= 0,	/*normal*/
			   DOCH_PRT_TYPE_PAGED					= 1,	/*paged*/
			   DOCH_PRT_TYPE_PAGED_DIGEST			= 2,	/*paged + keeps digest information*/
			   DOCH_PRT_TYPE_PAGED_COMPRESSED		= 3,	/*paged + keeps data in compressed form */
			   DOCH_PRT_TYPE_PAGED_DIGEST_COMPRESSED= 4		/*paged + keeps data in compressed form + digest*/
} DCOH_PartitionType;


/*Performance Control*/
typedef enum { DOCH_NORMAL_PERFORMANCE	= 0,	/*MLC*/
			   DOCH_FIRM_FLASH_OPTIMIZE	= 1,	/*Rigid MLC/SLC division, fast area field defines division*/
			   DOCH_FLEXI_FLASH_OPTIMIZE= 2		/*Adaptive MLC/SLC division, fast area field defines size of spare capacity for performance optimization*/
} DOCH_PerformanceControl;

/*Page size exponent (for paged partitions)*/
typedef enum { DOCH_PAGE_SIZE_512B	= 0,
			   DOCH_PAGE_SIZE_1KB	= 1,
			   DOCH_PAGE_SIZE_2KB	= 2,
			   DOCH_PAGE_SIZE_4KB	= 3,
			   DOCH_PAGE_SIZE_8KB	= 4,
			   DOCH_PAGE_SIZE_16KB	= 5,
			   DOCH_PAGE_SIZE_32KB	= 6
} DOCH_PageSizeExp;

/*Page size exponent (for paged partitions)*/
typedef enum { DOCH_HASH_TYPE_SHA1	= 0
} DOCH_HashType;

/*Fast Area Type*/
typedef enum { DOCH_FAST_AREA_TYPE_SECTORS	= 0,
			   DOCH_FAST_AREA_TYPE_PERCENT	= 1
} DOCH_FastAreaType;

/*Protection Type*/
typedef enum { DOCH_PARTITION_NOT_PROTECTED	= 0,
			   DOCH_PARTITION_PWD_PROTECTED	= 1,
			   DOCH_PARTITION_RSA_PROTECTED	= 2
} DOCH_ProtectionType;

#define DOCH_MAX_PWD_ATTEMPTS	5	/*"0" for Unlimited # of attempts*/

/*Partition access mode*/
typedef enum {
	DOCH_PART_ACCESS_MODE_FULL	= 0,
	DOCH_PART_ACCESS_MODE_RO	= 1,
	DOCH_PART_ACCESS_MODE_NONE	= 2
} DOCH_PartitionAccessMode;

/*Encryption Type*/
typedef enum { DOCH_ENCRYPT_NONE	= 0,	/*Partition is not encrypted*/
			   DOCH_ENCRYPT_AES_CTR	= 1,	/*Partition is AES-encrypted, CTR mode*/
			   DOCH_ENCRYPT_RC4		= 2		/*Partition is RC4-encrypted*/
} DOCH_EncryptType;


/*Lock Control*/
typedef enum { DOCH_LOCK_NOT_ACTIVE	= 0,/*LOCK# signal or soft-lock do not affect the access to this partition*/
			   DOCH_LOCK_ACTIVE		= 1 /*After LOCK# signal is active or soft-lock is written, access to partition*/
										/*can not be authenticated. If access has already been authenticated, it remains*/
} DOCH_LockControl;

/*OTP Bit*/
typedef enum { DOCH_OTP_BIT_OFF	= 0,
			   DOCH_OTP_BIT_ON	= 1
} DOCH_OTPBit;

typedef enum {
	PARTITION_TYPE_IPL		= 0x00,
	PARTITION_TYPE_BDTL		= 0x01,
	PARTITION_TYPE_BINARY	= 0x02,
	PARTITION_TYPE_OTP		= 0x03
} DOCH_PartitionType;

/******************************************************************************/
/*
 *	Partition Access structure
 */
/******************************************************************************/

/*Structure for DOCH_VSCMD_EXT_DEVICE_CTRL::DOCH_SET_PARTITION_PROTECTION
  and DOCH_VSCMD_EXT_SECURITY_CTRL::DOCH_EN_ACCESS_WPWD*/
typedef struct {
	FLByte bReserved1[0x100];
	FLByte bPassword[0x80];
	FLByte bReserved2[0x80];
} DOCH_PartitionAcessPassword;

/******************************************************************************/
/*
 *	PKI structures
 */
/******************************************************************************/

#define DOCH_CHLNG_SIZE		0x40
#define DOCH_PKI_KEY_SIZE	0x80

/*Structure for DOCH_VSCMD_EXT_SECURITY_CTRL::DOCH_TX_HOST_PUBLICKEY*/
typedef struct {
	FLWord wVersion;
	FLByte bReserved1[0xBE];
	FLByte bHostRandomChallange[DOCH_CHLNG_SIZE];
	FLByte bHostPublicKey[DOCH_PKI_KEY_SIZE];
	FLByte bReservedForLargerKey[0x80];
} DOCH_HostPublicKey;

/*Structure for DOCH_VSCMD_EXT_SECURITY_CTRL::DOCH_RX_DOCH_PUBLICKEY*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -