summaryrefslogtreecommitdiffhomepage
path: root/dev/ZBA/Sources
diff options
context:
space:
mode:
authorAmlal <amlalelmahrouss@icloud.com>2024-09-05 19:13:02 +0000
committerAmlal <amlalelmahrouss@icloud.com>2024-09-05 19:13:02 +0000
commit621e814da6d5005ade8a1fe3f378a363db559cf7 (patch)
tree438f1337c0eb2ae83cf3d409c29848d396be08b2 /dev/ZBA/Sources
parentcc9ce57cac59bd443e2319e3b8f427172b93f7da (diff)
parent3b60a1e87ab02a1b72d8bb9f7392780899d5a0d7 (diff)
Merged in major-refactor (pull request #19)
Major refactor
Diffstat (limited to 'dev/ZBA/Sources')
-rw-r--r--dev/ZBA/Sources/HEL/AMD64/BootAPI.S (renamed from dev/ZBA/Sources/HEL/AMD64/BootJump.S)6
-rw-r--r--dev/ZBA/Sources/HEL/AMD64/BootMain.cxx93
-rw-r--r--dev/ZBA/Sources/HEL/AMD64/BootTextWriter.cxx9
-rw-r--r--dev/ZBA/Sources/Thread.cxx2
4 files changed, 60 insertions, 50 deletions
diff --git a/dev/ZBA/Sources/HEL/AMD64/BootJump.S b/dev/ZBA/Sources/HEL/AMD64/BootAPI.S
index d8e09d4e..e391351d 100644
--- a/dev/ZBA/Sources/HEL/AMD64/BootJump.S
+++ b/dev/ZBA/Sources/HEL/AMD64/BootAPI.S
@@ -39,3 +39,9 @@ wait_gate2:
mov cr4,rax
reset_wait:
jmp reset_wait
+
+.global write_cr3
+
+write_cr3:
+ mov cr3, rcx
+ ret \ No newline at end of file
diff --git a/dev/ZBA/Sources/HEL/AMD64/BootMain.cxx b/dev/ZBA/Sources/HEL/AMD64/BootMain.cxx
index 576ada08..9cccc922 100644
--- a/dev/ZBA/Sources/HEL/AMD64/BootMain.cxx
+++ b/dev/ZBA/Sources/HEL/AMD64/BootMain.cxx
@@ -79,6 +79,8 @@ STATIC Bool CheckBootDevice(BootDeviceATA& ataDev)
return true;
}
+EXTERN_C Void write_cr3(VoidPtr new_cr3);
+
/// @brief Main EFI entrypoint.
/// @param ImageHandle Handle of this image.
/// @param SystemTable The system table of it.
@@ -152,6 +154,27 @@ EFI_EXTERN_C EFI_API Int Main(EfiHandlePtr ImageHandle,
handoverHdrPtr->f_HardwareTables.f_MultiProcessingEnabled = cnt_enabled > 1;
// Fill handover header now.
+ BDiskFormatFactory<BootDeviceATA> checkPart;
+
+ // ---------------------------------------------------- //
+ // The following checks for an exisiting partition
+ // inside the disk, if it doesn't have one,
+ // format the disk.
+ // ---------------------------------------------------- //
+
+ if (!checkPart.IsPartitionValid())
+ {
+ BDiskFormatFactory<BootDeviceATA>::BFileDescriptor root;
+ root.fFileName[0] = kNeFSRoot[0];
+ root.fFileName[1] = 0;
+
+ root.fKind = kNeFSCatalogKindDir;
+
+ checkPart.Format("ZKA (A:)", &root, 1);
+
+ rt_reset_hardware();
+ }
+
BS->GetMemoryMap(&SizePtr, Descriptor, &MapKey, &SzDesc, &RevDesc);
Descriptor = new EfiMemoryDescriptor[SzDesc];
@@ -186,52 +209,14 @@ EFI_EXTERN_C EFI_API Int Main(EfiHandlePtr ImageHandle,
handoverHdrPtr->f_FirmwareSpecific[HEL::kHandoverSpecificMemoryEfi] =
(UIntPtr)Descriptor;
- handoverHdrPtr->f_VirtualStart =
- (VoidPtr)Descriptor[cDefaultMemoryMap].VirtualStart;
+ handoverHdrPtr->f_BitMapStart = 0;
- handoverHdrPtr->f_HeapStart = 0;
-
- while (BS->AllocatePool(EfiLoaderData, kHandoverHeapSz, &handoverHdrPtr->f_HeapStart) != kEfiOk)
+ while (BS->AllocatePool(EfiRuntimeServicesData, kHandoverHeapSz, &handoverHdrPtr->f_BitMapStart) != kEfiOk)
;
handoverHdrPtr->f_VirtualSize =
Descriptor[cDefaultMemoryMap].NumberOfPages; /* # of pages */
- handoverHdrPtr->f_FirmwareVendorLen = BStrLen(SystemTable->FirmwareVendor);
-
- handoverHdrPtr->f_Magic = kHandoverMagic;
- handoverHdrPtr->f_Version = kHandoverVersion;
-
- // Provide fimware vendor name.
-
- BCopyMem(handoverHdrPtr->f_FirmwareVendorName, SystemTable->FirmwareVendor,
- handoverHdrPtr->f_FirmwareVendorLen);
-
- handoverHdrPtr->f_FirmwareVendorLen = BStrLen(SystemTable->FirmwareVendor);
-
- // Assign to global 'kHandoverHeader'.
-
- BDiskFormatFactory<BootDeviceATA> checkPart;
-
- if (!checkPart.IsPartitionValid())
- {
- BDiskFormatFactory<BootDeviceATA>::BFileDescriptor root;
- root.fFileName[0] = kNewFSRoot[0];
- root.fFileName[1] = 0;
-
- root.fKind = kNewFSCatalogKindDir;
-
- checkPart.Format("ZKA (A:)", &root, 1);
-
- rt_reset_hardware();
- }
-
- // ---------------------------------------------------- //
- // The following checks for an exisiting partition
- // inside the disk, if it doesn't have one,
- // format the disk.
- // ---------------------------------------------------- //
-
handoverHdrPtr->f_FirmwareCustomTables[0] = (VoidPtr)BS;
handoverHdrPtr->f_FirmwareCustomTables[1] = (VoidPtr)ST;
@@ -247,7 +232,7 @@ EFI_EXTERN_C EFI_API Int Main(EfiHandlePtr ImageHandle,
if (readerSysChk.Blob())
{
loaderSysChk = new Boot::BThread(readerSysChk.Blob());
- loaderSysChk->SetName("64-bit System Check DLL.");
+ loaderSysChk->SetName("System Check SYS.");
}
loaderSysChk->Start(handoverHdrPtr);
@@ -257,6 +242,20 @@ EFI_EXTERN_C EFI_API Int Main(EfiHandlePtr ImageHandle,
handoverHdrPtr->f_FirmwareCustomTables[0] = nullptr;
handoverHdrPtr->f_FirmwareCustomTables[1] = nullptr;
+ handoverHdrPtr->f_FirmwareVendorLen = BStrLen(SystemTable->FirmwareVendor);
+
+ handoverHdrPtr->f_Magic = kHandoverMagic;
+ handoverHdrPtr->f_Version = kHandoverVersion;
+
+ // Provide fimware vendor name.
+
+ BCopyMem(handoverHdrPtr->f_FirmwareVendorName, SystemTable->FirmwareVendor,
+ handoverHdrPtr->f_FirmwareVendorLen);
+
+ handoverHdrPtr->f_FirmwareVendorLen = BStrLen(SystemTable->FirmwareVendor);
+
+ // Assign to global 'kHandoverHeader'.
+
BFileReader readerKernel(L"newoskrnl.exe", ImageHandle);
readerKernel.ReadAll(0);
@@ -270,7 +269,7 @@ EFI_EXTERN_C EFI_API Int Main(EfiHandlePtr ImageHandle,
if (readerKernel.Blob())
{
loader = new Boot::BThread(readerKernel.Blob());
- loader->SetName("64-bit Kernel DLL.");
+ loader->SetName("64-Bit Kernel EXE.");
handoverHdrPtr->f_KernelImage = readerKernel.Blob();
}
@@ -288,11 +287,17 @@ EFI_EXTERN_C EFI_API Int Main(EfiHandlePtr ImageHandle,
urbanistTTF.ReadAll(0);
if (readerSysDrv.Blob() &&
- chimeWav.Blob())
+ chimeWav.Blob() &&
+ urbanistTTF.Blob())
{
handoverHdrPtr->f_StartupChime = chimeWav.Blob();
- handoverHdrPtr->f_StartupImage = readerKernel.Blob();
+ handoverHdrPtr->f_ChimeSz = chimeWav.Size();
+ handoverHdrPtr->f_StartupImage = readerSysDrv.Blob();
+ handoverHdrPtr->f_StartupSz = readerSysDrv.Size();
+ handoverHdrPtr->f_KernelImage = readerKernel.Blob();
+ handoverHdrPtr->f_KernelSz = readerKernel.Size();
handoverHdrPtr->f_TTFallbackFont = urbanistTTF.Blob();
+ handoverHdrPtr->f_FontSz = urbanistTTF.Size();
}
else
{
diff --git a/dev/ZBA/Sources/HEL/AMD64/BootTextWriter.cxx b/dev/ZBA/Sources/HEL/AMD64/BootTextWriter.cxx
index 467f4303..d43be468 100644
--- a/dev/ZBA/Sources/HEL/AMD64/BootTextWriter.cxx
+++ b/dev/ZBA/Sources/HEL/AMD64/BootTextWriter.cxx
@@ -134,7 +134,6 @@ BTextWriter& BTextWriter::WriteCharacter(CharacterTypeUTF16 c)
BTextWriter& BTextWriter::Write(const Long& x)
{
#ifdef __DEBUG__
- this->Write(L"0x");
this->_Write(x);
#endif // ifdef __DEBUG__
@@ -145,14 +144,14 @@ BTextWriter& BTextWriter::Write(const Long& x)
BTextWriter& BTextWriter::_Write(const Long& x)
{
#ifdef __DEBUG__
- UInt64 y = (x > 0 ? x : -x) / 16;
- UInt64 h = (x > 0 ? x : -x) % 16;
+ UInt64 y = (x > 0 ? x : -x) / 10;
+ UInt64 h = (x > 0 ? x : -x) % 10;
if (y)
this->_Write(y);
/* fail if the hex number is not base-16 */
- if (h > 15)
+ if (h > 10)
{
this->WriteCharacter('?');
return *this;
@@ -161,7 +160,7 @@ BTextWriter& BTextWriter::_Write(const Long& x)
if (y < 0)
y = -y;
- const char cNumbers[17] = "0123456789ABCDEF";
+ const char cNumbers[] = "0123456789";
this->WriteCharacter(cNumbers[h]);
#endif // ifdef __DEBUG__
diff --git a/dev/ZBA/Sources/Thread.cxx b/dev/ZBA/Sources/Thread.cxx
index 1ea83618..13b02b92 100644
--- a/dev/ZBA/Sources/Thread.cxx
+++ b/dev/ZBA/Sources/Thread.cxx
@@ -165,7 +165,7 @@ namespace Boot
err_fn(handover);
}
- rt_jump_to_address(fStartAddress, handover);
+ reinterpret_cast<HEL::HandoverProc>(fStartAddress)(handover);
}
const Char* BThread::GetName()