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$ ** $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 ** Revision 1.2 2005/07/14 15:15:17 jnherder
** Renamed some system library functionality. ** Renamed some system library functionality.
** **
@ -604,16 +607,19 @@ PUBLIC int main(void)
case DL_STOP: /* Stop device */ case DL_STOP: /* Stop device */
do_stop(&m); do_stop(&m);
break; break;
case HARD_STOP: /* Shut down */ case SYS_EVENT: {
for (rc = 0; rc < DE_PORT_NR; rc += 1) { 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) { if (de_table[rc].de_mode == DEM_ENABLED) {
m.m_type = DL_STOP; m.m_type = DL_STOP;
m.DL_PORT = rc; m.DL_PORT = rc;
do_stop(&m); do_stop(&m);
} }
}
} }
sys_exit(0);
break; break;
}
case HARD_INT: /* Interrupt from device */ case HARD_INT: /* Interrupt from device */
for (dep = de_table; dep < &de_table[DE_PORT_NR]; dep += 1) { for (dep = de_table; dep < &de_table[DE_PORT_NR]; dep += 1) {
/* If device is enabled and interrupt pending */ /* If device is enabled and interrupt pending */

View File

@ -315,7 +315,11 @@ int main(void)
fxp_check_ints(fp); fxp_check_ints(fp);
} }
break; 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; case SYN_ALARM: fxp_expire_timers(); break;
default: default:
panic("FXP"," illegal message", m.m_type); panic("FXP"," illegal message", m.m_type);

View File

@ -327,9 +327,7 @@ void main(void)
* the driver in some cases. * the driver in some cases.
* MINIX timeouts result in a SYN_ALARM message to the * MINIX timeouts result in a SYN_ALARM message to the
* driver and thus are handled where they should be * driver and thus are handled where they should be
* handled. Interrupt()s are faked by setting m_type to * handled. Locally, watchdog functions are used again.
* HARD_INT in rl_watchdog_f when needed, so that this
* case falls through.
*/ */
rl_watchdog_f(NULL); rl_watchdog_f(NULL);
break; break;
@ -339,7 +337,11 @@ void main(void)
check_int_events(); check_int_events();
break ; break ;
case FKEY_PRESSED: rtl8139_dump(&m); 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: default:
panic("rtl8139","illegal message", m.m_type); panic("rtl8139","illegal message", m.m_type);
} }
@ -1904,7 +1906,7 @@ int may_block;
reply.DL_STAT = status | ((u32_t) err << 16); reply.DL_STAT = status | ((u32_t) err << 16);
reply.DL_COUNT = rep->re_read_s; reply.DL_COUNT = rep->re_read_s;
if (OK != (r = getuptime(&now))) if (OK != (r = getuptime(&now)))
panic("dp8390","getuptime() failed:", r); panic("rtl8139","getuptime() failed:", r);
reply.DL_CLCK = now; reply.DL_CLCK = now;
r= send(rep->re_client, &reply); r= send(rep->re_client, &reply);
@ -1915,8 +1917,10 @@ int may_block;
return; return;
} }
if (r < 0) if (r < 0) {
panic("dp8390","send failed:", r); 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_read_s = 0;
rep->re_flags &= ~(REF_PACK_SENT | REF_PACK_RECV); rep->re_flags &= ~(REF_PACK_SENT | REF_PACK_RECV);
@ -2345,7 +2349,7 @@ timer_t *tp;
int i; int i;
re_t *rep; re_t *rep;
/* Use a synchronous alarm instead of a watchdog timer. */ /* 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++) 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: * The valid messages and their parameters are:
* *
* HARD_INT: output has been completed or input has arrived * 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_READ: a process wants to read from a terminal
* DEV_WRITE: a process wants to write on a terminal * DEV_WRITE: a process wants to write on a terminal
* DEV_IOCTL: a process wants to change a terminal's parameters * DEV_IOCTL: a process wants to change a terminal's parameters
@ -33,7 +33,7 @@
* --------------------------------------------------------------------------- * ---------------------------------------------------------------------------
* | HARD_INT | | | | | | | * | HARD_INT | | | | | | |
* |-------------+---------+---------+---------+---------+---------+---------| * |-------------+---------+---------+---------+---------+---------+---------|
* | HARD_STOP | | | | | | | * | SYS_EVENT | sig set | | | | | |
* |-------------+---------+---------+---------+---------+---------+---------| * |-------------+---------+---------+---------+---------+---------+---------|
* | DEV_READ |minor dev| proc nr | count | O_NONBLOCK| buf ptr | * | 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 */ case SYS_EVENT: { /* new kernel message is available */
sigset_t sigset = (sigset_t) tty_mess.NOTIFY_ARG; sigset_t sigset = (sigset_t) tty_mess.NOTIFY_ARG;
if (sigismember(&sigset, SIGKMESS)) { if (sigismember(&sigset, SIGKSTOP)) {
do_new_kmess(&tty_mess);
} else if (sigismember(&sigset, SIGTERM)) {
cons_stop(); /* first switch to primary console */
} else if (sigismember(&sigset, SIGKSTOP)) {
cons_stop(); /* switch to primary console */ cons_stop(); /* switch to primary console */
do_panic_dumps(&tty_mess); #if DEAD_CODE
} if (irq_hook_id != -1) {
continue; sys_irqdisable(&irq_hook_id);
} sys_irqrmpolicy(KEYBOARD_IRQ, &irq_hook_id);
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);
} }
printf("[DONE]\n"); #endif
printf("MINIX will now be shutdown.\n"); }
sys_exit(0); /* then exit TTY */ if (sigismember(&sigset, SIGTERM)) cons_stop();
} if (sigismember(&sigset, SIGKMESS)) do_new_kmess(&tty_mess);
continue; continue;
} }
case PANIC_DUMPS: /* allow panic dumps */ case PANIC_DUMPS: /* allow panic dumps */
cons_stop(); /* switch to primary console */ cons_stop(); /* switch to primary console */