diff options
author | Robert Morris <[email protected]> | 2019-06-03 14:13:07 -0400 |
---|---|---|
committer | Robert Morris <[email protected]> | 2019-06-03 14:13:07 -0400 |
commit | a9c1a6f742886a9d45e5c625cf4f9b1b5c7a8cc4 (patch) | |
tree | ff50c8aa95dbdc5f35954e586933ad63676c69c4 /uart.c | |
parent | 50cbc7510250a64674d619d13f5912edf08b767d (diff) | |
download | xv6-labs-a9c1a6f742886a9d45e5c625cf4f9b1b5c7a8cc4.tar.gz xv6-labs-a9c1a6f742886a9d45e5c625cf4f9b1b5c7a8cc4.tar.bz2 xv6-labs-a9c1a6f742886a9d45e5c625cf4f9b1b5c7a8cc4.zip |
takes one uart input interrupt, then panics
Diffstat (limited to 'uart.c')
-rw-r--r-- | uart.c | 19 |
1 files changed, 15 insertions, 4 deletions
@@ -1,4 +1,10 @@ +#include "types.h" +#include "param.h" #include "memlayout.h" +#include "riscv.h" +#include "proc.h" +#include "spinlock.h" +#include "defs.h" // // qemu -machine virt has a 16550a UART @@ -9,12 +15,12 @@ // // address of one of the registers -#define R(reg) ((unsigned int*)(UART0 + 4*(reg))) +#define R(reg) ((volatile unsigned char *)(UART0 + reg)) void uartinit(void) { - // disable interrupts + // disable interrupts -- IER *R(1) = 0x00; // special mode to set baud rate @@ -30,8 +36,11 @@ uartinit(void) // and set word length to 8 bits, no parity. *R(3) = 0x03; - // reset and enable FIFOs. + // reset and enable FIFOs -- FCR. *R(2) = 0x07; + + // enable receive interrupts -- IER. + *R(1) = 0x01; } void @@ -40,9 +49,11 @@ uartputc(int c) *R(0) = c; } -static int +uint uartgetc(void) { + // XXX this isn't right, must check there's data in the FIFO. + return *R(0); } void |