summaryrefslogtreecommitdiff
path: root/lib/uefi.c3l/uefi/protocol/services
diff options
context:
space:
mode:
Diffstat (limited to 'lib/uefi.c3l/uefi/protocol/services')
-rw-r--r--lib/uefi.c3l/uefi/protocol/services/boot.c3i86
-rw-r--r--lib/uefi.c3l/uefi/protocol/services/mem.c3i36
-rw-r--r--lib/uefi.c3l/uefi/protocol/services/runtime.c3i36
-rw-r--r--lib/uefi.c3l/uefi/protocol/services/time.c3i31
4 files changed, 189 insertions, 0 deletions
diff --git a/lib/uefi.c3l/uefi/protocol/services/boot.c3i b/lib/uefi.c3l/uefi/protocol/services/boot.c3i
new file mode 100644
index 0000000..c5b8e06
--- /dev/null
+++ b/lib/uefi.c3l/uefi/protocol/services/boot.c3i
@@ -0,0 +1,86 @@
+module uefi::protocol::boot_services;
+
+import uefi::protocol::mem;
+
+alias AllocatePagesFn = fn EfiStatus (AllocateType, MemoryType, usz, void**);
+alias AllocatePoolFn = fn EfiStatus (MemoryType, usz, void**);
+alias FreePagesFn = fn EfiStatus (uptr, usz);
+alias FreePoolFn = fn EfiStatus (void*);
+alias GetMemoryMapFn = fn EfiStatus (usz*, MemoryDescriptor*, usz*, usz*, uint*);
+alias HandleProtocolFn = fn EfiStatus (EfiHandle, EfiGuid*, void**);
+alias ExitBootServicesFn = fn EfiStatus (EfiHandle, usz);
+alias CopyMemFn = fn void (void* dst, void* src, usz);
+alias SetMemFn = fn void (void* buf, usz, char);
+
+module uefi;
+import uefi::protocol::boot_services;
+
+struct BootServices @packed {
+ inline TableHeader header;
+
+ // Task priority services
+ void* raise_tpl;
+ void* restore_tpl;
+
+ // Memory services (uefi::protocol::mem)
+ AllocatePagesFn allocate_pages;
+ FreePagesFn free_pages;
+ GetMemoryMapFn get_memory_map;
+ AllocatePoolFn allocate_pool;
+ FreePoolFn free_pool;
+
+ // Event and Timer services
+ void* create_event;
+ void* set_timer;
+ void* wait_for_event;
+ void* signal_event;
+ void* close_event;
+ void* check_event;
+
+ // Protocol Handler services
+ void* install_protocol_interface;
+ void* reinstall_protocol_interface;
+ void* uninstall_protocol_interface;
+ HandleProtocolFn handle_protocol;
+ void* _reserved;
+ void* register_protocol_notify;
+ void* locate_handle;
+ void* locate_device_path;
+ void* install_configuration_table;
+
+ // Image services
+ void* load_image;
+ void* start_image;
+ void* exit_image;
+ void* unload_image;
+ ExitBootServicesFn exit_boot_services;
+
+ // Misc services
+ void* get_next_monotonic_count;
+ void* stall;
+ void* set_watchdog_timer;
+
+ // Driver Support services
+ void* connect_controller;
+ void* disconnect_controller;
+
+ // Open/Close Protocol services
+ void* open_protocol;
+ void* close_protocol;
+ void* open_protocol_information;
+
+ // Library services
+ void* protocols_per_handle;
+ void* locate_handle_buffer;
+ void* locate_protocol;
+ void* install_multiple_protocol_interfaces;
+ void* uninstall_multiple_protocol_interfaces;
+
+ // 32-bit CRC services
+ void* calculate_crc32;
+
+ // More misc services
+ CopyMemFn copy_mem;
+ SetMemFn set_mem;
+ void* create_event_ex;
+}
diff --git a/lib/uefi.c3l/uefi/protocol/services/mem.c3i b/lib/uefi.c3l/uefi/protocol/services/mem.c3i
new file mode 100644
index 0000000..8b47264
--- /dev/null
+++ b/lib/uefi.c3l/uefi/protocol/services/mem.c3i
@@ -0,0 +1,36 @@
+module uefi::protocol::mem;
+
+enum MemoryType : uint {
+ RESERVED,
+ LOADER_CODE,
+ LOADER_DATA,
+ BOOT_SERVICES_CODE,
+ BOOT_SERVICES_DATA,
+ RUNTIME_SERVICES_CODE,
+ RUNTIME_SERVICES_DATA,
+ CONVENTIONAL,
+ UNUSABLE,
+ ACPI_RECLAIM,
+ ACPI_NVS,
+ MEMORY_MAPPED_IO,
+ MEMORY_MAPPED_IO_PORT_SPACE,
+ PAL_CODE,
+ PERSISTENT,
+ UNACCEPTED,
+}
+
+enum AllocateType {
+ ANY_PAGES,
+ MAX_ADDRESS,
+ ADDRESS,
+}
+
+struct MemoryDescriptor {
+ MemoryType type;
+ uptr physicalStart;
+ uptr virtualStart;
+ ulong numberOfPages;
+ ulong attribute;
+ // reserved padding
+ ulong _rsvd;
+}
diff --git a/lib/uefi.c3l/uefi/protocol/services/runtime.c3i b/lib/uefi.c3l/uefi/protocol/services/runtime.c3i
new file mode 100644
index 0000000..cb690ed
--- /dev/null
+++ b/lib/uefi.c3l/uefi/protocol/services/runtime.c3i
@@ -0,0 +1,36 @@
+module uefi::protocol::runtime_services;
+
+alias ResetSystemFn = fn void (ResetType, EfiStatus, usz, void*);
+
+enum ResetType : uint {
+ COLD,
+ WARM,
+ SHUTDOWN,
+ PLATFORM_SPECIFIC,
+}
+
+module uefi;
+import uefi::protocol::runtime_services;
+import uefi::protocol::time;
+
+struct RuntimeServices @packed {
+ inline TableHeader header;
+
+ GetTimeFn get_time;
+ void* set_time;
+ void* get_wakeup_time;
+ void* set_wakeup_time;
+
+ void* set_virtual_address_map;
+ void* convert_pointer;
+
+ void* get_variable;
+ void* get_next_variable_name;
+ void* set_variable;
+
+ void* get_next_high_monotonic_count;
+ ResetSystemFn reset_system;
+ void* update_capsule;
+ void* query_capsule_capabilities;
+ void* query_variable_info;
+}
diff --git a/lib/uefi.c3l/uefi/protocol/services/time.c3i b/lib/uefi.c3l/uefi/protocol/services/time.c3i
new file mode 100644
index 0000000..e7e20bc
--- /dev/null
+++ b/lib/uefi.c3l/uefi/protocol/services/time.c3i
@@ -0,0 +1,31 @@
+module uefi::protocol::time;
+
+const short UNSPECIFIED_TIMEZONE = 0x07FF;
+
+struct Time @packed {
+ ushort year;
+ char month;
+ char day;
+ char hour;
+ char minute;
+ char second;
+ char _pad1;
+ uint nanosecond;
+ short timezone;
+ DaylightFlags daylight;
+ char _pad2;
+}
+
+bitstruct DaylightFlags : char {
+ bool adjust : 0;
+ bool inDaylight : 1;
+ char reserved : 2..7;
+}
+
+struct TimeCapabilities @packed {
+ uint resolution;
+ uint accuracy;
+ bool setsToZero;
+}
+
+alias GetTimeFn = fn EfiStatus (Time*, TimeCapabilities*);