20 #include "InterruptManager.h" 21 #include "pedigree/kernel/machine/Machine.h" 22 #include "pedigree/kernel/machine/types.h" 23 #include "pedigree/kernel/panic.h" 24 #include "pedigree/kernel/processor/Processor.h" 25 #include "pedigree/kernel/utilities/utility.h" 27 #include "pedigree/kernel/debugger/Debugger.h" 30 #define SYSCALL_INTERRUPT_NUMBER 8 31 #define BREAKPOINT_INTERRUPT_NUMBER 9 33 const char *g_ExceptionNames[32] = {
35 "TLB modification exception",
36 "TLB exception (load or instruction fetch)",
37 "TLB exception (store)",
38 "Address error exception (load or instruction fetch)",
39 "Address error exception (store)",
40 "Bus error exception (instruction fetch)",
41 "Bus error exception (data: load or store)",
43 "Breakpoint exception",
44 "Reserved instruction exception",
45 "Coprocessor unusable exception",
46 "Arithmetic overflow exception",
48 "LDCz/SDCz to uncached address",
49 "Virtual coherency exception",
50 "Machine check exception",
51 "Floating point exception",
57 "Watchpoint exception",
83 if (
UNLIKELY(interruptNumber >= 256))
85 if (
UNLIKELY(handler != 0 && m_Handler[interruptNumber] != 0))
87 if (
UNLIKELY(handler == 0 && m_Handler[interruptNumber] == 0))
90 m_Handler[interruptNumber] = handler;
100 if (
UNLIKELY(interruptNumber >= 256))
102 if (
UNLIKELY(handler != 0 && m_DbgHandler[interruptNumber] != 0))
104 if (
UNLIKELY(handler == 0 && m_DbgHandler[interruptNumber] == 0))
107 m_DbgHandler[interruptNumber] = handler;
126 if (
UNLIKELY(Service >= serviceEnd))
128 if (
UNLIKELY(handler != 0 && m_SyscallHandler[Service] != 0))
130 if (
UNLIKELY(handler == 0 && m_SyscallHandler[Service] == 0))
133 m_SyscallHandler[Service] = handler;
138 Service_t service, uintptr_t
function, uintptr_t p1, uintptr_t p2,
139 uintptr_t p3, uintptr_t p4, uintptr_t p5)
154 size_t intNumber = interruptState.getInterruptNumber();
158 if (m_Instance.m_DbgHandler[intNumber] != 0)
159 m_Instance.m_DbgHandler[intNumber]->interrupt(
160 intNumber, interruptState);
164 if (intNumber == SYSCALL_INTERRUPT_NUMBER)
166 size_t serviceNumber = interruptState.getSyscallService();
168 serviceNumber < serviceEnd &&
169 m_Instance.m_SyscallHandler[serviceNumber] != 0))
170 m_Instance.m_SyscallHandler[serviceNumber]->syscall(interruptState);
173 else if (m_Instance.m_Handler[intNumber] != 0)
174 m_Instance.m_Handler[intNumber]->interrupt(intNumber, interruptState);
180 e.append(
"Exception #");
181 e.append(intNumber, 10);
183 e.append(g_ExceptionNames[intNumber]);
207 for (
size_t i = 0; i < 256; i++)
216 for (
size_t i = 0; i < serviceEnd; i++)
217 m_SyscallHandler[i] = 0;
virtual ~ARM926EInterruptManager()
static EXPORTED_PUBLIC SyscallManager & instance()
static Debugger & instance()
Handles interrupts and interrupt registrations from kernel components.
virtual bool registerSyscallHandler(Service_t Service, SyscallHandler *handler)
virtual size_t getDebugInterruptNumber() PURE
void start(InterruptState &state, LargeStaticString &description)
ARM926EInterruptManager()
virtual size_t getBreakpointInterruptNumber() PURE
virtual bool registerInterruptHandlerDebugger(size_t interruptNumber, InterruptHandler *handler)
virtual uintptr_t syscall(Service_t service, uintptr_t function, uintptr_t p1=0, uintptr_t p2=0, uintptr_t p3=0, uintptr_t p4=0, uintptr_t p5=0)
virtual bool registerInterruptHandler(size_t interruptNumber, InterruptHandler *handler)
static ARM926EInterruptManager & instance()
Abstract base class for interrupt-handlers.
void EXPORTED_PUBLIC panic(const char *msg) NORETURN
static void initialiseProcessor()
static void interrupt(InterruptState &interruptState)
static InterruptManager & instance()
static ARM926EInterruptManager m_Instance