diff options
-rw-r--r-- | defs.h | 1 | ||||
-rw-r--r-- | uart.c | 10 |
2 files changed, 8 insertions, 3 deletions
@@ -174,6 +174,7 @@ void usertrapret(void); void uartinit(void); void uartintr(void); void uartputc(int); +int uartgetc(void); // vm.c void kvminit(void); @@ -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 |