summaryrefslogtreecommitdiff
path: root/lib/mlibc/options/internal/x86_64-include
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2024-03-07 17:28:00 -0500
committerIan Moffett <ian@osmora.org>2024-03-07 17:28:32 -0500
commitbd5969fc876a10b18613302db7087ef3c40f18e1 (patch)
tree7c2b8619afe902abf99570df2873fbdf40a4d1a1 /lib/mlibc/options/internal/x86_64-include
parenta95b38b1b92b172e6cc4e8e56a88a30cc65907b0 (diff)
lib: Add mlibc
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'lib/mlibc/options/internal/x86_64-include')
-rw-r--r--lib/mlibc/options/internal/x86_64-include/mlibc/arch-defs.hpp12
-rw-r--r--lib/mlibc/options/internal/x86_64-include/mlibc/thread.hpp20
2 files changed, 32 insertions, 0 deletions
diff --git a/lib/mlibc/options/internal/x86_64-include/mlibc/arch-defs.hpp b/lib/mlibc/options/internal/x86_64-include/mlibc/arch-defs.hpp
new file mode 100644
index 0000000..0a4789f
--- /dev/null
+++ b/lib/mlibc/options/internal/x86_64-include/mlibc/arch-defs.hpp
@@ -0,0 +1,12 @@
+#ifndef MLIBC_ARCH_DEFS_HPP
+#define MLIBC_ARCH_DEFS_HPP
+
+#include <stddef.h>
+
+namespace mlibc {
+
+inline constexpr size_t page_size = 0x1000;
+
+} // namespace mlibc
+
+#endif // MLIBC_ARCH_DEFS_HPP
diff --git a/lib/mlibc/options/internal/x86_64-include/mlibc/thread.hpp b/lib/mlibc/options/internal/x86_64-include/mlibc/thread.hpp
new file mode 100644
index 0000000..ed02b67
--- /dev/null
+++ b/lib/mlibc/options/internal/x86_64-include/mlibc/thread.hpp
@@ -0,0 +1,20 @@
+#pragma once
+
+#include <stdint.h>
+#include <mlibc/tcb.hpp>
+
+namespace mlibc {
+
+inline Tcb *get_current_tcb() {
+ uintptr_t ptr;
+ asm ("movq %%fs:0, %0" : "=r"(ptr));
+ return reinterpret_cast<Tcb *>(ptr);
+}
+
+inline uintptr_t get_sp() {
+ uintptr_t rsp;
+ asm ("mov %%rsp, %0" : "=r"(rsp));
+ return rsp;
+}
+
+} // namespace mlibc