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
This commit is contained in:
parent
fa4a502e77
commit
5794c59372
@ -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),
|
||||
|
@ -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,
|
||||
@ -630,35 +617,6 @@ cardbus_teardown_intr(device_t cbdev, device_t child, struct resource *irq,
|
||||
/* Other Bus Methods */
|
||||
/************************************************************************/
|
||||
|
||||
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)
|
||||
{
|
||||
@ -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),
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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_ */
|
||||
|
Loading…
Reference in New Issue
Block a user