📄 defs.c
字号:
if (state == FL_OFF)
{
#if POLLING_INTERVAL == 0
/* If we are not polling, activate the interval routine before exit */
flIntervalRoutine(pVol);
#endif
}
else /* FL_ON */
{
pVol->window.currentPage = UNDEFINED_MAPPING; /* don't assume mapping still valid */
#ifdef FL_FIXED_MEDIA
pVol->remapped = TRUE;
#endif /* FL_FIXED_MEDIA */
}
}
/*----------------------------------------------------------------------*/
/* f l S e t P o w e r O n C a l l b a c k */
/* */
/* Sets a routine address to call when powering on the socket. */
/* */
/* Parameters: */
/* vol : Pointer identifying drive */
/* routine : Routine to call when turning on power */
/* flash : Flash object of routine */
/* */
/*----------------------------------------------------------------------*/
void flSetPowerOnCallback(FLSocket * pVol, void (*routine)(void *flash), void *flash)
{
pVol->powerOnCallback = routine;
pVol->flash = flash;
}
/*----------------------------------------------------------------------*/
/* f l I n t e r v a l R o u t i n e */
/* */
/* Performs periodic socket actions: Checks card presence, and handles */
/* the Vcc & Vpp turn off mechanisms. */
/* */
/* The routine may be called from the interval timer or synchronously. */
/* */
/* Parameters: */
/* vol : Pointer identifying drive */
/* */
/*----------------------------------------------------------------------*/
void flIntervalRoutine(FLSocket * pVol)
{
#ifndef FL_FIXED_MEDIA
if (pVol->getAndClearCardChangeIndicator == NULL && !pVol->cardChanged)
if (!pVol->cardDetected(pVol)) /* Check that the card is still there */
pVol->cardChanged = TRUE;
#endif /* FL_FIXED_MEDIA */
if (pVol->VppUsers == 0) {
if (pVol->VppState == PowerOn)
pVol->VppState = PowerGoingOff;
else if (pVol->VppState == PowerGoingOff) {
pVol->VppState = PowerOff;
#ifdef SOCKET_12_VOLTS
pVol->VppOff(pVol);
#endif
}
if (pVol->VccUsers == 0) {
if (pVol->VccState == PowerOn)
pVol->VccState = PowerGoingOff;
else if (pVol->VccState == PowerGoingOff) {
pVol->VccState = PowerOff;
pVol->VccOff(pVol);
}
}
}
}
#endif /* FL_FIXED_MEDIA */
/*----------------------------------------------------------------------*/
/* u d a t e S o c k e t P a r a m e t e r s */
/* */
/* Pass socket parameters to the socket interface layer. */
/* This function should be called after the socket parameters (like */
/* size and base) are known. If these parameters are known at */
/* registration time then there is no need to use this function, and */
/* the parameters can be passed to the registration routine. */
/* The structure passed in irData is specific for each socket interface.*/
/* */
/* Note : When using DiskOnChip this routine returns the socekt */
/* parameters instead of initializing them. */
/* */
/* Parameters: */
/* vol : Pointer identifying drive */
/* params : Record returning (or sending) the flsocket record */
/* */
/* Returns: */
/* FLStatus : 0 on success */
/*----------------------------------------------------------------------*/
FLStatus updateSocketParameters(FLSocket * pVol, void FAR1 *params)
{
if (pVol->updateSocketParams)
pVol->updateSocketParams(pVol, params);
return flOK;
}
#ifdef FL_EXIT
/*----------------------------------------------------------------------*/
/* f l E x i t S o c k e t */
/* */
/* Reset the socket and free resources that were allocated for this */
/* socket. */
/* This function is called when FLite exits. */
/* */
/* Parameters: */
/* vol : Pointer identifying drive */
/* */
/*----------------------------------------------------------------------*/
void flExitSocket(FLSocket * pVol)
{
#ifndef FL_FIXED_MEDIA
flMap(pVol, 0); /* reset the mapping register */
flDontNeedVcc(pVol);
flSocketSetBusy(pVol,FL_OFF);
#endif /* FL_FIXED_MEDIA */
if(pVol->freeSocket)
pVol->freeSocket(pVol); /* free allocated resources */
if(volBuffers[pVol->volNo] != NULL)
{
FL_FREE(volBuffers[pVol->volNo]);
volBuffers[pVol->volNo] = NULL;
}
#if (defined(FL_VERIFY_WRITE) || defined(VERIFY_VOLUME))
if(readBackBuffer[pVol->volNo] != NULL)
{
FL_FREE(readBackBuffer[pVol->volNo]);
readBackBuffer[pVol->volNo] = NULL;
}
#endif /* FL_VERIFY_WRITE || VERIFY_VOLUME */
}
#endif /* FL_EXIT */
/*----------------------------------------------------------------------*/
/* f l S e t W i n d o w S i z e */
/* */
/* Requests to set the window size to a specified value (power of 2). */
/* The window size is set to a size equal or greater than requested, */
/* if possible in hardware. */
/* */
/* Parameters: */
/* vol : Pointer identifying drive */
/* sizeIn4KBUnits : Requested window size in 4 KByte units. */
/* MUST be a power of 2. */
/* */
/*----------------------------------------------------------------------*/
void flSetWindowSize(FLSocket * pVol, unsigned sizeIn4KBunits)
{
pVol->window.size = (FLDword) (sizeIn4KBunits) * 0x1000L;
/* Size may not be possible. Actual size will be set by 'setWindow' */
pVol->window.base = (void *)(physicalToPointer((FLDword) pVol->window.baseAddress << 12,
pVol->window.size, pVol->volNo));
pVol->window.currentPage = UNDEFINED_MAPPING; /* force remapping */
}
/*-----------------------------------------------------------------------*/
/* f l I n i t S o c k e t s */
/* */
/* First call to this module: Initializes the controller and all sockets */
/* */
/* Parameters: */
/* vol : Pointer identifying drive */
/* */
/* Returns: */
/* FLStatus : 0 on success, failed otherwise */
/*---_-------------------------------------------------------------------*/
FLStatus flInitSockets(void)
{
unsigned volNo;
FLSocket * pVol = sockets;
for (volNo = 0; volNo < noOfSockets; volNo++, pVol++)
{
flSetWindowSize(pVol, 2); /* make it 8 KBytes */
#ifndef FL_FIXED_MEDIA
flSetWindowSpeed(pVol, 250);
flSetWindowBusWidth(pVol, 16);
pVol->cardChanged = FALSE;
#endif /* FL_FIXED_MEDIA */
/* allocate buffer for this socket */
volBuffers[volNo] = (FLBuffer *)FL_MALLOC(sizeof(FLBuffer));
if (volBuffers[volNo] == NULL)
{
DBG_PRINT_ERR(FLZONE_SOCKET,"ERROR - Failed allocating sector buffer for the socket.\r\n");
return flNotEnoughMemory;
}
#if (defined(FL_VERIFY_WRITE) || defined(VERIFY_VOLUME))
/* allocate read back buffer for this socket */
readBackBuffer[volNo] = (FLByte *)FL_MALLOC(READ_BACK_BUFFER_SIZE);
if (readBackBuffer[volNo] == NULL) {
DBG_PRINT_ERR(FLZONE_SOCKET,"ERROR - Failed allocating readBack buffer for the socket.\r\n");
return flNotEnoughMemory;
}
#endif /* FL_VERIFY_WRITE || MTD_READ_BBT || VERIFY_VOLUME */
}
return flOK;
}
/*============================================================================*/
/*end of file*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -