Skip to content

Commit

Permalink
> compile
Browse files Browse the repository at this point in the history
1911530
lighthouse
Linux VM-24-4-ubuntu 5.4.0-96-generic #109-Ubuntu SMP Wed Jan 12 16:49:16 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
 21:58:14 up 15 days,  4:30,  1 user,  load average: 0.19, 0.10, 0.36
725f6288288a6287883d16838ec407892c4d71
  • Loading branch information
ruichima authored and AnthonyHaozeZhu committed May 30, 2022
1 parent d1ff62b commit a7b7523
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 2 deletions.
3 changes: 3 additions & 0 deletions nanos-lite/src/irq.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ static _RegSet* do_event(_Event e, _RegSet* r) {
case _EVENT_TRAP:
printf("event:self-trapped\n");
return schedule(r);
case _EVENT_IRQ_TIME:
Log("event:IRQ_TIME");
return schedule(r);
default:
panic("Unhandled event ID = %d", e.event);
}
Expand Down
8 changes: 8 additions & 0 deletions nemu/src/cpu/exec/exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ typedef struct {
#define EXW(ex, w) {NULL, concat(exec_, ex), w}
#define EX(ex) EXW(ex, 0)
#define EMPTY EX(inv)
#define TIME_IRQ 32

static inline void set_width(int width) {
if (width == 0) {
Expand Down Expand Up @@ -252,4 +253,11 @@ void exec_wrapper(bool print_flag) {
void difftest_step(uint32_t);
difftest_step(eip);
#endif

if(cpu.INTR & cpu.eflags.IF) {
cpu.INTR = false;
extern void raise_intr(uint8_t NO, vaddr_t ret_addr);
raise_intr(TIME_IRQ, cpu.eip);
update_eip();
}
}
1 change: 1 addition & 0 deletions nemu/src/cpu/intr.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ void raise_intr(uint8_t NO, vaddr_t ret_addr) {
memcpy(&t1, &cpu.eflags, sizeof(cpu.eflags));
rtl_li(&t0, t1);
rtl_push(&t0);
cpu.eflags.IF = 0;
rtl_push(&cpu.cs);
rtl_li(&t0, ret_addr);
rtl_push(&t0);
Expand Down
6 changes: 6 additions & 0 deletions nexus-am/am/arch/x86-nemu/src/asye.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ static _RegSet* (*H)(_Event, _RegSet*) = NULL;
void vecsys();
void vecnull();
void vecself();
void vectime();

_RegSet* irq_handle(_RegSet *tf) {
_RegSet *next = tf;
Expand All @@ -18,6 +19,9 @@ _RegSet* irq_handle(_RegSet *tf) {
case 0x81:
ev.event = _EVENT_TRAP;
break;
case 32:
ev.event = _EVENT_IRQ_TIME;
break;
default:
ev.event = _EVENT_ERROR;
break;
Expand All @@ -43,6 +47,8 @@ void _asye_init(_RegSet*(*h)(_Event, _RegSet*)) {
// -------------------- system call --------------------------
idt[0x80] = GATE(STS_TG32, KSEL(SEG_KCODE), vecsys, DPL_USER);
idt[0x81] = GATE(STS_TG32, KSEL(SEG_KCODE), vecself, DPL_USER);
idt[32] = GATE(STS_TG32, KSEL(SEG_KCODE), vectime, DPL_USER);


set_idt(idt, sizeof(idt));

Expand Down
4 changes: 2 additions & 2 deletions nexus-am/am/arch/x86-nemu/src/pte.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ _RegSet *_umake(_Protect *p, _Area ustack, _Area kstack, void *entry, char *cons
memcpy((void*)ustack.end - 16, (void*)arg1, 4);

_RegSet tf;
tf.eflags = 0x02;
tf.cs = 8;
tf.eflags = 0x02 | FL_IF;
tf.cs = 0;
tf.eip = (uintptr_t) entry;
void *ptf = (void*) (ustack.end - 16 - sizeof(_RegSet));
memcpy(ptf, (void*)&tf, sizeof(_RegSet));
Expand Down
1 change: 1 addition & 0 deletions nexus-am/am/arch/x86-nemu/src/trap.S
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
.globl vecsys; vecsys: pushl $0; pushl $0x80; jmp asm_trap
.globl vecnull; vecnull: pushl $0; pushl $-1; jmp asm_trap
.globl vecself; vecself: pushl $0; pushl $0x81; jmp asm_trap
.globl vectime; vectime: pushl $0; pushl $32; jmp asm_trap

asm_trap:
pushal
Expand Down

0 comments on commit a7b7523

Please sign in to comment.