syscall.c 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /*------------------------------------------------------------------------*/
  2. /* Sample code of OS dependent controls for FatFs */
  3. /* (C)ChaN, 2014 */
  4. /* Portions COPYRIGHT 2017 STMicroelectronics */
  5. /* Portions Copyright (C) 2014, ChaN, all right reserved */
  6. /*------------------------------------------------------------------------*/
  7. /**
  8. ******************************************************************************
  9. * @attention
  10. *
  11. * Copyright (c) 2017 STMicroelectronics. All rights reserved.
  12. *
  13. * This software component is licensed by ST under BSD 3-Clause license,
  14. * the "License"; You may not use this file except in compliance with the
  15. * License. You may obtain a copy of the License at:
  16. * opensource.org/licenses/BSD-3-Clause
  17. *
  18. ******************************************************************************
  19. **/
  20. #include "fatfs/ff.h"
  21. #if _FS_REENTRANT
  22. /*------------------------------------------------------------------------*/
  23. /* Create a Synchronization Object */
  24. /*------------------------------------------------------------------------*/
  25. /* This function is called in f_mount() function to create a new
  26. / synchronization object, such as semaphore and mutex. When a 0 is returned,
  27. / the f_mount() function fails with FR_INT_ERR.
  28. */
  29. int ff_cre_syncobj ( /* 1:Function succeeded, 0:Could not create the sync object */
  30. BYTE vol, /* Corresponding volume (logical drive number) */
  31. _SYNC_t *sobj /* Pointer to return the created sync object */
  32. )
  33. {
  34. return 0;
  35. }
  36. /*------------------------------------------------------------------------*/
  37. /* Delete a Synchronization Object */
  38. /*------------------------------------------------------------------------*/
  39. /* This function is called in f_mount() function to delete a synchronization
  40. / object that created with ff_cre_syncobj() function. When a 0 is returned,
  41. / the f_mount() function fails with FR_INT_ERR.
  42. */
  43. int ff_del_syncobj ( /* 1:Function succeeded, 0:Could not delete due to any error */
  44. _SYNC_t sobj /* Sync object tied to the logical drive to be deleted */
  45. )
  46. {
  47. return 0;
  48. }
  49. /*------------------------------------------------------------------------*/
  50. /* Request Grant to Access the Volume */
  51. /*------------------------------------------------------------------------*/
  52. /* This function is called on entering file functions to lock the volume.
  53. / When a 0 is returned, the file function fails with FR_TIMEOUT.
  54. */
  55. int ff_req_grant ( /* 1:Got a grant to access the volume, 0:Could not get a grant */
  56. _SYNC_t sobj /* Sync object to wait */
  57. )
  58. {
  59. return 0;
  60. }
  61. /*------------------------------------------------------------------------*/
  62. /* Release Grant to Access the Volume */
  63. /*------------------------------------------------------------------------*/
  64. /* This function is called on leaving file functions to unlock the volume.
  65. */
  66. void ff_rel_grant (
  67. _SYNC_t sobj /* Sync object to be signaled */
  68. )
  69. {
  70. }
  71. #endif
  72. #if _USE_LFN == 3 /* LFN with a working buffer on the heap */
  73. /*------------------------------------------------------------------------*/
  74. /* Allocate a memory block */
  75. /*------------------------------------------------------------------------*/
  76. /* If a NULL is returned, the file function fails with FR_NOT_ENOUGH_CORE.
  77. */
  78. void* ff_memalloc ( /* Returns pointer to the allocated memory block */
  79. UINT msize /* Number of bytes to allocate */
  80. )
  81. {
  82. return ff_malloc(msize); /* Allocate a new memory block with POSIX API */
  83. }
  84. /*------------------------------------------------------------------------*/
  85. /* Free a memory block */
  86. /*------------------------------------------------------------------------*/
  87. void ff_memfree (
  88. void* mblock /* Pointer to the memory block to free */
  89. )
  90. {
  91. ff_free(mblock); /* Discard the memory block with POSIX API */
  92. }
  93. #endif