mirror of
https://github.com/EnderIce2/Fennix.git
synced 2025-07-02 10:59:15 +00:00
kernel: add aarch64 architecture support
Signed-off-by: EnderIce2 <enderice2@protonmail.com>
This commit is contained in:
@ -185,8 +185,10 @@ nsa __noreturn void HandleUnrecoverableException(CPU::ExceptionFrame *Frame)
|
||||
CPU::Pause();
|
||||
|
||||
ExPrint("\x1b[0m-----------------------------------------------\n");
|
||||
#if defined(__amd64__) || defined(__i386__)
|
||||
ExPrint("\x1b[30;41mUnrecoverable exception %#lx on CPU %d\n",
|
||||
Frame->InterruptNumber, core->ID);
|
||||
#endif
|
||||
#if defined(__amd64__) || defined(__i386__)
|
||||
ExPrint("CR0=%#lx CR2=%#lx CR3=%#lx CR4=%#lx CR8=%#lx\n",
|
||||
Frame->cr0, Frame->cr2, Frame->cr3, Frame->cr4, Frame->cr8);
|
||||
@ -222,7 +224,9 @@ nsa __noreturn void HandleUnrecoverableException(CPU::ExceptionFrame *Frame)
|
||||
#endif /* a86 */
|
||||
|
||||
Display->UpdateBuffer();
|
||||
#if defined(__amd64__) || defined(__i386__)
|
||||
error("Unrecoverable Exception: %#lx", Frame->InterruptNumber);
|
||||
#endif
|
||||
|
||||
UnrecoverableLock.store(false, std::memory_order_release);
|
||||
CPU::Stop();
|
||||
@ -231,6 +235,7 @@ nsa __noreturn void HandleUnrecoverableException(CPU::ExceptionFrame *Frame)
|
||||
nsa __noreturn void HandleExceptionInsideException(CPU::ExceptionFrame *Frame)
|
||||
{
|
||||
ExPrint("\x1b[0m-----------------------------------------------\n");
|
||||
#if defined(__amd64__) || defined(__i386__)
|
||||
ExPrint("Exception inside exception: %#lx at %#lx\n",
|
||||
Frame->InterruptNumber,
|
||||
#if defined(__amd64__)
|
||||
@ -240,6 +245,7 @@ nsa __noreturn void HandleExceptionInsideException(CPU::ExceptionFrame *Frame)
|
||||
#elif defined(__aarch64__)
|
||||
Frame->pc);
|
||||
#endif
|
||||
#endif // __amd64__ || __i386__
|
||||
#if defined(__amd64__) || defined(__i386__)
|
||||
ExPrint("CR0=%#lx CR2=%#lx CR3=%#lx CR4=%#lx CR8=%#lx\n",
|
||||
Frame->cr0, Frame->cr2, Frame->cr3, Frame->cr4, Frame->cr8);
|
||||
@ -286,6 +292,8 @@ nsa void HandleException(CPU::ExceptionFrame *Frame)
|
||||
CPU::PageTable(KernelPageTable);
|
||||
InitFont();
|
||||
|
||||
#if defined(__amd64__) || defined(__i386__)
|
||||
|
||||
/* First check the exception */
|
||||
if (unlikely(Frame->InterruptNumber == CPU::x86::DoubleFault))
|
||||
{
|
||||
@ -343,6 +351,7 @@ nsa void HandleException(CPU::ExceptionFrame *Frame)
|
||||
|
||||
ExceptionExit:
|
||||
ExceptionLock.store(false, std::memory_order_release);
|
||||
#endif
|
||||
}
|
||||
|
||||
nsa void BaseBufferStackError(bool Stack)
|
||||
|
@ -65,7 +65,9 @@ __no_sanitize("undefined") nsa bool CrashUHCIKeyboardDriver::Initialize()
|
||||
/* FIXME: stub */
|
||||
|
||||
debug("Initializing controller");
|
||||
#if defined(__amd64__) || defined(__i386__)
|
||||
outw((uint16_t)((uintptr_t)io + 0xC0), 0x8F00); /* Disable Legacy Mode Support */
|
||||
#endif
|
||||
|
||||
/* Disable All Interrupts */
|
||||
io->USBINTR.TOCRC = 0;
|
||||
|
@ -137,9 +137,7 @@ nsa const char *ExGetKSymbol(CPU::ExceptionFrame *Frame)
|
||||
Frame->eip > (uintptr_t)&_kernel_end)
|
||||
return "<OUTSIDE KERNEL>";
|
||||
#elif defined(__aarch64__)
|
||||
if (Frame->pc < (uintptr_t)&_kernel_start &&
|
||||
Frame->pc > (uintptr_t)&_kernel_end)
|
||||
return "<OUTSIDE KERNEL>";
|
||||
#warning "aarch64 not implemented"
|
||||
#endif
|
||||
|
||||
#if defined(__amd64__)
|
||||
@ -147,7 +145,8 @@ nsa const char *ExGetKSymbol(CPU::ExceptionFrame *Frame)
|
||||
#elif defined(__i386__)
|
||||
return ExGetKSymbolByAddress(Frame->eip);
|
||||
#elif defined(__aarch64__)
|
||||
return ExGetKSymbolByAddress(Frame->pc);
|
||||
#warning "aarch64 not implemented"
|
||||
return "stub";
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -302,9 +301,16 @@ nsa void DisplayMainScreen(CPU::ExceptionFrame *Frame)
|
||||
x86Exceptions[Frame->InterruptNumber].Name,
|
||||
x86Exceptions[Frame->InterruptNumber].Mnemonic,
|
||||
#elif defined(__aarch64__)
|
||||
#error "AA64 not implemented"
|
||||
"stub",
|
||||
"stub",
|
||||
#warning "aarch64 not implemented"
|
||||
#endif
|
||||
#if defined(__amd64__) || defined(__i386__)
|
||||
Frame->InterruptNumber);
|
||||
#elif defined(__aarch64__)
|
||||
0);
|
||||
#warning "aarch64 not implemented"
|
||||
#endif
|
||||
#if defined(__amd64__) || defined(__i386__)
|
||||
ExPrint("Cause: %s\n", x86Exceptions[Frame->InterruptNumber].Cause);
|
||||
#endif
|
||||
@ -315,7 +321,8 @@ nsa void DisplayMainScreen(CPU::ExceptionFrame *Frame)
|
||||
#elif defined(__i386__)
|
||||
Frame->eip);
|
||||
#elif defined(__aarch64__)
|
||||
Frame->pc);
|
||||
0);
|
||||
#warning "aarch64 not implemented"
|
||||
#endif
|
||||
|
||||
CPUData *core = GetCurrentCPU();
|
||||
@ -342,7 +349,7 @@ arch void DisplayDetailsScreen(CPU::ExceptionFrame *Frame);
|
||||
nsa void DisplayStackScreen(CPU::ExceptionFrame *Frame)
|
||||
{
|
||||
Memory::Virtual vmm;
|
||||
struct StackFrame *sf;
|
||||
struct StackFrame *sf = nullptr;
|
||||
#if defined(__amd64__)
|
||||
sf = (struct StackFrame *)Frame->rbp;
|
||||
#elif defined(__i386__)
|
||||
@ -353,6 +360,7 @@ nsa void DisplayStackScreen(CPU::ExceptionFrame *Frame)
|
||||
|
||||
if (!vmm.Check(sf))
|
||||
{
|
||||
#if defined(__amd64__) || defined(__i386__)
|
||||
void *ptr = ((Memory::PageTable *)Frame->cr3)->Get(sf);
|
||||
debug("Virtual pointer %#lx -> %#lx", sf, ptr);
|
||||
if (vmm.Check(ptr))
|
||||
@ -362,17 +370,18 @@ nsa void DisplayStackScreen(CPU::ExceptionFrame *Frame)
|
||||
ExPrint("\x1b[31m< No stack trace available. >\x1b[0m\n");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* FIXME: Get symbol offset more efficiently */
|
||||
|
||||
uintptr_t fIP;
|
||||
uintptr_t fIP = 0;
|
||||
#if defined(__amd64__)
|
||||
fIP = Frame->rip;
|
||||
#elif defined(__i386__)
|
||||
fIP = Frame->eip;
|
||||
#elif defined(__aarch64__)
|
||||
fIP = Frame->pc;
|
||||
#warning "aarch64 not implemented"
|
||||
#endif
|
||||
|
||||
ExPrint("%p", (void *)fIP);
|
||||
@ -557,6 +566,7 @@ nsa void DisplayCrashScreen(CPU::ExceptionFrame *Frame)
|
||||
DisplayBottomOverlay();
|
||||
|
||||
#ifdef DEBUG
|
||||
#if defined(__amd64__) || defined(__i386__)
|
||||
static int once = 0;
|
||||
static uint8_t com4 = 0xFF;
|
||||
if (!once++)
|
||||
@ -657,6 +667,7 @@ nsa void DisplayCrashScreen(CPU::ExceptionFrame *Frame)
|
||||
ExPrint(keyBuf);
|
||||
}
|
||||
#endif
|
||||
#endif // DEBUG
|
||||
debug("cpu halted");
|
||||
CPU::Halt(true);
|
||||
}
|
||||
@ -965,8 +976,10 @@ nsa void UserInput(char *Input)
|
||||
#ifdef DEBUG
|
||||
else if (strcmp(Input, "pt") == 0)
|
||||
{
|
||||
/* Helpful for qemu "info tlb" command */
|
||||
/* Helpful for qemu "info tlb" command */
|
||||
#if defined(__amd64__) || defined(__i386__)
|
||||
CPU::PageTable((void *)ExFrame->cr3);
|
||||
#endif
|
||||
ExPrint("Here be dragons\n");
|
||||
}
|
||||
else if (strcmp(Input, "ps") == 0)
|
||||
|
@ -86,6 +86,7 @@ nsa bool UserModeExceptionHandler(CPU::ExceptionFrame *Frame)
|
||||
#endif
|
||||
|
||||
int sigRet = -1;
|
||||
#if defined(__amd64__) || defined(__i386__)
|
||||
switch (Frame->InterruptNumber)
|
||||
{
|
||||
case CPU::x86::PageFault:
|
||||
@ -153,6 +154,7 @@ nsa bool UserModeExceptionHandler(CPU::ExceptionFrame *Frame)
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (sigRet == 0)
|
||||
{
|
||||
|
Reference in New Issue
Block a user