1 #ifndef ROS_ARCH_TRAP_H
2 #define ROS_ARCH_TRAP_H
5 # define SIZEOF_HW_TRAPFRAME (36*8)
7 # define SIZEOF_HW_TRAPFRAME (36*4)
12 #ifndef ROS_KERN_TRAP_H
13 #error "Do not include include arch/trap.h directly"
16 #include <ros/trapframe.h>
17 #include <arch/arch.h>
19 /* Kernel message interrupt vector. ignored, for the most part */
20 #define I_KERNEL_MSG 255
21 #warning "make sure this poke vector is okay"
22 /* this is for an ipi that just wakes a core, but has no handler (for now) */
23 #define I_POKE_CORE 254
25 static inline bool in_kernel(struct hw_trapframe *hw_tf)
27 return hw_tf->sr & SR_PS;
30 static inline uintptr_t get_hwtf_pc(struct hw_trapframe *hw_tf)
34 //return hw_tf->tf_rip;
37 static inline uintptr_t get_hwtf_fp(struct hw_trapframe *hw_tf)
39 /* do you even have frame pointers? this is used for backtrace, but if you
40 * don't use FPs, we'll need to change up our parameters or something. */
43 //return hw_tf->tf_rbp;
46 static inline void __attribute__((always_inline))
47 set_stack_pointer(uintptr_t sp)
49 asm volatile("move sp, %0" : : "r"(sp) : "memory");
52 static inline void __attribute__((always_inline))
53 set_frame_pointer(uintptr_t fp)
55 #warning "brho is just guessing here."
56 asm volatile("move fp, %0" : : "r"(fp) : "memory");
59 void handle_trap(struct hw_trapframe *hw_tf);
60 int emulate_fpu(struct hw_trapframe *hw_tf);