📄 fldrvvxw.c
字号:
(dword FAR2 *)pVal);
break;
case TFFS_OPT_FAST_DEFRAG: /* select iNFTL defrag. policy */
if( *((dword *) pVal) == TRUE )
status = flSetEnvAll (FL_SET_POLICY, FL_COMPLETE_ASAP, (dword FAR2 *)pVal);
else
status = flSetEnvAll (FL_SET_POLICY, FL_DEFAULT_POLICY, (dword FAR2 *)pVal);
break;
case TFFS_OPT_MARK_DELETE: /* write "deleted sector" marks to media */
if( *((dword *) pVal) == TRUE )
status = flSetEnvAll (FL_MARK_DELETE_ON_FLASH, FL_ON, (dword FAR2 *)pVal);
else
status = flSetEnvAll (FL_MARK_DELETE_ON_FLASH, FL_OFF, (dword FAR2 *)pVal);
break;
#ifdef FL_DRV_MULTIDOC
case TFFS_OPT_MTL_ALTDEFRAG: /* select MTL defrag. pocily */
if( *((dword *) pVal) == TRUE )
status = flSetEnvAll (FL_MTL_POLICY, FL_MTL_DEFRAGMENT_SEQUANTIAL, (dword FAR2 *)pVal);
else
status = flSetEnvAll (FL_MTL_POLICY, FL_MTL_DEFRAGMENT_ALL_DEVICES, (dword FAR2 *)pVal);
break;
#endif /* FL_DRV_MULTIDOC */
case TFFS_OPT_VERIFY_WRITE_BINARY: /* verify writes to bin. partitions */
if( *((dword *) pVal) == TRUE )
status = flSetEnvAll (FL_VERIFY_WRITE_BINARY, FL_ON, (dword FAR2 *)pVal);
else
status = flSetEnvAll (FL_VERIFY_WRITE_BINARY, FL_OFF, (dword FAR2 *)pVal);
break;
case TFFS_OPT_MTD_VERIFY: /* enable MTD's verify-after-write */
default:
status = flFeatureNotSupported;
break;
}
return ((status == flOK) ? OK : ERROR);
}
/* ---------------------------------------------------------------------- *
* *
* t f f s S e t S o c k e t O p t i o n *
* *
* Sets various TFFS runtime configuration options which are common for *
* all disk of specified socket. *
* *
* Parameters: *
* *
* socNo : socket # *
* option : TFFS runtime config. option (see fldrvvxw.h) *
* pVal : on entry - new setting of 'option' *
* on exit - previous setting of option *
* *
* Returns: *
* *
* ERROR if any error, otherwise OK *
* *
* ---------------------------------------------------------------------- */
STATUS tffsSetSocketOption ( int socNo,
int option,
void * pVal )
{
dword val;
FLStatus status;
dword dontcare;
/* arg sanity check */
if (socNo >= SOCKETS)
return ERROR;
if (pVal == NULL)
return ERROR;
val = *((dword *) pVal);
/* grab socket mutex if exists */
if (tffsSocketMutex[socNo] != NULL) {
if( semTake(tffsSocketMutex[socNo], WAIT_FOREVER) != OK )
return ERROR;
}
switch (option) {
case TFFS_OPT_VERIFY_WRITE_OTHER: /* verify 'other' writes */
status = flSetEnvSocket (FL_VERIFY_WRITE_OTHER, (byte)socNo,
val, (dword FAR2 *)pVal);
break;
case TFFS_OPT_ACCESS_TYPE: /* specify Access Routines */
status = flSetEnvSocket (FL_MTD_BUS_ACCESS_TYPE, (byte)socNo,
val, (dword FAR2 *)pVal);
#if 1 /* andrayk: force flUse8Bit to '1' if socket is being put into 16-bit access mode */
if (status == flOK) {
if( (val & (TFFS_OPT_NO_ADDR_SHIFT | TFFS_OPT_BUS_16BIT_ACCESS)) ==
(TFFS_OPT_NO_ADDR_SHIFT | TFFS_OPT_BUS_16BIT_ACCESS) )
status = flSetEnvAll (FL_DOC_8BIT_ACCESS, (dword)1, &dontcare);
}
#endif
break;
default:
status = flBadFunction;
break;
}
/* release socket mutex if prevuiusly was taken */
if (tffsSocketMutex[socNo] != NULL)
semGive (tffsSocketMutex[socNo]);
return ((status == flOK) ? OK : ERROR);
}
/* ---------------------------------------------------------------------- *
* *
* t f f s S e t D i s k O p t i o n *
* *
* Sets various TFFS runtime configuration options for specified disk of *
* specified socket. *
* *
* Parameters: *
* *
* handle : TFFS handle *
* option : TFFS runtime config. option (see fldrvvxw.h) *
* pVal : on entry - new setting of 'option' *
* on exit - previous setting of option *
* *
* Returns: *
* *
* ERROR if any error, otherwise OK *
* *
* ---------------------------------------------------------------------- */
STATUS tffsSetDiskOption ( int handle,
int option,
void * pVal )
{
int socNo;
int diskNo;
FLStatus status;
/* check args for sanity */
socNo = tffsHandle2Soc(handle);
diskNo = tffsHandle2Disk(handle);
if ((socNo >= SOCKETS) || (diskNo >= FL_MAX_DISKS_PER_SOCKET))
return ERROR;
if (pVal == NULL)
return ERROR;
/* grab socket mutex if exists */
if (tffsSocketMutex[socNo] != NULL) {
if( semTake(tffsSocketMutex[socNo], WAIT_FOREVER) != OK )
return ERROR;
}
switch (option) {
case TFFS_OPT_FAST_DEFRAG: /* select iNFTL defrag. policy */
if( *((dword *) pVal) == TRUE )
status = flSetEnvVolume (FL_SET_POLICY, (byte)socNo, (byte)diskNo,
FL_COMPLETE_ASAP, (dword FAR2 *)pVal);
else
status = flSetEnvVolume (FL_SET_POLICY, (byte)socNo, (byte)diskNo,
FL_DEFAULT_POLICY, (dword FAR2 *)pVal);
break;
case TFFS_OPT_VERIFY_WRITE_BDTL: /* verify low-level flash writes */
switch( *((dword *) pVal) == TRUE ) {
case TFFS_OPT_VERIFY_WRITE_BDTL_UPS: /* don't verify flash writes */
status = flSetEnvVolume (FL_VERIFY_WRITE_BDTL, (byte)socNo,
(byte)diskNo, FL_UPS, (dword FAR2 *)pVal);
break;
case TFFS_OPT_VERIFY_WRITE_BDTL_OFF: /* verify flash block writes only */
status = flSetEnvVolume (FL_VERIFY_WRITE_BDTL, (byte)socNo,
(byte)diskNo, FL_OFF, (dword FAR2 *)pVal);
break;
case TFFS_OPT_VERIFY_WRITE_BDTL_ON: /* verify all flash writes */
status = flSetEnvVolume (FL_VERIFY_WRITE_BDTL, (byte)socNo,
(byte)diskNo, FL_ON, (dword FAR2 *)pVal);
break;
default:
status = flBadParameter;
break;
}
break;
default:
status = flBadFunction;
break;
}
/* release socket mutex if previously was taken */
if (tffsSocketMutex[socNo] != NULL)
semGive (tffsSocketMutex[socNo]);
return ((status == flOK) ? OK : ERROR);
}
/* ---------------------------------------------------------------------- *
* *
* t f f s S o c k e t S e t A c c e s s H a n d l e r s *
* *
* Set socket's Access Routines. *
* *
* Parameters: *
* *
* socNo : socket # *
* accessHandlers : set of pointers to Access Routines that will *
* be installed on that socket *
* *
* Returns: *
* *
* ERROR if any error, otherwise OK *
* *
* ---------------------------------------------------------------------- */
STATUS tffsSocketSetAccessHandlers ( int socNo,
FLAccessStruct * accessHandlers )
{
FLStatus status;
/* arg sanity check */
if (socNo >= SOCKETS)
return ERROR;
if (accessHandlers == NULL)
return ERROR;
/* grab socket mutex if exists */
if (tffsSocketMutex[socNo] != NULL) {
if( semTake(tffsSocketMutex[socNo], WAIT_FOREVER) != OK )
return ERROR;
}
/* install new Access Routines */
status = flSetDocBusRoutine ((byte)socNo, accessHandlers);
/* release socket mutex if previously was taken */
if (tffsSocketMutex[socNo] != NULL)
semGive (tffsSocketMutex[socNo]);
return ((status == flOK) ? OK : ERROR);
}
/* ---------------------------------------------------------------------- *
* *
* t f f s S o c k e t G e t A c c e s s H a n d l e r s *
* *
* Get socket's Access Routines. *
* *
* Parameters: *
* *
* socNo : socket # *
* accessHandlers : Access Routines structure to fill in *
* Returns: *
* *
* ERROR if any error, otherwise OK *
* *
* ---------------------------------------------------------------------- */
STATUS tffsSocketGetAccessHandlers ( int socNo,
FLAccessStruct * accessHandlers )
{
FLStatus status;
/* arg sanity check */
if (socNo >= SOCKETS)
return ERROR;
if (accessHandlers == NULL)
return ERROR;
/* grab socket mutex if exists */
if (tffsSocketMutex[socNo] != NULL) {
if( semTake(tffsSocketMutex[socNo], WAIT_FOREVER) != OK )
return ERROR;
}
/* install new Access Routines */
status = flGetDocBusRoutine ((byte)socNo, accessHandlers);
/* release socket mutex if previously was taken */
if (tffsSocketMutex[socNo] != NULL)
semGive (tffsSocketMutex[socNo]);
return ((status == flOK) ? OK : ERROR);
}
/* ---------------------------------------------------------------------- *
* *
* t f f s M u l t i d o c *
* *
* Enable/disable or get status of multi-doc option. *
* *
* Parameters: *
* *
* op : enable/disable/get status (see fldrvvxw.h) *
* pVal : on entry - doesn't matter *
* on exit - status (enabled/disablable) *
* Returns: *
* *
* ERROR if any error, otherwise OK *
* *
* ---------------------------------------------------------------------- */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -