diff options
| author | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-01-28 21:43:49 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-01-28 21:44:02 +0100 |
| commit | dbe7795edd9c814a5c993941c961f6b26e249e43 (patch) | |
| tree | f13e408f22a6f0beb2721004717af70973ea4424 /Private/NewBoot/Source | |
| parent | f06d0703a5813841f5a6dacd294c5cfbe9394037 (diff) | |
Kernel: Replace gnu-efi with EFIKit.
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'Private/NewBoot/Source')
| -rw-r--r-- | Private/NewBoot/Source/HEL/AMD64/BootAMD64.cxx | 29 | ||||
| -rw-r--r-- | Private/NewBoot/Source/HEL/AMD64/EFIApi.hxx | 15 | ||||
| -rw-r--r-- | Private/NewBoot/Source/HEL/AMD64/EFIApiCrt0.cxx | 23 | ||||
| -rw-r--r-- | Private/NewBoot/Source/HEL/AMD64/EfiApi.cxx | 51 | ||||
| -rw-r--r-- | Private/NewBoot/Source/makefile | 12 |
5 files changed, 23 insertions, 107 deletions
diff --git a/Private/NewBoot/Source/HEL/AMD64/BootAMD64.cxx b/Private/NewBoot/Source/HEL/AMD64/BootAMD64.cxx index daaa62ec..39f8761e 100644 --- a/Private/NewBoot/Source/HEL/AMD64/BootAMD64.cxx +++ b/Private/NewBoot/Source/HEL/AMD64/BootAMD64.cxx @@ -9,9 +9,9 @@ #include <BootKit/Boot.hpp> -#define kVGABaseAddress 0xb8000 +constexpr hCore::UInt32 kVGABaseAddress = 0xb8000; -long long int BStrLen(const char* ptr) +long long int BStrLen(const char *ptr) { long long int cnt = 0; while (*ptr != 0) @@ -23,15 +23,12 @@ long long int BStrLen(const char* ptr) return cnt; } -void BKTextWriter::WriteString( - const char* str, - unsigned char forecolour, - unsigned char backcolour, - int x, - int y) +/** +@brief puts wrapper over VGA. +*/ +void BKTextWriter::WriteString(const char *str, unsigned char forecolour, unsigned char backcolour, int x, int y) { - if (*str == 0 || - !str) + if (*str == 0 || !str) return; for (SizeT idx = 0; idx < BStrLen(str); ++idx) @@ -41,12 +38,10 @@ void BKTextWriter::WriteString( } } -void BKTextWriter::WriteCharacter( - char c, - unsigned char forecolour, - unsigned char backcolour, - int x, - int y) +/** +@brief putc wrapper over VGA. +*/ +void BKTextWriter::WriteCharacter(char c, unsigned char forecolour, unsigned char backcolour, int x, int y) { UInt16 attrib = (backcolour << 4) | (forecolour & 0x0F); @@ -55,6 +50,6 @@ void BKTextWriter::WriteCharacter( // Decodes UInt16, gets attributes (back colour, fore colour) // Gets character, send it to video display with according colour in the registry. - fWhere = (volatile UInt16*)kVGABaseAddress + (y * 80 + x); + fWhere = (volatile UInt16 *)kVGABaseAddress + (y * 80 + x); *fWhere = c | (attrib << 8); } diff --git a/Private/NewBoot/Source/HEL/AMD64/EFIApi.hxx b/Private/NewBoot/Source/HEL/AMD64/EFIApi.hxx index d6bde7aa..4868fa00 100644 --- a/Private/NewBoot/Source/HEL/AMD64/EFIApi.hxx +++ b/Private/NewBoot/Source/HEL/AMD64/EFIApi.hxx @@ -9,20 +9,7 @@ #pragma once -#include <efi.h> -#include <efilib.h> - -/// @brief auto-mount and boots from a bootable drive. -/// does not return on success. -void newboot_mount_drive(const char *name); -void newboot_boot_file(const char *path); - -/// @brief initializes epm library. -void newboot_init_epm(EFI_HANDLE pImage); - -/// @brief frees the epm library, called when newboot_auto_mount/newboot_boot_file -/// succeeds. -void newboot_fini_epm(void); +#include <EFIKit/EFI.hxx> namespace HEL { diff --git a/Private/NewBoot/Source/HEL/AMD64/EFIApiCrt0.cxx b/Private/NewBoot/Source/HEL/AMD64/EFIApiCrt0.cxx index 656326a9..2044c3fd 100644 --- a/Private/NewBoot/Source/HEL/AMD64/EFIApiCrt0.cxx +++ b/Private/NewBoot/Source/HEL/AMD64/EFIApiCrt0.cxx @@ -9,25 +9,8 @@ #include "EFIApi.hxx" -#define main efi_main - -typedef EFI_STATUS (*EfiMainType)(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable); - -EFI_STATUS main(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) +extern "C" int EfiMain(void *ImageHandle, EfiSystemTable *SystemTable) { - InitializeLib(ImageHandle, SystemTable); - Print(L"NewBoot: Booting from EPM...\r\n"); - - // init - newboot_init_epm(ImageHandle); - - //! these two should execute a program if any on it. - newboot_mount_drive("epm:///system/"); - - // bye - newboot_fini_epm(); - - Print(L"NewBoot: No auto-mount found.\r\n"); - - return EFI_LOAD_ERROR; + SystemTable->conOut->output_string(SystemTable->conOut, L"HCORELDR: Preparing Handover structure...\r\n"); + return 0; } diff --git a/Private/NewBoot/Source/HEL/AMD64/EfiApi.cxx b/Private/NewBoot/Source/HEL/AMD64/EfiApi.cxx deleted file mode 100644 index 1728f14b..00000000 --- a/Private/NewBoot/Source/HEL/AMD64/EfiApi.cxx +++ /dev/null @@ -1,51 +0,0 @@ -/* - * ======================================================== - * - * NewBoot - * Copyright 2024 Mahrouss Logic, all rights reserved. - * - * ======================================================== - */ - -#include "EFIApi.hxx" -#include "PartitionMap.hxx" - -EFI_FILE_HANDLE kVolume = nullptr; -BootBlockType *kBootFolder = nullptr; -PartitionBlockType *kPartitionFolder = nullptr; - -void newboot_init_epm(EFI_HANDLE image) -{ - EFI_LOADED_IMAGE *loaded_image = NULL; /* image interface */ - EFI_GUID lipGuid = EFI_LOADED_IMAGE_PROTOCOL_GUID; /* image interface GUID */ - EFI_FILE_IO_INTERFACE *IOVolume; /* file system interface */ - EFI_GUID fsGuid = EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID; /* file system interface GUID */ - EFI_FILE_HANDLE Volume; /* the volume's interface */ - - /* get the loaded image protocol interface for our "image" */ - uefi_call_wrapper((void *)BS->HandleProtocol, 3, image, &lipGuid, (void **)&loaded_image); - /* get the volume handle */ - uefi_call_wrapper((void *)BS->HandleProtocol, 3, loaded_image->DeviceHandle, &fsGuid, (VOID *)&IOVolume); - uefi_call_wrapper((void *)IOVolume->OpenVolume, 2, IOVolume, &Volume); - - kVolume = Volume; - - kBootFolder = (BootBlockType *)AllocatePool(sizeof(BootBlockType)); - kPartitionFolder = (PartitionBlockType *)AllocatePool(sizeof(PartitionBlockType)); -} - -/** - * @brief fini the EPM library. - * Cleans up the memory we claimed and sets the fields to null pointer. - */ -void newboot_fini_epm() -{ - uefi_call_wrapper((void *)kVolume->Close, 1, kVolume); - kVolume = nullptr; - - FreePool(kBootFolder); - kBootFolder = nullptr; - - FreePool(kPartitionFolder); - kPartitionFolder = nullptr; -} diff --git a/Private/NewBoot/Source/makefile b/Private/NewBoot/Source/makefile index 25eb7983..e0ee861d 100644 --- a/Private/NewBoot/Source/makefile +++ b/Private/NewBoot/Source/makefile @@ -1,15 +1,17 @@ -# (C) Mahrouss Logic, 2024, all rights reserved. +################################################## +# ; (C) Mahrouss Logic, 2024, all rights reserved. +################################################## CC_GNU=x86_64-w64-mingw32-g++ LD_GNU=x86_64-w64-mingw32-ld -FLAG_GNU=-I../ -I../../ -I../../efiSDK/inc -I./ -c -fPIC -ffreestanding -fno-rtti -fno-exceptions -std=c++20 -D__HAVE_HCORE_APIS__ -D__hCore__ -I./ -I$(HOME)/ +FLAG_GNU=-fshort-wchar -fPIC -D__DBG__ -DEFI_FUNCTION_WRAPPER -I../ -I../../ -I../../efiSDK/inc -I./ -c -ffreestanding -fno-rtti -fno-exceptions -std=c++20 -D__HAVE_HCORE_APIS__ -D__hCore__ -I./ -I$(HOME)/ .PHONY: arch-amd64 arch-amd64: - $(CC_GNU) $(FLAG_GNU) -D__DBG__ HEL/AMD64/*.cxx - $(LD_GNU) *.o --script=../../efiSDK/gnuefi/coff_x86_64_efi.lds ../../efiSDK/x86_64/gnuefi/crt0-efi-x86_64.o \ - --subsystem=10 ../../efiSDK/x86_64/gnuefi/reloc_x86_64.o -L../../efiSDK/x86_64/gnuefi/ -lgnuefi -o HCORELDR.EXE + $(CC_GNU) $(FLAG_GNU) HEL/AMD64/*.cxx + $(LD_GNU) *.o -filealign:16 --subsystem=10 -ffreestanding -shared -o HCORELDR.EXE + .PHONY: clean clean: |
