/*===========================================================================* * chardriver_task * *===========================================================================*/ void chardriver_task(struct chardriver *cdp, int driver_type) { /* Main program of any device driver task. */ int r, ipc_status; message mess; running = TRUE; /* Here is the main loop of the disk task. It waits for a message, carries * it out, and sends a reply. */ while (running) { if ((r = sef_receive_status(ANY, &mess, &ipc_status)) != OK) panic("driver_receive failed: %d", r); chardriver_process(cdp, driver_type, &mess, ipc_status); } }
/*===========================================================================* * main * *===========================================================================*/ int main(void) { message msg; int r, ipc_status; /* SEF local startup. */ sef_local_startup(); /* The receive loop. */ for (;;) { if ((r = driver_receive(ANY, &msg, &ipc_status)) != OK) panic("memory: driver_receive failed (%d)", r); if (IS_BDEV_RQ(msg.m_type)) blockdriver_process(&m_bdtab, &msg, ipc_status); else chardriver_process(&m_cdtab, CHARDRIVER_SYNC, &msg, ipc_status); } return(OK); }
/*===========================================================================* * tty_task * *===========================================================================*/ int main(void) { /* Main routine of the terminal task. */ message tty_mess; /* buffer for all incoming messages */ int ipc_status; int line; int r; register tty_t *tp; /* SEF local startup. */ sef_local_startup(); while (TRUE) { /* Check for and handle any events on any of the ttys. */ for (tp = FIRST_TTY; tp < END_TTY; tp++) { if (tp->tty_events) handle_events(tp); } /* Get a request message. */ r= driver_receive(ANY, &tty_mess, &ipc_status); if (r != 0) panic("driver_receive failed with: %d", r); /* First handle all kernel notification types that the TTY supports. * - An alarm went off, expire all timers and handle the events. * - A hardware interrupt also is an invitation to check for events. * - A new kernel message is available for printing. * - Reset the console on system shutdown. * Then see if this message is different from a normal device driver * request and should be handled separately. These extra functions * do not operate on a device, in constrast to the driver requests. */ if (is_ipc_notify(ipc_status)) { switch (_ENDPOINT_P(tty_mess.m_source)) { case CLOCK: /* run watchdogs of expired timers */ expire_timers(tty_mess.m_notify.timestamp); break; case HARDWARE: /* hardware interrupt notification */ #if NR_RS_LINES > 0 /* serial I/O */ if (tty_mess.m_notify.interrupts & rs_irq_set) rs_interrupt(&tty_mess); #endif /* run watchdogs of expired timers */ expire_timers(tty_mess.m_notify.timestamp); break; default: /* do nothing */ break; } /* done, get new message */ continue; } switch (tty_mess.m_type) { case TTY_FKEY_CONTROL: /* (un)register a fkey observer */ do_fkey_ctl(&tty_mess); continue; case TTY_INPUT_UP: case TTY_INPUT_EVENT: do_input(&tty_mess); continue; default: /* should be a driver request */ ; /* do nothing; end switch */ } if (!IS_CDEV_RQ(tty_mess.m_type)) { chardriver_process(&tty_tab, &tty_mess, ipc_status); continue; } /* Only device requests should get to this point. * All requests have a minor device number. */ if (OK != chardriver_get_minor(&tty_mess, &line)) continue; if (line == VIDEO_MINOR) { do_video(&tty_mess, ipc_status); continue; } /* Execute the requested device driver function. */ chardriver_process(&tty_tab, &tty_mess, ipc_status); } return 0; }
/*===========================================================================* * tty_task * *===========================================================================*/ int main(int argc, char **argv) { /* Main routine of the terminal task. */ message tty_mess; /* buffer for all incoming messages */ int ipc_status; int line; int r; register tty_t *tp; env_setargs(argc, argv); tty_startup(); while (TRUE) { /* Check for and handle any events on any of the ttys. */ for (tp = FIRST_TTY; tp < END_TTY; tp++) { if (tp->tty_events) handle_events(tp); } /* Get a request message. */ r= driver_receive(ANY, &tty_mess, &ipc_status); if (r != 0) panic("driver_receive failed with: %d", r); if (is_ipc_notify(ipc_status)) { switch (_ENDPOINT_P(tty_mess.m_source)) { case CLOCK: /* run watchdogs of expired timers */ expire_timers(tty_mess.m_notify.timestamp); break; default: /* do nothing */ break; } /* done, get new message */ continue; } if (!IS_CDEV_RQ(tty_mess.m_type)) { chardriver_process(&tty_tab, &tty_mess, ipc_status); continue; } /* Only device requests should get to this point. * All requests have a minor device number. */ if (OK != chardriver_get_minor(&tty_mess, &line)) continue; if (is_pty(line)) { /* Terminals and pseudo terminals belong together. We can only * make a distinction between the two based on minor number and * not on position in the tty_table. Hence this special case. */ do_pty(&tty_mess, ipc_status); continue; } /* Execute the requested device driver function. */ chardriver_process(&tty_tab, &tty_mess, ipc_status); } return 0; }