Kernel sends SIGKSTOP just before shutdown. Drivers do clean up and exit.

This commit is contained in:
Jorrit Herder 2005-07-20 15:28:05 +00:00
parent f1153541c7
commit d2d975246d
4 changed files with 38 additions and 37 deletions

View file

@ -49,6 +49,9 @@
** +------------+---------+---------+---------------+
**
** $Log$
** Revision 1.3 2005/07/20 15:28:04 jnherder
** Kernel sends SIGKSTOP just before shutdown. Drivers do clean up and exit.
**
** Revision 1.2 2005/07/14 15:15:17 jnherder
** Renamed some system library functionality.
**
@ -604,16 +607,19 @@ PUBLIC int main(void)
case DL_STOP: /* Stop device */
do_stop(&m);
break;
case HARD_STOP: /* Shut down */
for (rc = 0; rc < DE_PORT_NR; rc += 1) {
case SYS_EVENT: {
sigset_t sigset = m.NOTIFY_ARG;
if (sigismember(&sigset, SIGKSTOP)) { /* Shut down */
for (rc = 0; rc < DE_PORT_NR; rc += 1) {
if (de_table[rc].de_mode == DEM_ENABLED) {
m.m_type = DL_STOP;
m.DL_PORT = rc;
do_stop(&m);
}
}
}
sys_exit(0);
break;
}
case HARD_INT: /* Interrupt from device */
for (dep = de_table; dep < &de_table[DE_PORT_NR]; dep += 1) {
/* If device is enabled and interrupt pending */

View file

@ -315,7 +315,11 @@ int main(void)
fxp_check_ints(fp);
}
break;
case HARD_STOP: fxp_stop(); break;
case SYS_EVENT: {
sigset_t sigset = m.NOTIFY_ARG;
if (sigismember(&sigset, SIGKSTOP)) fxp_stop();
break;
}
case SYN_ALARM: fxp_expire_timers(); break;
default:
panic("FXP"," illegal message", m.m_type);

View file

@ -327,9 +327,7 @@ void main(void)
* the driver in some cases.
* MINIX timeouts result in a SYN_ALARM message to the
* driver and thus are handled where they should be
* handled. Interrupt()s are faked by setting m_type to
* HARD_INT in rl_watchdog_f when needed, so that this
* case falls through.
* handled. Locally, watchdog functions are used again.
*/
rl_watchdog_f(NULL);
break;
@ -339,7 +337,11 @@ void main(void)
check_int_events();
break ;
case FKEY_PRESSED: rtl8139_dump(&m); break;
case HARD_STOP: rtl8139_stop(); break;
case SYS_EVENT: {
sigset_t sigset = m.NOTIFY_ARG;
if (sigismember(&sigset, SIGKSTOP)) rtl8139_stop();
break;
}
default:
panic("rtl8139","illegal message", m.m_type);
}
@ -1904,7 +1906,7 @@ int may_block;
reply.DL_STAT = status | ((u32_t) err << 16);
reply.DL_COUNT = rep->re_read_s;
if (OK != (r = getuptime(&now)))
panic("dp8390","getuptime() failed:", r);
panic("rtl8139","getuptime() failed:", r);
reply.DL_CLCK = now;
r= send(rep->re_client, &reply);
@ -1915,8 +1917,10 @@ int may_block;
return;
}
if (r < 0)
panic("dp8390","send failed:", r);
if (r < 0) {
printf("RTL8139 tried sending to %d, type %d\n", rep->re_client, reply.m_type);
panic("rtl8139","send failed:", r);
}
rep->re_read_s = 0;
rep->re_flags &= ~(REF_PACK_SENT | REF_PACK_RECV);
@ -2345,7 +2349,7 @@ timer_t *tp;
int i;
re_t *rep;
/* Use a synchronous alarm instead of a watchdog timer. */
sys_syncalrm(SELF, HZ, 0);
sys_setalarm(SELF, HZ, 0);
for (i= 0, rep = &re_table[0]; i<RE_PORT_NR; i++, rep++)
{

View file

@ -19,7 +19,7 @@
* The valid messages and their parameters are:
*
* HARD_INT: output has been completed or input has arrived
* HARD_STOP: MINIX wants to shutdown; run code to cleanly stop
* SYS_EVENT: e.g., MINIX wants to shutdown; run code to cleanly stop
* DEV_READ: a process wants to read from a terminal
* DEV_WRITE: a process wants to write on a terminal
* DEV_IOCTL: a process wants to change a terminal's parameters
@ -33,7 +33,7 @@
* ---------------------------------------------------------------------------
* | HARD_INT | | | | | | |
* |-------------+---------+---------+---------+---------+---------+---------|
* | HARD_STOP | | | | | | |
* | SYS_EVENT | sig set | | | | | |
* |-------------+---------+---------+---------+---------+---------+---------|
* | DEV_READ |minor dev| proc nr | count | O_NONBLOCK| buf ptr |
* |-------------+---------+---------+---------+---------+---------+---------|
@ -206,31 +206,18 @@ PUBLIC void main(void)
}
case SYS_EVENT: { /* new kernel message is available */
sigset_t sigset = (sigset_t) tty_mess.NOTIFY_ARG;
if (sigismember(&sigset, SIGKMESS)) {
do_new_kmess(&tty_mess);
} else if (sigismember(&sigset, SIGTERM)) {
cons_stop(); /* first switch to primary console */
} else if (sigismember(&sigset, SIGKSTOP)) {
if (sigismember(&sigset, SIGKSTOP)) {
cons_stop(); /* switch to primary console */
do_panic_dumps(&tty_mess);
}
continue;
}
case HARD_STOP: { /* MINIX is going down */
static int stop = 0; /* expect two HARD_STOP messages */
if (! stop++) {
cons_stop(); /* first switch to primary console */
} else {
if(irq_hook_id != -1) {
int r;
r = sys_irqdisable(&irq_hook_id);
r = sys_irqrmpolicy(KEYBOARD_IRQ, &irq_hook_id);
#if DEAD_CODE
if (irq_hook_id != -1) {
sys_irqdisable(&irq_hook_id);
sys_irqrmpolicy(KEYBOARD_IRQ, &irq_hook_id);
}
printf("[DONE]\n");
printf("MINIX will now be shutdown.\n");
sys_exit(0); /* then exit TTY */
}
continue;
#endif
}
if (sigismember(&sigset, SIGTERM)) cons_stop();
if (sigismember(&sigset, SIGKMESS)) do_new_kmess(&tty_mess);
continue;
}
case PANIC_DUMPS: /* allow panic dumps */
cons_stop(); /* switch to primary console */