Basic memory support
This commit is contained in:
parent
40696e2a1e
commit
3fc97ae98b
@ -10,6 +10,7 @@ include_directories(
|
|||||||
list(APPEND XTLDR_SOURCE
|
list(APPEND XTLDR_SOURCE
|
||||||
${XTLDR_SOURCE_DIR}/console.c
|
${XTLDR_SOURCE_DIR}/console.c
|
||||||
${XTLDR_SOURCE_DIR}/globals.c
|
${XTLDR_SOURCE_DIR}/globals.c
|
||||||
|
${XTLDR_SOURCE_DIR}/memory.c
|
||||||
${XTLDR_SOURCE_DIR}/string.c
|
${XTLDR_SOURCE_DIR}/string.c
|
||||||
${XTLDR_SOURCE_DIR}/xtldr.c)
|
${XTLDR_SOURCE_DIR}/xtldr.c)
|
||||||
|
|
||||||
|
92
xtldr2/memory.c
Normal file
92
xtldr2/memory.c
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
/**
|
||||||
|
* PROJECT: ExectOS
|
||||||
|
* COPYRIGHT: See COPYING.md in the top level directory
|
||||||
|
* FILE: xtldr/memory.c
|
||||||
|
* DESCRIPTION: XT Boot Manager EFI memory management
|
||||||
|
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <xtbm.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
|
||||||
|
BmAllocateEfiPages(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
|
||||||
|
BmAllocateEfiPool(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
|
||||||
|
BmFreeEfiPages(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
|
||||||
|
BmFreeEfiPool(IN PVOID Memory)
|
||||||
|
{
|
||||||
|
/* Free pool */
|
||||||
|
return EfiSystemTable->BootServices->FreePool(Memory);
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user