#include #include #include "amcc.h" dword base_addr; byte di_p0; void main(void) { byte bus_num, dev_fun_num, reg_num, pci_register[64]; word ven_id, dev_id, index; unsigned long config_data[32], PLX_reg[16]; unsigned int dh, dl; int err_code, i, irqI; ven_id = 0x13fe; dev_id = 0x1750; index = 0; clrscr(); err_code = find_pci_device(dev_id, ven_id, index, &bus_num, &dev_fun_num); if ( !err_code ) printf("Find PCI-1750 at Bus No.= %d Device No.= %d Function No. = %d\n", bus_num,dev_fun_num>>3,dev_fun_num&0x07); else { printf("Can not find any PCI-1750 ! \n"); getch(); exit(0); } for ( i=0;i<16;i++ ) { err_code = read_configuration_dword(bus_num, dev_fun_num, i*4, &config_data[i]); printf("PCI control register %02X = %08lx\n",i*4,config_data[i]); } printf("\nPress any key to continue !"); getch(); clrscr(); err_code = read_configuration_dword(bus_num, dev_fun_num, PCI_CS_BASE_ADDRESS_2, &base_addr); if ( !err_code ) { if( base_addr & 0x01 ) { base_addr &= 0xfffffffc; printf("\nPCI-1750 I/O base_addr=%lx\n",base_addr); } else { base_addr &= 0xfffffff0; printf("\nPCI-1750 MEMORY base_addr=%lx\n",base_addr); } } else { printf("Can not find any PCI-1750!\n"); getch(); } //printf("\nPress any key to continue !"); //getch(); //clrscr(); /************************* Get interrupt No. ***********************/ err_code = read_configuration_byte(bus_num, dev_fun_num, PCI_CS_INTERRUPT_LINE,&irqI); if ( !err_code ) printf("\nInterrupt line No.=%d\n", irqI); printf("\nPress any key to continue !"); getch(); clrscr(); while(!kbhit()) { di_p0 = inportb(base_addr + 0); printf("\nDI=%d", di_p0); } getch(); }