if_fxp.c (71228) | if_fxp.c (71485) |
---|---|
1/* 2 * Copyright (c) 1995, David Greenman 3 * All rights reserved. 4 * 5 * Modifications to support media selection: 6 * Copyright (c) 1997 Jason R. Thorpe. All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 13 unchanged lines hidden (view full) --- 22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 * SUCH DAMAGE. 29 * | 1/* 2 * Copyright (c) 1995, David Greenman 3 * All rights reserved. 4 * 5 * Modifications to support media selection: 6 * Copyright (c) 1997 Jason R. Thorpe. All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 13 unchanged lines hidden (view full) --- 22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 * SUCH DAMAGE. 29 * |
30 * $FreeBSD: head/sys/dev/fxp/if_fxp.c 71228 2001-01-19 01:59:14Z bmilekic $ | 30 * $FreeBSD: head/sys/dev/fxp/if_fxp.c 71485 2001-01-23 23:22:17Z mjacob $ |
31 */ 32 33/* 34 * Intel EtherExpress Pro/100B PCI Fast Ethernet driver 35 */ 36 37#include <sys/param.h> 38#include <sys/systm.h> --- 269 unchanged lines hidden (view full) --- 308} 309 310static int 311fxp_attach(device_t dev) 312{ 313 int error = 0; 314 struct fxp_softc *sc = device_get_softc(dev); 315 struct ifnet *ifp; | 31 */ 32 33/* 34 * Intel EtherExpress Pro/100B PCI Fast Ethernet driver 35 */ 36 37#include <sys/param.h> 38#include <sys/systm.h> --- 269 unchanged lines hidden (view full) --- 308} 309 310static int 311fxp_attach(device_t dev) 312{ 313 int error = 0; 314 struct fxp_softc *sc = device_get_softc(dev); 315 struct ifnet *ifp; |
316 u_long val; 317 int rid; | 316 u_int32_t val; 317 int rid, m1, m2, ebitmap; |
318 319 mtx_init(&sc->sc_mtx, device_get_nameunit(dev), MTX_DEF | MTX_RECURSE); 320 callout_handle_init(&sc->stat_ch); 321 322 FXP_LOCK(sc); 323 324 /* | 318 319 mtx_init(&sc->sc_mtx, device_get_nameunit(dev), MTX_DEF | MTX_RECURSE); 320 callout_handle_init(&sc->stat_ch); 321 322 FXP_LOCK(sc); 323 324 /* |
325 * Enable bus mastering. | 325 * Enable bus mastering. Enable memory space too, in case 326 * BIOS/Prom forgot about it. |
326 */ 327 val = pci_read_config(dev, PCIR_COMMAND, 2); 328 val |= (PCIM_CMD_MEMEN|PCIM_CMD_BUSMASTEREN); 329 pci_write_config(dev, PCIR_COMMAND, val, 2); | 327 */ 328 val = pci_read_config(dev, PCIR_COMMAND, 2); 329 val |= (PCIM_CMD_MEMEN|PCIM_CMD_BUSMASTEREN); 330 pci_write_config(dev, PCIR_COMMAND, val, 2); |
331 val = pci_read_config(dev, PCIR_COMMAND, 2); |
|
330 331 if (pci_get_powerstate(dev) != PCI_POWERSTATE_D0) { 332 u_int32_t iobase, membase, irq; 333 334 /* Save important PCI config data. */ 335 iobase = pci_read_config(dev, FXP_PCI_IOBA, 4); 336 membase = pci_read_config(dev, FXP_PCI_MMBA, 4); 337 irq = pci_read_config(dev, PCIR_INTLINE, 4); --- 6 unchanged lines hidden (view full) --- 344 345 /* Restore PCI config data. */ 346 pci_write_config(dev, FXP_PCI_IOBA, iobase, 4); 347 pci_write_config(dev, FXP_PCI_MMBA, membase, 4); 348 pci_write_config(dev, PCIR_INTLINE, irq, 4); 349 } 350 351 /* | 332 333 if (pci_get_powerstate(dev) != PCI_POWERSTATE_D0) { 334 u_int32_t iobase, membase, irq; 335 336 /* Save important PCI config data. */ 337 iobase = pci_read_config(dev, FXP_PCI_IOBA, 4); 338 membase = pci_read_config(dev, FXP_PCI_MMBA, 4); 339 irq = pci_read_config(dev, PCIR_INTLINE, 4); --- 6 unchanged lines hidden (view full) --- 346 347 /* Restore PCI config data. */ 348 pci_write_config(dev, FXP_PCI_IOBA, iobase, 4); 349 pci_write_config(dev, FXP_PCI_MMBA, membase, 4); 350 pci_write_config(dev, PCIR_INTLINE, irq, 4); 351 } 352 353 /* |
352 * Map control/status registers. | 354 * Figure out which we should try first - memory mapping or i/o mapping? 355 * We default to memory mapping. Then we accept an override from the 356 * command line. Then we check to see which one is enabled. |
353 */ | 357 */ |
354 rid = FXP_PCI_MMBA; 355 sc->mem = bus_alloc_resource(dev, SYS_RES_MEMORY, &rid, 356 0, ~0, 1, RF_ACTIVE); | 358 m1 = PCIM_CMD_MEMEN; 359 m2 = PCIM_CMD_PORTEN; 360 ebitmap = 0; 361 if (getenv_int("fxp_iomap", &ebitmap)) { 362 if (ebitmap & (1 << device_get_unit(dev))) { 363 m1 = PCIM_CMD_PORTEN; 364 m2 = PCIM_CMD_MEMEN; 365 } 366 } 367 368 if (val & m1) { 369 sc->rtp = 370 (m1 == PCIM_CMD_MEMEN)? SYS_RES_MEMORY : SYS_RES_IOPORT; 371 sc->rgd = (m1 == PCIM_CMD_MEMEN)? FXP_PCI_MMBA : FXP_PCI_IOBA; 372 sc->mem = bus_alloc_resource(dev, sc->rtp, &sc->rgd, 373 0, ~0, 1, RF_ACTIVE); 374 } 375 if (sc->mem == NULL && (val & m2)) { 376 sc->rtp = 377 (m2 == PCIM_CMD_MEMEN)? SYS_RES_MEMORY : SYS_RES_IOPORT; 378 sc->rgd = (m2 == PCIM_CMD_MEMEN)? FXP_PCI_MMBA : FXP_PCI_IOBA; 379 sc->mem = bus_alloc_resource(dev, sc->rtp, &sc->rgd, 380 0, ~0, 1, RF_ACTIVE); 381 } 382 |
357 if (!sc->mem) { | 383 if (!sc->mem) { |
358 device_printf(dev, "could not map memory\n"); | 384 device_printf(dev, "could not map device registers\n"); |
359 error = ENXIO; 360 goto fail; 361 } | 385 error = ENXIO; 386 goto fail; 387 } |
388 if (bootverbose) { 389 device_printf(dev, "using %s space register mapping\n", 390 sc->rtp == SYS_RES_MEMORY? "memory" : "I/O"); 391 } |
|
362 363 sc->sc_st = rman_get_bustag(sc->mem); 364 sc->sc_sh = rman_get_bushandle(sc->mem); 365 366 /* 367 * Allocate our interrupt. 368 */ 369 rid = 0; --- 12 unchanged lines hidden (view full) --- 382 goto fail; 383 } 384 385 /* Do generic parts of attach. */ 386 if (fxp_attach_common(sc, sc->arpcom.ac_enaddr)) { 387 /* Failed! */ 388 bus_teardown_intr(dev, sc->irq, sc->ih); 389 bus_release_resource(dev, SYS_RES_IRQ, 0, sc->irq); | 392 393 sc->sc_st = rman_get_bustag(sc->mem); 394 sc->sc_sh = rman_get_bushandle(sc->mem); 395 396 /* 397 * Allocate our interrupt. 398 */ 399 rid = 0; --- 12 unchanged lines hidden (view full) --- 412 goto fail; 413 } 414 415 /* Do generic parts of attach. */ 416 if (fxp_attach_common(sc, sc->arpcom.ac_enaddr)) { 417 /* Failed! */ 418 bus_teardown_intr(dev, sc->irq, sc->ih); 419 bus_release_resource(dev, SYS_RES_IRQ, 0, sc->irq); |
390 bus_release_resource(dev, SYS_RES_MEMORY, FXP_PCI_MMBA, sc->mem); | 420 bus_release_resource(dev, sc->rtp, sc->rgd, sc->mem); |
391 error = ENXIO; 392 goto fail; 393 } 394 395 device_printf(dev, "Ethernet address %6D%s\n", 396 sc->arpcom.ac_enaddr, ":", sc->phy_10Mbps_only ? ", 10Mbps" : ""); 397 398 ifp = &sc->arpcom.ac_if; --- 47 unchanged lines hidden (view full) --- 446 */ 447 fxp_stop(sc); 448 449 /* 450 * Deallocate resources. 451 */ 452 bus_teardown_intr(dev, sc->irq, sc->ih); 453 bus_release_resource(dev, SYS_RES_IRQ, 0, sc->irq); | 421 error = ENXIO; 422 goto fail; 423 } 424 425 device_printf(dev, "Ethernet address %6D%s\n", 426 sc->arpcom.ac_enaddr, ":", sc->phy_10Mbps_only ? ", 10Mbps" : ""); 427 428 ifp = &sc->arpcom.ac_if; --- 47 unchanged lines hidden (view full) --- 476 */ 477 fxp_stop(sc); 478 479 /* 480 * Deallocate resources. 481 */ 482 bus_teardown_intr(dev, sc->irq, sc->ih); 483 bus_release_resource(dev, SYS_RES_IRQ, 0, sc->irq); |
454 bus_release_resource(dev, SYS_RES_MEMORY, FXP_PCI_MMBA, sc->mem); | 484 bus_release_resource(dev, sc->rtp, sc->rgd, sc->mem); |
455 456 /* 457 * Free all the receive buffers. 458 */ 459 if (sc->rfa_headm != NULL) 460 m_freem(sc->rfa_headm); 461 462 /* --- 1459 unchanged lines hidden --- | 485 486 /* 487 * Free all the receive buffers. 488 */ 489 if (sc->rfa_headm != NULL) 490 m_freem(sc->rfa_headm); 491 492 /* --- 1459 unchanged lines hidden --- |