/*---Tiger 320 chip chagne 2004/9/13---*/ #include "Pio.H" WORD SubDeviceID, SubAuxID,SubVendorID, SubVendorID_320; DWORD SearchID; /* -------------------------------------------------------------------- */ float PIO_FloatSub2(float fA, float fB) { return(fA-fB); } short PIO_ShortSub2(short nA, short nB) { return(nA-nB); } WORD PIO_GetDriverVersion(WORD *wDriverVersion) { *wDriverVersion=0x220; return( NoError ); } /*--------------------------------------------------------------------*/ /* Veddor Device Sub-vendor Sub-device Sub-aux Tiger PIO_D144 E159 0002 80 01 00 100 PIO_D96 E159 0002 80 01 10 100 PIO_D64 E159 0002 80 01 20 100 PIO_D48 E159 0002 80 01 30 100 PIO_D24 E159 0002 80 01 40 100 PIO_D56 E159 0002 80 01 40 100 PIO-D168 E159 0001 d880 01 50 320 PIO_D144 E159 0001 5c80 01 00 320 PIO_D96 E159 0001 5880 01 10 320 PIO_D64 E159 0001 4080 01 20 320 PIO_D48 E159 0001 4080 01 30 320 PIO_D24 E159 0001 c080 01 40 320 PIO_D56 E159 0001 c080 01 40 320 PIO-DA4/8/16 E159 0002 80 04 00 100 PISO-C64 E159 0002 80 08 00 100 PISO-P64 E159 0002 80 08 10 100 PISO-A64 E159 0002 80 08 50 100 PISO-DA2 E159 0002 80 0B 00 100 PISO-813 E159 0002 80 0A 00 100 PISO-725 E159 0002 80 0C 00 100 PISO-P8SSR8AC E159 0002 80 08 30 100 PISO-P8SSR9DC E159 0002 80 08 30 100 PISO-P8R8 E159 0002 80 08 30 100 PIO-DA4/8/16 E159 0001 0x4180 0x00 0x00 320 PISO-DA2 E159 0001 0x4280 0x03 0x00 320 PISO-C64 E159 0001 0x0280 0x00 0x00 320 PISO-P64 E159 0001 0x0280 0x00 0x01 320 PISO-A64 E159 0001 0x8280 0x00 0x05 320 PISO-813 E159 0001 0x4280 0x02 0x00 320 PISO-725 E159 0001 0x0380 0x00 0x00 320 PISO-P8SSR8AC E159 0001 0x4200 0x00 0x30 320 PISO-P8SSR9DC E159 0001 0x4200 0x00 0x30 320 PISO-P8R8 E159 0001 0x4200 0x00 0x30 320 PISO-P32C32 E159 0002 80 08 20 100 PISO-P32A32 E159 0002 80 08 70 100 PISO-730 E159 0002 80 08 40 100 PISO-730A E159 0002 80 08 80 100 PISO-P32C32 E159 0001 0280 00 20 320 PISO-P32A32 E159 0001 8280 00 70 320 PISO-730 E159 0001 c2ff 00 40 320 PISO-730A E159 0001 62ff 00 80 320 VXC-142 E159 0001 61 00 00 320 VXC-142i E159 0001 161 02 00 320 VXC-182i E159 0001 161 01 00 320 --------------------------------------------------------------------*/ WORD PIO_DriverInit(WORD *wBoards, WORD wSubVendorID, WORD wSubDeviceID ,WORD wSubAuxID) { WORD wReturnCode; SubVendorID=wSubVendorID & 0x1fff; SubDeviceID=wSubDeviceID ; SubAuxID =wSubAuxID; SearchID =(SubVendorID << 16) + (SubDeviceID << 8) + SubAuxID; printf("SubVendorID=%x, SubDeviceID=%x ,SubAux=%x",SubVendorID,SubDeviceID,SubAuxID); printf("SearchID=%lx\n",SearchID); if (SearchID != 0xffffff) { if (GetSubVendorID_320() != 0) SubVendorID_320= GetSubVendorID_320(); else { printf("\nNot found ID=0x%lx card inside\n",SearchID); return (*wBoards=0); } } wReturnCode=GetAddress(); if ( wReturnCode ) { *wBoards=0; return( wReturnCode ); } *wBoards=wTotalBoards; return( wReturnCode ); } /* -------------------------------------------------------------------- */ WORD PIO_DriverClose(void) { return( NoError ); } /* -------------------------------------------------------------------- */ WORD PIO_GetConfigAddressSpace(WORD wBoardNo, WORD *wBaseAddr, WORD *wIrq, WORD *wSubVendor, WORD *wSubDevice, WORD *wSubAux, WORD *wSlotBus, WORD *wSlotDevice) { WORD wIndex; if (wGetAddress==0) { if (GetAddress()!=0) return(FindBoardError); } if ( wBoardNo>=wTotalBoards ) return ExceedBoardNumber; wIndex=wBoardNo; /* [0][1] --> system resource allocated */ *wBaseAddr = wConfigSpace[wIndex][0]; *wIrq = wConfigSpace[wIndex][1]; /* [2][3][4] --> subID to identify PIO/PISO cards */ *wSubVendor = wConfigSpace[wIndex][2]; *wSubDevice = wConfigSpace[wIndex][3]; *wSubAux = wConfigSpace[wIndex][4]; /* [5][6] --> SlotID to identify the slot position of this PIO/PISO card */ *wSlotBus = wConfigSpace[wIndex][5]; *wSlotDevice= wConfigSpace[wIndex][6]; return(NoError); } /* -------------------------------------------------------------------- */ /* [0][1] --> system resource allocated wConfigSpace[][0]= wBase wConfigSpace[][1]= wIrq [2][3][4] --> subID to identify PIO/PISO cards wConfigSpace[][2]= wSubVendorID wConfigSpace[][3]= wSubDeviceID wConfigSpace[][4]= wSubAuxID [5][6] --> SlotID to identify the slot position of this PIO/PISO card wConfigSpace[][5]= wSlotBus wConfigSpace[][6]= wSlotDevice */ //---------------------------------------------------------------------- WORD GetSubVendorID_320() { int i; for (i=0 ; i< TotalRecords ; i++ ) { if (SearchID != piso[i].SearchID) //not this card continue; return piso[i].SubVendorID_320; } return 0; } //------------------------------------------------------------------------ WORD GetAddress(void) { DWORD dConfigAddress,dBaseAddress,dwVal; WORD HiWord,LoWord,wVal; WORD ReturnCode,ww; UCHAR Bus,Device,Function,WhichLong; WORD sub_vendor,sub_device,sub_aux; WORD vendor_id,device_id; WORD wIrqNumber,i,j,k,and_val; wTotalBoards=0; /* initial board number is 0 */ Bus=0; for (Bus=0; Bus<32; Bus++) /* max 32 PCI-SLOT */ { Function=0; WhichLong=1; for(Device=0; Device<32; Device++) { WhichLong=0; WriteAddress(Bus,Device,Function,WhichLong); vendor_id=inport(0xcfc); device_id=inport(0xcfe); WhichLong=0x0b; WriteAddress(Bus,Device,Function,WhichLong); sub_vendor=inport(0xcfc); sub_device=inport(0xcfe); sub_vendor &= 0x1fff; // if (device_id!=0xffff) // { // printf("vendor_id=%x, device_id=%x\n",vendor_id,device_id); // printf("sub_vendor=%x, sub_device=%x\n",sub_vendor,sub_device); // } if((sub_vendor==0x61) && (sub_device==0x00)) { and_val=0; /* VXC-142 */ } if((sub_vendor==0x161) && ((sub_device==0x01)||(sub_device==0x02))) { and_val=0; /* VXC-142I,182i family */ } else and_val=0xf0; /* other family */ if ((SubVendorID==0xff) && (SubDeviceID==0xff) && (SubAuxID==0xff)) /* don't card sub_vendor, sub_device, sub_aux */ { if ((vendor_id==0xe159 && device_id==1)||(vendor_id==0xe159 && device_id==2)) { WhichLong=4; WriteAddress(Bus,Device,Function,WhichLong); wVal=(inport(0xcfc))&0xfffe; /*wBase */ outportb(wVal+2,0); sub_aux=(inport(wVal+0x07)) & and_val; WhichLong=15; /* interrupt channel */ WriteAddress(Bus,Device,Function,WhichLong); wVal=(inport(0xcfc))&0xff; wConfigSpace[wTotalBoards][1]=wVal; /* wIrq */ wConfigSpace[wTotalBoards][2]=sub_vendor; /* sub_VENDOR_ID */ wConfigSpace[wTotalBoards][3]=sub_device; /* sub_DEVICE_ID */ wConfigSpace[wTotalBoards][4]=sub_aux; /* sub_AUX_ID */ wConfigSpace[wTotalBoards][5]=Bus; /* SlotBusID */ wConfigSpace[wTotalBoards][6]=Device; /* SlotDeviceID */ wTotalBoards++; /* increment board number */ if (wTotalBoards >16) return ExceedBoardNumber; wGetAddress=1; } } else if ( vendor_id!=0xe159 ) { continue; } else if (((device_id==2) && (sub_vendor==0x80)&& (sub_device==SubDeviceID ))|| ((device_id==1) && (sub_vendor==SubVendorID_320)&&(sub_device==(SubDeviceID&0x03)))) { WhichLong=4; WriteAddress(Bus,Device,Function,WhichLong); wVal=(inport(0xcfc))&0xfffe; /*wBase */ outportb(wVal+2,0); sub_aux=(inport(wVal+0x07)) & and_val; if ((SubAuxID==0xff) || (sub_aux==SubAuxID)) { wConfigSpace[wTotalBoards][0]=wVal; /* wBase */ WhichLong=15; /* interrupt channel */ WriteAddress(Bus,Device,Function,WhichLong); wVal=(inport(0xcfc))&0xff; wConfigSpace[wTotalBoards][1]=wVal&0xff; /* wIrq */ wConfigSpace[wTotalBoards][2]=sub_vendor; /* sub_VENDOR_ID */ wConfigSpace[wTotalBoards][3]=sub_device; /* sub_DEVICE_ID */ wConfigSpace[wTotalBoards][4]=sub_aux; /* sub_AUX_ID */ wConfigSpace[wTotalBoards][5]=Bus; /* SlotBusID */ wConfigSpace[wTotalBoards][6]=Device; /* SlotDeviceID */ wTotalBoards++; /* increment board number */ if (wTotalBoards >16) return ExceedBoardNumber; wGetAddress=1; } } } } return( NoError ); } void WriteAddress(UCHAR bBus, UCHAR bDevice, UCHAR bFunction, UCHAR bWhichLong) { DWORD dOutData; WORD HiWord,LoWord; UCHAR HiByte,LoByte; HiWord=0x8000|bBus; HiByte=(bDevice<<3)|bFunction; LoByte=(bWhichLong<<2) & 0xfc; LoWord=( (WORD)HiByte<<8 )|LoByte; dOutData=( (DWORD)HiWord<<16 ) | LoWord; _outpd(0xcf8,dOutData); } /* -------------------------------------------------------------------- */ WORD ShowPioPiso(DWORD wSubVendorID, WORD wSubDevice, WORD wSubAux) { int i; for (i=0 ; i< TotalRecords ; i++ ) { if (SearchID != piso[i].SearchID) //not this card continue; printf("%15c\n",piso[i].name); return 0; } return 1; }