diff options
| author | Amlal EL Mahrouss <amlalelmahrouss@icloud.com> | 2024-07-28 08:37:45 +0200 |
|---|---|---|
| committer | Amlal EL Mahrouss <amlalelmahrouss@icloud.com> | 2024-07-28 10:07:41 +0200 |
| commit | d42e9fa42af70105346f14c8b48f60cd3f4ea845 (patch) | |
| tree | 34b58def6fb1129028276e90c2a1f594634b6c1e /Kernel/HALKit/AMD64 | |
| parent | 3feb5cb72e3e422e804098e2fdcb0bd3e7961627 (diff) | |
[IMP] New Storage.hpp inside StorageKit.
[REFACTOR] Process heap adjustements.
[WIP] SMP and Ring-3 switch for scheduler core.
Signed-off-by: Amlal EL Mahrouss <amlalelmahrouss@icloud.com>
Diffstat (limited to 'Kernel/HALKit/AMD64')
| -rw-r--r-- | Kernel/HALKit/AMD64/HalDebugOutput.cxx | 18 | ||||
| -rw-r--r-- | Kernel/HALKit/AMD64/HalDescriptorLoader.cxx | 9 | ||||
| -rw-r--r-- | Kernel/HALKit/AMD64/HalInstallTIB.asm | 19 | ||||
| -rw-r--r-- | Kernel/HALKit/AMD64/HalPageAlloc.hxx | 4 | ||||
| -rw-r--r-- | Kernel/HALKit/AMD64/Processor.hxx | 3 |
5 files changed, 36 insertions, 17 deletions
diff --git a/Kernel/HALKit/AMD64/HalDebugOutput.cxx b/Kernel/HALKit/AMD64/HalDebugOutput.cxx index 9e3dfcd8..36ae96b0 100644 --- a/Kernel/HALKit/AMD64/HalDebugOutput.cxx +++ b/Kernel/HALKit/AMD64/HalDebugOutput.cxx @@ -27,7 +27,7 @@ namespace Kernel /// @brief Init COM1. /// @return - bool serial_init() noexcept + bool hal_serial_init() noexcept { #ifdef __DEBUG__ if (kState == kStateReady || kState == kStateTransmit) @@ -64,7 +64,7 @@ namespace Kernel EXTERN_C void ke_io_write(const char* bytes) { #ifdef __DEBUG__ - Detail::serial_init(); + Detail::hal_serial_init(); if (!bytes || Detail::kState != kStateReady) return; @@ -74,18 +74,10 @@ namespace Kernel Detail::kState = kStateTransmit; SizeT index = 0; - SizeT len = rt_string_len(bytes, 0); - - const auto cColor = "\x1b[1;32m"; - SizeT lenClr = rt_string_len(cColor, 0); - - while (index < lenClr) - { - HAL::Out8(Detail::PORT, cColor[index]); - ++index; - } + SizeT len = 0; index = 0; + len = rt_string_len(bytes, 255); while (index < len) { @@ -103,7 +95,7 @@ namespace Kernel EXTERN_C void ke_io_read(const char* bytes) { #ifdef __DEBUG__ - Detail::serial_init(); + Detail::hal_serial_init(); if (!bytes || Detail::kState != kStateReady) return; diff --git a/Kernel/HALKit/AMD64/HalDescriptorLoader.cxx b/Kernel/HALKit/AMD64/HalDescriptorLoader.cxx index d0ac4e12..7ded9259 100644 --- a/Kernel/HALKit/AMD64/HalDescriptorLoader.cxx +++ b/Kernel/HALKit/AMD64/HalDescriptorLoader.cxx @@ -61,13 +61,14 @@ namespace Kernel::HAL { MUST_PASS(baseIdt[i]); - Detail::kInterruptVectorTable[i].Selector = kGdtCodeSelector; + Detail::kInterruptVectorTable[i].Selector = (i == kSyscallRoute) ? ((3 * 8) | 3) : kGdtCodeSelector; Detail::kInterruptVectorTable[i].Ist = 0x0; Detail::kInterruptVectorTable[i].TypeAttributes = kInterruptGate; - Detail::kInterruptVectorTable[i].OffsetLow = ((UIntPtr)baseIdt[i] & 0xFFFF); - Detail::kInterruptVectorTable[i].OffsetMid = (((UIntPtr)baseIdt[i] >> 16) & 0xFFFF); + Detail::kInterruptVectorTable[i].OffsetLow = ((UIntPtr)baseIdt[i] & __INT16_MAX__); + Detail::kInterruptVectorTable[i].OffsetMid = (((UIntPtr)baseIdt[i] >> 16) & __INT16_MAX__); Detail::kInterruptVectorTable[i].OffsetHigh = - (((UIntPtr)baseIdt[i] >> 32) & 0xFFFFFFFF); + (((UIntPtr)baseIdt[i] >> 32) & __INT32_MAX__); + Detail::kInterruptVectorTable[i].Zero = 0x0; } diff --git a/Kernel/HALKit/AMD64/HalInstallTIB.asm b/Kernel/HALKit/AMD64/HalInstallTIB.asm index 477018c0..00fe2ad8 100644 --- a/Kernel/HALKit/AMD64/HalInstallTIB.asm +++ b/Kernel/HALKit/AMD64/HalInstallTIB.asm @@ -22,3 +22,22 @@ rt_install_tib: ret ;; //////////////////////////////////////////////////// ;; + +[global rt_jump_user_mode] + +;; @used rcx, address to jump on. +;; @note adjusted for long mode. +rt_jump_user_mode: + mov ax, (6 * 8) | 3 ; user data segment with RPL 3 + mov ds, ax + mov es, ax + mov fs, ax + mov gs, ax ; SS is handled by iret + + mov rax, rsp + push (6 * 8) | 3 + push rax + pushf + push (5 * 8) | 3 + push rcx + iretq diff --git a/Kernel/HALKit/AMD64/HalPageAlloc.hxx b/Kernel/HALKit/AMD64/HalPageAlloc.hxx index 3166a46e..6e05e58e 100644 --- a/Kernel/HALKit/AMD64/HalPageAlloc.hxx +++ b/Kernel/HALKit/AMD64/HalPageAlloc.hxx @@ -26,6 +26,10 @@ #define kPTESize (0x1000) #endif // !kPTESize +#ifndef kAlign +#define kAlign __BIGGEST_ALIGNMENT__ +#endif // !kAlign + EXTERN_C void hal_flush_tlb(); EXTERN_C void hal_write_cr3(Kernel::UIntPtr pde); EXTERN_C void hal_write_cr0(Kernel::UIntPtr bit); diff --git a/Kernel/HALKit/AMD64/Processor.hxx b/Kernel/HALKit/AMD64/Processor.hxx index 9571cbfe..92b91c70 100644 --- a/Kernel/HALKit/AMD64/Processor.hxx +++ b/Kernel/HALKit/AMD64/Processor.hxx @@ -30,6 +30,8 @@ EXTERN_C #define kCPUBackendName "AMD64" +#define kSyscallRoute 0x32 + #define IsActiveLow(FLG) (FLG & 2) #define IsLevelTriggered(FLG) (FLG & 8) @@ -37,6 +39,7 @@ EXTERN_C #define kTrapGate (0xEF) #define kTaskGate (0b10001100) #define kGdtCodeSelector (0x08) +#define kGdtUserCodeSelector (0x10) #define cHeapStartOffset (0x10000000) namespace Kernel |
