5 enum pci_config_type __pci_cfg_type
;
7 static int type1_ok(void)
9 uint32_t oldcf8
, newcf8
;
11 /* Test for Configuration Method #1 */
13 /* Note: XFree86 writes ~0 and expects to read back 0x80fffffc. Linux
14 does this less severe test; go with Linux. */
17 outb(1, 0xcfb); /* For old Intel chipsets */
19 outl(0x80000000, 0xcf8);
24 return newcf8
== 0x80000000;
27 static int type2_ok(void)
29 uint8_t oldcf8
, oldcfa
;
32 /* Test for Configuration Method #2 */
34 /* CM#2 is hard to probe for, but let's do our best... */
37 outb(0, 0xcfb); /* For old Intel chipsets */
50 return cf8
== 0 && cfa
== 0;
53 int pci_set_config_type(enum pci_config_type type
)
55 static const com32sys_t ireg
= {
58 .eflags
.l
= EFLAGS_CF
,
62 if ( type
== PCI_CFG_AUTO
) {
65 /* Try to detect PCI BIOS */
66 __intcall(0x1a, &ireg
, &oreg
);
68 if ( !(oreg
.eflags
.l
& EFLAGS_CF
) &&
69 oreg
.eax
.b
[1] == 0 && oreg
.edx
.l
== 0x20494250 ) {
70 /* PCI BIOS present. Use direct access if we know how to do it. */
72 if ( (oreg
.eax
.b
[0] & 1) && type1_ok() )
74 else if ( (oreg
.eax
.b
[0] & 2) && type2_ok() )
77 type
= PCI_CFG_BIOS
; /* Use BIOS calls as fallback */
79 } else if ( type1_ok() ) {
81 } else if ( type2_ok() ) {
84 type
= PCI_CFG_NONE
; /* Badness... */
88 return (__pci_cfg_type
= type
);