SectorInfo

This structure emulates the typical physical layout of the actual extra area of flash. The FAL portion of the NAND flash block driver supplied by Microsoft makes use of 8 bytes of the Sector Extra Info area. The file public/COMMON/oak/drivers/block/msflashfmd/inc/fmd.h has the SectorInfo definition:

typedef struct _SectorInfo{
   DWORD dwReserved1;
   BYTE bOEMReserved;
   BYTE bBadBlock;
   WORD wReserved2;
}SectorInfo, *PSectorInfo;
Members
dwReserved1
Reserved. Used by the FAL to hold the logical to physical sector mapping information.
bOEMReserved
For use by OEM. One of the following (2 bits are recognized by the FAL):
#define OEM_BLOCK_RESERVED 0x01
#define OEM_BLOCK_READONLY 0x02
Any sectors that the OEM does not want the FAL to touch should have both of these bits set. This includes the sectors including the boot loader and any other flash data that sits before the MBR. Note also that because only full blocks can be erased, all sectors within a block should have the same values for these fields.

bBadBlock
Indicates if block is BAD.
wReserved2
Reserved. Used by the FAL to maintain state information about the sector.
Remarks
The SectorInfo data structure was designed to emulate the typical physical layout of the actual extra area of flash. Specifically, most NAND flash manufacturers (Samsung and Toshiba most notably) set byte 5 (the 6th byte) to 0 to indicate if a block has shipped BAD from the factory.

The following is a typical representation of how the extra area is utilized:

- - - - - - - - - - - - - - - -

|R|R|R|R|O|V|R|R|E|E|E|E|E|E|E|E|

- - - - - - - - - - - - - - - -

The following table describes each element.

Element Description
R reserved bytes used by the FAL
O byte for use by the OEM
V byte indicating if the block is valid (a.k.a. bad)
E bytes typically used for by the FMD for ECC

See Also
TFAT on NAND for Smartphone

 

 

 

 

;plateform.reg----------
see HKEY_LOCAL_MACHINE/init
see if have  #include
see xipregion DEFAULT_REGISTRY
;-----------------------

in Bootloader:
see sectorinfo if write right

uint8 u_BtFls_LgcSectorAlgn(uint32 xStrtAdr_u32, uint32 xBlkSize_u32) { const u_BtFls_SectorInfo_tst* xPhySectorInfoP_cpast; const u_BtFls_SectorInfo_tst* xPhySectorInfoD0_cpast; const u_BtFls_SectorInfo_tst* xMiniSectorInfoUCB_cpast; uint32 xDynStrtAdr_u32; uint8 cntrLgcSector_u8; uint8 xIdx_u8; uint8 xRet_u8 = E_NOT_OK; xPhySectorInfoP_cpast = u_BtFls_xPhySectorInfoP_cast; xPhySectorInfoD0_cpast = u_BtFls_xPhySectorInfoD0_cast; xMiniSectorInfoUCB_cpast = u_BtFls_xMiniSectorInfoUCB_cast; if(u_BtFls_xSectorAlgnIdx_u8 == 0u) { /* check if the requested erasing address range is in PFLASH */ if((xStrtAdr_u32 >= xPhySectorInfoP_cpast->xStrtAdr_u32) && ((xStrtAdr_u32 + xBlkSize_u32) <= (((xPhySectorInfoP_cpast + u_BtFls_xPhySectorPNr_u8) - 1u)->xStrtAdr_u32 + ((xPhySectorInfoP_cpast + u_BtFls_xPhySectorPNr_u8) - 1u)->xSectorSize_u32))) { /* check if the request start and end address is boundary of logical sector */ if(((xStrtAdr_u32 % U_BTFLS_LGCSECTORSIZP) == 0u) && ((xBlkSize_u32 % U_BTFLS_LGCSECTORSIZP) == 0u)) { xDynStrtAdr_u32 = xStrtAdr_u32; cntrLgcSector_u8 = 1u; for(xIdx_u8 = 1u; xIdx_u8 <= (xBlkSize_u32 / U_BTFLS_LGCSECTORSIZP); xIdx_u8 ++) { /* Msg(7:4391): need to caculate address*/ if(((xStrtAdr_u32 + ((uint32)xIdx_u8 * U_BTFLS_LGCSECTORSIZP)) % (U_BTFLS_MAXERASELGCSECTORNRP * U_BTFLS_LGCSECTORSIZP)) == 0u) { u_BtFls_xSectorAlgnInfo_ast[u_BtFls_xSectorAlgnIdx_u8].xStrtAdr_u32 = xDynStrtAdr_u32; u_BtFls_xSectorAlgnInfo_ast[u_BtFls_xSectorAlgnIdx_u8].xSectorNr_u8 = cntrLgcSector_u8; u_BtFls_xSectorAlgnIdx_u8 ++; /* Msg(7:4391): need to caculate address*/ xDynStrtAdr_u32 += ((uint32)cntrLgcSector_u8 * U_BTFLS_LGCSECTORSIZP); cntrLgcSector_u8 = 1u; } else if((xIdx_u8 == (xBlkSize_u32 / U_BTFLS_LGCSECTORSIZP)) && (xDynStrtAdr_u32 != (xStrtAdr_u32 + xBlkSize_u32))) { u_BtFls_xSectorAlgnInfo_ast[u_BtFls_xSectorAlgnIdx_u8].xStrtAdr_u32 = xDynStrtAdr_u32; u_BtFls_xSectorAlgnInfo_ast[u_BtFls_xSectorAlgnIdx_u8].xSectorNr_u8 = cntrLgcSector_u8; u_BtFls_xSectorAlgnIdx_u8 ++; } else { cntrLgcSector_u8 ++; } xRet_u8 = E_OK; } } else { xRet_u8 = E_NOT_OK; } } 逐行分析代码
08-28
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值