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

📄 doch_ata.h

📁 电子盘DEMO板程序
💻 H
📖 第 1 页 / 共 2 页
字号:
/******************************************************************************/
/*                                                                            */
/*  Copyright (C), 1995-2006, msystems Ltd. All rights reserved.              */
/*                                                                            */
/*  Redistribution and use in source and binary forms, with or without        */
/*  modification, are permitted provided that the following conditions are    */
/*  met:                                                                      */
/*  1. Redistributions of source code must retain the above copyright notice, */
/*     this list of conditions and the following disclaimer.                  */
/*  2. Redistributions in binary form must reproduce the above copyright      */
/*     notice, this list of conditions and the following disclaimer in the    */
/*     documentation and/or other materials provided with the distribution.   */
/*  3. Neither the name of msystems nor the names of its contributors may be  */
/*     used to endorse or promote products derived from this software without */
/*     specific prior written permission.                                     */
/*                                                                            */
/*  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS       */
/*  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
/*  TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR             */
/*  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT      */
/*  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,     */
/*  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED  */
/*  TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR    */
/*  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF    */
/*  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING      */
/*  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS        */
/*  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
/*                                                                            */
/******************************************************************************/
/***********************************************************************************/
/*																				   */
/*	Header file for doch_ata module												   */ 
/*																				   */
/***********************************************************************************/

/*
 * $Log:   V:/PVCSDB/DiskOnChip/archives/Test for 7.x/src/H3/doch_ata.h-arc  $
 * 
 *    Rev 1.31   Sep 11 2006 13:45:16   yaniv.iarovici
 * Legal header added
 * 
 *    Rev 1.30   Aug 22 2006 13:23:54   Yaniv.Iarovici
 * Add 'extern "c"' on flExit() definition
 * 	- extern DOCH_Socket sockets [DOCH_MAX_SOCKETS]
 * 	- DOCH_get_socket MACRO definition
 * 
 *    Rev 1.29   Aug 16 2006 08:46:10   Yaniv.Iarovici
 * structure DOCH:
 * 	- Remove wOtpToParition[]
 * 	- Add ETFFS_Identified instead
 * 
 *    Rev 1.28   Aug 09 2006 17:26:54   Polina.Marimont
 * initial for DOC Driver 1.0
 * 
 */

#ifndef DOCH_ATA_H
#define DOCH_ATA_H

#include "doch_sys.h"
#include "doch_api.h"

#include "part_inf.h"

/*
 * macros
 * (also customizable for internal purpose)
 *
 */

/* 'long'  DOCH operations can take up to DOCH_LONG_WAIT milliseconds  */
#ifndef DOCH_LONG_WAIT
	#define DOCH_LONG_WAIT   500
#endif /*DOCH_LONG_WAIT*/

/* 'short' DOCH operations can take up to DOCH_SHORT_WAIT milliseconds */
#ifndef DOCH_SHORT_WAIT
	#define DOCH_SHORT_WAIT  450
#endif /*DOCH_SHORT_WAIT*/

/* "Very short wait" used for identifying device = 50ms */
#ifndef DOCH_SHORT_IDENTIFY_TIMEOUT
	#define DOCH_SHORT_IDENTIFY_TIMEOUT   (10L*1000000L/gDochAccessNanosec)
#endif /*DOCH_SHORT_IDENTIFY_TIMEOUT*/

/* "Longer" wait used for identifying device = 500ms */
#ifndef DOCH_LONG_IDENTIFY_TIMEOUT
	#define DOCH_LONG_IDENTIFY_TIMEOUT   (500L*1000000L/gDochAccessNanosec)
#endif /*DOCH_LONG_IDENTIFY_TIMEOUT*/

#ifndef DOCH_DEFAULT_SLEEP_PERIOD
	#define DOCH_DEFAULT_SLEEP_PERIOD		3000
#endif /* DOCH_DEFAULT_SLEEP_PERIOD */

