summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Morris <[email protected]>2019-06-03 17:49:27 -0400
committerRobert Morris <[email protected]>2019-06-03 17:49:27 -0400
commitefecbee7c0c265b0b2fe956f308e1a73cc63eda6 (patch)
tree8bbb325b0655c486de345a5981acaa569cead885
parent6eae1be7550ecdc85269ce57c4a2f2dd0e9297b9 (diff)
downloadxv6-labs-efecbee7c0c265b0b2fe956f308e1a73cc63eda6.tar.gz
xv6-labs-efecbee7c0c265b0b2fe956f308e1a73cc63eda6.tar.bz2
xv6-labs-efecbee7c0c265b0b2fe956f308e1a73cc63eda6.zip
xx
-rw-r--r--defs.h1
-rw-r--r--uart.c10
2 files changed, 8 insertions, 3 deletions
diff --git a/defs.h b/defs.h
index 2a6c47a..1adbf78 100644
--- a/defs.h
+++ b/defs.h
@@ -174,6 +174,7 @@ void usertrapret(void);
void uartinit(void);
void uartintr(void);
void uartputc(int);
+int uartgetc(void);
// vm.c
void kvminit(void);
diff --git a/uart.c b/uart.c
index 659c574..b6271c1 100644
--- a/uart.c
+++ b/uart.c
@@ -49,11 +49,15 @@ uartputc(int c)
*R(0) = c;
}
-uint
+int
uartgetc(void)
{
- // XXX this isn't right, must check there's data in the FIFO.
- return *R(0);
+ if(*(5) & 0x01){
+ // input data is ready.
+ return *R(0);
+ } else {
+ return -1;
+ };
}
void