summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-01-08 18:13:03 +0100
committerAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-01-08 20:40:04 +0100
commitfc78d2f68ab5c9d9d84734fcc1af906c02a984b8 (patch)
tree8253a8439f6d107ebcd51b82783311d17f51a088
parentb06f525d69e6adab8da0a5129bcd39fc592c6922 (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>
-rw-r--r--KernelKit/PEF.hpp4
-rw-r--r--Source/CodeManager.cxx4
-rw-r--r--Source/FileManager.cxx7
-rw-r--r--TODO.txt2
-rw-r--r--newBoot/Source/Arch/AMD64/ATA.cxx18
-rw-r--r--newBoot/Source/Arch/AMD64/BIOSRuntime.cxx2
-rw-r--r--newBoot/Source/Arch/AMD64/BIOSRuntime0.asm4
-rw-r--r--newBoot/Source/Arch/AMD64/Processor.cxx16
-rw-r--r--newBoot/Source/Arch/AMD64/makefile1
-rw-r--r--newBoot/Source/Arch/PowerPC/.gitkeep0
-rw-r--r--newBoot/Source/MPT/API.cxx38
-rw-r--r--newBoot/Source/MPT/API.hxx6
12 files changed, 66 insertions, 36 deletions
diff --git a/KernelKit/PEF.hpp b/KernelKit/PEF.hpp
index 38418286..17dbc491 100644
--- a/KernelKit/PEF.hpp
+++ b/KernelKit/PEF.hpp
@@ -31,8 +31,8 @@ namespace hCore
kPefArchIntel86S,
kPefArchAMD64,
kPefArchRISCV,
- kPefArchARC, /* Advanced RISC architecture. */
- kPefArchPower,
+ kPefArch64x0, /* 64x000. */
+ kPefArchPOWER,
kPefArchInvalid = 0xFF,
};
diff --git a/Source/CodeManager.cxx b/Source/CodeManager.cxx
index 47c7bd1b..4f65de07 100644
--- a/Source/CodeManager.cxx
+++ b/Source/CodeManager.cxx
@@ -23,9 +23,9 @@ namespace hCore
UInt32 rt_get_pef_platform(void)
{
#ifdef __powerpc
- return kPefArchPower;
+ return kPefArchPOWER;
#elif defined(__arc__)
- return kPefArchARC;
+ return kPefArch64x0;
#elif defined(__x86_64__)
return kPefArchAMD64;
#else
diff --git a/Source/FileManager.cxx b/Source/FileManager.cxx
index c7e51811..55b16cbe 100644
--- a/Source/FileManager.cxx
+++ b/Source/FileManager.cxx
@@ -25,10 +25,10 @@ namespace hCore
{
if (kMounted)
{
- auto mount = kMounted;
- kMounted = nullptr;
+ auto mount = kMounted;
+ kMounted = nullptr;
- return mount;
+ return mount;
}
return nullptr;
@@ -39,7 +39,6 @@ namespace hCore
if (pMount)
{
kMounted = pMount;
-
return true;
}
diff --git a/TODO.txt b/TODO.txt
index 04f1a53c..09337b3b 100644
--- a/TODO.txt
+++ b/TODO.txt
@@ -1,4 +1,4 @@
- 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 [ 1/2 ]
+- We need a bootloader for PowerPC [ ]
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