diff options
author | mdodd <mdodd@FreeBSD.org> | 2002-10-02 04:42:24 +0000 |
---|---|---|
committer | mdodd <mdodd@FreeBSD.org> | 2002-10-02 04:42:24 +0000 |
commit | f005de54e0d5bb9ccccc4ac9ced19cf1accc1794 (patch) | |
tree | e6b596a8cc365e523fc4edb004608426e9c112dc /sys/dev/hea | |
parent | 9e360188d2a708c46c7f658cd14122a310409127 (diff) | |
download | FreeBSD-src-f005de54e0d5bb9ccccc4ac9ced19cf1accc1794.zip FreeBSD-src-f005de54e0d5bb9ccccc4ac9ced19cf1accc1794.tar.gz |
Create/destroy memory zones on module load/unload, not on device
attach/detach.
Diffstat (limited to 'sys/dev/hea')
-rw-r--r-- | sys/dev/hea/hea_freebsd.c | 62 | ||||
-rw-r--r-- | sys/dev/hea/hea_pci.c | 1 |
2 files changed, 48 insertions, 15 deletions
diff --git a/sys/dev/hea/hea_freebsd.c b/sys/dev/hea/hea_freebsd.c index 6efabb5..8640522 100644 --- a/sys/dev/hea/hea_freebsd.c +++ b/sys/dev/hea/hea_freebsd.c @@ -93,6 +93,8 @@ devclass_t hea_devclass; +static int hea_modevent(module_t, int, void *); + int hea_alloc (device_t dev) { @@ -158,18 +160,6 @@ hea_attach (device_t dev) eup = &sc->eup; error = 0; - eni_vcc_zone = uma_zcreate("eni vcc", sizeof(Eni_vcc), NULL, - NULL, NULL, NULL, UMA_ALIGN_PTR, 0); - if (eni_vcc_zone == NULL) - panic("hea_attach: uma_zcreate vcc"); - uma_zone_set_max(eni_vcc_zone, 100); - - eni_nif_zone = uma_zcreate("eni nif", sizeof(struct atm_nif), NULL, - NULL, NULL, NULL, UMA_ALIGN_PTR, 0); - if (eni_nif_zone == NULL) - panic("hea_attach: uma_zcreate nif"); - uma_zone_set_max(eni_nif_zone, 52); - /* * Start initializing it */ @@ -342,9 +332,6 @@ hea_detach (device_t dev) hea_free(dev); - uma_zdestroy(eni_vcc_zone); - uma_zdestroy(eni_nif_zone); - return (error); } @@ -391,3 +378,48 @@ hea_reset (device_t dev) return; } + +static int +hea_modevent (module_t mod, int type, void *data) +{ + int error; + + error = 0; + + switch (type) { + case MOD_LOAD: + + eni_nif_zone = uma_zcreate("eni nif", sizeof(struct atm_nif), + NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, 0); + if (eni_nif_zone == NULL) + panic("%s(): uma_zcreate nif", __func__); + uma_zone_set_max(eni_nif_zone, 52); + + eni_vcc_zone = uma_zcreate("eni vcc", sizeof(Eni_vcc), + NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, 0); + if (eni_vcc_zone == NULL) + panic("%s(): uma_zcreate vcc", __func__); + uma_zone_set_max(eni_vcc_zone, 100); + + break; + + case MOD_UNLOAD: + + uma_zdestroy(eni_nif_zone); + uma_zdestroy(eni_vcc_zone); + + break; + default: + break; + } + + return (error); +} + +static moduledata_t hea_moduledata = { + "hea", + hea_modevent, + NULL +}; +DECLARE_MODULE(hea, hea_moduledata, SI_SUB_DRIVERS, SI_ORDER_MIDDLE); +MODULE_VERSION(hea, 1); diff --git a/sys/dev/hea/hea_pci.c b/sys/dev/hea/hea_pci.c index d54a898..8432f58 100644 --- a/sys/dev/hea/hea_pci.c +++ b/sys/dev/hea/hea_pci.c @@ -246,3 +246,4 @@ static driver_t hea_pci_driver = { DRIVER_MODULE(hea, pci, hea_pci_driver, hea_devclass, 0, 0); MODULE_DEPEND(hea, pci, 1, 1, 1); +MODULE_DEPEND(hea, hea, 1, 1, 1); |