aboutsummaryrefslogtreecommitdiff
path: root/lib/mlibc/options/internal/x86-include
diff options
context:
space:
mode:
Diffstat (limited to 'lib/mlibc/options/internal/x86-include')
-rwxr-xr-xlib/mlibc/options/internal/x86-include/mlibc/arch-defs.hpp13
-rwxr-xr-xlib/mlibc/options/internal/x86-include/mlibc/thread.hpp21
2 files changed, 34 insertions, 0 deletions
diff --git a/lib/mlibc/options/internal/x86-include/mlibc/arch-defs.hpp b/lib/mlibc/options/internal/x86-include/mlibc/arch-defs.hpp
new file mode 100755
index 0000000..aa8fe38
--- /dev/null
+++ b/lib/mlibc/options/internal/x86-include/mlibc/arch-defs.hpp
@@ -0,0 +1,13 @@
+#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-include/mlibc/thread.hpp b/lib/mlibc/options/internal/x86-include/mlibc/thread.hpp
new file mode 100755
index 0000000..3475fb4
--- /dev/null
+++ b/lib/mlibc/options/internal/x86-include/mlibc/thread.hpp
@@ -0,0 +1,21 @@
+#pragma once
+
+#include <stdint.h>
+#include <mlibc/tcb.hpp>
+
+namespace mlibc {
+
+inline Tcb *get_current_tcb() {
+ uintptr_t ptr;
+ asm ("movl %%gs:0, %0" : "=r"(ptr));
+ return reinterpret_cast<Tcb *>(ptr);
+}
+
+inline uintptr_t get_sp() {
+ uintptr_t esp;
+ asm ("mov %%esp, %0" : "=r"(esp));
+ return esp;
+}
+
+} // namespace mlibc
+