📄 i2ellis.c
字号:
// sent (identity unknown...). Uses 16-bit (word) operations. Is called// indirectly through pB->i2eWriteBuf.////******************************************************************************static intiiWriteBuf16(i2eBordStrPtr pB, unsigned char *address, int count){ // Rudimentary sanity checking here. if (pB->i2eValid != I2E_MAGIC) COMPLETE(pB, I2EE_INVALID); OUTSW ( pB->i2eData, address, count); COMPLETE(pB, I2EE_GOOD);}//******************************************************************************// Function: iiWriteBuf8(pB, address, count)// Parameters: pB - pointer to board structure// address - address of data to write// count - number of data bytes to write//// Returns: True if everything appears copacetic.// False if there is any error: the pB->i2eError field has the error//// Description://// Writes 'count' bytes from 'address' to the data fifo specified by the board// structure pointer pB. Should count happen to be odd, an extra pad byte is// sent (identity unknown...). This is to be consistent with the 16-bit version.// Uses 8-bit (byte) operations. Is called indirectly through pB->i2eWriteBuf.////******************************************************************************static intiiWriteBuf8(i2eBordStrPtr pB, unsigned char *address, int count){ /* Rudimentary sanity checking here */ if (pB->i2eValid != I2E_MAGIC) COMPLETE(pB, I2EE_INVALID); OUTSB ( pB->i2eData, address, count ); COMPLETE(pB, I2EE_GOOD);}//******************************************************************************// Function: iiReadBuf16(pB, address, count)// Parameters: pB - pointer to board structure// address - address to put data read// count - number of data bytes to read//// Returns: True if everything appears copacetic.// False if there is any error: the pB->i2eError field has the error//// Description://// Reads 'count' bytes into 'address' from the data fifo specified by the board// structure pointer pB. Should count happen to be odd, an extra pad byte is// received (identity unknown...). Uses 16-bit (word) operations. Is called// indirectly through pB->i2eReadBuf.////******************************************************************************static intiiReadBuf16(i2eBordStrPtr pB, unsigned char *address, int count){ // Rudimentary sanity checking here. if (pB->i2eValid != I2E_MAGIC) COMPLETE(pB, I2EE_INVALID); INSW ( pB->i2eData, address, count); COMPLETE(pB, I2EE_GOOD);}//******************************************************************************// Function: iiReadBuf8(pB, address, count)// Parameters: pB - pointer to board structure// address - address to put data read// count - number of data bytes to read//// Returns: True if everything appears copacetic.// False if there is any error: the pB->i2eError field has the error//// Description://// Reads 'count' bytes into 'address' from the data fifo specified by the board// structure pointer pB. Should count happen to be odd, an extra pad byte is// received (identity unknown...). This to match the 16-bit behaviour. Uses// 8-bit (byte) operations. Is called indirectly through pB->i2eReadBuf.////******************************************************************************static intiiReadBuf8(i2eBordStrPtr pB, unsigned char *address, int count){ // Rudimentary sanity checking here. if (pB->i2eValid != I2E_MAGIC) COMPLETE(pB, I2EE_INVALID); INSB ( pB->i2eData, address, count); COMPLETE(pB, I2EE_GOOD);}//******************************************************************************// Function: iiReadWord16(pB)// Parameters: pB - pointer to board structure//// Returns: True if everything appears copacetic.// False if there is any error: the pB->i2eError field has the error//// Description://// Returns the word read from the data fifo specified by the board-structure// pointer pB. Uses a 16-bit operation. Is called indirectly through// pB->i2eReadWord.////******************************************************************************static unsigned shortiiReadWord16(i2eBordStrPtr pB){ return (unsigned short)( INW(pB->i2eData) );}//******************************************************************************// Function: iiReadWord8(pB)// Parameters: pB - pointer to board structure//// Returns: True if everything appears copacetic.// False if there is any error: the pB->i2eError field has the error//// Description://// Returns the word read from the data fifo specified by the board-structure// pointer pB. Uses two 8-bit operations. Bytes are assumed to be LSB first. Is// called indirectly through pB->i2eReadWord.////******************************************************************************static unsigned shortiiReadWord8(i2eBordStrPtr pB){ unsigned short urs; urs = INB ( pB->i2eData ); return ( ( INB ( pB->i2eData ) << 8 ) | urs );}//******************************************************************************// Function: iiWriteWord16(pB, value)// Parameters: pB - pointer to board structure// value - data to write//// Returns: True if everything appears copacetic.// False if there is any error: the pB->i2eError field has the error//// Description://// Writes the word 'value' to the data fifo specified by the board-structure// pointer pB. Uses 16-bit operation. Is called indirectly through// pB->i2eWriteWord.////******************************************************************************static voidiiWriteWord16(i2eBordStrPtr pB, unsigned short value){ WORD_TO(pB, (int)value);}//******************************************************************************// Function: iiWriteWord8(pB, value)// Parameters: pB - pointer to board structure// value - data to write//// Returns: True if everything appears copacetic.// False if there is any error: the pB->i2eError field has the error//// Description://// Writes the word 'value' to the data fifo specified by the board-structure// pointer pB. Uses two 8-bit operations (writes LSB first). Is called// indirectly through pB->i2eWriteWord.////******************************************************************************static voidiiWriteWord8(i2eBordStrPtr pB, unsigned short value){ BYTE_TO(pB, (char)value); BYTE_TO(pB, (char)(value >> 8) );}//******************************************************************************// Function: iiWaitForTxEmptyII(pB, mSdelay)// Parameters: pB - pointer to board structure// mSdelay - period to wait before returning//// Returns: True if the FIFO is empty.// False if it not empty in the required time: the pB->i2eError// field has the error.//// Description://// Waits up to "mSdelay" milliseconds for the outgoing FIFO to become empty; if// not empty by the required time, returns false and error in pB->i2eError,// otherwise returns true.//// mSdelay == 0 is taken to mean must be empty on the first test.//// This version operates on IntelliPort-II - style FIFO's//// Note this routine is organized so that if status is ok there is no delay at// all called either before or after the test. Is called indirectly through// pB->i2eWaitForTxEmpty.////******************************************************************************static intiiWaitForTxEmptyII(i2eBordStrPtr pB, int mSdelay){ unsigned long flags; int itemp; for (;;) { // This routine hinges on being able to see the "other" status register // (as seen by the local processor). His incoming fifo is our outgoing // FIFO. // // By the nature of this routine, you would be using this as part of a // larger atomic context: i.e., you would use this routine to ensure the // fifo empty, then act on this information. Between these two halves, // you will generally not want to service interrupts or in any way // disrupt the assumptions implicit in the larger context. // // Even worse, however, this routine "shifts" the status register to // point to the local status register which is not the usual situation. // Therefore for extra safety, we force the critical section to be // completely atomic, and pick up after ourselves before allowing any // interrupts of any kind. WRITE_LOCK_IRQSAVE(&Dl_spinlock,flags) OUTB(pB->i2ePointer, SEL_COMMAND); OUTB(pB->i2ePointer, SEL_CMD_SH); itemp = INB(pB->i2eStatus); OUTB(pB->i2ePointer, SEL_COMMAND); OUTB(pB->i2ePointer, SEL_CMD_UNSH); if (itemp & ST_IN_EMPTY) { UPDATE_FIFO_ROOM(pB); WRITE_UNLOCK_IRQRESTORE(&Dl_spinlock,flags) COMPLETE(pB, I2EE_GOOD); } WRITE_UNLOCK_IRQRESTORE(&Dl_spinlock,flags) if (mSdelay-- == 0) break; iiDelay(pB, 1); /* 1 mS granularity on checking condition */ } COMPLETE(pB, I2EE_TXE_TIME);}//******************************************************************************// Function: iiWaitForTxEmptyIIEX(pB, mSdelay)// Parameters: pB - pointer to board structure// mSdelay - period to wait before returning//// Returns: True if the FIFO is empty.// False if it not empty in the required time: the pB->i2eError// field has the error.//// Description://// Waits up to "mSdelay" milliseconds for the outgoing FIFO to become empty; if// not empty by the required time, returns false and error in pB->i2eError,// otherwise returns true.//// mSdelay == 0 is taken to mean must be empty on the first test.//// This version operates on IntelliPort-IIEX - style FIFO's//// Note this routine is organized so that if status is ok there is no delay at// all called either before or after the test. Is called indirectly through// pB->i2eWaitForTxEmpty.////******************************************************************************static intiiWaitForTxEmptyIIEX(i2eBordStrPtr pB, int mSdelay){ unsigned long flags; for (;;) { // By the nature of this routine, you would be using this as part of a // larger atomic context: i.e., you would use this routine to ensure the // fifo empty, then act on this information. Between these two halves, // you will generally not want to service interrupts or in any way // disrupt the assumptions implicit in the larger context. WRITE_LOCK_IRQSAVE(&Dl_spinlock,flags) if (INB(pB->i2eStatus) & STE_OUT_MT) { UPDATE_FIFO_ROOM(pB); WRITE_UNLOCK_IRQRESTORE(&Dl_spinlock,flags) COMPLETE(pB, I2EE_GOOD); } WRITE_UNLOCK_IRQRESTORE(&Dl_spinlock,flags) if (mSdelay-- == 0) break; iiDelay(pB, 1); // 1 mS granularity on checking condition } COMPLETE(pB, I2EE_TXE_TIME);}//******************************************************************************// Function: iiTxMailEmptyII(pB)// Parameters: pB - pointer to board structure//// Returns: True if the transmit mailbox is empty.// False if it not empty.//// Description://// Returns true or false according to whether the transmit mailbox is empty (and// therefore able to accept more mail)//// This version operates on IntelliPort-II - style FIFO's////******************************************************************************static intiiTxMailEmptyII(i2eBordStrPtr pB){ int port = pB->i2ePointer; OUTB ( port, SEL_OUTMAIL ); return ( INB(port) == 0 );}//******************************************************************************// Function: iiTxMailEmptyIIEX(pB)// Parameters: pB - pointer to board structure//// Returns: True if the transmit mailbox is empty.// False if it not empty.//// Description://// Returns true or false according to whether the transmit mailbox is empty (and// therefore able to accept more mail)//// This version operates on IntelliPort-IIEX - style FIFO's////******************************************************************************static intiiTxMailEmptyIIEX(i2eBordStrPtr pB){ return !(INB(pB->i2eStatus) & STE_OUT_MAIL);}//******************************************************************************// Function: iiTrySendMailII(pB,mail)// Parameters: pB - pointer to board structure// mail - value to write to mailbox//// Returns: True if the transmit mailbox is empty, and mail is sent.// False if it not empty.//// Description:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -