/* * VESUVIUS.C - NS VESUVIUS PCI chipset routines. * * Notes: * Algorithms from NS VESUVIUS Data Sheet * */ #include "local.h" LOCAL_DATA PIRQINFOHEADER gpiihIRQInfoHeader=NULL; UCHAR ReadIndexRegisterByte(UCHAR bIndex) { UCHAR bOldIndex, bResult; bOldIndex=READ_PORT_UCHAR((PUCHAR)0x24); WRITE_PORT_UCHAR((PUCHAR)0x24, bIndex); bResult=READ_PORT_UCHAR((PUCHAR)0x26); WRITE_PORT_UCHAR((PUCHAR)0x24, bOldIndex); return(bResult); } VOID WriteIndexRegisterByte(UCHAR bIndex, UCHAR bValue) { UCHAR bOldIndex; bOldIndex=READ_PORT_UCHAR((PUCHAR)0x24); WRITE_PORT_UCHAR((PUCHAR)0x24, bIndex); WRITE_PORT_UCHAR((PUCHAR)0x26, bValue); WRITE_PORT_UCHAR((PUCHAR)0x24, bOldIndex); } /**************************************************************************** * * VESUVIUSSetIRQ - Set a VESUVIUS PCI link to a specific IRQ * * Exported. * * ENTRY: bIRQNumber is the new IRQ to be used. * * bLink is the Link to be set. * * EXIT: Standard PCIMP return value. * ***************************************************************************/ PCIMPRET CDECL VESUVIUSSetIRQ(UCHAR bIRQNumber, UCHAR bLink) { UCHAR bIndex, bOldValue; // // Validate link number. // if (bLink > 4) { return(PCIMP_INVALID_LINK); } // // Zero based. // bLink--; // // Set various values. // bIndex=(bLink/2)+0x10; // // Read the old VESUVIUS IRQ register. // bOldValue=ReadIndexRegisterByte(bIndex); if (bLink&1) { bOldValue&=0x0f; bOldValue|=(bIRQNumber<<4); } else { bOldValue&=0xf0; bOldValue|=bIRQNumber; } // // Set the VESUVIUS IRQ register. // WriteIndexRegisterByte(bIndex, bOldValue); return(PCIMP_SUCCESS); } /**************************************************************************** * * VESUVIUSGetIRQ - Get the IRQ of a VESUVIUS PCI link * * Exported. * * ENTRY: pbIRQNumber is the buffer to fill. * * bLink is the Link to be read. * * EXIT: Standard PCIMP return value. * ***************************************************************************/ PCIMPRET CDECL VESUVIUSGetIRQ(PUCHAR pbIRQNumber, UCHAR bLink) { UCHAR bIndex, bOldValue; // // Validate link number. // if (bLink > 4) { return(PCIMP_INVALID_LINK); } // // Zero based. // bLink--; // // Set various values. // bIndex=(bLink/2)+0x10; // // Read the old VESUVIUS IRQ register. // bOldValue=ReadIndexRegisterByte(bIndex); if (bLink&1) bOldValue>>=4; *pbIRQNumber=bOldValue&0x0f; return(PCIMP_SUCCESS); } /**************************************************************************** * * VESUVIUSSetTrigger - Set the IRQ triggering values for the VESUVIUS * * Exported. * * ENTRY: ulTrigger has bits set for Level triggered IRQs. * * EXIT: Standard PCIMP return value. * ***************************************************************************/ PCIMPRET CDECL VESUVIUSSetTrigger(ULONG ulTrigger) { ULONG i; UCHAR bMask; bMask=(UCHAR)(ReadIndexRegisterByte(0x12)&0x0f); for (i=0; i<4; i++) { UCHAR bIRQ=ReadIndexRegisterByte((UCHAR)((i/2)+0x10)); if (i&1) bIRQ>>=4; bIRQ&=0x0f; // // PCI interrupts go through L-E conversion. // if(bIRQ && (ulTrigger & (1<>=4; bIRQ&=0x0f; if (bIRQ) *pulTrigger|=(1<4) return(PCIMP_FAILURE); return(PCIMP_SUCCESS); }