summaryrefslogtreecommitdiffhomepage
path: root/Boot/Sources
diff options
context:
space:
mode:
Diffstat (limited to 'Boot/Sources')
-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
4 files changed, 62 insertions, 44 deletions
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__