#include <lunaix/bits.h>
#include <asm/aa64_spsr.h>
-#define SYNDROME_ETYPE BITS(63, 56)
+#define SYNDROME_ETYPE BITFIELD(63, 56)
struct hart_state;
union {
reg_t x[31];
struct {
- reg_t x[29];
+ reg_t x_[29];
reg_t fp;
reg_t lr;
};
reg_t link;
struct {
reg_t sp_el0;
- reg_t sp_el1;
+ reg_t rsvd;
};
reg_t syndrome;
} compact align(16);
static inline int
-hart_vector_stamp(struct hart_state* hstate) {
+hart_vector_stamp(struct hart_state* hstate)
+{
return BITS_GET(hstate->execp.syndrome, SYNDROME_ETYPE);
}
static inline unsigned int
-hart_ecause(struct hart_state* hstate) {
+hart_ecause(struct hart_state* hstate)
+{
return hstate->execp.syndrome;
}
static inline ptr_t
hart_sp(struct hart_state* hstate)
{
- if (spsr_from_el0(hstate->execp.spsr)) {
- return hstate->execp.sp_el0;
- }
- return hstate->execp.sp_el1;
+ return __ptr(&hstate[-1]);
}
static inline bool
kernel_context(struct hart_state* hstate)
{
- // TODO
- return false;
+ reg_t spsr;
+
+ spsr = hstate->execp.spsr;
+ return !spsr_from_el0(spsr);
}
static inline ptr_t