📄 docbdk.c
字号:
/*
* $Log: V:/Flite/archives/TrueFFS5/Src/DOCBDK.C_V $
*
* Rev 1.35 May 14 2002 15:10:34 oris
* bdkInit - Added initialization of FLFlash record and its memSetGetMode routine pointer.
*
* Rev 1.34 May 01 2002 19:02:50 oris
* Removed warnings and imprroved documentation.
*
* Rev 1.33 Apr 30 2002 17:31:54 oris
* Bug fix - bdkSetDocWindow routine did not call bdkInit causing
* bdkFindDiskOnChip routine to reinitialize bdkVol->bdkDocWindow
* to NULL. The result is that the bdkSetDocWindow routine had no affect
*
* Rev 1.32 Apr 15 2002 20:14:30 oris
* Bug fix - No longer ignore the last binary block of high capacity (512MB and up) INFTL formatted device. This bug caused the placeExbByBuffer routine to fail.
* Bug fix - Physical size of INFTL formatted binary partition was 1 unit smaller then the real size.
*
* Rev 1.31 Apr 15 2002 07:35:38 oris
* Bug fix - bdkErase routine did not made sure not to erase OTP and DPS
* units of floors > 0.
*
* Rev 1.30 Feb 19 2002 20:58:44 oris
* Changed debug print.
* Bug fix - binary partition physical length was not reported properly , due to bad casting.
*
* Rev 1.29 Jan 20 2002 11:09:42 oris
* Added debug print.
*
* Rev 1.28 Jan 17 2002 22:58:56 oris
* Force calling bdkInit if not called.
* Moved declaration of internal variables to mtdsa.c
* Bug fix NO_INFTL_FAMILY_SUPPORT and NO_NFTL_FAMILY_SUPPORT where changed to NO_INFTL_SUPPORT and NO_INFTL_SUPPORT to comply with header file.
* Prevent creating binary partition with signature 0xffff ffff
* bdkInit uses tffsset instead of zeroing all the structure fields.
* Bug fix - retrieveHeader routine used a word variable instead of dword.
* freePointer call uses DOC_WIN_SIZE instead of DOC_WIN (part of new docsys ,mechanism).
* BDK now take socket and flash records using flSocketOf() and flFlashOf(). The records themselves are defined in mtdsa.c
* Use PROTECTABLE definition instead of 1 in calls to protectionSet.
* Added support for flVerifyWrite runtime variable for binary partitions
*
* Rev 1.27 Nov 16 2001 00:19:48 oris
* Bug fix - TrueFFS with verify write calling erase and then update block without erase flag, will fail.
*
* Rev 1.26 Nov 08 2001 10:45:04 oris
* Removed warnings.
* Bug fix - DiskOnChip with different number of blocks in the last floor.
*
* Rev 1.25 Oct 18 2001 22:17:02 oris
* Bug fix - Missing support for binary partiiton on M+ that spans over a single floor.
*
* Rev 1.24 Oct 10 2001 19:48:14 oris
* Bug fix - missing return statment caused the bdkGetProtectionType routine to call bdkSetProtectionType and therfore return a failing status.
*
* Rev 1.23 Sep 25 2001 17:37:00 oris
* Bug fix - bdkIdentifyProtection routine did not update after change protection call.
*
* Rev 1.22 Sep 15 2001 23:45:04 oris
* Bug fix - Changeable protection type was reported by the MTD even if user did not ask for it.
* Bug fix - Big endian casting caused wrong protection type to be returned.
*
* Rev 1.21 Jul 13 2001 01:00:48 oris
* Bug fix - when skipping bad blocks we no longer mark the bad block with the signature.
* Send default key before any protection change operation.
*
* Rev 1.20 May 30 2001 21:10:22 oris
* Bug fix - meida header was converted from little indien twice therefore suppling wrong data.
*
* Rev 1.19 May 17 2001 21:17:50 oris
* Improoved documentation of error codes.
*
* Rev 1.18 May 17 2001 16:51:08 oris
* Removed warnings.
*
* Rev 1.17 May 16 2001 21:17:04 oris
* Bug fix - One of the "ifndef" statement of NO_DOCPLUS_FAMILY_SUPPORT was coded as "ifdef".
* Bug fix - bdkEraseBootArea routine.
* Changed bdkCopyBootAreaFile and bdkUpdateBootAreaFile interface. The signature is not an unsigned char pointer and not signed.
* Removed warnings.
* Added arguments check in bdkSetProtectionType routine and forced the presence of PROTECTABLE flag.
* Compilation problems for MTD_STANDALONE were fixed.
* Changed DATA definition to FL_DATA.
*
* Rev 1.16 May 09 2001 00:32:02 oris
* Removed the DOC2000_FAMILY and DOCPLUS_FAMILY defintion and replaced it with NO_DOC2000_FAMILY_SUPPORT, NO_DOCPLUS_FAMILY_SUPPORT, NO_NFTL_SUPPORT and NO_INFTL_SUPPORT.
* Bug fix - bdkEraseBootArea did not erase more then a single unit.
* Bug fix - protection routine did not support floors properly.
* Added OTP and unique ID routines for Millennium Plus .
*
* Rev 1.15 May 06 2001 22:41:42 oris
* Removed warnings.
*
* Rev 1.14 May 02 2001 06:43:56 oris
* Bug fix - bdkRetrieveHeader routine with cascaded floors.
*
* Rev 1.13 May 01 2001 14:23:28 oris
* Removed warrnings.
*
* Rev 1.12 Apr 30 2001 17:59:04 oris
* Removed misleading debug massage when calling bdkCheckSignOffset.
* Reviced bdkRetrieveHeader routine not to use the MTD readBBT routine.
* Added initialization of the erasbleBlockSizeBits variable in order to simplify multiplications.
* Changed bdkSetBootPartitonNo, bdkGetProtectionType, bdkSetProtection prototypes.
* Bug fix - bdkGetPartitionType routine. Missing case caused type to be 0 at all times.
*
* Rev 1.11 Apr 16 2001 13:30:54 oris
* Bug fix - bad comparison with bdk flag.
* Bug fix - proection prevented read binary area since the dps were read protected.
* Removed warrnings.
*
* Rev 1.10 Apr 12 2001 06:49:50 oris
* Added forceDownload routine
* Changed checkWinForDoc routine to be under ifndef MTD_STANDALONE.
*
* Rev 1.9 Apr 10 2001 16:40:56 oris
* bug fixed for big_endien in bdkmount routine.
*
* Rev 1.8 Apr 09 2001 14:59:24 oris
* Bug fix in retreave header routine - header was searched on the first floor only.
* End with an empty line.
*
* Rev 1.7 Apr 01 2001 07:50:18 oris
* Updated copywrite notice.
* Removed nested comments.
* Removed static type from bdkVol for placinf exb file and standlone applications.
* Changed readBBT function call since prototype was changed.
* Bug fix in bdkretreave header routine - added casting to bbt pointer and iUnit.
* Fix for Big endien compilation problems.
* Remove unneeded variables.
* Bad spelling of "..changable..".
* Changed h\w to h/w.
* Changed 2400 family to doc plus family.
* Adde casting in calls to protection routine.
*
* Rev 1.6 Feb 20 2001 15:55:28 oris
* Bug fix - global partiton and socket variables were redaclared in bdcall routine.
*
* Rev 1.5 Feb 14 2001 02:36:44 oris
* Changed FLFlash and FLScoket records (used for the BDK) from static to global for the putImage utility.
*
* Rev 1.4 Feb 13 2001 01:41:50 oris
* bdkPartitionInfo returns the number of binary partitions in flags field of the bdkStruct and not irFlags
*
* Rev 1.3 Feb 07 2001 18:15:24 oris
* Changed else in bdkRetreaveHeader routine otherwise would not compiling bdk with a single doc family.
* Changed the socketTable and mtdTable so BDK package can compile.
*
* Rev 1.2 Feb 05 2001 20:46:30 oris
* Read the changable protection flag in protectionChangeInit routine
* from the media header and not from the MTD.
*
* Rev 1.1 Feb 05 2001 20:10:56 oris
* Removed // comments and added missing ;
*
* Rev 1.0 Feb 02 2001 13:19:44 oris
* Initial revision.
*
*/
/***********************************************************************************/
/* M-Systems Confidential */
/* Copyright (C) M-Systems Flash Disk Pioneers Ltd. 1995-2001 */
/* All Rights Reserved */
/***********************************************************************************/
/* NOTICE OF M-SYSTEMS OEM */
/* SOFTWARE LICENSE AGREEMENT */
/* */
/* THE USE OF THIS SOFTWARE IS GOVERNED BY A SEPARATE LICENSE */
/* AGREEMENT BETWEEN THE OEM AND M-SYSTEMS. REFER TO THAT AGREEMENT */
/* FOR THE SPECIFIC TERMS AND CONDITIONS OF USE, */
/* OR CONTACT M-SYSTEMS FOR LICENSE ASSISTANCE: */
/* E-MAIL = info@m-sys.com */
/***********************************************************************************/
/************************************************/
/* B i n a r y D e v e l o p m e n t K i t */
/* ------------------------------------------- */
/************************************************/
/*****************************************************************************
* File Header *
* ----------- *
* Name : docbdk.c *
* *
* Description : This file contains the binary partition handling routines. *
* *
* Note : The file has 2 interfaces each under its own compilation flag: *
* *
* BDK package - Standalone package that exports routines for binary *
* partitions handling(MTD_STANDALONE compilation flag). *
* OSAK module - Separated module of the OSAK package that exports a *
* common entry point to the same routines. (BDK_ACCESS *
* compilation flag). *
* *
* Warning : Do not use this file with the BDK_ACCESS compilation flag unless *
* you own the full OSAK package. *
*****************************************************************************/
#include "docbdk.h"
#ifndef MTD_STANDALONE
#include "doc2exb.h"
#include "blockdev.h"
#endif /* MTD_STANDALONE */
#if (defined(MTD_STANDALONE) && defined(ACCESS_BDK_IMAGE)) || defined(BDK_ACCESS)
/*********************** Global Variables Start******************************/
/* conversion table from OSAK handles to binary partition handles */
static byte handleTable[SOCKETS][MAX_BINARY_PARTITIONS_PER_DRIVE];
static byte noOfPartitions=0; /* number of mounted binary partition */
static byte globalPartitionNo=0; /* The current partition number */
static byte globalSocketNo = 0;
BDKVol bdkVols[BINARY_PARTITIONS]; /* binary partitions records */
BDKVol* bdkVol=bdkVols; /* pointer to current binary partition */
#ifdef MTD_STANDALONE
FLBoolean globalInitStatus = FALSE;
#endif /* MTD_STANDALONE */
/*********************** Internal Function Protoype *************************/
static FLStatus bdkMount (void);
static FLStatus getBootAreaInfo (word startUnit , byte FAR2* signature);
static CardAddress getPhysAddressOfUnit(word startUnit);
/*--------------------------------------------------------------------------*
* b d k I n i t
*
* Initialize all binary partition global variables
*
* Note : This function is called automaticly by bdkFindDiskOnChip.
*
* Parameters: None
*
* global variable output:
* bdkVols - initialized array of binary partitions records
* bdkVol - current binary partition record set to the first
*
* Return: Nothing
*
* Routine for both OSAK and the BDK stand alone package.
*--------------------------------------------------------------------------*/
void bdkInit(void)
{
byte index;
/* initialize binary partitions records with defaultive values */
tffsset(bdkVols,0,sizeof(bdkVols));
tffsset(handleTable,BDK_INVALID_VOLUME_HANDLE,sizeof(handleTable));
for (bdkVol=bdkVols,index=0;index<BINARY_PARTITIONS;bdkVol++,index++)
{
bdkVol->bdkGlobalStatus = BDK_S_INIT;
bdkVol->bdkSignOffset = BDK_SIGN_OFFSET;
#ifdef EDC_MODE
bdkVol->bdkEDC = EDC;
#endif /* EDC_MODE */
#ifdef UPDATE_BDK_IMAGE
bdkVol->updateImageFlag = BDK_COMPLETE_IMAGE_UPDATE;
#endif /* UPDATE_BDK_IMAGE */
}
/* Initialize binary handles conversion table with invalid values */
#ifdef MTD_STANDALONE
doc_noOfMTDs = 0;
globalPartitionNo=0;
globalSocketNo = 0;
globalInitStatus = TRUE;
tffsset(flFlashOf(0),0,sizeof(FLFlash));
#ifndef FL_NO_USE_FUNC
/* Just in case NULL is not 0 */
flFlashOf(0)->memSetGetMode = NULL;
#endif /* FL_NO_USE_FUNC */
#endif /* MTD_STANDALONE */
noOfPartitions=0;
bdkVol=bdkVols;
}
/*--------------------------------------------------------------------------*
* g e t P h y s A d d r e s s O f U n i t
*
* Return the physical address of a unit according to its number
* in the binary sub partition.
*
* Note : The sub partition is assumed to be mounted (BDK_S_INFO_FOUND is on).
*
* Parameters :
* startUnit : unit number in the binary sub partition.
*
* global variable input:
* bdkVol - current binary partition record
* flash - flash record enabling media I\O
* startImageBlock - physical unit number of the first and
* endImageBlock last units marked with the signature
* signBuffer - the sub partition signature
* bdkSignOffset - current signature offset
* erasableBlockBits - number of bits representing a unit
*
* Return :
* Physical address of the unit in the BDK partition or 0 if failed
*
* Routine for both OSAK and the BDK stand alone package.
*-------------------------------------------------------------------*/
static CardAddress getPhysAddressOfUnit(word startUnit)
{
word iBlock;
byte signRead[BDK_SIGNATURE_NAME];
FLFlash * flash=bdkVol->flash;
FLStatus status;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -