1 #ifndef __LUNAIX_ARCH_HART_H
2 #define __LUNAIX_ARCH_HART_H
7 #include <lunaix/compiler.h>
30 struct regcontext registers;
34 volatile struct exec_param* execp;
40 struct hart_state* parent_state;
52 hart_flow_redirect(struct hart_state* hstate, ptr_t pc, ptr_t sp)
54 hstate->execp->eip = pc;
55 hstate->execp->esp = sp;
59 hart_pc(struct hart_state* hstate)
61 return hstate->execp->eip;
65 hart_sp(struct hart_state* hstate)
67 return hstate->execp->esp;
71 kernel_context(struct hart_state* hstate)
73 return !((hstate->execp->cs) & 0b11);
77 hart_stack_frame(struct hart_state* hstate)
79 return hstate->registers.ebp;
83 hart_vector_stamp(struct hart_state* hstate) {
84 return hstate->execp->vector;
87 static inline unsigned int
88 hart_ecause(struct hart_state* hstate) {
89 return hstate->execp->err_code;
92 static inline struct hart_state*
93 hart_parent_state(struct hart_state* hstate)
95 return hstate->execp->parent_state;
99 hart_push_state(struct hart_state* p_hstate, struct hart_state* hstate)
101 hstate->execp->parent_state = p_hstate;
106 #endif /* __LUNAIX_ARCH_HART_H */