Added arch framework for handling page faults
[akaros.git] / kern / arch / sparc / trap.h
1 #ifndef ROS_INC_ARCH_TRAP_H
2 #define ROS_INC_ARCH_TRAP_H
3
4 #define SIZEOF_TRAPFRAME_T      0xB0
5 #define SIZEOF_ACTIVE_MESSAGE_T 0x18
6
7 #ifndef __ASSEMBLER__
8
9 #include <ros/common.h>
10
11 typedef struct
12 {
13         uint32_t gpr[32] __attribute__((aligned (8)));
14         uint32_t psr;
15         uint32_t pc;
16         uint32_t npc;
17         uint32_t wim;
18         uint32_t tbr;
19         uint32_t y;
20         uint32_t asr13;
21         uint32_t pad;
22         uint32_t fault_status;
23         uint32_t fault_addr;
24         uint64_t timestamp;
25 } trapframe_t;
26
27 typedef struct
28 {
29         uint32_t fpr[32] __attribute__((aligned (8)));
30         uint32_t fsr;
31 } ancillary_state_t;
32
33 void data_access_exception(trapframe_t* state);
34 void real_fp_exception(trapframe_t* state, ancillary_state_t* astate);
35 void address_unaligned(trapframe_t* state);
36 void illegal_instruction(trapframe_t* state);
37
38 void save_fp_state(ancillary_state_t* silly);
39 void restore_fp_state(ancillary_state_t* silly);
40 void emulate_fpu(trapframe_t* state, ancillary_state_t* astate);
41
42 static inline void set_errno(trapframe_t* tf, uint32_t errno)
43 {
44         tf->gpr[9] = errno;
45 }
46
47 #endif /* !__ASSEMBLER__ */
48
49 #endif /* !ROS_INC_ARCH_TRAP_H */