/*#define ONE_SEC_IN_NANO_SEC	(1000000000 / gDochAccessNanosec)*/

/* maximum number of sectors which could be read from / written to DOCH at once */
#define DOCH_MAX_SECTORS  256

/*ATA device definitions*/
#define DOCH_ATA_MASTER_DEV 0		/* master device only */
#define DOCH_ATA_SLAVE_DEV	1		/* slave device only */
#define DOCH_ATA_ALL_DEVS   0xff	/* all devices */

#define ATA_NO_ERR			0 /* no error on ATA command */

#define DOCH_ATA_MAX_TIMEOUT 0xFFFFFFFF

/* Access Layer Types */
typedef enum {
	DOCH_AL_NONE	= 0xCAF0,
	DOCH_AL_NOR		= 0xCAF1,
	DOCH_AL_SPI		= 0xCAF2,
	DOCH_AL_USER	= 0xCAF3,
	DOCH_AL_SIM		= 0xCAF4
} DOCH_AccessLayerType;

/*	Optional bits in DOCH_DRIVE_HEAD_REG	*/
#define DRIVE_HEAD_OPT1 0x80
#define DRIVE_HEAD_OPT2 0x20

/*	Pattern to add to DOCH_DRIVE_HEAD_REG to 	*/
/*Option1*/
#define CUSTOM_PARAM_TEMP		DRIVE_HEAD_OPT1	/*Temporary value*/
#define CUSTOM_PARAM_DEFAULT	0				/*DEFAULT value*/
#define PERM_DEFAULT_PART_OP	DRIVE_HEAD_OPT1	/*Permanently set default partition number*/
#define PREPARE_FOR_WRITE_OP	0				
#define REWRITE_NORMAL_OP		DRIVE_HEAD_OPT1	
#define WRITE_NORMAL_OP			DRIVE_HEAD_OPT1	
#define HASH_AS_IS				0				
#define HASH_BY_KEY				DRIVE_HEAD_OPT1	
#define DELETE_PARTITIONS_FAST  0				
#define DELETE_PARTITIONS_COMPLETE DRIVE_HEAD_OPT1	
/*Option2*/
#define ERASE_NORMAL			0				
#define ERASE_IMMEDIATE			DRIVE_HEAD_OPT2	


typedef enum { DOCH_4BITS		= 0,	/*TBD*/
			   DOCH_ATA_NIEN	= 2,
			   DOCH_ATA_SRST	= 4
} DOCH_control_reg;

/*	Data transfer modes	*/
typedef enum { DOCH_DATA_MODE_SINGLE			= 0x00,
			   DOCH_DATA_MODE_MULT				= 0x01
} DOCH_TransferMode;

/*	Atomic write sequence control	*/
typedef enum { DOCH_START_ATOMIC_WRITE		= 0x00,
			   DOCH_FINISH_ATOMIC_WRITE		= 0x01,
			   DOCH_ABORT_ATOMIC_WRITE		= 0x02
} DOCH_AtomicSeqCtrl;

/* set of DOCH Vendor-Specific ATA Commands */
typedef enum { 
			   /*I/O*/
			   DOCH_VSCMD_READ_PARTITION		= 0x82,
               DOCH_VSCMD_WRITE_PARTITION		= 0x83,
			   DOCH_VSCMD_WRITE_FLEXI			= 0x84,

			   /*Sectors Operations*/
			   DOCH_VSCMD_OPTIMIZE_PARTITION_SECTORS	= 0x86,
			   DOCH_VSCMD_ERASE_PARTITION_SECTORS		= 0x88,

			   /*Hash*/
			   DOCH_VSCMD_READ_CALCULATED_HASH	= 0x8A,
			   DOCH_VSCMD_WRITE_CALCULATED_HASH	= 0x8B,
			   DOCH_VSCMD_READ_ORIGINAL_HASH	= 0x8C,
			   DOCH_VSCMD_WRITE_GIVEN_HASH		= 0x8D,

			   /*Sub-commanded commands*/
			   DOCH_VSCMD_PARTITION_MANAGEMENT	= 0xFA,
			   DOCH_VSCMD_ACCESS_CONTROL		= 0xFB,
               DOCH_VSCMD_EXT_DEVICE_CTRL		= 0xFC,
               DOCH_VSCMD_EXT_SECURITY_CTRL		= 0xFD,

			   /*Supported standard ATA commands*/
			   DOCH_CMD_IDENTIFY_DEV            = 0xEC,
			   DOCH_DOWNLOAD_MICROCODE			= 0x92

} DOCH_Command;

