📄 defs.c
字号:
/* */
/* Identify the current Flash medium and select an MTD for it */
/* */
/* Parameters: */
/* socket : Socket of flash */
/* vol : New volume pointer */
/* */
/* Returns: */
/* FLStatus : 0 = Flash was identified */
/* other = identification failed */
/*----------------------------------------------------------------------*/
FLStatus flIdentifyFlash(FLSocket *socket, FLFlash * pVol)
{
/* Prevent re-identifing flash media */
if(pVol->wasIdentified == TRUE)
return flOK;
/* Setup default parameters for old MTD's that do not support new properties */
pVol->type = NOT_FLASH;
pVol->if_cfg = 8;
pVol->socket = socket;
return flOK;
}/*flIdentifyFlash*/
/*============================================================================*/
#ifdef __cplusplus
}
#endif
/*============================================================================*/
/*=== from bdstub.c */
#include "dochstub.h"
/*----------------------------------------------------------------------*/
/* Function name : lockForIO*/
/* Description : */
/* Return type : FLStatus */
/* Argument : FLByte socket*/
/* Argument : FLByte partition*/
/* Argument : FLBoolean onOff*/
/*----------------------------------------------------------------------*/
FLStatus lockForIO(FLByte socket, FLByte partition, FLBoolean onOff)
{
FLByte volNo;
#if (FS_SOCKETS < FL_SOCKETS) || (FS_MAX_TL_PARTITIONS < FL_MAX_TL_PARTITIONS)
/* then caller's check is not good enough */
if ((socket >= FL_SOCKETS) || (partition >= FL_MAX_TL_PARTITIONS))
return flBadDriveHandle;
#endif
volNo = flHandleConversionTable[socket][partition];
if (volNo == INVALID_VOLUME_NUMBER)
return flBadDriveHandle;
/* Group 3 - binary partition - has different relation of volNo to socket, but FS does not call them
some format routines require partition 0 - will be checked in caller */
checkStatus(dochSetBusy(socket, onOff, partition)); /* take DOCH mutex */
return flOK;
}/*lockForIO()*/
/*============================================================================*/
/*============================================================================*/
/*=== from flsocket.c */
FLByte noOfSockets; /* No. of drives actually registered */
static FLSocket sockets[FL_SOCKETS];
static FLBuffer *volBuffers[FL_SOCKETS];
#if (defined(FL_VERIFY_WRITE) || defined(VERIFY_VOLUME))
static FLByte* readBackBuffer[FL_SOCKETS];
#endif /* FL_VERIFY_WRITE || VERIFY_VOLUME */
/*----------------------------------------------------------------------*/
/* f l S o c k e t O f */
/* */
/* Gets the socket connected to a volume no. */
/* */
/* Parameters: */
/* volNo : Volume no. for which to get socket */
/* */
/* Returns: */
/* socket of volume no. */
/*----------------------------------------------------------------------*/
FLSocket *flSocketOf(unsigned volNo)
{
return &sockets[volNo];
}
#if (defined(FL_VERIFY_WRITE) || defined(VERIFY_VOLUME))
/*----------------------------------------------------------------------*/
/* f l R e a d B a c k B u f f e r O f */
/* */
/* Gets the read back buffer connected to a volume no. */
/* */
/* Parameters: */
/* volNo : Volume no. for which to get socket */
/* */
/* Returns: */
/* buffer of volume no. */
/*----------------------------------------------------------------------*/
FLByte * flReadBackBufferOf(unsigned volNo)
{
return readBackBuffer[volNo];
}
#endif /* FL_VERIFY_WRITE || VERIFY_VOLUME */
#ifndef FL_FIXED_MEDIA
/*----------------------------------------------------------------------*/
/* f l G e t M a p p i n g C o n t e x t */
/* */
/* Returns the currently mapped window page (in 4KB units) */
/* */
/* Parameters: */
/* vol : Pointer identifying drive */
/* */
/* Returns: */
/* unsigned int : Current mapped page no. */
/*----------------------------------------------------------------------*/
unsigned flGetMappingContext(FLSocket * pVol)
{
return pVol->window.currentPage;
}
/*----------------------------------------------------------------------*/
/* f l M a p */
/* */
/* Maps the window to a specified card address and returns a pointer to */
/* that location (some offset within the window). */
/* */
/* NOTE: Addresses over 128M are attribute memory. On PCMCIA adapters, */
/* subtract 128M from the address and map to attribute memory. */
/* */
/* Parameters: */
/* vol : Pointer identifying drive */
/* address : Byte-address on card. NOT necessarily on a */
/* full-window boundary. */
/* If above 128MB, address is in attribute space. */
/* */
/* Returns: */
/* Pointer to a location within the window mapping the address. */
/*----------------------------------------------------------------------*/
void FAR0 *flMap(FLSocket * pVol, CardAddress address)
{
unsigned pageToMap;
if (pVol->window.currentPage == UNDEFINED_MAPPING)
pVol->setWindow(pVol);
pageToMap = (unsigned) ((address & -pVol->window.size) >> 12);
if (pVol->window.currentPage != pageToMap) {
pVol->setMappingContext(pVol, pageToMap);
pVol->window.currentPage = pageToMap;
pVol->remapped = TRUE; /* indicate remapping done */
}
return addToFarPointer(pVol->window.base,address & (pVol->window.size - 1));
}
/*----------------------------------------------------------------------*/
/* f l S e t W i n d o w B u s W i d t h */
/* */
/* Requests to set the window bus width to 8 or 16 bits. */
/* Whether the request is filled depends on hardware capabilities. */
/* */
/* Parameters: */
/* vol : Pointer identifying drive */
/* width : Requested bus width */
/* */
/*----------------------------------------------------------------------*/
void flSetWindowBusWidth(FLSocket * pVol, unsigned width)
{
pVol->window.busWidth = width;
pVol->window.currentPage = UNDEFINED_MAPPING; /* force remapping */
}
/*----------------------------------------------------------------------*/
/* f l S e t W i n d o w S p e e d */
/* */
/* Requests to set the window speed to a specified value. */
/* The window speed is set to a speed equal or slower than requested, */
/* if possible in hardware. */
/* */
/* Parameters: */
/* vol : Pointer identifying drive */
/* nsec : Requested window speed in nanosecond. */
/* */
/*----------------------------------------------------------------------*/
void flSetWindowSpeed(FLSocket * pVol, unsigned nsec)
{
pVol->window.speed = nsec;
pVol->window.currentPage = UNDEFINED_MAPPING; /* force remapping */
}
/*----------------------------------------------------------------------*/
/* f l S o c k e t S e t B u s y */
/* */
/* Notifies the start and end of a file-system operation. */
/* */
/* Parameters: */
/* vol : Pointer identifying drive */
/* state : FL_ON (1) = operation entry */
/* FL_OFF(0) = operation exit */
/* */
/*----------------------------------------------------------------------*/
void flSocketSetBusy(FLSocket * pVol, FLBoolean state)
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -