@@ -456,7 +456,7 @@ fun cctx_setup_handles 1 {
handles @vfs_write vector_push_back ;
handles @vfs_truncate vector_push_back ;
handles @vfs_seek vector_push_back ;
- handles @kbd_getc vector_push_back ;
+ handles @input_getc vector_push_back ;
}
fun cctx_setup_runtime 1 {
@@ -111,6 +111,27 @@ fun serial_write 1 {
SERIAL_PORT c outb ;
+fun serial_maybe_read 0 {
+ if SERIAL_PORT 5 + inb 0x01 & ! {
+ 0 ret ;
+ }
+
+ $c
+ @c SERIAL_PORT inb = ;
+ c ret ;
+}
+fun serial_read 0 {
+ while 1 {
+ @c serial_maybe_read = ;
+ if c {
fun write 1 {
$c
@c 0 param = ;
@@ -24,7 +24,7 @@ const KBD_CTRL 2
const KBD_CAPS 4
fun kbd_get_scancode 0 {
- if 0x64 inb 1 & ! {
+ if 0x64 inb 0x01 & ! {
0 ret ;
@@ -100,3 +100,14 @@ fun kbd_getc 0 {
+# Take input from either serial or keyboard
+fun input_getc 0 {
+ @c kbd_maybe_getc = ;
+ if c { c ret ; }
@@ -19,7 +19,7 @@ struct __handles_t {
void (*vfs_write)(int c, int fd);
void (*vfs_truncate)(int fd);
int (*vfs_seek)(int whence, int offset, int fd);
- int (*kbd_getc)();
+ int (*input_getc)();
};
struct __handles_t *__handles;
@@ -28,7 +28,7 @@ ssize_t read(int fildes, void *buf, size_t nbyte) {
int c;
if (fildes == 0) {
- c = __handles->kbd_getc();
+ c = __handles->input_getc();
// Loop back character to console
__handles->write(c);
} else {