Move xf86FindPciDeviceVendor and xf86FindPciClass from xf86pciBus.c to
xf86int10.c. Refactor common code from those functions to do_find.
This commit is contained in:
parent
de8234606f
commit
a0f2e1cae4
|
@ -151,10 +151,6 @@ memType xf86ChkConflict(resRange *rgp, int entityIndex);
|
|||
ScrnInfoPtr xf86FindScreenForEntity(int entityIndex);
|
||||
Bool xf86NoSharedResources(int screenIndex, resType res);
|
||||
resPtr xf86FindIntersectOfLists(resPtr l1, resPtr l2);
|
||||
struct pci_device * xf86FindPciDeviceVendor(CARD16 vendorID, CARD16 deviceID,
|
||||
char n, const struct pci_device * pvp_exclude);
|
||||
struct pci_device * xf86FindPciClass(CARD8 intf, CARD8 subClass, CARD16 class,
|
||||
char n, const struct pci_device * pvp_exclude);
|
||||
void xf86RegisterStateChangeNotificationCallback(xf86StateChangeNotificationCallbackFunc func, pointer arg);
|
||||
Bool xf86DeregisterStateChangeNotificationCallback(xf86StateChangeNotificationCallbackFunc func);
|
||||
|
||||
|
|
|
@ -1030,72 +1030,6 @@ xf86CheckPciSlot( const struct pci_device * d )
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* xf86FindPciVendorDevice() xf86FindPciClass(): These functions
|
||||
* are meant to be used by the pci bios emulation. Some bioses
|
||||
* need to see if there are _other_ chips of the same type around
|
||||
* so by setting pvp_exclude one pci device can be explicitely
|
||||
* _excluded if required.
|
||||
*/
|
||||
_X_EXPORT struct pci_device *
|
||||
xf86FindPciDeviceVendor(CARD16 vendorID, CARD16 deviceID,
|
||||
char n, const struct pci_device * exclude)
|
||||
{
|
||||
struct pci_device *dev;
|
||||
struct pci_id_match m;
|
||||
struct pci_device_iterator *iter;
|
||||
|
||||
m.vendor_id = vendorID;
|
||||
m.device_id = deviceID;
|
||||
m.subvendor_id = PCI_MATCH_ANY;
|
||||
m.subdevice_id = PCI_MATCH_ANY;
|
||||
m.device_class = 0;
|
||||
m.device_class_mask = 0;
|
||||
|
||||
n++;
|
||||
|
||||
iter = pci_id_match_iterator_create(& m);
|
||||
while ((dev = pci_device_next(iter)) != NULL) {
|
||||
if ((dev != exclude) && !(--n)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
pci_iterator_destroy(iter);
|
||||
|
||||
return dev;
|
||||
}
|
||||
|
||||
_X_EXPORT struct pci_device *
|
||||
xf86FindPciClass(CARD8 intf, CARD8 subClass, CARD16 _class,
|
||||
char n, const struct pci_device * exclude)
|
||||
{
|
||||
struct pci_device *dev;
|
||||
struct pci_id_match m;
|
||||
struct pci_device_iterator *iter;
|
||||
|
||||
m.vendor_id = PCI_MATCH_ANY;
|
||||
m.device_id = PCI_MATCH_ANY;
|
||||
m.subvendor_id = PCI_MATCH_ANY;
|
||||
m.subdevice_id = PCI_MATCH_ANY;
|
||||
m.device_class = (((uint32_t)_class) << 16)
|
||||
| (((uint32_t)subClass) << 8) | intf;
|
||||
m.device_class_mask = 0x00ffffff;
|
||||
|
||||
n++;
|
||||
|
||||
iter = pci_id_match_iterator_create(& m);
|
||||
while ((dev = pci_device_next(iter)) != NULL) {
|
||||
if ((dev != exclude) && !(--n)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
pci_iterator_destroy(iter);
|
||||
|
||||
return dev;
|
||||
}
|
||||
|
||||
static void
|
||||
pciTagConvertRange2Host(PCITAG tag, resRange *pRange)
|
||||
{
|
||||
|
|
|
@ -593,12 +593,68 @@ int42_handler(xf86Int10InfoPtr pInt)
|
|||
#define DEVICE_NOT_FOUND 0x86
|
||||
#define BAD_REGISTER_NUMBER 0x87
|
||||
|
||||
#ifdef SHOW_ALL_DEVICES
|
||||
/**
|
||||
* \todo
|
||||
* Eliminate the reliance on \c xf86FindPciDeviceVendor and
|
||||
* \c xf86FindPciDeviceClass in this function. Create new functions in this
|
||||
* file that directly use libpciaccess to replace them.
|
||||
* These functions are meant to be used by the PCI BIOS emulation. Some
|
||||
* BIOSes need to see if there are \b other chips of the same type around so
|
||||
* by setting \c exclude one PCI device can be explicitely excluded, if
|
||||
* required.
|
||||
*/
|
||||
static struct pci_device *
|
||||
do_find(const struct pci_id_match *m, char n, const struct pci_device * exclude)
|
||||
{
|
||||
struct pci_device *dev;
|
||||
struct pci_device_iterator *iter;
|
||||
|
||||
n++;
|
||||
|
||||
iter = pci_id_match_iterator_create(m);
|
||||
while ((dev = pci_device_next(iter)) != NULL) {
|
||||
if ((dev != exclude) && !(--n)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
pci_iterator_destroy(iter);
|
||||
|
||||
return dev;
|
||||
}
|
||||
|
||||
|
||||
static struct pci_device *
|
||||
find_pci_device_vendor(CARD16 vendorID, CARD16 deviceID,
|
||||
char n, const struct pci_device * exclude)
|
||||
{
|
||||
struct pci_id_match m;
|
||||
|
||||
m.vendor_id = vendorID;
|
||||
m.device_id = deviceID;
|
||||
m.subvendor_id = PCI_MATCH_ANY;
|
||||
m.subdevice_id = PCI_MATCH_ANY;
|
||||
m.device_class = 0;
|
||||
m.device_class_mask = 0;
|
||||
|
||||
return do_find(& m, n, exclude);
|
||||
}
|
||||
|
||||
static struct pci_device *
|
||||
find_pci_class(CARD8 intf, CARD8 subClass, CARD16 _class,
|
||||
char n, const struct pci_device * exclude)
|
||||
{
|
||||
struct pci_id_match m;
|
||||
|
||||
m.vendor_id = PCI_MATCH_ANY;
|
||||
m.device_id = PCI_MATCH_ANY;
|
||||
m.subvendor_id = PCI_MATCH_ANY;
|
||||
m.subdevice_id = PCI_MATCH_ANY;
|
||||
m.device_class = (((uint32_t)_class) << 16)
|
||||
| (((uint32_t)subClass) << 8) | intf;
|
||||
m.device_class_mask = 0x00ffffff;
|
||||
|
||||
return do_find(& m, n, exclude);
|
||||
}
|
||||
#endif
|
||||
|
||||
static int
|
||||
int1A_handler(xf86Int10InfoPtr pInt)
|
||||
{
|
||||
|
@ -635,7 +691,7 @@ int1A_handler(xf86Int10InfoPtr pInt)
|
|||
}
|
||||
#ifdef SHOW_ALL_DEVICES
|
||||
else
|
||||
if ((dev = xf86FindPciDeviceVendor(X86_EDX, X86_ECX, X86_ESI, pvp))) {
|
||||
if ((dev = find_pci_device_vendor(X86_EDX, X86_ECX, X86_ESI, pvp))) {
|
||||
X86_EAX = X86_AL | (SUCCESSFUL << 8);
|
||||
X86_EFLAGS &= ~((unsigned long)0x01); /* clear carry flag */
|
||||
X86_EBX = pciSlotBX(dev);
|
||||
|
@ -656,10 +712,10 @@ int1A_handler(xf86Int10InfoPtr pInt)
|
|||
X86_EFLAGS &= ~((unsigned long)0x01); /* clear carry flag */
|
||||
}
|
||||
#ifdef SHOW_ALL_DEVICES
|
||||
else if ((dev = xf86FindPciClass(X86_CL, X86_CH,
|
||||
(X86_ECX & 0xffff0000) >> 16,
|
||||
X86_ESI, pvp))) {
|
||||
p X86_EAX = X86_AL | (SUCCESSFUL << 8);
|
||||
else if ((dev = find_pci_class(X86_CL, X86_CH,
|
||||
(X86_ECX & 0xffff0000) >> 16,
|
||||
X86_ESI, pvp))) {
|
||||
X86_EAX = X86_AL | (SUCCESSFUL << 8);
|
||||
X86_EFLAGS &= ~((unsigned long)0x01); /* clear carry flag */
|
||||
X86_EBX = pciSlotBX(dev);
|
||||
}
|
||||
|
|
|
@ -339,8 +339,6 @@ _X_HIDDEN void *xfree86LookupTab[] = {
|
|||
SYMFUNC(xf86GetSparse)
|
||||
SYMFUNC(xf86ChkConflict)
|
||||
SYMFUNC(xf86FindScreenForEntity)
|
||||
SYMFUNC(xf86FindPciDeviceVendor)
|
||||
SYMFUNC(xf86FindPciClass)
|
||||
SYMFUNC(xf86RegisterStateChangeNotificationCallback)
|
||||
SYMFUNC(xf86DeregisterStateChangeNotificationCallback)
|
||||
SYMFUNC(xf86NoSharedResources)
|
||||
|
|
Loading…
Reference in New Issue