summaryrefslogtreecommitdiffhomepage
path: root/Boot
diff options
context:
space:
mode:
Diffstat (limited to 'Boot')
-rw-r--r--Boot/BootKit/ProgramLoader.hxx1
-rw-r--r--Boot/Sources/HEL/AMD64/BootMain.cxx29
-rw-r--r--Boot/Sources/HEL/AMD64/New+Delete.cxx2
-rw-r--r--Boot/Sources/ProgramLoader.cxx9
-rw-r--r--Boot/amd64-efi.make7
5 files changed, 27 insertions, 21 deletions
diff --git a/Boot/BootKit/ProgramLoader.hxx b/Boot/BootKit/ProgramLoader.hxx
index 90f8996f..09fff89b 100644
--- a/Boot/BootKit/ProgramLoader.hxx
+++ b/Boot/BootKit/ProgramLoader.hxx
@@ -32,6 +32,7 @@ namespace Boot
void Start(HEL::HandoverInformationHeader* handover);
const char* GetName();
void SetName(const char* name);
+ bool IsValid();
private:
Char fBlobName[255];
diff --git a/Boot/Sources/HEL/AMD64/BootMain.cxx b/Boot/Sources/HEL/AMD64/BootMain.cxx
index 8705f4a8..5e0c8b05 100644
--- a/Boot/Sources/HEL/AMD64/BootMain.cxx
+++ b/Boot/Sources/HEL/AMD64/BootMain.cxx
@@ -227,8 +227,6 @@ EFI_EXTERN_C EFI_API Int Main(EfiHandlePtr ImageHandle,
diskFormatter.Format(kMachineModel, &rootDesc, 1);
}
-#ifdef __NEWOS_OTA__
-
BFileReader readerKernel(L"newoskrnl.exe", ImageHandle);
readerKernel.ReadAll(0);
@@ -236,30 +234,35 @@ EFI_EXTERN_C EFI_API Int Main(EfiHandlePtr ImageHandle,
Boot::ProgramLoader* loader = nullptr;
// ------------------------------------------ //
- // If we succeed in reading the blob, then execute it.
+ // If we succeed in reading the blob, then execute it.
// ------------------------------------------ //
if (readerKernel.Blob())
{
loader = new Boot::ProgramLoader(readerKernel.Blob());
- loader->SetName("\"newoskrnl.exe\" (ZKA 64-bit MP)");
+ loader->SetName("\"newoskrnl.exe\" (64-bit MP)");
}
- writer.Write("Running: ").Write(loader->GetName()).Write("\r");
+ if (!loader->IsValid())
+ {
+ writer.Write("newosldr: Invalid kernel image!\r");
+
+ EFI::Stop();
-#endif // ifdef __NEWOS_OTA__
+ CANT_REACH();
+ }
+
+ writer.Write("newosldr: ").Write(loader->GetName()).Write("\r");
+
+ CopyMem(handoverHdrPtr->f_CommandLine[0], "/SMP", StrLen("/SMP"));
EFI::ExitBootServices(*MapKey, ImageHandle);
// ---------------------------------------------------- //
- // Call OTA kernel or fallback to builtin.
+ // Call kernel.
// ---------------------------------------------------- //
-#ifdef __NEWOS_OTA__
- if (loader)
- loader->Start(handoverHdrPtr);
-#else
- hal_init_platform(handoverHdrPtr);
-#endif // ifdef __NEWOS_OTA__
+
+ loader->Start(handoverHdrPtr);
EFI::Stop();
diff --git a/Boot/Sources/HEL/AMD64/New+Delete.cxx b/Boot/Sources/HEL/AMD64/New+Delete.cxx
index 15903bb4..62dcda35 100644
--- a/Boot/Sources/HEL/AMD64/New+Delete.cxx
+++ b/Boot/Sources/HEL/AMD64/New+Delete.cxx
@@ -11,6 +11,8 @@
#ifdef __STANDALONE__
#include <cstddef> /* Since we're using GCC for this EFI program. */
+EXTERN EfiBootServices* BS;
+
/// @brief Allocates a new object.
/// @param sz the size.
/// @return
diff --git a/Boot/Sources/ProgramLoader.cxx b/Boot/Sources/ProgramLoader.cxx
index 4ea0d4c6..fabd1c63 100644
--- a/Boot/Sources/ProgramLoader.cxx
+++ b/Boot/Sources/ProgramLoader.cxx
@@ -39,13 +39,13 @@ namespace Boot
if (firstBytes[0] == kMagMz0 &&
firstBytes[1] == kMagMz1)
{
- writer.Write("newosldr: MZ executable detected.\r");
+ writer.Write("newosldr: Windows executable detected.\r");
ExecHeaderPtr hdrPtr = (ldr_find_exec_header(firstBytes));
ExecOptionalHeaderPtr optHdr = (ldr_find_opt_exec_header(firstBytes));
// Parse PE32+
- fStartAddress = (VoidPtr)((UIntPtr)optHdr->mImageBase + optHdr->mBaseOfCode + optHdr->mAddressOfEntryPoint);
+ fStartAddress = (VoidPtr)(optHdr->mAddressOfEntryPoint);
fStackPtr = new Char[optHdr->mSizeOfStackReserve];
writer.Write("newosldr: Major Linker: ").Write(optHdr->mMajorLinkerVersion).Write("\r");
@@ -112,4 +112,9 @@ namespace Boot
{
CopyMem(fBlobName, name, StrLen(name));
}
+
+ bool ProgramLoader::IsValid()
+ {
+ return fStartAddress != nullptr;
+ }
} // namespace Boot
diff --git a/Boot/amd64-efi.make b/Boot/amd64-efi.make
index f1e40d7a..49d2ae59 100644
--- a/Boot/amd64-efi.make
+++ b/Boot/amd64-efi.make
@@ -38,19 +38,14 @@ EMU_FLAGS=-net none -smp 2 -m 4G -M q35 \
LD_FLAGS=-e Main --subsystem=10
-ifeq ($(NEWS_STANDLONE), )
-OBJ=*.o ../Kernel/Objects/*.obj
-else
-RESCMD=$(WINDRES) BootloaderRsrc.rsrc -O coff -o BootloaderRsrc.o
STANDALONE_MACRO=-D__STANDALONE__
OBJ=*.o
-endif
REM=rm
REM_FLAG=-f
FLAG_ASM=-f win64
-FLAG_GNU=-fshort-wchar -D__EFI_x86_64__ -mno-red-zone -D__KERNEL__ -D__NEWBOOT__ \
+FLAG_GNU=-fshort-wchar -D__EFI_x86_64__ -D__NEWOS_OTA__ -mno-red-zone -D__KERNEL__ -D__NEWBOOT__ \
-DEFI_FUNCTION_WRAPPER -I./ -I../Vendor -I../Kernel -c -nostdlib -fno-rtti -fno-exceptions \
-std=c++20 -D__HAVE_MAHROUSS_APIS__ -D__NEWOS_AMD64__ -D__MAHROUSS__ -D__BOOTLOADER__