limine/common/lib/panic.s2.c
Kacper Słomiński e1f6ac8860
Initial AArch64 port (#205)
* 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.
2022-08-18 17:32:54 +02:00

97 lines
1.7 KiB
C

#include <stddef.h>
#include <stdbool.h>
#include <stdnoreturn.h>
#include <lib/print.h>
#include <lib/real.h>
#include <lib/trace.h>
#if uefi == 1
# include <efi.h>
#endif
#include <lib/blib.h>
#include <lib/readline.h>
#include <lib/gterm.h>
#include <lib/term.h>
#include <mm/pmm.h>
#include <menu.h>
noreturn void panic(bool allow_menu, const char *fmt, ...) {
va_list args;
va_start(args, fmt);
quiet = false;
static bool is_nested = false;
if (is_nested) {
goto nested;
}
is_nested = true;
if (
#if bios == 1
stage3_loaded == true &&
#endif
term_backend == NOT_READY) {
early_term = true;
term_vbe(NULL, 0, 0);
}
nested:
if (term_backend == NOT_READY) {
term_fallback();
}
#if bios == 1
if (stage3_loaded) {
#endif
print("\033[31mPANIC\033[37;1m\033[0m: ");
#if bios == 1
} else {
print("PANIC: ");
}
#endif
vprint(fmt, args);
va_end(args);
print("\n");
print_stacktrace(NULL);
if (
#if bios == 1
stage3_loaded == true &&
#endif
allow_menu == true) {
print("Press a key to return to menu.");
getchar();
menu(false);
/*
fb_clear(&fbinfo);
// release all uefi memory and return to firmware
pmm_release_uefi_mem();
gBS->Exit(efi_image_handle, EFI_ABORTED, 0, NULL);
*/
} else {
#if bios == 1
print("Press CTRL+ALT+DEL to reboot.");
rm_hcf();
#elif uefi == 1
print("System halted.");
for (;;) {
#if defined (__x86_64__) || defined (__i386__)
asm ("hlt");
#elif defined (__aarch64__)
asm ("wfi");
#else
#error Unknown architecture
#endif
}
#endif
}
}