📄 docbdk.c
字号:
* bdkSavedStartUnit - save start unit for next access
* bdkSavedSignOffset - save current signatur for next access
* flash - flash record enabling media I\O
* bdkGlobalStatus - set to BDK_S_INFO_FOUND
* startPartitionBlock - low physical boundry of the partition
* endPartitionBlock - high physical boundry of the partition
* signBuffer - initialize with given signature
* bootImageSize - size of the entire sub partition in bytes
* realBootImageSize - number of units writen in the sub partition
* startImageBlock - physical unit number of the first and
* endImageBlock last units marked with the signature
*
* Return :
* flOK - success
* flDriveNotAvailable - DiskOnChip ASIC was not found
* flUnknownMedia - failed in Flash chips recognition
* flBadDownload - DiskOnChip Millennium Plus reported an uncorrectable
* protection violation. This device is unusable.
* flBadFormat - TL format does not exists
* flNoSpaceInVolume - there are 0 units marked with this signature
* flDataError - MTD read fault.
* flHWProtection - HW protection was triggerd
*
* Routine for BDK stand alone package only.
*-------------------------------------------------------------------*/
FLStatus bdkCheckSignOffset( byte FAR2 *signature )
{
FLStatus status;
bdkVol->bdkSignOffset = 0; /* Look for signature units with offset 0 */
status = getBootAreaInfo( 0 , signature );
if (status!=flOK)
{
bdkVol->bdkSignOffset = BDK_SIGN_OFFSET; /* Now try with offset 8 */
checkStatus(getBootAreaInfo( 0 , signature ));
}
return( flOK );
}
/*-------------------------------------------------------------------
* b d k C o p y B o o t A r e a
*
* Copy the BDK Image from the DiskOnChip to a RAM area starting at
* 'startAddress', with a size of 'areaLen' bytes.
*
* Note : Blocks in the DiskOnChip are marked with a 4-byteacter signature
* followed by a 4-digit hexadecimal number.
*
* This routine simple calls bdkCopyBootAreaInit and loops over
* bdkCopyBootAreaBlock.
*
* Parameters: 'startAddress' - pointer to the beginning of the RAM area
* 'startUnit' - start block in image for reading
* 'areaLen' - BDK image size
* 'checkSum' - pointer to the checksum modulo 0x100
* 'signature' - 4-byteacter signature of storage units
*
* global variable input :
* bdkVol - current binary partition record
* bdkGlobalStatus - partition predsent status.
* bdkSavedStartUnit - start unit of previous access
* bdkSavedSignOffset - signature offset of previous access
* bdkSignOffset - current signature offset
* bdkDocWindow - explicitly sets the windows address
*
* global variable output :
* flash - flash record enabling media I\O
* bdkGlobalStatus - set to BDK_S_INFO_FOUND
* signBuffer - initialize with given signature
* bdkSavedStartUnit - save start unit for next access
* bdkSavedSignOffset - save current signature for next access
* startPartitionBlock - low physical boundry of the partition
* endPartitionBlock - high physical boundry of the partition
* startImageBlock - physical unit number of the first and
* endImageBlock last units marked with the signature
* bootImageSize - size of the entire sub partition in bytes
* realBootImageSize - number of units writen in the sub partition
*
* Return :
* flOK - success
* flDriveNotAvailable - DiskOnChip ASIC was not found
* flUnknownMedia - failed in Flash chips recognition
* flBadDownload - DiskOnChip Millennium Plus reported an uncorrectable
* protection violation. This device is unusable.
* flBadFormat - TL format does not exists
* flNoSpaceInVolume - there are 0 units marked with this signature
* flDataError - MTD dependent.
* flHWProtection - HW read protection was triggerd
*
* Routine for BDK stand alone package only.
*-------------------------------------------------------------------*/
FLStatus bdkCopyBootArea( byte FAR1 *startAddress,word startUnit,dword areaLen,
byte FAR2 *checkSum, byte FAR2 *signature )
{
dword curLen;
word copyLen;
checkStatus(bdkCopyBootAreaInit( startUnit, areaLen, signature ));
DEBUG_PRINT(("Debug: bdkCopyBootArea() - bdkCopyBootAreaInit was done succefully.\r\n"));
#ifdef BDK_CHECK_SUM
if (checkSum!=NULL)
*checkSum=0;
#endif /* BDK_CHECK_SUM */
for(curLen=0L;( curLen < areaLen );curLen+=bdkVol->flash->erasableBlockSize)
{
copyLen = (word)BDK_MIN((areaLen - curLen), bdkVol->flash->erasableBlockSize);
checkStatus(bdkCopyBootAreaBlock( (byte FAR1 *)startAddress, copyLen, checkSum ));
startAddress = (byte FAR1 *)addToFarPointer( startAddress, copyLen);
}
return flOK;
}
#endif /* MTD_STANDALONE */
/*-------------------------------------------------------------------
* b d k G e t B o o t P a r t i t i o n I n f o
*
* Get DiskOnChip binary sub partition Information.
*
* Note : Blocks in the DiskOnChip are marked with a 4-byteacter signature
* followed by a 4-digit hexadecimal number.
*
* Parameters: 'startUnit' - start Unit for Actual sub Partition Size
* 'partitionSize' - pointer to return sub Partition Size parameter
* 'realPartitionSize' - pointer to return Actual sub Partition Size
* 'unitSize' - pointer to return Unit Size parameter
* 'signature' - 4-byteacter signature of storage units
*
* global variable input :
* bdkVol - current binary partition record
* bdkGlobalStatus - partition predsent status.
* bdkSavedStartUnit - start unit of previous access
* bdkSavedSignOffset - signature offset of previous access
* bdkSignOffset - current signature offset
* bdkDocWindow - explicitly sets the windows address
*
* global variable output :
* flash - flash record enabling media I\O
* bdkGlobalStatus - set to BDK_S_INFO_FOUND
* signBuffer - initialize with given signature
* bdkSavedStartUnit - save start unit for next access
* bdkSavedSignOffset - save current signature for next access
* startPartitionBlock - low physical boundry of the partition
* endPartitionBlock - high physical boundry of the partition
* startImageBlock - physical unit number of the first and
* endImageBlock last units marked with the signature
* bootImageSize - size of the entire sub partition in bytes
* realBootImageSize - number of units writen in the sub partition
*
* Return :
* flOK - success
* flDriveNotAvailable - DiskOnChip ASIC was not found
* flUnknownMedia - failed in Flash chips recognition
* flBadDownload - DiskOnChip Millennium Plus reported an uncorrectable
* protection violation. This device is unusable.
* flBadFormat - TL format does not exists
* flNoSpaceInVolume - there are 0 units marked with this signature
* flDataError - MTD dependent.
* flHWProtection - HW read protection was triggerd
*
* Routine for BDK stand alone package only.*
*-------------------------------------------------------------------*/
FLStatus bdkGetBootPartitionInfo( word startUnit, dword FAR2 *partitionSize,
dword FAR2 *realPartitionSize,
dword FAR2 *unitSize, byte FAR2 *signature)
{
FLStatus st = flOK;
*partitionSize = 0L;
*unitSize = 0L;
st = getBootAreaInfo( startUnit , signature );
*partitionSize = bdkVol->bootImageSize;
*realPartitionSize = bdkVol->realBootImageSize;
*realPartitionSize -= ((startUnit - bdkVol->bdkSavedStartUnit) << bdkVol->erasableBlockBits);
*unitSize = bdkVol->flash->erasableBlockSize;
return( st );
}
/*-------------------------------------------------------------------
* b d k C o p y B o o t A r e a I n i t
*
* Initialize read operations on the DiskOnChip starting at 'startUnit', with
* a size of 'areaLen' bytes and 'signature'.
*
* Note : Blocks in the DiskOnChip are marked with a 4-byteacter signature
* followed by a 4-digit hexadecimal number.
*
* Parameters: 'startUnit' - start block in image for reading
* 'areaLen' - BDK image size
* 'signature' - 4-byteacter signature of storage units
*
* global variable input :
* bdkVol - current binary partition record
* flash - flash record enabling media I\O
* bdkGlobalStatus - was this partition accessed before
* bdkSavedSignBuffer - signature offset of previous access
* bdkSignOffset - current signature offset
*
* global variable output :
* bdkGlobalStatus - set to BDK_S_INFO_FOUND
* signBuffer - initialize with given signature
* bdkSavedSignBuffer - save current signatur for next access
* bootImageSize - size of the entire sub partition in bytes
* realBootImageSize - number of units writen in the sub partition
* startPartitionBlock - low physical boundry of the partition
* endPartitionBlock - high physical boundry of the partition
* startImageBlock - physical unit number of the first and
* endImageBlock last units marked with the signature
* curReadImageAddress - current address to read from
* actualReadLen - length left to read
*
* Return :
* flOK - success
* flDriveNotAvailable - DiskOnChip ASIC was not found
* flUnknownMedia - failed in Flash chips recognition
* flBadDownload - DiskOnChip Millennium Plus reported an uncorrectable
* protection violation. This device is unusable.
* flBadFormat - TL format does not exists
* flNoSpaceInVolume - there are 0 units marked with this signature
* flDataError - MTD read fault.
* flHWProtection - HW read protection was triggerd
*
* Routine for both OSAK and the BDK stand alone package.
*-------------------------------------------------------------------*/
FLStatus bdkCopyBootAreaInit(word startUnit ,
dword areaLen ,
byte FAR2 *signature)
{
dword realSize; /* remaining real size from start unit */
checkStatus(getBootAreaInfo( startUnit , signature ));
realSize = bdkVol->realBootImageSize;
realSize -= (startUnit - bdkVol->bdkSavedStartUnit) << bdkVol->erasableBlockBits;
if (areaLen>realSize)
{
DEBUG_PRINT(("got out of the partition.\r\n"));
return( flNoSpaceInVolume );
}
bdkVol->curReadImageBlock = startUnit;
bdkVol->actualReadLen = areaLen;
bdkVol->curReadImageAddress = getPhysAddressOfUnit( startUnit );
return( flOK );
}
/*-------------------------------------------------------------------
* bdkCopyBootAreaBlock - Read to 'buffer' from the DiskOnChip BDK Image area.
*
* Note : Before the first use of this function 'bdkCopyBootAreaInit'
* must be called
*
* Parameters: 'buf' - buffer to read into
* 'bufferLen' - buffer length in bytes
* 'checkSum' - pointer to the checksum modulo 0x100
*
* global variable input :
* bdkVol - current binary partition record
* flash - flash record enabling media I\O
* signBuffer - sub partition signature
* bdkSignOffset - current signature offset
* curReadImageAddress - current address to read from
* actualReadLen - length left to read
* endImageBlock - last signatured block in sub partition
* erasableBlockBits - no' of bits used to represent a block
*
* global variable output :
* curReadImageAddress - updated address to read from
* actualReadLen - updated length left to read
*
* Return :
* flOK - success
* flBadLength - required length will cause crossing unit boundry
* flNoSpaceInVolume - no more signatured units found
* flDataError - MTD read fault.
* flHWProtection - HW read protection was triggerd
*
* Routine for both OSAK and the BDK stand alone package.
*-------------------------------------------------------------------*/
FLStatus bdkCopyBootAreaBlock( byte FAR1 *buf, word bufferLen, byte FAR2 *checkSum )
{
word iBlock, readLen;
byte modes;
byte signRead[BDK_SIGNATURE_NAME];
FLFlash * flash = bdkVol->flash;
FLStatus status;
if( (bufferLen > flash->erasableBlockSize ) ||
(bufferLen > bdkVol->actualReadLen))
return( flBadLength );
/* find next good unit */
if( (bdkVol->curReadImageAddress & (flash->erasableBlockSize-1)) == 0 )
{
iBlock = (word)( bdkVol->curReadImageAddress >> bdkVol->erasableBlockBits );
for(;( iBlock <= bdkVol->endImageBlock ); iBlock++)
{
if ((dword)(iBlock % bdkVol->blockPerFloor) < bdkVol->flash->firstUsableBlock)
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -