rtos_memory.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /*!
  2. *******************************************************************************
  3. **
  4. ** \file rtos_memory.h
  5. **
  6. ** \version 1.0
  7. **
  8. ** \date March 20, 2003
  9. **
  10. ** \author Wolfgang Larisch
  11. **
  12. ** \brief A generic OS adaptation layer library
  13. **
  14. ** This header file defines RTOS internal functions which are implemented
  15. ** either in the uC/OS or the Nucleus port (maybe others OSes will follow in
  16. ** the future).
  17. **
  18. ** \attention THIS SAMPLE CODE IS PROVIDED AS IS. GOKE MICROELECTRONICS
  19. ** ACCEPTS NO RESPONSIBILITY OR LIABILITY FOR ANY ERRORS OR
  20. ** OMMISSIONS.
  21. **
  22. ** (C) Copyright 2002 - 2007 by Goke Microelectronics China
  23. **
  24. *******************************************************************************
  25. */
  26. #ifndef RTOS_MEMORY_H
  27. #define RTOS_MEMORY_H
  28. #include "gtypes.h"
  29. #include "rtos_lib.h"
  30. #ifdef __cplusplus
  31. extern "C" {
  32. #endif
  33. /*!
  34. *******************************************************************************
  35. **
  36. ** \brief Allocate a bunch of memory from the system heap
  37. **
  38. ** This function allocates the given size of memory from the available
  39. ** OS controlled SDRAM heap space.
  40. **
  41. ** \param size size of memory in bytes to allocate.
  42. ** \param shared a boolean value which decides whether to allocate a
  43. ** memory block as shared (GTRUE) or as private (GFALSE)
  44. ** memory. Private memory can only be de-allocated by
  45. ** the thread that has allocated the memory, shared
  46. ** memory can be de-allocated by any thread.
  47. **
  48. ** \return memory a pointer to the start address of the allocated memory
  49. ** block, or \b NULL if the required size of memory was not
  50. ** available.
  51. **
  52. ** \sa rtos_types
  53. **
  54. *******************************************************************************
  55. */
  56. RTOS_Memory RTOS_SysMemoryAllocate( RTOS_Size size, RTOS_Flag shared );
  57. /*!
  58. *******************************************************************************
  59. **
  60. ** \brief Release (de-allocate) a bunch of system heap memory
  61. **
  62. ** This function de-allocates a previoulsy allocated bunch of memory.
  63. **
  64. ** \param memory a pointer to the start of the memory block to release.
  65. **
  66. ** \return status the result status, either \b RTOS_OK,
  67. ** \b RTOS_MEMORY_FAILURE if the given memory pointer does not
  68. ** point to dynamic allocated memory or \b RTOS_THREAD_FAILURE
  69. ** if the allocated memory space is owned by a different
  70. ** thread.
  71. **
  72. ** \sa rtos_types
  73. ** \sa rtos_status
  74. **
  75. *******************************************************************************
  76. */
  77. RTOS_Status RTOS_SysMemoryRelease( RTOS_Memory memory );
  78. /*
  79. *******************************************************************************
  80. **
  81. ** This function allocates the given size of memory from the available
  82. ** OS controlled user heap.
  83. ** For better performace, we control all the available OS handled RAM by
  84. ** segments of a min. size of RTOS_HeapMinAllocSize bytes.
  85. **
  86. *******************************************************************************
  87. */
  88. RTOS_Memory RTOS_MemoryAllocate( RTOS_Size bytes, RTOS_Flag shared );
  89. RTOS_Memory RTOS_Malloc( RTOS_Size bytes);
  90. RTOS_Memory RTOS_Realloc( RTOS_Memory addr, RTOS_Size bytes );
  91. /*
  92. *******************************************************************************
  93. **
  94. ** This function de-allocates a previoulsy allocated bunch of memory
  95. ** within the user heap.
  96. **
  97. *******************************************************************************
  98. */
  99. RTOS_Status RTOS_MemoryRelease( RTOS_Memory memory );
  100. /*
  101. *******************************************************************************
  102. **
  103. ** This function sets the given amount of bytes in the given source address
  104. ** the the specified byte value.
  105. **
  106. *******************************************************************************
  107. */
  108. RTOS_Memory RTOS_MemorySet( RTOS_Memory mem, U8 value, RTOS_Size bytes );
  109. #ifdef __cplusplus
  110. }
  111. #endif
  112. /*
  113. *******************************************************************************
  114. **
  115. ** end
  116. **
  117. *******************************************************************************
  118. */
  119. #endif /* RTOS_MEMORY_H */