summaryrefslogtreecommitdiffhomepage
path: root/Boot
diff options
context:
space:
mode:
Diffstat (limited to 'Boot')
-rw-r--r--Boot/BootKit/BootKit.hxx4
-rw-r--r--Boot/Sources/HEL/AMD64/BootMain.cxx8
-rw-r--r--Boot/Sources/HEL/AMD64/compile_flags.txt6
-rw-r--r--Boot/Sources/ProgramLoader.cxx88
-rw-r--r--Boot/Sources/compile_flags.txt4
-rw-r--r--Boot/amd64-efi.make2
6 files changed, 65 insertions, 47 deletions
diff --git a/Boot/BootKit/BootKit.hxx b/Boot/BootKit/BootKit.hxx
index 3c0ea09c..b95d635f 100644
--- a/Boot/BootKit/BootKit.hxx
+++ b/Boot/BootKit/BootKit.hxx
@@ -235,7 +235,7 @@ public:
return false;
}
- writer.Write(L"Device Size: ").Write(this->fDiskDev.GetDiskSize()).Write(L"\r");
+ writer.Write(L"newosldr: disk size: ").Write(this->fDiskDev.GetDiskSize()).Write(L"\r");
if (blockPart->DiskSize != this->fDiskDev.GetDiskSize() ||
blockPart->DiskSize < 1 ||
@@ -249,7 +249,7 @@ public:
EFI::ThrowError(L"Invalid-Partition-Name", L"Invalid disk partition.");
}
- writer.Write(L"Device Partition: ").Write(blockPart->PartitionName).Write(L" is healthy.\r");
+ writer.Write(L"newosldr: partition name: ").Write(blockPart->PartitionName).Write(L" is healthy.\r");
return true;
}
diff --git a/Boot/Sources/HEL/AMD64/BootMain.cxx b/Boot/Sources/HEL/AMD64/BootMain.cxx
index ce4074b2..e971abc0 100644
--- a/Boot/Sources/HEL/AMD64/BootMain.cxx
+++ b/Boot/Sources/HEL/AMD64/BootMain.cxx
@@ -241,7 +241,7 @@ EFI_EXTERN_C EFI_API Int Main(EfiHandlePtr ImageHandle,
if (readerKernel.Blob())
{
loader = new Boot::ProgramLoader(readerKernel.Blob());
- loader->SetName("NewOSKrnl (Patched)");
+ loader->SetName("'newoskrnl.exe'");
}
#endif // ifdef __NEWOS_CAN_PATCH__
@@ -256,12 +256,10 @@ EFI_EXTERN_C EFI_API Int Main(EfiHandlePtr ImageHandle,
if (loader)
loader->Start(handoverHdrPtr);
- else
- hal_init_platform(handoverHdrPtr);
-#else
- hal_init_platform(handoverHdrPtr);
#endif // ifdef __NEWOS_CAN_PATCH__
+ hal_init_platform(handoverHdrPtr);
+
EFI::Stop();
CANT_REACH();
diff --git a/Boot/Sources/HEL/AMD64/compile_flags.txt b/Boot/Sources/HEL/AMD64/compile_flags.txt
index e4515efe..d7a2b538 100644
--- a/Boot/Sources/HEL/AMD64/compile_flags.txt
+++ b/Boot/Sources/HEL/AMD64/compile_flags.txt
@@ -1,3 +1,7 @@
-std=c++20
-I../../../
--I../../../../
+-I../../../../Kernel
+-D__NEWOS_AMD64__
+-std=c++20
+-D__x86_64__
+-D__NEWOS_CAN_PATCH__
diff --git a/Boot/Sources/ProgramLoader.cxx b/Boot/Sources/ProgramLoader.cxx
index 90175bef..0603fb9c 100644
--- a/Boot/Sources/ProgramLoader.cxx
+++ b/Boot/Sources/ProgramLoader.cxx
@@ -7,60 +7,72 @@
#include <BootKit/ProgramLoader.hxx>
#include <BootKit/Vendor/Support.hxx>
#include <BootKit/BootKit.hxx>
+
+EXTERN_C
+{
#include <string.h>
+}
namespace Boot
{
ProgramLoader::ProgramLoader(VoidPtr blob)
: fBlob(blob), fStartAddress(nullptr)
{
- // detect the format.
- const char* firstBytes = reinterpret_cast<char*>(fBlob);
+ // detect the format.
+ const Char* firstBytes = reinterpret_cast<char*>(fBlob);
- BTextWriter writer;
- writer.WriteCharacter(firstBytes[0]).WriteCharacter(firstBytes[1]).WriteCharacter('\r').WriteCharacter('\n');
+ BTextWriter writer;
- if (!firstBytes)
- {
- // failed to provide a valid pointer.
- return;
- }
+ if (!firstBytes)
+ {
+ // failed to provide a valid pointer.
+ return;
+ }
- if (firstBytes[0] == 'M' &&
- firstBytes[1] == 'Z')
- {
- // Parse PE32+
- fStartAddress = nullptr;
- }
- else if (firstBytes[0] == 'J' &&
- firstBytes[1] == 'o' &&
- firstBytes[2] == 'y' &&
- firstBytes[3] == '!')
- {
- // Parse Non FAT PEF.
- fStartAddress = nullptr;
- }
- else
- {
- // probably a binary blob.
- fStartAddress = fBlob;
- }
- }
+ if (firstBytes[0] == 'M' &&
+ firstBytes[1] == 'Z')
+ {
+ // Parse PE32+
+ fStartAddress = nullptr;
+ writer.Write("newosldr: MZ executable detected.\r");
+ }
+ else if (firstBytes[0] == 'J' &&
+ firstBytes[1] == 'o' &&
+ firstBytes[2] == 'y' &&
+ firstBytes[3] == '!')
+ {
+ // Parse Non FAT PEF.
+ fStartAddress = nullptr;
+ writer.Write("newosldr: PEF executable detected.\r");
+ }
+ else
+ {
+ // probably a binary blob.
+ fStartAddress = fBlob;
+ }
+ }
Void ProgramLoader::Start(HEL::HandoverInformationHeader* handover)
{
- if (!fStartAddress) return;
+ BTextWriter writer;
+ writer.Write("newosldr: running: ").Write(fBlobName).Write("\r");
+
+ if (!fStartAddress)
+ {
+ writer.Write("newosldr: exec error.\r");
+ return;
+ }
- ((HEL::HandoverProc)fStartAddress)(handover);
+ ((HEL::HandoverProc)fStartAddress)(handover);
}
const Char* ProgramLoader::GetName()
- {
- return fBlobName;
- }
+ {
+ return fBlobName;
+ }
Void ProgramLoader::SetName(const Char* name)
- {
- CopyMem(fBlobName, name, StrLen(name));
- }
-} // namespace Boot \ No newline at end of file
+ {
+ CopyMem(fBlobName, name, StrLen(name));
+ }
+} // namespace Boot
diff --git a/Boot/Sources/compile_flags.txt b/Boot/Sources/compile_flags.txt
index c74d22b2..b42b9a4f 100644
--- a/Boot/Sources/compile_flags.txt
+++ b/Boot/Sources/compile_flags.txt
@@ -1,4 +1,8 @@
-std=c++20
-I../
-I../../
+-I../../Kernel
-D__NEWOS_AMD64__
+-std=c++20
+-D__x86_64__
+-D__NEWOS_CAN_PATCH__
diff --git a/Boot/amd64-efi.make b/Boot/amd64-efi.make
index 294bfb9e..5e14908e 100644
--- a/Boot/amd64-efi.make
+++ b/Boot/amd64-efi.make
@@ -53,7 +53,7 @@ REM_FLAG=-f
FLAG_ASM=-f win64
FLAG_GNU=-fshort-wchar -D__EFI_x86_64__ -mno-red-zone -D__KERNEL__ -D__NEWBOOT__ \
-DEFI_FUNCTION_WRAPPER -I./ -I../Vendor -I../Kernel -I./ -c -nostdlib -fno-rtti -fno-exceptions \
- -std=c++20 -D__HAVE_MAHROUSS_APIS__ -D__NEWOS_AMD64__ -D__MAHROUSS__ -D__BOOTLOADER__ -I./
+ -std=c++20 -D__NEWOS_CAN_PATCH__ -D__HAVE_MAHROUSS_APIS__ -D__NEWOS_AMD64__ -D__MAHROUSS__ -D__BOOTLOADER__ -I./
BOOT_LOADER=newosldr.exe
KERNEL=newoskrnl.exe