pci_pci.c (f41be0f07673849a55ab3dfbba8878b9cb06b133) | pci_pci.c (d7be980dbe6961abce6b3e12de0391cbad295f95) |
---|---|
1/*- 2 * Copyright (c) 1994,1995 Stefan Esser, Wolfgang StanglMeier 3 * Copyright (c) 2000 Michael Smith <msmith@freebsd.org> 4 * Copyright (c) 2000 BSDi 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 45 unchanged lines hidden (view full) --- 54 55#include "pcib_if.h" 56 57static int pcib_probe(device_t dev); 58static int pcib_suspend(device_t dev); 59static int pcib_resume(device_t dev); 60static int pcib_power_for_sleep(device_t pcib, device_t dev, 61 int *pstate); | 1/*- 2 * Copyright (c) 1994,1995 Stefan Esser, Wolfgang StanglMeier 3 * Copyright (c) 2000 Michael Smith <msmith@freebsd.org> 4 * Copyright (c) 2000 BSDi 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 45 unchanged lines hidden (view full) --- 54 55#include "pcib_if.h" 56 57static int pcib_probe(device_t dev); 58static int pcib_suspend(device_t dev); 59static int pcib_resume(device_t dev); 60static int pcib_power_for_sleep(device_t pcib, device_t dev, 61 int *pstate); |
62static uint16_t pcib_ari_get_rid(device_t pcib, device_t dev); | 62static int pcib_ari_get_id(device_t pcib, device_t dev, 63 enum pci_id_type type, uintptr_t *id); |
63static uint32_t pcib_read_config(device_t dev, u_int b, u_int s, 64 u_int f, u_int reg, int width); 65static void pcib_write_config(device_t dev, u_int b, u_int s, 66 u_int f, u_int reg, uint32_t val, int width); 67static int pcib_ari_maxslots(device_t dev); 68static int pcib_ari_maxfuncs(device_t dev); 69static int pcib_try_enable_ari(device_t pcib, device_t dev); 70static int pcib_ari_enabled(device_t pcib); --- 38 unchanged lines hidden (view full) --- 109 DEVMETHOD(pcib_write_config, pcib_write_config), 110 DEVMETHOD(pcib_route_interrupt, pcib_route_interrupt), 111 DEVMETHOD(pcib_alloc_msi, pcib_alloc_msi), 112 DEVMETHOD(pcib_release_msi, pcib_release_msi), 113 DEVMETHOD(pcib_alloc_msix, pcib_alloc_msix), 114 DEVMETHOD(pcib_release_msix, pcib_release_msix), 115 DEVMETHOD(pcib_map_msi, pcib_map_msi), 116 DEVMETHOD(pcib_power_for_sleep, pcib_power_for_sleep), | 64static uint32_t pcib_read_config(device_t dev, u_int b, u_int s, 65 u_int f, u_int reg, int width); 66static void pcib_write_config(device_t dev, u_int b, u_int s, 67 u_int f, u_int reg, uint32_t val, int width); 68static int pcib_ari_maxslots(device_t dev); 69static int pcib_ari_maxfuncs(device_t dev); 70static int pcib_try_enable_ari(device_t pcib, device_t dev); 71static int pcib_ari_enabled(device_t pcib); --- 38 unchanged lines hidden (view full) --- 110 DEVMETHOD(pcib_write_config, pcib_write_config), 111 DEVMETHOD(pcib_route_interrupt, pcib_route_interrupt), 112 DEVMETHOD(pcib_alloc_msi, pcib_alloc_msi), 113 DEVMETHOD(pcib_release_msi, pcib_release_msi), 114 DEVMETHOD(pcib_alloc_msix, pcib_alloc_msix), 115 DEVMETHOD(pcib_release_msix, pcib_release_msix), 116 DEVMETHOD(pcib_map_msi, pcib_map_msi), 117 DEVMETHOD(pcib_power_for_sleep, pcib_power_for_sleep), |
117 DEVMETHOD(pcib_get_rid, pcib_ari_get_rid), | 118 DEVMETHOD(pcib_get_id, pcib_ari_get_id), |
118 DEVMETHOD(pcib_try_enable_ari, pcib_try_enable_ari), 119 DEVMETHOD(pcib_ari_enabled, pcib_ari_enabled), 120 DEVMETHOD(pcib_decode_rid, pcib_ari_decode_rid), 121 122 DEVMETHOD_END 123}; 124 125static devclass_t pcib_devclass; --- 2443 unchanged lines hidden (view full) --- 2569{ 2570 struct pcib_softc *sc; 2571 2572 sc = device_get_softc(pcib); 2573 2574 return ((sc->flags & PCIB_ENABLE_ARI) != 0); 2575} 2576 | 119 DEVMETHOD(pcib_try_enable_ari, pcib_try_enable_ari), 120 DEVMETHOD(pcib_ari_enabled, pcib_ari_enabled), 121 DEVMETHOD(pcib_decode_rid, pcib_ari_decode_rid), 122 123 DEVMETHOD_END 124}; 125 126static devclass_t pcib_devclass; --- 2443 unchanged lines hidden (view full) --- 2570{ 2571 struct pcib_softc *sc; 2572 2573 sc = device_get_softc(pcib); 2574 2575 return ((sc->flags & PCIB_ENABLE_ARI) != 0); 2576} 2577 |
2577static uint16_t 2578pcib_ari_get_rid(device_t pcib, device_t dev) | 2578static int 2579pcib_ari_get_id(device_t pcib, device_t dev, enum pci_id_type type, 2580 uintptr_t *id) |
2579{ 2580 struct pcib_softc *sc; 2581 uint8_t bus, slot, func; 2582 | 2581{ 2582 struct pcib_softc *sc; 2583 uint8_t bus, slot, func; 2584 |
2585 if (type != PCI_ID_RID) 2586 return (ENXIO); 2587 |
|
2583 sc = device_get_softc(pcib); 2584 2585 if (sc->flags & PCIB_ENABLE_ARI) { 2586 bus = pci_get_bus(dev); 2587 func = pci_get_function(dev); 2588 | 2588 sc = device_get_softc(pcib); 2589 2590 if (sc->flags & PCIB_ENABLE_ARI) { 2591 bus = pci_get_bus(dev); 2592 func = pci_get_function(dev); 2593 |
2589 return (PCI_ARI_RID(bus, func)); | 2594 *id = (PCI_ARI_RID(bus, func)); |
2590 } else { 2591 bus = pci_get_bus(dev); 2592 slot = pci_get_slot(dev); 2593 func = pci_get_function(dev); 2594 | 2595 } else { 2596 bus = pci_get_bus(dev); 2597 slot = pci_get_slot(dev); 2598 func = pci_get_function(dev); 2599 |
2595 return (PCI_RID(bus, slot, func)); | 2600 *id = (PCI_RID(bus, slot, func)); |
2596 } | 2601 } |
2602 2603 return (0); |
|
2597} 2598 2599/* 2600 * Check that the downstream port (pcib) and the endpoint device (dev) both 2601 * support ARI. If so, enable it and return 0, otherwise return an error. 2602 */ 2603static int 2604pcib_try_enable_ari(device_t pcib, device_t dev) --- 50 unchanged lines hidden --- | 2604} 2605 2606/* 2607 * Check that the downstream port (pcib) and the endpoint device (dev) both 2608 * support ARI. If so, enable it and return 0, otherwise return an error. 2609 */ 2610static int 2611pcib_try_enable_ari(device_t pcib, device_t dev) --- 50 unchanged lines hidden --- |