
#include <dos.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "pci.c"

int
main ()
{
  unsigned int CardAddr[32];
  int CardAddrIndex;
  int i, j;
  unsigned pciaddr, addr, swid;

  for (i = 0; i < 32; i++)
    CardAddr[i] = 0;
  CardAddrIndex = 0;

  if (!IsPCIPresent ()) {
    printf ("No PCI interface.\n");
    return 1;
  }
  for (i = 0; i < PCICardInfoCount; i++) {
    for (j = 0; j < 8; j++) {
      pciaddr = FindPCIDevice2 (PCICardInfo[i].venderID, PCICardInfo[i].deviceID, j);
      if (pciaddr) {
	addr = ReadPCIConfigDWord (pciaddr, 0x1C) & 0xfffe;
	swid = inportb (addr + 1);
	printf ("Found: %s#%1d     I/O address: %04X SW1:%04X\n", PCICardInfo[i].name, j + 1, addr, swid);

	if (CardAddrIndex >= 32)
	  break;
	CardAddr[CardAddrIndex++] = pciaddr;
      }
      else
	break;
    }
  }
  if (CardAddrIndex == 0)
    printf("No PCI card found.\n");
  return 0;

}
