From a9c1a6f742886a9d45e5c625cf4f9b1b5c7a8cc4 Mon Sep 17 00:00:00 2001 From: Robert Morris Date: Mon, 3 Jun 2019 14:13:07 -0400 Subject: takes one uart input interrupt, then panics --- trap.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'trap.c') diff --git a/trap.c b/trap.c index 74f3456..2b8fd41 100644 --- a/trap.c +++ b/trap.c @@ -42,6 +42,19 @@ usertrap(void) // save user program counter. p->tf->epc = r_sepc(); + + // PLIC setup + // qemu makes UART0 be interrupt number 10. + int irq = 10; + // set uart's priority to be non-zero (otherwise disabled). + *(uint*)(0x0c000000L + irq*4) = 1; + // set uart's enable bit for hart 0 s-mode. + *(uint*)0x0c002080 = (1 << irq); + + // hart 0 S-mode priority threshold. + *(uint*)0x0c201000 = 0; + + intr_on(); if(r_scause() == 8){ // system call -- cgit v1.2.3