]> Zhao Yanbai Git Server - minix.git/commitdiff
Kernel sends SIGKSTOP just before shutdown. Drivers do clean up and exit.
authorJorrit Herder <jnherder@minix3.org>
Wed, 20 Jul 2005 15:28:05 +0000 (15:28 +0000)
committerJorrit Herder <jnherder@minix3.org>
Wed, 20 Jul 2005 15:28:05 +0000 (15:28 +0000)
drivers/dpeth/dp.c
drivers/fxp/fxp.c
drivers/rtl8139/rtl8139.c
drivers/tty/tty.c

index 0f443be276127f50e547f481590b87f57dbb6d4e..b84a1386f87a01035028c687f068d150c3d64fd2 100644 (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 */
index 5855354f718039aa0395cc7a88d83ce3cd0259ac..63463488a337fda0822666193eb7d0f46d8ba1b1 100644 (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);
index 9e86b7104b52904a4ff90b88efe7b669ec338e77..56fda570e66aaab3f42b7f8e0e143588b6a2056b 100755 (executable)
@@ -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++)
        {
index cd67d2de393a6be346a6f137c358cd47f04bb7d5..42544c6b580fedb36f962d81d522914b92aabc66 100644 (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 */