diff options
| author | Amlal El Mahrouss <amlal@el-mahrouss-logic.com> | 2024-03-22 20:24:42 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal@el-mahrouss-logic.com> | 2024-03-22 20:24:42 +0100 |
| commit | 954285b6c9553a047d0789707ad520c84099e74a (patch) | |
| tree | 2057016a60f38d6df7e9ffe3fc836be3a39cdf06 /Private/NewBoot/Source | |
| parent | 5d0bf1cb68c6eb6eb59f1f82fcccfc3e21bf3f9f (diff) | |
EPM: NewBoot: Implement EPM scheme for HCore.
Signed-off-by: Amlal El Mahrouss <amlal@el-mahrouss-logic.com>
Diffstat (limited to 'Private/NewBoot/Source')
| -rw-r--r-- | Private/NewBoot/Source/HEL/AMD64/BootEPM.cxx | 54 | ||||
| -rw-r--r-- | Private/NewBoot/Source/HEL/AMD64/BootMain.cxx | 5 |
2 files changed, 59 insertions, 0 deletions
diff --git a/Private/NewBoot/Source/HEL/AMD64/BootEPM.cxx b/Private/NewBoot/Source/HEL/AMD64/BootEPM.cxx index a4edfa57..6d2998f3 100644 --- a/Private/NewBoot/Source/HEL/AMD64/BootEPM.cxx +++ b/Private/NewBoot/Source/HEL/AMD64/BootEPM.cxx @@ -5,3 +5,57 @@ ------------------------------------------- */ #include <BootKit/BootKit.hxx> + +// {310E1FC7-2060-425D-BE7B-75A37CC679BC} +STATIC const BlockGUID kEPMGuid = { + 0x310e1fc7, + 0x2060, + 0x425d, + {0xbe, 0x7b, 0x75, 0xa3, 0x7c, 0xc6, 0x79, 0xbc}}; + +Void boot_try_write_partition_map(const Char* namePart, SizeT namePartLength, + BDeviceATA* ataInterface) { + if (namePartLength > kEPMNameLength || !namePart) return; + if (!ataInterface) return; + + ataInterface->Leak().mBase = kEPMStartPartition; + ataInterface->Leak().mSize = 512; + + Char buf[512] = {0}; + + ataInterface->Read(buf, 1); + + BTextWriter writer; + + writer.Write(L"NewBoot: Reading EPM boot block..\r\n"); + + for (SizeT i = 0; i < kEPMMagicLength; i++) { + if (buf[i] != kEPMMagic[i]) { + writer.Write(L"NewBoot: Writing EPM boot block..\r\n"); + + BootBlockType* bootBlock = (BootBlockType*)buf; + + bootBlock->Version = kEPMHCore; + bootBlock->NumBlocks = kEPMMaxBlks; + + for (SizeT i = 0; i < kEPMNameLength; i++) { + bootBlock->Magic[i] = kEPMMagic[i]; + } + + for (SizeT i = 0; i < namePartLength; i++) { + bootBlock->Name[i] = namePart[i]; + } + + bootBlock->SectorStart = + sizeof(BootBlockType) + (sizeof(PartitionBlockType) * kEPMMaxBlks); + + bootBlock->SectorSz = kATASectorSize; + + bootBlock->Uuid = kEPMGuid; + + ataInterface->Write(buf, 1); + + return; + } + } +}
\ 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 a3f82275..b4e7b56d 100644 --- a/Private/NewBoot/Source/HEL/AMD64/BootMain.cxx +++ b/Private/NewBoot/Source/HEL/AMD64/BootMain.cxx @@ -27,6 +27,11 @@ EFI_EXTERN_C EFI_API Int EfiMain(EfiHandlePtr ImageHandle, InitGOP(); // Quick Toolkit for UI BTextWriter writer; + BDeviceATA ataDrv; + + Char namePart[kEPMNameLength] = { "NewKernel Standard System" }; + + boot_try_write_partition_map(namePart, kEPMNameLength, &ataDrv); /// Splash screen stuff |
