]> cloudbase.mooo.com Git - z180-stamp.git/blobdiff - fatfs/src/option/syscall.c
Merge branch 'chan-fatfs' into fatfs-integration
[z180-stamp.git] / fatfs / src / option / syscall.c
index ccfd47e5e4319c1c2a458cb98ced4a9744353b44..c9d219b797027dab0c1ad1721a62f1084a18f9aa 100644 (file)
@@ -1,10 +1,8 @@
 /*------------------------------------------------------------------------*/\r
 /* Sample code of OS dependent controls for FatFs                         */\r
-/* (C)ChaN, 2012                                                          */\r
+/* (C)ChaN, 2014                                                          */\r
 /*------------------------------------------------------------------------*/\r
 \r
-#include <stdlib.h>            /* ANSI memory controls */\r
-#include <malloc.h>            /* ANSI memory controls */\r
 \r
 #include "../ff.h"\r
 \r
 /*------------------------------------------------------------------------*/\r
 /* Create a Synchronization Object\r
 /*------------------------------------------------------------------------*/\r
-/* This function is called by f_mount() function to create a new\r
-/  synchronization object, such as semaphore and mutex. When a 0 is\r
-/  returned, the f_mount() function fails with FR_INT_ERR.\r
+/* This function is called in f_mount() function to create a new\r
+/  synchronization object, such as semaphore and mutex. When a 0 is returned,\r
+/  the f_mount() function fails with FR_INT_ERR.\r
 */\r
 \r
-int ff_cre_syncobj (   /* 1:Function succeeded, 0:Could not create due to any error */\r
-       BYTE vol,                       /* Corresponding logical drive being processed */\r
-       _SYNC_tsobj           /* Pointer to return the created sync object */\r
+int ff_cre_syncobj (   /* 1:Function succeeded, 0:Could not create the sync object */\r
+       BYTE vol,                       /* Corresponding volume (logical drive number) */\r
+       _SYNC_t *sobj           /* Pointer to return the created sync object */\r
 )\r
 {\r
        int ret;\r
@@ -29,13 +27,13 @@ int ff_cre_syncobj (        /* 1:Function succeeded, 0:Could not create due to any erro
        *sobj = CreateMutex(NULL, FALSE, NULL);         /* Win32 */\r
        ret = (int)(*sobj != INVALID_HANDLE_VALUE);\r
 \r
-//     *sobj = SyncObjects[vol];               /* uITRON (give a static created semaphore) */\r
-//     ret = 1;\r
+//     *sobj = SyncObjects[vol];                       /* uITRON (give a static sync object) */\r
+//     ret = 1;                                                        /* The initial value of the semaphore must be 1. */\r
 \r
-//     *sobj = OSMutexCreate(0, &err); /* uC/OS-II */\r
+//     *sobj = OSMutexCreate(0, &err);         /* uC/OS-II */\r
 //     ret = (int)(err == OS_NO_ERR);\r
 \r
-//  *sobj = xSemaphoreCreateMutex();   /* FreeRTOS */\r
+//     *sobj = xSemaphoreCreateMutex();        /* FreeRTOS */\r
 //     ret = (int)(*sobj != NULL);\r
 \r
        return ret;\r
@@ -47,8 +45,8 @@ int ff_cre_syncobj (  /* 1:Function succeeded, 0:Could not create due to any erro
 /* Delete a Synchronization Object                                        */\r
 /*------------------------------------------------------------------------*/\r
 /* This function is called in f_mount() function to delete a synchronization\r
-/  object that created with ff_cre_syncobj() function. When a 0 is\r
-/  returned, the f_mount() function fails with FR_INT_ERR.\r
+/  object that created with ff_cre_syncobj() function. When a 0 is returned,\r
+/  the f_mount() function fails with FR_INT_ERR.\r
 */\r
 \r
 int ff_del_syncobj (   /* 1:Function succeeded, 0:Could not delete due to any error */\r
@@ -65,7 +63,7 @@ int ff_del_syncobj (  /* 1:Function succeeded, 0:Could not delete due to any erro
 //     OSMutexDel(sobj, OS_DEL_ALWAYS, &err);  /* uC/OS-II */\r
 //     ret = (int)(err == OS_NO_ERR);\r
 \r
-//  xSemaphoreDelete(sobj);            /* FreeRTOS */\r
+//  vSemaphoreDelete(sobj);            /* FreeRTOS */\r
 //     ret = 1;\r
 \r
        return ret;\r
@@ -77,10 +75,10 @@ int ff_del_syncobj (        /* 1:Function succeeded, 0:Could not delete due to any erro
 /* Request Grant to Access the Volume                                     */\r
 /*------------------------------------------------------------------------*/\r
 /* This function is called on entering file functions to lock the volume.\r
-/  When a FALSE is returned, the file function fails with FR_TIMEOUT.\r
+/  When a 0 is returned, the file function fails with FR_TIMEOUT.\r
 */\r
 \r
-int ff_req_grant (     /* TRUE:Got a grant to access the volume, FALSE:Could not get a grant */\r
+int ff_req_grant (     /* 1:Got a grant to access the volume, 0:Could not get a grant */\r
        _SYNC_t sobj    /* Sync object to wait */\r
 )\r
 {\r
@@ -135,7 +133,7 @@ void* ff_memalloc ( /* Returns pointer to the allocated memory block */
        UINT msize              /* Number of bytes to allocate */\r
 )\r
 {\r
-       return malloc(msize);\r
+       return malloc(msize);   /* Allocate a new memory block with POSIX API */\r
 }\r
 \r
 \r
@@ -147,7 +145,7 @@ void ff_memfree (
        void* mblock    /* Pointer to the memory block to free */\r
 )\r
 {\r
-       free(mblock);\r
+       free(mblock);   /* Discard the memory block with POSIX API */\r
 }\r
 \r
 #endif\r