Implemented dev_uart_read
@@ -22,12 +22,28 @@ static int dev_uart_write(vnode_t *t, uio_t *uio) {
}
static int dev_uart_read(vnode_t *t, uio_t *uio) {
+ char buffer[UART_BUF_MAX];
+ unsigned curr = 0;
+ while (curr < UART_BUF_MAX && curr < uio->uio_resid) {
+ buffer[curr] = uart_getchar();
+ if (buffer[curr] == '\n')
+ break;
+ curr++;
+ }
+ int res = uiomove(buffer, UART_BUF_MAX - 1, uio);
+ if (res)
+ return res;
+ return 0;
+}
+
+static int dev_uart_getattr(vnode_t *t, vattr_t *buf) {
return -ENOTSUP;
}
vnodeops_t dev_uart_vnodeops = {
.v_lookup = vnode_op_notsup,
.v_readdir = vnode_op_notsup,
+ .v_getattr = dev_uart_getattr,
.v_open = vnode_open_generic,
.v_write = dev_uart_write,
.v_read = dev_uart_read,
