PCIS_INT.CPP
上传用户:whzhdz
上传日期:2007-03-07
资源大小:6k
文件大小:1k
开发平台:

DOS

  1. #include <stdio.h>
  2. #include <conio.h>
  3. #include <dos.h>
  4. void main(void)
  5. {
  6.     int bus, device, func, regindex;
  7.     union REGS regs, outregs;
  8.     unsigned long lo, hi, ovalue;
  9.     unsigned long BaseAddr;
  10.     clrscr();
  11.     func = 0;
  12.     regindex = 0;
  13.     for(bus=0; bus<5; bus++)
  14.     {
  15. for(device=0; device<32; device++)
  16. {
  17.      regs.h.bh = bus;
  18.      regs.h.bl = (device<<3) | (func & 0x07);
  19.      regindex = 0;
  20.      regs.x.di = regindex;
  21.      regs.x.ax = 0xB109;
  22.      int86(0x1A,&regs,&outregs);
  23.      lo = outregs.x.cx;
  24.      regs.x.di = regindex + 2;
  25.      int86(0x1A,&regs,&outregs);
  26.      hi = outregs.x.cx;
  27.      ovalue = hi*65536l+lo;
  28.      if (lo != 0xffff)
  29.      {
  30.  printf("nBus = 0x%xn", bus);
  31.  printf("Device = 0x%xn", device);
  32.  printf("ID = %lxn", ovalue);
  33.  for(BaseAddr=0; BaseAddr<=5; BaseAddr++)
  34.  {
  35.      regindex = 0x10 + BaseAddr*4;
  36.      regs.x.di = regindex;
  37.      int86(0x1A,&regs,&outregs);
  38.      lo = outregs.x.cx;
  39.      regs.x.di = regindex + 2;
  40.      int86(0x1A,&regs,&outregs);
  41.      hi = outregs.x.cx;
  42.      ovalue = hi*65536l+lo;
  43.      printf("Base%d: Low = 0x%xtHi = 0x%xn", BaseAddr, lo, hi);
  44.  }
  45.  regindex = 0x3c;
  46.  regs.x.di = regindex;
  47.  int86(0x1A,&regs,&outregs);
  48.  lo = outregs.x.cx;
  49.  printf("IRQ# = %dn", lo & 0xff);
  50.  getch();
  51.      }
  52. }
  53.     }
  54. }