summaryrefslogtreecommitdiffhomepage
path: root/dev/zka/KernelKit/ThreadLocalStorage.hxx
diff options
context:
space:
mode:
authorAmlal <amlal@el-mahrouss-logic.com>2024-09-22 17:46:11 +0200
committerAmlal <amlal@el-mahrouss-logic.com>2024-09-22 17:46:11 +0200
commit8719b4570a2d10dd49a0d3a47e24f5c55bdda85e (patch)
treeba095740888f3768e08b2ea058b0ea6da2d0403d /dev/zka/KernelKit/ThreadLocalStorage.hxx
parent45944b3d2dab04b763fcc6d10164fe8069e60b08 (diff)
:boom: A big refactor on the filesystem structure.
Signed-off-by: Amlal <amlal@el-mahrouss-logic.com>
Diffstat (limited to 'dev/zka/KernelKit/ThreadLocalStorage.hxx')
-rw-r--r--dev/zka/KernelKit/ThreadLocalStorage.hxx54
1 files changed, 54 insertions, 0 deletions
diff --git a/dev/zka/KernelKit/ThreadLocalStorage.hxx b/dev/zka/KernelKit/ThreadLocalStorage.hxx
new file mode 100644
index 00000000..a25d8926
--- /dev/null
+++ b/dev/zka/KernelKit/ThreadLocalStorage.hxx
@@ -0,0 +1,54 @@
+/* -------------------------------------------
+
+ Copyright ZKA Technologies.
+
+------------------------------------------- */
+
+#ifndef _KERNELKIT_TLS_HPP
+#define _KERNELKIT_TLS_HPP
+
+#include <NewKit/Defines.hxx>
+
+///! @brief Thread Local Storage for newoskrnl.
+
+#define kCookieMag0 'Z'
+#define kCookieMag1 'K'
+#define kCookieMag2 'A'
+
+#define kTLSCookieLen (3U)
+
+struct THREAD_INFORMATION_BLOCK;
+
+/// @brief Thread Information Block.
+/// Located in GS on AMD64, other architectures have their own stuff. (64x0, 32x0, ARM64)
+struct PACKED THREAD_INFORMATION_BLOCK final
+{
+ Kernel::Char f_Cookie[kTLSCookieLen]{0}; //! Thread magic number.
+ Kernel::VoidPtr f_ThreadRecord{nullptr}; //! Thread information record.
+};
+
+///! @brief Cookie Sanity check.
+Kernel::Boolean tls_check_tib(THREAD_INFORMATION_BLOCK* the_tib);
+
+///! @brief new ptr syscall.
+template <typename T>
+T* tls_new_ptr(void) noexcept;
+
+///! @brief delete ptr syscall.
+template <typename T>
+Kernel::Boolean tls_delete_ptr(T* ptr) noexcept;
+
+template <typename T, typename... Args>
+T* tls_new_class(Args&&... args);
+
+/// @brief TLS install TIB and PIB. (syscall)
+EXTERN_C Kernel::Void rt_install_tib(THREAD_INFORMATION_BLOCK* TIB, THREAD_INFORMATION_BLOCK* PIB);
+
+/// @brief TLS check (syscall)
+EXTERN_C Kernel::Bool tls_check_syscall_impl(Kernel::VoidPtr TIB) noexcept;
+
+#include <KernelKit/ThreadLocalStorage.inl>
+
+// last rev 7/7/24
+
+#endif /* ifndef _KERNELKIT_TLS_HPP */