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

📄 tlinternal.h

📁 Zoran V966 DVD 解码 Soc芯片的源程序
💻 H
📖 第 1 页 / 共 2 页
字号:
/**
2003 ZORAN Corporation, All Rights Reserved THIS IS PROPRIETARY SOURCE CODE OF  
ZORAN CORPORATION                                                               
                                                                                
%file TlInternal.c
                                                                                
%desc                                                                           
  Internal header file for NAND-based translation layer.
*/

#ifndef __TLINTERNAL_H
#define __TLINTERNAL_H

// Define necessary macros.

// Number of physical blocks in one zone in NAND/SSFDC
#define SSFDC_MAX_PUNITS_PER_ZONE   1024 
// Amount of units in one zone that may be assigned for file system 
// usage in NAND/SSFDC
#define SSFDC_MAX_VUNITS_PER_ZONE   1000 

// Number of physical blocks in one segment (zone) in MS
#define MS_MAX_PUNITS_PER_ZONE      512  
// Amount of units in one zone that may be assigned to file system in MS
#define MS_MAX_VUNITS_PER_ZONE      496  

// Status of a physical unit
#define UNIT_BAD                0 // Unit is defective or unavailable
#define UNIT_ERASED             1 // Unit is erased
#define UNIT_AVAILABLE          2 // Assigned unit
#define UNIT_FREE               3 // Unassigned unit
#define UNIT_UNKNOWN            4 // Incorrectly assigned unit

// Number of times to retry when failing to read/write from a unit/sector
#define NUM_OF_RETRIES          10 

#define BYTE_UNASSIGNED         0xFF
#define WORD_UNASSIGNED         0xFFFF
#define DWORD_UNASSIGNED        0xFFFFFFFFUL

//xD type M
// No virtual to physical mapping
#define NO_UNIT                 DWORD_UNASSIGNED   
// CIS/IDI was not located where it had to be
//xD type M
#define NO_CIS                  (DWORD_UNASSIGNED-1)

// Unit not cached (max in 4 bits)
#define UNIT_NOT_CACHED         BYTE_UNASSIGNED

// Sector status flags
#define INCORRECT_DATA	        0x00
#define CORRECT_DATA	        0xFF

// Unit status flags
#define EARLY_INCORRECT_BLOCK   0x00
#define LATE_INCORRECT_BLOCK    0xF0
#define CORRECT_BLOCK           0xFF

// Masks for deciding which redundant fields to update
#define RDNDT_SECTOR_STATUS        1
#define RDNDT_UNIT_STATUS          2
#define RDNDT_VIRTUAL_ADDRESS      4

// The numbers of the corresponding bytes in the redundant 
// area of SSFDC/NAND
#define SSFDC_RDNDT_SECTOR_STATUS_BYTE           4
#define SSFDC_RDNDT_UNIT_STATUS_BYTE             5
#define SSFDC_RDNDT_VIRTUAL_ADDRESS1_BYTE1       6
#define SSFDC_RDNDT_VIRTUAL_ADDRESS1_BYTE2       7
#define SSFDC_RDNDT_VIRTUAL_ADDRESS2_BYTE1      11
#define SSFDC_RDNDT_VIRTUAL_ADDRESS2_BYTE2      12

// The numbers of the corresponding bytes (and bits in these bytes)
// in the redundant area of MS
#define MS_RDNDT_OVERWRITE_STATUS_BYTE           0
#define MS_RDNDT_UNIT_STATUS_BIT                 7
#define MS_RDNDT_SECTOR_STATUS_BIT1              6
#define MS_RDNDT_SECTOR_STATUS_BIT2              5
#define MS_RDNDT_UPDATE_STATUS_BIT               4
#define MS_RDNDT_MANAGEMENT_STATUS_BYTE          1
#define MS_RDNDT_SYSTEM_BIT                      2
#define MS_RDNDT_VIRTUAL_ADDRESS_BYTE1           2
#define MS_RDNDT_VIRTUAL_ADDRESS_BYTE2           3

#define CEIL_DIV(a, b) ((a + b - 1)/b ) 

///////////////////////////////////////////////////////////////////////////////
// Debug printing definitions
///////////////////////////////////////////////////////////////////////////////

// - Undefine this to eliminate all debug messages
// - Define to 0 to print only once the deepest debug message
// - Define to 1 to print all debug message

#define DEBUG_PRINT 1

#ifdef DEBUG_PRINT

STATIC BOOL bDebugPrint = TRUE;
#define INIT_DBGPRINT() { bDebugPrint = TRUE; }

#if ( DEBUG_PRINT == 0 )
#define DISABLE_DBGPRINT() { bDebugPrint = FALSE; }
#else
#define DISABLE_DBGPRINT() { }
#endif // ( DEBUG_PRINT == 0 )

#else

