summaryrefslogtreecommitdiffhomepage
path: root/dev/ZBA/Sources
diff options
context:
space:
mode:
authorAmlal <amlal@el-mahrouss-logic.com>2024-09-12 05:32:09 +0200
committerAmlal <amlal@el-mahrouss-logic.com>2024-09-12 05:32:09 +0200
commit95f2fc6a9ba93d98a81a817c489de5946dc3f13b (patch)
treeb97f07c20b41a34550eaa37bc877507e044e356a /dev/ZBA/Sources
parentb323d403149db3d720a63af1087d44718821bd67 (diff)
Kernel and Bootloader improvements.
- The Allocator works, we have to find a free memory region for the kernel though. - Add Init procedure to DriveMgr. - Refactor CG for cgwm.sys Signed-off-by: Amlal <amlal@el-mahrouss-logic.com>
Diffstat (limited to 'dev/ZBA/Sources')
-rw-r--r--dev/ZBA/Sources/HEL/AMD64/BootATA.cxx2
-rw-r--r--dev/ZBA/Sources/HEL/AMD64/BootFileReader.cxx12
-rw-r--r--dev/ZBA/Sources/HEL/AMD64/BootMain.cxx35
-rw-r--r--dev/ZBA/Sources/HEL/AMD64/BootPlatform.cxx2
-rw-r--r--dev/ZBA/Sources/HEL/AMD64/BootString.cxx10
-rw-r--r--dev/ZBA/Sources/HEL/AMD64/BootTextWriter.cxx12
-rw-r--r--dev/ZBA/Sources/Thread.cxx2
7 files changed, 44 insertions, 31 deletions
diff --git a/dev/ZBA/Sources/HEL/AMD64/BootATA.cxx b/dev/ZBA/Sources/HEL/AMD64/BootATA.cxx
index 2f802cc0..171fe371 100644
--- a/dev/ZBA/Sources/HEL/AMD64/BootATA.cxx
+++ b/dev/ZBA/Sources/HEL/AMD64/BootATA.cxx
@@ -21,6 +21,8 @@
/// bugs: 0
+using namespace Boot;
+
#define kATADataLen 256
static Boolean kATADetected = false;
diff --git a/dev/ZBA/Sources/HEL/AMD64/BootFileReader.cxx b/dev/ZBA/Sources/HEL/AMD64/BootFileReader.cxx
index 7c9fd042..3c71eaab 100644
--- a/dev/ZBA/Sources/HEL/AMD64/BootFileReader.cxx
+++ b/dev/ZBA/Sources/HEL/AMD64/BootFileReader.cxx
@@ -31,7 +31,7 @@
/***
@brief File Reader constructor.
*/
-BFileReader::BFileReader(const CharacterTypeUTF16* path,
+Boot::BFileReader::BFileReader(const CharacterTypeUTF16* path,
EfiHandlePtr ImageHandle)
{
if (path != nullptr)
@@ -98,7 +98,7 @@ BFileReader::BFileReader(const CharacterTypeUTF16* path,
mErrorCode = kOperationOkay;
}
-BFileReader::~BFileReader()
+Boot::BFileReader::~BFileReader()
{
if (this->mFile)
{
@@ -126,7 +126,7 @@ BFileReader::~BFileReader()
@param **readUntil** size of file
@param **chunkToRead** chunk to read each time.
*/
-Void BFileReader::ReadAll(SizeT readUntil, SizeT chunkToRead, UIntPtr outAddress)
+Void Boot::BFileReader::ReadAll(SizeT readUntil, SizeT chunkToRead, UIntPtr outAddress)
{
if (mBlob == nullptr)
{
@@ -183,21 +183,21 @@ Void BFileReader::ReadAll(SizeT readUntil, SizeT chunkToRead, UIntPtr outAddress
/// @brief error code getter.
/// @return the error code.
-Int32& BFileReader::Error()
+Int32& Boot::BFileReader::Error()
{
return mErrorCode;
}
/// @brief blob getter.
/// @return the blob.
-VoidPtr BFileReader::Blob()
+VoidPtr Boot::BFileReader::Blob()
{
return mBlob;
}
/// @breif Size getter.
/// @return the size of the file.
-UInt64& BFileReader::Size()
+UInt64& Boot::BFileReader::Size()
{
return mSizeFile;
}
diff --git a/dev/ZBA/Sources/HEL/AMD64/BootMain.cxx b/dev/ZBA/Sources/HEL/AMD64/BootMain.cxx
index 55d93c29..0e7a9171 100644
--- a/dev/ZBA/Sources/HEL/AMD64/BootMain.cxx
+++ b/dev/ZBA/Sources/HEL/AMD64/BootMain.cxx
@@ -80,7 +80,7 @@ STATIC Bool CheckBootDevice(BootDeviceATA& ataDev)
}
EXTERN_C VoidPtr boot_read_cr3();
-EXTERN_C Void boot_write_cr3(VoidPtr new_cr3);
+EXTERN_C Void boot_write_cr3(VoidPtr new_cr3);
EXTERN EfiBootServices* BS;
@@ -159,7 +159,7 @@ EFI_EXTERN_C EFI_API Int Main(EfiHandlePtr ImageHandle,
handover_hdr->f_HardwareTables.f_MultiProcessingEnabled = cnt_enabled > 1;
// Fill handover header now.
- BDiskFormatFactory<BootDeviceATA> checkPart;
+ Boot::BDiskFormatFactory<BootDeviceATA> checkPart;
// ---------------------------------------------------- //
// The following checks for an exisiting partition
@@ -169,7 +169,7 @@ EFI_EXTERN_C EFI_API Int Main(EfiHandlePtr ImageHandle,
if (!checkPart.IsPartitionValid())
{
- BDiskFormatFactory<BootDeviceATA>::BFileDescriptor root;
+ Boot::BDiskFormatFactory<BootDeviceATA>::BFileDescriptor root;
root.fFileName[0] = kNeFSRoot[0];
root.fFileName[1] = 0;
@@ -204,13 +204,22 @@ EFI_EXTERN_C EFI_API Int Main(EfiHandlePtr ImageHandle,
// Update handover file specific table and phyiscal start field.
//-----------------------------------------------------------//
- handover_hdr->f_BitMapStart = reinterpret_cast<VoidPtr>(kHandoverBitMapStart); /* # of pages */
- handover_hdr->f_BitMapSize = kHandoverBitMapSz; /* # of pages */
+ handover_hdr->f_BitMapStart = nullptr; /* # of pages */
+ handover_hdr->f_BitMapSize = kHandoverBitMapSz; /* # of pages */
+
+ while (BS->AllocatePool(EfiLoaderData, handover_hdr->f_BitMapSize, &handover_hdr->f_BitMapStart) != kEfiOk)
+ {
+ if (handover_hdr->f_BitMapStart)
+ {
+ BS->FreePool(handover_hdr->f_BitMapStart);
+ handover_hdr->f_BitMapStart = nullptr;
+ }
+ }
handover_hdr->f_FirmwareCustomTables[0] = (VoidPtr)BS;
handover_hdr->f_FirmwareCustomTables[1] = (VoidPtr)ST;
- BFileReader readerSysChk(L"syschk.sys", ImageHandle);
+ Boot::BFileReader readerSysChk(L"syschk.sys", ImageHandle);
readerSysChk.ReadAll(0);
Boot::BThread* loaderSysChk = nullptr;
@@ -232,21 +241,21 @@ EFI_EXTERN_C EFI_API Int Main(EfiHandlePtr ImageHandle,
handover_hdr->f_FirmwareCustomTables[0] = nullptr;
handover_hdr->f_FirmwareCustomTables[1] = nullptr;
- handover_hdr->f_FirmwareVendorLen = BStrLen(SystemTable->FirmwareVendor);
+ handover_hdr->f_FirmwareVendorLen = Boot::BStrLen(SystemTable->FirmwareVendor);
handover_hdr->f_Magic = kHandoverMagic;
handover_hdr->f_Version = kHandoverVersion;
// Provide fimware vendor name.
- BCopyMem(handover_hdr->f_FirmwareVendorName, SystemTable->FirmwareVendor,
+ Boot::BCopyMem(handover_hdr->f_FirmwareVendorName, SystemTable->FirmwareVendor,
handover_hdr->f_FirmwareVendorLen);
- handover_hdr->f_FirmwareVendorLen = BStrLen(SystemTable->FirmwareVendor);
+ handover_hdr->f_FirmwareVendorLen = Boot::BStrLen(SystemTable->FirmwareVendor);
// Assign to global 'kHandoverHeader'.
- BFileReader readerKernel(L"newoskrnl.exe", ImageHandle);
+ Boot::BFileReader readerKernel(L"newoskrnl.exe", ImageHandle);
readerKernel.ReadAll(0);
@@ -268,9 +277,9 @@ EFI_EXTERN_C EFI_API Int Main(EfiHandlePtr ImageHandle,
CGDrawString("NEWOSLDR: PLEASE RECOVER YOUR NEWOSKRNL KERNEL DLL.", 30, 10, RGB(0xFF, 0xFF, 0xFF));
}
- BFileReader chimeWav(L"ZKA\\startup.wav", ImageHandle);
- BFileReader readerSysDrv(L"ZKA\\startup.sys", ImageHandle);
- BFileReader urbanistTTF(L"ZKA\\urbanist.ttf", ImageHandle);
+ Boot::BFileReader chimeWav(L"ZKA\\startup.wav", ImageHandle);
+ Boot::BFileReader readerSysDrv(L"ZKA\\startup.sys", ImageHandle);
+ Boot::BFileReader urbanistTTF(L"ZKA\\urbanist.ttf", ImageHandle);
readerSysDrv.ReadAll(0);
chimeWav.ReadAll(0);
diff --git a/dev/ZBA/Sources/HEL/AMD64/BootPlatform.cxx b/dev/ZBA/Sources/HEL/AMD64/BootPlatform.cxx
index c5218fe1..31566a95 100644
--- a/dev/ZBA/Sources/HEL/AMD64/BootPlatform.cxx
+++ b/dev/ZBA/Sources/HEL/AMD64/BootPlatform.cxx
@@ -10,6 +10,8 @@
#ifdef __STANDALONE__
+using namespace Boot;
+
EXTERN_C void rt_hlt()
{
asm volatile("hlt");
diff --git a/dev/ZBA/Sources/HEL/AMD64/BootString.cxx b/dev/ZBA/Sources/HEL/AMD64/BootString.cxx
index ad87bce2..1c109b80 100644
--- a/dev/ZBA/Sources/HEL/AMD64/BootString.cxx
+++ b/dev/ZBA/Sources/HEL/AMD64/BootString.cxx
@@ -15,11 +15,11 @@
#include <BootKit/Protocol.hxx>
#include <BootKit/BootKit.hxx>
-/// bugs 0
+/// BUGS: 0
/////////////////////////////////////////////////////////////////////////////////////////////////////////
-Kernel::SizeT BCopyMem(CharacterTypeUTF16* dest, CharacterTypeUTF16* src, const Kernel::SizeT len)
+Kernel::SizeT Boot::BCopyMem(CharacterTypeUTF16* dest, CharacterTypeUTF16* src, const Kernel::SizeT len)
{
if (!dest || !src)
return 0;
@@ -33,7 +33,7 @@ Kernel::SizeT BCopyMem(CharacterTypeUTF16* dest, CharacterTypeUTF16* src, const
return index;
}
-Kernel::SizeT BStrLen(const CharacterTypeUTF16* ptr)
+Kernel::SizeT Boot::BStrLen(const CharacterTypeUTF16* ptr)
{
if (!ptr)
return 0;
@@ -49,7 +49,7 @@ Kernel::SizeT BStrLen(const CharacterTypeUTF16* ptr)
return cnt;
}
-Kernel::SizeT BSetMem(CharacterTypeUTF16* src, const CharacterTypeUTF16 byte, const Kernel::SizeT len)
+Kernel::SizeT Boot::BSetMem(CharacterTypeUTF16* src, const CharacterTypeUTF16 byte, const Kernel::SizeT len)
{
if (!src)
return 0;
@@ -70,7 +70,7 @@ Kernel::SizeT BSetMem(CharacterTypeUTF16* src, const CharacterTypeUTF16 byte, co
return cnt;
}
-Kernel::SizeT BSetMem(CharacterTypeUTF8* src, const CharacterTypeUTF8 byte, const Kernel::SizeT len)
+Kernel::SizeT Boot::BSetMem(CharacterTypeUTF8* src, const CharacterTypeUTF8 byte, const Kernel::SizeT len)
{
if (!src)
return 0;
diff --git a/dev/ZBA/Sources/HEL/AMD64/BootTextWriter.cxx b/dev/ZBA/Sources/HEL/AMD64/BootTextWriter.cxx
index fdd9eba1..b0679715 100644
--- a/dev/ZBA/Sources/HEL/AMD64/BootTextWriter.cxx
+++ b/dev/ZBA/Sources/HEL/AMD64/BootTextWriter.cxx
@@ -23,7 +23,7 @@
/**
@brief puts wrapper over EFI ConOut.
*/
-BTextWriter& BTextWriter::Write(const CharacterTypeUTF16* str)
+Boot::BTextWriter& Boot::BTextWriter::Write(const CharacterTypeUTF16* str)
{
#ifdef __DEBUG__
if (!str || *str == 0)
@@ -55,7 +55,7 @@ BTextWriter& BTextWriter::Write(const CharacterTypeUTF16* str)
/// @brief UTF-8 equivalent of Write (UTF-16).
/// @param str the input string.
-BTextWriter& BTextWriter::Write(const Char* str)
+Boot::BTextWriter& Boot::BTextWriter::Write(const Char* str)
{
#ifdef __DEBUG__
if (!str || *str == 0)
@@ -85,7 +85,7 @@ BTextWriter& BTextWriter::Write(const Char* str)
return *this;
}
-BTextWriter& BTextWriter::Write(const UChar* str)
+Boot::BTextWriter& Boot::BTextWriter::Write(const UChar* str)
{
#ifdef __DEBUG__
if (!str || *str == 0)
@@ -118,7 +118,7 @@ BTextWriter& BTextWriter::Write(const UChar* str)
/**
@brief putc wrapper over EFI ConOut.
*/
-BTextWriter& BTextWriter::WriteCharacter(CharacterTypeUTF16 c)
+Boot::BTextWriter& Boot::BTextWriter::WriteCharacter(CharacterTypeUTF16 c)
{
#ifdef __DEBUG__
EfiCharType str[2];
@@ -131,7 +131,7 @@ BTextWriter& BTextWriter::WriteCharacter(CharacterTypeUTF16 c)
return *this;
}
-BTextWriter& BTextWriter::Write(const Long& x)
+Boot::BTextWriter& Boot::BTextWriter::Write(const Long& x)
{
#ifdef __DEBUG__
this->_Write(x);
@@ -141,7 +141,7 @@ BTextWriter& BTextWriter::Write(const Long& x)
return *this;
}
-BTextWriter& BTextWriter::_Write(const Long& x)
+Boot::BTextWriter& Boot::BTextWriter::_Write(const Long& x)
{
#ifdef __DEBUG__
UInt64 y = (x > 0 ? x : -x) / 16;
diff --git a/dev/ZBA/Sources/Thread.cxx b/dev/ZBA/Sources/Thread.cxx
index c811e620..1f780fa2 100644
--- a/dev/ZBA/Sources/Thread.cxx
+++ b/dev/ZBA/Sources/Thread.cxx
@@ -153,7 +153,7 @@ namespace Boot
HEL::HandoverProc err_fn = [](HEL::HANDOVER_INFO_HEADER* rcx) -> void {
CGDrawString("NEWOSLDR: INVALID IMAGE! ABORTING...", 50, 10, RGB(0xFF, 0xFF, 0xFF));
- EFI::Stop();
+ ::EFI::Stop();
};
if (!fStartAddress)