diff options
Diffstat (limited to 'Kernel')
| -rw-r--r-- | Kernel/HALKit/64x0/ReadMe.md | 4 | ||||
| -rw-r--r-- | Kernel/HALKit/AMD64/HalACPIFactoryInterface.cxx | 11 | ||||
| -rw-r--r-- | Kernel/HALKit/AMD64/HalCoreMultiProcessingAMD64.cpp | 33 | ||||
| -rw-r--r-- | Kernel/HALKit/AMD64/HalHardwareMP.cpp | 4 | ||||
| -rw-r--r-- | Kernel/HALKit/AMD64/HalInterruptAPI.asm | 20 | ||||
| -rw-r--r-- | Kernel/HALKit/AMD64/ReadMe.md | 4 | ||||
| -rw-r--r-- | Kernel/HALKit/ARM64/ReadMe.md | 4 | ||||
| -rw-r--r-- | Kernel/HALKit/POWER/ReadMe.md | 4 | ||||
| -rw-r--r-- | Kernel/HALKit/RISCV/ReadMe.md | 4 | ||||
| -rw-r--r-- | Kernel/KernelKit/DebugOutput.hpp | 28 | ||||
| -rw-r--r-- | Kernel/Source/AppMain.cxx | 10 | ||||
| -rw-r--r-- | Kernel/Source/CodeManager.cxx | 37 |
12 files changed, 113 insertions, 50 deletions
diff --git a/Kernel/HALKit/64x0/ReadMe.md b/Kernel/HALKit/64x0/ReadMe.md new file mode 100644 index 00000000..6744f602 --- /dev/null +++ b/Kernel/HALKit/64x0/ReadMe.md @@ -0,0 +1,4 @@ +64x0 Hardware Abstraction Layer + +- Supported CPU: SoftwareLabs 64x0 +- Supported Firmware: CoreBoot
\ No newline at end of file diff --git a/Kernel/HALKit/AMD64/HalACPIFactoryInterface.cxx b/Kernel/HALKit/AMD64/HalACPIFactoryInterface.cxx index 3609165f..f4c9226e 100644 --- a/Kernel/HALKit/AMD64/HalACPIFactoryInterface.cxx +++ b/Kernel/HALKit/AMD64/HalACPIFactoryInterface.cxx @@ -75,7 +75,7 @@ namespace NewOS SDT* xsdt = (SDT*)(rsdPtr->XsdtAddress >> (rsdPtr->XsdtAddress & 0xFFF)); - SizeT num = xsdt->Length + sizeof(SDT) / 8; + SizeT num = (xsdt->Length + sizeof(SDT)) / 8; this->fEntries = num; @@ -83,10 +83,11 @@ namespace NewOS kcout << "ACPI: Address of XSDT: " << hex_number((UIntPtr)xsdt) << endl; constexpr short ACPI_SIGNATURE_LENGTH = 4; + SizeT offsetToAdd = 0UL; for (Size index = 0; index < num; ++index) { - SDT* sdt = (SDT*)*((UInt64*)(UInt64)xsdt + sizeof(SDT) + (index * 8)); + SDT* sdt = &(xsdt[index]) + offsetToAdd; for (int signature_index = 0; signature_index < 4; signature_index++) { @@ -94,11 +95,13 @@ namespace NewOS break; if (signature_index == 3) - return ErrorOr<voidPtr>(reinterpret_cast<voidPtr>((SDT*)sdt)); + return ErrorOr<voidPtr>(reinterpret_cast<voidPtr>(sdt)); } + + offsetToAdd = sdt->Length; } - return ErrorOr<voidPtr>{-1}; + return ErrorOr<voidPtr>{nullptr}; } /*** diff --git a/Kernel/HALKit/AMD64/HalCoreMultiProcessingAMD64.cpp b/Kernel/HALKit/AMD64/HalCoreMultiProcessingAMD64.cpp index 2129d790..ec6d47da 100644 --- a/Kernel/HALKit/AMD64/HalCoreMultiProcessingAMD64.cpp +++ b/Kernel/HALKit/AMD64/HalCoreMultiProcessingAMD64.cpp @@ -23,12 +23,12 @@ namespace NewOS::HAL constexpr Int32 kThreadBoot = 4; /* - * - * this is used to store info about the current running thread - * we use this struct to determine if we can use it, or mark it as used or on - * sleep. - * - */ + * + * this is used to store info about the current running thread + * we use this struct to determine if we can use it, or mark it as used or on + * sleep. + * + */ struct ProcessorInfoAMD64 final { @@ -51,12 +51,12 @@ namespace NewOS::HAL { struct MadtAddress final { + UInt32 fAddress; UInt32 fFlags; // 1 = Dual Legacy PICs installed - UInt32 fPhysicalAddress; Char fType; Char fRecLen; // record length - } Madt[]; + } fMadt[]; }; struct MadtProcessorLocalApic final @@ -104,20 +104,23 @@ namespace NewOS::HAL void hal_system_get_cores(voidPtr rsdPtr) { - kcout << "New OS: Constructing ACPIFactoryInterface...\r"; - auto acpi = ACPIFactoryInterface(rsdPtr); kApicMadt = acpi.Find(kApicSignature).Leak().Leak(); if (kApicMadt) { - kcout << "New OS: Successfuly fetched the MADT!\r"; + kcout << "New OS: Successfuly fetched the cores!\r"; kApicInfoBlock = (MadtType*)kApicMadt; + + kcout << "New OS: Revision: "; + kcout.HexNumber(kApicInfoBlock->Revision).EndLine(); + + ke_stop(RUNTIME_CHECK_BOOTSTRAP); } - else - { - MUST_PASS(false); - } + else + { + ke_stop(RUNTIME_CHECK_BOOTSTRAP); + } } } // namespace NewOS::HAL diff --git a/Kernel/HALKit/AMD64/HalHardwareMP.cpp b/Kernel/HALKit/AMD64/HalHardwareMP.cpp index 2ebf45fd..83e99ef8 100644 --- a/Kernel/HALKit/AMD64/HalHardwareMP.cpp +++ b/Kernel/HALKit/AMD64/HalHardwareMP.cpp @@ -16,7 +16,7 @@ namespace NewOS { HAL::rt_cli(); - stack->Rcx = 0; + HAL::rt_sti(); } @@ -27,7 +27,7 @@ namespace NewOS { HAL::rt_cli(); - stack->Rcx = 1; + HAL::rt_sti(); } diff --git a/Kernel/HALKit/AMD64/HalInterruptAPI.asm b/Kernel/HALKit/AMD64/HalInterruptAPI.asm index e4063388..875a1abc 100644 --- a/Kernel/HALKit/AMD64/HalInterruptAPI.asm +++ b/Kernel/HALKit/AMD64/HalInterruptAPI.asm @@ -14,16 +14,16 @@ %define kInterruptId 0x21 %macro IntExp 1 -global __HCR_INT_%1 -__HCR_INT_%1: +global __NEW_INT_%1 +__NEW_INT_%1: cld iretq %endmacro %macro IntNormal 1 -global __HCR_INT_%1 -__HCR_INT_%1: +global __NEW_INT_%1 +__NEW_INT_%1: cld iretq @@ -54,7 +54,7 @@ IntNormal 4 IntNormal 5 ;; Invalid opcode interrupt -__HCR_INT_6: +__NEW_INT_6: cli push rax @@ -75,7 +75,7 @@ IntExp 11 IntExp 12 -__HCR_INT_13: +__NEW_INT_13: cli push rax @@ -88,7 +88,7 @@ __HCR_INT_13: sti iretq -__HCR_INT_14: +__NEW_INT_14: cli push rax @@ -135,7 +135,7 @@ IntNormal 41 IntNormal 42 IntNormal 43 -__HCR_INT_44: +__NEW_INT_44: cli ;; TODO: CoreEvents dispatch routine. @@ -153,7 +153,7 @@ IntNormal 47 IntNormal 48 IntNormal 49 -__HCR_INT_50: +__NEW_INT_50: cli ;; todo handle system calls. @@ -217,6 +217,6 @@ section .data kInterruptVectorTable: %assign i 0 %rep 256 - dq __HCR_INT_%+i + dq __NEW_INT_%+i %assign i i+1 %endrep diff --git a/Kernel/HALKit/AMD64/ReadMe.md b/Kernel/HALKit/AMD64/ReadMe.md new file mode 100644 index 00000000..0be48c77 --- /dev/null +++ b/Kernel/HALKit/AMD64/ReadMe.md @@ -0,0 +1,4 @@ +AMD64 Hardware Abstraction Layer + +- Supported CPU: AMD64 CPU +- Supported Firmware: EDK 2
\ No newline at end of file diff --git a/Kernel/HALKit/ARM64/ReadMe.md b/Kernel/HALKit/ARM64/ReadMe.md new file mode 100644 index 00000000..89679e18 --- /dev/null +++ b/Kernel/HALKit/ARM64/ReadMe.md @@ -0,0 +1,4 @@ +ARM64 Hardware Abstraction Layer + +- Supported CPU: Qualcomm CPU +- Supported Firmware: EDK 2
\ No newline at end of file diff --git a/Kernel/HALKit/POWER/ReadMe.md b/Kernel/HALKit/POWER/ReadMe.md new file mode 100644 index 00000000..a9751581 --- /dev/null +++ b/Kernel/HALKit/POWER/ReadMe.md @@ -0,0 +1,4 @@ +POWER Hardware Abstraction Layer + +- Supported CPU: POWER +- Supported Firmware: CoreBoot
\ No newline at end of file diff --git a/Kernel/HALKit/RISCV/ReadMe.md b/Kernel/HALKit/RISCV/ReadMe.md new file mode 100644 index 00000000..b099aa31 --- /dev/null +++ b/Kernel/HALKit/RISCV/ReadMe.md @@ -0,0 +1,4 @@ +RISCV64 Hardware Abstraction Layer + +- Supported CPU: RISCV64 +- Supported Firmware: CoreBoot
\ No newline at end of file diff --git a/Kernel/KernelKit/DebugOutput.hpp b/Kernel/KernelKit/DebugOutput.hpp index 7fde69aa..656fe7a9 100644 --- a/Kernel/KernelKit/DebugOutput.hpp +++ b/Kernel/KernelKit/DebugOutput.hpp @@ -15,7 +15,7 @@ #define kDebugUnboundPort 0x0FEED -#define kDebugMag0 'H' +#define kDebugMag0 'N' #define kDebugMag1 'D' #define kDebugMag2 'B' #define kDebugMag3 'G' @@ -27,6 +27,12 @@ namespace NewOS { + class TerminalDevice; + + inline TerminalDevice& end_line(); + inline TerminalDevice& number(const Long& x); + inline TerminalDevice& hex_number(const Long& x); + // @brief Emulates a VT100 terminal. class TerminalDevice final : public DeviceInterface<const Char*> { @@ -34,10 +40,30 @@ namespace NewOS TerminalDevice(void (*print)(const Char*), void (*get)(const Char*)) : DeviceInterface<const Char*>(print, get) { + } virtual ~TerminalDevice() { + + } + + TerminalDevice& Number(const Long Data) noexcept + { + number(Data); + return *this; + } + + TerminalDevice& HexNumber(const Long Data) noexcept + { + number(Data); + return *this; + } + + TerminalDevice& EndLine() noexcept + { + end_line(); + return *this; } /// @brief returns device name (terminal name) diff --git a/Kernel/Source/AppMain.cxx b/Kernel/Source/AppMain.cxx index b91d6082..4f5de11f 100644 --- a/Kernel/Source/AppMain.cxx +++ b/Kernel/Source/AppMain.cxx @@ -22,6 +22,7 @@ #include <NewKit/KernelCheck.hpp> #include <NewKit/String.hpp> #include <NewKit/Utils.hpp> +#include <KernelKit/CodeManager.hpp> namespace Detail { @@ -177,6 +178,12 @@ namespace Detail return fNewFS; } }; + + STATIC NewOS::Void AppWatchdogThread(NewOS::Void) + { + NewOS::kcout << "SystemSanityThread: Exiting process..."; + NewOS::ProcessScheduler::Shared().Leak().GetCurrent().Leak().Exit(0); + } } // namespace Detail /// @file Main microkernel entrypoint. @@ -186,6 +193,9 @@ EXTERN_C NewOS::Void AppMain(NewOS::Void) /// Now run kernel loop, until no process are running. Detail::FilesystemWizard wizard; // automatic. + auto cWatchdogThreadName = "SystemSanityThread"; + NewOS::execute_from_image((NewOS::MainKind)Detail::AppWatchdogThread, cWatchdogThreadName); + while (NewOS::ProcessScheduler::Shared().Leak().Run() > 0) { ; diff --git a/Kernel/Source/CodeManager.cxx b/Kernel/Source/CodeManager.cxx index 39917163..001795ce 100644 --- a/Kernel/Source/CodeManager.cxx +++ b/Kernel/Source/CodeManager.cxx @@ -8,22 +8,23 @@ #include <KernelKit/CodeManager.hpp> #include <KernelKit/ProcessScheduler.hpp> -using namespace NewOS; - -/// @brief Executes a new process from a function. kernel code only. -/// @note This sets up a new stack, anything on the main function that calls the kernel will not be accessible. -/// @param main the start of the process. -/// @return if the process was started or not. -bool execute_from_image(MainKind main, const char* processName) noexcept +namespace NewOS { - if (!main) - return false; - - ProcessHeader proc((VoidPtr)main); - proc.Kind = ProcessHeader::kDriverKind; - rt_copy_memory((VoidPtr)processName, proc.Name, rt_string_len(proc.Name)); - - Ref<ProcessHeader> refProc = proc; - - return ProcessScheduler::Shared().Leak().Add(refProc); -}
\ No newline at end of file + /// @brief Executes a new process from a function. kernel code only. + /// @note This sets up a new stack, anything on the main function that calls the kernel will not be accessible. + /// @param main the start of the process. + /// @return if the process was started or not. + bool execute_from_image(MainKind main, const char* processName) noexcept + { + if (!main) + return false; + + ProcessHeader proc((VoidPtr)main); + proc.Kind = ProcessHeader::kDriverKind; + rt_copy_memory((VoidPtr)processName, proc.Name, rt_string_len(proc.Name)); + + Ref<ProcessHeader> refProc = proc; + + return ProcessScheduler::Shared().Leak().Add(refProc); + } +} // namespace NewOS
\ No newline at end of file |
