interplane.Get Omega
Read in your language

physics-mv

FORGE: request-bound machine realization, providers and verification for AienOS. Host, simulated and GB10 hardware paths have separate evidence.

Brought by drakestapleton

branch main Branches Tags History

physics-mv / m3 / vector_table.s

205 lines · 4929 bytes Raw Blame History
1/*
2 * m3/vector_table.s - 2,048-Byte Aligned AArch64 Exception Vector Table
3 * Milestone 3: PHYSICS_EFFECTS (Sovereign Machine)
4 *
5 * Vector Table Geometry:
6 * Base Alignment: 2,048 bytes (0x800)
7 * Total Span: exactly 2,048 bytes (0x000..0x7FF)
8 * 16 architectural vector slots spaced exactly 128 bytes (0x80) apart:
9 * 0x000: Current EL with SP0 (Sync)
10 * 0x080: Current EL with SP0 (IRQ)
11 * 0x100: Current EL with SP0 (FIQ)
12 * 0x180: Current EL with SP0 (SError)
13 * 0x200: Current EL with SPx (Sync -> Main Trap)
14 * 0x280: Current EL with SPx (IRQ)
15 * 0x300: Current EL with SPx (FIQ)
16 * 0x380: Current EL with SPx (SError)
17 * 0x400: Lower EL AArch64 (Sync)
18 * 0x480: Lower EL AArch64 (IRQ)
19 * 0x500: Lower EL AArch64 (FIQ)
20 * 0x580: Lower EL AArch64 (SError)
21 * 0x600: Lower EL AArch32 (Sync)
22 * 0x680: Lower EL AArch32 (IRQ)
23 * 0x700: Lower EL AArch32 (FIQ)
24 * 0x780: Lower EL AArch32 (SError)
25 */
26
27 .global vector_table
28
29 .section .text.vectors, "ax"
30 .balign 2048
31
32vector_table:
33/* Slot 0 (0x000): Current EL with SP0 - Sync */
34 mov x0, #0
35 b common_trap
36 .balign 128
37
38/* Slot 1 (0x080): Current EL with SP0 - IRQ */
39 mov x0, #1
40 b common_trap
41 .balign 128
42
43/* Slot 2 (0x100): Current EL with SP0 - FIQ */
44 mov x0, #2
45 b common_trap
46 .balign 128
47
48/* Slot 3 (0x180): Current EL with SP0 - SError */
49 mov x0, #3
50 b common_trap
51 .balign 128
52
53/* Slot 4 (0x200): Current EL with SPx - Sync */
54 mov x0, #4
55 b common_trap
56 .balign 128
57
58/* Slot 5 (0x280): Current EL with SPx - IRQ */
59 mov x0, #5
60 b common_trap
61 .balign 128
62
63/* Slot 6 (0x300): Current EL with SPx - FIQ */
64 mov x0, #6
65 b common_trap
66 .balign 128
67
68/* Slot 7 (0x380): Current EL with SPx - SError */
69 mov x0, #7
70 b common_trap
71 .balign 128
72
73/* Slot 8 (0x400): Lower EL AArch64 - Sync */
74 mov x0, #8
75 b common_trap
76 .balign 128
77
78/* Slot 9 (0x480): Lower EL AArch64 - IRQ */
79 mov x0, #9
80 b common_trap
81 .balign 128
82
83/* Slot 10 (0x500): Lower EL AArch64 - FIQ */
84 mov x0, #10
85 b common_trap
86 .balign 128
87
88/* Slot 11 (0x580): Lower EL AArch64 - SError */
89 mov x0, #11
90 b common_trap
91 .balign 128
92
93/* Slot 12 (0x600): Lower EL AArch32 - Sync */
94 mov x0, #12
95 b common_trap
96 .balign 128
97
98/* Slot 13 (0x680): Lower EL AArch32 - IRQ */
99 mov x0, #13
100 b common_trap
101 .balign 128
102
103/* Slot 14 (0x700): Lower EL AArch32 - FIQ */
104 mov x0, #14
105 b common_trap
106 .balign 128
107
108/* Slot 15 (0x780): Lower EL AArch32 - SError */
109 mov x0, #15
110 b common_trap
111 .balign 128
112
113/* Common Trap Handler in general .text section */
114 .section .text, "ax"
115 .balign 4
116common_trap:
117 /* Capture trap state to PHYSICS_BOOT_STATE + 0x80 = 0x40208880 */
118 ldr x1, =0x40208880
119
120 /* Save x2..x30 first */
121 stp x2, x3, [x1, #16]
122 stp x4, x5, [x1, #32]
123 stp x6, x7, [x1, #48]
124 stp x8, x9, [x1, #64]
125 stp x10, x11, [x1, #80]
126 stp x12, x13, [x1, #96]
127 stp x14, x15, [x1, #112]
128 stp x16, x17, [x1, #128]
129 stp x18, x19, [x1, #144]
130 stp x20, x21, [x1, #160]
131 stp x22, x23, [x1, #176]
132 stp x24, x25, [x1, #192]
133 stp x26, x27, [x1, #208]
134 stp x28, x29, [x1, #224]
135 str x30, [x1, #240]
136
137 /* Save slot index to +0x100 */
138 str x0, [x1, #0x100]
139
140 /* Save SP to +0x0F8 */
141 mov x2, sp
142 str x2, [x1, #0x0F8]
143
144 /* Save CurrentEL */
145 mrs x3, CurrentEL
146 str x3, [x1, #0x108]
147
148 /* Save ESR, ELR, SPSR */
149 mrs x4, esr_el1
150 str x4, [x1, #0x110]
151 mrs x5, elr_el1
152 str x5, [x1, #0x118]
153 mrs x6, spsr_el1
154 str x6, [x1, #0x120]
155
156 /* Evaluate ESR.EC to check FAR validity */
157 lsr x7, x4, #26 /* x7 = EC */
158 cmp x7, #0x20 /* Instruction abort lower EL */
159 b.eq .Lfar_valid
160 cmp x7, #0x21 /* Instruction abort same EL */
161 b.eq .Lfar_valid
162 cmp x7, #0x22 /* PC alignment */
163 b.eq .Lfar_valid
164 cmp x7, #0x24 /* Data abort lower EL */
165 b.eq .Lfar_valid
166 cmp x7, #0x25 /* Data abort same EL */
167 b.eq .Lfar_valid
168 cmp x7, #0x26 /* SP alignment */
169 b.eq .Lfar_valid
170
171 /* FAR not valid */
172 str xzr, [x1, #0x128]
173 str xzr, [x1, #0x130]
174 b .Lwrite_magic
175
176.Lfar_valid:
177 mrs x8, far_el1
178 str x8, [x1, #0x128]
179 mov x9, #1
180 str x9, [x1, #0x130]
181
182.Lwrite_magic:
183 /* Write magic TRAPFRM1 (0x314D524650415254) last */
184 ldr x10, =0x314D524650415254
185 str x10, [x1, #0x138]
186
187 /* Emit diagnostic trap notification to UART */
188 ldr x1, =0x09000000
189 adr x2, .Lmsg_trap
190.Lput_trap_loop:
191 ldrb w3, [x2], #1
192 cbz w3, .Lput_trap_done
1931: ldrb w4, [x1, #24]
194 tst w4, #32
195 b.ne 1b
196 strb w3, [x1]
197 b .Lput_trap_loop
198.Lput_trap_done:
199
200 /* Quiesce into terminal loop */
2012: wfe
202 b 2b
203
204.Lmsg_trap:
205 .asciz "PHYSICS: TRAP_EXCEPTION\n"