fix a bug
This commit is contained in:
parent
406d3a09f9
commit
8c82c9b6d8
|
@ -22,18 +22,11 @@ void consoleinit(void);
|
|||
void consoleintr(int);
|
||||
void consputc(int);
|
||||
|
||||
// sbi.c
|
||||
// void sbi_console_putchar(int ch);
|
||||
// int sbi_console_getchar();
|
||||
// void sbi_send_ipi(const unsigned long *hart_mask);
|
||||
// void sbi_set_timer(uint64 stime_value);
|
||||
|
||||
// timer.c
|
||||
void timerinit();
|
||||
void supervisor_timer();
|
||||
// static inline void set_next_timeout();
|
||||
uint64 read_time();
|
||||
void set_next_timeout();
|
||||
void timer_tick();
|
||||
|
||||
// exec.c
|
||||
int exec(char*, char**);
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include "sbi.h"
|
||||
|
||||
static int tick = 0;
|
||||
|
||||
void timerinit() {
|
||||
// enable supervisor-mode timer interrupts.
|
||||
w_sie(r_sie() | SIE_STIE);
|
||||
|
@ -14,20 +15,19 @@ void timerinit() {
|
|||
printf("timerinit\n");
|
||||
}
|
||||
|
||||
void supervisor_timer() {
|
||||
timer_tick();
|
||||
}
|
||||
|
||||
static inline void
|
||||
void
|
||||
set_next_timeout() {
|
||||
// printf("[Timer]read_time: %d\n", r_time());
|
||||
// There is a very strang bug,
|
||||
// if comment the printf line below
|
||||
// the timer will not work.
|
||||
printf("");
|
||||
sbi_set_timer(r_time() + INTERVAL);
|
||||
}
|
||||
|
||||
uint64 read_time() {
|
||||
uint64 *mtime = (uint64 *)0xffffffff0200bff8;
|
||||
return *(mtime);
|
||||
}
|
||||
// uint64 read_time() {
|
||||
// uint64 *mtime = (uint64 *)0xffffffff0200bff8;
|
||||
// return *(mtime);
|
||||
// }
|
||||
|
||||
void timer_tick() {
|
||||
set_next_timeout();
|
||||
|
|
|
@ -13,7 +13,6 @@ extern char trampoline[], uservec[], userret[];
|
|||
|
||||
// in kernelvec.S, calls kerneltrap().
|
||||
void kernelvec();
|
||||
void __interrupt();
|
||||
|
||||
extern int devintr();
|
||||
|
||||
|
|
Loading…
Reference in New Issue