|
PatchworkOS
19e446b
A non-POSIX operating system.
|
The UEFI bootloader of PatchworkOS. More...
The UEFI bootloader of PatchworkOS.
PatchworkOS UEFI Bootloader.
Modules | |
| Boot Information | |
| Boot information. | |
Macros | |
| #define | GOP_WIDTH 1920 |
Ignored if GOP_USE_DEFAULT_RES is set to 1. | |
| #define | GOP_HEIGHT 1080 |
Ignored if GOP_USE_DEFAULT_RES is set to 1. | |
| #define | GOP_USE_DEFAULT_RES 1 |
| #define | MEM_BASIC_ALLOCATOR_RESERVE_PERCENTAGE 10 |
| #define | MEM_BASIC_ALLOCATOR_MIN_PAGES 8192 |
| #define | EXIT_BOOT_SERVICES_MAX_RETRIES 5 |
Enumerations | |
| enum | panic_code_t { PANIC_ALLOCATOR_EXHAUSTED = 0 , PANIC_PAGE_TABLE_INIT = 1 , PANIC_IDENTITY_MAP = 2 , PANIC_HIGHER_HALF_INVALID = 3 , PANIC_HIGHER_HALF_MAP = 4 , PANIC_KERNEL_MAP = 5 , PANIC_GOP_MAP = 6 } |
| Panic error codes for debugging when boot services are unavailable. More... | |
Functions | |
| static void * | rsdp_locate (EFI_SYSTEM_TABLE *systemTable) |
| Locates the ACPI RSDP from the EFI configuration table. | |
| static UINT32 | gop_find_best_mode (EFI_GRAPHICS_OUTPUT_PROTOCOL *gop, int64_t requestedWidth, int64_t requestedHeight) |
| Finds the best matching graphics mode for the requested resolution. | |
| static EFI_STATUS | gop_set_mode (EFI_GRAPHICS_OUTPUT_PROTOCOL *gop, int64_t requestedWidth, int64_t requestedHeight) |
| Sets the graphics mode to best match the requested resolution. | |
| static EFI_STATUS | gop_init (boot_gop_t *buffer) |
| Initializes the GOP buffer structure with framebuffer information. | |
| static _NORETURN void | panic_halt (panic_code_t code) |
| Halts the system with a colored screen indicating the error. | |
| static EFI_STATUS | mem_map_init (boot_memory_map_t *map) |
| Initializes the EFI memory map structure. | |
| static void | mem_map_cleanup (boot_memory_map_t *map) |
| Free the memory map structure. | |
| static size_t | mem_count_available_pages (boot_memory_map_t *map) |
| Calculates the total available conventional memory. | |
| static EFI_STATUS | mem_allocator_init (void) |
| Initializes the basic page allocator. | |
| static uint64_t | basic_allocator_alloc_pages (pfn_t *pfns, size_t amount) |
| Allocate pages from the basic allocator. | |
| static void | mem_page_table_init (page_table_t *table, boot_memory_map_t *map, boot_gop_t *gop, boot_kernel_t *kernel) |
| Initializes the kernel page table with all required mappings. | |
| static bool | wstr_to_str (char *dest, size_t destSize, const CHAR16 *src) |
| Copies a wide character string to a narrow character buffer. | |
| static void | boot_file_free (boot_file_t *file) |
| Frees a boot file structure and its data. | |
| static void | boot_dir_free (boot_dir_t *dir) |
| Recursively frees a directory tree. | |
| static boot_file_t * | disk_load_file (EFI_FILE *parentDir, const CHAR16 *fileName) |
| Loads a single file from an EFI file handle. | |
| static boot_dir_t * | disk_load_dir (EFI_FILE *dirHandle, const CHAR16 *dirName) |
| Recursively loads a directory and its contents. | |
| static EFI_STATUS | disk_init (boot_disk_t *disk, EFI_FILE *rootHandle) |
| Loads the initial RAM disk from the boot volume. | |
| static EFI_STATUS | kernel_load (boot_kernel_t *kernel, EFI_FILE *rootHandle) |
| Loads and validates the kernel ELF file. | |
| static void | splash_screen_display (void) |
| Displays the bootloader splash screen. | |
| static EFI_STATUS | volume_open_root (EFI_FILE **rootFile, EFI_HANDLE imageHandle) |
| Opens the root volume of the boot device. | |
| static EFI_STATUS | boot_info_populate (EFI_HANDLE imageHandle, EFI_SYSTEM_TABLE *systemTable, boot_info_t *bootInfo) |
| Populates the boot information structure. | |
| static EFI_STATUS | boot_services_exit (EFI_HANDLE imageHandle, boot_info_t *bootInfo) |
| Exits UEFI boot services and prepares for kernel handoff. | |
| EFI_STATUS | efi_main (EFI_HANDLE imageHandle, EFI_SYSTEM_TABLE *systemTable) |
| UEFI entry point. | |
Variables | ||
| struct { | ||
| EFI_PHYSICAL_ADDRESS buffer | ||
| size_t maxPages | ||
| size_t pagesAllocated | ||
| boot_gop_t * gop | ||
| boot_memory_map_t * map | ||
| } | basicAllocator | |
| Basic page allocator state. | ||
| static const uint32_t | PANIC_COLORS [] | |
| Color values for panic display. | ||
| #define GOP_WIDTH 1920 |
| #define GOP_HEIGHT 1080 |
| enum panic_code_t |
|
static |
|
static |
Finds the best matching graphics mode for the requested resolution.
| gop | Pointer to the GOP protocol. |
| requestedWidth | Desired horizontal resolution. |
| requestedHeight | Desired vertical resolution. |
Definition at line 111 of file main.c.
|
static |
Sets the graphics mode to best match the requested resolution.
| gop | Pointer to the GOP protocol. |
| requestedWidth | Desired horizontal resolution. |
| requestedHeight | Desired vertical resolution. |
EFI_SUCCESS. On failure, an EFI error code. Definition at line 154 of file main.c.
|
static |
Initializes the GOP buffer structure with framebuffer information.
Locates the Graphics Output Protocol, optionally sets the desired resolution, and populates the boot_gop_t structure with framebuffer details.
| buffer | Pointer to the boot_gop_t structure to populate. |
EFI_SUCCESS. On failure, an EFI error code. Definition at line 171 of file main.c.
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
Initializes the kernel page table with all required mappings.
| table | Pointer to the page table structure. |
| map | Pointer to the memory map. |
| gop | Pointer to the GOP information. |
| kernel | Pointer to the kernel information. |
Definition at line 435 of file main.c.
Copies a wide character string to a narrow character buffer.
| dest | Destination buffer. |
| destSize | Size of the destination buffer. |
| src | Source wide string. |
true if the string was fully copied, false if truncated. Definition at line 504 of file main.c.
|
static |
|
static |
|
static |
Loads a single file from an EFI file handle.
| parentDir | The parent directory handle. |
| fileName | The name of the file to load. |
NULL. Definition at line 574 of file main.c.
|
static |
Recursively loads a directory and its contents.
| dirHandle | The directory handle to read from. |
| dirName | The name of the directory. |
NULL. Definition at line 645 of file main.c.
|
static |
Loads the initial RAM disk from the boot volume.
| disk | Pointer to the disk structure to populate. |
| rootHandle | Handle to the root of the boot volume. |
Definition at line 748 of file main.c.
|
static |
Loads and validates the kernel ELF file.
| kernel | Pointer to the kernel structure to populate. |
| rootHandle | Handle to the root of the boot volume. |
EFI_SUCCESS. On failure, an EFI error code. Definition at line 786 of file main.c.
|
static |
|
static |
|
static |
Populates the boot information structure.
Initializes all boot data including GOP, RSDP, disk, and kernel.
| imageHandle | The loaded image handle. |
| systemTable | Pointer to the EFI system table. |
| bootInfo | Pointer to the boot info structure to populate. |
Definition at line 982 of file main.c.
|
static |
Exits UEFI boot services and prepares for kernel handoff.
| imageHandle | The loaded image handle. |
| bootInfo | Pointer to the boot info structure. |
EFI_SUCCESS. On failure, an EFI error code. Definition at line 1047 of file main.c.
| EFI_STATUS efi_main | ( | EFI_HANDLE | imageHandle, |
| EFI_SYSTEM_TABLE * | systemTable | ||
| ) |
| struct { ... } basicAllocator |
Basic page allocator state.
This allocator is used after exiting boot services when UEFI memory allocation is no longer available.