memory: add AllocateKernelMapping

This is just quick and dirty, with nothing to free it
This commit is contained in:
Edgaru089 2021-10-23 19:38:19 +08:00
parent ade70d176a
commit a3fe5c5902
2 changed files with 13 additions and 0 deletions

View File

@ -7,6 +7,8 @@
#include <string.h>
uint64_t memory_KernelMappingBottom = KERNEL_MISC_MAPPING;
void *efiMallocTyped(size_t size, EFI_MEMORY_TYPE type) {
void *data;
efiBootServices->AllocatePool(type, size, &data);

View File

@ -25,6 +25,17 @@ extern "C" {
#define KERNEL_MISC_SIZE (KERNEL_IDT_SIZE + KERNEL_GDT_SIZE) // add all the misc sizes
#define KERNEL_MAPPING_BOTTOM (KERNEL_MISC_MAPPING) // bottom of the static kernel mapping range
extern uint64_t memory_KernelMappingBottom;
// Allocates a new region for memory mapping in the kernel memory range
// align must be a exponent of 2
static inline uint64_t memory_AllocateKernelMapping(uint64_t size, uint64_t align) {
memory_KernelMappingBottom -= size;
memory_KernelMappingBottom &= ~(align - 1);
return memory_KernelMappingBottom;
}
extern uint64_t paging_LoaderCodeAddress, paging_LoaderCodeSize; // physical address for loader code section
static inline uint64_t paging_MapFunction(void *func) {