summaryrefslogtreecommitdiffhomepage
path: root/dev/crt/src
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-10-13 15:29:55 +0200
committerAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-10-13 15:29:55 +0200
commit7477a0f942c374b652da4f80cdb36d4661aac3c8 (patch)
treed06627de4689b5661f4b95c4fa15f932b004ad13 /dev/crt/src
parent182f2baa4d38a286d3453cc0da90ebec5fb25266 (diff)
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 <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'dev/crt/src')
-rw-r--r--dev/crt/src/alloca.cxx9
-rw-r--r--dev/crt/src/base_exception.cxx (renamed from dev/crt/src/crt_lib.cxx)4
-rw-r--r--dev/crt/src/new+delete.cxx52
3 files changed, 61 insertions, 4 deletions
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 <crt/alloca.hxx>
+
+/// @note Just here for building.
diff --git a/dev/crt/src/crt_lib.cxx b/dev/crt/src/base_exception.cxx
index 530e40db..a8a43ac7 100644
--- a/dev/crt/src/crt_lib.cxx
+++ b/dev/crt/src/base_exception.cxx
@@ -4,10 +4,6 @@
------------------------------------------- */
-#include <crt/alloca.hxx>
-#include <crt/defines.hxx>
#include <crt/base_exception.hxx>
-#include <crt/math.hxx>
-#include <crt/base_alloc.hxx>
/// @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 <crt/base_alloc.hxx>
+
+#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));
+}