more explicable scratch area size for machine-mode timer interrupts
This commit is contained in:
parent
0c55849d28
commit
6c16759503
|
@ -93,8 +93,8 @@ kernelvec:
|
||||||
timervec:
|
timervec:
|
||||||
# start.c has set up the memory that mscratch points to:
|
# start.c has set up the memory that mscratch points to:
|
||||||
# scratch[0,8,16] : register save area.
|
# scratch[0,8,16] : register save area.
|
||||||
# scratch[32] : address of CLINT's MTIMECMP register.
|
# scratch[24] : address of CLINT's MTIMECMP register.
|
||||||
# scratch[40] : desired interval between interrupts.
|
# scratch[32] : desired interval between interrupts.
|
||||||
|
|
||||||
csrrw a0, mscratch, a0
|
csrrw a0, mscratch, a0
|
||||||
sd a1, 0(a0)
|
sd a1, 0(a0)
|
||||||
|
@ -103,8 +103,8 @@ timervec:
|
||||||
|
|
||||||
# schedule the next timer interrupt
|
# schedule the next timer interrupt
|
||||||
# by adding interval to mtimecmp.
|
# by adding interval to mtimecmp.
|
||||||
ld a1, 32(a0) # CLINT_MTIMECMP(hart)
|
ld a1, 24(a0) # CLINT_MTIMECMP(hart)
|
||||||
ld a2, 40(a0) # interval
|
ld a2, 32(a0) # interval
|
||||||
ld a3, 0(a1)
|
ld a3, 0(a1)
|
||||||
add a3, a3, a2
|
add a3, a3, a2
|
||||||
sd a3, 0(a1)
|
sd a3, 0(a1)
|
||||||
|
|
|
@ -10,8 +10,8 @@ void timerinit();
|
||||||
// entry.S needs one stack per CPU.
|
// entry.S needs one stack per CPU.
|
||||||
__attribute__ ((aligned (16))) char stack0[4096 * NCPU];
|
__attribute__ ((aligned (16))) char stack0[4096 * NCPU];
|
||||||
|
|
||||||
// scratch area for timer interrupt, one per CPU.
|
// a scratch area per CPU for machine-mode timer interrupts.
|
||||||
uint64 mscratch0[NCPU * 32];
|
uint64 timer_scratch[NCPU][5];
|
||||||
|
|
||||||
// assembly code in kernelvec.S for machine-mode timer interrupt.
|
// assembly code in kernelvec.S for machine-mode timer interrupt.
|
||||||
extern void timervec();
|
extern void timervec();
|
||||||
|
@ -64,12 +64,12 @@ timerinit()
|
||||||
*(uint64*)CLINT_MTIMECMP(id) = *(uint64*)CLINT_MTIME + interval;
|
*(uint64*)CLINT_MTIMECMP(id) = *(uint64*)CLINT_MTIME + interval;
|
||||||
|
|
||||||
// prepare information in scratch[] for timervec.
|
// prepare information in scratch[] for timervec.
|
||||||
// scratch[0..3] : space for timervec to save registers.
|
// scratch[0..2] : space for timervec to save registers.
|
||||||
// scratch[4] : address of CLINT MTIMECMP register.
|
// scratch[3] : address of CLINT MTIMECMP register.
|
||||||
// scratch[5] : desired interval (in cycles) between timer interrupts.
|
// scratch[4] : desired interval (in cycles) between timer interrupts.
|
||||||
uint64 *scratch = &mscratch0[32 * id];
|
uint64 *scratch = &timer_scratch[id][0];
|
||||||
scratch[4] = CLINT_MTIMECMP(id);
|
scratch[3] = CLINT_MTIMECMP(id);
|
||||||
scratch[5] = interval;
|
scratch[4] = interval;
|
||||||
w_mscratch((uint64)scratch);
|
w_mscratch((uint64)scratch);
|
||||||
|
|
||||||
// set the machine-mode trap handler.
|
// set the machine-mode trap handler.
|
||||||
|
|
Loading…
Reference in a new issue