📄 doc2exb.c
字号:
/*
* $Log: V:/Flite/archives/TrueFFS5/Src/DOC2EXB.C_V $
*
* Rev 1.29 Oct 31 2002 17:08:00 oris
* Allow formatting with Bios driver current version and "5120"
*
* Rev 1.28 Oct 23 2002 12:00:02 oris
* Used the new BiosDriverEXBVersion instead of TrueFFSVersion .
*
* Rev 1.27 May 01 2002 19:02:36 oris
* Added support for DiskOnChip Millennium Plus 16MB
*
* Rev 1.26 Apr 15 2002 07:35:12 oris
* Moved doc2exb internal functions declaration to blockdev.c.
* Make sure all relevant data is stored in little endian format.
*
* Rev 1.25 Feb 19 2002 20:58:28 oris
* Moved include directive and routine prototypes from H file.
*
* Rev 1.24 Jan 23 2002 23:31:18 oris
* Removed warnings.
* Replaced Alon based DiskOnChip writeIPL code with the MTD writeIPL routine.
*
* Rev 1.23 Jan 21 2002 20:44:02 oris
* Bad support for firmware other then the default 3 firmwares (TrueFFS 4.3 backward compatibility firmware).
* Added support for DiskOnChip Millennium Plus 16MB firmware.
* Missing far heap initialization for DiskOnChip 2000 firmware.
*
* Rev 1.22 Jan 17 2002 22:58:32 oris
* Added new flags for placeExbByBuffer - Choose firmware to place
* Added firmware number to getExbInfo().
* Changed debug print to Dformat print.
* Removed exb size calculation when writing SPL - It is done as part of the firmware build
* Added support for far malloc heap.
* All DiskOnChip use the same STACK size definition.
*
* Rev 1.21 Nov 08 2001 10:44:50 oris
* Removed warnings.
*
* Rev 1.20 Sep 24 2001 18:23:10 oris
* Removed warnings.
*
* Rev 1.19 Sep 16 2001 21:47:42 oris
* Bug fix - support for 1KB IPL code for DiskOnChip2000 tsop.
*
* Rev 1.18 Sep 15 2001 23:44:54 oris
* Bug fix - The last 512 bytes of the last firmware were not written, and IPL was not loaded.
*
* Rev 1.17 Jul 30 2001 17:57:36 oris
* Removed warrnings
*
* Rev 1.16 Jul 30 2001 00:20:52 oris
* Support new IPL and SPL formats.
*
* Rev 1.15 Jul 13 2001 01:00:08 oris
* Changed constant stack space from magic numbers to contents.
* Added erase before write for the binary write operation.
*
* Rev 1.14 Jun 17 2001 08:17:16 oris
* Changed placeExbByBuffer exbflags argument to word instead of byte to support /empty flag.
* Adjust exb size field to fit OSAK 4.3 format.
* Added \empty flag - Leaves exb space empty.
*
* Rev 1.13 May 29 2001 19:47:12 oris
* Bug fix - trueffs heap size discounted boot units (heap too small)
* Doc2000 exbOffset hardcoded to 40.
*
* Rev 1.12 May 16 2001 21:16:50 oris
* Change "data" named variables to flData to avoid name clashes.
* Removed warnings.
*
* Rev 1.11 May 09 2001 00:31:52 oris
* Bug fix - Added check status to intializaion routine of place EXB by buffer.
*
* Rev 1.10 May 06 2001 22:41:34 oris
* Reduced tffs head size for Millennium Plus and DOC2000 tsop devices.
* Removed warnings.
*
* Rev 1.9 Apr 12 2001 06:48:46 oris
* Added call to download routine in order to load new IPL.
*
* Rev 1.8 Apr 10 2001 16:40:22 oris
* Removed warrnings.
*
* Rev 1.7 Apr 09 2001 14:59:04 oris
* Reduced exb size read by the SPL to minimum.
*
* Rev 1.6 Apr 03 2001 18:08:42 oris
* Bug fix - exb flags were not properly written.
*
* Rev 1.5 Apr 03 2001 16:34:50 oris
* Removed unsused variables.
*
* Rev 1.4 Apr 03 2001 14:36:46 oris
* Completly reviced in order to support alon devices.
*
* Rev 1.3 Apr 02 2001 00:54:32 oris
* Added doc2000 exb family.
* Supply the exact length of the exb in the binary partition.
* Removed the no_pnp_header from the media.
* Bug fix for calculation Spl size.
*
* Rev 1.2 Apr 01 2001 07:49:42 oris
* Updated copywrite notice.
* Added support for doc2300 firmware.
* Bug fixes for mdoc plus.
* Added support for 1k IPL.
* Added consideration in media type in calculating tffs heap size.
* Changed h\w to h/w
* Changed 2400 family to doc plus family.
*
* Rev 1.1 Feb 08 2001 10:37:54 oris
* Bug fix for unaligned file signature
*
* Rev 1.0 Feb 02 2001 12:59:48 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 */
/***********************************************************************************/
/*****************************************************************************
* File Header *
* ----------- *
* Project : TrueFFS source code *
* *
* Name : doc2exb.c *
* *
* Description : This file contains the code for analizing and writing *
* M-Systems EXB firmware files *
* *
*****************************************************************************/
#include "doc2exb.h"
#include "bddefs.h"
#ifdef WRITE_EXB_IMAGE
extern FLStatus absMountVolume(Volume vol);
#define BUFFER exb->buffer->flData
exbStruct exbs[SOCKETS];
#define roundedUpShift(a,bits) (((a - 1) >> bits)+1)
/*----------------------------------------------------------------------*/
/* g e t E x b I n f o */
/* */
/* Analize M-systems firmware file */
/* Analizes M-systems firmware (exb) file, calclating the media space */
/* required for it. */
/* */
/* Parameters: */
/* vol : Pointer identifying drive */
/* buf : Pointer to EXB file buffer */
/* bufLen : Size of the buffer */
/* bufFlags : Flags for the EXB - specifing type of */
/* firmware to extract from the EXB file. */
/* */
/* Returns: */
/* FLStatus : flOK on success. */
/* flBadLength if buffer size is too small */
/* flBadParameter on any other failure */
/* vol.binaryLength : Total size needed in the binary partition */
/* exbs[i].firmwareStart : offset of the firmware begining in the file */
/* exbs[i].firmwareEnd : offset of the firmware end in the file */
/* exbs[i]l.splOffset : offset of the spl start in the file */
/* exbs[i]l.exbFileEnd : Total exb file size. */
/*----------------------------------------------------------------------*/
FLStatus getExbInfo(Volume vol, void FAR1 * buf, dword bufLen, word exbFlags)
{
byte i;
byte mediaType;
ExbGlobalHeader FAR1* globalHeader = (ExbGlobalHeader FAR1*)buf;
FirmwareHeader FAR1* firmwareHeader = (FirmwareHeader FAR1*)
flAddLongToFarPointer(buf,sizeof(ExbGlobalHeader));
/* Make sure size given is big enough */
if (bufLen < sizeof(FirmwareHeader) * LE4(globalHeader->noOfFirmwares) +
sizeof(ExbGlobalHeader))
{
DFORMAT_PRINT(("ERROR - Buffer size not big enough.\r\n"));
return flBadLength;
}
/* Make sure this is an M-systems EXB file */
if (tffscmp(globalHeader->mSysSign,SIGN_MSYS,SIGN_MSYS_SIZE) != 0)
{
DFORMAT_PRINT(("ERROR - Given file is not M-systems EXB file.\r\n"));
return flBadParameter;
}
i = (exbFlags & FIRMWARE_NO_MASK) >> FIRMWARE_NO_SHIFT;
if(i == 0)
{
/* Make sure this is the correct version of TrueFFS */
if ((tffscmp(globalHeader->osakVer,BiosDriverEXBVersion,SIGN_MSYS_SIZE) != 0) &&
(tffscmp(globalHeader->osakVer,"5120" ,SIGN_MSYS_SIZE) != 0) )
{
DFORMAT_PRINT(("ERROR - Incorrect TrueFFS EXB file version.\r\n"));
return flBadParameter;
}
/* Find the corrent firmware in the file */
/* Automatic firmware detection - by DiskOnChip type */
switch (vol.flash->mediaType)
{
case DOC_TYPE:
case MDOC_TYPE:
mediaType = DOC2000_FAMILY_FIRMWARE;
break;
case MDOCP_TYPE:
case MDOCP_16_TYPE:
mediaType = DOCPLUS_FAMILY_FIRMWARE;
break;
case DOC2000TSOP_TYPE:
mediaType = DOC2300_FAMILY_FIRMWARE;
break;
default:
DFORMAT_PRINT(("Unknown H/W - Try specifing the firmware manualy.\r\n"));
return flFeatureNotSupported;
}
for (i=0;i<LE4(globalHeader->noOfFirmwares);i++,firmwareHeader++)
{
if (LE4(firmwareHeader->type) == mediaType)
break;
}
}
else /* Use given firmware */
{
i--; /* 0 was used for automatic choose of firmware */
}
if (i >= LE4(globalHeader->noOfFirmwares))
{
DFORMAT_PRINT(("ERROR - The EXB file does not support the required firmware.\r\n"));
return flBadParameter;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -