2021-10-10 14:39:17 +08:00
|
|
|
|
|
|
|
#include "../main.h"
|
2021-11-06 23:40:50 +08:00
|
|
|
#include "../efimain.h"
|
2021-10-10 14:39:17 +08:00
|
|
|
#include "memory.h"
|
|
|
|
#include "../runtime/stdio.h"
|
2021-10-11 23:35:54 +08:00
|
|
|
#include "../extlib/dlmalloc/malloc-2.8.6.h"
|
2021-10-10 14:39:17 +08:00
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
|
2021-10-23 19:38:19 +08:00
|
|
|
uint64_t memory_KernelMappingBottom = KERNEL_MISC_MAPPING;
|
|
|
|
|
2021-10-10 14:39:17 +08:00
|
|
|
void *efiMallocTyped(size_t size, EFI_MEMORY_TYPE type) {
|
|
|
|
void *data;
|
|
|
|
efiBootServices->AllocatePool(type, size, &data);
|
|
|
|
memset(data, 0, size);
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
|
|
|
void *efiMalloc(size_t size) {
|
|
|
|
return efiMallocTyped(size, EfiLoaderData);
|
|
|
|
}
|
|
|
|
|
|
|
|
void efiFree(void *data) {
|
|
|
|
efiBootServices->FreePool(data);
|
|
|
|
}
|
|
|
|
|
|
|
|
void *kMalloc(size_t size) {
|
2021-10-11 23:35:54 +08:00
|
|
|
void *mem = dlmalloc(size);
|
2021-10-10 14:39:17 +08:00
|
|
|
io_Printf("kMalloc: size=%llu, pos=0x%llx\n", size, mem);
|
|
|
|
return mem;
|
|
|
|
}
|
|
|
|
|
|
|
|
void kFree(void *data) {
|
|
|
|
io_Printf("kFree: 0x%llx\n", data);
|
2021-10-11 23:35:54 +08:00
|
|
|
dlfree(data);
|
2021-10-10 14:39:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void *kMemoryMap(void *desiredVirtual, int pageCount, int protectionFlags, int flags, int fd) {
|
|
|
|
}
|
|
|
|
|
|
|
|
void kMemoryUnmap(void *pageStart, int pageCount) {
|
|
|
|
}
|