ssi_pal_file_plat.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /**************************************************************************************
  2. * Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved *
  3. * *
  4. * This file and the related binary are licensed under the following license: *
  5. * *
  6. * ARM Object Code and Header Files License, v1.0 Redistribution. *
  7. * *
  8. * Redistribution and use of object code, header files, and documentation, without *
  9. * modification, are permitted provided that the following conditions are met: *
  10. * *
  11. * 1) Redistributions must reproduce the above copyright notice and the *
  12. * following disclaimer in the documentation and/or other materials *
  13. * provided with the distribution. *
  14. * *
  15. * 2) Unless to the extent explicitly permitted by law, no reverse *
  16. * engineering, decompilation, or disassembly of is permitted. *
  17. * *
  18. * 3) Redistribution and use is permitted solely for the purpose of *
  19. * developing or executing applications that are targeted for use *
  20. * on an ARM-based product. *
  21. * *
  22. * DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND *
  23. * CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT *
  24. * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, *
  25. * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE *
  26. * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, *
  27. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED *
  28. * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
  29. * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
  30. * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
  31. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
  32. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
  33. **************************************************************************************/
  34. #ifndef _SSI_PAL_FILE_INT_H
  35. #define _SSI_PAL_FILE_INT_H
  36. #ifdef __cplusplus
  37. extern "C"
  38. {
  39. #endif
  40. #include "stdio.h"
  41. /**
  42. * @brief File Description:
  43. * This file contains wrapper functions for file related operations.
  44. */
  45. /**** ----- Files General Definitions ----- ****/
  46. /* Definitions for file modes */
  47. #define SASI_PAL_MAX_SIZE_MODE 4
  48. #define SASI_PAL_NUM_OF_SUPPORT_MODES 12
  49. typedef char SaSiPalFileModeStr_t[SASI_PAL_MAX_SIZE_MODE];
  50. typedef SaSiPalFileModeStr_t SaSiPalFileModesTable_t[SASI_PAL_NUM_OF_SUPPORT_MODES];
  51. extern const SaSiPalFileModeStr_t SaSiPalFileModeTable[];
  52. /**** ------------------------------------- ****/
  53. //#define _SaSiFile_t FILE
  54. /*----------------------------
  55. PUBLIC FUNCTIONS
  56. -----------------------------------*/
  57. /**
  58. * @brief A wrapper for fopen functionality (to create a new file, the file is opened for read and
  59. * write).
  60. *
  61. */
  62. #define _SaSi_PalFileCreate(aFileName) SaSi_PalFOpen(aFileName, SASI_PAL_WriteAndRead)
  63. /**
  64. * @brief A wrapper for fopen functionality. SaSiPalFileModeTable contains all possible modes
  65. * for fopen
  66. *
  67. */
  68. #define _SaSi_PalFOpen(aFileName, aFileMode) ((SaSiFile_t)fopen(aFileName, SaSiPalFileModeTable[aFileMode]))
  69. /**
  70. * @brief A wrapper for fclose functionality.
  71. *
  72. */
  73. #define _SaSi_PalFClose(aFileHandle) fclose((FILE*)aFileHandle)
  74. /**
  75. * @brief A wrapper for fseek functionality
  76. *
  77. */
  78. #define _SaSi_PalFSeek(aFileHandle, aOffset, aSeekOrigin) fseek((FILE*)aFileHandle, aOffset, aSeekOrigin)
  79. /**
  80. * @brief A wrapper for ftell functionality
  81. *
  82. */
  83. #define _SaSi_PalFTell(aFileHandle) ftell((FILE*)aFileHandle)
  84. /**
  85. * @brief A wrapper for fread functionality
  86. *
  87. */
  88. #define _SaSi_PalFRead(aFileHandle, aBuffer, aSize) fread(aBuffer, 1, aSize, (FILE*)aFileHandle)
  89. /**
  90. * @brief A wrapper for fwrite functionality
  91. *
  92. */
  93. #define _SaSi_PalFWrite(aFileHandle, aBuffer, aSize) fwrite(aBuffer, 1, aSize, (FILE*)aFileHandle)
  94. /**
  95. * @brief A wrapper for fflush functionality
  96. *
  97. */
  98. #define _SaSi_PalFFlush(aFileHandle) fflush((FILE*)aFileHandle)
  99. #ifdef __cplusplus
  100. }
  101. #endif
  102. #endif