1 #include "pci/pci.h" 2 3 void BWL(pci_write)(TYPE v, pciaddr_t a) 4 { 5 for (;;) { 6 switch (__pci_cfg_type) { 7 case PCI_CFG_AUTO: 8 pci_set_config_type(PCI_CFG_AUTO); 9 break; /* Try again */ 10 11 case PCI_CFG_TYPE1: 12 { 13 uint32_t oldcf8; 14 cli(); 15 oldcf8 = inl(0xcf8); 16 outl(a, 0xcf8); 17 BWL(out) (v, 0xcfc + (a & 3)); 18 outl(oldcf8, 0xcf8); 19 sti(); 20 } 21 return; 22 23 case PCI_CFG_TYPE2: 24 { 25 uint8_t oldcf8, oldcfa; 26 27 if (a & (0x10 << 11)) 28 return; /* Devices 16-31 not supported */ 29 30 cli(); 31 oldcf8 = inb(0xcf8); 32 oldcfa = inb(0xcfa); 33 outb(0xf0 + ((a >> (8 - 1)) & 0x0e), 0xcf8); 34 outb(a >> 16, 0xcfa); 35 BWL(out) (v, 0xc000 + ((a >> (11 - 8)) & 0xf00) + (a & 0xff)); 36 outb(oldcf8, 0xcf8); 37 outb(oldcfa, 0xcfa); 38 sti(); 39 } 40 return; 41 42 case PCI_CFG_BIOS: 43 __pci_read_write_bios(BIOSCALL, v, a); 44 return; 45 46 default: 47 return; 48 } 49 } 50 } 51