diff options
| author | Amlal El Mahrouss <amlal@el-mahrouss-logic.com> | 2024-03-30 06:28:37 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal@el-mahrouss-logic.com> | 2024-03-30 06:28:37 +0100 |
| commit | d9b859eb709aca21577a777995c9a9127c9b329c (patch) | |
| tree | 51e827b7e5b2835e20ce6cb2dd49de01ea3fa05a | |
| parent | 596f3d07aa58751d186dadd4f4fb392327e66254 (diff) | |
Bootloader: See below.
What has been done:
- Rename BDevice* to BootDevice* class.
- Refactor partition write functions.
What needs to be done:
- Schedule processes on cores.
- NewFS support on kernel.
- AHCI support.
- PowerPC support.
Signed-off-by: Amlal El Mahrouss <amlal@el-mahrouss-logic.com>
| -rw-r--r-- | Private/NewBoot/BootKit/Arch/ATA.hxx | 12 | ||||
| -rw-r--r-- | Private/NewBoot/BootKit/Arch/SATA.hxx | 12 | ||||
| -rw-r--r-- | Private/NewBoot/BootKit/BootKit.hxx | 2 | ||||
| -rw-r--r-- | Private/NewBoot/Source/HEL/AMD64/BootATA.cxx | 14 | ||||
| -rw-r--r-- | Private/NewBoot/Source/HEL/AMD64/BootCustomPart.cxx | 12 | ||||
| -rw-r--r-- | Private/NewBoot/Source/HEL/AMD64/BootEPM.cxx | 11 | ||||
| -rw-r--r-- | Private/NewBoot/Source/HEL/AMD64/BootMain.cxx | 4 |
7 files changed, 37 insertions, 30 deletions
diff --git a/Private/NewBoot/BootKit/Arch/ATA.hxx b/Private/NewBoot/BootKit/Arch/ATA.hxx index 4defc0aa..5501f947 100644 --- a/Private/NewBoot/BootKit/Arch/ATA.hxx +++ b/Private/NewBoot/BootKit/Arch/ATA.hxx @@ -10,17 +10,17 @@ using namespace NewOS; -class BDeviceATA final { +class BootDeviceATA final { public: enum { kPrimary = ATA_PRIMARY_IO, kSecondary = ATA_SECONDARY_IO, }; - explicit BDeviceATA() noexcept; - ~BDeviceATA() = default; + explicit BootDeviceATA() noexcept; + ~BootDeviceATA() = default; - HCORE_COPY_DEFAULT(BDeviceATA); + HCORE_COPY_DEFAULT(BootDeviceATA); struct ATATrait final { SizeT mBase{1024}; @@ -34,8 +34,8 @@ class BDeviceATA final { operator bool(); - BDeviceATA& Read(Char* Buf, const SizeT& SecCount); - BDeviceATA& Write(Char* Buf, const SizeT& SecCount); + BootDeviceATA& Read(Char* Buf, const SizeT& SecCount); + BootDeviceATA& Write(Char* Buf, const SizeT& SecCount); ATATrait& Leak(); diff --git a/Private/NewBoot/BootKit/Arch/SATA.hxx b/Private/NewBoot/BootKit/Arch/SATA.hxx index 8bd8f2cb..cbaeb404 100644 --- a/Private/NewBoot/BootKit/Arch/SATA.hxx +++ b/Private/NewBoot/BootKit/Arch/SATA.hxx @@ -9,12 +9,12 @@ #include <CompilerKit/CompilerKit.hxx> #include <Builtins/AHCI/Defines.hxx> -class BDeviceSATA final { +class BootDeviceSATA final { public: - explicit BDeviceSATA() noexcept; - ~BDeviceSATA() = default; + explicit BootDeviceSATA() noexcept; + ~BootDeviceSATA() = default; - HCORE_COPY_DEFAULT(BDeviceSATA); + HCORE_COPY_DEFAULT(BootDeviceSATA); struct SATATrait final { NewOS::SizeT mBase{1024}; @@ -26,8 +26,8 @@ class BDeviceSATA final { operator bool() { return this->Leak().mDetected; } - BDeviceSATA& Read(NewOS::WideChar* Buf, const NewOS::SizeT& SecCount); - BDeviceSATA& Write(NewOS::WideChar* Buf, const NewOS::SizeT& SecCount); + BootDeviceSATA& Read(NewOS::WideChar* Buf, const NewOS::SizeT& SecCount); + BootDeviceSATA& Write(NewOS::WideChar* Buf, const NewOS::SizeT& SecCount); SATATrait& Leak(); diff --git a/Private/NewBoot/BootKit/BootKit.hxx b/Private/NewBoot/BootKit/BootKit.hxx index a0e8309c..be46f64c 100644 --- a/Private/NewBoot/BootKit/BootKit.hxx +++ b/Private/NewBoot/BootKit/BootKit.hxx @@ -205,4 +205,4 @@ class BVersionString final { static const CharacterTypeUTF16 *Shared() { return BOOTLOADER_VERSION; } }; -EXTERN_C Boolean boot_write_newfs_partition(const Char* namePart, SizeT namePartLength, BDeviceATA* ataInterface); +EXTERN_C Boolean boot_write_epm_partition(const Char* namePart, SizeT namePartLength, BootDeviceATA* ataInterface); diff --git a/Private/NewBoot/Source/HEL/AMD64/BootATA.cxx b/Private/NewBoot/Source/HEL/AMD64/BootATA.cxx index 50bab4b7..5b966813 100644 --- a/Private/NewBoot/Source/HEL/AMD64/BootATA.cxx +++ b/Private/NewBoot/Source/HEL/AMD64/BootATA.cxx @@ -93,7 +93,7 @@ ATAInit_Retry: } OutBus = - (Bus == ATA_PRIMARY_IO) ? BDeviceATA::kPrimary : BDeviceATA::kSecondary; + (Bus == ATA_PRIMARY_IO) ? BootDeviceATA::kPrimary : BootDeviceATA::kSecondary; OutMaster = (Bus == ATA_PRIMARY_IO) ? ATA_MASTER : ATA_SLAVE; Out8(Bus + ATA_REG_HDDEVSEL, 0xA0 | ATA_MASTER << 4); @@ -200,7 +200,7 @@ Boolean boot_ata_detected(Void) { return kATADetected; } * @brief ATA Device constructor. * @param void none. */ -BDeviceATA::BDeviceATA() noexcept { +BootDeviceATA::BootDeviceATA() noexcept { if (boot_ata_detected()) return; if (boot_ata_init(ATA_PRIMARY_IO, true, this->Leak().mBus, @@ -217,14 +217,14 @@ BDeviceATA::BDeviceATA() noexcept { /** * @brief Is ATA detected? */ -BDeviceATA::operator bool() { return boot_ata_detected(); } +BootDeviceATA::operator bool() { return boot_ata_detected(); } /** @brief Read Buf from disk @param Sz Sector size @param Buf buffer */ -BDeviceATA& BDeviceATA::Read(CharacterTypeUTF8* Buf, const SizeT& SectorSz) { +BootDeviceATA& BootDeviceATA::Read(CharacterTypeUTF8* Buf, const SizeT& SectorSz) { if (!boot_ata_detected()) { Leak().mErr = true; return *this; @@ -245,7 +245,7 @@ BDeviceATA& BDeviceATA::Read(CharacterTypeUTF8* Buf, const SizeT& SectorSz) { @param Sz Sector size @param Buf buffer */ -BDeviceATA& BDeviceATA::Write(CharacterTypeUTF8* Buf, const SizeT& SectorSz) { +BootDeviceATA& BootDeviceATA::Write(CharacterTypeUTF8* Buf, const SizeT& SectorSz) { if (!boot_ata_detected()) { Leak().mErr = true; return *this; @@ -263,6 +263,6 @@ BDeviceATA& BDeviceATA::Write(CharacterTypeUTF8* Buf, const SizeT& SectorSz) { /** * @brief ATA trait getter. - * @return BDeviceATA::ATATrait& the drive config. + * @return BootDeviceATA::ATATrait& the drive config. */ -BDeviceATA::ATATrait& BDeviceATA::Leak() { return mTrait; } +BootDeviceATA::ATATrait& BootDeviceATA::Leak() { return mTrait; } diff --git a/Private/NewBoot/Source/HEL/AMD64/BootCustomPart.cxx b/Private/NewBoot/Source/HEL/AMD64/BootCustomPart.cxx index 2e811f5f..29fd596d 100644 --- a/Private/NewBoot/Source/HEL/AMD64/BootCustomPart.cxx +++ b/Private/NewBoot/Source/HEL/AMD64/BootCustomPart.cxx @@ -8,13 +8,15 @@ #include <FSKit/NewFS.hxx> /// @brief Writes a NewOS partition on top of EPM -/// @param ataInterface The drive interface. +/// @param ataInterface The ATA interface. /// @return -EXTERN_C Void boot_write_newos_specific_partition(BDeviceATA* ataInterface) { +EXTERN_C Boolean boot_write_newos_partition(BootDeviceATA* ataInterface) { + if (!ataInterface) return No; + ataInterface->Leak().mBase = 0; - ataInterface->Leak().mSize = 512; + ataInterface->Leak().mSize = kATASectorSize; - Char newOSHeader[512] = { + Char newOSHeader[kATASectorSize] = { /// signature of our system partition. 'N', 'e', 'w', '!', /// version of our os partition @@ -35,4 +37,6 @@ EXTERN_C Void boot_write_newos_specific_partition(BDeviceATA* ataInterface) { }; ataInterface->Write(newOSHeader, 1); + + return Yes; }
\ No newline at end of file diff --git a/Private/NewBoot/Source/HEL/AMD64/BootEPM.cxx b/Private/NewBoot/Source/HEL/AMD64/BootEPM.cxx index e9bf7574..244736c7 100644 --- a/Private/NewBoot/Source/HEL/AMD64/BootEPM.cxx +++ b/Private/NewBoot/Source/HEL/AMD64/BootEPM.cxx @@ -16,10 +16,13 @@ STATIC const BlockGUID kEPMGuid = { 0x425d, {0xbe, 0x7b, 0x75, 0xa3, 0x7c, 0xc6, 0x79, 0xbc}}; -EXTERN_C Void boot_write_newos_specific_partition(BDeviceATA*); +/// @brief External reference, write a NewOS Reserved Partition. +/// @param ataInterface ATA interface +/// @return +EXTERN_C Boolean boot_write_newos_partition(BootDeviceATA* ataInterface); -EXTERN_C Boolean boot_write_newfs_partition(const Char* namePart, SizeT namePartLength, - BDeviceATA* ataInterface) { +EXTERN_C Boolean boot_write_epm_partition(const Char* namePart, SizeT namePartLength, + BootDeviceATA* ataInterface) { if (namePartLength > kEPMNameLength || !namePart) return No; if (!ataInterface) return No; @@ -105,7 +108,7 @@ EXTERN_C Boolean boot_write_newfs_partition(const Char* namePart, SizeT namePart ataInterface->Write(buf, 1); - boot_write_newos_specific_partition(ataInterface); + boot_write_newos_partition(ataInterface); return No; } diff --git a/Private/NewBoot/Source/HEL/AMD64/BootMain.cxx b/Private/NewBoot/Source/HEL/AMD64/BootMain.cxx index e9c900ba..88ad1e32 100644 --- a/Private/NewBoot/Source/HEL/AMD64/BootMain.cxx +++ b/Private/NewBoot/Source/HEL/AMD64/BootMain.cxx @@ -41,7 +41,7 @@ EFI_EXTERN_C EFI_API Int EfiMain(EfiHandlePtr ImageHandle, .Write(SystemTable->FirmwareVendor) .Write(L"\r\n"); - BDeviceATA ataDrv; + BootDeviceATA ataDrv; Boolean isIniNotFound = No; /// if ATA drive is initialized and EFI vendor supports an EPM scheme. @@ -52,7 +52,7 @@ EFI_EXTERN_C EFI_API Int EfiMain(EfiHandlePtr ImageHandle, /// tries to read an EPM block, or writes one if it fails. bool isIniNotFound = - boot_write_newfs_partition(namePart, kEPMNameLength, &ataDrv); + boot_write_epm_partition(namePart, kEPMNameLength, &ataDrv); } else if (SystemTable->FirmwareVendor[0] != '@') { writer.Write(L"This firmware can't understand NewOS, please use Mahrouss Logic products instead\r\nOur website: www.el-mahrouss-logic.com\r\n"); return kEfiFail; |
