diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2025-05-02 19:38:46 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-05-02 19:38:46 +0200 |
| commit | 997be16e5ac9a68d54882ab69529815860d62955 (patch) | |
| tree | 19d6129c2d776bb1edc5d4a7325e39ca176c3403 /dev/kernel/FirmwareKit/EFI/API.h | |
| parent | 618104e74c195d7508a18450524f8ed7f9af8cc6 (diff) | |
| parent | b3b4b1ebdcd6adeac914869017c86d892b7a8ced (diff) | |
Merge pull request #28 from nekernel-org/dev
0.0.2
Diffstat (limited to 'dev/kernel/FirmwareKit/EFI/API.h')
| -rw-r--r-- | dev/kernel/FirmwareKit/EFI/API.h | 122 |
1 files changed, 53 insertions, 69 deletions
diff --git a/dev/kernel/FirmwareKit/EFI/API.h b/dev/kernel/FirmwareKit/EFI/API.h index f3b03bb5..47b9e4d1 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,85 +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(); - } - } - - /** +EXTERN_C void rt_halt(); + +namespace Boot { +/// @brief Halt and clear interrupts. +/// @return +inline Void Stop() noexcept { + while (YES) { + rt_cli(); + rt_halt(); + } +} + +/** @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; - - ST->ConOut->ClearScreen(SystemTable->ConOut); - ST->ConOut->SetAttribute(SystemTable->ConOut, kEFIYellow); - - ST->BootServices->SetWatchdogTimer(0, 0, 0, nullptr); - ST->ConOut->EnableCursor(ST->ConOut, false); +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__ */ |
