diff options
Diffstat (limited to 'pk')
-rw-r--r-- | pk/emulation.c | 10 | ||||
-rw-r--r-- | pk/mentry.S | 4 | ||||
-rw-r--r-- | pk/pk.h | 6 |
3 files changed, 14 insertions, 6 deletions
diff --git a/pk/emulation.c b/pk/emulation.c index bd5b6a8..36c90a6 100644 --- a/pk/emulation.c +++ b/pk/emulation.c @@ -225,15 +225,15 @@ DECLARE_EMULATION_FUNC(emulate_mul_div32) int32_t val; // If compiled with -mno-multiply, GCC will expand these out - if ((insn & MASK_MUL) == MATCH_MULW) + if ((insn & MASK_MULW) == MATCH_MULW) val = rs1 * rs2; - else if ((insn & MASK_DIV) == MATCH_DIV) + else if ((insn & MASK_DIVW) == MATCH_DIVW) val = (int32_t)rs1 / (int32_t)rs2; - else if ((insn & MASK_DIVU) == MATCH_DIVU) + else if ((insn & MASK_DIVUW) == MATCH_DIVUW) val = rs1 / rs2; - else if ((insn & MASK_REM) == MATCH_REM) + else if ((insn & MASK_REMW) == MATCH_REMW) val = (int32_t)rs1 % (int32_t)rs2; - else if ((insn & MASK_REMU) == MATCH_REMU) + else if ((insn & MASK_REMUW) == MATCH_REMUW) val = rs1 % rs2; else return truly_illegal_insn(regs, mcause, mepc, mstatus, insn); diff --git a/pk/mentry.S b/pk/mentry.S index baf35ec..0bc56f0 100644 --- a/pk/mentry.S +++ b/pk/mentry.S @@ -125,6 +125,7 @@ mentry: j init_first_hart .LmultiHart: +#if MAX_HARTS > 1 # make sure our hart id is within a valid range li a1, MAX_HARTS bgeu a0, a1, .LmultiHart @@ -142,6 +143,9 @@ mentry: beqz sp, 1b j init_other_hart +#else + j .LmultiHart +#endif .Linterrupt: sll a1, a1, 1 # discard MSB @@ -3,7 +3,11 @@ #ifndef _PK_H #define _PK_H -#define MAX_HARTS 32 // coupled to width of booted_harts_mask +#ifdef __riscv_atomic +# define MAX_HARTS 32 // coupled to width of booted_harts_mask +#else +# define MAX_HARTS 1 +#endif #ifndef __ASSEMBLER__ |