summaryrefslogtreecommitdiff
path: root/uart.c
diff options
context:
space:
mode:
authorRobert Morris <[email protected]>2019-06-03 14:13:07 -0400
committerRobert Morris <[email protected]>2019-06-03 14:13:07 -0400
commita9c1a6f742886a9d45e5c625cf4f9b1b5c7a8cc4 (patch)
treeff50c8aa95dbdc5f35954e586933ad63676c69c4 /uart.c
parent50cbc7510250a64674d619d13f5912edf08b767d (diff)
downloadxv6-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.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/uart.c b/uart.c
index 9a77c5a..807c46e 100644
--- a/uart.c
+++ b/uart.c
@@ -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