summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>1999-04-24 19:59:20 +0000
committerpeter <peter@FreeBSD.org>1999-04-24 19:59:20 +0000
commite7462e4ae57c4f138096d5845ab761b06a08fb0a (patch)
tree9ee3e749205bf562cf331a25d5e24364dcfa94bb /sys
parent484e1a3ce13414a858152975b70ae9751604a37a (diff)
downloadFreeBSD-src-e7462e4ae57c4f138096d5845ab761b06a08fb0a.zip
FreeBSD-src-e7462e4ae57c4f138096d5845ab761b06a08fb0a.tar.gz
Replace the pcidevice_set linker set based configuration mechanism for old
style pci drivers with a simple one-line change to use a module that registers itself under new-bus and should in theory enable just about all of the pci drivers to be loadable (kldload and loader(8)) but without having the impact of converting the APIs yet. This also fixes the problem of having undefined variables when only new-style pci drivers are present.
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/pci/pci.c26
-rw-r--r--sys/dev/pci/pcivar.h14
-rw-r--r--sys/pci/pci.c26
-rw-r--r--sys/pci/pcivar.h14
4 files changed, 58 insertions, 22 deletions
diff --git a/sys/dev/pci/pci.c b/sys/dev/pci/pci.c
index 889550c..6312279 100644
--- a/sys/dev/pci/pci.c
+++ b/sys/dev/pci/pci.c
@@ -23,7 +23,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $Id: pci.c,v 1.94 1999/04/11 02:47:31 eivind Exp $
+ * $Id: pci.c,v 1.95 1999/04/16 21:22:52 peter Exp $
*
*/
@@ -38,6 +38,7 @@
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/malloc.h>
+#include <sys/module.h>
#include <sys/fcntl.h>
#include <sys/conf.h>
#include <sys/kernel.h>
@@ -926,17 +927,17 @@ static devclass_t pci_devclass;
/*
* Create a new style driver around each old pci driver.
*/
-static void
-pci_wrap_old_drivers(void)
+int
+compat_pci_handler(struct moduledata *mod, int type, void *data)
{
- struct pci_device **dvpp, *dvp;
+ struct pci_device *dvp = (struct pci_device *)data;
+ driver_t *driver;
- dvpp = (struct pci_device **)pcidevice_set.ls_items;
- while ((dvp = *dvpp++) != NULL) {
- driver_t *driver;
+ switch (type) {
+ case MOD_LOAD:
driver = malloc(sizeof(driver_t), M_DEVBUF, M_NOWAIT);
if (!driver)
- continue;
+ return ENOMEM;
bzero(driver, sizeof(driver_t));
driver->name = dvp->pd_name;
driver->methods = pci_compat_methods;
@@ -944,7 +945,14 @@ pci_wrap_old_drivers(void)
driver->softc = sizeof(struct pci_devinfo *);
driver->priv = dvp;
devclass_add_driver(pci_devclass, driver);
+ break;
+ case MOD_UNLOAD:
+ printf("%s: module unload not supported!\n", mod->name);
+ return EOPNOTSUPP;
+ default:
+ break;
}
+ return 0;
}
/*
@@ -1330,7 +1338,7 @@ pci_modevent(module_t mod, int what, void *arg)
{
switch (what) {
case MOD_LOAD:
- pci_wrap_old_drivers();
+ /* pci_wrap_old_drivers(); */
break;
case MOD_UNLOAD:
diff --git a/sys/dev/pci/pcivar.h b/sys/dev/pci/pcivar.h
index 3607132..3df7074 100644
--- a/sys/dev/pci/pcivar.h
+++ b/sys/dev/pci/pcivar.h
@@ -23,7 +23,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $Id: pcivar.h,v 1.26 1999/04/16 21:22:52 peter Exp $
+ * $Id: pcivar.h,v 1.27 1999/04/17 08:36:07 peter Exp $
*
*/
@@ -271,7 +271,6 @@ typedef void pci_inthand_t(void *arg);
/* just copied from old PCI code for now ... */
-extern struct linker_set pcidevice_set;
extern int pci_mechanism;
struct pci_device {
@@ -300,5 +299,16 @@ int pci_map_int_right(pcici_t cfg, pci_inthand_t *handler, void *arg,
intrmask_t *maskptr, u_int flags);
int pci_unmap_int (pcici_t tag);
+struct moduledata;
+int compat_pci_handler (struct moduledata *, int, void *);
+#define COMPAT_PCI_DRIVER(name, pcidata) \
+static moduledata_t name##_mod = { \
+ #name, \
+ compat_pci_handler, \
+ &pcidata \
+}; \
+DECLARE_MODULE(name, name##_mod, SI_SUB_DRIVERS, SI_ORDER_ANY)
+
+
#endif /* PCI_COMPAT */
#endif /* _PCIVAR_H_ */
diff --git a/sys/pci/pci.c b/sys/pci/pci.c
index 889550c..6312279 100644
--- a/sys/pci/pci.c
+++ b/sys/pci/pci.c
@@ -23,7 +23,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $Id: pci.c,v 1.94 1999/04/11 02:47:31 eivind Exp $
+ * $Id: pci.c,v 1.95 1999/04/16 21:22:52 peter Exp $
*
*/
@@ -38,6 +38,7 @@
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/malloc.h>
+#include <sys/module.h>
#include <sys/fcntl.h>
#include <sys/conf.h>
#include <sys/kernel.h>
@@ -926,17 +927,17 @@ static devclass_t pci_devclass;
/*
* Create a new style driver around each old pci driver.
*/
-static void
-pci_wrap_old_drivers(void)
+int
+compat_pci_handler(struct moduledata *mod, int type, void *data)
{
- struct pci_device **dvpp, *dvp;
+ struct pci_device *dvp = (struct pci_device *)data;
+ driver_t *driver;
- dvpp = (struct pci_device **)pcidevice_set.ls_items;
- while ((dvp = *dvpp++) != NULL) {
- driver_t *driver;
+ switch (type) {
+ case MOD_LOAD:
driver = malloc(sizeof(driver_t), M_DEVBUF, M_NOWAIT);
if (!driver)
- continue;
+ return ENOMEM;
bzero(driver, sizeof(driver_t));
driver->name = dvp->pd_name;
driver->methods = pci_compat_methods;
@@ -944,7 +945,14 @@ pci_wrap_old_drivers(void)
driver->softc = sizeof(struct pci_devinfo *);
driver->priv = dvp;
devclass_add_driver(pci_devclass, driver);
+ break;
+ case MOD_UNLOAD:
+ printf("%s: module unload not supported!\n", mod->name);
+ return EOPNOTSUPP;
+ default:
+ break;
}
+ return 0;
}
/*
@@ -1330,7 +1338,7 @@ pci_modevent(module_t mod, int what, void *arg)
{
switch (what) {
case MOD_LOAD:
- pci_wrap_old_drivers();
+ /* pci_wrap_old_drivers(); */
break;
case MOD_UNLOAD:
diff --git a/sys/pci/pcivar.h b/sys/pci/pcivar.h
index 3607132..3df7074 100644
--- a/sys/pci/pcivar.h
+++ b/sys/pci/pcivar.h
@@ -23,7 +23,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $Id: pcivar.h,v 1.26 1999/04/16 21:22:52 peter Exp $
+ * $Id: pcivar.h,v 1.27 1999/04/17 08:36:07 peter Exp $
*
*/
@@ -271,7 +271,6 @@ typedef void pci_inthand_t(void *arg);
/* just copied from old PCI code for now ... */
-extern struct linker_set pcidevice_set;
extern int pci_mechanism;
struct pci_device {
@@ -300,5 +299,16 @@ int pci_map_int_right(pcici_t cfg, pci_inthand_t *handler, void *arg,
intrmask_t *maskptr, u_int flags);
int pci_unmap_int (pcici_t tag);
+struct moduledata;
+int compat_pci_handler (struct moduledata *, int, void *);
+#define COMPAT_PCI_DRIVER(name, pcidata) \
+static moduledata_t name##_mod = { \
+ #name, \
+ compat_pci_handler, \
+ &pcidata \
+}; \
+DECLARE_MODULE(name, name##_mod, SI_SUB_DRIVERS, SI_ORDER_ANY)
+
+
#endif /* PCI_COMPAT */
#endif /* _PCIVAR_H_ */
OpenPOWER on IntegriCloud