diff options
| author | Ada Christine <adachristine18@gmail.com> | 2021-12-16 12:06:04 +0000 |
|---|---|---|
| committer | Ada Christine <adachristine18@gmail.com> | 2021-12-16 12:06:04 +0000 |
| commit | ec1233b4fcd61a8d1eccbf030cede36e9848e06c (patch) | |
| tree | 13ffdc3b3948275e8c764ccf10368d555ff4d5e1 /api | |
| parent | a7f79219706c357c6c15978cea5e654042b14acb (diff) | |
reworking loader
Diffstat (limited to 'api')
| -rw-r--r-- | api/kernel/entry.h | 1 | ||||
| -rw-r--r-- | api/kernel/memory/paging.h | 1 | ||||
| -rw-r--r-- | api/kernel/memory/range.h | 2 | ||||
| -rw-r--r-- | api/loader/data_efi.h | 49 | ||||
| -rw-r--r-- | api/loader/efi/shim.h | 47 | ||||
| -rw-r--r-- | api/loader/shim.h | 4 |
6 files changed, 55 insertions, 49 deletions
diff --git a/api/kernel/entry.h b/api/kernel/entry.h index 8a26125..d119ca1 100644 --- a/api/kernel/entry.h +++ b/api/kernel/entry.h @@ -5,3 +5,4 @@ #define KERNEL_ENTRY_STACK_BASE ((char *)KERNEL_ENTRY_STACK_HEAD - KERNEL_ENTRY_STACK_SIZE) typedef void (*kernel_entry_func)(void *data); + diff --git a/api/kernel/memory/paging.h b/api/kernel/memory/paging.h index fc1aa45..000d12b 100644 --- a/api/kernel/memory/paging.h +++ b/api/kernel/memory/paging.h @@ -31,3 +31,4 @@ #define page_address(a, l) ((uintptr_t)a & ~(page_size(l) - 1)) #define page_offset(a, l) ((uintptr_t)a & (page_size(l) - 1)) #define page_count(s, l) (((s + page_size(l) - 1) & ~(page_size(l) - 1)) / page_size(l)) + diff --git a/api/kernel/memory/range.h b/api/kernel/memory/range.h index 6a68467..90b3354 100644 --- a/api/kernel/memory/range.h +++ b/api/kernel/memory/range.h @@ -11,6 +11,7 @@ enum memory_range_type RESERVED_MEMORY, SYSTEM_MEMORY, AVAILABLE_MEMORY, + INVALID_MEMORY = 0xff }; struct memory_range @@ -19,3 +20,4 @@ struct memory_range phys_addr_t base; size_t size; }; + diff --git a/api/loader/data_efi.h b/api/loader/data_efi.h deleted file mode 100644 index e5d1dd4..0000000 --- a/api/loader/data_efi.h +++ /dev/null @@ -1,49 +0,0 @@ -#pragma once - -#include <kernel/memory/range.h> - -#include <efi.h> - -#include <stddef.h> - -#define UserMemoryType ((EFI_MEMORY_TYPE)0x80000000) -#define SystemMemoryType (UserMemoryType|0x01) - -enum efi_boot_data_type -{ - MEMORY_MAP_DATA, - FRAMEBUFFER_DATA, - ACPI_DATA, -}; - -struct efi_memory_map_data -{ - UINTN size; - UINTN key; - UINTN descsize; - UINT32 descver; - EFI_MEMORY_DESCRIPTOR data[]; -}; - -struct efi_framebuffer_data -{ - struct memory_range buffer; - UINT32 width; - UINT32 height; - UINT32 pitch; - UINT8 pxsize; - EFI_PIXEL_BITMASK bitmask; - EFI_GRAPHICS_PIXEL_FORMAT pxformat; -}; - -struct efi_acpi_data -{ - void *rsdp; -}; - -struct efi_boot_data -{ - struct efi_memory_map_data *memory_map; - struct efi_framebuffer_data *framebuffer; - struct efi_acpi_data *acpi; -}; 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); + diff --git a/api/loader/shim.h b/api/loader/shim.h new file mode 100644 index 0000000..531a62b --- /dev/null +++ b/api/loader/shim.h @@ -0,0 +1,4 @@ +#pragma once + + + |
