int init(void) { inode_t* ino; if(unlikely((ino = vfs_mkdev("tty", 0, S_IFCHR | 0666)) == NULL)) return E_ERR; memset(&ios, 0, sizeof(ios)); ios.c_iflag |= 0; ios.c_oflag |= 0; ios.c_cflag |= 0; ios.c_lflag |= ISIG | ICANON | ECHO | ECHOE; ios.c_cc[VEOF] = 000; ios.c_cc[VEOL] = 000; ios.c_cc[VERASE] = 0177; ios.c_cc[VINTR] = 003; ios.c_cc[VKILL] = 025; ios.c_cc[VQUIT] = 034; ios.c_cc[VMIN] = 0; ino->read = tty_read; ino->write = tty_write; //ino->ioctl = tty_ioctl; ino->userdata = (void*) &ios; sys_symlink("/dev/tty0", "/dev/stdin"); sys_symlink("/dev/tty0", "/dev/stdout"); sys_symlink("/dev/tty0", "/dev/stderr"); return E_OK; }
int init(void) { inode_t* ino; if(unlikely((ino = vfs_mkdev("log", -1, S_IFCHR | 0222)) == NULL)) return -1; ino->write = log_write; return 0; }
int init(void) { inode_t* ino; if(unlikely((ino = vfs_mkdev("zero", -1, S_IFCHR | 0666)) == NULL)) return E_ERR; ino->read = zero_read; return E_OK; }
int blkdev_init_mbr(blkdev_t* blkdev) { struct inode* dev = blkdev->dev; if(unlikely(!dev)) return -1; mbr_ptable_t table[4]; char name[2]; if(unlikely(vfs_read(dev, &table, 0x1BE, 64) != 64)) return -1; int i, j = 0; for(i = 0; i < 4; i++) { if(table[i].sysid == 0) continue; mbr_partition_t* mbr = (mbr_partition_t*) kmalloc(sizeof(mbr_partition_t), GFP_KERNEL); if(unlikely(!mbr)) return -1; mbr->dev = dev; mbr->offset = (off64_t) table[i].lba * 512; mbr->size = (off64_t) table[i].size * 512; name[0] = '0' + j++; name[1] = '\0'; inode_t* ch = vfs_mkdev(dev->name, i, S_IFBLK | blkdev->mode); if(unlikely(!ch)) return -1; ch->size = (off64_t) table[i].size * 512; ch->userdata = (void*) mbr; ch->ioctl = dev->ioctl; ch->open = dev->open; ch->close = dev->close; ch->read = mbr_read; ch->write = mbr_write; } return 0; }
int init(void) { context_t* cx = kcalloc(1, sizeof(context_t), GFP_KERNEL); if(unlikely(!cx)) { errno = ENOMEM; return -1; } cx->vmode = KD_TEXT; if(fb_init(cx) != 0) return -1; cx->vt = vterm_new_with_allocator(cx->console.rows, cx->console.cols, &mm, NULL); cx->vs = vterm_obtain_screen(cx->vt); cx->vc = vterm_obtain_state(cx->vt); //vterm_set_utf8(cx->vt, 1); vterm_screen_set_callbacks(cx->vs, &cbs, cx); vterm_screen_reset(cx->vs, 0); vterm_state_reset(cx->vc, 0); VTermRect r = { .start_row = 0, .start_col = 0, .end_row = cx->console.rows, .end_col = cx->console.cols }; console_cbs_damage(r, cx); vterm_input_write(cx->vt, "\e[20h", 5); inode_t* ino = vfs_mkdev("console", -1, S_IFCHR | 0222); ino->ioctl = console_ioctl; ino->write = console_write; ino->userdata = cx; return 0; } int dnit(void) { return 0; }
int init(void) { memset(fbdev, 0, sizeof(fbdev_t)); int i; for(i = sizeof(hooks) / sizeof(void*); i > 0 ; i--) if(hooks[i - 1] () == 0) break; inode_t* ino; if(unlikely((ino = vfs_mkdev("fb", 0, S_IFCHR | 0666)) == NULL)) return E_ERR; extern int fb_ioctl(struct inode*, int, void*); ino->ioctl = fb_ioctl; return E_OK; }
int init(void) { int i; for(i = 0; i < 4; i++) { outb(COM[i] + 1, 0x00); outb(COM[i] + 3, 0x80); outb(COM[i] + 0, 0x03); outb(COM[i] + 1, 0x00); outb(COM[i] + 3, 0x03); outb(COM[i] + 2, 0xC7); outb(COM[i] + 4, 0x0B); inode_t* ino = vfs_mkdev("uart", i, S_IFCHR | 0666); ino->ioctl = uart_ioctl; ino->read = uart_read; ino->write = uart_write; } return E_OK; }
int init(void) { tty_read_init(); inode_t* ino_outp; if(unlikely((ino_outp = vfs_mkdev("tty", 0, S_IFCHR | 0666)) == NULL)) return -1; inode_t* ino_inp; if(unlikely((ino_inp = vfs_mkdev("tty", 1, S_IFCHR | 0666)) == NULL)) return -1; struct tty_context* tio = (struct tty_context*) kmalloc(sizeof(struct tty_context), GFP_KERNEL); if(unlikely(!tio)) { kprintf(ERROR "tty: no memory left!"); return -1; } memset(tio, 0, sizeof(struct tty_context)); tio->ios.c_iflag = TTYDEF_IFLAG; tio->ios.c_oflag = TTYDEF_OFLAG; tio->ios.c_cflag = TTYDEF_CFLAG; tio->ios.c_lflag = TTYDEF_LFLAG; tio->ios.c_cc[VEOF] = CEOF; tio->ios.c_cc[VEOL] = CEOL; tio->ios.c_cc[VERASE] = CERASE; tio->ios.c_cc[VINTR] = CINTR; tio->ios.c_cc[VKILL] = CKILL; tio->ios.c_cc[VMIN] = CMIN; tio->ios.c_cc[VQUIT] = CQUIT; tio->ios.c_cc[VSUSP] = CSUSP; tio->ios.c_cc[VTIME] = CTIME; tio->ios.c_cc[VSTART] = CSTART; tio->ios.c_cc[VSTOP] = CSTOP; tio->ios.__c_ispeed = tio->ios.__c_ospeed = TTYDEF_SPEED; tio->winsize.ws_row = 25; tio->winsize.ws_col = 80; tio->winsize.ws_xpixel = 80 * 8; tio->winsize.ws_ypixel = 25 * 16; tio->lined = 0; tio->output = 1; tio->outlen = 0; fifo_init(&tio->in, TTY_BUFSIZ, O_NONBLOCK); fifo_init(&tio->uin, TTY_BUFSIZ, O_NONBLOCK); ino_outp->read = tty_read; ino_outp->write = tty_output_write; ino_outp->ioctl = tty_ioctl; ino_outp->userdata = (void*) tio; ino_inp->read = tty_read; ino_inp->write = tty_input_write; ino_inp->ioctl = tty_ioctl; ino_inp->userdata = (void*) tio; extern int tty_daemon(void*); if(sys_clone(tty_daemon, NULL, CLONE_VM | CLONE_FILES | CLONE_FS | CLONE_SIGHAND, NULL) < 0) kprintf(ERROR "tty: daemon could not start! Some actions like keystroke's binding will be disabled\n"); sys_symlink("/dev/tty1", "/dev/stdin"); sys_symlink("/dev/tty0", "/dev/stdout"); sys_symlink("/dev/tty0", "/dev/stderr"); sys_symlink("/dev/tty0", "/dev/tty"); /* fallback */ return 0; }