From 3deaef2a5d5ca3ad8a4339c21be3b054fba4fda2 Mon Sep 17 00:00:00 2001 From: Lee Lup Yuen Date: Sat, 20 Jan 2024 09:40:32 +0800 Subject: [PATCH] To handle a keypress, we trigger the UART3 Interrupt --- riscv_cpu.c | 1 + virtio.c | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/riscv_cpu.c b/riscv_cpu.c index 26f9ba3..c20e8e7 100644 --- a/riscv_cpu.c +++ b/riscv_cpu.c @@ -1157,6 +1157,7 @@ static void raise_exception2(RISCVCPUState *s, uint32_t cause, static void raise_exception(RISCVCPUState *s, uint32_t cause) { printf("raise_exception: cause=%d\n", cause);//// + printf("raise_exception: sleep\n"); sleep(1);//// raise_exception2(s, cause, 0); } diff --git a/virtio.c b/virtio.c index bc6a8cb..a586cee 100644 --- a/virtio.c +++ b/virtio.c @@ -1334,8 +1334,8 @@ int virtio_console_write_data(VIRTIODevice *s, const uint8_t *buf, int buf_len) //// To handle a keypress, we trigger the UART3 Interrupt. //// TODO: Pass the keypress to VM Guest printf("[%c]\n", buf[0]); //// - // s->int_status |= 1; - // set_irq(s->irq, 1); + s->int_status |= 1; + set_irq(s->irq, 1); // TODO: Clear the interrupt after reading keypress // set_irq(s->irq, 0);