summaryrefslogtreecommitdiffhomepage
path: root/Private/NewBoot/Source
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@el-mahrouss-logic.com>2024-03-26 05:37:44 +0100
committerAmlal El Mahrouss <amlal@el-mahrouss-logic.com>2024-03-26 05:37:44 +0100
commit0d6df50e386dae373c654522d241330a8a42412b (patch)
tree004fba8b1bd513154cb925450c76ae1e011b86f8 /Private/NewBoot/Source
parent1cd930c0c72f215101300dfcc5860800a474362d (diff)
NewBoot: Fully Implemented an EPM drive, needs now to write the layout
found inside Private/Rooot inside the epm.img, so that the user can install it. 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.cxx50
-rw-r--r--Private/NewBoot/Source/HEL/AMD64/BootMain.cxx2
2 files changed, 49 insertions, 3 deletions
diff --git a/Private/NewBoot/Source/HEL/AMD64/BootEPM.cxx b/Private/NewBoot/Source/HEL/AMD64/BootEPM.cxx
index da28a3f3..d59adc48 100644
--- a/Private/NewBoot/Source/HEL/AMD64/BootEPM.cxx
+++ b/Private/NewBoot/Source/HEL/AMD64/BootEPM.cxx
@@ -5,6 +5,7 @@
------------------------------------------- */
#include <BootKit/BootKit.hxx>
+#include <FSKit/NewFS.hxx>
// {310E1FC7-2060-425D-BE7B-75A37CC679BC}
STATIC const BlockGUID kEPMGuid = {
@@ -13,8 +14,8 @@ STATIC const BlockGUID kEPMGuid = {
0x425d,
{0xbe, 0x7b, 0x75, 0xa3, 0x7c, 0xc6, 0x79, 0xbc}};
-Void boot_try_read_partition_map(const Char* namePart, SizeT namePartLength,
- BDeviceATA* ataInterface) {
+Void boot_write_newfs_partition(const Char* namePart, SizeT namePartLength,
+ BDeviceATA* ataInterface) {
if (namePartLength > kEPMNameLength || !namePart) return;
if (!ataInterface) return;
@@ -53,6 +54,51 @@ Void boot_try_read_partition_map(const Char* namePart, SizeT namePartLength,
bootBlock->Uuid = kEPMGuid;
+ PartitionBlock* partBlock = (PartitionBlock*)(buf + sizeof(BootBlock));
+
+ char* fsName = "NewFS";
+ int fsNameLength = 6;
+
+ for (SizeT i = 0; i < fsNameLength; i++) {
+ partBlock->Fs[i] = fsName[i];
+ }
+
+ partBlock->Magic = kEPMHCore;
+
+ char* partName = "System HD";
+ int partNameLength = 10;
+
+ for (SizeT i = 0; i < partNameLength; i++) {
+ partBlock->Name[i] = partName[i];
+ }
+
+ partBlock->SectorSz = kATASectorSize;
+ partBlock->SectorStart = kEPMStartPartition + MIB(4);
+ partBlock->Version = kNewFSVersionInteger;
+ partBlock->Type = kNewFSPartitionTypeStandard;
+ partBlock->SectorEnd = 0; /// grows on the disk.
+
+ PartitionBlock* swapBlock = (PartitionBlock*)(buf + sizeof(BootBlock) + sizeof(PartitionBlock));
+
+ for (SizeT i = 0; i < fsNameLength; i++) {
+ swapBlock->Fs[i] = fsName[i];
+ }
+
+ swapBlock->Magic = kEPMHCore;
+
+ partName = "Swap HD";
+ partNameLength = 8;
+
+ for (SizeT i = 0; i < partNameLength; i++) {
+ swapBlock->Name[i] = partName[i];
+ }
+
+ swapBlock->SectorSz = kATASectorSize;
+ swapBlock->SectorStart = kEPMStartPartition;
+ swapBlock->Version = kNewFSVersionInteger;
+ swapBlock->Type = kNewFSPartitionTypeBoot;
+ swapBlock->SectorEnd = MIB(4); /// 4 MIB swap partition.
+
ataInterface->Write(buf, 1);
return;
diff --git a/Private/NewBoot/Source/HEL/AMD64/BootMain.cxx b/Private/NewBoot/Source/HEL/AMD64/BootMain.cxx
index 21481f85..3766e23f 100644
--- a/Private/NewBoot/Source/HEL/AMD64/BootMain.cxx
+++ b/Private/NewBoot/Source/HEL/AMD64/BootMain.cxx
@@ -49,7 +49,7 @@ EFI_EXTERN_C EFI_API Int EfiMain(EfiHandlePtr ImageHandle,
Char namePart[kEPMNameLength] = { "BootBlock" };
/// tries to read an EPM block, or writes one if it fails.
- boot_try_read_partition_map(namePart, kEPMNameLength, &ataDrv);
+ boot_write_newfs_partition(namePart, kEPMNameLength, &ataDrv);
}
/// Read Kernel blob.