static int stdout_io(struct device *dev, struct iobuf *iob, bool write) { if (write) { char *data = iob->io_base; for (; iob->io_resid != 0; iob->io_resid --) { kcons_putc(*data ++); } return 0; } return -E_INVAL; }
static int dev_stdin_read(char *buf, size_t len) { int ret = 0; bool intr_flag; local_intr_save(intr_flag); { while(1) { if(ret >= len) break; try_again: if (p_rpos < p_wpos) { char c = stdin_buffer[p_rpos % STDIN_BUFSIZE]; //FIXME kcons_putc(c); *buf ++ = c; p_rpos ++; ret ++; if(p_rpos >= p_wpos) break; } else { wait_t __wait, *wait = &__wait; wait_current_set(wait_queue, wait, WT_KBD); local_intr_restore(intr_flag); schedule(); local_intr_save(intr_flag); wait_current_del(wait_queue, wait); if (wait->wakeup_flags == WT_KBD) { goto try_again; } break; } } } local_intr_restore(intr_flag); return ret; }
static uint32_t sys_putc(uint32_t arg[]) { int c = (int)arg[0]; kcons_putc(c); return 0; }
/* * * cputch - writes a single character @c to stdout, and it will * increace the value of counter pointed by @cnt. * */ static void cputch(int c, int *cnt, int fd) { kcons_putc(c); (*cnt)++; }