img_mem_man.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /*!
  2. *****************************************************************************
  3. *
  4. * @File img_mem_man.h
  5. * ---------------------------------------------------------------------------
  6. *
  7. * Copyright (c) Imagination Technologies Ltd.
  8. *
  9. * The contents of this file are subject to the MIT license as set out below.
  10. *
  11. * Permission is hereby granted, free of charge, to any person obtaining a
  12. * copy of this software and associated documentation files (the "Software"),
  13. * to deal in the Software without restriction, including without limitation
  14. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  15. * and/or sell copies of the Software, and to permit persons to whom the
  16. * Software is furnished to do so, subject to the following conditions:
  17. *
  18. * The above copyright notice and this permission notice shall be included in
  19. * all copies or substantial portions of the Software.
  20. *
  21. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  22. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  23. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  24. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  25. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  26. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  27. * THE SOFTWARE.
  28. *
  29. * Alternatively, the contents of this file may be used under the terms of the
  30. * GNU General Public License Version 2 ("GPL")in which case the provisions of
  31. * GPL are applicable instead of those above.
  32. *
  33. * If you wish to allow use of your version of this file only under the terms
  34. * of GPL, and not to allow others to use your version of this file under the
  35. * terms of the MIT license, indicate your decision by deleting the provisions
  36. * above and replace them with the notice and other provisions required by GPL
  37. * as set out in the file called "GPLHEADER" included in this distribution. If
  38. * you do not delete the provisions above, a recipient may use your version of
  39. * this file under the terms of either the MIT license or GPL.
  40. *
  41. * This License is also included in this distribution in the file called
  42. * "MIT_COPYING".
  43. *
  44. *****************************************************************************/
  45. #ifndef IMG_MEM_MAN_UAPI_H
  46. #define IMG_MEM_MAN_UAPI_H
  47. /* memory attributes */
  48. enum img_mem_attr {
  49. IMG_MEM_ATTR_CACHED = 0x00000001,
  50. IMG_MEM_ATTR_UNCACHED = 0x00000002,
  51. IMG_MEM_ATTR_WRITECOMBINE = 0x00000004,
  52. /* Special */
  53. IMG_MEM_ATTR_SECURE = 0x00000010,
  54. IMG_MEM_ATTR_NOMAP = 0x00000020,
  55. IMG_MEM_ATTR_NOSYNC = 0x00000040,
  56. /* Internal */
  57. IMG_MEM_ATTR_MMU = 0x10000000,
  58. IMG_MEM_ATTR_OCM = 0x20000000,
  59. };
  60. /* Cache attributes mask */
  61. #define IMG_MEM_ATTR_CACHE_MASK 0xf
  62. /* Supported heap types */
  63. enum img_mem_heap_type {
  64. IMG_MEM_HEAP_TYPE_UNKNOWN = 0,
  65. IMG_MEM_HEAP_TYPE_UNIFIED,
  66. IMG_MEM_HEAP_TYPE_CARVEOUT,
  67. IMG_MEM_HEAP_TYPE_ION,
  68. IMG_MEM_HEAP_TYPE_DMABUF,
  69. IMG_MEM_HEAP_TYPE_COHERENT,
  70. IMG_MEM_HEAP_TYPE_ANONYMOUS,
  71. IMG_MEM_HEAP_TYPE_OCM,
  72. };
  73. /* Heap attributes */
  74. enum img_mem_heap_attrs {
  75. IMG_MEM_HEAP_ATTR_INTERNAL = 0x01,
  76. IMG_MEM_HEAP_ATTR_IMPORT = 0x02,
  77. IMG_MEM_HEAP_ATTR_EXPORT = 0x04,
  78. IMG_MEM_HEAP_ATTR_SEALED = 0x08,
  79. /* User attributes */
  80. IMG_MEM_HEAP_ATTR_LOCAL = 0x10,
  81. IMG_MEM_HEAP_ATTR_SHARED = 0x20,
  82. };
  83. /* heaps ids */
  84. #define IMG_MEM_MAN_HEAP_ID_INVALID 0
  85. #define IMG_MEM_MAN_MIN_HEAP 1
  86. #define IMG_MEM_MAN_MAX_HEAP 16
  87. /* buffer ids (per memory context) */
  88. #define IMG_MEM_MAN_BUF_ID_INVALID 0
  89. #define IMG_MEM_MAN_MIN_BUFFER 1
  90. #define IMG_MEM_MAN_MAX_BUFFER 2000
  91. /* Definition of VA guard gap between allocations */
  92. #define IMG_MEM_VA_GUARD_GAP 0x1000
  93. /* Virtual memory space for buffers allocated
  94. * in the kernel - OCM & device debug buffers */
  95. #define IMG_MEM_VA_HEAP1_BASE 0x8000000ULL
  96. #define IMG_MEM_VA_HEAP1_SIZE 0x40000000ULL
  97. /* Definition of VA guard gap between heaps - 2MB (size of MMU PD) */
  98. #define IMG_MEM_HEAP_GUARD_GAP 0x200000
  99. /* Virtual memory space for buffers allocated in the user space */
  100. #define IMG_MEM_VA_HEAP2_BASE ( \
  101. IMG_MEM_VA_HEAP1_BASE + IMG_MEM_VA_HEAP1_SIZE + IMG_MEM_HEAP_GUARD_GAP)
  102. #define IMG_MEM_VA_HEAP2_SIZE 0x3C0000000ULL
  103. #endif /* IMG_MEM_MAN_UAPI_H */