/* set of operation codes for DOCH_VSCMD_PARTITION_MANAGEMENT command */
typedef enum { 
			   DOCH_GET_PARTITION_INFO			= 0x00,
			   DOCH_SET_DEFAULT_PARTITION		= 0x11,
			   DOCH_SET_PARTITION_PROTECTION	= 0x18,
			   DOCH_GET_PARTITION_USER_ATTR		= 0x70,
			   DOCH_SET_PARTITION_USER_ATTR		= 0x71,
			   DOCH_DELETE_PARTITIONS			= 0xB0,
			   DOCH_ADD_PARTITION				= 0xB4,
			   DOCH_SECURE_ERASE				= 0xB8
} DOCH_PartitionManageOp;

/* set of operation codes for DOCH_VSCMD_ACCESS_CONTROL command */
typedef enum {
			   DOCH_EN_ACCESS_WPWD				= 0x30,
			   DOCH_DISABLE_ACCESS				= 0x31,

			   /*Enable access with challange/response protocol*/
			   DOCH_TX_HOST_PUBLICKEY			= 0x32,
			   DOCH_RX_DOCH_PUBLICKEY			= 0x33,
			   DOCH_VERIFY_HOST_KEY				= 0x34
} DOCH_AccessCtrlOp;

/* set of operation codes for DOCH_VSCMD_EXT_DEVICE_CTRL command */
typedef enum { 
			   DOCH_IDENTIFY_DISKONCHIP_DEVICE	= 0x00,
			   DOCH_GET_EXTENDED_DEVICE_INFO	= 0x01,
			   DOCH_SET_DATA_XFER_MODE			= 0x10,
			   DOCH_ATOMIC_WRITE_SEQUENCE		= 0x20,
			   DOCH_OPTIMIZE_MEDIA				= 0x30,
			   DOCH_GET_CUSTOM_PARAM			= 0x40,
			   DOCH_SET_CUSTOM_PARAM			= 0x41,
			   DOCH_CALIBRATE_CLOCK				= 0x50,
			   DOCH_GET_POWER_MODE				= 0x60,
			   DOCH_SET_POWER_MODE				= 0x61,
			   DOCH_GET_DISK_USER_ATTR			= 0x70,
			   DOCH_SET_DISK_USER_ATTR			= 0x71,
			   DOCH_GET_CONFIGURATION_DATA		= 0x72,
			   DOCH_SET_CONFIGURATION_DATA		= 0x73,
			   DOCH_ACTIVATE_DEBUG_MODE			= 0x7C,
			   DOCH_RETRIEVE_DBG_MSG			= 0x7E,
			   DOCH_SET_ALERT_LEVEL				= 0x7F,
   			   DOCH_GET_RESET_STATUS			= 0x80,
			   DOCH_NOTIFY_PLATFORM_RESUMED		= 0x8E,
			   DOCH_NOTIFY_RESET				= 0x8F
} DOCH_DeviceCtrlOp;

/* set of operation codes for DOCH_VSCMD_EXT_SECURITY_CTRL command */
typedef enum {
			   DOCH_REPORT_SUPPORTED_ALGORITHMS	= 0x00,
			   DOCH_GET_ALGORITHM_CAPABILITIES	= 0x01,
			   DOCH_SET_ALGORITHM_MODE			= 0x02,
			   DOCH_RETURN_RANDOM_NUMBERS		= 0x10,
			   DOCH_AUTO_HASH_CONTROL			= 0x40,
			   DOCH_SET_KEYS					= 0x48,
			   DOCH_START_HASH_STREAM_CALC		= 0x50,
			   DOCH_READ_STOP_HASH_STREAM_CALC	= 0x51
} DOCH_SecurityCtrlOp;

