mirror of
https://github.com/limine-bootloader/limine
synced 2024-12-05 14:42:16 +03:00
e1f6ac8860
* Initial aarch64 port * Enable chainload on aarch64 No changes necessary since it's all UEFI anyway. * Add specification for Limine protocol for aarch64 * PROTOCOL: Specify state of information in DT /chosen node * common: Add spinup code for aarch64 * common: Port elf and term to aarch64 * common: Port vmm to aarch64 Also prepare to drop VMM_FLAG_PRESENT on x86. * protos: Port limine boot protocol to aarch64 Also drop VMM_FLAG_PRESENT since we never unmap pages anyway. * test: Add DTB request * PROTOCOL: Port SMP request to aarch64 * cpu: Add cache maintenance functions for aarch64 * protos/limine, sys: Port SMP to aarch64 Also move common asm macros into a header file. * test: Start up APs * vmm: Unify get_next_level and implement large page splitting * protos/limine: Map framebuffer using correct caching mode on AArch64 * CI: Fix GCC build for aarch64 * entry, menu: Replace uses of naked attribute with separate asm file GCC does not understand the naked attribute on aarch64, and didn't understand it for x86 in older versions.
121 lines
3.0 KiB
C
121 lines
3.0 KiB
C
#include <stddef.h>
|
|
#include <stdint.h>
|
|
#include <stdnoreturn.h>
|
|
#include <lib/term.h>
|
|
#include <lib/real.h>
|
|
#include <lib/blib.h>
|
|
#include <lib/libc.h>
|
|
#include <lib/part.h>
|
|
#include <lib/config.h>
|
|
#include <lib/trace.h>
|
|
#include <sys/e820.h>
|
|
#include <sys/a20.h>
|
|
#include <sys/idt.h>
|
|
#include <sys/gdt.h>
|
|
#include <lib/print.h>
|
|
#include <fs/file.h>
|
|
#include <lib/elf.h>
|
|
#include <mm/pmm.h>
|
|
#include <menu.h>
|
|
#include <pxe/pxe.h>
|
|
#include <pxe/tftp.h>
|
|
#include <drivers/disk.h>
|
|
#include <sys/lapic.h>
|
|
#include <lib/readline.h>
|
|
|
|
void stage3_common(void);
|
|
|
|
#if uefi == 1
|
|
noreturn void uefi_entry(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) {
|
|
gST = SystemTable;
|
|
gBS = SystemTable->BootServices;
|
|
gRT = SystemTable->RuntimeServices;
|
|
efi_image_handle = ImageHandle;
|
|
|
|
EFI_STATUS status;
|
|
|
|
status = gBS->SetWatchdogTimer(0, 0x10000, 0, NULL);
|
|
if (status) {
|
|
term_vbe(NULL, 0, 0);
|
|
early_term = true;
|
|
print("WARNING: Failed to disable watchdog timer!\n");
|
|
}
|
|
|
|
term_notready();
|
|
|
|
init_memmap();
|
|
|
|
#if defined (__x86_64__) || defined (__i386__)
|
|
init_gdt();
|
|
#endif
|
|
|
|
disk_create_index();
|
|
|
|
boot_volume = NULL;
|
|
|
|
EFI_HANDLE current_handle = ImageHandle;
|
|
for (;;) {
|
|
if (current_handle == NULL) {
|
|
term_vbe(NULL, 0, 0);
|
|
early_term = true;
|
|
|
|
print("WARNING: Could not meaningfully match the boot device handle with a volume.\n");
|
|
print(" Using the first volume containing a Limine configuration!\n");
|
|
|
|
for (size_t i = 0; i < volume_index_i; i++) {
|
|
struct file_handle *f;
|
|
|
|
if ((f = fopen(volume_index[i], "/limine.cfg")) == NULL
|
|
&& (f = fopen(volume_index[i], "/boot/limine.cfg")) == NULL
|
|
&& (f = fopen(volume_index[i], "/EFI/BOOT/limine.cfg")) == NULL) {
|
|
continue;
|
|
}
|
|
|
|
fclose(f);
|
|
|
|
if (volume_index[i]->backing_dev != NULL) {
|
|
boot_volume = volume_index[i]->backing_dev;
|
|
} else {
|
|
boot_volume = volume_index[i];
|
|
}
|
|
|
|
break;
|
|
}
|
|
|
|
if (boot_volume != NULL)
|
|
stage3_common();
|
|
|
|
panic(false, "No volume contained a Limine configuration file");
|
|
}
|
|
|
|
EFI_GUID loaded_img_prot_guid = EFI_LOADED_IMAGE_PROTOCOL_GUID;
|
|
EFI_LOADED_IMAGE_PROTOCOL *loaded_image = NULL;
|
|
|
|
status = gBS->HandleProtocol(current_handle, &loaded_img_prot_guid,
|
|
(void **)&loaded_image);
|
|
|
|
if (status) {
|
|
panic(false, "HandleProtocol failure (%x)", status);
|
|
}
|
|
|
|
boot_volume = disk_volume_from_efi_handle(loaded_image->DeviceHandle);
|
|
|
|
if (boot_volume != NULL)
|
|
stage3_common();
|
|
|
|
current_handle = loaded_image->ParentHandle;
|
|
}
|
|
}
|
|
#endif
|
|
|
|
noreturn void stage3_common(void) {
|
|
term_notready();
|
|
|
|
#if defined (__x86_64__) || defined (__i386__)
|
|
init_flush_irqs();
|
|
init_io_apics();
|
|
#endif
|
|
|
|
menu(true);
|
|
}
|