require '_h2ph_pre.ph';

no warnings 'redefine';

unless(defined(&_DEV_PCI_PCIVAR_H_)) {
    eval 'sub _DEV_PCI_PCIVAR_H_ () {1;}' unless defined(&_DEV_PCI_PCIVAR_H_);
    require 'sys/device.ph';
    require 'machine/bus.ph';
    require 'dev/pci/pcireg.ph';
    eval 'sub PCI_PWR_D0 () {0;}' unless defined(&PCI_PWR_D0);
    eval 'sub PCI_PWR_D1 () {1;}' unless defined(&PCI_PWR_D1);
    eval 'sub PCI_PWR_D2 () {2;}' unless defined(&PCI_PWR_D2);
    eval 'sub PCI_PWR_D3 () {3;}' unless defined(&PCI_PWR_D3);
    if(defined(&_KERNEL)) {
	if(defined( &__alpha__)) {
	    require 'alpha/pci/pci_machdep.ph';
	}
 elsif(defined( &__i386__)) {
	    require 'i386/pci/pci_machdep.ph';
	}
 elsif(defined( &__cats__)) {
	    require 'cats/pci/pci_machdep.ph';
	}
 elsif(defined( &__powerpc__)) {
	    require 'powerpc/pci/pci_machdep.ph';
	}
 elsif(defined( &__sgi__)) {
	    require 'sgi/pci/pci_machdep.ph';
	} else {
	    require 'machine/pci_machdep.ph';
	}
	eval 'sub PCI_FLAGS_IO_ENABLED () {0x1;}' unless defined(&PCI_FLAGS_IO_ENABLED);
	eval 'sub PCI_FLAGS_MEM_ENABLED () {0x2;}' unless defined(&PCI_FLAGS_MEM_ENABLED);
	eval 'sub PCI_FLAGS_MRL_OKAY () {0x4;}' unless defined(&PCI_FLAGS_MRL_OKAY);
	eval 'sub PCI_FLAGS_MRM_OKAY () {0x8;}' unless defined(&PCI_FLAGS_MRM_OKAY);
	eval 'sub PCI_FLAGS_MWI_OKAY () {0x10;}' unless defined(&PCI_FLAGS_MWI_OKAY);
	eval 'sub PCI_QUIRK_MULTIFUNCTION () {1;}' unless defined(&PCI_QUIRK_MULTIFUNCTION);
	eval 'sub PCI_QUIRK_MONOFUNCTION () {2;}' unless defined(&PCI_QUIRK_MONOFUNCTION);
	eval 'sub pcibuscf_bus () { $cf_loc[0];}' unless defined(&pcibuscf_bus);
	eval 'sub PCIBUS_UNK_BUS () {-1;}' unless defined(&PCIBUS_UNK_BUS);
	eval 'sub pcicf_dev () { $cf_loc[0];}' unless defined(&pcicf_dev);
	eval 'sub PCI_UNK_DEV () {-1;}' unless defined(&PCI_UNK_DEV);
	eval 'sub pcicf_function () { $cf_loc[1];}' unless defined(&pcicf_function);
	eval 'sub PCI_UNK_FUNCTION () {-1;}' unless defined(&PCI_UNK_FUNCTION);
    }
}
1;
