diff options
author | imp <imp@FreeBSD.org> | 2003-02-17 21:20:35 +0000 |
---|---|---|
committer | imp <imp@FreeBSD.org> | 2003-02-17 21:20:35 +0000 |
commit | 583fcf1070d55ddcf8c7a9561385a8e8ff0c53e0 (patch) | |
tree | 4f68d03a384b1cde118e6478644bb9e14b4ab201 /sys | |
parent | 80e27851f2afb65a95c749d65636a67daacc2309 (diff) | |
download | FreeBSD-src-583fcf1070d55ddcf8c7a9561385a8e8ff0c53e0.zip FreeBSD-src-583fcf1070d55ddcf8c7a9561385a8e8ff0c53e0.tar.gz |
Move the pnp and location info into the common pci bus. Make all known
pci busses implement this.
Also minor comment smithing in cardbus. Fix copyright to this year
with my name on it since I've been doing a lot to this file.
Reviewed by: jhb
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/acpica/acpi_pci.c | 2 | ||||
-rw-r--r-- | sys/dev/cardbus/cardbus.c | 50 | ||||
-rw-r--r-- | sys/dev/pci/pci.c | 31 | ||||
-rw-r--r-- | sys/dev/pci/pci_private.h | 4 |
4 files changed, 41 insertions, 46 deletions
diff --git a/sys/dev/acpica/acpi_pci.c b/sys/dev/acpica/acpi_pci.c index 077f6be..2448b62 100644 --- a/sys/dev/acpica/acpi_pci.c +++ b/sys/dev/acpica/acpi_pci.c @@ -98,6 +98,8 @@ static device_method_t acpi_pci_methods[] = { DEVMETHOD(bus_release_resource, bus_generic_rl_release_resource), DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), + DEVMETHOD(bus_child_pnpinfo_str, pci_child_pnpinfo_str_method), + DEVMETHOD(bus_child_location_str, pci_child_location_str_method), /* PCI interface */ DEVMETHOD(pci_read_config, pci_read_config_method), diff --git a/sys/dev/cardbus/cardbus.c b/sys/dev/cardbus/cardbus.c index 2d265b6..eddfe61 100644 --- a/sys/dev/cardbus/cardbus.c +++ b/sys/dev/cardbus/cardbus.c @@ -1,6 +1,6 @@ /* - * Copyright (c) 2000,2001 Jonathan Chen. - * All rights reserved. + * Copyright (c) 2003 M. Warner Losh. All Rights Reserved. + * Copyright (c) 2000,2001 Jonathan Chen. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -28,15 +28,6 @@ * $FreeBSD$ */ -/* - * Cardbus Bus Driver - * - * much of the bus code was stolen directly from sys/pci/pci.c - * (Copyright (c) 1997, Stefan Esser <se@freebsd.org>) - * - * Written by Jonathan Chen <jon@freebsd.org> - */ - #include <sys/param.h> #include <sys/systm.h> #include <sys/malloc.h> @@ -85,10 +76,6 @@ static struct resource *cardbus_alloc_resource(device_t cbdev, device_t child, u_int flags); static int cardbus_attach(device_t cbdev); static int cardbus_attach_card(device_t cbdev); -static int cardbus_child_location_str(device_t cbdev, device_t child, - char *, size_t len); -static int cardbus_child_pnpinfo_str(device_t cbdev, device_t child, - char *, size_t len); static void cardbus_delete_resource(device_t cbdev, device_t child, int type, int rid); static void cardbus_delete_resource_method(device_t cbdev, device_t child, @@ -631,35 +618,6 @@ cardbus_teardown_intr(device_t cbdev, device_t child, struct resource *irq, /************************************************************************/ static int -cardbus_child_location_str(device_t cbdev, device_t child, char *buf, - size_t buflen) -{ - struct cardbus_devinfo *dinfo; - pcicfgregs *cfg; - - dinfo = device_get_ivars(child); - cfg = &dinfo->pci.cfg; - snprintf(buf, buflen, "slot=%d function=%d", pci_get_slot(child), - pci_get_function(child)); - return (0); -} - -static int -cardbus_child_pnpinfo_str(device_t cbdev, device_t child, char *buf, - size_t buflen) -{ - struct cardbus_devinfo *dinfo; - pcicfgregs *cfg; - - dinfo = device_get_ivars(child); - cfg = &dinfo->pci.cfg; - snprintf(buf, buflen, "vendor=0x%04x device=0x%04x subvendor=0x%04x " - "subdevice=0x%04x", cfg->vendor, cfg->device, cfg->subvendor, - cfg->subdevice); - return (0); -} - -static int cardbus_read_ivar(device_t cbdev, device_t child, int which, uintptr_t *result) { struct cardbus_devinfo *dinfo; @@ -717,8 +675,8 @@ static device_method_t cardbus_methods[] = { DEVMETHOD(bus_set_resource, cardbus_set_resource_method), DEVMETHOD(bus_get_resource, cardbus_get_resource_method), DEVMETHOD(bus_delete_resource, cardbus_delete_resource_method), - DEVMETHOD(bus_child_pnpinfo_str, cardbus_child_pnpinfo_str), - DEVMETHOD(bus_child_location_str, cardbus_child_location_str), + DEVMETHOD(bus_child_pnpinfo_str, pci_child_pnpinfo_str_method), + DEVMETHOD(bus_child_location_str, pci_child_location_str_method), /* Card Interface */ DEVMETHOD(card_attach_card, cardbus_attach_card), diff --git a/sys/dev/pci/pci.c b/sys/dev/pci/pci.c index ef9893f..39ab54c 100644 --- a/sys/dev/pci/pci.c +++ b/sys/dev/pci/pci.c @@ -107,6 +107,8 @@ static device_method_t pci_methods[] = { DEVMETHOD(bus_release_resource, bus_generic_rl_release_resource), DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), + DEVMETHOD(bus_child_pnpinfo_str, pci_child_pnpinfo_str_method), + DEVMETHOD(bus_child_location_str, pci_child_location_str_method), /* PCI interface */ DEVMETHOD(pci_read_config, pci_read_config_method), @@ -1390,6 +1392,35 @@ pci_write_config_method(device_t dev, device_t child, int reg, cfg->bus, cfg->slot, cfg->func, reg, val, width); } +int +pci_child_location_str_method(device_t cbdev, device_t child, char *buf, + size_t buflen) +{ + struct pci_devinfo *dinfo; + pcicfgregs *cfg; + + dinfo = device_get_ivars(child); + cfg = &dinfo->cfg; + snprintf(buf, buflen, "slot=%d function=%d", pci_get_slot(child), + pci_get_function(child)); + return (0); +} + +int +pci_child_pnpinfo_str_method(device_t cbdev, device_t child, char *buf, + size_t buflen) +{ + struct pci_devinfo *dinfo; + pcicfgregs *cfg; + + dinfo = device_get_ivars(child); + cfg = &dinfo->cfg; + snprintf(buf, buflen, "vendor=0x%04x device=0x%04x subvendor=0x%04x " + "subdevice=0x%04x", cfg->vendor, cfg->device, cfg->subvendor, + cfg->subdevice); + return (0); +} + static int pci_modevent(module_t mod, int what, void *arg) { diff --git a/sys/dev/pci/pci_private.h b/sys/dev/pci/pci_private.h index c01e416..1064997 100644 --- a/sys/dev/pci/pci_private.h +++ b/sys/dev/pci/pci_private.h @@ -68,4 +68,8 @@ struct pci_devinfo *pci_read_device(device_t pcib, int b, int s, int f, size_t size); void pci_print_verbose(struct pci_devinfo *dinfo); int pci_freecfg(struct pci_devinfo *dinfo); +int pci_child_location_str_method(device_t cbdev, device_t child, + char *buf, size_t buflen); +int pci_child_pnpinfo_str_method(device_t cbdev, device_t child, + char *buf, size_t buflen); #endif /* _PCI_PRIVATE_H_ */ |