summaryrefslogtreecommitdiffhomepage
path: root/Private/NewBoot/Source/FileReader.cxx
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlalelmahrouss@icloud.com>2024-02-05 10:53:58 +0100
committerAmlal El Mahrouss <amlalelmahrouss@icloud.com>2024-02-05 10:53:58 +0100
commitf8c9b81ff120160af60af6e9d44cba338aceb65a (patch)
treecb4683589aab4d50470628f189dc366814fd80ad /Private/NewBoot/Source/FileReader.cxx
parente03903b98aa0b4d2dc3ed4637863124f28c4e1fe (diff)
Kernel: Improved kernel design and Bootloader runs on real hardware!
Signed-off-by: Amlal El Mahrouss <amlalelmahrouss@icloud.com>
Diffstat (limited to 'Private/NewBoot/Source/FileReader.cxx')
-rw-r--r--Private/NewBoot/Source/FileReader.cxx45
1 files changed, 18 insertions, 27 deletions
diff --git a/Private/NewBoot/Source/FileReader.cxx b/Private/NewBoot/Source/FileReader.cxx
index be0e7746..a18c5093 100644
--- a/Private/NewBoot/Source/FileReader.cxx
+++ b/Private/NewBoot/Source/FileReader.cxx
@@ -17,8 +17,7 @@
#include <EFIKit/Handover.hxx>
#include "EFIKit/EFI.hxx"
-#include "KernelKit/PE.hpp"
-#include "NewKit/Defines.hpp"
+#include "NewKit/Macros.hpp"
////////////////////////////////////////////////////////////////////////////////////////////////////
//
@@ -46,14 +45,21 @@ BFileReader::~BFileReader() {
if (this->mBlob) {
BS->FreePool(this->mBlob);
}
+
+ if (this->mFile) {
+ this->mFile->Close(this->mFile);
+ this->mFile = nullptr;
+ }
+
+ BSetMem(this->mPath, 0, kPathLen);
}
/**
@brief this reads all of the buffer.
@param ImageHandle used internally.
*/
-Void BFileReader::Fetch(EfiHandlePtr ImageHandle) {
- mWriter.WriteString(L"HCoreLdr: Fetch-File: ")
+Void BFileReader::ReadAll(EfiHandlePtr ImageHandle) {
+ mWriter.WriteString(L"HCoreLdr: ReadAll: ")
.WriteString(mPath)
.WriteString(L"\r\n");
@@ -102,13 +108,6 @@ Void BFileReader::Fetch(EfiHandlePtr ImageHandle) {
rootFs->Close(rootFs);
- if (kernelFile->Revision < EFI_FILE_PROTOCOL_REVISION2) {
- mWriter.WriteString(L"HCoreLdr: Fetch-Protocol: Invalid-Revision: ")
- .WriteString(mPath)
- .WriteString(L"\r\n");
- return;
- }
-
/// File FAT info.
UInt32 szInfo = sizeof(EfiFileInfo);
@@ -126,8 +125,7 @@ Void BFileReader::Fetch(EfiHandlePtr ImageHandle) {
return;
}
- mWriter.WriteString(L"HCoreLdr: Fetch-Info: In-Progress...")
- .WriteString(L"\r\n");
+ /// Allocate Handover page.
VoidPtr blob = (VoidPtr)kHandoverStartKernel;
@@ -136,21 +134,14 @@ Void BFileReader::Fetch(EfiHandlePtr ImageHandle) {
EFI::RaiseHardError(L"HCoreLdr_PageError", L"Allocation error.");
}
- UInt32* sz = nullptr;
-
- BS->AllocatePool(EfiLoaderData, sizeof(UInt32), (VoidPtr*)&sz);
-
- *sz = info->FileSize;
-
- mWriter.WriteString(L"HCoreLdr: Fetch-Info: Read...").WriteString(L"\r\n");
-
- kernelFile->Read(kernelFile, sz, blob);
-
- mWriter.WriteString(L"HCoreLdr: Fetch-Info: Success...").WriteString(L"\r\n");
-
- mCached = true;
+ mSizeFile = info->FileSize;
+ mFile = kernelFile;
mErrorCode = kOperationOkay;
mBlob = blob;
- // We are done!
+ this->File()->Read(this->File(), &mSizeFile, this->Blob());
+
+ mWriter.WriteString(L"HCoreLdr: ReadAll: OK: ")
+ .WriteString(mPath)
+ .WriteString(L"\r\n");
}