forked from xt-sys/exectos
Rename memory related routines to follow naming convention
This commit is contained in:
168
xtldr/memory.c
168
xtldr/memory.c
@@ -9,6 +9,88 @@
|
||||
#include <xtldr.h>
|
||||
|
||||
|
||||
/**
|
||||
* This routine allocates one or more 4KB pages.
|
||||
*
|
||||
* @param Pages
|
||||
* The number of contiguous 4KB pages to allocate.
|
||||
*
|
||||
* @param Memory
|
||||
* The pointer to a physical address.
|
||||
*
|
||||
* @return This routine returns a status code.
|
||||
*
|
||||
* @since XT 1.0
|
||||
*/
|
||||
XTCDECL
|
||||
EFI_STATUS
|
||||
BlAllocateMemoryPages(IN UINT64 Pages,
|
||||
OUT PEFI_PHYSICAL_ADDRESS Memory)
|
||||
{
|
||||
return EfiSystemTable->BootServices->AllocatePages(AllocateAnyPages, EfiLoaderData, Pages, Memory);
|
||||
}
|
||||
|
||||
/**
|
||||
* This routine allocates a pool memory.
|
||||
*
|
||||
* @param Size
|
||||
* The number of bytes to allocate from the pool.
|
||||
*
|
||||
* @param Memory
|
||||
* The pointer to a physical address.
|
||||
*
|
||||
* @return This routine returns a status code.
|
||||
*
|
||||
* @since XT 1.0
|
||||
*/
|
||||
XTCDECL
|
||||
EFI_STATUS
|
||||
BlAllocateMemoryPool(IN UINT_PTR Size,
|
||||
OUT PVOID *Memory)
|
||||
{
|
||||
/* Allocate pool */
|
||||
return EfiSystemTable->BootServices->AllocatePool(EfiLoaderData, Size, Memory);
|
||||
}
|
||||
|
||||
/**
|
||||
* This routine frees memory pages.
|
||||
*
|
||||
* @param Pages
|
||||
* The number of contiguous 4 KB pages to free.
|
||||
*
|
||||
* @param Memory
|
||||
* The base physical address of the pages to be freed.
|
||||
*
|
||||
* @return This routine returns a status code.
|
||||
*
|
||||
* @since XT 1.0
|
||||
*/
|
||||
XTCDECL
|
||||
EFI_STATUS
|
||||
BlFreeMemoryPages(IN UINT64 Pages,
|
||||
IN EFI_PHYSICAL_ADDRESS Memory)
|
||||
{
|
||||
return EfiSystemTable->BootServices->FreePages(Memory, Pages);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns pool memory to the system.
|
||||
*
|
||||
* @param Memory
|
||||
* The pointer to the buffer to free.
|
||||
*
|
||||
* @return This routine returns a status code.
|
||||
*
|
||||
* @since XT 1.0
|
||||
*/
|
||||
XTCDECL
|
||||
EFI_STATUS
|
||||
BlFreeMemoryPool(IN PVOID Memory)
|
||||
{
|
||||
/* Free pool */
|
||||
return EfiSystemTable->BootServices->FreePool(Memory);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the memory descriptors which define a memory map of all the physical memory ranges reserved by the UEFI.
|
||||
*
|
||||
@@ -50,14 +132,14 @@ BlGetMemoryMap(OUT PEFI_MEMORY_MAP MemoryMap)
|
||||
if(MemoryMap->Map)
|
||||
{
|
||||
/* Free allocated memory */
|
||||
BlMemoryFreePool(MemoryMap->Map);
|
||||
BlFreeMemoryPool(MemoryMap->Map);
|
||||
}
|
||||
return Status;
|
||||
}
|
||||
|
||||
/* Allocate the desired amount of memory */
|
||||
MemoryMap->MapSize += 2 * MemoryMap->DescriptorSize;
|
||||
BlMemoryAllocatePool(MemoryMap->MapSize, (PVOID *)&MemoryMap->Map);
|
||||
BlAllocateMemoryPool(MemoryMap->MapSize, (PVOID *)&MemoryMap->Map);
|
||||
}
|
||||
while(Status == STATUS_EFI_BUFFER_TOO_SMALL);
|
||||
|
||||
@@ -71,85 +153,3 @@ BlGetMemoryMap(OUT PEFI_MEMORY_MAP MemoryMap)
|
||||
/* Return success */
|
||||
return STATUS_EFI_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* This routine allocates one or more 4KB pages.
|
||||
*
|
||||
* @param Pages
|
||||
* The number of contiguous 4KB pages to allocate.
|
||||
*
|
||||
* @param Memory
|
||||
* The pointer to a physical address.
|
||||
*
|
||||
* @return This routine returns a status code.
|
||||
*
|
||||
* @since XT 1.0
|
||||
*/
|
||||
XTCDECL
|
||||
EFI_STATUS
|
||||
BlMemoryAllocatePages(IN UINT64 Pages,
|
||||
OUT PEFI_PHYSICAL_ADDRESS Memory)
|
||||
{
|
||||
return EfiSystemTable->BootServices->AllocatePages(AllocateAnyPages, EfiLoaderData, Pages, Memory);
|
||||
}
|
||||
|
||||
/**
|
||||
* This routine allocates a pool memory.
|
||||
*
|
||||
* @param Size
|
||||
* The number of bytes to allocate from the pool.
|
||||
*
|
||||
* @param Memory
|
||||
* The pointer to a physical address.
|
||||
*
|
||||
* @return This routine returns a status code.
|
||||
*
|
||||
* @since XT 1.0
|
||||
*/
|
||||
XTCDECL
|
||||
EFI_STATUS
|
||||
BlMemoryAllocatePool(IN UINT_PTR Size,
|
||||
OUT PVOID *Memory)
|
||||
{
|
||||
/* Allocate pool */
|
||||
return EfiSystemTable->BootServices->AllocatePool(EfiLoaderData, Size, Memory);
|
||||
}
|
||||
|
||||
/**
|
||||
* This routine frees memory pages.
|
||||
*
|
||||
* @param Pages
|
||||
* The number of contiguous 4 KB pages to free.
|
||||
*
|
||||
* @param Memory
|
||||
* The base physical address of the pages to be freed.
|
||||
*
|
||||
* @return This routine returns a status code.
|
||||
*
|
||||
* @since XT 1.0
|
||||
*/
|
||||
XTCDECL
|
||||
EFI_STATUS
|
||||
BlMemoryFreePages(IN UINT64 Pages,
|
||||
IN EFI_PHYSICAL_ADDRESS Memory)
|
||||
{
|
||||
return EfiSystemTable->BootServices->FreePages(Memory, Pages);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns pool memory to the system.
|
||||
*
|
||||
* @param Memory
|
||||
* The pointer to the buffer to free.
|
||||
*
|
||||
* @return This routine returns a status code.
|
||||
*
|
||||
* @since XT 1.0
|
||||
*/
|
||||
XTCDECL
|
||||
EFI_STATUS
|
||||
BlMemoryFreePool(IN PVOID Memory)
|
||||
{
|
||||
/* Free pool */
|
||||
return EfiSystemTable->BootServices->FreePool(Memory);
|
||||
}
|
||||
|
Reference in New Issue
Block a user