From: David van Moolenbroek Date: Mon, 30 Sep 2013 22:42:41 +0000 (+0200) Subject: system.conf: subsystem VID/DID matching support X-Git-Tag: v3.3.0~543 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/pkcs11-destroy.html?a=commitdiff_plain;h=89332ecdf1aabcfdcbb6feba45b9cdc278f322a4;p=minix.git system.conf: subsystem VID/DID matching support - 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 --- diff --git a/commands/service/parse.c b/commands/service/parse.c index 389f268df..e00911afc 100644 --- a/commands/service/parse.c +++ b/commands/service/parse.c @@ -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++; } } diff --git a/drivers/atl2/atl2.conf b/drivers/atl2/atl2.conf index 4cfee56bc..92b92cab9 100644 --- a/drivers/atl2/atl2.conf +++ b/drivers/atl2/atl2.conf @@ -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 diff --git a/drivers/dec21140A/dec21140A.conf b/drivers/dec21140A/dec21140A.conf index dd1199382..6540a1c91 100644 --- a/drivers/dec21140A/dec21140A.conf +++ b/drivers/dec21140A/dec21140A.conf @@ -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 diff --git a/drivers/e1000/e1000.conf b/drivers/e1000/e1000.conf index 20e561992..968874cd0 100644 --- a/drivers/e1000/e1000.conf +++ b/drivers/e1000/e1000.conf @@ -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 ; diff --git a/drivers/fxp/fxp.conf b/drivers/fxp/fxp.conf index ed4668c74..0259471a1 100644 --- a/drivers/fxp/fxp.conf +++ b/drivers/fxp/fxp.conf @@ -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 diff --git a/drivers/lance/lance.conf b/drivers/lance/lance.conf index a25361fc7..b5a4dda67 100644 --- a/drivers/lance/lance.conf +++ b/drivers/lance/lance.conf @@ -8,7 +8,7 @@ service lance IRQCTL # 19 DEVIO # 21 ; - pci device 1022/2000; + pci device 1022:2000; uid 0; }; diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 40d6b28d2..367d586a2 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -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; irsp_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; } diff --git a/drivers/rtl8139/rtl8139.conf b/drivers/rtl8139/rtl8139.conf index bbab4eb40..1e5984504 100644 --- a/drivers/rtl8139/rtl8139.conf +++ b/drivers/rtl8139/rtl8139.conf @@ -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 diff --git a/drivers/rtl8169/rtl8169.conf b/drivers/rtl8169/rtl8169.conf index 79a21dc4b..eac701795 100644 --- a/drivers/rtl8169/rtl8169.conf +++ b/drivers/rtl8169/rtl8169.conf @@ -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 diff --git a/drivers/virtio_net/virtio_net.conf b/drivers/virtio_net/virtio_net.conf index 46daa1e7e..ca19a2574 100644 --- a/drivers/virtio_net/virtio_net.conf +++ b/drivers/virtio_net/virtio_net.conf @@ -9,5 +9,5 @@ service virtio_net DEVIO ; - pci device 1af4/1000; + pci device 1af4:1000; } diff --git a/etc/system.conf b/etc/system.conf index 854901574..2bfd282ea 100644 --- a/etc/system.conf +++ b/etc/system.conf @@ -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 diff --git a/include/minix/rs.h b/include/minix/rs.h index f48d552e7..a0c79497e 100644 --- a/include/minix/rs.h +++ b/include/minix/rs.h @@ -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. */ diff --git a/man/man5/system.conf.5 b/man/man5/system.conf.5 index 111b21ea8..db46b394b 100644 --- a/man/man5/system.conf.5 +++ b/man/man5/system.conf.5 @@ -144,19 +144,22 @@ specifies the quantum size (ms) the scheduler must consider the service for. The default is specified in \fB\fR (see macro \fBDSRV_QT\fR). .RE .PP -\fBpci device\fR \fI\fR\fB;\fR +\fBpci device\fR \fI\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\fR\fB;\fR +\fBpci class\fR \fI\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 diff --git a/servers/rs/manager.c b/servers/rs/manager.c index 7926d2b67..a7ef923a8 100644 --- a/servers/rs/manager.c +++ b/servers/rs/manager.c @@ -1627,10 +1627,14 @@ endpoint_t source; for (i= 0; ipci_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");