📄 flsysvxw.c
字号:
* ---------------------------------------------------------------------- */
FLStatus flCreateMutex ( FLMutex * mutex )
{
return flOK;
}
/* ---------------------------------------------------------------------- *
* *
* f l T a k e M u t e x *
* *
* Try to take mutex, if free. *
* *
* Parameters: *
* *
* mutex : Pointer to mutex *
* *
* Returns: *
* *
* always TRUE *
* *
* ---------------------------------------------------------------------- */
int flTakeMutex ( FLMutex * mutex )
{
return TRUE;
}
/* ---------------------------------------------------------------------- *
* *
* f l F r e e M u t e x *
* *
* Free mutex. *
* *
* Parameters: *
* *
* mutex : Pointer to mutex *
* *
* ---------------------------------------------------------------------- */
void flFreeMutex ( FLMutex * mutex )
{}
/*----------------------------------------------------------------------*/
/* f l C u r r e n t T i m e */
/* */
/* Return current DOS time. Not supported. */
/* */
/*----------------------------------------------------------------------*/
unsigned flCurrentTime(void)
{
return 0;
}
/*----------------------------------------------------------------------*/
/* f l C u r r e n t D a t e */
/* */
/* Return current DOS date. Not supported. */
/* */
/*----------------------------------------------------------------------*/
unsigned flCurrentDate(void)
{
return 0;
}
#ifdef FL_EXIT
/* ---------------------------------------------------------------------- *
* *
* f l D e l e t e M u t e x *
* *
* Creates or initializes a mutex *
* *
* Parameters: *
* *
* mutex : Pointer to mutex *
* *
* ---------------------------------------------------------------------- */
void flDeleteMutex ( FLMutex * mutex )
{}
#endif /* FL_EXIT */
/* ---------------------------------------------------------------------- *
* *
* t f f s M s g S a v e *
* *
* Append TrueFFS message message to the message log. *
* *
* Parameters: *
* *
* msg : message to append to the log *
* *
* Returns: *
* *
* number of chars appended to the buffer (including terminating *
* null char) *
* *
* ---------------------------------------------------------------------- */
int tffsMsgSave ( const char * msg, ... )
{
register int cnt = 0;
/* arg sanity check */
if (msg != NULL) {
/* if log exists, append message to log */
if (msgLogStart != NULL) {
if( semTake(msgLogMutex, WAIT_FOREVER) == OK ) {
for( ; msgLogCurrent < msgLogStart + (tffsMsgBufSize * 1024); ) {
cnt++ ;
*msgLogCurrent++ = *msg++;
if( *(msg - 1) == '\0')
break;
}
semGive (msgLogMutex);
}
}
}
return cnt;
}
/* ---------------------------------------------------------------------- *
* *
* t f f s V i e w D e b u g L o g *
* *
* Returns a pointer to the Debug Log (NULL if tffsMsgBufSize is zero). *
* *
* Returns: *
* *
* pointer to the beginning of debug log *
* *
* ---------------------------------------------------------------------- */
char * tffsViewDebugLog ( void )
{
return msgLogStart;
}
/* ---------------------------------------------------------------------- *
* *
* f l m a l l o c *
* *
* Wrapper for ANSI C routine malloc(). Used to catch heap corruption. *
* *
* ---------------------------------------------------------------------- */
void * flmalloc ( size_t nBytes )
{
#ifdef FL_SYS_MEM_CORRUPTION
char * p;
p = malloc( sizeof(int) + FL_SYS_SENTINEL_STR_LEN + nBytes + FL_SYS_SENTINEL_STR_LEN);
if (p != NULL) {
/* record number of bytes allocated */
*((int *)p) = nBytes;
/* start sentinel */
memcpy( p + sizeof(int), sentinelStr, FL_SYS_SENTINEL_STR_LEN );
/* end sentinel */
memcpy( p + sizeof(int) + FL_SYS_SENTINEL_STR_LEN + nBytes,
sentinelStr, FL_SYS_SENTINEL_STR_LEN );
p += (sizeof(int) + FL_SYS_SENTINEL_STR_LEN);
}
printf ("malloc() allocated %d bytes at address 0x%lx\n", (int)nBytes, (long)p);
return p;
#else
return malloc (nBytes);
#endif /* FL_SYS_MEM_CORRUPTION */
}
/* ---------------------------------------------------------------------- *
* *
* f l f r e e *
* *
* Wrapper for ANSI C routine free(). Used to catch heap corruption. *
* *
* ---------------------------------------------------------------------- */
void flfree ( void * p )
{
#ifdef FL_SYS_MEM_CORRUPTION
int nBytes;
char * pp;
/* the beginning of allocated block */
pp = (char *)p - (sizeof(int) + FL_SYS_SENTINEL_STR_LEN);
/* number of bytes that was allocated */
nBytes = *((int *) pp);
printf ("freeing memory, %d bytes at 0x%lx\n", nBytes, (long)p);
/* is start sentinel ok ? */
if( memcmp(pp + sizeof(int), sentinelStr, FL_SYS_SENTINEL_STR_LEN) != 0)
printf ("Error, memory corruption detected !\n");
/* is end sentinel ok ? */
if( memcmp((char *)p + nBytes, sentinelStr, FL_SYS_SENTINEL_STR_LEN) != 0)
printf ("Error, memory corruption detected !\n");
/* trash start sentinel, so we know that region was freed */
memset (pp + sizeof(int), 0, FL_SYS_SENTINEL_STR_LEN);
/* free memory */
free (pp);
#else
free (p);
#endif /* FL_SYS_MEM_CORRUPTION */
}
/* PCI EVB specific */
void setWindowOffset(FLBoolean using8KB, volatile FLByte * baseAddr)
{
/* PortaDoc EVB is Used*/
FLDword pciValueToSet;
volatile FLByte * pciRegAddress = baseAddr + HIB_PCI_CONTROL_REGISTER;
if(using8KB)
pciValueToSet = (PCI_MEM_WIN_0 | BUS_ACESS_16_BIT | PCI_WIN_SIZE_32K);
else
pciValueToSet = (PCI_MEM_WIN_1 | BUS_ACESS_16_BIT | PCI_WIN_SIZE_32K);
*((volatile FLWord FAR0*)(pciRegAddress))=(FLWord)(pciValueToSet);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -