📄 doch_ata.h
字号:
/****************************************************************************** * * * Project: DOC Driver for Linux 2.4 Block device driver for mDOC H3 family * * of devices under Linux kernel 2.4. * * * * Version: 1.0 * * Email questions to: oemsupport@sandisk.com * * Copyright (C) SanDisk IL Ltd. 1995 - 2007 * * SanDisk IL Ltd., 7 Atir Yeda Street, Kfar Saba 44425, Israel * * * ****************************************************************************** * * * 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 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, which is set forth in the readme.txt file. * * 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., 51 * * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * * * This License does not grant you any right to use the trademarks, service * * marks or logos of SanDisk IL Ltd. or SanDisk Corporation. * * Subject to the foregoing, SanDisk IL Ltd., for itself and on behalf of its * * licensors, hereby reserves all intellectual property rights in the program,* * except for the rights expressly granted in this License. * * * ******************************************************************************//***********************************************************************************/
/* */
/* Header file for doch_ata module */
/* */
/***********************************************************************************/
/*
* $Log: V:/PVCSDB/DiskOnChip/archives/Test for 7.x/src/H3/doch_ata.h-arc $
*
* Rev 1.32.1.1 Nov 12 2006 09:47:02 Yaniv.Iarovici
* 1. Added parameter 'FLBoolean waitOnBusy' to doch_reset().
* 2. Added 'DOCH_SRST_WAIT'
*
* Rev 1.32.1.0 Oct 31 2006 12:23:36 yaniv.iarovici
* Added doch_init_window().
*
* Rev 1.32 Oct 05 2006 11:00:42 yaniv.iarovici
* 1. Removed dwMulti_Read, dwMulti_Write.
* 2. Added dwMulti_MAX.
* 3. Removed DOCH_multReadOp structure.
*
* 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*/
/* Wait for busy bit to clear before sending SRST to the device (milliseconds) */
#ifndef DOCH_SRST_WAIT
#define DOCH_SRST_WAIT DOCH_SHORT_WAIT
#endif /*DOCH_SRST_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*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -