1 /*
2  * Copyright (c) 2021 Travis Geiselbrecht
3  *
4  * Use of this source code is governed by a MIT-style
5  * license that can be found in the LICENSE file or at
6  * https://opensource.org/licenses/MIT
7  */
8 #include <arch/m68k.h>
9 #include <inttypes.h>
10 #include <lk/debug.h>
11 #include <lk/trace.h>
12 #include <kernel/thread.h>
13 
14 #define LOCAL_TRACE 0
15 
16 // defined in platform interrupt controller
17 extern enum handler_return m68k_platform_irq(uint8_t irq);
18 
m68k_exception(void * frame,uint8_t code)19 void m68k_exception(void *frame, uint8_t code) {
20     LTRACEF("frame %p, code %hhu\n", frame, code);
21 
22     panic("unimplemented exception %hhu\n", code);
23 }
24 
m68k_irq(void * frame,uint8_t code)25 void m68k_irq(void *frame, uint8_t code) {
26     LTRACEF("frame %p, code %hhu\n", frame, code);
27 
28     if (unlikely(code == 0)) {
29         // spurious interrupt
30         return;
31     }
32 
33     enum handler_return ret = m68k_platform_irq(code);
34     if (ret == INT_RESCHEDULE) {
35         thread_preempt();
36     }
37 }
38