int main(int argc, char **argv) { struct tty* tty = tty_create(); sleep(2); tty_destroy(tty); return 0; }
void tty_init() { screen_init(); vt_init(); keyboard_init(); /* * Create NTERMS tty's, all with the default line discipline * and a virtual terminal driver. */ int nterms, i; nterms = vt_num_terminals(); for (i = 0; i < nterms; ++i) { tty_driver_t *ttyd; tty_device_t *tty; tty_ldisc_t *ldisc; ttyd = vt_get_tty_driver(i); KASSERT(NULL != ttyd); KASSERT(NULL != ttyd->ttd_ops); KASSERT(NULL != ttyd->ttd_ops->register_callback_handler); tty = tty_create(ttyd, i); if (NULL == tty) { panic("Not enough memory to allocate tty\n"); } if (NULL != ttyd->ttd_ops->register_callback_handler( ttyd, tty_global_driver_callback, (void *)tty)) { panic("Callback already registered " "to terminal %d\n", i); } ldisc = n_tty_create(); if (NULL == ldisc) { panic("Not enough memory to allocate " "line discipline\n"); } KASSERT(NULL != ldisc); KASSERT(NULL != ldisc->ld_ops); KASSERT(NULL != ldisc->ld_ops->attach); ldisc->ld_ops->attach(ldisc, tty); if (bytedev_register(&tty->tty_cdev) != 0) { panic("Error registering tty as byte device\n"); } } }