]> Zhao Yanbai Git Server - minix.git/commitdiff
rs changes (also use driver configurations in the image ramdisk)
authorPhilip Homburg <philip@cs.vu.nl>
Tue, 31 Oct 2006 13:35:04 +0000 (13:35 +0000)
committerPhilip Homburg <philip@cs.vu.nl>
Tue, 31 Oct 2006 13:35:04 +0000 (13:35 +0000)
drivers/memory/ramdisk/Makefile
drivers/memory/ramdisk/proto
drivers/memory/ramdisk/rc
etc/Makefile
etc/drivers.conf [new file with mode: 0644]
etc/rs.single [new file with mode: 0644]
include/minix/com.h
servers/rs/main.c
servers/rs/manager.c
servers/rs/manager.h
servers/rs/service.c

index dce479feaee7f1141b4a782ad41846d0341551dc..40f62e3e32624eb2ed370d5b35a44558e4840cd6 100644 (file)
@@ -2,13 +2,14 @@
 
 PROGRAMS=at_wini bios_wini cdprobe dev2name floppy loadramdisk newroot \
        pci sh service sysenv mfs
+EXTRA=drivers.conf passwd
 
 MAKEDEV=/usr/bin/MAKEDEV
 
 all:   image.c image.s
 
 clean:
-       rm -rf $(PROGRAMS) bintoc image image.c image.s t proto.gen
+       rm -rf $(PROGRAMS) $(EXTRA) bintoc image image.c image.s t proto.gen
 
 image.c:       bintoc image
        ./bintoc -o $@ image
@@ -21,7 +22,7 @@ image.s:      image.c
 bintoc:        bintoc.c
        $(CC) -o $@ bintoc.c
 
-image: proto.gen mtab rc $(PROGRAMS)
+image: proto.gen mtab rc $(PROGRAMS) $(EXTRA)
        mkfs -B 2048 image proto.gen || { rm -f image; false; }
 
 at_wini: ../../at_wini/at_wini
@@ -96,6 +97,12 @@ mfs: ../../../servers/mfs/mfs
 ../../../servers/mfs/mfs: 
        cd ../../../servers/mfs && make
 
+drivers.conf: ../../../etc/drivers.conf
+       install -s ../../../etc/$@ $@
+
+passwd: ../../../etc/passwd
+       install -s ../../../etc/$@ $@
+
 depend: 
        /usr/bin/mkdep "$(CC) -E $(CPPFLAGS)" *.c > .depend
 
index 63a375d7cbff50c11ecfc1069946128d22c1aee2..100176071315b986ae0b4b6b2f7b6a1c248eb9c1 100644 (file)
@@ -19,7 +19,9 @@ d--755 0 0
 @DEV@
        $
        etc d--755 0 0
+               drivers.conf ---644 0 0 drivers.conf
                mtab ---644 0 0 mtab
+               passwd ---644 0 0 passwd
                rc ---755 0 0 rc
        $
 $
index 2a0fac3eece7bde7dd92efd9d1a8bffa98662fc6..0c4cad34cda1d85c7ff08636679d712b2685a66e 100644 (file)
@@ -1,13 +1,13 @@
 #!/bin/sh
 set -e
-/bin/service up /bin/pci
-/bin/service -c up /bin/floppy -dev /dev/fd0
+/bin/service up /bin/pci -config /etc/drivers.conf
+/bin/service -c up /bin/floppy -config /etc/drivers.conf -dev /dev/fd0
 if [ X`/bin/sysenv bios_wini` = Xyes ]
 then
        echo Using bios_wini.
        /bin/service -c up /bin/bios_wini -dev /dev/c0d0
 else
-       /bin/service -c up /bin/at_wini -dev /dev/c0d0
+       /bin/service -c up /bin/at_wini -dev /dev/c0d0 -script /etc/rs.single -config /etc/drivers.conf
 fi
 
 rootdev=`sysenv rootdev` || echo 'No rootdev?'
index 8f05dd616db67bda8c5f9e7e544c523f2c69b3b0..a38f4e1c68ab01c29e2134cf18af4cf546e846f5 100644 (file)
@@ -1,7 +1,7 @@
 
 ETC=/etc/
 USRETC=/usr/etc/
-FILES1=fstab group hostname.file inet.conf motd.install mtab passwd profile protocols rc services termcap ttytab utmp rc.cd binary_sizes binary_sizes.big binary_sizes.xxl rc.rescue syslog.conf rc.daemons.dist 
+FILES1=fstab group hostname.file inet.conf motd.install mtab passwd profile protocols rc services termcap ttytab utmp rc.cd binary_sizes binary_sizes.big binary_sizes.xxl rc.rescue syslog.conf rc.daemons.dist rs.single
 FILES2=shadow
 FILES3=daily dhcptags.conf rc
 
diff --git a/etc/drivers.conf b/etc/drivers.conf
new file mode 100644 (file)
index 0000000..88090f6
--- /dev/null
@@ -0,0 +1,135 @@
+driver floppy
+{
+       irq     6;
+       io      3f0:8
+               0:10    # XXX DMA controller
+               81      # Also DMA
+               ;
+       system
+               UMAP            # 14
+               VIRCOPY         # 15
+               IRQCTL          # 19
+               DEVIO           # 21
+               VDEVIO          # 23
+               SETALARM        # 24
+               TIMES           # 25
+               SAFECOPYFROM    # 31
+               SAFECOPYTO      # 32
+               ;
+};
+
+driver dp8390
+{
+       system
+               KILL            #  6
+               VIRCOPY         # 15
+               IRQCTL          # 19
+               DEVIO           # 21
+               SDEVIO          # 22
+               SETALARM        # 24
+               GETINFO         # 26
+               SAFECOPYFROM    # 31
+               SAFECOPYTO      # 32
+               SETGRANT        # 34
+       ;
+       pci device      10ec/8029;
+       uid     0;
+};
+
+driver dumpcore
+{
+       system
+               TRACE           #  5
+               VIRCOPY         # 15
+               GETINFO         # 26
+               SETGRANT        # 34
+       ;
+};
+
+driver inet
+{
+       system
+               KILL            #  6
+               SETALARM        # 24
+               TIMES           # 25
+               SAFECOPYFROM    # 31
+               SAFECOPYTO      # 32
+               VSAFECOPY       # 33
+               SETGRANT        # 34
+       ;
+       uid 0;
+};
+
+driver random
+{
+       system
+               KILL            #  6
+               UMAP            # 14
+               SETALARM        # 24
+               GETINFO         # 26
+               SAFECOPYFROM    # 31
+               SAFECOPYTO      # 32
+               SETGRANT        # 34
+       ;
+};
+
+driver cmos
+{
+       io      70:2;
+       system
+               DEVIO           # 21
+               TIMES           # 25
+               SAFECOPYTO      # 32
+               SETGRANT        # 34
+               READBIOS        # 35
+       ;
+};
+
+driver is
+{
+       system
+               GETINFO         # 26
+               SETGRANT        # 34
+       ;
+};
+
+driver pci
+{
+       io      cf8:8           # PCI bus controller
+               4d0:2           # PIIX
+       ;
+       system
+               PRIVCTL         #  4
+               KILL            #  6
+               DEVIO           # 21
+               GETINFO         # 26
+               SAFECOPYFROM    # 31
+               SAFECOPYTO      # 32
+               SETGRANT        # 34
+       ;
+};
+
+driver at_wini
+{
+       io      1f0:8           # Controller 0
+               3f6             # Also controller 0
+       ;
+       irq
+               14              # Controller 0
+       ;
+       system
+               KILL            #  6
+               UMAP            # 14
+               IRQCTL          # 19
+               DEVIO           # 21
+               SDEVIO          # 22
+               VDEVIO          # 23
+               SETALARM        # 24
+               TIMES           # 25
+               GETINFO         # 26
+               SAFECOPYFROM    # 31
+               SAFECOPYTO      # 32
+               SETGRANT        # 34
+               READBIOS        # 35
+       ;
+};
diff --git a/etc/rs.single b/etc/rs.single
new file mode 100644 (file)
index 0000000..527435a
--- /dev/null
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+# 'Recovery' script that doesn't. This script is to be used for drivers that
+# should not be restarted. Instead, the scripts configures the driver 'down'.
+echo "Arguments: $@" >/dev/console
+service down "$1"
index 978a0ffa0395fda339a1d4ac54229e20dc8766e7..b206bd22c336856d558352491617b848dac53c68 100755 (executable)
 #define RS_UP_COPY     (RS_RQ_BASE + 6)        /* start system service and
                                                 * keep the binary in memory
                                                 */
-#define RS_RUN         (RS_RQ_BASE + 7)        /* run without restart */
-#define RS_START       (RS_RQ_BASE + 8)        /* start a driver/service
+#define RS_START       (RS_RQ_BASE + 7)        /* start a driver/service
                                                 * arguments are passed in 
                                                 * a struct rs_start
                                                 */
index f47cf18c9904fa1db6661a22610ae0155a9c92b5..dec432bdc6220a4149e8e40f229a324f9f068fa6 100644 (file)
@@ -83,7 +83,6 @@ PUBLIC int main(void)
           switch(call_nr) {
           case RS_UP:          result = do_up(&m, FALSE, 0); break;
           case RS_UP_COPY:     result = do_up(&m, TRUE, 0); break;
-         case RS_RUN:          result = do_up(&m, FALSE, RS_EXITING);  break;
          case RS_START:        result = do_start(&m);          break;
           case RS_DOWN:        result = do_down(&m);           break;
           case RS_REFRESH:     result = do_refresh(&m);        break;
@@ -139,7 +138,6 @@ PRIVATE void init_server(void)
   for (s=0; s< NR_BOOT_PROCS; s++) {
       ip = &image[s];
       if (ip->proc_nr >= 0) {
-          nr_in_use ++;
           rproc[s].r_flags = RS_IN_USE;
           rproc[s].r_proc_nr_e = ip->endpoint;
           rproc[s].r_pid = getnpid(ip->proc_nr);
index 8513df17e590f71f73b386cb9e2da242da011817..aafef4ee31cb701eb1736de7ac5655b2101ddea3 100644 (file)
@@ -20,8 +20,6 @@
 /* Allocate variables. */
 struct rproc rproc[NR_SYS_PROCS];              /* system process table */
 struct rproc *rproc_ptr[NR_PROCS];             /* mapping for fast access */
-int nr_in_use;                                         /* number of services */
-extern int errno;                              /* error status */
 
 /* Prototypes for internal functions that do the hard work. */
 FORWARD _PROTOTYPE( int start_service, (struct rproc *rp, int flags,
@@ -61,13 +59,11 @@ int flags;                                  /* extra flags, if any */
   endpoint_t ep;                               /* new endpoint no. */
 
   /* See if there is a free entry in the table with system processes. */
-  if (nr_in_use >= NR_SYS_PROCS) return(EAGAIN); 
   for (slot_nr = 0; slot_nr < NR_SYS_PROCS; slot_nr++) {
       rp = &rproc[slot_nr];                    /* get pointer to slot */
       if (! rp->r_flags & RS_IN_USE)           /* check if available */
          break;
   }
-  nr_in_use ++;                                        /* update administration */
 
   /* Obtain command name and parameters. This is a space-separated string
    * that looks like "/sbin/service arg1 arg2 ...". Arguments are optional.
@@ -166,13 +162,11 @@ message *m_ptr;                                   /* request message pointer */
   if (s != OK) return(s);
 
   /* See if there is a free entry in the table with system processes. */
-  if (nr_in_use >= NR_SYS_PROCS) return(EAGAIN); 
   for (slot_nr = 0; slot_nr < NR_SYS_PROCS; slot_nr++) {
       rp = &rproc[slot_nr];                    /* get pointer to slot */
       if (! rp->r_flags & RS_IN_USE)           /* check if available */
          break;
   }
-  nr_in_use ++;                                        /* update administration */
 
   /* Obtain command name and parameters. This is a space-separated string
    * that looks like "/sbin/service arg1 arg2 ...". Arguments are optional.
@@ -977,8 +971,8 @@ struct priv *privp;
                src_bit, call_nr;
        unsigned long mask;
 
-       /* Clear the privilege structure */
-       memset(privp, '\0', sizeof(*privp));
+       /* Clear s_k_call_mask */
+       memset(privp->s_k_call_mask, '\0', sizeof(privp->s_k_call_mask));
 
        src_bits_per_word= 8*sizeof(rp->r_call_mask[0]);
        dst_bits_per_word= 8*sizeof(privp->s_k_call_mask[0]);
@@ -1017,6 +1011,12 @@ int endpoint;
        int i, r;
        struct rs_pci rs_pci;
 
+       if (strcmp(rp->r_label, "pci") == 0)
+       {
+               printf("init_pci: not when starting 'pci'\n");
+               return;
+       }
+
        len= strlen(rp->r_label);
        if (len+1 > sizeof(rs_pci.rsp_label))
        {
index f6da67fe331b44eafe9251af492b35675415adc0..8f22ab7aac0ac546216f9c1ec30dfc8d4686c835 100644 (file)
@@ -60,7 +60,6 @@ extern struct rproc {
 
 /* Mapping for fast access to the system process table. */ 
 extern struct rproc *rproc_ptr[NR_PROCS];
-extern int nr_in_use;
 
 /* Flag values. */
 #define RS_IN_USE       0x001  /* set when process slot is in use */
index 470cf060dd1cb9dd0fe764d672ef957d7c1980d5..8ed7a8f55535472ed0b858738a09c8ba728b8ed0 100644 (file)
@@ -33,14 +33,15 @@ PRIVATE char *known_requests[] = {
   "rescue", 
   "shutdown", 
   "upcopy",    /* fill for RS_UP_COPY */
-  "run", 
   "catch for illegal requests"
 };
 #define ILLEGAL_REQUEST  sizeof(known_requests)/sizeof(char *)
 
 /* Global error number set for failed system calls. */
 #define OK 0
-extern int errno;
+
+#define RUN_CMD                "run"
+#define RUN_SCRIPT     "/etc/rs.single"        /* Default script for 'run' */
 
 /* Define names for arguments provided to this utility. The first few 
  * arguments are required and have a known index. Thereafter, some optional
@@ -75,6 +76,7 @@ extern int errno;
  * are stored globally in the following variables:
  */
 PRIVATE int req_type;
+PRIVATE int do_run= 0;         /* 'run' command instead of 'up' */
 PRIVATE char *req_label;
 PRIVATE char *req_path;
 PRIVATE char *req_args;
@@ -150,22 +152,38 @@ PRIVATE int parse_arguments(int argc, char **argv)
       exit(EINVAL);
   }
 
-  /* Verify request type. */
-  for (req_type=0; req_type< ILLEGAL_REQUEST; req_type++) {
-      if (strcmp(known_requests[req_type],argv[optind+ARG_REQUEST])==0) break;
+  if (strcmp(argv[optind+ARG_REQUEST], RUN_CMD) == 0)
+  {
+       req_nr= RS_UP;
+       do_run= TRUE;
   }
-  if (req_type == ILLEGAL_REQUEST) {
-      print_usage(argv[ARG_NAME], "illegal request type");
-      exit(ENOSYS);
+  else
+  {
+       /* Verify request type. */
+       for (req_type=0; req_type< ILLEGAL_REQUEST; req_type++) {
+           if (strcmp(known_requests[req_type],argv[optind+ARG_REQUEST])==0)
+               break;
+       }
+       if (req_type == ILLEGAL_REQUEST) {
+           print_usage(argv[ARG_NAME], "illegal request type");
+           exit(ENOSYS);
+       }
+       req_nr = RS_RQ_BASE + req_type;
   }
-  req_nr = RS_RQ_BASE + req_type;
 
-  if (req_nr == RS_UP || req_nr == RS_RUN) {
+  if (req_nr == RS_UP) {
 
       rs_start.rss_flags= 0;
       if (c_flag)
        rs_start.rss_flags |= RF_COPY;
 
+      if (do_run)
+      {
+       /* Set default recovery script for RUN */
+        req_script = RUN_SCRIPT;
+       req_nr = RS_START;
+      }
+
       if (req_nr == RS_UP && c_flag)
        req_nr= RS_UP_COPY;
 
@@ -640,6 +658,8 @@ struct
        int call_nr;
 } system_tab[]=
 {
+       { "PRIVCTL",            SYS_PRIVCTL },
+       { "TRACE",              SYS_TRACE },
        { "KILL",               SYS_KILL },
        { "UMAP",               SYS_UMAP },
        { "VIRCOPY",            SYS_VIRCOPY },
@@ -652,7 +672,9 @@ struct
        { "GETINFO",            SYS_GETINFO },
        { "SAFECOPYFROM",       SYS_SAFECOPYFROM },
        { "SAFECOPYTO",         SYS_SAFECOPYTO },
+       { "VSAFECOPY",          SYS_VSAFECOPY },
        { "SETGRANT",           SYS_SETGRANT },
+       { "READBIOS",           SYS_READBIOS },
        { NULL,         0 }
 };
 
@@ -865,7 +887,6 @@ PUBLIC int main(int argc, char **argv)
   switch(request) {
   case RS_UP:
   case RS_UP_COPY:
-  case RS_RUN:
       /* Build space-separated command string to be passed to RS server. */
       strcpy(command, req_path);
       command[strlen(req_path)] = ' ';