ugfx/src/gfile/fatfs/src/syscall.c

76 lines
2.6 KiB
C
Raw Normal View History

2014-06-25 03:23:57 +00:00
/*
* This file is subject to the terms of the GFX License. If a copy of
* the license was not distributed with this file, you can obtain one at:
*
* http://ugfx.org/license.html
*/
2014-06-25 03:23:57 +00:00
#include "gfx.h"
2014-06-25 03:23:57 +00:00
#include "ff.h"
#if _FS_REENTRANT
2014-06-25 03:23:57 +00:00
/*------------------------------------------------------------------------*/
/* Static array of Synchronization Objects */
/*------------------------------------------------------------------------*/
static gfxSem ff_sem[_VOLUMES];
2014-06-25 03:23:57 +00:00
/*------------------------------------------------------------------------*/
/* Create a Synchronization Object */
/*------------------------------------------------------------------------*/
int ff_cre_syncobj(BYTE vol, _SYNC_t *sobj)
{
*sobj = ff_sem[vol];
gfxSemInit(sobj, 1, MAX_SEMAPHORE_COUNT);
2014-06-25 03:23:57 +00:00
return 1;
2014-06-25 03:23:57 +00:00
}
/*------------------------------------------------------------------------*/
/* Delete a Synchronization Object */
/*------------------------------------------------------------------------*/
int ff_del_syncobj(_SYNC_t sobj)
{
gfxSemDestroy( (gfxSem*)&sobj );
2014-06-25 03:23:57 +00:00
return 1;
2014-06-25 03:23:57 +00:00
}
/*------------------------------------------------------------------------*/
/* Request Grant to Access the Volume */
/*------------------------------------------------------------------------*/
int ff_req_grant(_SYNC_t sobj)
{
if (gfxSemWait( (gfxSem*)&sobj, (delaytime_t)_FS_TIMEOUT) )
return TRUE;
return FALSE;
2014-06-25 03:23:57 +00:00
}
/*------------------------------------------------------------------------*/
/* Release Grant to Access the Volume */
/*------------------------------------------------------------------------*/
void ff_rel_grant(_SYNC_t sobj)
{
gfxSemSignal( (gfxSem*)&sobj );
2014-06-25 03:23:57 +00:00
}
#endif /* _FS_REENTRANT */
#if _USE_LFN == 3 /* LFN with a working buffer on the heap */
/*------------------------------------------------------------------------*/
/* Allocate a memory block */
/*------------------------------------------------------------------------*/
void *ff_memalloc(UINT size)
{
return gfxAlloc( (size_t)size );
2014-06-25 03:23:57 +00:00
}
/*------------------------------------------------------------------------*/
/* Free a memory block */
/*------------------------------------------------------------------------*/
void ff_memfree(void *mblock)
{
gfxFree(mblock);
2014-06-25 03:23:57 +00:00
}
#endif /* _USE_LFN == 3 */