UefiBootServicesTableLibUnitTestMemory.c 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. /** @file
  2. Implementation of memory related services in the UEFI Boot Services table for use in unit tests.
  3. Copyright (c) Microsoft Corporation
  4. SPDX-License-Identifier: BSD-2-Clause-Patent
  5. **/
  6. #include "UefiBootServicesTableLibUnitTest.h"
  7. /**
  8. Allocates pages from the memory map.
  9. @param Type The type of allocation to perform
  10. @param MemoryType The type of memory to turn the allocated pages
  11. into
  12. @param NumberOfPages The number of pages to allocate
  13. @param Memory A pointer to receive the base allocated memory
  14. address
  15. @return Status. On success, Memory is filled in with the base address allocated
  16. @retval EFI_INVALID_PARAMETER Parameters violate checking rules defined in
  17. spec.
  18. @retval EFI_NOT_FOUND Could not allocate pages match the requirement.
  19. @retval EFI_OUT_OF_RESOURCES No enough pages to allocate.
  20. @retval EFI_SUCCESS Pages successfully allocated.
  21. **/
  22. EFI_STATUS
  23. EFIAPI
  24. UnitTestAllocatePages (
  25. IN EFI_ALLOCATE_TYPE Type,
  26. IN EFI_MEMORY_TYPE MemoryType,
  27. IN UINTN NumberOfPages,
  28. IN OUT EFI_PHYSICAL_ADDRESS *Memory
  29. )
  30. {
  31. return EFI_NOT_AVAILABLE_YET;
  32. }
  33. /**
  34. Frees previous allocated pages.
  35. @param Memory Base address of memory being freed
  36. @param NumberOfPages The number of pages to free
  37. @retval EFI_NOT_FOUND Could not find the entry that covers the range
  38. @retval EFI_INVALID_PARAMETER Address not aligned
  39. @return EFI_SUCCESS -Pages successfully freed.
  40. **/
  41. EFI_STATUS
  42. EFIAPI
  43. UnitTestFreePages (
  44. IN EFI_PHYSICAL_ADDRESS Memory,
  45. IN UINTN NumberOfPages
  46. )
  47. {
  48. return EFI_NOT_AVAILABLE_YET;
  49. }
  50. /**
  51. This function returns a copy of the current memory map. The map is an array of
  52. memory descriptors, each of which describes a contiguous block of memory.
  53. @param MemoryMapSize A pointer to the size, in bytes, of the
  54. MemoryMap buffer. On input, this is the size of
  55. the buffer allocated by the caller. On output,
  56. it is the size of the buffer returned by the
  57. firmware if the buffer was large enough, or the
  58. size of the buffer needed to contain the map if
  59. the buffer was too small.
  60. @param MemoryMap A pointer to the buffer in which firmware places
  61. the current memory map.
  62. @param MapKey A pointer to the location in which firmware
  63. returns the key for the current memory map.
  64. @param DescriptorSize A pointer to the location in which firmware
  65. returns the size, in bytes, of an individual
  66. EFI_MEMORY_DESCRIPTOR.
  67. @param DescriptorVersion A pointer to the location in which firmware
  68. returns the version number associated with the
  69. EFI_MEMORY_DESCRIPTOR.
  70. @retval EFI_SUCCESS The memory map was returned in the MemoryMap
  71. buffer.
  72. @retval EFI_BUFFER_TOO_SMALL The MemoryMap buffer was too small. The current
  73. buffer size needed to hold the memory map is
  74. returned in MemoryMapSize.
  75. @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.
  76. **/
  77. EFI_STATUS
  78. EFIAPI
  79. UnitTestGetMemoryMap (
  80. IN OUT UINTN *MemoryMapSize,
  81. IN OUT EFI_MEMORY_DESCRIPTOR *MemoryMap,
  82. OUT UINTN *MapKey,
  83. OUT UINTN *DescriptorSize,
  84. OUT UINT32 *DescriptorVersion
  85. )
  86. {
  87. return EFI_NOT_AVAILABLE_YET;
  88. }
  89. /**
  90. Allocate pool of a particular type.
  91. @param PoolType Type of pool to allocate
  92. @param Size The amount of pool to allocate
  93. @param Buffer The address to return a pointer to the allocated
  94. pool
  95. @retval EFI_INVALID_PARAMETER PoolType not valid or Buffer is NULL
  96. @retval EFI_OUT_OF_RESOURCES Size exceeds max pool size or allocation failed.
  97. @retval EFI_SUCCESS Pool successfully allocated.
  98. **/
  99. EFI_STATUS
  100. EFIAPI
  101. UnitTestAllocatePool (
  102. IN EFI_MEMORY_TYPE PoolType,
  103. IN UINTN Size,
  104. OUT VOID **Buffer
  105. )
  106. {
  107. return EFI_NOT_AVAILABLE_YET;
  108. }
  109. /**
  110. Frees pool.
  111. @param Buffer The allocated pool entry to free
  112. @retval EFI_INVALID_PARAMETER Buffer is not a valid value.
  113. @retval EFI_SUCCESS Pool successfully freed.
  114. **/
  115. EFI_STATUS
  116. EFIAPI
  117. UnitTestFreePool (
  118. IN VOID *Buffer
  119. )
  120. {
  121. return EFI_NOT_AVAILABLE_YET;
  122. }