summaryrefslogtreecommitdiffhomepage
path: root/Private/NewBoot/Source
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-04-24 08:24:36 +0200
committerAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-04-24 08:24:36 +0200
commit1e0ecf576c5cc3272a1e5e0b5c0f09041014d90b (patch)
tree6b9a68e505e8be6dab6c33fa99a8ec47c79cc534 /Private/NewBoot/Source
parent21de9c0793156287836efcf87b99a3ef948f4939 (diff)
Kernel: tons of patches and fixes.
Bootloader: Add error screen and support page in case of a catastrophic failure. Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'Private/NewBoot/Source')
-rw-r--r--Private/NewBoot/Source/HEL/AMD64/BootFileReader.cxx21
-rw-r--r--Private/NewBoot/Source/HEL/AMD64/BootMain.cxx15
-rw-r--r--Private/NewBoot/Source/HEL/AMD64/New+Delete.cxx5
-rw-r--r--Private/NewBoot/Source/makefile2
4 files changed, 25 insertions, 18 deletions
diff --git a/Private/NewBoot/Source/HEL/AMD64/BootFileReader.cxx b/Private/NewBoot/Source/HEL/AMD64/BootFileReader.cxx
index 3a445d61..33067380 100644
--- a/Private/NewBoot/Source/HEL/AMD64/BootFileReader.cxx
+++ b/Private/NewBoot/Source/HEL/AMD64/BootFileReader.cxx
@@ -10,7 +10,10 @@
#include <BootKit/BootKit.hxx>
#include <FirmwareKit/Handover.hxx>
+#include <cstddef>
+/// @file BootFileReader
+/// @brief Bootloader File reader.
/// BUGS: 0
////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -61,6 +64,7 @@ BFileReader::BFileReader(const CharacterTypeUTF16* path,
if (efp->OpenVolume(efp, &rootFs) != kEfiOk) {
mWriter.Write(L"New Boot: Fetch-Protocol: No-Such-Volume").Write(L"\r\n");
+ EFI::RaiseHardError(L"NoSuchVolume", L"No Such volume.");
this->mErrorCode = kNotSupported;
return;
}
@@ -72,6 +76,7 @@ BFileReader::BFileReader(const CharacterTypeUTF16* path,
mWriter.Write(L"New Boot: Fetch-Protocol: No-Such-Path: ")
.Write(mPath)
.Write(L"\r\n");
+ EFI::RaiseHardError(L"NoSuchPath", L"No Such file on filesystem.");
this->mErrorCode = kNotSupported;
return;
}
@@ -100,8 +105,8 @@ BFileReader::~BFileReader() {
*/
Void BFileReader::ReadAll(SizeT until, SizeT chunk) {
if (mBlob == nullptr) {
- if (auto err = BS->AllocatePool(EfiLoaderCode, until,
- (VoidPtr*)&mBlob) != kEfiOk) {
+ if (auto err = BS->AllocatePool(EfiLoaderCode, until, (VoidPtr*)&mBlob) !=
+ kEfiOk) {
mWriter.Write(L"*** EFI-Code: ").Write(err).Write(L" ***\r\n");
EFI::RaiseHardError(L"NewBoot_PageError", L"Allocation error.");
}
@@ -113,16 +118,16 @@ Void BFileReader::ReadAll(SizeT until, SizeT chunk) {
UInt64 szCnt = 0;
UInt64 curSz = 0;
- while (curSz < until) {
- if (mFile->Read(mFile, &bufSize, (VoidPtr)((UIntPtr)mBlob + curSz)) != kEfiOk) {
- break;
+ while (szCnt < until) {
+ if (mFile->Read(mFile, &bufSize, (VoidPtr)((UIntPtr)mBlob + curSz)) !=
+ kEfiOk) {
+ break;
}
szCnt += bufSize;
curSz += bufSize;
- if (bufSize == 0)
- break;
+ if (bufSize == 0) break;
}
mSizeFile = curSz;
@@ -135,7 +140,7 @@ Int32& BFileReader::Error() { return mErrorCode; }
/// @brief blob getter.
/// @return the blob.
-VoidPtr BFileReader::Blob(){ return mBlob; }
+VoidPtr BFileReader::Blob() { return mBlob; }
/// @breif Size getter.
/// @return the size of the file.
diff --git a/Private/NewBoot/Source/HEL/AMD64/BootMain.cxx b/Private/NewBoot/Source/HEL/AMD64/BootMain.cxx
index 1f140f7e..42852b5d 100644
--- a/Private/NewBoot/Source/HEL/AMD64/BootMain.cxx
+++ b/Private/NewBoot/Source/HEL/AMD64/BootMain.cxx
@@ -5,8 +5,7 @@
------------------------------------------- */
#include <BootKit/BootKit.hxx>
-#include <BootKit/Rsrc/Driver.rsrc>
-#include <Builtins/Toolbox/Lerp.hxx>
+#include <BootKit/Rsrc/NewBoot.rsrc>
#include <Builtins/Toolbox/Toolbox.hxx>
#include <KernelKit/MSDOS.hpp>
#include <KernelKit/PEF.hpp>
@@ -118,18 +117,18 @@ EFI_EXTERN_C EFI_API Int Main(EfiHandlePtr ImageHandle,
///! Finally draw bootloader screen.
- auto kHandoverHeader = handoverHdrPtr;
+ kHandoverHeader = handoverHdrPtr;
ToolboxInitRsrc();
- ToolboxDrawZone(RGB(FF, FF, FF), handoverHdrPtr->f_GOP.f_Height,
+ ToolboxDrawZone(RGB(9d, 9d, 9d), handoverHdrPtr->f_GOP.f_Height,
handoverHdrPtr->f_GOP.f_Width, 0, 0);
ToolboxClearRsrc();
- ToolboxDrawRsrc(Driver, DRIVER_HEIGHT, DRIVER_WIDTH,
- (handoverHdrPtr->f_GOP.f_Width - DRIVER_HEIGHT) / 2,
- (handoverHdrPtr->f_GOP.f_Height - DRIVER_HEIGHT) / 2);
+ ToolboxDrawRsrc(NewBoot, NEWBOOT_HEIGHT, NEWBOOT_WIDTH,
+ (handoverHdrPtr->f_GOP.f_Width - NEWBOOT_WIDTH) / 2,
+ (handoverHdrPtr->f_GOP.f_Height - NEWBOOT_HEIGHT) / 2);
ToolboxClearRsrc();
@@ -203,5 +202,7 @@ EFI_EXTERN_C EFI_API Int Main(EfiHandlePtr ImageHandle,
}
}
+ EFI::RaiseHardError(L"Invalid-PEF-Executable", L"PEF executable expected. Got something else.");
+
return kEfiFail;
}
diff --git a/Private/NewBoot/Source/HEL/AMD64/New+Delete.cxx b/Private/NewBoot/Source/HEL/AMD64/New+Delete.cxx
index af7f2f00..1bb2d9ca 100644
--- a/Private/NewBoot/Source/HEL/AMD64/New+Delete.cxx
+++ b/Private/NewBoot/Source/HEL/AMD64/New+Delete.cxx
@@ -5,10 +5,11 @@
------------------------------------------- */
#include <BootKit/BootKit.hxx>
+#include <cstddef> /* Since we're using GCC for this EFI program. */
/// @brief Allocates a new object.
/// @param sz the size.
-/// @return
+/// @return
void* operator new(size_t sz)
{
void* buf = nullptr;
@@ -30,4 +31,4 @@ void operator delete(void* buf)
void operator delete(void* buf, size_t size)
{
BS->FreePool(buf);
-} \ No newline at end of file
+}
diff --git a/Private/NewBoot/Source/makefile b/Private/NewBoot/Source/makefile
index 224c352e..2f9e3756 100644
--- a/Private/NewBoot/Source/makefile
+++ b/Private/NewBoot/Source/makefile
@@ -30,7 +30,7 @@ REM=rm
REM_FLAG=-f
FLAG_ASM=-f win64
-FLAG_GNU=-fshort-wchar -D__EFI_x86_64__ -mno-red-zone -D__KERNEL__ -DEFI_FUNCTION_WRAPPER -I../ -I../../ -I./ -c -ffreestanding -fno-rtti -fno-exceptions -std=c++20 -D__HAVE_MAHROUSS_APIS__ -D__MAHROUSS__ -D__BOOTLOADER__ -I./
+FLAG_GNU=-fshort-wchar -D__EFI_x86_64__ -mno-red-zone -D__KERNEL__ -D__NEWBOOT__ -DEFI_FUNCTION_WRAPPER -I../ -I../../ -I./ -c -nostdlib -fno-rtti -fno-exceptions -std=c++20 -D__HAVE_MAHROUSS_APIS__ -D__MAHROUSS__ -D__BOOTLOADER__ -I./
.PHONY: invalid-recipe
invalid-recipe: