pci.c (276299) | pci.c (278320) |
---|---|
1/*- 2 * Copyright (c) 1997, Stefan Esser <se@freebsd.org> 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 --- 13 unchanged lines hidden (view full) --- 22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1997, Stefan Esser <se@freebsd.org> 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 --- 13 unchanged lines hidden (view full) --- 22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29#include <sys/cdefs.h> |
30__FBSDID("$FreeBSD: head/sys/dev/pci/pci.c 276299 2014-12-27 14:26:18Z marius $"); | 30__FBSDID("$FreeBSD: head/sys/dev/pci/pci.c 278320 2015-02-06 16:09:01Z jhb $"); |
31 32#include "opt_bus.h" 33 34#include <sys/param.h> 35#include <sys/systm.h> 36#include <sys/malloc.h> 37#include <sys/module.h> | 31 32#include "opt_bus.h" 33 34#include <sys/param.h> 35#include <sys/systm.h> 36#include <sys/malloc.h> 37#include <sys/module.h> |
38#include <sys/limits.h> |
|
38#include <sys/linker.h> 39#include <sys/fcntl.h> 40#include <sys/conf.h> 41#include <sys/kernel.h> 42#include <sys/queue.h> 43#include <sys/sysctl.h> 44#include <sys/endian.h> 45 --- 4773 unchanged lines hidden (view full) --- 4819 cfg->bus, cfg->slot, cfg->func, reg, val, width); 4820} 4821 4822int 4823pci_child_location_str_method(device_t dev, device_t child, char *buf, 4824 size_t buflen) 4825{ 4826 | 39#include <sys/linker.h> 40#include <sys/fcntl.h> 41#include <sys/conf.h> 42#include <sys/kernel.h> 43#include <sys/queue.h> 44#include <sys/sysctl.h> 45#include <sys/endian.h> 46 --- 4773 unchanged lines hidden (view full) --- 4820 cfg->bus, cfg->slot, cfg->func, reg, val, width); 4821} 4822 4823int 4824pci_child_location_str_method(device_t dev, device_t child, char *buf, 4825 size_t buflen) 4826{ 4827 |
4827 snprintf(buf, buflen, "slot=%d function=%d", pci_get_slot(child), 4828 pci_get_function(child)); | 4828 snprintf(buf, buflen, "pci%d:%d:%d:%d", pci_get_domain(child), 4829 pci_get_bus(child), pci_get_slot(child), pci_get_function(child)); |
4829 return (0); 4830} 4831 4832int 4833pci_child_pnpinfo_str_method(device_t dev, device_t child, char *buf, 4834 size_t buflen) 4835{ 4836 struct pci_devinfo *dinfo; --- 13 unchanged lines hidden (view full) --- 4850{ 4851 struct pci_devinfo *dinfo = device_get_ivars(child); 4852 pcicfgregs *cfg = &dinfo->cfg; 4853 4854 return (PCIB_ROUTE_INTERRUPT(device_get_parent(dev), child, 4855 cfg->intpin)); 4856} 4857 | 4830 return (0); 4831} 4832 4833int 4834pci_child_pnpinfo_str_method(device_t dev, device_t child, char *buf, 4835 size_t buflen) 4836{ 4837 struct pci_devinfo *dinfo; --- 13 unchanged lines hidden (view full) --- 4851{ 4852 struct pci_devinfo *dinfo = device_get_ivars(child); 4853 pcicfgregs *cfg = &dinfo->cfg; 4854 4855 return (PCIB_ROUTE_INTERRUPT(device_get_parent(dev), child, 4856 cfg->intpin)); 4857} 4858 |
4859static void 4860pci_lookup(void *arg, const char *name, device_t *dev) 4861{ 4862 long val; 4863 char *end; 4864 int domain, bus, slot, func; 4865 4866 if (*dev != NULL) 4867 return; 4868 4869 /* 4870 * Accept pciconf-style selectors of either pciD:B:S:F or 4871 * pciB:S:F. In the latter case, the domain is assumed to 4872 * be zero. 4873 */ 4874 if (strncmp(name, "pci", 3) != 0) 4875 return; 4876 val = strtol(name + 3, &end, 10); 4877 if (val < 0 || val > INT_MAX || *end != ':') 4878 return; 4879 domain = val; 4880 val = strtol(end + 1, &end, 10); 4881 if (val < 0 || val > INT_MAX || *end != ':') 4882 return; 4883 bus = val; 4884 val = strtol(end + 1, &end, 10); 4885 if (val < 0 || val > INT_MAX) 4886 return; 4887 slot = val; 4888 if (*end == ':') { 4889 val = strtol(end + 1, &end, 10); 4890 if (val < 0 || val > INT_MAX || *end != '\0') 4891 return; 4892 func = val; 4893 } else if (*end == '\0') { 4894 func = slot; 4895 slot = bus; 4896 bus = domain; 4897 domain = 0; 4898 } else 4899 return; 4900 4901 if (domain > PCI_DOMAINMAX || bus > PCI_BUSMAX || slot > PCI_SLOTMAX || 4902 func > PCIE_ARI_FUNCMAX || (slot != 0 && func > PCI_FUNCMAX)) 4903 return; 4904 4905 *dev = pci_find_dbsf(domain, bus, slot, func); 4906} 4907 |
|
4858static int 4859pci_modevent(module_t mod, int what, void *arg) 4860{ 4861 static struct cdev *pci_cdev; | 4908static int 4909pci_modevent(module_t mod, int what, void *arg) 4910{ 4911 static struct cdev *pci_cdev; |
4912 static eventhandler_tag tag; |
|
4862 4863 switch (what) { 4864 case MOD_LOAD: 4865 STAILQ_INIT(&pci_devq); 4866 pci_generation = 0; 4867 pci_cdev = make_dev(&pcicdev, 0, UID_ROOT, GID_WHEEL, 0644, 4868 "pci"); 4869 pci_load_vendor_data(); | 4913 4914 switch (what) { 4915 case MOD_LOAD: 4916 STAILQ_INIT(&pci_devq); 4917 pci_generation = 0; 4918 pci_cdev = make_dev(&pcicdev, 0, UID_ROOT, GID_WHEEL, 0644, 4919 "pci"); 4920 pci_load_vendor_data(); |
4921 tag = EVENTHANDLER_REGISTER(dev_lookup, pci_lookup, NULL, 4922 1000); |
|
4870 break; 4871 4872 case MOD_UNLOAD: | 4923 break; 4924 4925 case MOD_UNLOAD: |
4926 if (tag != NULL) 4927 EVENTHANDLER_DEREGISTER(dev_lookup, tag); |
|
4873 destroy_dev(pci_cdev); 4874 break; 4875 } 4876 4877 return (0); 4878} 4879 4880static void --- 248 unchanged lines hidden --- | 4928 destroy_dev(pci_cdev); 4929 break; 4930 } 4931 4932 return (0); 4933} 4934 4935static void --- 248 unchanged lines hidden --- |