📄 fx_ssfdc.h
字号:
/**
%file Fx_SSFDC.h
%desc
Header file for SSFDC high-level driver.
%author Ofir Alon
*/
#ifndef __FXSSFDC_H
#define __FXSSFDC_H
#include "Config.h" // Global Configuration - do not remove!
#ifdef INTERNAL_MEM_CARD_READER
///////////////////////////////////////////////////////////////////////////////
// Definitions of unit number and zone number
///////////////////////////////////////////////////////////////////////////////
typedef USHORT UNITNO; // Unit number
typedef USHORT ZONENO; // Zone number
///////////////////////////////////////////////////////////////////////////////
// The following structure defines a virtual unit
///////////////////////////////////////////////////////////////////////////////
typedef struct {
// The mapping to the physical unit
UNITNO uwPhysicalUnit;
// Either 0, 1 or UNIT_NOT_CACHED
BYTE byCacheEntry;
} VUNIT; // Virtual Unit
///////////////////////////////////////////////////////////////////////////////
// The following structure defines a physical unit
///////////////////////////////////////////////////////////////////////////////
typedef struct {
// Status of the unit (Either UNIT_BAD, UNIT_ERASED, UNIT_FREE or UNIT_AVAILABLE)
BYTE byStatus;
// The mapping to the virtual unit
UNITNO uwVirtualUnit;
} PUNIT;
///////////////////////////////////////////////////////////////////////////////
// The following structure defines a units cache used in translation layer
///////////////////////////////////////////////////////////////////////////////
typedef struct {
// Pointers to cache buffers
PBYTE pbUnitsBuffers[2];
// Indication of whether the corresponding cache entry
// was modified or not
CHAR chModified[2];
// The virtual and physical unit numbers of the cached units
UNITNO uwVirtualUnitsNumbers[2]; // = { NO_UNIT, NO_UNIT }
UNITNO uwPhysicalUnitsNumbers[2]; // = { NO_UNIT, NO_UNIT }
// The least recently used (LRU) entry in cache
BYTE byLruEntry;
} UNITS_CACHE;
///////////////////////////////////////////////////////////////////////////////
// The following structure defines a translation layer information
// for NAND, SSFDC and MS media
///////////////////////////////////////////////////////////////////////////////
typedef struct {
// The type of the media to be used - NAND/SSFDC/MS
UINT uiMediaType;
// Number of virtual units in media
UNITNO uwNumberOfVirtualUnits;
// Number of physical units in media
UNITNO uwNumberOfPhysicalUnits;
// Total number of zones in media
UINT uwNumberOfZones;
// Number of sectors per one unit
ULONG ulSectorsPerUnit;
// Number of virtual units per zone.
// In NAND/SSFDC, in case of big cards (>8MB), the media is divided into
// zones with 1000 virtual units mapped to 1024 physical units. In case of
// small cards (<=8MB), there is only one zone with (up to) 1000 virtual
// units mapped to (up to) 1024 physical units.
// In MS every physical segment (zone) equals to 512 units (blocks).
// The first 2 blocks are occupied for the system (boot block and boot backup).
// The first virtual segment has 494 units and every subsequent zone
// has 496 units.
ULONG ulVirtualUnitsPerZone;
// Number of physical units per zone
ULONG ulPhysicalUnitsPerZone;
// Holds the iterator over free units in zone
// The size is: uwNumberOfZones
UNITNO* uwRoverUnits;
// Holds status of the unit + number of invalid sectors in the unit
// The size is: uwNumberOfPhysicalUnits
PUNIT* sPhysicalTable;
// Holds mapping from virtual to physical unit
// The size is: uwNumberOfVirtualUnits
VUNIT* sVirtualTable;
// The units cache we use
UNITS_CACHE sUnitsCache;
// The number of the unit in which CIS/IDI block resides
// In MS this points to the backup boot block (and not to the primary)
UNITNO uwCisBlock;
// The number of the unit in which information block resides (only for MS)
UNITNO uwInformationBlock;
// This semaphore prevents two threads from trying to access the TL
// simulanously.
TX_SEMAPHORE txTlProtect;
} TL_INFO;
///////////////////////////////////////////////////////////////////////////////
// Function declarations.
///////////////////////////////////////////////////////////////////////////////
UINT
SsfdcTlReadSectors( FX_MEDIA* psMedia,
TL_INFO* psTlInfo,
ULONG ulLogicalSector,
ULONG ulNumOfSectors,
PBYTE pbyBuffer );
UINT
SsfdcTlWriteSectors( FX_MEDIA* psMedia,
TL_INFO* psTlInfo,
ULONG ulLogicalSector,
ULONG ulNumOfSectors,
PBYTE pbyBuffer );
UINT
SsfdcTlFlush( FX_MEDIA* psMedia, TL_INFO* psTlInfo );
UINT
SsfdcTlAbort( FX_MEDIA* psMedia, TL_INFO* psTlInfo );
UINT
SsfdcTlNandSsfdcMediaInit( FX_MEDIA* psMedia, UINT uiMediaType );
UINT
SsfdcTlMsMediaInit( FX_MEDIA* psMedia, UINT uiMediaType );
UINT
SsfdcTlDriverInit( FX_MEDIA* psMedia,
TL_INFO** ppsTlInfo,
BOOL bIsOnMediaFormat,
UINT uiMediaType );
UINT
SsfdcTlFormatMedia( FX_MEDIA* psMedia, TL_INFO* psTlInfo );
UINT
SsfdcTlFormatPartition( FX_MEDIA* psMedia,
TL_INFO* psTlInfo,
ULONG ulStartSector,
ULONG ulNumberOfSectors );
UINT
SsfdcTlBootRead( FX_MEDIA* psMedia, TL_INFO* psTlInfo );
#endif // INTERNAL_MEM_CARD_READER
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -