diff options
Diffstat (limited to 'dev/kernel/FirmwareKit/EFI/API.h')
| -rw-r--r-- | dev/kernel/FirmwareKit/EFI/API.h | 112 |
1 files changed, 51 insertions, 61 deletions
diff --git a/dev/kernel/FirmwareKit/EFI/API.h b/dev/kernel/FirmwareKit/EFI/API.h index 87ab697b..0b937477 100644 --- a/dev/kernel/FirmwareKit/EFI/API.h +++ b/dev/kernel/FirmwareKit/EFI/API.h @@ -1,6 +1,6 @@ /* ------------------------------------------- - Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved. + Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved. ------------------------------------------- */ @@ -12,7 +12,7 @@ #include <KernelKit/MSDOS.h> #include <KernelKit/PE.h> -#define kNeWebsiteMacro "https://aker.com/help" +#define kNeWebsiteMacro "https://aker.com/help" #define kNeKernelSubsystem (StrLen(kNeWebsiteMacro)) #ifdef __BOOTZ__ @@ -23,79 +23,69 @@ class BootTextWriter; #include <BootKit/BootKit.h> #include <modules/CoreGfx/CoreGfx.h> -#endif // ifdef __BOOTZ__ +#endif // ifdef __BOOTZ__ -inline EfiSystemTable* ST = nullptr; +inline EfiSystemTable* ST = nullptr; inline EfiBootServices* BS = nullptr; EXTERN_C void rt_cli(); EXTERN_C void rt_hlt(); -namespace Boot -{ - /// @brief Halt and clear interrupts. - /// @return - inline Void Stop() noexcept - { - while (YES) - { - rt_cli(); - rt_hlt(); - } - } - - /** +namespace Boot { +/// @brief Halt and clear interrupts. +/// @return +inline Void Stop() noexcept { + while (YES) { + rt_cli(); + rt_hlt(); + } +} + +/** @brief Exit EFI API to let the OS load correctly. Bascially frees everything we have in the EFI side. */ - inline Void ExitBootServices(UInt64 MapKey, EfiHandlePtr ImageHandle) noexcept - { - if (!ST) - return; - - ST->BootServices->ExitBootServices(ImageHandle, MapKey); - } - - inline UInt32 Platform() noexcept - { - return kPeMachineAMD64; - } - - /*** - * @brief Throw an error, stop execution as well. - * @param ErrorCode error code to be print. - * @param Reason reason to be print. - */ - inline void ThrowError(const EfiCharType* ErrorCode, - const EfiCharType* Reason) noexcept - { - ST->ConOut->OutputString(ST->ConOut, L"\r*** STOP ***\r"); - - ST->ConOut->OutputString(ST->ConOut, L"*** ERROR: "); - ST->ConOut->OutputString(ST->ConOut, ErrorCode); - - ST->ConOut->OutputString(ST->ConOut, L" ***\r *** REASON: "); - ST->ConOut->OutputString(ST->ConOut, Reason); - - ST->ConOut->OutputString(ST->ConOut, L" ***\r"); - - Boot::Stop(); - } -} // namespace Boot - -inline void fw_init_efi(EfiSystemTable* SystemTable) noexcept -{ - if (!SystemTable) - return; - - ST = SystemTable; - BS = ST->BootServices; +inline Void ExitBootServices(UInt64 MapKey, EfiHandlePtr ImageHandle) noexcept { + if (!ST) return; + + ST->BootServices->ExitBootServices(ImageHandle, MapKey); +} + +inline UInt32 Platform() noexcept { + return kPeMachineAMD64; +} + +/*** + * @brief Throw an error, stop execution as well. + * @param ErrorCode error code to be print. + * @param Reason reason to be print. + */ +inline void ThrowError(const EfiCharType* ErrorCode, const EfiCharType* Reason) noexcept { + ST->ConOut->OutputString(ST->ConOut, L"\r*** STOP ***\r"); + + ST->ConOut->OutputString(ST->ConOut, L"*** ERROR: "); + ST->ConOut->OutputString(ST->ConOut, ErrorCode); + + ST->ConOut->OutputString(ST->ConOut, L" ***\r *** REASON: "); + ST->ConOut->OutputString(ST->ConOut, Reason); + + ST->ConOut->OutputString(ST->ConOut, L" ***\r"); + + Boot::Stop(); +} +} // namespace Boot + +inline void fw_init_efi(EfiSystemTable* SystemTable) noexcept { + if (!SystemTable) return; + + ST = SystemTable; + BS = ST->BootServices; } #ifdef __BOOTZ__ #include <BootKit/Platform.h> -#endif // ifdef __BOOTZ__ +#endif // ifdef __BOOTZ__ #endif /* ifndef __EFI_API__ */ |
