mirror of
https://github.com/86Box/probing-tools.git
synced 2026-02-24 20:35:34 -07:00
pcireg: Fix mechanism 1/2 detection in QEMU and potentially other hardware
This commit is contained in:
41
clib/clib.c
41
clib/clib.c
@@ -329,20 +329,20 @@ int
|
||||
pci_init()
|
||||
{
|
||||
multi_t cf8;
|
||||
cf8.u32 = 0x80000000;
|
||||
cf8.u32 = 0x80001234;
|
||||
|
||||
/* Determine the supported PCI configuration mechanism. */
|
||||
cli();
|
||||
outb(0xcf8, 0x00);
|
||||
outb(0xcfa, 0x00);
|
||||
if ((inb(0xcf8) == 0x00) && (inb(0xcfa) == 0x00)) {
|
||||
pci_mechanism = 2;
|
||||
pci_device_count = 32;
|
||||
outl(0xcf8, cf8.u32);
|
||||
cf8.u32 = inl(0xcf8);
|
||||
if (cf8.u32 == 0x80001234) {
|
||||
pci_mechanism = 1;
|
||||
pci_device_count = 32;
|
||||
} else {
|
||||
outl(0xcf8, cf8.u32);
|
||||
cf8.u32 = inl(0xcf8);
|
||||
if (cf8.u32 == 0x80000000) {
|
||||
pci_mechanism = 1;
|
||||
outb(0xcf8, 0x00);
|
||||
outb(0xcfa, 0x00);
|
||||
if ((inb(0xcf8) == 0x00) && (inb(0xcfa) == 0x00)) {
|
||||
pci_mechanism = 2;
|
||||
pci_device_count = 16;
|
||||
}
|
||||
}
|
||||
@@ -531,24 +531,3 @@ pci_writel(uint8_t bus, uint8_t dev, uint8_t func, uint8_t reg, uint32_t val)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* File I/O functions. */
|
||||
void
|
||||
fseek_to(FILE *f, long offset)
|
||||
{
|
||||
fseek(f, offset, SEEK_SET);
|
||||
|
||||
#ifdef __POSIX_UEFI__
|
||||
/* Work around broken fseek implementation. */
|
||||
long pos = ftell(f);
|
||||
if (pos == offset)
|
||||
return;
|
||||
|
||||
uint8_t dummy[512];
|
||||
while (pos < offset) {
|
||||
fread(&dummy, MIN(sizeof(dummy), offset - pos), 1, f);
|
||||
pos = ftell(f);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -125,7 +125,4 @@ extern void pci_writeb(uint8_t bus, uint8_t dev, uint8_t func, uint8_t reg, uint
|
||||
extern void pci_writew(uint8_t bus, uint8_t dev, uint8_t func, uint8_t reg, uint16_t val);
|
||||
extern void pci_writel(uint8_t bus, uint8_t dev, uint8_t func, uint8_t reg, uint32_t val);
|
||||
|
||||
/* File I/O functions. */
|
||||
extern void fseek_to(FILE *f, long offset);
|
||||
|
||||
#endif
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user