📄 i2ellis.h
字号:
// This is set when we hit the MB_OUT_STUFFED mailbox, which prevents us // putting more in the mailbox until an appropriate mailbox message is // received. unsigned char i2eWaitingForEmptyFifo; // Any mailbox bits waiting to be sent to the board are OR'ed in here. unsigned char i2eOutMailWaiting; // The head of any incoming packet is read into here, is then examined and // we dispatch accordingly. unsigned short i2eLeadoffWord[1]; // Running counter of interrupts where the mailbox indicated incoming data. unsigned short i2eFifoInInts; // Running counter of interrupts where the mailbox indicated outgoing data // had been stripped. unsigned short i2eFifoOutInts; // If not void, gives the address of a routine to call if fatal board error // is found (only applies to standard l/w). void (*i2eFatalTrap)(struct _i2eBordStr *); // Will point to an array of some sort of channel structures (whose format // is unknown at this level, being a function of what loadware is // installed and the code configuration (max sizes of buffers, etc.)). void *i2eChannelPtr; // Set indicates that the board has gone fatal. unsigned short i2eFatal; // The number of elements pointed to by i2eChannelPtr. unsigned short i2eChannelCnt; // Ring-buffers of channel structures whose channels have particular needs. rwlock_t Fbuf_spinlock; volatile unsigned short i2Fbuf_strip; // Strip index volatile unsigned short i2Fbuf_stuff; // Stuff index void *i2Fbuf[CH_QUEUE_SIZE]; // An array of channel pointers // of channels who need to send // flow control packets. rwlock_t Dbuf_spinlock; volatile unsigned short i2Dbuf_strip; // Strip index volatile unsigned short i2Dbuf_stuff; // Stuff index void *i2Dbuf[CH_QUEUE_SIZE]; // An array of channel pointers // of channels who need to send // data or in-line command packets. rwlock_t Bbuf_spinlock; volatile unsigned short i2Bbuf_strip; // Strip index volatile unsigned short i2Bbuf_stuff; // Stuff index void *i2Bbuf[CH_QUEUE_SIZE]; // An array of channel pointers // of channels who need to send // bypass command packets. /* * A set of flags to indicate that certain events have occurred on at least * one of the ports on this board. We use this to decide whether to spin * through the channels looking for breaks, etc. */ int got_input; int status_change; bidStat channelBtypes; /* * Debugging counters, etc. */ unsigned long debugFlowQueued; unsigned long debugInlineQueued; unsigned long debugDataQueued; unsigned long debugBypassQueued; unsigned long debugFlowCount; unsigned long debugInlineCount; unsigned long debugBypassCount; rwlock_t read_fifo_spinlock; rwlock_t write_fifo_spinlock;// For queuing interrupt bottom half handlers. /\/\|=mhw=|\/\/ struct work_struct tqueue_interrupt; struct timer_list SendPendingTimer; // Used by iiSendPending unsigned int SendPendingRetry;} i2eBordStr, *i2eBordStrPtr;//-------------------------------------------------------------------// Macro Definitions for the indirect calls defined in the i2eBordStr//-------------------------------------------------------------------//#define iiDelay(a,b) (*(a)->i2eDelay)(b)#define iiWriteBuf(a,b,c) (*(a)->i2eWriteBuf)(a,b,c)#define iiReadBuf(a,b,c) (*(a)->i2eReadBuf)(a,b,c)#define iiWriteWord(a,b) (*(a)->i2eWriteWord)(a,b)#define iiReadWord(a) (*(a)->i2eReadWord)(a)#define iiWaitForTxEmpty(a,b) (*(a)->i2eWaitForTxEmpty)(a,b)#define iiTxMailEmpty(a) (*(a)->i2eTxMailEmpty)(a)#define iiTrySendMail(a,b) (*(a)->i2eTrySendMail)(a,b)#define iiGetMail(a) (*(a)->i2eGetMail)(a)#define iiEnableMailIrq(a) (*(a)->i2eEnableMailIrq)(a)#define iiDisableMailIrq(a) (*(a)->i2eWriteMask)(a,0)#define iiWriteMask(a,b) (*(a)->i2eWriteMask)(a,b)//-------------------------------------------// Manifests for i2eBordStr://-------------------------------------------#define YES 1#define NO 0#define NULLFUNC (void (*)(void))0#define NULLPTR (void *)0typedef void (*delayFunc_t)(unsigned int);// i2eValid//#define I2E_MAGIC 0x4251 // Structure is valid.#define I2E_INCOMPLETE 0x1122 // Structure failed during init.// i2eError//#define I2EE_GOOD 0 // Operation successful#define I2EE_BADADDR 1 // Address out of range#define I2EE_BADSTATE 2 // Attempt to perform a function when the board // structure was in the incorrect state#define I2EE_BADMAGIC 3 // Bad magic number from Power On test (i2ePomSize // reflects what was read#define I2EE_PORM_SHORT 4 // Power On message too short#define I2EE_PORM_LONG 5 // Power On message too long#define I2EE_BAD_FAMILY 6 // Un-supported board family type#define I2EE_INCONSIST 7 // Firmware reports something impossible, // e.g. unexpected number of ports... Almost no // excuse other than bad FIFO...#define I2EE_POSTERR 8 // Power-On self test reported a bad error#define I2EE_BADBUS 9 // Unknown Bus type declared in message#define I2EE_TXE_TIME 10 // Timed out waiting for TX Fifo to empty#define I2EE_INVALID 11 // i2eValid field does not indicate a valid and // complete board structure (for functions which // require this be so.)#define I2EE_BAD_PORT 12 // Discrepancy between channels actually found and // what the product is supposed to have. Check // i2eGoodMap vs i2eChannelMap for details.#define I2EE_BAD_IRQ 13 // Someone specified an unsupported IRQ#define I2EE_NOCHANNELS 14 // No channel structures have been defined (for // functions requiring this).// i2eFifoStyle//#define FIFO_II 0 /* IntelliPort-II style: see also i2hw.h */#define FIFO_IIEX 1 /* IntelliPort-IIEX style */// i2eGetMail//#define NO_MAIL_HERE 0x1111 // Since mail is unsigned char, cannot possibly // promote to 0x1111.// i2eState//#define II_STATE_COLD 0 // Addresses have been defined, but board not even // reset yet.#define II_STATE_RESET 1 // Board,if it exists, has just been reset#define II_STATE_READY 2 // Board ready for its first block#define II_STATE_LOADING 3 // Board continuing load#define II_STATE_LOADED 4 // Board has finished load: status ok#define II_STATE_BADLOAD 5 // Board has finished load: failed!#define II_STATE_STDLOADED 6 // Board has finished load: standard firmware// i2eUsingIrq//#define IRQ_UNDEFINED 0x1352 // No valid irq (or polling = 0) can ever // promote to this!//------------------------------------------// Handy Macros for i2ellis.c and others// Note these are common to -II and -IIEX//------------------------------------------// Given a pointer to the board structure, does the input FIFO have any data or// not?//#define HAS_INPUT(pB) !(INB(pB->i2eStatus) & ST_IN_EMPTY)#define HAS_NO_INPUT(pB) (INB(pB->i2eStatus) & ST_IN_EMPTY)// Given a pointer to board structure, read a byte or word from the fifo//#define BYTE_FROM(pB) (unsigned char)INB(pB->i2eData)#define WORD_FROM(pB) (unsigned short)INW(pB->i2eData)// Given a pointer to board structure, is there room for any data to be written// to the data fifo?//#define HAS_OUTROOM(pB) !(INB(pB->i2eStatus) & ST_OUT_FULL)#define HAS_NO_OUTROOM(pB) (INB(pB->i2eStatus) & ST_OUT_FULL)// Given a pointer to board structure, write a single byte to the fifo// structure. Note that for 16-bit interfaces, the high order byte is undefined// and unknown.//#define BYTE_TO(pB, c) OUTB(pB->i2eData,(c))// Write a word to the fifo structure. For 8-bit interfaces, this may have// unknown results.//#define WORD_TO(pB, c) OUTW(pB->i2eData,(c))// Given a pointer to the board structure, is there anything in the incoming// mailbox?//#define HAS_MAIL(pB) (INB(pB->i2eStatus) & ST_IN_MAIL)#define UPDATE_FIFO_ROOM(pB) (pB)->i2eFifoRemains=(pB)->i2eFifoSize// Handy macro to round up a number (like the buffer write and read routines do)// #define ROUNDUP(number) (((number)+1) & (~1))//------------------------------------------// Function Declarations for i2ellis.c//------------------------------------------//// Functions called directly//// Initialization of a board & structure is in four (five!) parts://// 0) iiEllisInit() - Initialize iiEllis subsystem.// 1) iiSetAddress() - Define the board address & delay function for a board.// 2) iiReset() - Reset the board (provided it exists)// -- Note you may do this to several boards --// 3) iiResetDelay() - Delay for 2 seconds (once for all boards)// 4) iiInitialize() - Attempt to read Power-up message; further initialize// accelerators//// Then you may use iiDownloadAll() or iiDownloadFile() (in i2file.c) to write// loadware. To change loadware, you must begin again with step 2, resetting// the board again (step 1 not needed).static void iiEllisInit(void);static int iiSetAddress(i2eBordStrPtr, int, delayFunc_t );static int iiReset(i2eBordStrPtr);static int iiResetDelay(i2eBordStrPtr);static int iiInitialize(i2eBordStrPtr);// Routine to validate that all channels expected are there.//extern int iiValidateChannels(i2eBordStrPtr);// Routine used to download a block of loadware.//static int iiDownloadBlock(i2eBordStrPtr, loadHdrStrPtr, int);// Return values given by iiDownloadBlock, iiDownloadAll, iiDownloadFile://#define II_DOWN_BADVALID 0 // board structure is invalid#define II_DOWN_CONTINUING 1 // So far, so good, firmware expects more#define II_DOWN_GOOD 2 // Download complete, CRC good#define II_DOWN_BAD 3 // Download complete, but CRC bad#define II_DOWN_BADFILE 4 // Bad magic number in loadware file#define II_DOWN_BADSTATE 5 // Board is in an inappropriate state for // downloading loadware. (see i2eState)#define II_DOWN_TIMEOUT 6 // Timeout waiting for firmware#define II_DOWN_OVER 7 // Too much data#define II_DOWN_UNDER 8 // Not enough data#define II_DOWN_NOFILE 9 // Loadware file not found// Routine to download an entire loadware module: Return values are a subset of// iiDownloadBlock's, excluding, of course, II_DOWN_CONTINUING//static int iiDownloadAll(i2eBordStrPtr, loadHdrStrPtr, int, int);// Called indirectly always. Needed externally so the routine might be// SPECIFIED as an argument to iiReset()////static void ii2DelayIO(unsigned int); // N-millisecond delay using //hardware spin//static void ii2DelayTimer(unsigned int); // N-millisecond delay using Linux //timer// Many functions defined here return True if good, False otherwise, with an// error code in i2eError field. Here is a handy macro for setting the error// code and returning.//#define COMPLETE(pB,code) \ if(1){ \ pB->i2eError = code; \ return (code == I2EE_GOOD);\ }#endif // I2ELLIS_H
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -