From 6a0f30a1ce393b325f22dfe3fe821dd766dfe231 Mon Sep 17 00:00:00 2001 From: "Kevin Alavik (puffer)" Date: Tue, 9 Jul 2024 11:48:59 +0200 Subject: [PATCH 01/10] Fixed types Signed-off-by: Kevin Alavik (puffer) --- efi_types.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/efi_types.h b/efi_types.h index c56fb5e..ff110e9 100644 --- a/efi_types.h +++ b/efi_types.h @@ -6,8 +6,8 @@ typedef char efi_int8_t; typedef unsigned char efi_uint8_t; typedef short efi_int16_t; typedef unsigned short efi_uint16_t; -typedef efi_int efi_int32_t; -typedef unsigned efi_int efi_uint32_t; +typedef int efi_int32_t; +typedef unsigned int efi_uint32_t; #if defined(_X64) typedef long efi_int64_t; typedef unsigned long efi_uint64_t; -- 2.39.5 From c3148bf35ff8c8d6950c0e35c03895279f67ddd4 Mon Sep 17 00:00:00 2001 From: "Kevin Alavik (puffer)" Date: Tue, 9 Jul 2024 11:49:09 +0200 Subject: [PATCH 02/10] Update efilib.h Signed-off-by: Kevin Alavik (puffer) --- efilib.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/efilib.h b/efilib.h index 40e0750..5e79899 100644 --- a/efilib.h +++ b/efilib.h @@ -4,7 +4,7 @@ #include "efi.h" #include "efi_st.h" -#define EFI_ERROR(status) (((INTN)(status)) < 0) +#define EFI_ERROR(status) (((EFI_INTN)(status)) < 0) #endif /* EFI_EFILIB_H */ -- 2.39.5 From f0a2562855c704526e2198717308e5c520b3a704 Mon Sep 17 00:00:00 2001 From: Jozef Nagy Date: Wed, 10 Jul 2024 19:51:09 +0200 Subject: [PATCH 03/10] Use compiler-provided stdint.h --- efi_types.h | 41 +++++++++++++---------------------------- 1 file changed, 13 insertions(+), 28 deletions(-) diff --git a/efi_types.h b/efi_types.h index ff110e9..f1a057c 100644 --- a/efi_types.h +++ b/efi_types.h @@ -1,36 +1,21 @@ #ifndef EFI_TYPES_H #define EFI_TYPES_H -// Standard Data types -typedef char efi_int8_t; -typedef unsigned char efi_uint8_t; -typedef short efi_int16_t; -typedef unsigned short efi_uint16_t; -typedef int efi_int32_t; -typedef unsigned int efi_uint32_t; -#if defined(_X64) -typedef long efi_int64_t; -typedef unsigned long efi_uint64_t; -#elif defined (_X32) -typedef long long efi_int64_t; -typedef unsigned long long efi_uint64_t; -#else -#error _X32/_X64 is undefined! -#endif +#include // Common UEFI Data types -typedef efi_int8_t EFI_INT8; -typedef efi_uint8_t EFI_UINT8; -typedef efi_int16_t EFI_INT16; -typedef efi_uint16_t EFI_UINT16; -typedef efi_int32_t EFI_INT32; -typedef efi_uint32_t EFI_UINT32; -typedef efi_int64_t EFI_INT64; -typedef efi_uint64_t EFI_UINT64; -typedef efi_int64_t EFI_INTN; -typedef efi_uint64_t EFI_UINTN; +typedef int8_t EFI_INT8; +typedef uint8_t EFI_UINT8; +typedef int16_t EFI_INT16; +typedef uint16_t EFI_UINT16; +typedef int32_t EFI_INT32; +typedef uint32_t EFI_UINT32; +typedef int64_t EFI_INT64; +typedef uint64_t EFI_UINT64; +typedef int64_t EFI_INTN; +typedef uint64_t EFI_UINTN; typedef char CHAR8; -typedef efi_uint16_t CHAR16; +typedef uint16_t CHAR16; typedef void VOID; typedef EFI_INT32 EFI_INT; @@ -177,7 +162,7 @@ typedef struct { #define EFI_BACKGROUND_BROWN 0x60 #define EFI_BACKGROUND_LIGHTGRAY 0x70 -// Converts Foreground and Background colors efi_into a single value +// Converts Foreground and Background colors into a single value #define EFI_TEXT_ATTR(Foreground,Background) \ ((Foreground) | ((Background) << 4)) -- 2.39.5 From d97352695513d5be831e60255e138378b4adf14d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl?= <81994075+RaphProductions@users.noreply.github.com> Date: Wed, 10 Jul 2024 22:59:20 +0200 Subject: [PATCH 04/10] Update console_support.h MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Raphaƫl <81994075+RaphProductions@users.noreply.github.com> --- protocols/console_support.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/protocols/console_support.h b/protocols/console_support.h index dfd5d22..10713f2 100644 --- a/protocols/console_support.h +++ b/protocols/console_support.h @@ -31,6 +31,13 @@ #define EFI_SCANCODE_FN10 0x14 #define EFI_SCANCODE_ESC 0x17 +// EFI special characters +#define EFI_CHAR_NULL 0x0000 +#define EFI_CHAR_BACKSPACE 0x0008 +#define EFI_CHAR_TAB 0x0009 +#define EFI_CHAR_LINEFEED 0x000A +#define EFI_CHAR_CARRIAGE_RETURN 0x000D + typedef struct _EFI_SIMPLE_TEXT_INPUT_PROTOCOL EFI_SIMPLE_TEXT_INPUT_PROTOCOL; typedef struct { -- 2.39.5 From adda2d9ee06adf688850abfb38cbced5eaee8639 Mon Sep 17 00:00:00 2001 From: Jozef Nagy Date: Sat, 27 Jul 2024 11:33:12 +0200 Subject: [PATCH 05/10] Added EFI_FILE_INFO --- protocols/media_access.h | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/protocols/media_access.h b/protocols/media_access.h index 28e8a64..1d4d2dd 100644 --- a/protocols/media_access.h +++ b/protocols/media_access.h @@ -41,6 +41,8 @@ typedef EFI_LOAD_FILE_PROTOCOL EFI_LOAD_FILE2_PROTOCOL; #define EFI_FILE_PROTOCOL_REVISION2 0x00020000 #define EFI_FILE_PROTOCOL_LATEST_REVISION EFI_FILE_PROTOCOL_REVISION2 +#define EFI_FILE_INFO_GUID {0x09576e92,0x6d3f,0x11d2, {0x8e,0x39,0x00,0xa0,0xc9,0x69,0x72,0x3b}} + #define EFI_FILE_MODE_READ 0x0000000000000001 #define EFI_FILE_MODE_WRITE 0x0000000000000002 #define EFI_FILE_MODE_CREATE 0x8000000000000000 @@ -62,6 +64,17 @@ typedef struct { VOID *Buffer; } EFI_FILE_IO_TOKEN; +typedef struct { + EFI_UINT64 Size; + EFI_UINT64 FileSize; + EFI_UINT64 PhysicalSize; + EFI_TIME CreateTime; + EFI_TIME LastAccessTime; + EFI_TIME ModificationTime; + EFI_UINT64 Attribute; + CHAR16 FileName[256]; +} EFI_FILE_INFO; + typedef EFI_STATUS (EFIAPI *EFI_FILE_OPEN)( @@ -120,7 +133,7 @@ EFI_STATUS IN EFI_FILE_PROTOCOL *This, IN EFI_GUID *InformationType, IN OUT EFI_UINTN *BufferSize, - OUT VOID *Buffer + OUT EFI_FILE_INFO *Buffer ); typedef @@ -129,7 +142,7 @@ EFI_STATUS IN EFI_FILE_PROTOCOL *This, IN EFI_GUID *InformationType, IN EFI_UINTN BufferSize, - IN VOID *Buffer + IN EFI_FILE_INFO *Buffer ); typedef -- 2.39.5 From d6fe5092e538e3b6f6ed64873cccf7a88fd6298b Mon Sep 17 00:00:00 2001 From: "Kevin Alavik (puffer)" Date: Sun, 18 Aug 2024 18:59:53 +0200 Subject: [PATCH 06/10] fix: MaxNode -> MaxMode Signed-off-by: Kevin Alavik (puffer) --- protocols/console_support.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protocols/console_support.h b/protocols/console_support.h index 10713f2..cc7c81d 100644 --- a/protocols/console_support.h +++ b/protocols/console_support.h @@ -257,7 +257,7 @@ EFI_STATUS ); typedef struct { - EFI_INT32 MaxNode; + EFI_INT32 MaxMode; // Current settings EFI_INT32 Mode; -- 2.39.5 From 5dd8b57340061d0bdcfbb5c9e16795c621e99307 Mon Sep 17 00:00:00 2001 From: Jozef Nagy Date: Sat, 31 Aug 2024 16:17:36 +0200 Subject: [PATCH 07/10] Updated ACPI table GUID definitions --- efi_st.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/efi_st.h b/efi_st.h index 97935db..24353e5 100644 --- a/efi_st.h +++ b/efi_st.h @@ -25,9 +25,8 @@ #define EFI_SPECIFICATION_VERSION EFI_SYSTEM_TABLE_REVISION #define EFI_SYSTEM_TABLE_REVISION EFI_2_100_SYSTEM_TABLE_REVISION -#define ACPI_TABLE_GUID {0xeb9d2d30,0x2d88,0x11d3, {0x9a,0x16,0x00,0x90,0x27,0x3f,0xc1,0x4d}} +#define EFI_ACPI_10_TABLE_GUID {0xeb9d2d30,0x2d88,0x11d3, {0x9a,0x16,0x00,0x90,0x27,0x3f,0xc1,0x4d}} #define EFI_ACPI_20_TABLE_GUID {0x8868e871,0xe4f1,0x11d3, {0xbc,0x22,0x00,0x80,0xc7,0x3c,0x88,0x81}} -#define ACPI_10_TABLE_GUID ACPI_TABLE_GUID* #define EFI_ACPI_TABLE_GUID {0x8868e871,0xe4f1,0x11d3, {0xbc,0x22,0x00,0x80,0xc7,0x3c,0x88,0x81}} #define SAL_SYSTEM_TABLE_GUID {0xeb9d2d32,0x2d88,0x11d3, {0x9a,0x16,0x00,0x90,0x27,0x3f,0xc1,0x4d}} #define SMBIOS_TABLE_GUID {0xeb9d2d31,0x2d88,0x11d3, {0x9a,0x16,0x00,0x90,0x27,0x3f,0xc1,0x4d}} -- 2.39.5 From 00ed5f5d53641d48024d8a1346edef07d1d79421 Mon Sep 17 00:00:00 2001 From: Jozef Nagy Date: Sat, 31 Aug 2024 16:28:12 +0200 Subject: [PATCH 08/10] Updated ACPI table GUID definitions --- efi_st.h | 1 - 1 file changed, 1 deletion(-) diff --git a/efi_st.h b/efi_st.h index 24353e5..51040a8 100644 --- a/efi_st.h +++ b/efi_st.h @@ -27,7 +27,6 @@ #define EFI_ACPI_10_TABLE_GUID {0xeb9d2d30,0x2d88,0x11d3, {0x9a,0x16,0x00,0x90,0x27,0x3f,0xc1,0x4d}} #define EFI_ACPI_20_TABLE_GUID {0x8868e871,0xe4f1,0x11d3, {0xbc,0x22,0x00,0x80,0xc7,0x3c,0x88,0x81}} -#define EFI_ACPI_TABLE_GUID {0x8868e871,0xe4f1,0x11d3, {0xbc,0x22,0x00,0x80,0xc7,0x3c,0x88,0x81}} #define SAL_SYSTEM_TABLE_GUID {0xeb9d2d32,0x2d88,0x11d3, {0x9a,0x16,0x00,0x90,0x27,0x3f,0xc1,0x4d}} #define SMBIOS_TABLE_GUID {0xeb9d2d31,0x2d88,0x11d3, {0x9a,0x16,0x00,0x90,0x27,0x3f,0xc1,0x4d}} #define SMBIOS3_TABLE_GUID {0xf2fd1544, 0x9794, 0x4a2c, {0x99,0x2e,0xe5,0xbb,0xcf,0x20,0xe3,0x94}} -- 2.39.5 From 693be19acd46bb022d274f2c971b6a78930c475a Mon Sep 17 00:00:00 2001 From: Jozef Nagy Date: Sat, 25 Jan 2025 20:40:27 +0100 Subject: [PATCH 09/10] Added AxBoot specific stuff --- efilib.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/efilib.h b/efilib.h index 5e79899..7f92d52 100644 --- a/efilib.h +++ b/efilib.h @@ -2,9 +2,17 @@ #define EFI_EFILIB_H #include "efi.h" -#include "efi_st.h" #define EFI_ERROR(status) (((EFI_INTN)(status)) < 0) +/* AxBoot-specific stuff */ +#ifdef AXBOOT_UEFI + +extern EFI_HANDLE gImageHandle; +extern EFI_SYSTEM_TABLE *gSystemTable; +extern EFI_BOOT_SERVICES *gBootServices; + +#endif + #endif /* EFI_EFILIB_H */ -- 2.39.5 From c6a93ef5d4f6129cc579b3376d1f2990515210f9 Mon Sep 17 00:00:00 2001 From: Jozef Nagy Date: Sat, 25 Jan 2025 21:30:06 +0100 Subject: [PATCH 10/10] Added efi_status_to_str() --- efilib.h | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) diff --git a/efilib.h b/efilib.h index 7f92d52..5a2907b 100644 --- a/efilib.h +++ b/efilib.h @@ -5,6 +5,85 @@ #define EFI_ERROR(status) (((EFI_INTN)(status)) < 0) +static inline const char *efi_status_to_str(EFI_STATUS s) +{ + switch (s) { + case EFI_SUCCESS: + return "Success"; + case EFI_LOAD_ERROR: + return "Image failed to load"; + case EFI_INVALID_PARAMETER: + return "Invalid parameter specified"; + case EFI_UNSUPPORTED: + return "Operation not supported"; + case EFI_BAD_BUFFER_SIZE: + return "Improper buffer size"; + case EFI_BUFFER_TOO_SMALL: + return "Buffer is too small"; + case EFI_NOT_READY: + return "No data pending"; + case EFI_DEVICE_ERROR: + return "Device reported an error"; + case EFI_WRITE_PROTECTED: + return "Device has write protection"; + case EFI_OUT_OF_RESOURCES: + return "Out of resources"; + case EFI_VOLUME_CORRUPTED: + return "File system is corrupted"; + case EFI_VOLUME_FULL: + return "No more space on filesystem"; + case EFI_NO_MEDIA: + return "No medium found"; + case EFI_MEDIA_CHANGED: + return "Medium has changed"; + case EFI_NOT_FOUND: + return "Item not found"; + case EFI_ACCESS_DENIED: + return "Access denied"; + case EFI_NO_RESPONSE: + return "Server was not found or did not respond"; + case EFI_NO_MAPPING: + return "A mapping to a device doesn't exist"; + case EFI_TIMEOUT: + return "Timeout"; + case EFI_NOT_STARTED: + return "Protocol has not been started yet"; + case EFI_ALREADY_STARTED: + return "Protocol has already been started"; + case EFI_ABORTED: + return "Operation was aborted"; + case EFI_ICMP_ERROR: + return "ICMP error"; + case EFI_TFTP_ERROR: + return "TFTP error"; + case EFI_PROTOCOL_ERROR: + return "Protocol error"; + case EFI_INCOMPATIBLE_VERSION: + return "Incompatible version"; + case EFI_SECURITY_VIOLATION: + return "Security violation"; + case EFI_CRC_ERROR: + return "CRC error"; + case EFI_END_OF_MEDIA: + return "End of media reached"; + case EFI_END_OF_FILE: + return "End of file reached"; + case EFI_INVALID_LANGUAGE: + return "Invalid language specified"; + case EFI_COMPROMISED_DATA: + return "Security status of data is unknown or compromised"; + case EFI_IP_ADDRESS_CONFLICT: + return "IP Address conflict"; + case EFI_HTTP_ERROR: + return "HTTP Error"; + default: + return "Unknown Error"; + } + + __builtin_unreachable(); + return "Unknown Error"; +} + /* AxBoot-specific stuff */ #ifdef AXBOOT_UEFI -- 2.39.5