#define bDebugPrint FALSE
#define INIT_DBGPRINT() { }
#define DISABLE_DBGPRINT() { }

#endif // DEBUG_PRINT

#define DBGPRINT0(str) { bDebugPrint ? printf(str) : FALSE; DISABLE_DBGPRINT(); }
#define DBGPRINT1(str,arg1) { bDebugPrint ? printf(str,arg1) : FALSE; DISABLE_DBGPRINT(); }
#define DBGPRINT2(str,arg1,arg2) { bDebugPrint ? printf(str,arg1,arg2) : FALSE; DISABLE_DBGPRINT(); }
#define DBGPRINT3(str,arg1,arg2,arg3) { bDebugPrint ? printf(str,arg1,arg2,arg3) : FALSE; DISABLE_DBGPRINT(); }
#define DBGPRINT4(str,arg1,arg2,arg3,arg4) { bDebugPrint ? printf(str,arg1,arg2,arg3,arg4) : FALSE; DISABLE_DBGPRINT(); }

///////////////////////////////////////////////////////////////////////////////
// Definitions of unit number and zone number
///////////////////////////////////////////////////////////////////////////////

//xD type M
typedef ULONG UNITNO; // Unit number

typedef USHORT ZONENO; // Zone number

///////////////////////////////////////////////////////////////////////////////
// The following structure defines a virtual unit
///////////////////////////////////////////////////////////////////////////////

typedef struct tagSVUNIT {
    // The mapping to the physical unit
    UNITNO uwPhysicalUnit;
    // Either 0, 1 or UNIT_NOT_CACHED
#ifndef TL_SUPPORT_WRITE   
    BYTE   byCacheEntry;
#endif
} SVUNIT; // Virtual Unit

///////////////////////////////////////////////////////////////////////////////
// The following structure defines a physical unit
///////////////////////////////////////////////////////////////////////////////

typedef struct tagSPUNIT {
    // Status of the unit (Either UNIT_BAD, UNIT_ERASED, UNIT_FREE,
    // UNIT_AVAILABLE or UNIT_UNKNOWN)
    BYTE   byStatus;
    // The mapping to the virtual unit
#ifndef TL_SUPPORT_WRITE    
    UNITNO uwVirtualUnit;
#endif
} SPUNIT;

///////////////////////////////////////////////////////////////////////////////
// The following structure defines a units cache used in translation layer
///////////////////////////////////////////////////////////////////////////////

typedef struct tagSUNITSCACHE{
    // Pointers to cache buffers
#ifdef TL_SUPPORT_WRITE
    DWORD  pbUnitsBuffers[2];
#else
    PBYTE  pbUnitsBuffers[2];
#endif

    // 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];
    UNITNO uwPhysicalUnitsNumbers[2];
    // The least recently used (LRU) entry in cache
    BYTE   byLruEntry;
} SUNITSCACHE;

///////////////////////////////////////////////////////////////////////////////
// The following structure defines a translation layer information
// for NAND, SSFDC and MS media
///////////////////////////////////////////////////////////////////////////////

typedef struct tagSTLINFO {
    // 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 block).
    // The first virtual segment has 494 units and every subsequent zone
    // has 496 units.
    ULONG   ulVirtualUnitsPerZone;

    // Number of physical units per zone
    ULONG   ulPhysicalUnitsPerZone;

#ifdef CARD_WRITE

    // 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
//    SPUNIT*  sPhysicalTable;

    // Holds mapping from virtual to physical unit
    // The size is: uwNumberOfVirtualUnits
//    SVUNIT*  sVirtualTable;

    // The units cache we use
    SUNITSCACHE sUnitsCache;
#endif

    // 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;

    // This semaphore prevents two threads from trying to access the TL
    // simulanously.
#if 0
    TX_SEMAPHORE txTlProtect;
#endif

    // Counter of number of open medias that are using the same TL
    BYTE byMediaCount;

	UNITNO    uwCachedUnit;
} STLINFO;

#ifdef TL_SUPPORT_WRITE
STATIC BOOL  TlIsVirtualUnitCached(STLINFO *psTlInfo, UNITNO uwVirtualUnit);
//STATIC BYTE  TlFlushLRUVirtualUnit(FX_MEDIA *psMedia, STLINFO *psTlInfo);
STATIC BYTE  TlCacheVirtualUnit(FX_MEDIA *psMedia, BYTE byOpType, STLINFO *psTlInfo, UNITNO uwVirtualUnit);
#endif


///////////////////////////////////////////////////////////////////////////////
// Local to TL functions declarations
///////////////////////////////////////////////////////////////////////////////


STATIC UNITNO
TlSectorToUnit( STLINFO* psTlInfo, ULONG ulSector );

STATIC UNITNO
TlVirtualUnitToPhysicalUnit( STLINFO* psTlInfo, UNITNO uwUnit );

STATIC USHORT

⌨️ 快捷键说明

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