/*
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2, or (at
* your option) any later version.
*/
#include "grub.h"
#include "pci.h"
unsigned long virt_offset = 0;
{
return ((unsigned long)virt_addr) + virt_offset;
}
{
return (void *)(phys_addr - virt_offset);
}
#ifdef INCLUDE_3C595
extern struct pci_driver t595_driver;
#endif /* INCLUDE_3C595 */
#ifdef INCLUDE_3C90X
extern struct pci_driver a3c90x_driver;
#endif /* INCLUDE_3C90X */
#ifdef INCLUDE_DAVICOM
extern struct pci_driver davicom_driver;
#endif /* INCLUDE_DAVICOM */
#ifdef INCLUDE_E1000
extern struct pci_driver e1000_driver;
#endif /* INCLUDE_E1000 */
#ifdef INCLUDE_EEPRO100
extern struct pci_driver eepro100_driver;
#endif /* INCLUDE_EEPRO100 */
#ifdef INCLUDE_EPIC100
extern struct pci_driver epic100_driver;
#endif /* INCLUDE_EPIC100 */
#ifdef INCLUDE_FORCEDETH
extern struct pci_driver forcedeth_driver;
#endif /* INCLUDE_FORCEDETH */
#ifdef INCLUDE_NATSEMI
extern struct pci_driver natsemi_driver;
#endif /* INCLUDE_NATSEMI */
#ifdef INCLUDE_NS83820
extern struct pci_driver ns83820_driver;
#endif /* INCLUDE_NS83820 */
#ifdef INCLUDE_NS8390
extern struct pci_driver nepci_driver;
#endif /* INCLUDE_NS8390 */
#ifdef INCLUDE_PCNET32
extern struct pci_driver pcnet32_driver;
#endif /* INCLUDE_PCNET32 */
#ifdef INCLUDE_PNIC
extern struct pci_driver pnic_driver;
#endif /* INCLUDE_PNIC */
#ifdef INCLUDE_RTL8139
extern struct pci_driver rtl8139_driver;
#endif /* INCLUDE_RTL8139 */
#ifdef INCLUDE_SIS900
extern struct pci_driver sis900_driver;
extern struct pci_driver sis_bridge_driver;
#endif /* INCLUDE_SIS900 */
#ifdef INCLUDE_SUNDANCE
extern struct pci_driver sundance_driver;
#endif /* INCLUDE_SUNDANCE */
#ifdef INCLUDE_TG3
extern struct pci_driver tg3_driver;
#endif /* INCLUDE_TG3 */
#ifdef INCLUDE_TLAN
extern struct pci_driver tlan_driver;
#endif /* INCLUDE_TLAN */
#ifdef INCLUDE_TULIP
extern struct pci_driver tulip_driver;
#endif /* INCLUDE_TULIP */
#ifdef INCLUDE_UNDI
extern struct pci_driver undi_driver;
#endif /* INCLUDE_UNDI */
#ifdef INCLUDE_VIA_RHINE
extern struct pci_driver rhine_driver;
#endif/* INCLUDE_VIA_RHINE */
#ifdef INCLUDE_W89C840
extern struct pci_driver w89c840_driver;
#endif /* INCLUDE_W89C840 */
#ifdef INCLUDE_R8169
extern struct pci_driver r8169_driver;
#endif /* INCLUDE_R8169 */
#ifdef INCLUDE_3C595
#endif /* INCLUDE_3C595 */
#ifdef INCLUDE_3C90X
#endif /* INCLUDE_3C90X */
#ifdef INCLUDE_DAVICOM
#endif /* INCLUDE_DAVICOM */
#ifdef INCLUDE_E1000
#endif /* INCLUDE_E1000 */
#ifdef INCLUDE_EEPRO100
#endif /* INCLUDE_EEPRO100 */
#ifdef INCLUDE_EPIC100
#endif /* INCLUDE_EPIC100 */
#ifdef INCLUDE_FORCEDETH
#endif /* INCLUDE_FORCEDETH */
#ifdef INCLUDE_NATSEMI
#endif /* INCLUDE_NATSEMI */
#ifdef INCLUDE_NS83820
#endif /* INCLUDE_NS83820 */
#ifdef INCLUDE_NS8390
#endif /* INCLUDE_NS8390 */
#ifdef INCLUDE_PCNET32
#endif /* INCLUDE_PCNET32 */
#ifdef INCLUDE_PNIC
#endif /* INCLUDE_PNIC */
#ifdef INCLUDE_RTL8139
#endif /* INCLUDE_RTL8139 */
#ifdef INCLUDE_SIS900
#endif /* INCLUDE_SIS900 */
#ifdef INCLUDE_SUNDANCE
#endif /* INCLUDE_SUNDANCE */
#ifdef INCLUDE_TG3
& tg3_driver,
#endif /* INCLUDE_TG3 */
#ifdef INCLUDE_TLAN
#endif /* INCLUDE_TLAN */
#ifdef INCLUDE_TULIP
& tulip_driver,
#endif /* INCLUDE_TULIP */
#ifdef INCLUDE_VIA_RHINE
#endif/* INCLUDE_VIA_RHINE */
#ifdef INCLUDE_W89C840
#endif /* INCLUDE_W89C840 */
#ifdef INCLUDE_R8169
#endif /* INCLUDE_R8169 */
/* We must be the last one */
#ifdef INCLUDE_UNDI
#endif /* INCLUDE_UNDI */
0
};
static void scan_drivers(
int type,
{
/* Assume there is only one match of the correct type */
int i, j;
for(j = 0; pci_drivers[j] != 0; j++){
driver = pci_drivers[j];
continue;
if (skip_driver) {
if (skip_driver == driver)
skip_driver = 0;
continue;
}
goto out;
}
}
}
if (!class) {
goto out;
}
for(j = 0; pci_drivers[j] != 0; j++){
driver = pci_drivers[j];
continue;
if (skip_driver) {
if (skip_driver == driver)
skip_driver = 0;
continue;
}
if (last_driver == driver)
continue;
goto out;
}
}
out:
return;
}
{
unsigned char hdr_type = 0;
int reg;
EnterFunction("scan_pci_bus");
first_bus = 0;
first_devfn = 0;
first_driver = 0;
/* Re read the header type on a restart */
}
/* Scan all PCI buses, until we find our card.
* We could be smart only scan the required buses but that
* is error prone, and tricky.
* By scanning all possible pci buses in order we should find
* our card eventually.
*/
buses=256;
continue;
/* some broken boards return 0 if a slot is empty: */
if (l == 0xffffffff || l == 0x00000000) {
continue;
}
vendor = l & 0xffff;
#if DEBUG
{
int i;
printf("%hhx:%hhx.%hhx [%hX/%hX] ---- ",
#if DEBUG > 1
for(i = 0; i < 256; i++) {
unsigned char byte;
if ((i & 0xf) == 0) {
printf("%hhx: ", i);
}
if ((i & 0xf) == 0xf) {
printf("\n");
}
}
#endif
}
#endif
#if DEBUG
printf("No driver fit.\n");
#endif
continue;
}
#if DEBUG
printf("Get Driver:\n");
#endif
/* Get the ROM base address */
romaddr >>= 10;
/* Get the ``membase'' */
/* Get the ``ioaddr'' */
continue;
/* Strip the I/O address out of the returned value */
/* Take the first one or the one that matches in boot ROM address */
}
#if DEBUG > 2
printf("Found %s ROM address %#hx\n",
#endif
LeaveFunction("scan_pci_bus");
return;
}
first_devfn = 0;
}
first_bus = 0;
LeaveFunction("scan_pci_bus");
}
/*
* Set device to be a busmaster in case BIOS neglected to do so.
* Also adjust PCI latency timer to a reasonable value, 32.
*/
{
unsigned char pci_latency;
if (pci_command != new_command) {
#if DEBUG > 0
"The PCI BIOS has not enabled this device!\n"
"Updating PCI command %hX->%hX. pci_bus %hhX pci_device_fn %hhX\n",
#endif
}
if (pci_latency < 32) {
#if DEBUG > 0
printf("PCI latency timer (CFLT) is unreasonably low at %d. Setting to 32 clocks.\n",
#endif
}
}
/*
* Find the start of a pci resource.
*/
{
unsigned long bar;
if (lo & PCI_BASE_ADDRESS_SPACE_IO) {
} else {
bar = 0;
if (hi) {
if (sizeof(unsigned long) > sizeof(uint32_t)) {
/* It's REALLY interesting:-) */
}
else {
printf("Unhandled 64bit BAR\n");
return -1UL;
}
}
}
}
}
/*
* Find the size of a pci resource.
*/
{
/* Save the original bar */
/* Compute which bits can be set */
/* Restore the original size */
/* Find the significant bits */
if (start & PCI_BASE_ADDRESS_SPACE_IO) {
} else {
}
/* Find the lowest bit set */
return size;
}
/**
* pci_find_capability - query for devices' capabilities
* @dev: PCI device to query
* @cap: capability code
*
* Tell if a device supports a given PCI capability.
* Returns the address of the requested capability structure within the
* device's PCI configuration space or 0 in case the device does not
* support it. Possible values for @cap:
*
* %PCI_CAP_ID_PM Power Management
*
* %PCI_CAP_ID_AGP Accelerated Graphics Port
*
* %PCI_CAP_ID_VPD Vital Product Data
*
* %PCI_CAP_ID_SLOTID Slot Identification
*
* %PCI_CAP_ID_MSI Message Signalled Interrupts
*
* %PCI_CAP_ID_CHSWP CompactPCI HotSwap
*/
{
if (!(status & PCI_STATUS_CAP_LIST))
return 0;
switch (hdr_type & 0x7F) {
case PCI_HEADER_TYPE_NORMAL:
case PCI_HEADER_TYPE_BRIDGE:
default:
break;
case PCI_HEADER_TYPE_CARDBUS:
break;
}
pos &= ~3;
#if DEBUG > 0
#endif
if (id == 0xff)
break;
return pos;
}
return 0;
}