From: Ben Gras Date: Tue, 20 Feb 2007 17:09:19 +0000 (+0000) Subject: . pci driver now returns devices, even when they have been pci_reserve()d X-Git-Tag: v3.1.3~68 X-Git-Url: http://zhaoyanbai.com/repos/man.dnssec-checkds.html?a=commitdiff_plain;h=168d766f32f0a67460d1c64448cad1a4272b060b;p=minix.git . pci driver now returns devices, even when they have been pci_reserve()d . pci_reserve() returns an error on devices that have already been reserved, instead of panic()ing; the pci_reserve() library call still panics, pci_reserve_ok() returns an int. . this allows at_wini to use the instance value as intended, as all devices are seen, even reserved ones . only devices actually used by at_wini are pci_reserve()d . pci doesn't release devices based on argv[0], as at_wini both have the same name and multiple instances won't work together properly --- diff --git a/drivers/at_wini/at_wini.c b/drivers/at_wini/at_wini.c index 353632dd4..5a8acb839 100644 --- a/drivers/at_wini/at_wini.c +++ b/drivers/at_wini/at_wini.c @@ -581,8 +581,6 @@ PRIVATE void init_params_pci(int skip) else continue; /* Unsupported device class */ - pci_reserve(devind); - /* Found a controller. * Programming interface register tells us more. */ @@ -611,6 +609,12 @@ PRIVATE void init_params_pci(int skip) skip--; continue; } + if(pci_reserve_ok(devind) != OK) { + printf("at_wini%d: pci_reserve %d failed - " + "ignoring controller!\n", + w_instance, devind); + continue; + } if ((s=sys_irqsetpolicy(irq, 0, &irq_hook)) != OK) { printf("atapci: couldn't set IRQ policy %d\n", irq); continue; diff --git a/drivers/pci/main.c b/drivers/pci/main.c index 03b417beb..9283e4617 100644 --- a/drivers/pci/main.c +++ b/drivers/pci/main.c @@ -140,8 +140,10 @@ message *mp; { /* Ignore all init calls for a process after the first one */ } +#if 0 else pci_release(names[i].name); +#endif names[i].tasknr= mp->m_source; mp->m_type= 0; @@ -440,8 +442,8 @@ message *mp; devind= mp->m1_i1; - pci_reserve3(devind, mp->m_source, names[i].name); - mp->m_type= OK; + + mp->m_type= pci_reserve3(devind, mp->m_source, names[i].name); r= send(mp->m_source, mp); if (r != 0) { diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 5cd173a27..929c9d27b 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -243,8 +243,10 @@ int *devindp; } if (devind >= nr_pcidev) return 0; +#if 0 if (pcidev[devind].pd_inuse) return 0; +#endif *devindp= devind; return 1; } @@ -262,8 +264,10 @@ u16_t *didp; for (devind= 0; devind < nr_pcidev; devind++) { +#if 0 if (pcidev[devind].pd_inuse) continue; +#endif if (!visible(aclp, devind)) continue; break; @@ -289,8 +293,10 @@ u16_t *didp; for (devind= *devindp+1; devind < nr_pcidev; devind++) { +#if 0 if (pcidev[devind].pd_inuse) continue; +#endif if (!visible(aclp, devind)) continue; break; @@ -306,7 +312,7 @@ u16_t *didp; /*===========================================================================* * pci_reserve3 * *===========================================================================*/ -PUBLIC void pci_reserve3(devind, proc, name) +PUBLIC int pci_reserve3(devind, proc, name) int devind; int proc; char *name; @@ -317,7 +323,8 @@ char *name; struct mem_range mr; assert(devind <= nr_pcidev); - assert(!pcidev[devind].pd_inuse); + if(pcidev[devind].pd_inuse) + return EBUSY; pcidev[devind].pd_inuse= 1; strcpy(pcidev[devind].pd_name, name); @@ -376,8 +383,11 @@ char *name; proc, r); } } + + return OK; } +#if 0 /*===========================================================================* * pci_release * *===========================================================================*/ @@ -395,6 +405,7 @@ char *name; pcidev[i].pd_inuse= 0; } } +#endif /*===========================================================================* * pci_ids * diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index 898090484..b20942659 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h @@ -82,7 +82,7 @@ extern struct pci_isabridge pci_isabridge[]; extern struct pci_pcibridge pci_pcibridge[]; /* Utility functions */ -_PROTOTYPE( void pci_reserve3, (int devind, int proc, char name[M3_STRING])); +_PROTOTYPE( int pci_reserve3, (int devind, int proc, char name[M3_STRING])); _PROTOTYPE( void pci_release, (char name[M3_STRING]) ); _PROTOTYPE( int pci_first_dev_a, (struct rs_pci *aclp, int *devindp, u16_t *vidp, u16_t *didp) ); diff --git a/include/minix/syslib.h b/include/minix/syslib.h index 9eeb93a03..dddd916df 100755 --- a/include/minix/syslib.h +++ b/include/minix/syslib.h @@ -185,6 +185,7 @@ _PROTOTYPE( int pci_next_dev, (int *devindp, u16_t *vidp, u16_t *didp) ); _PROTOTYPE( int pci_find_dev, (U8_t bus, U8_t dev, U8_t func, int *devindp) ); _PROTOTYPE( void pci_reserve, (int devind) ); +_PROTOTYPE( int pci_reserve_ok, (int devind) ); _PROTOTYPE( void pci_ids, (int devind, u16_t *vidp, u16_t *didp) ); _PROTOTYPE( void pci_rescan_bus, (U8_t busnr) ); _PROTOTYPE( u8_t pci_attr_r8, (int devind, int port) ); diff --git a/lib/syslib/pci_reserve.c b/lib/syslib/pci_reserve.c index 84d7ad0d1..3c0941ad0 100644 --- a/lib/syslib/pci_reserve.c +++ b/lib/syslib/pci_reserve.c @@ -26,3 +26,17 @@ int devind; panic("pci", "pci_reserve: got bad reply from PCI", m.m_type); } +/*===========================================================================* + * pci_reserve_ok * + *===========================================================================*/ +PUBLIC int pci_reserve_ok(devind) +int devind; +{ + int r; + message m; + + m.m1_i1= devind; + + return(_taskcall(pci_procnr, BUSC_PCI_RESERVE, &m)); +} +