diff options
| author | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-10-12 19:20:29 +0200 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-10-12 19:20:29 +0200 |
| commit | c7b637d7b68d9b7e271e70a5a5cc0c4fcf9172de (patch) | |
| tree | 2d297a7250978efa7a81e101232f62254892f94b /dev/zba/src | |
| parent | 3347073aaa031b71e5063192f0806d83e9021c34 (diff) | |
IMP: Porting stack to AARCH64.
- Bootloader and kernel were made to be ported to mulitple
platforms.
- Some part of the stack have to be written specifically
for the platform though.
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'dev/zba/src')
| -rw-r--r-- | dev/zba/src/BootFileReader.cxx (renamed from dev/zba/src/HEL/AMD64/BootFileReader.cxx) | 0 | ||||
| -rw-r--r-- | dev/zba/src/BootString.cxx (renamed from dev/zba/src/HEL/AMD64/BootString.cxx) | 0 | ||||
| -rw-r--r-- | dev/zba/src/BootSupport.cxx (renamed from dev/zba/src/HEL/AMD64/Support.cxx) | 6 | ||||
| -rw-r--r-- | dev/zba/src/BootTextWriter.cxx (renamed from dev/zba/src/HEL/AMD64/BootTextWriter.cxx) | 0 | ||||
| -rw-r--r-- | dev/zba/src/HEL/AMD64/BootMain.cxx | 50 | ||||
| -rw-r--r-- | dev/zba/src/HEL/AMD64/BootPlatform.cxx | 3 | ||||
| -rw-r--r-- | dev/zba/src/HEL/ARM64/BootMain.cxx | 20 | ||||
| -rw-r--r-- | dev/zba/src/HEL/ARM64/BootPlatform.cxx | 40 | ||||
| -rw-r--r-- | dev/zba/src/New+Delete.cxx (renamed from dev/zba/src/HEL/AMD64/New+Delete.cxx) | 2 | ||||
| -rw-r--r-- | dev/zba/src/Thread.cxx | 10 |
10 files changed, 90 insertions, 41 deletions
diff --git a/dev/zba/src/HEL/AMD64/BootFileReader.cxx b/dev/zba/src/BootFileReader.cxx index e81ba3fb..e81ba3fb 100644 --- a/dev/zba/src/HEL/AMD64/BootFileReader.cxx +++ b/dev/zba/src/BootFileReader.cxx diff --git a/dev/zba/src/HEL/AMD64/BootString.cxx b/dev/zba/src/BootString.cxx index 1c109b80..1c109b80 100644 --- a/dev/zba/src/HEL/AMD64/BootString.cxx +++ b/dev/zba/src/BootString.cxx diff --git a/dev/zba/src/HEL/AMD64/Support.cxx b/dev/zba/src/BootSupport.cxx index aa93318b..bab53c2c 100644 --- a/dev/zba/src/HEL/AMD64/Support.cxx +++ b/dev/zba/src/BootSupport.cxx @@ -74,9 +74,7 @@ EXTERN_C int strcmp(const char* whatToCheck, const char* whatToCheckRight) return len; } -/// @brief somthing specific to the Microsoft's ABI, When the stack grows too big. -EXTERN_C void ___chkstk_ms(void) -{ -} +/// @brief something specific to the Microsoft's ABI, When the stack grows too big. +EXTERN_C void ___chkstk_ms(void) {} #endif diff --git a/dev/zba/src/HEL/AMD64/BootTextWriter.cxx b/dev/zba/src/BootTextWriter.cxx index b0679715..b0679715 100644 --- a/dev/zba/src/HEL/AMD64/BootTextWriter.cxx +++ b/dev/zba/src/BootTextWriter.cxx diff --git a/dev/zba/src/HEL/AMD64/BootMain.cxx b/dev/zba/src/HEL/AMD64/BootMain.cxx index 8f8c45d1..3c5e80a3 100644 --- a/dev/zba/src/HEL/AMD64/BootMain.cxx +++ b/dev/zba/src/HEL/AMD64/BootMain.cxx @@ -5,11 +5,9 @@ ------------------------------------------- */ #include <BootKit/BootKit.hxx> -#include <BootKit/Rsrc/NewBoot.rsrc> #include <modules/FB/FB.hxx> #include <modules/FB/Text.hxx> #include <FirmwareKit/EFI.hxx> -#include <FirmwareKit/EFI/API.hxx> #include <FirmwareKit/Handover.hxx> #include <KernelKit/MSDOS.hxx> #include <KernelKit/PE.hxx> @@ -17,7 +15,6 @@ #include <NewKit/Macros.hxx> #include <NewKit/Ref.hxx> #include <BootKit/Thread.hxx> -#include <cstring> // make the compiler shut up. #ifndef kMachineModel @@ -71,14 +68,6 @@ STATIC Void InitVideoFB() noexcept } } -/// @brief check the BootDevice if suitable. -STATIC Bool CheckBootDevice(BootDeviceATA& ataDev) -{ - if (ataDev.Leak().mErr) - return false; - return true; -} - EXTERN_C VoidPtr boot_read_cr3(); EXTERN_C Void boot_write_cr3(VoidPtr new_cr3); @@ -88,21 +77,23 @@ EXTERN EfiBootServices* BS; /// @param ImageHandle Handle of this image. /// @param SystemTable The system table of it. /// @return nothing, never returns. -EFI_EXTERN_C EFI_API Int Main(EfiHandlePtr ImageHandle, +EFI_EXTERN_C EFI_API Int32 Main(EfiHandlePtr ImageHandle, EfiSystemTable* SystemTable) { InitEFI(SystemTable); ///! Init the EFI library. - InitVideoFB(); ///! Init the GOP. - - UInt32 MapKey = 0; - UInt32 SizePtr = sizeof(EfiMemoryDescriptor); - EfiMemoryDescriptor* Descriptor = nullptr; - UInt32 SzDesc = sizeof(EfiMemoryDescriptor); - UInt32 RevDesc = 0; HEL::HANDOVER_INFO_HEADER* handover_hdr = new HEL::HANDOVER_INFO_HEADER(); + UInt32 map_key = 0; + UInt32 size_struct_ptr = sizeof(EfiMemoryDescriptor); + EfiMemoryDescriptor* struct_ptr = nullptr; + UInt32 sz_desc = sizeof(EfiMemoryDescriptor); + UInt32 rev_desc = 0; + +#ifdef __ZKA_USE_FB__ + InitVideoFB(); ///! Init the GOP. + for (SizeT indexVT = 0; indexVT < SystemTable->NumberOfTableEntries; ++indexVT) { @@ -130,6 +121,7 @@ EFI_EXTERN_C EFI_API Int Main(EfiHandlePtr ImageHandle, handover_hdr->f_GOP.f_PixelPerLine = kGop->Mode->Info->PixelsPerScanLine; handover_hdr->f_GOP.f_PixelFormat = kGop->Mode->Info->PixelFormat; handover_hdr->f_GOP.f_Size = kGop->Mode->FrameBufferSize; +#endif // __ZKA_USE_FB__ // ------------------------------------------- // // Grab MP services, extended to runtime. // @@ -144,17 +136,21 @@ EFI_EXTERN_C EFI_API Int Main(EfiHandlePtr ImageHandle, kHandoverHeader = handover_hdr; +#ifdef __ZKA_USE_FB__ CGInit(); CGDrawInRegion(CGColor(0xFF, 0x3A, 0x3A), handover_hdr->f_GOP.f_Height, handover_hdr->f_GOP.f_Width, 0, 0); CGFini(); +#endif // __ZKA_USE_FB__ UInt32 cnt_enabled = 0; UInt32 cnt_disabled = 0; mp->GetNumberOfProcessors(mp, &cnt_disabled, &cnt_enabled); +#ifdef __ZKA_USE_FB__ CGDrawString("NEWOSLDR (C) ZKA TECHNOLOGIES.", 10, 10, RGB(0xFF, 0xFF, 0xFF)); CGDrawString((cnt_enabled > 1) ? "MULTIPLE PROCESSORS DETECTED." : "SINGLE PROCESSOR DETECTED.", 20, 10, RGB(0xFF, 0xFF, 0xFF)); +#endif // __ZKA_USE_FB__ handover_hdr->f_HardwareTables.f_MultiProcessingEnabled = cnt_enabled > 1; // Fill handover header now. @@ -180,10 +176,10 @@ EFI_EXTERN_C EFI_API Int Main(EfiHandlePtr ImageHandle, rt_reset_hardware(); } - BS->GetMemoryMap(&SizePtr, Descriptor, &MapKey, &SzDesc, &RevDesc); + BS->GetMemoryMap(&size_struct_ptr, struct_ptr, &map_key, &sz_desc, &rev_desc); - Descriptor = new EfiMemoryDescriptor[SzDesc]; - BS->GetMemoryMap(&SizePtr, Descriptor, &MapKey, &SzDesc, &RevDesc); + struct_ptr = new EfiMemoryDescriptor[sz_desc]; + BS->GetMemoryMap(&size_struct_ptr, struct_ptr, &map_key, &sz_desc, &rev_desc); auto cDefaultMemoryMap = 0; // Grab any usable entries. @@ -193,7 +189,7 @@ EFI_EXTERN_C EFI_API Int Main(EfiHandlePtr ImageHandle, SizeT lookIndex = 0UL; - for (; Descriptor[lookIndex].Kind != EfiMemoryType::EfiConventionalMemory; ++lookIndex) + for (; struct_ptr[lookIndex].Kind != EfiMemoryType::EfiConventionalMemory; ++lookIndex) { ZKA_UNUSED(0); } @@ -274,7 +270,9 @@ EFI_EXTERN_C EFI_API Int Main(EfiHandlePtr ImageHandle, } else { +#ifdef __ZKA_USE_FB__ CGDrawString("NEWOSLDR: PLEASE RECOVER YOUR MINKRNL IMAGE.", 30, 10, RGB(0xFF, 0xFF, 0xFF)); +#endif // __ZKA_USE_FB__ } Boot::BFileReader chimeWav(L"zka\\startup.wav", ImageHandle); @@ -300,13 +298,17 @@ EFI_EXTERN_C EFI_API Int Main(EfiHandlePtr ImageHandle, } else { +#ifdef __ZKA_USE_FB__ CGDrawString("NEWOSLDR: ONE OR MORE SYSTEM COMPONENTS ARE MISSING, PLEASE REFORMAT THE OS.", 30, 10, RGB(0xFF, 0xFF, 0xFF)); +#endif // __ZKA_USE_FB__ } - EFI::ExitBootServices(MapKey, ImageHandle); + EFI::ExitBootServices(map_key, ImageHandle); +#ifdef __ZKA_USE_FB__ CGDrawInRegion(CGColor(0xFF, 0x3A, 0x3A), handover_hdr->f_GOP.f_Height, handover_hdr->f_GOP.f_Width, 0, 0); CGFini(); +#endif // __ZKA_USE_FB__ // ---------------------------------------------------- // // Finally load Kernel, and the cr3 to it. diff --git a/dev/zba/src/HEL/AMD64/BootPlatform.cxx b/dev/zba/src/HEL/AMD64/BootPlatform.cxx index 31566a95..ff863a57 100644 --- a/dev/zba/src/HEL/AMD64/BootPlatform.cxx +++ b/dev/zba/src/HEL/AMD64/BootPlatform.cxx @@ -1,3 +1,4 @@ + /* ------------------------------------------- Copyright ZKA Technologies. @@ -102,4 +103,4 @@ void rt_hlt() Kernel::HAL::rt_halt(); } -#endif // 0 +#endif // __STANDALONE__ diff --git a/dev/zba/src/HEL/ARM64/BootMain.cxx b/dev/zba/src/HEL/ARM64/BootMain.cxx new file mode 100644 index 00000000..ff26b14c --- /dev/null +++ b/dev/zba/src/HEL/ARM64/BootMain.cxx @@ -0,0 +1,20 @@ +/* ------------------------------------------- + + Copyright ZKA Technologies. + +------------------------------------------- */ + +#include <FirmwareKit/EFI.hxx> + +EXTERN EfiBootServices* BS; + +/// @brief Main EFI entrypoint. +/// @param ImageHandle Handle of this image. +/// @param SystemTable The system table of it. +/// @return nothing, never returns. +EFI_EXTERN_C EFI_API Int32 Main(EfiHandlePtr ImageHandle, + EfiSystemTable* SystemTable) +{ + + return 0; +} diff --git a/dev/zba/src/HEL/ARM64/BootPlatform.cxx b/dev/zba/src/HEL/ARM64/BootPlatform.cxx new file mode 100644 index 00000000..fba4b61c --- /dev/null +++ b/dev/zba/src/HEL/ARM64/BootPlatform.cxx @@ -0,0 +1,40 @@ +/* ------------------------------------------- + + Copyright ZKA Technologies. + +------------------------------------------- */ + +#include <BootKit/Platform.hxx> +#include <BootKit/Protocol.hxx> +#include <BootKit/BootKit.hxx> + +#ifdef __STANDALONE__ + +using namespace Boot; + +EXTERN_C void rt_hlt() +{ + while (Yes); +} + +EXTERN_C void rt_cli() +{ + +} + +EXTERN_C void rt_sti() +{ + +} + +EXTERN_C void rt_cld() +{ + +} + +EXTERN_C void rt_std() +{ + +} + +#endif // __STANDALONE__ diff --git a/dev/zba/src/HEL/AMD64/New+Delete.cxx b/dev/zba/src/New+Delete.cxx index 4a308f94..7240875a 100644 --- a/dev/zba/src/HEL/AMD64/New+Delete.cxx +++ b/dev/zba/src/New+Delete.cxx @@ -9,8 +9,6 @@ #include <BootKit/BootKit.hxx> #ifdef __STANDALONE__ -#include <cstddef> /* Since we're using GCC for this EFI program. */ - EXTERN EfiBootServices* BS; /// @brief Allocates a new object. diff --git a/dev/zba/src/Thread.cxx b/dev/zba/src/Thread.cxx index b19894a9..2383d675 100644 --- a/dev/zba/src/Thread.cxx +++ b/dev/zba/src/Thread.cxx @@ -15,14 +15,6 @@ #include <CFKit/LoaderUtils.hxx> #include <modules/FB/Text.hxx> -EXTERN_C -{ -#include <string.h> - - Void - rt_jump_to_address(VoidPtr start, VoidPtr handover); -} - // External boot services symbol. EXTERN EfiBootServices* BS; @@ -161,8 +153,6 @@ namespace Boot err_fn(handover); } - rt_jump_to_address(fStartAddress, handover); - reinterpret_cast<HEL::HandoverProc>(fStartAddress)(handover); } |
