1 /* 2 * Copyright 2021, Haiku, Inc. 3 * Distributed under the terms of the MIT License. 4 */ 5 6 7 #ifndef _ARCH_TRAPS_H_ 8 #define _ARCH_TRAPS_H_ 9 10 11 # NOTE: this macro don't save SP, it should be saved manually 12 .macro PushTrapFrame extSize 13 addi sp, sp, -(\extSize + 256) 14 15 sd ra, \extSize + 0*8(sp) 16 sd t6, \extSize + 1*8(sp) 17 # sd sp, \extSize + 2*8(sp) # sp 18 sd gp, \extSize + 3*8(sp) 19 sd tp, \extSize + 4*8(sp) 20 sd t0, \extSize + 5*8(sp) 21 sd t1, \extSize + 6*8(sp) 22 sd t2, \extSize + 7*8(sp) 23 sd t5, \extSize + 8*8(sp) 24 sd s1, \extSize + 9*8(sp) 25 sd a0, \extSize + 10*8(sp) 26 sd a1, \extSize + 11*8(sp) 27 sd a2, \extSize + 12*8(sp) 28 sd a3, \extSize + 13*8(sp) 29 sd a4, \extSize + 14*8(sp) 30 sd a5, \extSize + 15*8(sp) 31 sd a6, \extSize + 16*8(sp) 32 sd a7, \extSize + 17*8(sp) 33 sd s2, \extSize + 18*8(sp) 34 sd s3, \extSize + 19*8(sp) 35 sd s4, \extSize + 20*8(sp) 36 sd s5, \extSize + 21*8(sp) 37 sd s6, \extSize + 22*8(sp) 38 sd s7, \extSize + 23*8(sp) 39 sd s8, \extSize + 24*8(sp) 40 sd s9, \extSize + 25*8(sp) 41 sd s10, \extSize + 26*8(sp) 42 sd s11, \extSize + 27*8(sp) 43 sd t3, \extSize + 28*8(sp) 44 sd t4, \extSize + 29*8(sp) 45 sd fp, \extSize + 30*8(sp) 46 47 addi fp, sp, \extSize + 256 48 .endm 49 50 51 .macro PopTrapFrame extSize 52 ld ra, \extSize + 0*8(sp) 53 ld t6, \extSize + 1*8(sp) 54 # ld sp, \extSize + 2*8(sp) restore later 55 ld gp, \extSize + 3*8(sp) 56 # ld tp, \extSize + 4*8(sp) 57 ld t0, \extSize + 5*8(sp) 58 ld t1, \extSize + 6*8(sp) 59 ld t2, \extSize + 7*8(sp) 60 ld t5, \extSize + 8*8(sp) 61 ld s1, \extSize + 9*8(sp) 62 ld a0, \extSize + 10*8(sp) 63 ld a1, \extSize + 11*8(sp) 64 ld a2, \extSize + 12*8(sp) 65 ld a3, \extSize + 13*8(sp) 66 ld a4, \extSize + 14*8(sp) 67 ld a5, \extSize + 15*8(sp) 68 ld a6, \extSize + 16*8(sp) 69 ld a7, \extSize + 17*8(sp) 70 ld s2, \extSize + 18*8(sp) 71 ld s3, \extSize + 19*8(sp) 72 ld s4, \extSize + 20*8(sp) 73 ld s5, \extSize + 21*8(sp) 74 ld s6, \extSize + 22*8(sp) 75 ld s7, \extSize + 23*8(sp) 76 ld s8, \extSize + 24*8(sp) 77 ld s9, \extSize + 25*8(sp) 78 ld s10, \extSize + 26*8(sp) 79 ld s11, \extSize + 27*8(sp) 80 ld t3, \extSize + 28*8(sp) 81 ld t4, \extSize + 29*8(sp) 82 ld fp, \extSize + 30*8(sp) 83 84 ld sp, \extSize + 2*8(sp) 85 .endm 86 87 88 #endif // _ARCH_TRAPS_H_ 89