diff options
| author | amlal <amlal@el-mahrouss-logic.com> | 2024-03-26 05:52:57 +0100 |
|---|---|---|
| committer | amlal <amlal@el-mahrouss-logic.com> | 2024-03-26 05:58:34 +0100 |
| commit | dbe4573f61ae059c9dafb8e7623370121d443451 (patch) | |
| tree | 31b8172c9850cfe4ba467282aabc7f1941c2ea4c | |
| parent | 0d6df50e386dae373c654522d241330a8a42412b (diff) | |
NewBoot: See below.
- Do not run kernel directly on bootloader now.
- Throw an error if no partition is found.
Signed-off-by: amlal <amlal@el-mahrouss-logic.com>
| -rw-r--r-- | Private/NewBoot/BootKit/BootKit.hxx | 2 | ||||
| -rw-r--r-- | Private/NewBoot/Source/HEL/AMD64/BootEPM.cxx | 17 | ||||
| -rw-r--r-- | Private/NewBoot/Source/HEL/AMD64/BootMain.cxx | 72 |
3 files changed, 38 insertions, 53 deletions
diff --git a/Private/NewBoot/BootKit/BootKit.hxx b/Private/NewBoot/BootKit/BootKit.hxx index dbdbb072..75934ed2 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; } }; -Void boot_write_newfs_partition(const Char* namePart, SizeT namePartLength, BDeviceATA* ataInterface); +EXTERN_C Boolean boot_write_newfs_partition(const Char* namePart, SizeT namePartLength, BDeviceATA* ataInterface); diff --git a/Private/NewBoot/Source/HEL/AMD64/BootEPM.cxx b/Private/NewBoot/Source/HEL/AMD64/BootEPM.cxx index d59adc48..871f35a3 100644 --- a/Private/NewBoot/Source/HEL/AMD64/BootEPM.cxx +++ b/Private/NewBoot/Source/HEL/AMD64/BootEPM.cxx @@ -14,13 +14,13 @@ STATIC const BlockGUID kEPMGuid = { 0x425d, {0xbe, 0x7b, 0x75, 0xa3, 0x7c, 0xc6, 0x79, 0xbc}}; -Void boot_write_newfs_partition(const Char* namePart, SizeT namePartLength, +EXTERN_C Boolean boot_write_newfs_partition(const Char* namePart, SizeT namePartLength, BDeviceATA* ataInterface) { - if (namePartLength > kEPMNameLength || !namePart) return; - if (!ataInterface) return; + if (namePartLength > kEPMNameLength || !namePart) return No; + if (!ataInterface) return No; ataInterface->Leak().mBase = 0; - ataInterface->Leak().mSize = 512; + ataInterface->Leak().mSize = kATASectorSize; Char buf[512] = {0}; @@ -28,11 +28,11 @@ Void boot_write_newfs_partition(const Char* namePart, SizeT namePartLength, BTextWriter writer; - writer.Write(L"NewBoot.exe: Checking for an EPM BootBlock...\r\n"); + writer.Write(L"NewBoot.exe: Checking for a NewFS partition...\r\n"); for (SizeT i = 0; i < kEPMMagicLength; i++) { if (buf[i] != kEPMMagic[i]) { - writer.Write(L"NewBoot.exe: Writing an EPM BootBlock...\r\n"); + writer.Write(L"NewBoot.exe: Writing a NewFS partition...\r\n"); BootBlockType* bootBlock = (BootBlockType*)buf; @@ -101,7 +101,10 @@ Void boot_write_newfs_partition(const Char* namePart, SizeT namePartLength, ataInterface->Write(buf, 1); - return; + return No; } } + + writer.Write(L"NewBoot.exe: Partition found, everything is OK.\r\n"); + return Yes; }
\ No newline at end of file diff --git a/Private/NewBoot/Source/HEL/AMD64/BootMain.cxx b/Private/NewBoot/Source/HEL/AMD64/BootMain.cxx index 3766e23f..33491867 100644 --- a/Private/NewBoot/Source/HEL/AMD64/BootMain.cxx +++ b/Private/NewBoot/Source/HEL/AMD64/BootMain.cxx @@ -17,22 +17,18 @@ #define kMaxBufSize 256 -/// @brief kernel main entrypoint/ -/// @param handoverInfo -EXTERN_C void Main(HEL::HandoverInformationHeader* handoverInfo); - /// @brief Bootloader main type. typedef void (*bt_main_type)(HEL::HandoverInformationHeader* handoverInfo); /// @brief Main EFI entrypoint. /// @param ImageHandle Handle of this image. /// @param SystemTable The system table of it. -/// @return +/// @return EFI_EXTERN_C EFI_API Int EfiMain(EfiHandlePtr ImageHandle, EfiSystemTable* SystemTable) { InitEFI(SystemTable); // Init the EFI library. InitGOP(); // Init the GOP. - + BTextWriter writer; /// Splash screen stuff @@ -44,12 +40,14 @@ EFI_EXTERN_C EFI_API Int EfiMain(EfiHandlePtr ImageHandle, .Write(L"\r\n"); BDeviceATA ataDrv; + Boolean isIniNotFound = No; if (ataDrv) { - Char namePart[kEPMNameLength] = { "BootBlock" }; + Char namePart[kEPMNameLength] = {"BootBlock"}; /// tries to read an EPM block, or writes one if it fails. - boot_write_newfs_partition(namePart, kEPMNameLength, &ataDrv); + bool isIniNotFound = + boot_write_newfs_partition(namePart, kEPMNameLength, &ataDrv); } /// Read Kernel blob. @@ -60,13 +58,6 @@ EFI_EXTERN_C EFI_API Int EfiMain(EfiHandlePtr ImageHandle, kernelImg.ReadAll(); if (kernelImg.Error() == BFileReader::kOperationOkay) { - // First check for a .MANIFEST inside the ESP. - // This will tell us about the current kernel. - BFileReader systemManifest(L".MANIFEST", ImageHandle); - - systemManifest.Size(kMaxBufSize); - systemManifest.ReadAll(); - UInt32 MapKey = 0; UInt32* Size; EfiMemoryDescriptor* Descriptor; @@ -133,48 +124,39 @@ EFI_EXTERN_C EFI_API Int EfiMain(EfiHandlePtr ImageHandle, BCopyMem(handoverHdrPtr->f_FirmwareVendorName, SystemTable->FirmwareVendor, handoverHdrPtr->f_FirmwareVendorLen); +#ifdef __DEBUG__ writer.Write(L"NewBoot.exe: Fetching ACPI's 'RSD PTR'...").Write(L"\r\n"); +#endif - for (SizeT indexVT = 0; indexVT < SystemTable->NumberOfTableEntries; ++indexVT) - { - volatile Char* vendorTable = reinterpret_cast<volatile Char*>(SystemTable->ConfigurationTable[indexVT].VendorTable); - - if (vendorTable[0] == 'R' && - vendorTable[1] == 'S' && - vendorTable[2] == 'D' && - vendorTable[3] == ' ' && - vendorTable[4] == 'P' && - vendorTable[5] == 'T' && - vendorTable[6] == 'R' && - vendorTable[7] == ' ') { + for (SizeT indexVT = 0; indexVT < SystemTable->NumberOfTableEntries; + ++indexVT) { + volatile Char* vendorTable = reinterpret_cast<volatile Char*>( + SystemTable->ConfigurationTable[indexVT].VendorTable); + + if (vendorTable[0] == 'R' && vendorTable[1] == 'S' && + vendorTable[2] == 'D' && vendorTable[3] == ' ' && + vendorTable[4] == 'P' && vendorTable[5] == 'T' && + vendorTable[6] == 'R' && vendorTable[7] == ' ') { handoverHdrPtr->f_HardwareTables.f_RsdPtr = (VoidPtr)vendorTable; - writer.Write(L"NewBoot.exe: Found ACPI's 'RSD PTR' table on this machine.").Write(L"\r\n"); + +#ifdef __DEBUG__ + writer + .Write( + L"NewBoot.exe: Found ACPI's 'RSD PTR' table on this machine.") + .Write(L"\r\n"); +#endif break; } } - /// TODO: Set this to what we found inside NewFS partition. - bool isIniNotFound = true; - - if (isIniNotFound) { - handoverHdrPtr->f_Magic = kHandoverMagic; - handoverHdrPtr->f_Version = kHandoverVersion; - - writer.Write(L"NewBoot.exe: Setting up OS...\r\n"); - - ST->ConOut->ClearScreen(ST->ConOut); - - EFI::ExitBootServices(MapKey, ImageHandle); - - Main(handoverHdrPtr); + if (!isIniNotFound) { + writer.Write(L"NewBoot.exe: No partition found for s10. (HCR-1000)\r\n"); } else { handoverHdrPtr->f_Magic = kHandoverMagic; handoverHdrPtr->f_Version = kHandoverVersion; - writer.Write(L"NewBoot.exe: Running OS...\r\n"); - - ST->ConOut->ClearScreen(ST->ConOut); + writer.Write(L"NewBoot.exe: Running s10...\r\n"); EFI::ExitBootServices(MapKey, ImageHandle); |
