diff options
| author | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-01-29 15:14:37 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-01-29 15:14:37 +0100 |
| commit | b89b9bc8ec4955f3eef3d34a4c917ace0a5cf2d9 (patch) | |
| tree | 4d82f613f7e2fbb306fb9ab8b86506b4334ebeee /Private/EFIKit | |
| parent | e8af9b5cdc8efd7eee7a53c6fd78918fa2b0a810 (diff) | |
Bootloader: Add support for Boot Services.
Kernel: Did refactor to code in Drive Manager, XPM has become EPM.
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'Private/EFIKit')
| -rw-r--r-- | Private/EFIKit/EFI.hxx | 136 | ||||
| -rw-r--r-- | Private/EFIKit/EPM.hxx | 8 |
2 files changed, 105 insertions, 39 deletions
diff --git a/Private/EFIKit/EFI.hxx b/Private/EFIKit/EFI.hxx index fac59f8b..fd4e31aa 100644 --- a/Private/EFIKit/EFI.hxx +++ b/Private/EFIKit/EFI.hxx @@ -7,7 +7,8 @@ * ======================================================== */ -#pragma once +#ifndef __EFI__ +#define __EFI__ /** @brief HCore Implementation of UEFI protocols. @@ -17,12 +18,15 @@ using namespace hCore; +typedef VoidPtr EfiHandlePtr; + struct EfiTableHeader; struct EfiLoadFileProtocol; struct EfiSimpleTextOutputProtocol; struct EfiDevicePathProtocol; +struct EfiBootServices; -/// What's boot policy? +/// What's BootBolicy? /// If TRUE, indicates that the request originates from the boot manager, and that the boot manager is attempting to /// load FilePath as a boot selection. If FALSE, then FilePath must match an exact file to be loaded. @@ -113,64 +117,124 @@ typedef enum EfiMemoryType EfiMaxMemoryType, } EfiMemoryType; -typedef UInt64 (*EfiAllocatePool)(EfiMemoryType PoolType, UInt32 Size, Void **Buffer); -typedef UInt64 (*EfiFreePool)(Void *Buffer); +typedef UInt64 (*EfiAllocatePool)(EfiMemoryType PoolType, UInt32 Size, VoidPtr *Buffer); +typedef UInt64 (*EfiFreePool)(VoidPtr Buffer); typedef struct EfiTableHeader { - UInt64 signature; - UInt32 revision; - UInt32 headerSize; - UInt32 crc32; - UInt32 reserved; + UInt64 Signature; + UInt32 Revision; + UInt32 HeaderSize; + UInt32 Crc32; + UInt32 Reserved; } EfiTableHeader; typedef struct EfiLoadFileProtocol { - EfiLoadFile loadFile; + EfiLoadFile LoadFile; } EfiLoadFileProtocol; typedef struct EfiDevicePathProtocol { - UInt8 type; - UInt8 subType; - UInt8 lenData[2]; + UInt8 Type; + UInt8 SubType; + UInt8 LengthData[2]; } EfiDevicePathProtocol; +typedef UInt64 (*EfiExitBootServices)(VoidPtr ImageHandle, UInt32 MapKey); + +/** +@name EfiBootServices +@brief UEFI Boot Services record, it contains functions necessary to a firmware level application. +*/ +typedef struct EfiBootServices +{ + EfiTableHeader SystemTable; + UIntPtr RaiseTPL; + UIntPtr RestoreTPL; + UIntPtr AllocatePages; + UIntPtr FreePages; + UIntPtr GetMemoryMap; + EfiAllocatePool AllocatePool; + EfiFreePool FreePool; + UIntPtr CreateEvent; + UIntPtr SetTimer; + UIntPtr WaitForEvent; + UIntPtr SignalEvent; + UIntPtr CloseEvent; + UIntPtr CheckEvent; + UIntPtr InstallProtocolInterface; + UIntPtr ReinstallProtocolInterface; + UIntPtr UninstallProtocolInterface; + UIntPtr HandleProtocol; + VoidPtr Reserved; + UIntPtr RegisterProtocolNotify; + UIntPtr LocateHandle; + UIntPtr LocateDevicePath; + UIntPtr InstallConfigurationTable; + UIntPtr LoadImage; + UIntPtr StartImage; + UIntPtr Exit; + UIntPtr UnloadImage; + EfiExitBootServices ExitBootServices; + UIntPtr GetNextMonotonicCount; + UIntPtr Stall; + UIntPtr SetWatchdogTimer; + UIntPtr ConnectController; + UIntPtr DisconnectController; + UIntPtr OpenProtocol; + UIntPtr CloseProtocol; + UIntPtr OpenProtocolInformation; + UIntPtr ProtocolsPerHandle; + UIntPtr LocateHandleBuffer; + UIntPtr LocateProtocol; + UIntPtr InstallMultipleProtocolInterfaces; + UIntPtr UninstallMultipleProtocolInterfaces; + UIntPtr CalculateCrc32; + UIntPtr CopyMem; + UIntPtr SetMem; + UIntPtr CreateEventEx; +} EfiBootServices; + #define kEntireDevPath 0xFF #define kThisInstancePath 0x01 typedef struct EfiSimpleTextOutputProtocol { - UInt64 reset; - EfiTextString outputString; - UInt64 testString; - UInt64 queryMode; - UInt64 setMode; - UInt64 setAttribute; - UInt64 clearScreen; - UInt64 setCursorPosition; - UInt64 enableCursor; - UInt64 mode; + UInt64 Reset; + EfiTextString OutputString; + UInt64 TestString; + UInt64 QueryMode; + UInt64 SetMode; + UInt64 SetAttribute; + UInt64 ClearScreen; + UInt64 SetCursorPosition; + UInt64 EnableCursor; + UInt64 Mode; } EfiSimpleTextOutputProtocol; typedef struct EfiSystemTable { - EfiTableHeader hdr; - WideChar *firmwareVendor; - UInt32 firmwareRevision; - VoidPtr consoleInHandle; - UInt64 conIn; - VoidPtr consoleOutHandle; - EfiSimpleTextOutputProtocol *conOut; - VoidPtr standardErrorHandle; - UInt64 stdErr; - UInt64 runtimeServices; - UInt64 bootServices; - UInt64 numberOfTableEntries; - UInt64 configurationTable; + EfiTableHeader SystemHeader; + WideChar *FirmwareVendor; + UInt32 FirmwareRevision; + VoidPtr ConsoleInHandle; + UInt64 ConIn; + VoidPtr ConsoleOutHandle; + EfiSimpleTextOutputProtocol *ConOut; + VoidPtr StandardErrorHandle; + UInt64 StdErr; + UInt64 RuntimeServices; + EfiBootServices *BootServices; + UInt64 NumberOfTableEntries; + UInt64 ConfigurationTable; } EfiSystemTable; #define EfiMain efi_main #define kEfiOk 0 +#define kEfiFail -1 + +#define EFI_EXTERN_C extern "C" + +#endif // __EFI__ diff --git a/Private/EFIKit/EPM.hxx b/Private/EFIKit/EPM.hxx index 07de7d7c..4b88c4cd 100644 --- a/Private/EFIKit/EPM.hxx +++ b/Private/EFIKit/EPM.hxx @@ -10,7 +10,9 @@ #ifndef __PARTITION_MAP__ #define __PARTITION_MAP__ -inline constexpr int kUUIDLen = 37; +inline consteval int kUUIDLen = 37; +inline consteval int kNameLen = 32; +inline consteval int kMagicLen = 4; /* the first 512 > x > 1024 bytes of a disk contains this headers. */ @@ -20,8 +22,8 @@ inline constexpr int kUUIDLen = 37; */ struct __attribute__((packed)) BootBlock { - char magic[4]; - char name[32]; + char magic[kMagicLen]; + char name[kNameLen]; char uuid[kUUIDLen]; int version; long long int num_blocks; |
