summaryrefslogtreecommitdiff
path: root/api/loader/efi/shim.h
diff options
context:
space:
mode:
authorAda Christine <adachristine18@gmail.com>2021-12-16 12:06:04 +0000
committerAda Christine <adachristine18@gmail.com>2021-12-16 12:06:04 +0000
commitec1233b4fcd61a8d1eccbf030cede36e9848e06c (patch)
tree13ffdc3b3948275e8c764ccf10368d555ff4d5e1 /api/loader/efi/shim.h
parenta7f79219706c357c6c15978cea5e654042b14acb (diff)
reworking loader
Diffstat (limited to 'api/loader/efi/shim.h')
-rw-r--r--api/loader/efi/shim.h47
1 files changed, 47 insertions, 0 deletions
diff --git a/api/loader/efi/shim.h b/api/loader/efi/shim.h
new file mode 100644
index 0000000..3486c34
--- /dev/null
+++ b/api/loader/efi/shim.h
@@ -0,0 +1,47 @@
+#pragma once
+
+#include <loader/shim.h>
+
+#include <efi.h>
+
+#ifdef __ELF__
+ #define EFIEXPORT __attribute__((visibility("default")))
+#else
+ #define EFIEXPORT __declspec(dllexport)
+#endif
+
+#define OsVendorMemoryType(t) ((EFI_MEMORY_TYPE)(0x80000000|t))
+#define SystemMemoryType OsVendorMemoryType(1)
+
+struct efi_loader_image;
+
+struct efi_loader_image
+{
+ CHAR16 *path;
+ EFI_HANDLE image_handle;
+ EFI_SYSTEM_TABLE *system_table;
+ EFI_FILE_PROTOCOL *root;
+ EFI_FILE_PROTOCOL *file;
+ EFI_PHYSICAL_ADDRESS buffer_base;
+ UINTN buffer_size;
+};
+
+typedef EFI_STATUS (*efi_image_func)(struct efi_loader_image *image);
+typedef EFI_STATUS (*efi_page_alloc_func)(EFI_MEMORY_TYPE type,
+ UINTN size,
+ EFI_PHYSICAL_ADDRESS *base);
+typedef EFI_STATUS (*efi_page_free_func)(EFI_PHYSICAL_ADDRESS base, UINTN size);
+
+struct efi_loader_interface
+{
+ efi_page_alloc_func page_alloc;
+ efi_page_free_func page_free;
+
+ efi_image_func image_open;
+ efi_image_func image_alloc;
+ efi_image_func image_load;
+};
+
+typedef EFI_STATUS (*efi_shim_entry_func)(struct efi_loader_image *image,
+ struct efi_loader_interface *interface);
+