Simple program for detecting the PCI Bus.
Here is the program: (Running QNX 4.25H)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <conio.h>
#include <sys/pci.h>
int main (int argc, char ** argv)
{
unsigned num_buses, version, hardware;
int err, pci_installed;
err = _CA_PCI_BIOS_Present (&num_buses, &version, &hardware );
pci_installed = err ? 0 : 1;
if (pci_installed)
{
printf (“Number of buses = %d, Version = %d, Hardware = %d \n”,
num_buses, version, hardware);
}
else
{
printf (“PCI Bus is not present. \n”);
}
return 0;
}
Running the program produces the following
(The program produced no printed output from the printf 's.):
test terminated (SIGSEV) at 0007:0000A179.
%1 Memory fault ./test
Behind the scenes, _CA_PCI_BIOS_Present (…)
performs something like:
{
int pci_installed, last_bus;
union REGS r;
memset (&r, 0, sizeof (r));
r.w.ax = 0xB101; // function number to check for PCI BIOS
int386 (0x1A, &r, &r);
pci_installed = r.h.ah;
last_bus = r.h.cl;
}
…And in a similar fashion, the interrupt function call int386
causes a SIGSEGV.
It should not crash the program, whether a PCI BIOS is detected or not.
Any ideas why this is happening?
-GF