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 <lk/asm.h>
9
10.text
11
12.macro irq_vector n
13m68k_irq_vector_\n:
14    moveml  %d0-%d7/%a0-%a6, %sp@-
15
16    pea     \n
17    movel   %sp,%sp@-
18    jsr     m68k_irq
19    addaw   #8, %sp
20
21    moveml  %sp@+, %d0-%d7/%a0-%a6
22    rte
23.endm
24
25irq_vector 0
26irq_vector 1
27irq_vector 2
28irq_vector 3
29irq_vector 4
30irq_vector 5
31irq_vector 6
32irq_vector 7
33
34.macro exception_vector name n
35\name:
36    moveml  %d0-%d7/%a0-%a6, %sp@-
37
38    pea     \n
39    movel   %sp,%sp@-
40    jsr     m68k_exception
41    addaw   #8, %sp
42
43    moveml  %sp@+, %d0-%d7/%a0-%a6
44    rte
45.endm
46
47exception_vector m68k_access_fault 2
48exception_vector m68k_address_error 3
49exception_vector m68k_illegal_vector 4
50exception_vector m68k_div_by_zero 5
51exception_vector m68k_chk 6
52exception_vector m68k_trap 7
53exception_vector m68k_priv_violation 8
54exception_vector m68k_trace 9
55exception_vector m68k_unimp_aline 10
56exception_vector m68k_unimp_fline 11
57
58.section .text.vectab
59.align 4
60DATA(exc_vectors)
61.org 0x8
62    .long m68k_access_fault
63    .long m68k_address_error
64    .long m68k_illegal_vector
65    .long m68k_div_by_zero
66    .long m68k_chk
67    .long m68k_trap
68    .long m68k_priv_violation
69    .long m68k_trace
70    .long m68k_unimp_aline
71    .long m68k_unimp_fline
72.org 0x60
73    .long m68k_irq_vector_0
74    .long m68k_irq_vector_1
75    .long m68k_irq_vector_2
76    .long m68k_irq_vector_3
77    .long m68k_irq_vector_4
78    .long m68k_irq_vector_5
79    .long m68k_irq_vector_6
80    .long m68k_irq_vector_7
81.org 4*256
82END_DATA(exc_vectors)
83
84