From f99e383775fa43c5c1354067962b1590ff2abdae Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Sat, 3 Feb 2024 20:39:06 +0100 Subject: NewBoot: Will work on AHCI instead, ATA is not getting any further in the future. Signed-off-by: Amlal El Mahrouss --- BUG_LIST.TXT | 3 - MailMap | 2 +- Private/HALKit/AMD64/ACPI/ACPI.hpp | 1 + Private/HALKit/AMD64/ACPIManagerAMD64.cpp | 69 -------- Private/HALKit/AMD64/ControlRegister.s | 35 ---- Private/HALKit/AMD64/CoreInterruptHandlerAMD64.cpp | 90 ---------- Private/HALKit/AMD64/CoreMultiProcessingAMD64.cpp | 127 -------------- Private/HALKit/AMD64/CoreSyscallHandlerAMD64.cpp | 23 --- Private/HALKit/AMD64/DebugOutput.cxx | 73 -------- Private/HALKit/AMD64/DebugPort.cxx | 59 ------- Private/HALKit/AMD64/HalACPIManager.cpp | 74 +++++++++ Private/HALKit/AMD64/HalControlRegister.s | 35 ++++ .../HALKit/AMD64/HalCoreInterruptHandlerAMD64.cpp | 90 ++++++++++ .../HALKit/AMD64/HalCoreMultiProcessingAMD64.cpp | 127 ++++++++++++++ .../HALKit/AMD64/HalCoreSyscallHandlerAMD64.cpp | 23 +++ Private/HALKit/AMD64/HalDebugOutput.cxx | 74 +++++++++ Private/HALKit/AMD64/HalDebugPort.cxx | 59 +++++++ Private/HALKit/AMD64/HalInstallTIB.asm | 18 ++ Private/HALKit/AMD64/HalSMPCoreManager.asm | 35 ++++ Private/HALKit/AMD64/HalStartSequence.asm | 40 +++++ Private/HALKit/AMD64/InstallTIB.asm | 18 -- Private/HALKit/AMD64/SMPCoreManager.asm | 35 ---- Private/HALKit/AMD64/StartSequence.asm | 40 ----- Private/HALKit/PowerPC/HalHardware.cpp | 48 ------ Private/HALKit/PowerPC/HalHardware.cxx | 49 ++++++ Private/NewBoot/BootKit/Arch/AHCI.hxx | 12 ++ Private/NewBoot/BootKit/Arch/ATA.hxx | 11 +- Private/NewBoot/BootKit/BootKit.hxx | 22 +-- Private/NewBoot/Source/Entrypoint.cxx | 5 +- Private/NewBoot/Source/FileReader.cxx | 54 ++++++ Private/NewBoot/Source/HEL/AMD64/AMD64-AHCI.cxx | 19 +++ Private/NewBoot/Source/HEL/AMD64/AMD64-ATA.cxx | 183 +++++++++++++-------- .../Source/HEL/AMD64/AMD64-CoreSync-ATA.asm | 24 --- Private/NewBoot/Source/ImageReader.cxx | 72 -------- Private/NewBoot/Source/String.cxx | 25 --- Private/NewBoot/Source/TextWriter.cxx | 48 ++++++ Private/NewBoot/Source/makefile | 8 +- Private/NewKit/Macros.hpp | 4 +- Private/NewKit/compile_flags.txt | 1 + Private/Source/CxxKitRT.cxx | 20 --- Private/makefile | 7 +- Public/BUG_LIST.TXT | 3 + Public/SPECIFICATION.TXT | 32 ++++ Public/TODO_LIST.TXT | 20 +++ SPECIFICATION.TXT | 32 ---- TODO_LIST.TXT | 20 --- 46 files changed, 955 insertions(+), 914 deletions(-) delete mode 100644 BUG_LIST.TXT delete mode 100644 Private/HALKit/AMD64/ACPIManagerAMD64.cpp delete mode 100644 Private/HALKit/AMD64/ControlRegister.s delete mode 100644 Private/HALKit/AMD64/CoreInterruptHandlerAMD64.cpp delete mode 100644 Private/HALKit/AMD64/CoreMultiProcessingAMD64.cpp delete mode 100644 Private/HALKit/AMD64/CoreSyscallHandlerAMD64.cpp delete mode 100644 Private/HALKit/AMD64/DebugOutput.cxx delete mode 100644 Private/HALKit/AMD64/DebugPort.cxx create mode 100644 Private/HALKit/AMD64/HalACPIManager.cpp create mode 100644 Private/HALKit/AMD64/HalControlRegister.s create mode 100644 Private/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cpp create mode 100644 Private/HALKit/AMD64/HalCoreMultiProcessingAMD64.cpp create mode 100644 Private/HALKit/AMD64/HalCoreSyscallHandlerAMD64.cpp create mode 100644 Private/HALKit/AMD64/HalDebugOutput.cxx create mode 100644 Private/HALKit/AMD64/HalDebugPort.cxx create mode 100644 Private/HALKit/AMD64/HalInstallTIB.asm create mode 100644 Private/HALKit/AMD64/HalSMPCoreManager.asm create mode 100644 Private/HALKit/AMD64/HalStartSequence.asm delete mode 100644 Private/HALKit/AMD64/InstallTIB.asm delete mode 100644 Private/HALKit/AMD64/SMPCoreManager.asm delete mode 100644 Private/HALKit/AMD64/StartSequence.asm delete mode 100644 Private/HALKit/PowerPC/HalHardware.cpp create mode 100644 Private/HALKit/PowerPC/HalHardware.cxx create mode 100644 Private/NewBoot/BootKit/Arch/AHCI.hxx create mode 100644 Private/NewBoot/Source/FileReader.cxx create mode 100644 Private/NewBoot/Source/HEL/AMD64/AMD64-AHCI.cxx delete mode 100644 Private/NewBoot/Source/HEL/AMD64/AMD64-CoreSync-ATA.asm delete mode 100644 Private/NewBoot/Source/ImageReader.cxx create mode 100644 Private/NewBoot/Source/TextWriter.cxx delete mode 100644 Private/Source/CxxKitRT.cxx create mode 100644 Public/BUG_LIST.TXT create mode 100644 Public/SPECIFICATION.TXT create mode 100644 Public/TODO_LIST.TXT delete mode 100644 SPECIFICATION.TXT delete mode 100644 TODO_LIST.TXT diff --git a/BUG_LIST.TXT b/BUG_LIST.TXT deleted file mode 100644 index 1fa4e00a..00000000 --- a/BUG_LIST.TXT +++ /dev/null @@ -1,3 +0,0 @@ -ADD THE BUGS HERE: - -None diff --git a/MailMap b/MailMap index 126cdd13..ec0da09f 100644 --- a/MailMap +++ b/MailMap @@ -1 +1 @@ -amlel - Microkernel,Bootloader - amlalelmahrouss@icloud.com, +33 6 58 57 30 14 +amlel - Microkernel and Bootloader - amlalelmahrouss@icloud.com, +33 6 58 57 30 14 diff --git a/Private/HALKit/AMD64/ACPI/ACPI.hpp b/Private/HALKit/AMD64/ACPI/ACPI.hpp index d97c4fdd..f1a7c27c 100644 --- a/Private/HALKit/AMD64/ACPI/ACPI.hpp +++ b/Private/HALKit/AMD64/ACPI/ACPI.hpp @@ -13,6 +13,7 @@ /** https://uefi.org/specs/ACPI/6.5/05_ACPI_Software_Programming_Model.html + https://wiki.osdev.org/RSDT */ #include diff --git a/Private/HALKit/AMD64/ACPIManagerAMD64.cpp b/Private/HALKit/AMD64/ACPIManagerAMD64.cpp deleted file mode 100644 index 9bdd368b..00000000 --- a/Private/HALKit/AMD64/ACPIManagerAMD64.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/* - * ======================================================== - * - * HCore - * Copyright Mahrouss Logic, all rights reserved. - * - * ======================================================== - */ - -#include -#include -#include - -namespace HCore { -ACPIManager::ACPIManager(voidPtr rsdPtr) : m_Rsdp(rsdPtr), m_Entries(0) { - RSDP *_rsdPtr = reinterpret_cast(this->m_Rsdp); - - MUST_PASS(_rsdPtr); - MUST_PASS(_rsdPtr->Revision >= 2); -} - -void ACPIManager::Shutdown() {} -void ACPIManager::Reset() {} - -ErrorOr ACPIManager::Find(const char *signature) { - MUST_PASS(m_Rsdp); - - if (!signature) return ErrorOr{-2}; - - if (*signature == 0) return ErrorOr{-3}; - - RSDP *rsdPtr = reinterpret_cast(this->m_Rsdp); - - auto xsdt = rsdPtr->XsdtAddress; - SizeT num = (rsdPtr->Length + sizeof(SDT)) / 8; - - for (Size index = 0; index < num; ++index) { - SDT *sdt = reinterpret_cast(xsdt + sizeof(SDT) + index * 8); - - if (!Checksum(sdt->Signature, 4)) ke_stop(RUNTIME_CHECK_ACPI); - - if (StringBuilder::Equals(const_cast(sdt->Signature), - signature)) - return ErrorOr(reinterpret_cast(sdt)); - } - - return ErrorOr{-1}; -} - -bool ACPIManager::Checksum(const char *checksum, SSizeT len) { - if (len == 0) return -1; - - char chr = 0; - - for (int index = 0; index < len; ++index) { - chr += checksum[index]; - } - - return chr == 0; -} - -void rt_shutdown_acpi_qemu_20(void) { HAL::Out16(0xb004, 0x2000); } - -void rt_shutdown_acpi_qemu_30_plus(void) { HAL::Out16(0x604, 0x2000); } - -void rt_shutdown_acpi_virtualbox(void) { HAL::Out16(0x4004, 0x3400); } - -/// you'll have to parse the MADT otherwise! -} // namespace HCore diff --git a/Private/HALKit/AMD64/ControlRegister.s b/Private/HALKit/AMD64/ControlRegister.s deleted file mode 100644 index d7e0c019..00000000 --- a/Private/HALKit/AMD64/ControlRegister.s +++ /dev/null @@ -1,35 +0,0 @@ -.globl write_cr3 -.globl write_cr0 -.globl read_cr2 -.globl read_cr3 -.globl read_cr0 -.globl flush_tlb - -.section .text - flush_tlb: - mov %rsi, %cr3 - mov %cr3, %rsi - xor %rax, %rax - ret - - read_cr3: - movq %rax, %cr3 - ret - - read_cr0: - movq %rax, %cr0 - ret - - read_cr2: - movq %rax, %cr2 - ret - - write_cr3: - movq %cr3, %rdi - ret - - write_cr0: - movq %cr0, %rdi - ret - - diff --git a/Private/HALKit/AMD64/CoreInterruptHandlerAMD64.cpp b/Private/HALKit/AMD64/CoreInterruptHandlerAMD64.cpp deleted file mode 100644 index caf891d1..00000000 --- a/Private/HALKit/AMD64/CoreInterruptHandlerAMD64.cpp +++ /dev/null @@ -1,90 +0,0 @@ -/* - * ======================================================== - * - * HCore - * Copyright Mahrouss Logic, all rights reserved. - * - * ======================================================== - */ - -#include -#include -#include - -extern "C" void idt_handle_system_call(HCore::UIntPtr rsp) { - HCore::HAL::StackFrame *sf = reinterpret_cast(rsp); - rt_syscall_handle(sf); - - HCore::kcout << "System Call with ID: " - << HCore::StringBuilder::FromInt("syscall{%}", sf->R15); -} - -extern "C" void idt_handle_gpf(HCore::UIntPtr rsp) { - MUST_PASS(HCore::ProcessManager::Shared().Leak().GetCurrent()); - - HCore::kcout << HCore::StringBuilder::FromInt("rsp{%}", rsp); - - HCore::kcout - << "General Protection Fault, Caused by " - << HCore::ProcessManager::Shared().Leak().GetCurrent().Leak().GetName(); - - HCore::ProcessManager::Shared().Leak().GetCurrent().Leak().Crash(); -} - -extern "C" void idt_handle_scheduler(HCore::UIntPtr rsp) { - HCore::kcout << HCore::StringBuilder::FromInt("rsp{%}", rsp); - - HCore::kcout - << "Will be scheduled back later " - << HCore::ProcessManager::Shared().Leak().GetCurrent().Leak().GetName(); - - /// schedule another process. - if (!HCore::ProcessHelper::StartScheduling()) { - HCore::kcout << "Let's continue schedule this process...\r\n"; - } -} - -extern "C" void idt_handle_pf(HCore::UIntPtr rsp) { - HCore::kcout << HCore::StringBuilder::FromInt("rsp{%}", rsp); - - MUST_PASS(HCore::ProcessManager::Shared().Leak().GetCurrent()); - - HCore::kcout - << "Segmentation Fault, Caused by " - << HCore::ProcessManager::Shared().Leak().GetCurrent().Leak().GetName(); - - HCore::ProcessManager::Shared().Leak().GetCurrent().Leak().Crash(); -} - -extern "C" void idt_handle_math(HCore::UIntPtr rsp) { - HCore::kcout << HCore::StringBuilder::FromInt("rsp{%}", rsp); - - MUST_PASS(HCore::ProcessManager::Shared().Leak().GetCurrent()); - - HCore::kcout - << "Math error, Caused by " - << HCore::ProcessManager::Shared().Leak().GetCurrent().Leak().GetName(); - - HCore::ProcessManager::Shared().Leak().GetCurrent().Leak().Crash(); -} - -extern "C" void idt_handle_generic(HCore::UIntPtr rsp) { - HCore::kcout << HCore::StringBuilder::FromInt("sp{%}", rsp); - - MUST_PASS(HCore::ProcessManager::Shared().Leak().GetCurrent()); - - HCore::kcout - << "Processor error, Caused by " - << HCore::ProcessManager::Shared().Leak().GetCurrent().Leak().GetName(); - - HCore::ProcessManager::Shared().Leak().GetCurrent().Leak().Crash(); -} - -extern "C" HCore::UIntPtr rt_handle_interrupts(HCore::UIntPtr &rsp) { - HCore::HAL::rt_cli(); - - HCore::HAL::StackFramePtr sf = (HCore::HAL::StackFramePtr)rsp; - - HCore::HAL::rt_sti(); - return rsp; -} diff --git a/Private/HALKit/AMD64/CoreMultiProcessingAMD64.cpp b/Private/HALKit/AMD64/CoreMultiProcessingAMD64.cpp deleted file mode 100644 index 1e53140f..00000000 --- a/Private/HALKit/AMD64/CoreMultiProcessingAMD64.cpp +++ /dev/null @@ -1,127 +0,0 @@ -/* - * ======================================================== - * - * HCore - * Copyright Mahrouss Logic, all rights reserved. - * - * ======================================================== - */ - -#include -#include - -/////////////////////////////////////////////////////////////////////////////////////// - -//! NOTE: fGSI stands 'Field Global System Interrupt' - -namespace HCore::HAL { -constexpr Int32 kThreadAPIC = 0; -constexpr Int32 kThreadLAPIC = 1; -constexpr Int32 kThreadIOAPIC = 2; -constexpr Int32 kThreadAPIC64 = 3; -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. - * - */ - -struct ProcessorInfoAMD64 final { - Int32 ThreadType; - UIntPtr JumpAddress; - - struct { - UInt32 Code; - UInt32 Data; - UInt32 BSS; - } Selector; -}; - -static voidPtr kApicMadt = nullptr; -static const char* kApicSignature = "APIC"; - -struct Madt final { - char fMag[4]; - Int32 fLength; - char fRev; - - struct MadtAddress final { - UInt32 fPhysicalAddress; - UInt32 fFlags; // 1 = Dual Legacy PICs installed - - Char fType; - Char fRecLen; // record length - }; -}; - -struct MadtProcessorLocalApic final { - Char fProcessorId; - Char fApicId; - UInt32 fFlags; -}; - -struct MadtIOApic final { - Char fApicId; - Char fReserved; - UInt32 fAddress; - UInt32 fSystemInterruptBase; -}; - -struct MadtInterruptSource final { - Char fBusSource; - Char fIrqSource; - UInt32 fGSI; - UInt16 fFlags; -}; - -struct MadtInterruptNmi final { - Char fNmiSource; - Char fReserved; - UInt16 fFlags; - UInt32 fGSI; -}; - -struct MadtLocalApicAddressOverride final { - UInt16 fResvered; - UIntPtr fAddress; -}; - -/////////////////////////////////////////////////////////////////////////////////////// - -static Madt kApicMadtList[256]; - -Madt* system_find_core(Madt* madt) { - madt = madt + sizeof(Madt); - - if (string_compare(madt->fMag, kApicSignature, - string_length(kApicSignature)) == 0) - return madt; - - return nullptr; -} - -/////////////////////////////////////////////////////////////////////////////////////// - -void system_get_cores(voidPtr rsdPtr) { - auto acpi = ACPIManager(rsdPtr); - kApicMadt = acpi.Find(kApicSignature).Leak().Leak(); - - MUST_PASS(kApicMadt); // MADT must exist. - - SizeT counter = 0UL; - Madt* offset = system_find_core((Madt*)kApicMadt); - //! now find core addresses. - while (offset != nullptr) { - // calls rt_copy_memory in NewC++ - kApicMadtList[counter] = *offset; - offset = system_find_core(offset); - - ++counter; - } -} -} // namespace HCore::HAL - -/////////////////////////////////////////////////////////////////////////////////////// diff --git a/Private/HALKit/AMD64/CoreSyscallHandlerAMD64.cpp b/Private/HALKit/AMD64/CoreSyscallHandlerAMD64.cpp deleted file mode 100644 index 4f1ed4da..00000000 --- a/Private/HALKit/AMD64/CoreSyscallHandlerAMD64.cpp +++ /dev/null @@ -1,23 +0,0 @@ -/* - * ======================================================== - * - * HCore - * Copyright Mahrouss Logic, all rights reserved. - * - * ======================================================== - */ - -#include -#include -#include - -HCore::Array - kSyscalls; - -// IDT System Call Handler. -// NOTE: don't trust the user. -extern "C" void rt_syscall_handle(HCore::HAL::StackFrame *stack) { - for (HCore::SizeT index = 0UL; index < kMaxSyscalls; ++index) { - (kSyscalls[index].Leak().Leak())(stack->R15, stack); - } -} diff --git a/Private/HALKit/AMD64/DebugOutput.cxx b/Private/HALKit/AMD64/DebugOutput.cxx deleted file mode 100644 index c4e9cc48..00000000 --- a/Private/HALKit/AMD64/DebugOutput.cxx +++ /dev/null @@ -1,73 +0,0 @@ -/* - * ======================================================== - * - * HCore - * Copyright Mahrouss Logic, all rights reserved. - * - * ======================================================== - */ - -#include -#include -#include - -namespace HCore { -enum CommStatus { - kStateReady = 0xCF, - kStateTransmit = 0xFC, - kStateLimbo, - kStateCnt = 3 -}; - -namespace Detail { -constexpr short PORT = 0x3F8; - -static int kState = kStateLimbo; - -bool serial_init() { -#ifdef __DEBUG__ - HAL::Out8(PORT + 1, 0x00); // Disable all interrupts - HAL::Out8(PORT + 3, 0x80); // Enable DLAB (set baud rate divisor) - HAL::Out8(PORT + 0, 0x03); // Set divisor to 3 (lo byte) 38400 baud - HAL::Out8(PORT + 1, 0x00); // (hi byte) - HAL::Out8(PORT + 3, 0x03); // 8 bits, no parity, one stop bit - HAL::Out8(PORT + 2, 0xC7); // Enable FIFO, clear them, with 14-byte threshold - HAL::Out8(PORT + 4, 0x0B); // IRQs enabled, RTS/DSR set - HAL::Out8(PORT + 4, 0x1E); // Set in loopback mode, test the serial chip - HAL::Out8(PORT + 0, 0xAE); // Test serial chip (send byte 0xAE and check if - // serial returns same byte) - - // Check if serial is faulty (i.e: not same byte as sent) - if (HAL::In8(PORT) != 0xAE) { - ke_stop(RUNTIME_CHECK_HANDSHAKE); - } - - kReady = kStateReady; - - // If serial is not faulty set it in normal operation mode - // (not-loopback with IRQs enabled and OUT#1 and OUT#2 bits enabled) - HAL::Out8(Detail::PORT + 4, 0x0F); -#endif - - return true; -} -} // namespace Detail - -void system_io_print(const char *bytes) { - if (!bytes || Detail::kState != kStateReady) return; - - Detail::kState = kStateTransmit; - - SizeT index = 0; - SizeT len = string_length(bytes, 256); - - while (index < len) { - HAL::Out8(Detail::PORT, bytes[index]); - ++index; - } - - Detail::kState = kStateReady; -} - -TerminalDevice kcout(HCore::system_io_print, nullptr); -} // namespace HCore diff --git a/Private/HALKit/AMD64/DebugPort.cxx b/Private/HALKit/AMD64/DebugPort.cxx deleted file mode 100644 index d292f95d..00000000 --- a/Private/HALKit/AMD64/DebugPort.cxx +++ /dev/null @@ -1,59 +0,0 @@ -/* - * ======================================================== - * - * HCore - * Copyright Mahrouss Logic, all rights reserved. - * - * ======================================================== - */ - -//! @file DebuggerPort.cxx -//! @brief UART debug via packets. - -#include - -#define kDebugMaxPorts 16 - -#define kDebugUnboundPort 0xFFFF - -#define kDebugMag0 'X' -#define kDebugMag1 'D' -#define kDebugMag2 'B' -#define kDebugMag3 'G' - -#define kDebugSourceFile 0 -#define kDebugLine 33 -#define kDebugTeam 43 -#define kDebugEOP 49 - -// after that we have start of additional data. - -namespace HCore { -typedef Char rt_debug_type[255]; - -class DebuggerPorts final { - public: - Int16 fPort[kDebugMaxPorts]; - Int16 fBoundCnt; -}; - -void rt_debug_listen(DebuggerPorts* theHook) noexcept { - if (theHook == nullptr) return; - - for (UInt32 i = 0U; i < kDebugMaxPorts; ++i) { - HAL::Out16(theHook->fPort[i], kDebugMag0); - HAL::rt_wait_for_io(); - - HAL::Out16(theHook->fPort[i], kDebugMag1); - HAL::rt_wait_for_io(); - - HAL::Out16(theHook->fPort[i], kDebugMag2); - HAL::rt_wait_for_io(); - - HAL::Out16(theHook->fPort[i], kDebugMag3); - HAL::rt_wait_for_io(); - - if (HAL::In16(theHook->fPort[i] != kDebugUnboundPort)) theHook->fBoundCnt++; - } -} -} // namespace HCore diff --git a/Private/HALKit/AMD64/HalACPIManager.cpp b/Private/HALKit/AMD64/HalACPIManager.cpp new file mode 100644 index 00000000..6cac4eca --- /dev/null +++ b/Private/HALKit/AMD64/HalACPIManager.cpp @@ -0,0 +1,74 @@ +/* + * ======================================================== + * + * HCore + * Copyright Mahrouss Logic, all rights reserved. + * + * ======================================================== + */ + +#include +#include +#include + +namespace HCore { +ACPIManager::ACPIManager(voidPtr rsdPtr) : m_Rsdp(rsdPtr), m_Entries(0) { + RSDP *_rsdPtr = reinterpret_cast(this->m_Rsdp); + + MUST_PASS(_rsdPtr); + MUST_PASS(_rsdPtr->Revision >= 2); +} + +void ACPIManager::Shutdown() {} +void ACPIManager::Reset() {} + +ErrorOr ACPIManager::Find(const char *signature) { + MUST_PASS(m_Rsdp); + + if (!signature) return ErrorOr{-2}; + + if (*signature == 0) return ErrorOr{-3}; + + RSDP *rsdPtr = reinterpret_cast(this->m_Rsdp); + + auto xsdt = rsdPtr->XsdtAddress; + SizeT num = (rsdPtr->Length + sizeof(SDT)) / 8; + + for (Size index = 0; index < num; ++index) { + SDT *sdt = reinterpret_cast(xsdt + sizeof(SDT) + index * 8); + + if (!Checksum(sdt->Signature, 4)) ke_stop(RUNTIME_CHECK_ACPI); + + if (StringBuilder::Equals(const_cast(sdt->Signature), + signature)) + return ErrorOr(reinterpret_cast(sdt)); + } + + return ErrorOr{-1}; +} + +/*** + @brief check SDT header + @param checksum the header to checksum + @param len the length of it. +*/ +bool ACPIManager::Checksum(const char *checksum, SSizeT len) { + if (len == 0) return -1; + + char chr = 0; + + for (int index = 0; index < len; ++index) { + chr += checksum[index]; + } + + return chr == 0; +} + +void rt_shutdown_acpi_qemu_20(void) { HAL::Out16(0xb004, 0x2000); } + +void rt_shutdown_acpi_qemu_30_plus(void) { HAL::Out16(0x604, 0x2000); } + +void rt_shutdown_acpi_virtualbox(void) { HAL::Out16(0x4004, 0x3400); } + +/// You have to parse the MADT! +} // namespace HCore diff --git a/Private/HALKit/AMD64/HalControlRegister.s b/Private/HALKit/AMD64/HalControlRegister.s new file mode 100644 index 00000000..d7e0c019 --- /dev/null +++ b/Private/HALKit/AMD64/HalControlRegister.s @@ -0,0 +1,35 @@ +.globl write_cr3 +.globl write_cr0 +.globl read_cr2 +.globl read_cr3 +.globl read_cr0 +.globl flush_tlb + +.section .text + flush_tlb: + mov %rsi, %cr3 + mov %cr3, %rsi + xor %rax, %rax + ret + + read_cr3: + movq %rax, %cr3 + ret + + read_cr0: + movq %rax, %cr0 + ret + + read_cr2: + movq %rax, %cr2 + ret + + write_cr3: + movq %cr3, %rdi + ret + + write_cr0: + movq %cr0, %rdi + ret + + diff --git a/Private/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cpp b/Private/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cpp new file mode 100644 index 00000000..caf891d1 --- /dev/null +++ b/Private/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cpp @@ -0,0 +1,90 @@ +/* + * ======================================================== + * + * HCore + * Copyright Mahrouss Logic, all rights reserved. + * + * ======================================================== + */ + +#include +#include +#include + +extern "C" void idt_handle_system_call(HCore::UIntPtr rsp) { + HCore::HAL::StackFrame *sf = reinterpret_cast(rsp); + rt_syscall_handle(sf); + + HCore::kcout << "System Call with ID: " + << HCore::StringBuilder::FromInt("syscall{%}", sf->R15); +} + +extern "C" void idt_handle_gpf(HCore::UIntPtr rsp) { + MUST_PASS(HCore::ProcessManager::Shared().Leak().GetCurrent()); + + HCore::kcout << HCore::StringBuilder::FromInt("rsp{%}", rsp); + + HCore::kcout + << "General Protection Fault, Caused by " + << HCore::ProcessManager::Shared().Leak().GetCurrent().Leak().GetName(); + + HCore::ProcessManager::Shared().Leak().GetCurrent().Leak().Crash(); +} + +extern "C" void idt_handle_scheduler(HCore::UIntPtr rsp) { + HCore::kcout << HCore::StringBuilder::FromInt("rsp{%}", rsp); + + HCore::kcout + << "Will be scheduled back later " + << HCore::ProcessManager::Shared().Leak().GetCurrent().Leak().GetName(); + + /// schedule another process. + if (!HCore::ProcessHelper::StartScheduling()) { + HCore::kcout << "Let's continue schedule this process...\r\n"; + } +} + +extern "C" void idt_handle_pf(HCore::UIntPtr rsp) { + HCore::kcout << HCore::StringBuilder::FromInt("rsp{%}", rsp); + + MUST_PASS(HCore::ProcessManager::Shared().Leak().GetCurrent()); + + HCore::kcout + << "Segmentation Fault, Caused by " + << HCore::ProcessManager::Shared().Leak().GetCurrent().Leak().GetName(); + + HCore::ProcessManager::Shared().Leak().GetCurrent().Leak().Crash(); +} + +extern "C" void idt_handle_math(HCore::UIntPtr rsp) { + HCore::kcout << HCore::StringBuilder::FromInt("rsp{%}", rsp); + + MUST_PASS(HCore::ProcessManager::Shared().Leak().GetCurrent()); + + HCore::kcout + << "Math error, Caused by " + << HCore::ProcessManager::Shared().Leak().GetCurrent().Leak().GetName(); + + HCore::ProcessManager::Shared().Leak().GetCurrent().Leak().Crash(); +} + +extern "C" void idt_handle_generic(HCore::UIntPtr rsp) { + HCore::kcout << HCore::StringBuilder::FromInt("sp{%}", rsp); + + MUST_PASS(HCore::ProcessManager::Shared().Leak().GetCurrent()); + + HCore::kcout + << "Processor error, Caused by " + << HCore::ProcessManager::Shared().Leak().GetCurrent().Leak().GetName(); + + HCore::ProcessManager::Shared().Leak().GetCurrent().Leak().Crash(); +} + +extern "C" HCore::UIntPtr rt_handle_interrupts(HCore::UIntPtr &rsp) { + HCore::HAL::rt_cli(); + + HCore::HAL::StackFramePtr sf = (HCore::HAL::StackFramePtr)rsp; + + HCore::HAL::rt_sti(); + return rsp; +} diff --git a/Private/HALKit/AMD64/HalCoreMultiProcessingAMD64.cpp b/Private/HALKit/AMD64/HalCoreMultiProcessingAMD64.cpp new file mode 100644 index 00000000..1e53140f --- /dev/null +++ b/Private/HALKit/AMD64/HalCoreMultiProcessingAMD64.cpp @@ -0,0 +1,127 @@ +/* + * ======================================================== + * + * HCore + * Copyright Mahrouss Logic, all rights reserved. + * + * ======================================================== + */ + +#include +#include + +/////////////////////////////////////////////////////////////////////////////////////// + +//! NOTE: fGSI stands 'Field Global System Interrupt' + +namespace HCore::HAL { +constexpr Int32 kThreadAPIC = 0; +constexpr Int32 kThreadLAPIC = 1; +constexpr Int32 kThreadIOAPIC = 2; +constexpr Int32 kThreadAPIC64 = 3; +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. + * + */ + +struct ProcessorInfoAMD64 final { + Int32 ThreadType; + UIntPtr JumpAddress; + + struct { + UInt32 Code; + UInt32 Data; + UInt32 BSS; + } Selector; +}; + +static voidPtr kApicMadt = nullptr; +static const char* kApicSignature = "APIC"; + +struct Madt final { + char fMag[4]; + Int32 fLength; + char fRev; + + struct MadtAddress final { + UInt32 fPhysicalAddress; + UInt32 fFlags; // 1 = Dual Legacy PICs installed + + Char fType; + Char fRecLen; // record length + }; +}; + +struct MadtProcessorLocalApic final { + Char fProcessorId; + Char fApicId; + UInt32 fFlags; +}; + +struct MadtIOApic final { + Char fApicId; + Char fReserved; + UInt32 fAddress; + UInt32 fSystemInterruptBase; +}; + +struct MadtInterruptSource final { + Char fBusSource; + Char fIrqSource; + UInt32 fGSI; + UInt16 fFlags; +}; + +struct MadtInterruptNmi final { + Char fNmiSource; + Char fReserved; + UInt16 fFlags; + UInt32 fGSI; +}; + +struct MadtLocalApicAddressOverride final { + UInt16 fResvered; + UIntPtr fAddress; +}; + +/////////////////////////////////////////////////////////////////////////////////////// + +static Madt kApicMadtList[256]; + +Madt* system_find_core(Madt* madt) { + madt = madt + sizeof(Madt); + + if (string_compare(madt->fMag, kApicSignature, + string_length(kApicSignature)) == 0) + return madt; + + return nullptr; +} + +/////////////////////////////////////////////////////////////////////////////////////// + +void system_get_cores(voidPtr rsdPtr) { + auto acpi = ACPIManager(rsdPtr); + kApicMadt = acpi.Find(kApicSignature).Leak().Leak(); + + MUST_PASS(kApicMadt); // MADT must exist. + + SizeT counter = 0UL; + Madt* offset = system_find_core((Madt*)kApicMadt); + //! now find core addresses. + while (offset != nullptr) { + // calls rt_copy_memory in NewC++ + kApicMadtList[counter] = *offset; + offset = system_find_core(offset); + + ++counter; + } +} +} // namespace HCore::HAL + +/////////////////////////////////////////////////////////////////////////////////////// diff --git a/Private/HALKit/AMD64/HalCoreSyscallHandlerAMD64.cpp b/Private/HALKit/AMD64/HalCoreSyscallHandlerAMD64.cpp new file mode 100644 index 00000000..4f1ed4da --- /dev/null +++ b/Private/HALKit/AMD64/HalCoreSyscallHandlerAMD64.cpp @@ -0,0 +1,23 @@ +/* + * ======================================================== + * + * HCore + * Copyright Mahrouss Logic, all rights reserved. + * + * ======================================================== + */ + +#include +#include +#include + +HCore::Array + kSyscalls; + +// IDT System Call Handler. +// NOTE: don't trust the user. +extern "C" void rt_syscall_handle(HCore::HAL::StackFrame *stack) { + for (HCore::SizeT index = 0UL; index < kMaxSyscalls; ++index) { + (kSyscalls[index].Leak().Leak())(stack->R15, stack); + } +} diff --git a/Private/HALKit/AMD64/HalDebugOutput.cxx b/Private/HALKit/AMD64/HalDebugOutput.cxx new file mode 100644 index 00000000..ac16cf70 --- /dev/null +++ b/Private/HALKit/AMD64/HalDebugOutput.cxx @@ -0,0 +1,74 @@ +/* + * ======================================================== + * + * HCore + * Copyright Mahrouss Logic, all rights reserved. + * + * ======================================================== + */ + +#include +#include +#include + +namespace HCore { +enum CommStatus { + kStateReady = 0xCF, + kStateTransmit = 0xFC, + kStateLimbo, + kStateCnt = 3 +}; + +namespace Detail { +constexpr short PORT = 0x3F8; + +static int kState = kStateLimbo; + +bool serial_init() { +#ifdef __DEBUG__ + HAL::Out8(PORT + 1, 0x00); // Disable all interrupts + HAL::Out8(PORT + 3, 0x80); // Enable DLAB (set baud rate divisor) + HAL::Out8(PORT + 0, 0x03); // Set divisor to 3 (lo byte) 38400 baud + HAL::Out8(PORT + 1, 0x00); // (hi byte) + HAL::Out8(PORT + 3, 0x03); // 8 bits, no parity, one stop bit + HAL::Out8(PORT + 2, 0xC7); // Enable FIFO, clear them, with 14-byte threshold + HAL::Out8(PORT + 4, 0x0B); // IRQs enabled, RTS/DSR set + HAL::Out8(PORT + 4, 0x1E); // Set in loopback mode, test the serial chip + HAL::Out8(PORT + 0, 0xAE); // Test serial chip (send byte 0xAE and check if + // serial returns same byte) + + // Check if serial is faulty (i.e: not same byte as sent) + if (HAL::In8(PORT) != 0xAE) { + ke_stop(RUNTIME_CHECK_HANDSHAKE); + } + + kReady = kStateReady; + + // If serial is not faulty set it in normal operation mode + // (not-loopback with IRQs enabled and OUT#1 and OUT#2 bits enabled) + HAL::Out8(Detail::PORT + 4, 0x0F); +#endif + + return true; +} +} // namespace Detail + +void ke_io_print(const char *bytes) { + if (!bytes || Detail::kState != kStateReady) return; + if (*bytes == 0) return; + + Detail::kState = kStateTransmit; + + SizeT index = 0; + SizeT len = string_length(bytes, 256); + + while (index < len) { + HAL::Out8(Detail::PORT, bytes[index]); + ++index; + } + + Detail::kState = kStateReady; +} + +TerminalDevice kcout(HCore::ke_io_print, nullptr); +} // namespace HCore diff --git a/Private/HALKit/AMD64/HalDebugPort.cxx b/Private/HALKit/AMD64/HalDebugPort.cxx new file mode 100644 index 00000000..d292f95d --- /dev/null +++ b/Private/HALKit/AMD64/HalDebugPort.cxx @@ -0,0 +1,59 @@ +/* + * ======================================================== + * + * HCore + * Copyright Mahrouss Logic, all rights reserved. + * + * ======================================================== + */ + +//! @file DebuggerPort.cxx +//! @brief UART debug via packets. + +#include + +#define kDebugMaxPorts 16 + +#define kDebugUnboundPort 0xFFFF + +#define kDebugMag0 'X' +#define kDebugMag1 'D' +#define kDebugMag2 'B' +#define kDebugMag3 'G' + +#define kDebugSourceFile 0 +#define kDebugLine 33 +#define kDebugTeam 43 +#define kDebugEOP 49 + +// after that we have start of additional data. + +namespace HCore { +typedef Char rt_debug_type[255]; + +class DebuggerPorts final { + public: + Int16 fPort[kDebugMaxPorts]; + Int16 fBoundCnt; +}; + +void rt_debug_listen(DebuggerPorts* theHook) noexcept { + if (theHook == nullptr) return; + + for (UInt32 i = 0U; i < kDebugMaxPorts; ++i) { + HAL::Out16(theHook->fPort[i], kDebugMag0); + HAL::rt_wait_for_io(); + + HAL::Out16(theHook->fPort[i], kDebugMag1); + HAL::rt_wait_for_io(); + + HAL::Out16(theHook->fPort[i], kDebugMag2); + HAL::rt_wait_for_io(); + + HAL::Out16(theHook->fPort[i], kDebugMag3); + HAL::rt_wait_for_io(); + + if (HAL::In16(theHook->fPort[i] != kDebugUnboundPort)) theHook->fBoundCnt++; + } +} +} // namespace HCore diff --git a/Private/HALKit/AMD64/HalInstallTIB.asm b/Private/HALKit/AMD64/HalInstallTIB.asm new file mode 100644 index 00000000..58f4801b --- /dev/null +++ b/Private/HALKit/AMD64/HalInstallTIB.asm @@ -0,0 +1,18 @@ +;; /* +;; * ======================================================== +;; * +;; * HCore +;; * Copyright Mahrouss Logic, all rights reserved. +;; * +;; * ======================================================== +;; */ + +[bits 64] + +[global rt_install_tib] + +rt_install_tib: + mov rsi, gs + ret + +;; //////////////////////////////////////////////////// ;; diff --git a/Private/HALKit/AMD64/HalSMPCoreManager.asm b/Private/HALKit/AMD64/HalSMPCoreManager.asm new file mode 100644 index 00000000..9741d092 --- /dev/null +++ b/Private/HALKit/AMD64/HalSMPCoreManager.asm @@ -0,0 +1,35 @@ +;; /* +;; * ======================================================== +;; * +;; * HCore +;; * Copyright Mahrouss Logic, all rights reserved. +;; * +;; * ======================================================== +;; */ + +[bits 64] + +[global rt_do_context_switch] + +section .text + +rt_do_context_switch: + mov rcx, r15 + + mov [r15+0], rax + mov [r15+8], rbx + mov [r15+16], rcx + mov [r15+24], rdx + mov [r15+32], rsi + mov [r15+40], rdi + mov [r15+48], rbp + mov [r15+56], rsp + mov [r15+64], r8 + mov [r15+72], r9 + mov [r15+80], r10 + mov [r15+88], r11 + mov [r15+96], r12 + mov [r15+104], r13 + mov [r15+112], r14 + mov [r15+120], r15 + ret diff --git a/Private/HALKit/AMD64/HalStartSequence.asm b/Private/HALKit/AMD64/HalStartSequence.asm new file mode 100644 index 00000000..c8e0a4e2 --- /dev/null +++ b/Private/HALKit/AMD64/HalStartSequence.asm @@ -0,0 +1,40 @@ +;; /* +;; * ======================================================== +;; * +;; * HCore +;; * Copyright Mahrouss Logic, all rights reserved. +;; * +;; * ======================================================== +;; */ + +[bits 64] + +;; Global symbol of this unit +[global Main] +[global MainUnsupported] + +;; External symbols needed by this unit. +[extern RuntimeMain] + +%define kTypeKernel 100 +%define kArchAmd64 122 + +section .NewBoot + +HandoverMagic: dq 0xBAD55 +HandoverType: dw kTypeKernel +HandoverArch: dw kArchAmd64 +;; This NewBootStart points to Main. +HandoverStart: dq Main + +section .text + +;; Just a simple setup, we'd also need to tell some before +Main: + push rcx + jmp RuntimeMain + pop rcx +L0: + cli + hlt + jmp $ diff --git a/Private/HALKit/AMD64/InstallTIB.asm b/Private/HALKit/AMD64/InstallTIB.asm deleted file mode 100644 index 58f4801b..00000000 --- a/Private/HALKit/AMD64/InstallTIB.asm +++ /dev/null @@ -1,18 +0,0 @@ -;; /* -;; * ======================================================== -;; * -;; * HCore -;; * Copyright Mahrouss Logic, all rights reserved. -;; * -;; * ======================================================== -;; */ - -[bits 64] - -[global rt_install_tib] - -rt_install_tib: - mov rsi, gs - ret - -;; //////////////////////////////////////////////////// ;; diff --git a/Private/HALKit/AMD64/SMPCoreManager.asm b/Private/HALKit/AMD64/SMPCoreManager.asm deleted file mode 100644 index 9741d092..00000000 --- a/Private/HALKit/AMD64/SMPCoreManager.asm +++ /dev/null @@ -1,35 +0,0 @@ -;; /* -;; * ======================================================== -;; * -;; * HCore -;; * Copyright Mahrouss Logic, all rights reserved. -;; * -;; * ======================================================== -;; */ - -[bits 64] - -[global rt_do_context_switch] - -section .text - -rt_do_context_switch: - mov rcx, r15 - - mov [r15+0], rax - mov [r15+8], rbx - mov [r15+16], rcx - mov [r15+24], rdx - mov [r15+32], rsi - mov [r15+40], rdi - mov [r15+48], rbp - mov [r15+56], rsp - mov [r15+64], r8 - mov [r15+72], r9 - mov [r15+80], r10 - mov [r15+88], r11 - mov [r15+96], r12 - mov [r15+104], r13 - mov [r15+112], r14 - mov [r15+120], r15 - ret diff --git a/Private/HALKit/AMD64/StartSequence.asm b/Private/HALKit/AMD64/StartSequence.asm deleted file mode 100644 index c8e0a4e2..00000000 --- a/Private/HALKit/AMD64/StartSequence.asm +++ /dev/null @@ -1,40 +0,0 @@ -;; /* -;; * ======================================================== -;; * -;; * HCore -;; * Copyright Mahrouss Logic, all rights reserved. -;; * -;; * ======================================================== -;; */ - -[bits 64] - -;; Global symbol of this unit -[global Main] -[global MainUnsupported] - -;; External symbols needed by this unit. -[extern RuntimeMain] - -%define kTypeKernel 100 -%define kArchAmd64 122 - -section .NewBoot - -HandoverMagic: dq 0xBAD55 -HandoverType: dw kTypeKernel -HandoverArch: dw kArchAmd64 -;; This NewBootStart points to Main. -HandoverStart: dq Main - -section .text - -;; Just a simple setup, we'd also need to tell some before -Main: - push rcx - jmp RuntimeMain - pop rcx -L0: - cli - hlt - jmp $ diff --git a/Private/HALKit/PowerPC/HalHardware.cpp b/Private/HALKit/PowerPC/HalHardware.cpp deleted file mode 100644 index 96b2d09f..00000000 --- a/Private/HALKit/PowerPC/HalHardware.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/* - * ======================================================== - * - * HCore - * Copyright Mahrouss Logic, all rights reserved. - * - * ======================================================== - */ - -#include -#include - -extern "C" void flush_tlb() {} -extern "C" void rt_wait_for_io() {} -extern "C" HCore::HAL::StackFrame* rt_get_current_context() {} - -namespace HCore { -namespace HAL { -UIntPtr hal_create_page(bool rw, bool user) { return 0; } - -UIntPtr hal_alloc_page(UIntPtr offset, bool rw, bool user) { return 0; } -} // namespace HAL - -// @brief wakes up thread. -// wakes up thread from hang. -void rt_wakeup_thread(HAL::StackFrame* stack) {} - -// @brief makes thread sleep. -// hooks and hangs thread to prevent code from executing. -void rt_hang_thread(HAL::StackFrame* stack) {} - -// @brief main HAL entrypoint -void ke_init_hal() {} - -void system_io_print(const char* bytes) { - if (!bytes) return; - - SizeT index = 0; - SizeT len = string_length(bytes, 256); - - while (index < len) { - // TODO - ++index; - } -} - -TerminalDevice kcout(HCore::system_io_print, nullptr); -} // namespace HCore diff --git a/Private/HALKit/PowerPC/HalHardware.cxx b/Private/HALKit/PowerPC/HalHardware.cxx new file mode 100644 index 00000000..550d3747 --- /dev/null +++ b/Private/HALKit/PowerPC/HalHardware.cxx @@ -0,0 +1,49 @@ +/* + * ======================================================== + * + * HCore + * Copyright Mahrouss Logic, all rights reserved. + * + * ======================================================== + */ + +#include +#include + +extern "C" void flush_tlb() {} +extern "C" void rt_wait_for_io() {} + +extern "C" HCore::HAL::StackFrame* rt_get_current_context() {} + +namespace HCore { +namespace HAL { +UIntPtr hal_create_page(bool rw, bool user) { return 0; } + +UIntPtr hal_alloc_page(UIntPtr offset, bool rw, bool user) { return 0; } +} // namespace HAL + +// @brief wakes up thread. +// wakes up thread from hang. +void rt_wakeup_thread(HAL::StackFrame* stack) {} + +// @brief makes thread sleep. +// hooks and hangs thread to prevent code from executing. +void rt_hang_thread(HAL::StackFrame* stack) {} + +// @brief main HAL entrypoint +void ke_init_hal() {} + +void ke_com_print(const char* bytes) { + if (!bytes) return; + + SizeT index = 0; + SizeT len = string_length(bytes, 256); + + while (index < len) { + // TODO + ++index; + } +} + +TerminalDevice kcout(HCore::ke_com_print, nullptr); +} // namespace HCore diff --git a/Private/NewBoot/BootKit/Arch/AHCI.hxx b/Private/NewBoot/BootKit/Arch/AHCI.hxx new file mode 100644 index 00000000..2e3739b5 --- /dev/null +++ b/Private/NewBoot/BootKit/Arch/AHCI.hxx @@ -0,0 +1,12 @@ +/* + * ======================================================== + * + * NewBoot + * Copyright Mahrouss Logic, all rights reserved. + * + * ======================================================== + */ + +#pragma once + +#include diff --git a/Private/NewBoot/BootKit/Arch/ATA.hxx b/Private/NewBoot/BootKit/Arch/ATA.hxx index 4042aaa9..4b4eb399 100644 --- a/Private/NewBoot/BootKit/Arch/ATA.hxx +++ b/Private/NewBoot/BootKit/Arch/ATA.hxx @@ -111,12 +111,6 @@ using namespace HCore; #define ATA_ADDRESS3(x) (x + 5) #define ATA_COMMAND(x) (x + 7) -Boolean ATAInitDriver(UInt8 Bus, UInt8 Drv); -Void ATAWait(UInt16 IO); -Void ATAReadLba(UInt32 Lba, UInt8 Bus, Boolean Master, wchar_t* Buf, - SizeT Offset); -Void ATAWriteLba(UInt32 Lba, UInt8 Bus, Boolean Master, wchar_t* Buf, - SizeT Offset); Boolean ATAIsDetected(Void); class BATADevice final { @@ -134,7 +128,10 @@ class BATADevice final { struct ATATraits final { SizeT mBase{1024}; UInt16 mBus{kPrimary}; - Boolean mMaster{true}; + UInt8 mMaster{0}; + Boolean mErr{false}; + + operator bool() { return !mErr; } }; operator bool() { return ATAIsDetected(); } diff --git a/Private/NewBoot/BootKit/BootKit.hxx b/Private/NewBoot/BootKit/BootKit.hxx index 6fdbacaf..d1584d8a 100644 --- a/Private/NewBoot/BootKit/BootKit.hxx +++ b/Private/NewBoot/BootKit/BootKit.hxx @@ -56,13 +56,13 @@ HCore::SizeT BSetMem(CharacterType *src, const CharacterType byte, const HCore::SizeT len); /** - * @brief BootKit Image Reader class - * Reads using the UEFI Simple File protocol. + * @brief BootKit File Reader class + * Reads using the New Filesystem Boot partition. */ -class BImageReader final { +class BFileReader final { public: - explicit BImageReader(const CharacterType *path); - ~BImageReader() = default; + explicit BFileReader(const CharacterType *path); + ~BFileReader() = default; HCore::VoidPtr Fetch(SizeT &size); @@ -78,8 +78,8 @@ class BImageReader final { Int32 &Error() { return mErrorCode; } public: - BImageReader &operator=(const BImageReader &) = default; - BImageReader(const BImageReader &) = default; + BFileReader &operator=(const BFileReader &) = default; + BFileReader(const BFileReader &) = default; private: Int32 mErrorCode{kOperationOkay}; @@ -115,21 +115,21 @@ inline void Out32(UInt16 port, UInt32 value) { } inline UInt8 In8(UInt16 port) { - UInt8 value = 0UL; + UInt8 value; asm volatile("inb %1, %%al" : "=a"(value) : "Nd"(port) : "memory"); return value; } inline UInt16 In16(UInt16 port) { - UInt16 value = 0UL; - asm volatile("in %%dx, %%ax" : "=a"(value) : "d"(port)); + UInt16 value; + asm volatile("inw %%dx, %%ax" : "=a"(value) : "d"(port)); return value; } inline UInt32 In32(UInt16 port) { - UInt32 value = 0UL; + UInt32 value; asm volatile("inl %1, %%eax" : "=a"(value) : "Nd"(port) : "memory"); return value; diff --git a/Private/NewBoot/Source/Entrypoint.cxx b/Private/NewBoot/Source/Entrypoint.cxx index ff118f8a..d2134746 100644 --- a/Private/NewBoot/Source/Entrypoint.cxx +++ b/Private/NewBoot/Source/Entrypoint.cxx @@ -7,7 +7,6 @@ * ======================================================== */ -#include "EFIKit/EFI.hxx" #define __BOOTLOADER__ 1 #include @@ -25,7 +24,7 @@ STATIC Void DrawBackground() { for (int h = 0; h < gop->Mode->Info->HorizontalResolution; ++h) { *((UInt32*)(gop->Mode->FrameBufferBase + 4 * gop->Mode->Info->PixelsPerScanLine * w + 4 * h)) = - RGB(20, 20, 20); + RGB(10, 10, 10); } } } @@ -43,7 +42,7 @@ EFI_EXTERN_C Int EfiMain(EfiHandlePtr ImageHandle, UInt64 mapKey = 0; - BImageReader img(L"HCoreKrnl.exe"); + BFileReader img(L"HCoreKrnl.exe"); SizeT sz = 0UL; PEImagePtr blob = (PEImagePtr)img.Fetch(sz); diff --git a/Private/NewBoot/Source/FileReader.cxx b/Private/NewBoot/Source/FileReader.cxx new file mode 100644 index 00000000..39884f9f --- /dev/null +++ b/Private/NewBoot/Source/FileReader.cxx @@ -0,0 +1,54 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + + File: FileReader.cxx + Purpose: NewBoot FileReader, + Read complete file and store it in a buffer. + + Revision History: + + + +------------------------------------------- */ + +#include +#include +#include + +//////////////////////////////////////////////////////////////////////////////////////////////////// +// +// +// @brief BImageReader class +// +// +//////////////////////////////////////////////////////////////////////////////////////////////////// + +/*** + @brief File Reader constructor. +*/ +BFileReader::BFileReader(const CharacterType *path) { + if (path != nullptr) { + SizeT index = 0UL; + for (; path[index] != L'\0'; ++index) { + mPath[index] = path[index]; + } + + mPath[index] = 0; + } +} + +/** + @brief this reads all of the buffer. + @param size, new buffer size. +*/ +HCore::VoidPtr BFileReader::Fetch(SizeT &size) { + mWriter.WriteString(L"HCoreLdr: Fetch-File: ") + .WriteString(mPath) + .WriteString(L"\r\n"); + + this->mCached = true; + this->mErrorCode = kNotSupported; + + return nullptr; +} diff --git a/Private/NewBoot/Source/HEL/AMD64/AMD64-AHCI.cxx b/Private/NewBoot/Source/HEL/AMD64/AMD64-AHCI.cxx new file mode 100644 index 00000000..2d449bbb --- /dev/null +++ b/Private/NewBoot/Source/HEL/AMD64/AMD64-AHCI.cxx @@ -0,0 +1,19 @@ +/* + * ======================================================== + * + * NewBoot + * Copyright Mahrouss Logic, all rights reserved. + * + * ======================================================== + */ + +/** + * @file AHCI.cxx + * @author Amlal El Mahrouss (amlalelmahrouss@icloud.com) + * @brief AHCI driver. + * @version 0.1 + * @date 2024-02-02 + * + * @copyright Copyright (c) 2024 Mahrouss Logic + * + */ diff --git a/Private/NewBoot/Source/HEL/AMD64/AMD64-ATA.cxx b/Private/NewBoot/Source/HEL/AMD64/AMD64-ATA.cxx index d6b6e0a9..3414d060 100644 --- a/Private/NewBoot/Source/HEL/AMD64/AMD64-ATA.cxx +++ b/Private/NewBoot/Source/HEL/AMD64/AMD64-ATA.cxx @@ -14,133 +14,162 @@ * @version 0.1 * @date 2024-02-02 * - * @copyright Copyright (c) 2024 + * @copyright Copyright (c) 2024 Mahrouss Logic * */ #include #include +#include + +#include "BootKit/Platform.hxx" /// bugs: 0 -extern "C" Void ATAWaitForIO(Void); +#define kATADataLen 256 static Boolean kATADetected = false; static Int32 kATADeviceType = kATADeviceCount; +static CharacterType kATAData[kATADataLen] = {0}; + +STATIC Boolean ATAWaitForIO(UInt16 IO) { + for (int i = 0; i < 4; i++) In8(IO + ATA_REG_STATUS); + +ATAWaitForIO_Retry: + auto statRdy = In8(IO + ATA_REG_STATUS); + + if ((statRdy & ATA_SR_BSY)) goto ATAWaitForIO_Retry; + +ATAWaitForIO_Retry2: + statRdy = In8(IO + ATA_REG_STATUS); + + if (statRdy & ATA_SR_ERR) return false; + + if (!(statRdy & ATA_SR_DRDY)) goto ATAWaitForIO_Retry2; + + return true; +} -void ATASelect(UInt8 Bus, Boolean isMaster) { - if (Bus == ATA_PRIMARY) - Out8(ATA_PRIMARY_IO + ATA_REG_HDDEVSEL, - isMaster ? ATA_PRIMARY_SEL : ATA_SECONDARY_SEL); +Void ATASelect(UInt16 Bus) { + if (Bus == ATA_PRIMARY_IO) + Out8(Bus + ATA_REG_HDDEVSEL, ATA_PRIMARY_SEL); else - Out8(ATA_SECONDARY_IO + ATA_REG_HDDEVSEL, - isMaster ? ATA_PRIMARY_SEL : ATA_SECONDARY_SEL); + Out8(Bus + ATA_REG_HDDEVSEL, ATA_SECONDARY_SEL); } -Boolean ATAInitDriver(UInt8 Bus, UInt8 Drive, UInt16& OutBus, - Boolean& OutMaster) { +Boolean ATAInitDriver(UInt16 Bus, UInt8 Drive, UInt16& OutBus, + UInt8& OutMaster) { BTextWriter writer; - UInt16 IO = (Bus == ATA_PRIMARY) ? ATA_PRIMARY_IO : ATA_SECONDARY_IO; + UInt16 IO = Bus; - ATASelect(Bus, Drive); + // Bus init, NEIN bit. + Out8(IO + 1, 1); - Out8(IO + ATA_REG_SEC_COUNT0, 0); - Out8(IO + ATA_REG_LBA0, 0); - Out8(IO + ATA_REG_LBA1, 0); - Out8(IO + ATA_REG_LBA2, 0); + ATASelect(IO); + + // identify until it's good. +ATAInit_Retry: + auto statRdy = In8(IO + ATA_REG_STATUS); + + if (statRdy & ATA_SR_ERR) { + return false; + } + if ((statRdy & ATA_SR_BSY)) goto ATAInit_Retry; Out8(IO + ATA_REG_COMMAND, ATA_CMD_IDENTIFY); - UInt8 status = In8(IO + ATA_REG_STATUS); + for (SizeT indexData = 0ul; indexData < kATADataLen; ++indexData) { + kATAData[indexData] = In16(IO + ATA_REG_DATA); + } - if (status & ATA_SR_ERR) { -#ifdef __DEBUG__ - writer.WriteString(L"HCoreLdr: Init ATA: Bad Drive!\r\n"); -#endif // ifdef __DEBUG__ - return false; + writer.WriteString(L"HCoreLdr: Drive: "); + + /// fetch drive info + + for (SizeT indexData = 0; indexData < kATADataLen; indexData += 1) { + writer.WriteCharacter(kATAData[indexData + 1]) + .WriteCharacter(kATAData[indexData]); } + writer.WriteString(L"\r\n"); + OutBus = (Bus == ATA_PRIMARY) ? BATADevice::kPrimary : BATADevice::kSecondary; - OutMaster = (Bus == ATA_PRIMARY); + OutMaster = (Bus == ATA_PRIMARY) ? ATA_MASTER : ATA_SLAVE; - unsigned cl = In16(Bus + ATA_CYL_LOW); /* get the "signature bytes" */ - unsigned ch = In16(Bus + ATA_CYL_HIGH); + Out8(Bus + ATA_REG_HDDEVSEL, 0xA0 | ATA_MASTER << 4); + + In8(Bus + ATA_REG_CONTROL); + In8(Bus + ATA_REG_CONTROL); + In8(Bus + ATA_REG_CONTROL); + In8(Bus + ATA_REG_CONTROL); + + unsigned cl = In8(Bus + ATA_CYL_LOW); /* get the "signature bytes" */ + unsigned ch = In8(Bus + ATA_CYL_HIGH); /* differentiate ATA, ATAPI, SATA and SATAPI */ if (cl == 0x14 && ch == 0xEB) { - writer.WriteString(L"HCoreLdr: PATAPI: drive detected.\r\n"); + writer.WriteString(L"HCoreLdr: PATAPI drive detected.\r\n"); kATADeviceType = kATADevicePATA_PI; } if (cl == 0x69 && ch == 0x96) { - writer.WriteString(L"HCoreLdr: SATAPI: drive detected.\r\n"); + writer.WriteString(L"HCoreLdr: SATAPI drive detected.\r\n"); kATADeviceType = kATADeviceSATA_PI; } + if (cl == 0 && ch == 0) { - writer.WriteString(L"HCoreLdr: PATA: drive detected.\r\n"); + writer.WriteString(L"HCoreLdr: PATA drive detected.\r\n"); kATADeviceType = kATADevicePATA; } + if (cl == 0x3c && ch == 0xc3) { - writer.WriteString(L"HCoreLdr: SATA: drive detected.\r\n"); + writer.WriteString(L"HCoreLdr: SATA drive detected.\r\n"); kATADeviceType = kATADeviceSATA; } - return true; -} + Out8(IO + ATA_REG_CONTROL, 0x02); -/*** @brief - * This polls the ATA drive. - */ -void ATAWait(UInt16 IO) { - for (int i = 0; i < 4000; i++) In8(IO + ATA_REG_ALT_STATUS); + return true; } -void ATAPoll(UInt16 IO) { ATAWait(IO); } - -Void ATAReadLba(UInt32 Lba, UInt8 IO, Boolean Master, CharacterType* Buf, +Void ATAReadLba(UInt32 Lba, UInt8 IO, UInt8 Master, CharacterType* Buf, SizeT Offset) { - rt_cli(); - ATAWaitForIO(); - - Lba &= 0x00FFFFFF; - UInt8 Command = (Master ? 0xE0 : 0xF0); - Out8(IO + ATA_REG_HDDEVSEL, Command | ((Lba >> 24))); + Out8(IO + ATA_REG_HDDEVSEL, + (Command << 4) | (((Lba & 0x0f000000) >> 24) & 0x0f)); Out8(IO + ATA_REG_SEC_COUNT0, 0x1); + Out8(IO + ATA_REG_FEATURES, 0); - Out8(IO + ATA_REG_LBA0, (UInt8)Lba); - Out8(IO + ATA_REG_LBA1, (UInt8)Lba >> 8); - Out8(IO + ATA_REG_LBA2, (UInt8)Lba >> 16); + Out8(IO + ATA_REG_LBA0, (UInt8)(Lba & 0x000000ff)); + Out8(IO + ATA_REG_LBA1, (UInt8)(Lba & 0x0000ff00) >> 8); + Out8(IO + ATA_REG_LBA2, (UInt8)(Lba & 0x00ff0000) >> 16); Out8(IO + ATA_REG_COMMAND, ATA_CMD_READ_PIO); - Buf[Offset] = In16(IO); - - ATAWaitForIO(); - rt_sti(); + for (SizeT i = 0; i < 256; ++i) { + Buf[Offset + i] = In16(IO + ATA_REG_DATA); + } } -Void ATAWriteLba(UInt32 Lba, UInt8 IO, Boolean Master, wchar_t* Buf, +Void ATAWriteLba(UInt32 Lba, UInt8 IO, UInt8 Master, wchar_t* Buf, SizeT Offset) { - rt_cli(); - ATAWaitForIO(); - Lba &= 0x00FFFFFF; - UInt8 Command = (Master ? 0xE0 : 0xF0); - Out8(IO + ATA_REG_HDDEVSEL, Command | ((Lba >> 24))); + Out8(IO + ATA_REG_HDDEVSEL, + (Command << 4) | (((Lba & 0x0f000000) >> 24) & 0x0f)); Out8(IO + ATA_REG_SEC_COUNT0, 0x1); + Out8(IO + ATA_REG_FEATURES, 0); - Out8(IO + ATA_REG_LBA0, (UInt8)Lba); - Out8(IO + ATA_REG_LBA1, (UInt8)Lba >> 8); - Out8(IO + ATA_REG_LBA2, (UInt8)Lba >> 16); + Out8(IO + ATA_REG_LBA0, (UInt8)(Lba & 0x000000ff)); + Out8(IO + ATA_REG_LBA1, (UInt8)(Lba & 0x0000ff00) >> 8); + Out8(IO + ATA_REG_LBA2, (UInt8)(Lba & 0x00ff0000) >> 16); Out8(IO + ATA_REG_COMMAND, ATA_CMD_WRITE_PIO); - Out16(IO, Buf[Offset]); - ATAWaitForIO(); - rt_sti(); + for (SizeT i = 0; i < 256; ++i) { + Out16(IO + ATA_REG_DATA, Buf[Offset + i]); + } } Boolean ATAIsDetected(Void) { return kATADetected; } @@ -160,13 +189,13 @@ Boolean ATAIsDetected(Void) { return kATADetected; } BATADevice::BATADevice() noexcept { if (ATAIsDetected()) return; - if (ATAInitDriver(ATA_PRIMARY, true, this->Leak().mBus, + if (ATAInitDriver(ATA_PRIMARY_IO, true, this->Leak().mBus, this->Leak().mMaster) || - ATAInitDriver(ATA_PRIMARY, false, this->Leak().mBus, + ATAInitDriver(ATA_PRIMARY_IO, false, this->Leak().mBus, this->Leak().mMaster) || - ATAInitDriver(ATA_SECONDARY, true, this->Leak().mBus, + ATAInitDriver(ATA_SECONDARY_IO, true, this->Leak().mBus, this->Leak().mMaster) || - ATAInitDriver(ATA_SECONDARY, false, this->Leak().mBus, + ATAInitDriver(ATA_SECONDARY_IO, false, this->Leak().mBus, this->Leak().mMaster)) { kATADetected = true; @@ -181,9 +210,14 @@ BATADevice::BATADevice() noexcept { @param Buf buffer */ BATADevice& BATADevice::Read(CharacterType* Buf, const SizeT& SectorSz) { - if (!ATAIsDetected()) return *this; + if (!ATAIsDetected()) { + Leak().mErr = true; + return *this; + } + + Leak().mErr = false; - if (!Buf || SectorSz > kATASectorSz || SectorSz < 1) return *this; + if (!Buf || SectorSz < 1) return *this; for (SizeT i = 0UL; i < SectorSz; ++i) { ATAReadLba(this->Leak().mBase + i, this->Leak().mBus, this->Leak().mMaster, @@ -199,9 +233,14 @@ BATADevice& BATADevice::Read(CharacterType* Buf, const SizeT& SectorSz) { @param Buf buffer */ BATADevice& BATADevice::Write(CharacterType* Buf, const SizeT& SectorSz) { - if (!ATAIsDetected()) return *this; + if (!ATAIsDetected()) { + Leak().mErr = true; + return *this; + } + + Leak().mErr = false; - if (!Buf || SectorSz > kATASectorSz || SectorSz < 1) return *this; + if (!Buf || SectorSz < 1) return *this; SizeT Off = 0UL; diff --git a/Private/NewBoot/Source/HEL/AMD64/AMD64-CoreSync-ATA.asm b/Private/NewBoot/Source/HEL/AMD64/AMD64-CoreSync-ATA.asm deleted file mode 100644 index 6ad07a59..00000000 --- a/Private/NewBoot/Source/HEL/AMD64/AMD64-CoreSync-ATA.asm +++ /dev/null @@ -1,24 +0,0 @@ -[bits 64] - - -section .text -global ATAWaitForIO - -ATAWaitForIO: - push ax - push dx - - xor ax, ax - mov dx, 01F7h - -ATAWaitForIO_Loop: - in al, dx - and al, 0C0h - cmp al, 040h - jne ATAWaitForIO_Loop - -ATAWaitForIO_End: - pop dx - pop ax - - ret diff --git a/Private/NewBoot/Source/ImageReader.cxx b/Private/NewBoot/Source/ImageReader.cxx deleted file mode 100644 index 98e025a8..00000000 --- a/Private/NewBoot/Source/ImageReader.cxx +++ /dev/null @@ -1,72 +0,0 @@ -/* ------------------------------------------- - - Copyright Mahrouss Logic - - File: String.cxx - Purpose: NewBoot string library - - Revision History: - - - -------------------------------------------- */ - -#include -#include -#include - -#include "NewKit/Defines.hpp" - -//////////////////////////////////////////////////////////////////////////////////////////////////// -// -// -// @brief BImageReader class -// -// -//////////////////////////////////////////////////////////////////////////////////////////////////// - -/*** - @brief File Reader constructor. -*/ -BImageReader::BImageReader(const CharacterType *path) { - if (path != nullptr) { - SizeT index = 0UL; - for (; path[index] != L'\0'; ++index) { - mPath[index] = path[index]; - } - - mPath[index] = 0; - } -} - -/** - @brief this reads all of the buffer. - @param size, new buffer size. -*/ -HCore::VoidPtr BImageReader::Fetch(SizeT &size) { - mWriter.WriteString(L"HCoreLdr: Fetch-Image: ") - .WriteString(mPath) - .WriteString(L"\r\n"); - - CharacterType bootBlockBytes[kATASectorSz] = {0}; - - mDevice.Leak().mBase = kNewFSAddressAsLba; - mDevice.Leak().mMaster = true; - - mDevice.Read(bootBlockBytes, kATASectorSz); - - NewBootBlock *bootBlock = (NewBootBlock *)bootBlockBytes; - - for (SizeT index = 0UL; index < kNewFSIdentLen; ++index) { - if (bootBlock->Ident[index] != kNewFSIdent[index]) { - mWriter.WriteString(L"HCoreLdr: NewFS: Not found.\r\n"); - return nullptr; - } - } - - /// get file catalog with mPath inside it. - - this->mCached = true; - - return nullptr; -} diff --git a/Private/NewBoot/Source/String.cxx b/Private/NewBoot/Source/String.cxx index a2d19f1f..e080a01d 100644 --- a/Private/NewBoot/Source/String.cxx +++ b/Private/NewBoot/Source/String.cxx @@ -61,28 +61,3 @@ HCore::SizeT BSetMem(CharacterType *src, const CharacterType byte, return cnt; } - -///////////////////////////////////////////////////////////////////////////////////////////////////////// - -/** -@brief puts wrapper over EFI. -*/ -BTextWriter &BTextWriter::WriteString(const CharacterType *str) { - if (*str == 0 || !str) return *this; - - ST->ConOut->OutputString(ST->ConOut, str); - - return *this; -} - -/** -@brief putc wrapper over EFI. -*/ -BTextWriter &BTextWriter::WriteCharacter(CharacterType c) { - EfiCharType str[2]; - str[0] = c; - str[1] = 0; - ST->ConOut->OutputString(ST->ConOut, str); - - return *this; -} diff --git a/Private/NewBoot/Source/TextWriter.cxx b/Private/NewBoot/Source/TextWriter.cxx new file mode 100644 index 00000000..77baa067 --- /dev/null +++ b/Private/NewBoot/Source/TextWriter.cxx @@ -0,0 +1,48 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + + File: String.cxx + Purpose: NewBoot string library + + Revision History: + + + +------------------------------------------- */ + +#include +#include +#include + +/// bugs 0 + +///////////////////////////////////////////////////////////////////////////////////////////////////////// + +/** +@brief puts wrapper over EFI ConOut. +*/ +BTextWriter &BTextWriter::WriteString(const CharacterType *str) { +#ifdef __DEBUG__ + + if (*str == 0 || !str) return *this; + + ST->ConOut->OutputString(ST->ConOut, str); +#endif + + return *this; +} + +/** +@brief putc wrapper over EFI ConOut. +*/ +BTextWriter &BTextWriter::WriteCharacter(CharacterType c) { +#ifdef __DEBUG__ + EfiCharType str[2]; + str[0] = c; + str[1] = 0; + ST->ConOut->OutputString(ST->ConOut, str); +#endif + + return *this; +} diff --git a/Private/NewBoot/Source/makefile b/Private/NewBoot/Source/makefile index eb836632..460b5dc1 100644 --- a/Private/NewBoot/Source/makefile +++ b/Private/NewBoot/Source/makefile @@ -16,16 +16,18 @@ invalid-recipe: .PHONY: bootloader-amd64 bootloader-amd64: - $(ASM) $(FLAG_ASM) HEL/AMD64/AMD64-CoreSync-ATA.asm $(CC_GNU) $(FLAG_GNU) HEL/AMD64/*.cxx *.cxx $(LD_GNU) *.o HEL/AMD64/*.obj -e efi_main -filealign:16 -shared --subsystem=10 -ffreestanding -o HCoreLdr.exe cp HCoreLdr.exe CDROM/EFI/BOOT/BOOTX64.EFI - cp ../../HCoreKrnl.exe CDROM/EFI/BOOT/HCoreKrnl.exe + +.PHONY: make-disk +make-disk: + qemu-img create -f qcow2 os.epm 1M .PHONY: run-efi-debug run-efi-debug: wget https://retrage.github.io/edk2-nightly/bin/DEBUGX64_OVMF.fd -O OVMF.fd - qemu-system-x86_64 -bios OVMF.fd -drive file=fat:rw:CDROM,format=raw -d int + qemu-system-x86_64 -M q35 -bios OVMF.fd -drive file=os.epm,index=0,if=ide,format=qcow2 -drive file=fat:rw:CDROM,index=1,format=raw -d int .PHONY: clean clean: diff --git a/Private/NewKit/Macros.hpp b/Private/NewKit/Macros.hpp index 50d44946..8b974fc2 100644 --- a/Private/NewKit/Macros.hpp +++ b/Private/NewKit/Macros.hpp @@ -88,4 +88,6 @@ #define NO_EXEC ATTRIBUTE(noexec) #define EXTERN extern -#define STATIC static \ No newline at end of file +#define STATIC static + +#include diff --git a/Private/NewKit/compile_flags.txt b/Private/NewKit/compile_flags.txt index a37ae6bf..14c5bc51 100644 --- a/Private/NewKit/compile_flags.txt +++ b/Private/NewKit/compile_flags.txt @@ -3,3 +3,4 @@ -std=c++20 -I./ -I../ +-I../../../ diff --git a/Private/Source/CxxKitRT.cxx b/Private/Source/CxxKitRT.cxx deleted file mode 100644 index cc2d477d..00000000 --- a/Private/Source/CxxKitRT.cxx +++ /dev/null @@ -1,20 +0,0 @@ -/* - * ======================================================== - * - * HCore - * Copyright Mahrouss Logic, all rights reserved. - * - * ======================================================== - */ - -#include -#include -#include - -using namespace HCore; - -// unimplemented _HintTell -void _HintTell(_HintMessage* ppMsg, _HintId* pId) { - (void)ppMsg; - (void)pId; -} diff --git a/Private/makefile b/Private/makefile index f21a037e..6834c0be 100644 --- a/Private/makefile +++ b/Private/makefile @@ -8,7 +8,7 @@ LD = x86_64-w64-mingw32-ld CCFLAGS = -c -ffreestanding -fno-rtti -fno-exceptions -std=c++20 -D__HAVE_HCORE_APIS__ -D__HCORE__ -I../ -I./ -I$(HOME)/ ASM = nasm ASMFLAGS = -f win64 -LDFLAGS = -e Main -filealign:16 -shared --subsystem=10 +LDFLAGS = -e Main -filealign:16 -shared --subsystem=10 LDOBJ = Obj/*.obj # This file is the kernel, responsible of task management, memory, drivers and more. @@ -31,8 +31,9 @@ h-core-amd64: $(CC) $(CCFLAGS) Source/*.cxx HALKit/AMD64/PCI/*.cpp Source/Network/*.cpp\ Source/Storage/*.cxx HALKit/AMD64/*.cxx HALKit/AMD64/*.cpp HALKit/AMD64/*.s $(ASM) $(ASMFLAGS) HALKit/AMD64/HalInterruptRouting.asm - $(ASM) $(ASMFLAGS) HALKit/AMD64/SMPCoreManager.asm - $(ASM) $(ASMFLAGS) HALKit/AMD64/StartSequence.asm + $(ASM) $(ASMFLAGS) HALKit/AMD64/HalSMPCoreManager.asm + $(ASM) $(ASMFLAGS) HALKit/AMD64/HalStartSequence.asm + $(ASM) $(ASMFLAGS) HALKit/AMD64/HalInstallTIB.asm $(MOVEALL) OBJCOPY = x86_64-elf-objcopy diff --git a/Public/BUG_LIST.TXT b/Public/BUG_LIST.TXT new file mode 100644 index 00000000..1fa4e00a --- /dev/null +++ b/Public/BUG_LIST.TXT @@ -0,0 +1,3 @@ +ADD THE BUGS HERE: + +None diff --git a/Public/SPECIFICATION.TXT b/Public/SPECIFICATION.TXT new file mode 100644 index 00000000..a681984f --- /dev/null +++ b/Public/SPECIFICATION.TXT @@ -0,0 +1,32 @@ +=================================== +0: General Information +=================================== + +- ABI and Format: PEF/PE32+. +- Architecture: Microkernel. +- Language: C++/(Assembly (AMD64, X64000, X86S, ARM64)) + +=================================== +1: The HCore Microkernel +=================================== + +- Drive Abstraction. +- SMP, Preemptive MT. +- Separation of Files/Devices. +- Networking. +- Hardware Abstraction Layer. +- Native Filesystem support (NewFS). +- Program Loader. +- TLS. +- Canary bird. +- Dynamic Libraries. +- Cross platform code (it has to work for each platform) + +=================================== +2: The Filesystem +=================================== + +- Catalog based with forks. +- Large storage support. +- Long file names. +- UNIX path style. diff --git a/Public/TODO_LIST.TXT b/Public/TODO_LIST.TXT new file mode 100644 index 00000000..b89c0659 --- /dev/null +++ b/Public/TODO_LIST.TXT @@ -0,0 +1,20 @@ +- We need preemptive multi-threading. [ X ] +- We then need sync primitives. [ X ] +- We also need a system library for the OS. [ X ] +- We need a bootloader for AMD64/ARM [ X ] + - Implement Boot Services [ X ] + - Design Handover [ X ] + - Load kernel into memory [ ] + - Jump to kernel [ ] +- Context switch x87/SSE/AVX registers [ ] +- Framebuffer and ATA support [ ] +- Native Subsystem and GUI [ ] + +Status: + +HCoreLdr: Working. +HCoreKrnl: Not run yet. + +Prioritize: +HCoreLdr: Protocol and API. +HCoreKrnl: Complying to specs. diff --git a/SPECIFICATION.TXT b/SPECIFICATION.TXT deleted file mode 100644 index a681984f..00000000 --- a/SPECIFICATION.TXT +++ /dev/null @@ -1,32 +0,0 @@ -=================================== -0: General Information -=================================== - -- ABI and Format: PEF/PE32+. -- Architecture: Microkernel. -- Language: C++/(Assembly (AMD64, X64000, X86S, ARM64)) - -=================================== -1: The HCore Microkernel -=================================== - -- Drive Abstraction. -- SMP, Preemptive MT. -- Separation of Files/Devices. -- Networking. -- Hardware Abstraction Layer. -- Native Filesystem support (NewFS). -- Program Loader. -- TLS. -- Canary bird. -- Dynamic Libraries. -- Cross platform code (it has to work for each platform) - -=================================== -2: The Filesystem -=================================== - -- Catalog based with forks. -- Large storage support. -- Long file names. -- UNIX path style. diff --git a/TODO_LIST.TXT b/TODO_LIST.TXT deleted file mode 100644 index b89c0659..00000000 --- a/TODO_LIST.TXT +++ /dev/null @@ -1,20 +0,0 @@ -- We need preemptive multi-threading. [ X ] -- We then need sync primitives. [ X ] -- We also need a system library for the OS. [ X ] -- We need a bootloader for AMD64/ARM [ X ] - - Implement Boot Services [ X ] - - Design Handover [ X ] - - Load kernel into memory [ ] - - Jump to kernel [ ] -- Context switch x87/SSE/AVX registers [ ] -- Framebuffer and ATA support [ ] -- Native Subsystem and GUI [ ] - -Status: - -HCoreLdr: Working. -HCoreKrnl: Not run yet. - -Prioritize: -HCoreLdr: Protocol and API. -HCoreKrnl: Complying to specs. -- cgit v1.2.3