1/* 2 * Copyright (c) 2023 Frontgrade Gaisler AB 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7/* 8 * This file contains the trap entry for SPARC operating with 9 * single-vector trap model, defined in SPARC V8E. The processor 10 * redirects execution to a single entry on any trap event. From 11 * there, two levels of look-up tables are used to find the trap 12 * handler. 13 * 14 * - Execution time is constant. 15 * - Condition flags are not modified. 16 * - Provides handler with PSR in l0, TBR in l6 17 * - This SVT implementation is less than 400 bytes long. (An MVT 18 * table is always 4096 bytes long.) 19 * 20 * See trap_table_mvt.S for information about SPARC trap types. 21 */ 22 23#include <zephyr/toolchain.h> 24#include <zephyr/linker/sections.h> 25#include <zephyr/arch/sparc/sparc.h> 26 27#ifdef CONFIG_IRQ_OFFLOAD 28 #define IRQ_OFFLOAD_HANDLER __sparc_trap_irq_offload 29#else 30 #define IRQ_OFFLOAD_HANDLER __sparc_trap_fault 31#endif 32 33GTEXT(__sparc_trap_table) 34GTEXT(__start) 35 36SECTION_SUBSEC_FUNC(TEXT, traptable, __sparc_trap_table) 37__start: 38 rd %psr, %l0 39 mov %tbr, %l6 40 41 and %l6, 0xf00, %l7 42 srl %l7, 6, %l7 43 set __sparc_trap_table_svt_level0, %l4 44 ld [%l4 + %l7], %l4 45 46 and %l6, 0x0f0, %l7 47 srl %l7, 2, %l7 48 ld [%l4 + %l7], %l4 49 50 srl %l6, 4, %l3 51 jmp %l4 52 and %l3, 0xf, %l3 /* Interrupt level */ 53 54__sparc_trap_svt_in_trap: 55 ta 0x00 56 nop 57 58SECTION_VAR(RODATA, __sparc_trap_table_svt_tables) 59 .align 4 60__sparc_trap_table_svt_level0: 61 .word __sparc_trap_table_svt_00 62 .word __sparc_trap_table_svt_10 63 .word __sparc_trap_table_svt_allbad 64 .word __sparc_trap_table_svt_allbad 65 .word __sparc_trap_table_svt_allbad 66 .word __sparc_trap_table_svt_allbad 67 .word __sparc_trap_table_svt_allbad 68 .word __sparc_trap_table_svt_allbad 69 .word __sparc_trap_table_svt_80 70 .word __sparc_trap_table_svt_allbad 71 .word __sparc_trap_table_svt_allbad 72 .word __sparc_trap_table_svt_allbad 73 .word __sparc_trap_table_svt_allbad 74 .word __sparc_trap_table_svt_allbad 75 .word __sparc_trap_table_svt_allbad 76 .word __sparc_trap_table_svt_allbad 77 78__sparc_trap_table_svt_00: 79 .word __sparc_trap_reset 80 .word __sparc_trap_fault 81 .word __sparc_trap_fault 82 .word __sparc_trap_fault 83 .word __sparc_trap_fault 84 .word __sparc_trap_window_overflow 85 .word __sparc_trap_window_underflow 86__sparc_trap_table_svt_allbad: 87 .word __sparc_trap_fault 88 .word __sparc_trap_fault 89 .word __sparc_trap_fault 90 .word __sparc_trap_fault 91 .word __sparc_trap_fault 92 .word __sparc_trap_fault 93 .word __sparc_trap_fault 94 .word __sparc_trap_fault 95 .word __sparc_trap_fault 96 .word __sparc_trap_fault 97 .word __sparc_trap_fault 98 .word __sparc_trap_fault 99 .word __sparc_trap_fault 100 .word __sparc_trap_fault 101 .word __sparc_trap_fault 102 .word __sparc_trap_fault 103 104__sparc_trap_table_svt_10: 105 .word __sparc_trap_fault 106 .word __sparc_trap_interrupt 107 .word __sparc_trap_interrupt 108 .word __sparc_trap_interrupt 109 .word __sparc_trap_interrupt 110 .word __sparc_trap_interrupt 111 .word __sparc_trap_interrupt 112 .word __sparc_trap_interrupt 113 .word __sparc_trap_interrupt 114 .word __sparc_trap_interrupt 115 .word __sparc_trap_interrupt 116 .word __sparc_trap_interrupt 117 .word __sparc_trap_interrupt 118 .word __sparc_trap_interrupt 119 .word __sparc_trap_interrupt 120 .word __sparc_trap_interrupt 121 122__sparc_trap_table_svt_80: 123 .word __sparc_trap_svt_in_trap 124 .word __sparc_trap_fault 125 .word __sparc_trap_fault 126 .word __sparc_trap_flush_windows 127 .word __sparc_trap_fault 128 .word __sparc_trap_fault 129 .word __sparc_trap_fault 130 .word __sparc_trap_fault 131 .word __sparc_trap_fault 132 .word __sparc_trap_sw_set_pil 133 .word __sparc_trap_fault 134 .word __sparc_trap_fault 135 .word __sparc_trap_fault 136 .word IRQ_OFFLOAD_HANDLER 137 .word __sparc_trap_fault 138 .word __sparc_trap_except_reason 139