From 7477a0f942c374b652da4f80cdb36d4661aac3c8 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Sun, 13 Oct 2024 15:29:55 +0200 Subject: IMP: Delete the memory list when exiting process. IMP: Add Allocation (and delete) of MemoryList. IMP: BitMap allocator must now allocate directories as well. IMP: Add Handover arch to check if executable is an AMD64 executable or ARM64 executable. FIX: Add ::EFI::Stop, when a thread doesn't load correctly. Signed-off-by: Amlal El Mahrouss --- dev/crt/src/alloca.cxx | 9 ++++++++ dev/crt/src/base_exception.cxx | 9 ++++++++ dev/crt/src/crt_lib.cxx | 13 ----------- dev/crt/src/new+delete.cxx | 52 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 70 insertions(+), 13 deletions(-) create mode 100644 dev/crt/src/alloca.cxx create mode 100644 dev/crt/src/base_exception.cxx delete mode 100644 dev/crt/src/crt_lib.cxx create mode 100644 dev/crt/src/new+delete.cxx (limited to 'dev/crt/src') diff --git a/dev/crt/src/alloca.cxx b/dev/crt/src/alloca.cxx new file mode 100644 index 00000000..d2f684b3 --- /dev/null +++ b/dev/crt/src/alloca.cxx @@ -0,0 +1,9 @@ +/* ------------------------------------------- + + Copyright ZKA Technologies. + +------------------------------------------- */ + +#include + +/// @note Just here for building. diff --git a/dev/crt/src/base_exception.cxx b/dev/crt/src/base_exception.cxx new file mode 100644 index 00000000..a8a43ac7 --- /dev/null +++ b/dev/crt/src/base_exception.cxx @@ -0,0 +1,9 @@ +/* ------------------------------------------- + + Copyright ZKA Technologies. + +------------------------------------------- */ + +#include + +/// @note Just here for building. diff --git a/dev/crt/src/crt_lib.cxx b/dev/crt/src/crt_lib.cxx deleted file mode 100644 index 530e40db..00000000 --- a/dev/crt/src/crt_lib.cxx +++ /dev/null @@ -1,13 +0,0 @@ -/* ------------------------------------------- - - Copyright ZKA Technologies. - -------------------------------------------- */ - -#include -#include -#include -#include -#include - -/// @note Just here for building. diff --git a/dev/crt/src/new+delete.cxx b/dev/crt/src/new+delete.cxx new file mode 100644 index 00000000..1241bf66 --- /dev/null +++ b/dev/crt/src/new+delete.cxx @@ -0,0 +1,52 @@ +/* ------------------------------------------- + + Copyright ZKA Technologies. + +------------------------------------------- */ + +#include + +#define kAllocSyscallId "mov $10, %%r9\n\t" +#define kFreeSyscallId "mov $11, %%r9\n\t" + +void* operator new(size_t length) +{ + void* ptr = nullptr; + + // do syscall according to PEF convention. + asm ("mov %0, %%r8\n\t" + kAllocSyscallId + "syscall" + : "=r" (ptr)); + + return ptr; +} + +void* operator new[](size_t length) +{ + ptr_type ptr = nullptr; + + // do syscall according to PEF convention. + asm ("mov %0, %%r8\n\t" + kAllocSyscallId + "syscall" + : "=r" (ptr)); + + return ptr; +} + +void operator delete(void* ptr) noexcept +{ + asm ("mov %0, %%r8\n\t" + kFreeSyscallId + "syscall" + : "=r" (ptr)); +} + +void operator delete[](void* ptr) noexcept +{ + asm ("mov %0, %%r8\n\t" + kFreeSyscallId + "syscall" + : "=r" (ptr)); +} -- cgit v1.2.3