From 0476248f648ccddea9bdf9bae9095c3231e6643d Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Fri, 26 Jan 2024 15:37:37 +0100 Subject: Kernel: Retarget AMD64 according to spec. Kernel/Toolchain: Now move hKernel to /System/ when building the system. MPT: Fix API. newBoot: This is the priority, get a standard file layout to load the kernel at BK_START_KERNEL (0x00080000) Signed-off-by: Amlal El Mahrouss --- newBoot/Source/Arch/AMD64/BootAMD64.cxx | 4 +- newBoot/Source/Arch/AMD64/Processor.cxx | 7 ++++ newBoot/Source/MPT/API.cxx | 67 ++++++++++++++++++--------------- newBoot/Source/MPT/API.hxx | 2 +- newBoot/Source/MPT/MPT.hxx | 6 +-- newBoot/Source/Start.cxx | 2 +- 6 files changed, 50 insertions(+), 38 deletions(-) (limited to 'newBoot/Source') diff --git a/newBoot/Source/Arch/AMD64/BootAMD64.cxx b/newBoot/Source/Arch/AMD64/BootAMD64.cxx index 5543a34f..0ed59ff0 100644 --- a/newBoot/Source/Arch/AMD64/BootAMD64.cxx +++ b/newBoot/Source/Arch/AMD64/BootAMD64.cxx @@ -23,7 +23,7 @@ long long int BStrLen(const char* ptr) return cnt; } -void BTextWriter::WriteString( +void BKTextWriter::WriteString( const char* str, unsigned char forecolour, unsigned char backcolour, @@ -41,7 +41,7 @@ void BTextWriter::WriteString( } } -void BTextWriter::WriteCharacter( +void BKTextWriter::WriteCharacter( char c, unsigned char forecolour, unsigned char backcolour, diff --git a/newBoot/Source/Arch/AMD64/Processor.cxx b/newBoot/Source/Arch/AMD64/Processor.cxx index 18b5e8e7..50330e47 100644 --- a/newBoot/Source/Arch/AMD64/Processor.cxx +++ b/newBoot/Source/Arch/AMD64/Processor.cxx @@ -7,6 +7,13 @@ * ======================================================== */ +/* + * + * @file Processor.cxx + * @brief Processor Specific Functions. + * + */ + extern "C" void rt_halt(void) { asm volatile("hlt"); } extern "C" void rt_cli(void) { asm volatile("cli"); } diff --git a/newBoot/Source/MPT/API.cxx b/newBoot/Source/MPT/API.cxx index c5e31d7f..e607eecd 100644 --- a/newBoot/Source/MPT/API.cxx +++ b/newBoot/Source/MPT/API.cxx @@ -10,22 +10,6 @@ #include "API.hxx" #include "Detail.hxx" -struct Files32FileHdr final -{ - char Filename[32]; - char Ext[3]; - char Attr; - char Case; - char CreateMs; - unsigned short Create; - unsigned short CreateDate; - unsigned short LastAccess; - unsigned short Timestamp; - unsigned short Datestamp; - unsigned short StartLba; - unsigned int SizeFile; -}; - #define kFilesR 0x01 /* read-only */ #define kFilesH 0x02 /* hidden */ #define kFilesS 0x04 /* system */ @@ -36,29 +20,50 @@ struct Files32FileHdr final // @brief Array of unused bits. #define kFilesU { 0x40, 0x80 } -struct Files32FileGroup final +namespace mpt::detail { - Files32FileHdr* fHdr{ nullptr }; + struct Files32FileHdr final + { + char Filename[32]; + char Ext[3]; + char Attr; + char Case; + char CreateMs; + unsigned short Create; + unsigned short CreateDate; + unsigned short LastAccess; + unsigned short Timestamp; + unsigned short Datestamp; + unsigned short StartLba; + unsigned int SizeFile; + }; + + struct Files32FileGroup final + { + Files32FileHdr* fHdr{ nullptr }; + + Files32FileGroup* fUpper{ nullptr }; + Files32FileGroup* fLower{ nullptr }; + Files32FileGroup* fPrev{ nullptr }; + Files32FileGroup* fNext{ nullptr }; + }; - Files32FileGroup* fUpper{ nullptr }; - Files32FileGroup* fLower{ nullptr }; - Files32FileGroup* fPrev{ nullptr }; - Files32FileGroup* fNext{ nullptr }; -} kRootGroup = nullptr; + /* @brief external inits */ + extern "C" int init_ata_mpt(void); + extern "C" int init_mpt(void); -/* @brief external inits */ -extern "C" int init_ata_mpt(void); -extern "C" int init_mpt(void); + Files32FileGroup* kRootGroup = nullptr; +} namespace mpt { - bool filesystem_init(void) noexcept + bool init_mpt() noexcept { - kRootGroup = detail::new_class(); + detail::kRootGroup = detail::new_class(); - assert(kRootGroup != nullptr); - assert(init_ata_mpt() == detail::okay); - assert(init_mpt() == detail::okay); + assert(detail::kRootGroup != nullptr); + assert(detail::init_ata_mpt() == detail::okay); + assert(detail::init_mpt() == detail::okay); return true; } diff --git a/newBoot/Source/MPT/API.hxx b/newBoot/Source/MPT/API.hxx index 1c5123b1..3ce689e7 100644 --- a/newBoot/Source/MPT/API.hxx +++ b/newBoot/Source/MPT/API.hxx @@ -13,5 +13,5 @@ namespace mpt { /// initializes the Master Partition Table and the Files32 filesystem. /// \return status, assert(fail) is also triggered, use filesystem_hook_error if you want to catch it. - bool filesystem_init(void) noexcept; + bool init_mpt() noexcept; } \ No newline at end of file diff --git a/newBoot/Source/MPT/MPT.hxx b/newBoot/Source/MPT/MPT.hxx index cd97b113..e8bbe7cd 100644 --- a/newBoot/Source/MPT/MPT.hxx +++ b/newBoot/Source/MPT/MPT.hxx @@ -23,7 +23,7 @@ struct MasterPartitionTable final enum { - kPartEfi = 'efi', - kPartEpm = 'epm', - kPartEbr = 'ebr', + kPartEfi = 0x10, + kPartEpm = 0x11, + kPartEbr = 0x12, }; \ No newline at end of file diff --git a/newBoot/Source/Start.cxx b/newBoot/Source/Start.cxx index 0dbe1de0..5f320ac7 100644 --- a/newBoot/Source/Start.cxx +++ b/newBoot/Source/Start.cxx @@ -11,7 +11,7 @@ extern "C" void __AppMain(void) { - BTextWriter writer; + BKTextWriter writer; writer.WriteString("Starting hCore...", kBlack, kWhite, 0, 0); const char* args[] = { "/hCore.bin" }; -- cgit v1.2.3