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