📄 sim_dev.h
字号:
/******************************************************************************/
/* */
/* 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. */
/* */
/******************************************************************************/
/*
* $Log:
*/
#ifndef SIM_DEVICE_H
#define SIM_DEVICE_H
#include "flchkdef.h"
#include "doch_ata.h"
#include "part_inf.h"
#define DOCH_NUM_OF_SIMULATED_DEVICES 2
#define DEFAULT_SIM_FILENAME "doch_sim"
#define dochSimulatorVer "0001"
#define SIM_READ 0
#define SIM_WRITE 1
#define DOCH_SIM_CAPACITY 0x2000000 /*32MB */
#define DOCH_SIM_CAPACITY_PERCENTAGE 0.93
#define SIMULTOR_IDENTIFY_STRING "M-SYSTEMS DOC H SIMULATOR FILE "
typedef enum {
SIM_ITEM_ID_STRING = 0,
SIM_ITEM_SLAVE_PRESENT = 1,
SIM_ITEM_CONFIG_REGS = 2,
SIM_ITEM_DEV_SIZE_IN_SECTORS = 3,
SIM_ITEM_TOTAL_DEV_SIZE_IN_SECTORS = 4,
SIM_ITEM_IPL_MODE = 5,
SIM_ITEM_MAX_IPL_SIZE = 6,
SIM_ITEM_ETFFS_SIZE = 7,
SIM_ITEM_ETFFS_CODE = 8,
SIM_ITEM_DRIVE_PARAMS = 9,
SIM_ITEM_DEV_INFO = 10,
SIM_ITEM_PARTITIONS = 11,
SIM_ITEM_DISK_ATTRIBUTES = 12,
SIM_ITEM_STORAGE = 13
} DOCH_SimFileItem;
typedef enum {
simATAOK = 0xBB00,
simATANotFormatted = 0xBB01,
simATANoSpace = 0xBB02,
simATAExcLimit = 0xBB03,
simATANotAuth = 0xBB04,
simATANoReadAccess = 0xBB05,
simATANoWriteAccess = 0xBB06,
simATASlockActive = 0xBB07
} sSimATAReturnCodes;
typedef struct
{
FLWord wDataPort; /* Data register */
FLByte bErrorFeature; /* Error/feature register */
FLByte bSectorCount;
FLByte bLBALow;
FLByte bLBAMid;
FLByte bLBAHigh;
FLByte bDevice;
FLByte bStatusCommand;
FLByte bAltStatusControl;
} sSimATARegisters;
typedef struct
{
FLWord wChipID1;
FLWord wBurstWriteModeCtrl;
FLWord wBurstWriteModeExit;
FLWord wDownloadCtrl;
FLWord wIPLCtrl;
FLWord wWarmBoot;
FLWord wPowerDown;
FLWord wDMACtrl;
FLWord wSWLock;
FLWord wEndianCtrl;
FLWord wOperationMode;
FLWord wPowerMode;
FLWord wDmaNegation;
FLWord wChipID2;
FLWord wBurstReadModeCtrl;
} sSimHostConfigRegisters;
typedef struct
{
FLDword dwSize; /* In sectors, 0 means partition does not exist */
FLDword dwRequestedSize;/* In sectors, 0 means partition does not exist */
FLDword dwOffset; /* Offset of the partition data from the start of the file/buffer */
FLWord wActive; /* Partition was formatted */
FLWord wAuthenticated; /* "1" if the partition is authenticated */
FLWord wKeyInserted; /* "1" if the key was inserted */
DOCH_PartitionInfo info; /* Partition Info structure */
DOCH_PartitionUserAttr userAttr;
FLSByte sbPasskey[128]; /* Passkey */
} sSimPartitionInfo;
typedef struct
{
FLByte * sbBuffer;
FLSNative nBufferLen;
FLByte * sbCurrentPosition;
FLByte * sbPositionToReach;
FLSNative nDirection;
} sSimCommandBuffer;
typedef struct
{
FLDword firstSector;
FLDword numOfSectors;
} sSimSecureErase;
typedef struct { /* note: all fields in this structure will be saved in memory mapped file */
FLDword dwDevSizeInSectors;/*exported capacity(93%)*/
FLDword dwTotalDevSizeInSectors; /*total capacity*/
FLWord wIPLMode;
FLWord wXIPTestMode;
FLDword dwXIPMaxSize;
FLDword dwEtffsSize;
DOCH_DriveParameters driveParameters;
sSimPartitionInfo partitions[DOCH_MAX_PARTITIONS];
DOCH_DeviceAttributes diskAttributes;
FLBoolean bPpartitionAuthenticated[DOCH_MAX_SECTORS];
FLByte bEtffsCode[DOCH_MAX_SECTORS][DOCH_SECTOR_SIZE];
#ifdef DOCH_RAM_SIMULATION
unsigned char bStorage[DOCH_SIM_CAPACITY];
#else /* DOCH_RAM_SIMULATION*/
/* simulate DOCH in the file */
/* TODO replace following fields by right fields when memory mapped file will be implemented */
FLByte * bStorage; /* pointer to buffer, which holds pointer to buffer */
#endif /*DOCH_RAM_SIMULATION*/
} DOCH_SimDevice;
typedef struct {
/* fields should not be saved into file */
sSimATARegisters in_regs;
sSimATARegisters out_regs;
FLByte pciCtrlReg;
FLByte inDPDMode;
DOCH_TransferMode xferMode;
FLByte multiCount;
sSimCommandBuffer cmdBuffer;
FLByte selDevNum; /*Selected dev num last time device register was set*/
#ifndef DOCH_RAM_SIMULATION
FILE * pSimFile; /* holds OS pointer to file */
#endif /*DOCH_RAM_SIMULATION*/
/* fields, which must be saved in file */
FLBoolean bSlavePresent; /* TRUE, when master and slave devices exists, FALSE when master only device appear */
sSimHostConfigRegisters config_regs; /* configuration registers */
DOCH_SimDevice device[ATA_MAX_NUM_OF_DEVICES]; /* master and slave information */
} DOCH_SimSocket;
DOCH_SimDevice* getSimDev(FLSNative ataDev);
DOCH_SimSocket* getSimSocket(void);
FLByte* getPartSetupInfo(void);
FLByte* getDiskOnChipDeviceInfo(FLByte bDev);
FLByte* getConfigPartition(FLByte partNum);
FLByte* getExtendedDeviceInfo(void);
FLByte* getSandBox(void);
FLByte* getAtaDebug(void);
void setActiveMode(FLByte WM);
FLByte getActiveMode(void);
void setWorkMode(FLByte WM);
FLByte getWorkMode(void);
void setInactiveMode(FLByte WM);
FLByte getInactiveMode(void);
void setTimeOutForIdle(FLWord TO);
FLWord getTimeOutForIdle(void);
void* choosePartition(DOCH_SimSocket* simSocket, FLByte partNum);
FLSNative initSimRegisters(void);
FLSNative initDriveParameters(FLByte numOfDevices);
FLSNative initVarious(FLBoolean fNewDev);
FLSNative doch_sim_finish_data_xfer(DOCH_SimSocket* simSocket);
FLSNative setSimReg(FLSNative offset, FLSNative value);
FLSNative getSimReg(FLSNative offset);
FLSNative simFileIO(DOCH_SimSocket* simSocket, DOCH_SimFileItem item, FLByte devNum, FLByte read, void* data);
#ifndef DOCH_RAM_SIMULATION
#ifdef DOCH_FILE_SIMULATION
DOCH_Error SimRegDeviceFromFile(FLSByte * bSimFileName, FLDword dwMasterSizeInSectors, FLDword dwSlaveSizeInSectors );
extern FLByte * pSimFileName; /* one file for master and slave devices */
extern FLDword dwSimLength[ATA_MAX_NUM_OF_DEVICES]; /* lengths for each master and slave devices */
#endif/* DOCH_FILE_SIMULATION*/
#endif /*DOCH_RAM_SIMULATION*/
#endif /*SIM_DEVICE_H*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -