diff options
| author | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-01-08 18:13:03 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-01-08 20:40:04 +0100 |
| commit | fc78d2f68ab5c9d9d84734fcc1af906c02a984b8 (patch) | |
| tree | 8253a8439f6d107ebcd51b82783311d17f51a088 /newBoot | |
| parent | b06f525d69e6adab8da0a5129bcd39fc592c6922 (diff) | |
boot\mpt: add init_ata_mpt, and some specific things about the MPT.
other: add ppc directory for newBoot support.
rev A: make it prettier.
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'newBoot')
| -rw-r--r-- | newBoot/Source/Arch/AMD64/ATA.cxx | 18 | ||||
| -rw-r--r-- | newBoot/Source/Arch/AMD64/BIOSRuntime.cxx | 2 | ||||
| -rw-r--r-- | newBoot/Source/Arch/AMD64/BIOSRuntime0.asm | 4 | ||||
| -rw-r--r-- | newBoot/Source/Arch/AMD64/Processor.cxx | 16 | ||||
| -rw-r--r-- | newBoot/Source/Arch/AMD64/makefile | 1 | ||||
| -rw-r--r-- | newBoot/Source/Arch/PowerPC/.gitkeep | 0 | ||||
| -rw-r--r-- | newBoot/Source/MPT/API.cxx | 38 | ||||
| -rw-r--r-- | newBoot/Source/MPT/API.hxx | 6 |
8 files changed, 58 insertions, 27 deletions
diff --git a/newBoot/Source/Arch/AMD64/ATA.cxx b/newBoot/Source/Arch/AMD64/ATA.cxx index 5ddf3efa..ce905639 100644 --- a/newBoot/Source/Arch/AMD64/ATA.cxx +++ b/newBoot/Source/Arch/AMD64/ATA.cxx @@ -157,10 +157,16 @@ extern "C" UInt32 in32(UInt16 port) return value; } -extern "C" void rt_halt() { asm volatile("hlt"); } - -extern "C" void rt_cli() { asm volatile("cli"); } - -extern "C" void rt_sti() { asm volatile("sti"); } +extern "C" int init_ata_mpt(void) +{ + for (int i = 0; i < 255; ++i) + { + if (ATAInitDriver(i, ATA_MASTER)) + { + ATAInitDriver(i, ATA_SLAVE); + return 1; + } + } -extern "C" void rt_cld() { asm volatile("cld"); }
\ No newline at end of file + return 0; +}
\ No newline at end of file diff --git a/newBoot/Source/Arch/AMD64/BIOSRuntime.cxx b/newBoot/Source/Arch/AMD64/BIOSRuntime.cxx index b8a95560..611a48c4 100644 --- a/newBoot/Source/Arch/AMD64/BIOSRuntime.cxx +++ b/newBoot/Source/Arch/AMD64/BIOSRuntime.cxx @@ -5,4 +5,4 @@ #include <BootKit/Boot.hpp> #include "ATA.hxx" -extern "C" char __STACK[4096] = { 0 }; +extern "C" char __runtime_stack[4096] = { 0 }; diff --git a/newBoot/Source/Arch/AMD64/BIOSRuntime0.asm b/newBoot/Source/Arch/AMD64/BIOSRuntime0.asm index 5b5a6338..3a690d99 100644 --- a/newBoot/Source/Arch/AMD64/BIOSRuntime0.asm +++ b/newBoot/Source/Arch/AMD64/BIOSRuntime0.asm @@ -1,6 +1,6 @@ ;; Copyright Mahrouss Logic, all rights reserved -extern __STACK +extern __runtime_stack global NBRuntimeZero bits 16 @@ -36,7 +36,7 @@ NBProtectedMode: mov gs, ax mov ss, ax - mov esp, __STACK + mov esp, __runtime_stack jmp 0x8000000 NBLoopOne: diff --git a/newBoot/Source/Arch/AMD64/Processor.cxx b/newBoot/Source/Arch/AMD64/Processor.cxx new file mode 100644 index 00000000..65cf85cb --- /dev/null +++ b/newBoot/Source/Arch/AMD64/Processor.cxx @@ -0,0 +1,16 @@ +/* +* ======================================================== +* +* newBoot +* Copyright Mahrouss Logic, all rights reserved. +* +* ======================================================== +*/ + +extern "C" void rt_halt(void) { asm volatile("hlt"); } + +extern "C" void rt_cli(void) { asm volatile("cli"); } + +extern "C" void rt_sti(void) { asm volatile("sti"); } + +extern "C" void rt_cld(void) { asm volatile("cld"); } diff --git a/newBoot/Source/Arch/AMD64/makefile b/newBoot/Source/Arch/AMD64/makefile index fb4b0910..21860551 100644 --- a/newBoot/Source/Arch/AMD64/makefile +++ b/newBoot/Source/Arch/AMD64/makefile @@ -22,6 +22,7 @@ CCFLAGS = -c -ffreestanding -fno-rtti -fno-exceptions -std=c++20 -D__HAVE_HCORE build-crt0-bios: $(CC) $(CCFLAGS) BIOSRuntime.cxx $(CC) $(CCFLAGS) ATA.cxx + $(CC) $(CCFLAGS) Processor.cxx $(ASM) $(ASMFLAGS) BIOSRuntime0.asm $(LD) --oformat $(FMT) ATA.o -o $(ATAMOD) diff --git a/newBoot/Source/Arch/PowerPC/.gitkeep b/newBoot/Source/Arch/PowerPC/.gitkeep new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/newBoot/Source/Arch/PowerPC/.gitkeep diff --git a/newBoot/Source/MPT/API.cxx b/newBoot/Source/MPT/API.cxx index 2cedd73e..b76ac645 100644 --- a/newBoot/Source/MPT/API.cxx +++ b/newBoot/Source/MPT/API.cxx @@ -9,7 +9,7 @@ #include "API.hxx" -struct Files32FileHdr +struct Files32FileHdr final { char Filename[32]; char Ext[3]; @@ -35,7 +35,8 @@ struct Files32FileHdr // @brief Array of unused bits. #define kFilesU { 0x40, 0x80 } -struct Files32FileGroup { +struct Files32FileGroup final +{ Files32FileHdr* fHdr{ nullptr }; Files32FileGroup* fUpper{ nullptr }; @@ -49,23 +50,30 @@ extern "C" void* AllocPtr(long sz); namespace detail { -template <typename Cls> -Cls* new_class() -{ - Cls* cls = (Cls*)AllocPtr(sizeof(Cls)); - *cls = Cls(); + template <typename Cls> + Cls* new_class() + { + Cls* cls = (Cls*)AllocPtr(sizeof(Cls)); + *cls = Cls(); - return cls; -} + return cls; + } } +/* @brief external inits */ +extern "C" int init_ata_mpt(void); +extern "C" int init_mpt(void); + namespace mpt { -bool filesystem_init(void) -{ - kRootGroup = detail::new_class<Files32FileGroup>(); - Assert(kRootGroup != nullptr); + bool filesystem_init(void) noexcept + { + kRootGroup = detail::new_class<Files32FileGroup>(); + Assert(kRootGroup != nullptr); - return true; -} + Assert(init_ata_mpt() == 1); + Assert(init_mpt() == 1); + + return true; + } }
\ No newline at end of file diff --git a/newBoot/Source/MPT/API.hxx b/newBoot/Source/MPT/API.hxx index 42822371..1439c128 100644 --- a/newBoot/Source/MPT/API.hxx +++ b/newBoot/Source/MPT/API.hxx @@ -11,7 +11,7 @@ namespace mpt { -/// initializes the Master Partition Table Files32 filesystem. -/// \return status, assert(fail) is also triggered, use filesystem_hook_error if you want to catch it. -bool filesystem_init(void); + /// 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; }
\ No newline at end of file |