/* set of operation codes for DOCH_VSCMD_CRYPTO_CONTROL command */
typedef enum { DOCH_HASH_NO_ENCRYPTION	= 0x00,
               DOCH_HASH_ENCRYPT_BY_KEY	= 0x01
} DOCH_HashEncrypt_Op;

/* bits in DOCH_STATUS_REG and DOCH_ALT_STATUS_REG registers */
#define DOCH_ERROR      0x01
#define DOCH_DRQ        0x08
#define DOCH_DSC        0x10
#define DOCH_READY      0x40
#define DOCH_BUSY       0x80

/* bits in DOCH_STATUS_REG and DOCH_ALT_STATUS_REG registers */
#define DOCH_ERR_REG_BIT0	0x01;
#define DOCH_ERR_REG_BIT1	0x02;
#define DOCH_ERR_REG_ABRT	0x04;
#define DOCH_ERR_REG_BIT3	0x08;
#define DOCH_ERR_REG_BIT4	0x10;
#define DOCH_ERR_REG_BIT5	0x20;
#define DOCH_ERR_REG_BIT6	0x40;
#define DOCH_ERR_REG_BIT7	0x80;

/* bits for DOCH_DRIVE_HEAD_REG register */
#define DOCH_DEVICE     0x10
#define DOCH_LBA        0x40
#define DOCH_DRIVE_HEAD 0xA0

/* DOCH configuration bits (IDENTIFY_DEVICE Word#0)	*/
#define DOCH_ATAPI      0x8000
#define DOCH_REMOVABLE  0x0080
#define DOCH_FIXED      0x0040

/*	IDENTIFY DEVICE data	*/
/*==========================*/
typedef struct {
	FLWord	wGeneralConfiguration;
	FLWord	wDefaultNumberOfCylinders;	/*1*/
	FLWord	wSpecificConfiguration;		/*ATA-5*/
	FLWord	wDefaultNumberOfHeads;		/*3*/
	FLDword	dwReserved2;
	FLWord	wDefaultSectorsPerTrack;	/*6*/
	FLWord	wReserved1[3];
	FLByte	bSerialNumber[20];			/*10*/
	FLWord	wReserved4[2];
	FLWord	wVsFLBytesInReadWriteLONG;	/*obsolete in ata-5*/
	FLByte	bFirmwareRevision[8];		/*23*/
	FLByte	bModelNumber[40];			/*27*/

	FLByte	bReserved3;					/*47	ata-4+ : must be 0x80*/
	FLByte	bMaxSectorsPerMulti;

	FLWord	wReserved5;
	FLWord	wCapabilities;				/*49*/
	FLWord	wCapabilities2;				/*ata-4*/

	FLByte	bPIOTransferTiming;			/*51	obsolete in ATA-5*/
	FLByte	bReserved6a;

	FLWord	wReserved7;					/*was (single-word?) DMA Timing in ATA-2*/
	FLWord	wWordSupported;				/*53*/
	FLWord	wCurrentNumberOfCylinders;	/*54*/
	FLWord	wCurrentNumberOfHeads;		/*55*/
	FLWord	wCurrentSectorPerTrack;		/*56*/

	FLWord	wCurrentCapacityInSectorsLow;	/*57*/
	FLWord	wCurrentCapacityInSectorsHigh;	/*58*/

	FLByte	bMultipleSectorSettingValid;	/*59*/
	FLByte	bMultipleSectorCurrentNumber;

	FLWord	wTotalNumberOfSectorsLow;	/*60*/
	FLWord	wTotalNumberOfSectorsHigh;	/*61*/

⌨️ 快捷键说明

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