summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--Boot/BootKit/Support.hxx1
-rw-r--r--Boot/Sources/ProgramLoader.cxx16
-rw-r--r--Kernel/HALKit/AMD64/HalBoot.asm4
-rw-r--r--Kernel/amd64-efi.make2
4 files changed, 14 insertions, 9 deletions
diff --git a/Boot/BootKit/Support.hxx b/Boot/BootKit/Support.hxx
index a12148a1..4acffb75 100644
--- a/Boot/BootKit/Support.hxx
+++ b/Boot/BootKit/Support.hxx
@@ -16,6 +16,7 @@
#define MoveMem(dst, src, sz) memcpy(dst, src, sz)
#define CopyMem(dst, src, sz) memcpy(dst, src, sz)
#define StrLen(src) strlen(src)
+#define StrCmp(dst, src) strcmp(dst, src)
inline int IsSpace(int c)
{
diff --git a/Boot/Sources/ProgramLoader.cxx b/Boot/Sources/ProgramLoader.cxx
index 7461b87b..6568f0aa 100644
--- a/Boot/Sources/ProgramLoader.cxx
+++ b/Boot/Sources/ProgramLoader.cxx
@@ -53,27 +53,33 @@ namespace Boot
writer.Write("newosldr: Major Subsystem Ver: ").Write(optHdr->mMajorSubsystemVersion).Write("\r");
writer.Write("newosldr: Minor Subsystem Ver: ").Write(optHdr->mMinorSubsystemVersion).Write("\r");
writer.Write("newosldr: Magic: ").Write(hdrPtr->mSignature).Write("\r");
- writer.Write("newosldr: ImageBase: ").Write(optHdr->mImageBase).Write("\r");
constexpr auto cPageSize = 512;
EfiPhysicalAddress loadStartAddress = optHdr->mImageBase;
loadStartAddress += optHdr->mBaseOfData;
+ writer.Write("newosldr: ImageBase: ").Write(loadStartAddress).Write("\r");
+
auto numPages = optHdr->mSizeOfImage / cPageSize;
BS->AllocatePages(AllocateAddress, EfiLoaderData, numPages, &loadStartAddress);
ExecSectionHeaderPtr sectPtr = (ExecSectionHeaderPtr)(((Char*)optHdr) + hdrPtr->mSizeOfOptionalHeader);
+ constexpr auto sectionForCode = ".start";
+
for (SizeT sectIndex = 0; sectIndex < numSecs; ++sectIndex)
{
ExecSectionHeaderPtr sect = &sectPtr[sectIndex];
- if (strcmp(".text", sect->mName) == 0)
+ if (StrCmp(sectionForCode, sect->mName) == 0)
{
- fStartAddress = (VoidPtr)((UIntPtr)fBlob + sect->mVirtualAddress + optHdr->mAddressOfEntryPoint);
+ fStartAddress = (VoidPtr)((UIntPtr)loadStartAddress + sect->mVirtualAddress);
+ writer.Write("newosldr: Start Address: ").Write((UIntPtr)fStartAddress).Write("\r");
}
+ writer.Write("newosldr: offset ").Write(sect->mPointerToRawData).Write(" of ").Write(sect->mName).Write(".\r");
+
CopyMem((VoidPtr)(loadStartAddress + sect->mVirtualAddress), (VoidPtr)((UIntPtr)fBlob + sect->mPointerToRawData), sect->mSizeOfRawData);
}
@@ -81,8 +87,6 @@ namespace Boot
BS->AllocatePages(AllocateAddress, EfiLoaderData, 1, &start);
- writer.Write("newosldr: Start Address: ").Write((UIntPtr)fStartAddress).Write("\r");
-
// ================================ //
// Allocate stack.
// ================================ //
@@ -129,7 +133,7 @@ namespace Boot
err_fn(handover);
}
- rt_jump_to_address(reinterpret_cast<HEL::HandoverProc>(fStartAddress), handover, fStackPtr);
+ reinterpret_cast<HEL::HandoverProc>(fStartAddress)(handover);
err_fn(handover);
}
diff --git a/Kernel/HALKit/AMD64/HalBoot.asm b/Kernel/HALKit/AMD64/HalBoot.asm
index 6cd119ac..7bda9635 100644
--- a/Kernel/HALKit/AMD64/HalBoot.asm
+++ b/Kernel/HALKit/AMD64/HalBoot.asm
@@ -16,7 +16,7 @@
%define kArchAmd64 122
%define kHandoverMagic 0xBADCC
-section .newosldr
+section .ldr
HandoverMagic: dq kHandoverMagic
HandoverType: dw kTypeKernel
@@ -24,7 +24,7 @@ HandoverArch: dw kArchAmd64
;; This NewBootStart points to Main.
HandoverStart: dq hal_init_platform
-section .text
+section .start
[global ke_startup_platform]
diff --git a/Kernel/amd64-efi.make b/Kernel/amd64-efi.make
index bf41827b..3de2bf30 100644
--- a/Kernel/amd64-efi.make
+++ b/Kernel/amd64-efi.make
@@ -5,7 +5,7 @@
CC = x86_64-w64-mingw32-g++
LD = x86_64-w64-mingw32-ld
-CCFLAGS = -fshort-wchar -c -ffreestanding -fPIC -shared -D__NEWOS_AMD64__ -mno-red-zone -fno-rtti -fno-exceptions \
+CCFLAGS = -fshort-wchar -c -ffreestanding -shared -D__NEWOS_AMD64__ -mno-red-zone -fno-rtti -fno-exceptions \
-std=c++20 -D__NEWOS_SUPPORT_NX__ -I../Vendor -D__FSKIT_USE_NEWFS__ \
-D__NEWOSKRNL__ -D__HAVE_MAHROUSS_APIS__ -D__MAHROUSS__ -I./ -I../