summaryrefslogtreecommitdiffhomepage
path: root/Private/NewBoot/Source
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlalelmahrouss@icloud.com>2024-02-05 19:19:12 +0100
committerAmlal El Mahrouss <amlalelmahrouss@icloud.com>2024-02-05 19:19:12 +0100
commitf3e49a9d6b865e7a3f6361ed88863cd12a5f90f1 (patch)
treebb1ba85c3bc627be09f397f44eb216459f34d902 /Private/NewBoot/Source
parent6191833a26e887c2b91ba4ad655297bfe70c97d5 (diff)
HCR-13 : Optimize filesystem operations on UEFI.
- Stream concept, on demand. Signed-off-by: Amlal El Mahrouss <amlalelmahrouss@icloud.com>
Diffstat (limited to 'Private/NewBoot/Source')
-rw-r--r--Private/NewBoot/Source/FileReader.cxx9
-rw-r--r--Private/NewBoot/Source/RuntimeMain.cxx (renamed from Private/NewBoot/Source/Entrypoint.cxx)35
-rw-r--r--Private/NewBoot/Source/TextWriter.cxx5
-rw-r--r--Private/NewBoot/Source/makefile2
4 files changed, 25 insertions, 26 deletions
diff --git a/Private/NewBoot/Source/FileReader.cxx b/Private/NewBoot/Source/FileReader.cxx
index 54e59dde..efd53020 100644
--- a/Private/NewBoot/Source/FileReader.cxx
+++ b/Private/NewBoot/Source/FileReader.cxx
@@ -113,10 +113,6 @@ Void BFileReader::ReadAll() {
.WriteString(mPath)
.WriteString(L"\r\n");
- mWriter.WriteString(L"HCoreLdr: ReadAll: FETCH: ")
- .WriteString(mPath)
- .WriteString(L"\r\n");
-
/// Allocate Handover page.
UInt8* blob = (UInt8*)kHandoverStartKernel;
@@ -131,10 +127,5 @@ Void BFileReader::ReadAll() {
if (mFile->Read(mFile, &mSizeFile, mBlob) != kEfiOk) return;
- mSizeFile = KIB(kMaxReadSize);
mErrorCode = kOperationOkay;
-
- mWriter.WriteString(L"HCoreLdr: ReadAll: OK: ")
- .WriteString(mPath)
- .WriteString(L"\r\n");
}
diff --git a/Private/NewBoot/Source/Entrypoint.cxx b/Private/NewBoot/Source/RuntimeMain.cxx
index b63fb0a1..6feefea5 100644
--- a/Private/NewBoot/Source/Entrypoint.cxx
+++ b/Private/NewBoot/Source/RuntimeMain.cxx
@@ -11,6 +11,7 @@
#include <BootKit/BootKit.hxx>
#include <EFIKit/Api.hxx>
+#include <KernelKit/MSDOS.hpp>
#include <KernelKit/PE.hpp>
#include <NewKit/Ref.hpp>
@@ -21,28 +22,40 @@ EFI_EXTERN_C EFI_API Int EfiMain(EfiHandlePtr ImageHandle,
BTextWriter writer;
+#ifndef __DEBUG__
+
+ writer.WriteString(
+ L"MahroussLogic (R) HCore Version 1.0.0 (Release Channel)\r\n");
+
+#else
+
+ writer.WriteString(
+ L"MahroussLogic (R) HCore Version 1.0.0 (Insiders Channel)\r\n");
+
+#endif
+
writer.WriteString(L"HCoreLdr: Firmware Vendor: ")
.WriteString(SystemTable->FirmwareVendor)
.WriteString(L"\r\n");
BFileReader img(L"HCOREKRNL.EXE", ImageHandle);
+ img.ReadAll();
- UInt8 buf[1024] = {0};
- UInt32 bufSz = 1024;
+ if (img.Error() == BFileReader::kOperationOkay) {
+ VoidPtr blob = img.Blob();
- img.File()->Read(img.File(), &bufSz, buf);
+ UInt64 MapKey = 0;
- if (buf[0] != kMagMz0 || buf[1] != kMagMz1) {
- EFI::RaiseHardError(L"HCoreLdr_NoBlob", L"No Such blob.");
- return kEfiFail;
- }
+ EFI::ExitBootServices(MapKey, ImageHandle);
+ EFI::Stop();
- writer.WriteString(L"HCoreLdr: Loading HCOREKRNL.EXE...\r\n");
+ return kEfiOk;
+ }
- UInt64 MapKey = 0;
+ writer.WriteString(
+ L"HCoreLdr: Missing HCOREKRNL.EXE! Your system is damaged.\r\n");
- EFI::ExitBootServices(MapKey, ImageHandle);
EFI::Stop();
- return kEfiOk;
+ return kEfiFail;
}
diff --git a/Private/NewBoot/Source/TextWriter.cxx b/Private/NewBoot/Source/TextWriter.cxx
index b6a8e3b8..c885f317 100644
--- a/Private/NewBoot/Source/TextWriter.cxx
+++ b/Private/NewBoot/Source/TextWriter.cxx
@@ -22,12 +22,9 @@
@brief puts wrapper over EFI ConOut.
*/
BTextWriter &BTextWriter::WriteString(const CharacterType *str) {
-#ifdef __DEBUG__
-
if (*str == 0 || !str) return *this;
ST->ConOut->OutputString(ST->ConOut, str);
-#endif
return *this;
}
@@ -36,12 +33,10 @@ BTextWriter &BTextWriter::WriteString(const CharacterType *str) {
@brief putc wrapper over EFI ConOut.
*/
BTextWriter &BTextWriter::WriteCharacter(CharacterType c) {
-#ifdef __DEBUG__
EfiCharType str[2];
str[0] = c;
str[1] = 0;
ST->ConOut->OutputString(ST->ConOut, str);
-#endif
return *this;
}
diff --git a/Private/NewBoot/Source/makefile b/Private/NewBoot/Source/makefile
index 02990084..cc550bdd 100644
--- a/Private/NewBoot/Source/makefile
+++ b/Private/NewBoot/Source/makefile
@@ -31,7 +31,7 @@ make-disk:
.PHONY: run-efi-debug
run-efi-debug:
wget https://retrage.github.io/edk2-nightly/bin/DEBUGX64_OVMF.fd -O OVMF.fd
- qemu-system-x86_64 -smp 2 -m 4G -M q35 -bios OVMF.fd -drive file=os.epm,index=0,if=ide,format=qcow2 -drive file=fat:rw:CDROM,index=1,format=raw -serial stdio
+ qemu-system-x86_64 -net none -smp 2 -m 4G -M q35 -bios OVMF.fd -drive file=os.epm,index=0,if=ide,format=qcow2 -drive file=fat:rw:CDROM,index=1,format=raw -serial stdio
.PHONY: clean
clean: