]> Zhao Yanbai Git Server - minix.git/commitdiff
system.conf: subsystem VID/DID matching support
authorDavid van Moolenbroek <david@minix3.org>
Mon, 30 Sep 2013 22:42:41 +0000 (00:42 +0200)
committerLionel Sambuc <lionel@minix3.org>
Sat, 1 Mar 2014 08:04:57 +0000 (09:04 +0100)
- change "vid/did" to "vid:did", old form still supported for now;
- allow "vid:did/subvid:subdid" specification in system.conf, in
  which case a device will be visible to a driver if the subsystem
  VID/DID also match.

Change-Id: I7aef54da1b0bc81e24b5d98f1a28416f38f8b266

14 files changed:
commands/service/parse.c
drivers/atl2/atl2.conf
drivers/dec21140A/dec21140A.conf
drivers/e1000/e1000.conf
drivers/fxp/fxp.conf
drivers/lance/lance.conf
drivers/pci/pci.c
drivers/rtl8139/rtl8139.conf
drivers/rtl8169/rtl8169.conf
drivers/virtio_net/virtio_net.conf
etc/system.conf
include/minix/rs.h
man/man5/system.conf.5
servers/rs/manager.c

index 389f268df18780e420d39f67ee41d84f40d23100..e00911afc4bb00344258a7a102af886a088cf9ca 100644 (file)
@@ -519,7 +519,7 @@ static void do_io(config_t *cpe, struct rs_start *rs_start)
 
 static void do_pci_device(config_t *cpe, struct rs_start *rs_start)
 {
-       u16_t vid, did;
+       u16_t vid, did, sub_vid, sub_did;
        char *check, *check2;
 
        /* Process a list of PCI device IDs */
@@ -536,12 +536,25 @@ static void do_pci_device(config_t *cpe, struct rs_start *rs_start)
                                cpe->file, cpe->line);
                }
                vid= strtoul(cpe->word, &check, 0x10);
-               if (check[0] == '/')
-                       did= strtoul(check+1, &check2, 0x10);
-               if (check[0] != '/' || check2[0] != '\0')
-               {
+               if (check[0] != ':' && /* LEGACY: */ check[0] != '/') {
+                       fatal("do_pci_device: bad ID '%s' at %s:%d",
+                               cpe->word, cpe->file, cpe->line);
+               }
+               did= strtoul(check+1, &check, 0x10);
+               if (check[0] == '/') {
+                       sub_vid= strtoul(check+1, &check, 0x10);
+                       if (check[0] == ':')
+                               sub_did= strtoul(check+1, &check2, 0x10);
+                       if (check[0] != ':' || check2[0] != '\0') {
+                               fatal("do_pci_device: bad ID '%s' at %s:%d",
+                                       cpe->word, cpe->file, cpe->line);
+                       }
+               } else if (check[0] != '\0') {
                        fatal("do_pci_device: bad ID '%s' at %s:%d",
                                cpe->word, cpe->file, cpe->line);
+               } else {
+                       sub_vid = NO_SUB_VID;
+                       sub_did = NO_SUB_DID;
                }
                if (rs_start->rss_nr_pci_id >= RS_NR_PCI_DEVICE)
                {
@@ -550,6 +563,8 @@ static void do_pci_device(config_t *cpe, struct rs_start *rs_start)
                }
                rs_start->rss_pci_id[rs_start->rss_nr_pci_id].vid= vid;
                rs_start->rss_pci_id[rs_start->rss_nr_pci_id].did= did;
+               rs_start->rss_pci_id[rs_start->rss_nr_pci_id].sub_vid= sub_vid;
+               rs_start->rss_pci_id[rs_start->rss_nr_pci_id].sub_did= sub_did;
                rs_start->rss_nr_pci_id++;
        }
 }
index 4cfee56bc38a370ea39ca3551250190bed765af4..92b92cab96d98743856c41b390c07ba80d046834 100644 (file)
@@ -6,7 +6,7 @@ service atl2
                 UMAP            # 14
                 IRQCTL          # 19
         ;
-        pci device      1969/2048;
+        pci device      1969:2048;
         ipc
                 SYSTEM pm rs tty ds vm
                 pci inet lwip
index dd1199382b91e1ee6ee0c71b92639288b93f6b88..6540a1c913c571a62b486aab368e0d6ea330d522 100644 (file)
@@ -8,7 +8,7 @@ service dec21140A
                 IRQCTL          # 19
                 DEVIO           # 21
         ;
-        pci device      1011/0009;
+        pci device      1011:0009;
         ipc
                 SYSTEM pm rs log tty ds vm
                 pci inet lwip
index 20e56199242b3c9ef3dbdc458a79ae0244d49789..968874cd0820479d4c059e90b376b8f19a23d907 100644 (file)
@@ -7,13 +7,13 @@ service e1000
                 IRQCTL          # 19
                 DEVIO           # 21
         ;
-        pci device      8086/100e;
-        pci device      8086/100f;
-        pci device      8086/107c;
-        pci device      8086/10cd;
-        pci device      8086/10d3;
-        pci device      8086/10de;
-        pci device      8086/105e;
+        pci device      8086:100e;
+        pci device      8086:100f;
+        pci device      8086:107c;
+        pci device      8086:10cd;
+        pci device      8086:10d3;
+        pci device      8086:10de;
+        pci device      8086:105e;
         ipc
                 SYSTEM pm rs log tty ds vm
                 pci inet lwip ;
index ed4668c7478ebb9773df38f06df0371ab30e5a66..0259471a1f4705bb8bda44e6b8f21d8cbc98647d 100644 (file)
@@ -8,13 +8,13 @@ service fxp
                 IRQCTL          # 19
                 DEVIO           # 21
         ;
-        pci device      8086/1031;
-        pci device      8086/1032;
-        pci device      8086/103d;
-        pci device      8086/1064;
-        pci device      8086/1229;
-        pci device      8086/2449;
-        pci device      8086/1209;
+        pci device      8086:1031;
+        pci device      8086:1032;
+        pci device      8086:103d;
+        pci device      8086:1064;
+        pci device      8086:1229;
+        pci device      8086:2449;
+        pci device      8086:1209;
         ipc
                 SYSTEM pm rs log tty ds vm
                 pci inet lwip amddev
index a25361fc7ea851eade0092bdadcab0a2012341a5..b5a4dda67146164774485e34a29ab35913187370 100644 (file)
@@ -8,7 +8,7 @@ service lance
                 IRQCTL          # 19
                 DEVIO           # 21
         ;
-        pci device      1022/2000;
+        pci device      1022:2000;
         uid     0;
 };
 
index 40d6b28d20747304a9cc5c17f43cbceb8242a7e5..367d586a22858542b32f1b011af5527e50ba5d3c 100644 (file)
@@ -70,6 +70,8 @@ static struct pcidev
        u8_t pd_infclass;
        u16_t pd_vid;
        u16_t pd_did;
+       u16_t pd_sub_vid;
+       u16_t pd_sub_did;
        u8_t pd_ilr;
 
        u8_t pd_inuse;
@@ -737,7 +739,7 @@ static void pci_intel_init()
                dstr= "unknown device";
        if (debug)
        {
-               printf("pci_intel_init: %s (%04X/%04X)\n",
+               printf("pci_intel_init: %s (%04X:%04X)\n",
                        dstr, vid, did);
        }
 
@@ -774,7 +776,7 @@ static void pci_intel_init()
 static void probe_bus(int busind)
 {
        u32_t dev, func, t3;
-       u16_t vid, did, sts;
+       u16_t vid, did, sts, sub_vid, sub_did;
        u8_t headt;
        u8_t baseclass, subclass, infclass;
        int devind, busnr;
@@ -831,12 +833,15 @@ static void probe_bus(int busind)
                            }
                        }
 
+                       sub_vid= pci_attr_r16(devind, PCI_SUBVID);
+                       sub_did= pci_attr_r16(devind, PCI_SUBDID);
+
                        dstr= pci_dev_name(vid, did);
                        if (debug)
                        {
                                if (dstr)
                                {
-                                       printf("%d.%lu.%lu: %s (%04X/%04X)\n",
+                                       printf("%d.%lu.%lu: %s (%04X:%04X)\n",
                                                busnr, (unsigned long)dev,
                                                (unsigned long)func, dstr,
                                                vid, did);
@@ -851,8 +856,7 @@ static void probe_bus(int busind)
                                }
                                printf("Device index: %d\n", devind);
                                printf("Subsystem: Vid 0x%x, did 0x%x\n",
-                                       pci_attr_r16(devind, PCI_SUBVID),
-                                       pci_attr_r16(devind, PCI_SUBDID));
+                                       sub_vid, sub_did);
                        }
 
                        baseclass= pci_attr_r8_u(devind, PCI_BCR);
@@ -886,6 +890,8 @@ static void probe_bus(int busind)
                        pcidev[devind].pd_infclass= infclass;
                        pcidev[devind].pd_vid= vid;
                        pcidev[devind].pd_did= did;
+                       pcidev[devind].pd_sub_vid= sub_vid;
+                       pcidev[devind].pd_sub_did= sub_did;
                        pcidev[devind].pd_inuse= 0;
                        pcidev[devind].pd_bar_nr= 0;
                        record_irq(devind);
@@ -1531,7 +1537,7 @@ static void complete_bars(void)
                        if (debug)
                        {
                                printf(
-               "pci device %d (%04x/%04x), bar %d: base 0x%x, size 0x%x\n",
+               "pci device %d (%04x:%04x), bar %d: base 0x%x, size 0x%x\n",
                                        i, pcidev[i].pd_vid, pcidev[i].pd_did,
                                        j, base, size);
                        }
@@ -1765,7 +1771,7 @@ int busind;
                        dstr= "unknown device";
                if (debug)
                {
-                       printf("found ISA bridge (%04X/%04X) %s\n",
+                       printf("found ISA bridge (%04X:%04X) %s\n",
                                vid, did, dstr);
                }
                pcibus[busind].pb_isabridge_dev= bridge_dev;
@@ -1803,7 +1809,7 @@ int busind;
        if (debug)
        {
                printf(
-               "(warning) unsupported ISA bridge %04X/%04X for bus %d\n",
+               "(warning) unsupported ISA bridge %04X:%04X for bus %d\n",
                        pcidev[unknown_bridge].pd_vid,
                        pcidev[unknown_bridge].pd_did, busind);
        }
@@ -1899,7 +1905,7 @@ int busind;
                                t3 != PCI_T3_PCI2PCI_SUBTR)
                        {
                                printf(
-"Unknown PCI class %02x:%02x:%02x for PCI-to-PCI bridge, device %04X/%04X\n",
+"Unknown PCI class %02x/%02x/%02x for PCI-to-PCI bridge, device %04X:%04X\n",
                                        baseclass, subclass, infclass,
                                        vid, did);
                                continue;
@@ -1908,7 +1914,7 @@ int busind;
                                t3 != PCI_T3_CARDBUS)
                        {
                                printf(
-"Unknown PCI class %02x:%02x:%02x for Cardbus bridge, device %04X/%04X\n",
+"Unknown PCI class %02x/%02x/%02x for Cardbus bridge, device %04X:%04X\n",
                                        baseclass, subclass, infclass,
                                        vid, did);
                                continue;
@@ -1917,7 +1923,7 @@ int busind;
 
                if (debug)
                {
-                       printf("%u.%u.%u: PCI-to-PCI bridge: %04X/%04X\n",
+                       printf("%u.%u.%u: PCI-to-PCI bridge: %04X:%04X\n",
                                pcidev[devind].pd_busnr,
                                pcidev[devind].pd_dev, 
                                pcidev[devind].pd_func, vid, did);
@@ -2640,6 +2646,7 @@ static int visible(aclp, devind)
 struct rs_pci *aclp;
 int devind;
 {
+       u16_t acl_sub_vid, acl_sub_did;
        int i;
        u32_t class_id;
 
@@ -2651,8 +2658,14 @@ int devind;
        /* Check whether the caller is allowed to get this device. */
        for (i= 0; i<aclp->rsp_nr_device; i++)
        {
+               acl_sub_vid = aclp->rsp_device[i].sub_vid;
+               acl_sub_did = aclp->rsp_device[i].sub_did;
                if (aclp->rsp_device[i].vid == pcidev[devind].pd_vid &&
-                       aclp->rsp_device[i].did == pcidev[devind].pd_did)
+                       aclp->rsp_device[i].did == pcidev[devind].pd_did &&
+                       (acl_sub_vid == NO_SUB_VID ||
+                       acl_sub_vid == pcidev[devind].pd_sub_vid) &&
+                       (acl_sub_did == NO_SUB_DID ||
+                       acl_sub_did == pcidev[devind].pd_sub_did))
                {
                        return TRUE;
                }
index bbab4eb40ae1fa73d38fb32c7980d60a503ac8b4..1e598450462adc7c1d9848b512fd193140c8cd85 100644 (file)
@@ -7,23 +7,23 @@ service rtl8139
                 IRQCTL          # 19
                 DEVIO           # 21
         ;
-        pci device      10ec/8139;
-        pci device      02ac/1012;
-        pci device      1065/8139;
-        pci device      1113/1211;
-        pci device      1186/1300;
-        pci device      1186/1340;
-        pci device      11db/1234;
-        pci device      1259/a117;
-        pci device      1259/a11e;
-        pci device      126c/1211;
-        pci device      13d1/ab06;
-        pci device      1432/9130;
-        pci device      14ea/ab06;
-        pci device      14ea/ab07;
-        pci device      1500/1360;
-        pci device      1743/8139;
-        pci device      4033/1360;
+        pci device      10ec:8139;
+        pci device      02ac:1012;
+        pci device      1065:8139;
+        pci device      1113:1211;
+        pci device      1186:1300;
+        pci device      1186:1340;
+        pci device      11db:1234;
+        pci device      1259:a117;
+        pci device      1259:a11e;
+        pci device      126c:1211;
+        pci device      13d1:ab06;
+        pci device      1432:9130;
+        pci device      14ea:ab06;
+        pci device      14ea:ab07;
+        pci device      1500:1360;
+        pci device      1743:8139;
+        pci device      4033:1360;
         ipc
                 SYSTEM pm rs log tty ds vm
                 pci inet lwip amddev
index 79a21dc4b8f7af0b6034a9f34061fd6e8656e085..eac7017951e33a08e7db77ac34fa3a085b99e408 100644 (file)
@@ -8,16 +8,16 @@ service rtl8169
                 IRQCTL          # 19
                 DEVIO           # 21
         ;
-        pci device      10ec/8129;
-        pci device      10ec/8136;
-        pci device      10ec/8167;
-        pci device      10ec/8169;
-        pci device      10ec/8168;
-        pci device      1186/4300;
-        pci device      1259/c107;
-        pci device      1385/8169;
-        pci device      16ec/0116;
-        pci device      1737/1032;
+        pci device      10ec:8129;
+        pci device      10ec:8136;
+        pci device      10ec:8167;
+        pci device      10ec:8169;
+        pci device      10ec:8168;
+        pci device      1186:4300;
+        pci device      1259:c107;
+        pci device      1385:8169;
+        pci device      16ec:0116;
+        pci device      1737:1032;
         ipc
                 SYSTEM pm rs log tty ds vm
                 pci inet lwip amddev
index 46daa1e7e01c3bb3282cacb0ab41fe4a1cafef1e..ca19a2574bdd9bc991b28694cc50bc1445cb8bb1 100644 (file)
@@ -9,5 +9,5 @@ service virtio_net
                DEVIO
        ;
 
-       pci device      1af4/1000;
+       pci device      1af4:1000;
 }
index 8549015742b7c2440738f7d4ef6da823068f6361..2bfd282eaafbaeb88a145c87807ce0c414f211d9 100644 (file)
@@ -255,7 +255,7 @@ service dp8390
                DEVIO           # 21
                SDEVIO          # 22
        ;
-       pci device      10ec/8029;
+       pci device      10ec:8029;
        uid     0;
 };
 
@@ -348,7 +348,7 @@ service virtio_blk
                DEVIO
        ;
 
-       pci device      1af4/1001;
+       pci device      1af4:1001;
 };
 
 service at_wini
@@ -437,8 +437,8 @@ service orinoco
                DEVIO           # 21
                VM_MAP          # 30
        ;
-       pci device      1260/3873;
-       pci device      1186/1300;
+       pci device      1260:3873;
+       pci device      1186:1300;
        uid     0;
 };
 
@@ -449,7 +449,7 @@ service es1370
                IRQCTL          # 19
                DEVIO           # 21
        ;
-       pci device 1274/5000;
+       pci device 1274:5000;
 };
 
 service es1371
@@ -459,7 +459,7 @@ service es1371
                IRQCTL          # 19
                DEVIO           # 21
        ;
-       pci device 1274/1371;
+       pci device 1274:1371;
 };
 
 service ti1225
@@ -467,12 +467,12 @@ service ti1225
        system
                IRQCTL          # 19
        ;
-       pci device      104c/ac1c;
+       pci device      104c:ac1c;
 };
 
 service amddev
 {
-       pci device      1022/1103;
+       pci device      1022:1103;
        system
                UMAP_REMOTE     # 17
        ;
@@ -671,7 +671,7 @@ service vbox
                IRQCTL          # 19
                DEVIO           # 21
        ;
-       pci device      80ee/cafe;
+       pci device      80ee:cafe;
        ipc
                SYSTEM
                PM
index f48d552e7f54afb5fe1088447e6b3e7e3cc25ee3..a0c79497e59a1133bb1a77e6f2fd6c32e86ec087 100644 (file)
@@ -47,6 +47,20 @@ struct rss_label
        size_t l_len;
 };
 
+struct rs_pci_id {
+       u16_t vid;
+       u16_t did;
+       u16_t sub_vid;
+       u16_t sub_did;
+};
+#define NO_SUB_VID     0xffff
+#define NO_SUB_DID     0xffff
+
+struct rs_pci_class {
+       u32_t pciclass;
+       u32_t mask;
+};
+
 /* Arguments needed to start a new driver or server */
 struct rs_start
 {
@@ -68,9 +82,9 @@ struct rs_start
        int rss_nr_io;
        struct { unsigned base; unsigned len; } rss_io[RSS_NR_IO];
        int rss_nr_pci_id;
-       struct { u16_t vid; u16_t did; } rss_pci_id[RS_NR_PCI_DEVICE];
+       struct rs_pci_id rss_pci_id[RS_NR_PCI_DEVICE];
        int rss_nr_pci_class;
-       struct { u32_t pciclass; u32_t mask; } rss_pci_class[RS_NR_PCI_CLASS];
+       struct rs_pci_class rss_pci_class[RS_NR_PCI_CLASS];
        bitchunk_t rss_system[SYS_CALL_MASK_SIZE];
        struct rss_label rss_label;
        char *rss_ipc;
@@ -94,9 +108,9 @@ struct rs_pci
        char rsp_label[RS_MAX_LABEL_LEN];
        int rsp_endpoint;
        int rsp_nr_device;
-       struct { u16_t vid; u16_t did; } rsp_device[RS_NR_PCI_DEVICE];
+       struct rs_pci_id rsp_device[RS_NR_PCI_DEVICE];
        int rsp_nr_class;
-       struct { u32_t pciclass; u32_t mask; } rsp_class[RS_NR_PCI_CLASS];
+       struct rs_pci_class rsp_class[RS_NR_PCI_CLASS];
 };
 
 /* Definition of a public entry of the system process table. */
index 111b21ea883b650d6c642cd1939f64b3f2052b9b..db46b394b2e6e6301e06c85c156ea99397401fd8 100644 (file)
@@ -144,19 +144,22 @@ specifies the quantum size (ms) the scheduler must consider the service for.
 The default is specified in \fB<minix/priv.h>\fR (see macro \fBDSRV_QT\fR).
 .RE
 .PP
-\fBpci device\fR \fI<vid/did>\fR\fB;\fR
+\fBpci device\fR \fI<vid:did[/subvid:subdid]>\fR\fB;\fR
 .PP
 .RS
 specifies the PCI device IDs the system service is allowed to use
-(only used for device drivers).
+(only used for device drivers).  Optionally, a subsystem ID may be provided
+for more precise (limited) matching.
 The default is to allow no PCI device IDs.
 .RE
 .PP
-\fBpci class\fR \fI<class1/mask1 class2/mask2...classN/maskN>\fR\fB;\fR
+\fBpci class\fR \fI<class[/subclass[/progif]]>\fR\fB;\fR
 .PP
 .RS
 specifies the PCI classes the system service is allowed to use
 (only used for device drivers).
+Optionally, a subclass code and a programming interface code may be provided
+for more precise (limited) matching.
 The default is to allow no PCI classes.
 .RE
 .PP
index 7926d2b673d84449276bb858f541facbf3f5de37..a7ef923a8a59fa1008b52b7d1326fe7998259321 100644 (file)
@@ -1627,10 +1627,14 @@ endpoint_t source;
   for (i= 0; i<rpub->pci_acl.rsp_nr_device; i++) {
       rpub->pci_acl.rsp_device[i].vid= rs_start->rss_pci_id[i].vid;
       rpub->pci_acl.rsp_device[i].did= rs_start->rss_pci_id[i].did;
+      rpub->pci_acl.rsp_device[i].sub_vid= rs_start->rss_pci_id[i].sub_vid;
+      rpub->pci_acl.rsp_device[i].sub_did= rs_start->rss_pci_id[i].sub_did;
       if(rs_verbose)
-          printf("RS: init_slot: PCI %04x/%04x\n",
+          printf("RS: init_slot: PCI %04x/%04x (sub %04x:%04x)\n",
               rpub->pci_acl.rsp_device[i].vid,
-              rpub->pci_acl.rsp_device[i].did);
+              rpub->pci_acl.rsp_device[i].did,
+              rpub->pci_acl.rsp_device[i].sub_vid,
+              rpub->pci_acl.rsp_device[i].sub_did);
   }
   if (rs_start->rss_nr_pci_class > RS_NR_PCI_CLASS) {
       printf("RS: init_slot: too many PCI class IDs\n");