summaryrefslogtreecommitdiffhomepage
path: root/dev/ZBAKit
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-12-01 18:41:41 +0100
committerAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-12-01 18:41:41 +0100
commitf83e7bddcf24433adbfc9214e0f8f8139f8b6362 (patch)
tree0447eddc2ebff291f96286847c238b4f907515b1 /dev/ZBAKit
parentc62790f8f773a2f10464d2b1e0e286f2b3156712 (diff)
FIX: Fixing ARM64 execution when booting from bootloader.
FIX: Now works both for ARM64 and AMD64 EFI backends. TODO: The ACB backend needs to be done too. Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'dev/ZBAKit')
-rw-r--r--dev/ZBAKit/BootKit/Support.h14
-rw-r--r--dev/ZBAKit/arm64-efi.make2
-rw-r--r--dev/ZBAKit/src/HEL/ARM64/BootAPI.S12
-rw-r--r--dev/ZBAKit/src/HEL/ARM64/BootMain.cc14
4 files changed, 26 insertions, 16 deletions
diff --git a/dev/ZBAKit/BootKit/Support.h b/dev/ZBAKit/BootKit/Support.h
index 1ee1dc47..2c1db6f4 100644
--- a/dev/ZBAKit/BootKit/Support.h
+++ b/dev/ZBAKit/BootKit/Support.h
@@ -6,13 +6,11 @@
#pragma once
-#include <cstddef>
-
/// @file Support.h
/// @brief Purpose of this file is to help port libs into the bootloader.
-#define cLongMax ((long)(~0UL >> 1))
-#define cLongMin (~cLongMax)
+#define kLongMax ((long)(~0UL >> 1))
+#define kLongMin (~kLongMax)
#ifdef __NEWOSLDR__
@@ -65,7 +63,7 @@ inline long StringToLong(const char* nptr, char** endptr, int base)
const char *p = nptr, *endp;
bool is_neg = 0, overflow = 0;
- /* Need unsigned so (-cLongMin) can fit in these: */
+ /* Need unsigned so (-kLongMin) can fit in these: */
unsigned long n = 0UL, cutoff;
int cutlim;
@@ -124,8 +122,8 @@ inline long StringToLong(const char* nptr, char** endptr, int base)
base = 10;
}
- cutoff = (is_neg) ? -(cLongMin / base) : cLongMax / base;
- cutlim = (is_neg) ? -(cLongMin % base) : cLongMax % base;
+ cutoff = (is_neg) ? -(kLongMin / base) : kLongMax / base;
+ cutlim = (is_neg) ? -(kLongMin % base) : kLongMax % base;
while (1)
{
@@ -160,7 +158,7 @@ inline long StringToLong(const char* nptr, char** endptr, int base)
if (overflow)
{
- return ((is_neg) ? cLongMin : cLongMax);
+ return ((is_neg) ? kLongMin : kLongMax);
}
return (long)((is_neg) ? -n : n);
diff --git a/dev/ZBAKit/arm64-efi.make b/dev/ZBAKit/arm64-efi.make
index db805848..12aae5f8 100644
--- a/dev/ZBAKit/arm64-efi.make
+++ b/dev/ZBAKit/arm64-efi.make
@@ -46,7 +46,7 @@ REM_FLAG=-f
FLAG_ASM=-f win64
FLAG_GNU=-fshort-wchar -c -ffreestanding -MMD -mno-red-zone -D__ZKA_ARM64__ -fno-rtti -fno-exceptions -I./ \
-target aarch64-unknown-windows \
- -std=c++20 -D__FSKIT_USE_NEFS__ -D__STANDALONE__ -D__MINOSKRNL__ -D__NEWOSLDR__ -D__HAVE_ZKA_APIS__ -D__ZKA__ -I../ -I../zka
+ -std=c++20 -D__FSKIT_USE_NEFS__ -D__STANDALONE__ -D__MINOSKRNL__ -D__NEWOSLDR__ -D__HAVE_ZKA_APIS__ -D__ZKA__ -I../ -I../ZKAKit
BOOT_LOADER=zbaosldr.exe
KERNEL=minoskrnl.exe
diff --git a/dev/ZBAKit/src/HEL/ARM64/BootAPI.S b/dev/ZBAKit/src/HEL/ARM64/BootAPI.S
new file mode 100644
index 00000000..9a53dfc9
--- /dev/null
+++ b/dev/ZBAKit/src/HEL/ARM64/BootAPI.S
@@ -0,0 +1,12 @@
+.global rt_jump_to_address
+
+.text
+
+/**
+ @brief this function setups a stack and then jumps to
+ a function */
+rt_jump_to_address:
+ mov x19, x0
+ mov sp, x2
+ br x19
+
diff --git a/dev/ZBAKit/src/HEL/ARM64/BootMain.cc b/dev/ZBAKit/src/HEL/ARM64/BootMain.cc
index 1d3d9150..99e321ee 100644
--- a/dev/ZBAKit/src/HEL/ARM64/BootMain.cc
+++ b/dev/ZBAKit/src/HEL/ARM64/BootMain.cc
@@ -9,12 +9,12 @@
#include <BootKit/Thread.h>
#include <BootKit/BootKit.h>
-#ifndef cExpectedWidth
-#define cExpectedWidth 844
+#ifndef kExpectedWidth
+#define kExpectedWidth 844
#endif
-#ifndef cExpectedHeight
-#define cExpectedHeight 390
+#ifndef kExpectedHeight
+#define kExpectedHeight 390
#endif
EXTERN EfiBootServices* BS;
@@ -52,8 +52,8 @@ EFI_EXTERN_C EFI_API Int32 Main(EfiHandlePtr ImageHandle,
writer.Write(infoPtr->VerticalResolution);
writer.Write("\r");
- if (infoPtr->HorizontalResolution == cExpectedWidth &&
- infoPtr->VerticalResolution == cExpectedHeight)
+ if (infoPtr->HorizontalResolution == kExpectedWidth &&
+ infoPtr->VerticalResolution == kExpectedHeight)
{
kGop->SetMode(kGop, i);
break;
@@ -69,7 +69,7 @@ EFI_EXTERN_C EFI_API Int32 Main(EfiHandlePtr ImageHandle,
auto kernel_thread = Boot::BThread(reader_kernel.Blob());
if (kernel_thread.IsValid())
- kernel_thread.Start(nullptr);
+ kernel_thread.Start(nullptr, YES);
}
CANT_REACH();