⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ip2main.c

📁 linux和2410结合开发 用他可以生成2410所需的zImage文件
💻 C
📖 第 1 页 / 共 5 页
字号:
	if ( Eisa_irq ) {		printk(KERN_DEBUG ", Interrupt %d %s\n",		       setup_irq, (ismine & 2) ? "(edge)" : "(level)");	} else {		printk(KERN_DEBUG ", (polled)\n");	}#endif	return setup_address;}/******************************************************************************//* Function:   set_irq()                                                      *//* Parameters: index to board in board table                                  *//*             IRQ to use                                                     *//* Returns:    Success (0)                                                    *//*                                                                            *//* Description:                                                               *//******************************************************************************/static voidset_irq( int boardnum, int boardIrq ){	unsigned char tempCommand[16];	i2eBordStrPtr pB = i2BoardPtrTable[boardnum];	unsigned long flags;	/*	 * Notify the boards they may generate interrupts. This is done by	 * sending an in-line command to channel 0 on each board. This is why	 * the channels have to be defined already. For each board, if the	 * interrupt has never been defined, we must do so NOW, directly, since	 * board will not send flow control or even give an interrupt until this	 * is done.  If polling we must send 0 as the interrupt parameter.	 */	// We will get an interrupt here at the end of this function	iiDisableMailIrq(pB);	/* We build up the entire packet header. */	CHANNEL_OF(tempCommand) = 0;	PTYPE_OF(tempCommand) = PTYPE_INLINE;	CMD_COUNT_OF(tempCommand) = 2;	(CMD_OF(tempCommand))[0] = CMDVALUE_IRQ;	(CMD_OF(tempCommand))[1] = boardIrq;	/*	 * Write to FIFO; don't bother to adjust fifo capacity for this, since	 * board will respond almost immediately after SendMail hit.	 */	WRITE_LOCK_IRQSAVE(&pB->write_fifo_spinlock,flags);	iiWriteBuf(pB, tempCommand, 4);	WRITE_UNLOCK_IRQRESTORE(&pB->write_fifo_spinlock,flags);	pB->i2eUsingIrq = boardIrq;	pB->i2eOutMailWaiting |= MB_OUT_STUFFED;	/* Need to update number of boards before you enable mailbox int */	++i2nBoards;	CHANNEL_OF(tempCommand) = 0;	PTYPE_OF(tempCommand) = PTYPE_BYPASS;	CMD_COUNT_OF(tempCommand) = 6;	(CMD_OF(tempCommand))[0] = 88;	// SILO	(CMD_OF(tempCommand))[1] = 64;	// chars	(CMD_OF(tempCommand))[2] = 32;	// ms	(CMD_OF(tempCommand))[3] = 28;	// MAX_BLOCK	(CMD_OF(tempCommand))[4] = 64;	// chars	(CMD_OF(tempCommand))[5] = 87;	// HW_TEST	WRITE_LOCK_IRQSAVE(&pB->write_fifo_spinlock,flags);	iiWriteBuf(pB, tempCommand, 8);	WRITE_UNLOCK_IRQRESTORE(&pB->write_fifo_spinlock,flags);	CHANNEL_OF(tempCommand) = 0;	PTYPE_OF(tempCommand) = PTYPE_BYPASS;	CMD_COUNT_OF(tempCommand) = 1;	(CMD_OF(tempCommand))[0] = 84;	/* get BOX_IDS */	iiWriteBuf(pB, tempCommand, 3);#ifdef XXX	// enable heartbeat for test porpoises	CHANNEL_OF(tempCommand) = 0;	PTYPE_OF(tempCommand) = PTYPE_BYPASS;	CMD_COUNT_OF(tempCommand) = 2;	(CMD_OF(tempCommand))[0] = 44;	/* get ping */	(CMD_OF(tempCommand))[1] = 200;	/* 200 ms */	WRITE_LOCK_IRQSAVE(&pB->write_fifo_spinlock,flags);	iiWriteBuf(pB, tempCommand, 4);	WRITE_UNLOCK_IRQRESTORE(&pB->write_fifo_spinlock,flags);#endif	iiEnableMailIrq(pB);	iiSendPendingMail(pB);}/******************************************************************************//* Interrupt Handler Section                                                  *//******************************************************************************/static inline voidservice_all_boards(){	int i;	i2eBordStrPtr  pB;	/* Service every board on the list */	for( i = 0; i < IP2_MAX_BOARDS; ++i ) {		pB = i2BoardPtrTable[i];		if ( pB ) {			i2ServiceBoard( pB );		}	}}/******************************************************************************//* Function:   ip2_interrupt_bh(pB)                                           *//* Parameters: pB - pointer to the board structure                            *//* Returns:    Nothing                                                        *//*                                                                            *//* Description:                                                               *//*	Service the board in a bottom half interrupt handler and then         *//*	reenable the board's interrupts if it has an IRQ number               *//*                                                                            *//******************************************************************************/static voidip2_interrupt_bh(i2eBordStrPtr pB){//	pB better well be set or we have a problem!  We can only get//	here from the IMMEDIATE queue.  Here, we process the boards.//	Checking pB doesn't cost much and it saves us from the sanity checkers.	bh_counter++; 	if ( pB ) {		i2ServiceBoard( pB );		if( pB->i2eUsingIrq ) {//			Re-enable his interrupts			iiEnableMailIrq(pB);		}	}}/******************************************************************************//* Function:   ip2_interrupt(int irq, void *dev_id, struct pt_regs * regs)    *//* Parameters: irq - interrupt number                                         *//*             pointer to optional device ID structure                        *//*             pointer to register structure                                  *//* Returns:    Nothing                                                        *//*                                                                            *//* Description:                                                               *//*                                                                            *//*	Our task here is simply to identify each board which needs servicing. *//*	If we are queuing then, queue it to be serviced, and disable its irq  *//*	mask otherwise process the board directly.                            *//*                                                                            *//*	We could queue by IRQ but that just complicates things on both ends   *//*	with very little gain in performance (how many instructions does      *//*	it take to iterate on the immediate queue).                           *//*                                                                            *//*                                                                            *//******************************************************************************/static voidip2_interrupt(int irq, void *dev_id, struct pt_regs * regs){	int i;	i2eBordStrPtr  pB;	ip2trace (ITRC_NO_PORT, ITRC_INTR, 99, 1, irq );	/* Service just the boards on the list using this irq */	for( i = 0; i < i2nBoards; ++i ) {		pB = i2BoardPtrTable[i];//		Only process those boards which match our IRQ.//			IRQ = 0 for polled boards, we won't poll "IRQ" boards		if ( pB && (pB->i2eUsingIrq == irq) ) {#ifdef USE_IQI		    if (NO_MAIL_HERE != ( pB->i2eStartMail = iiGetMail(pB))) {//			Disable his interrupt (will be enabled when serviced)//			This is mostly to protect from reentrancy.			iiDisableMailIrq(pB);//			Park the board on the immediate queue for processing.			queue_task(&pB->tqueue_interrupt, &tq_immediate);//			Make sure the immediate queue is flagged to fire.			mark_bh(IMMEDIATE_BH);		    }#else//		We are using immediate servicing here.  This sucks and can//		cause all sorts of havoc with ppp and others.  The failsafe//		check on iiSendPendingMail could also throw a hairball.			i2ServiceBoard( pB );#endif /* USE_IQI */		}	}	++irq_counter;	ip2trace (ITRC_NO_PORT, ITRC_INTR, ITRC_RETURN, 0 );}/******************************************************************************//* Function:   ip2_poll(unsigned long arg)                                    *//* Parameters: ?                                                              *//* Returns:    Nothing                                                        *//*                                                                            *//* Description:                                                               *//* This function calls the library routine i2ServiceBoard for each board in   *//* the board table. This is used instead of the interrupt routine when polled *//* mode is specified.                                                         *//******************************************************************************/static voidip2_poll(unsigned long arg){	ip2trace (ITRC_NO_PORT, ITRC_INTR, 100, 0 );	TimerOn = 0; // it's the truth but not checked in service	// Just polled boards, IRQ = 0 will hit all non-interrupt boards.	// It will NOT poll boards handled by hard interrupts.	// The issue of queued BH interrups is handled in ip2_interrupt().	ip2_interrupt(0, NULL, NULL);	PollTimer.expires = POLL_TIMEOUT;	add_timer( &PollTimer );	TimerOn = 1;	ip2trace (ITRC_NO_PORT, ITRC_INTR, ITRC_RETURN, 0 );}static inline void do_input( i2ChanStrPtr pCh ){	unsigned long flags;	ip2trace(CHANN, ITRC_INPUT, 21, 0 );	// Data input	if ( pCh->pTTY != NULL ) {		READ_LOCK_IRQSAVE(&pCh->Ibuf_spinlock,flags)		if (!pCh->throttled && (pCh->Ibuf_stuff != pCh->Ibuf_strip)) {			READ_UNLOCK_IRQRESTORE(&pCh->Ibuf_spinlock,flags)			i2Input( pCh );		} else			READ_UNLOCK_IRQRESTORE(&pCh->Ibuf_spinlock,flags)	} else {		ip2trace(CHANN, ITRC_INPUT, 22, 0 );		i2InputFlush( pCh );	}}// code duplicated from n_tty (ldisc)static inline void isig(int sig, struct tty_struct *tty, int flush){	if (tty->pgrp > 0)		kill_pg(tty->pgrp, sig, 1);	if (flush || !L_NOFLSH(tty)) {		if ( tty->ldisc.flush_buffer )  			tty->ldisc.flush_buffer(tty);		i2InputFlush( tty->driver_data );	}}static inline voiddo_status( i2ChanStrPtr pCh ){	int status;	status =  i2GetStatus( pCh, (I2_BRK|I2_PAR|I2_FRA|I2_OVR) );	ip2trace (CHANN, ITRC_STATUS, 21, 1, status );	if (pCh->pTTY && (status & (I2_BRK|I2_PAR|I2_FRA|I2_OVR)) ) {		if ( (status & I2_BRK) ) {			// code duplicated from n_tty (ldisc)			if (I_IGNBRK(pCh->pTTY))				goto skip_this;			if (I_BRKINT(pCh->pTTY)) {				isig(SIGINT, pCh->pTTY, 1);				goto skip_this;			}			wake_up_interruptible(&pCh->pTTY->read_wait);		}#ifdef NEVER_HAPPENS_AS_SETUP_XXX	// and can't work because we don't know the_char	// as the_char is reported on a seperate path	// The intelligent board does this stuff as setup	{	char brkf = TTY_NORMAL;	unsigned char brkc = '\0';	unsigned char tmp;		if ( (status & I2_BRK) ) {			brkf = TTY_BREAK;			brkc = '\0';		} 		else if (status & I2_PAR) {			brkf = TTY_PARITY;			brkc = the_char;		} else if (status & I2_FRA) {			brkf = TTY_FRAME;			brkc = the_char;		} else if (status & I2_OVR) {			brkf = TTY_OVERRUN;			brkc = the_char;		}		tmp = pCh->pTTY->real_raw;		pCh->pTTY->real_raw = 0;		pCh->pTTY->ldisc.receive_buf( pCh->pTTY, &brkc, &brkf, 1 );		pCh->pTTY->real_raw = tmp;	}#endif /* NEVER_HAPPENS_AS_SETUP_XXX */	}skip_this:	if ( status & (I2_DDCD | I2_DDSR | I2_DCTS | I2_DRI) ) {		wake_up_interruptible(&pCh->delta_msr_wait);		if ( (pCh->flags & ASYNC_CHECK_CD) && (status & I2_DDCD) ) {			if ( status & I2_DCD ) {				if ( pCh->wopen ) {					wake_up_interruptible ( &pCh->open_wait );				}			} else if ( !(pCh->flags & ASYNC_CALLOUT_ACTIVE) ) {				if (pCh->pTTY &&  (!(pCh->pTTY->termios->c_cflag & CLOCAL)) ) {					tty_hangup( pCh->pTTY );				}			}		}	}	ip2trace (CHANN, ITRC_STATUS, 26, 0 );}/******************************************************************************//* Device Open/Close/Ioctl Entry Point Section                                *//******************************************************************************//******************************************************************************//* Function:   open_sanity_check()                                            *//* Parameters: Pointer to tty structure                                       *//*             Pointer to file structure                                      *//* Returns:    Success or failure                                             *//*                                                                            *//* Description:                                                               *//* Verifies the structure magic numbers and cross links.                      *//******************************************************************************/#ifdef IP2DEBUG_OPENstatic void open_sanity_check( i2ChanStrPtr pCh, i2eBordStrPtr pBrd ){	if ( pBrd->i2eValid != I2E_MAGIC ) {		printk(KERN_ERR "IP2: invalid board structure\n" );	} else if ( pBrd != pCh->pMyBord ) {		printk(KERN_ERR "IP2: board structure pointer mismatch (%p)\n",			 pCh->pMyBord );	} else if ( pBrd->i2eChannelCnt < pCh->port_index ) {		printk(KERN_ERR "IP2: bad device index (%d)\n", pCh->port_index );	} else if (&((i2ChanStrPtr)pBrd->i2eChannelPtr)[pCh->port_index] != pCh) {	} else {		printk(KERN_INFO "IP2: all pointers check out!\n" );	}}#endif/******************************************************************************//* Function:   ip2_open()                                                     *//* Parameters: Pointer to tty structure                                       *//*             Pointer to file structure                                      *//* Returns:    Success or failure                                             *//*                                                                            *//* Description: (MANDATORY)                                                   *//* A successful device open has to run a gauntlet of checks before it         *//* completes. After some sanity checking and pointer setup, the function      *//* blocks until all conditions are satisfied. It then initialises the port to *//* the default characteristics and returns.                                   *//******************************************************************************/static intip2_open( PTTY tty, struct file *pFile ){	wait_queue_t wait;	int rc = 0;	int do_clocal = 0;	i2ChanStrPtr  pCh = DevTable[MINOR(tty->device)];	ip2trace (MINOR(tty->device), ITRC_OPEN, ITRC_ENTER, 0 );	if ( pCh == NULL ) {		return -ENODEV;	}	/* Setup pointer links in device and tty structures */	pCh->pTTY = tty;	tty->driver_data = pCh;	MOD_INC_USE_COUNT;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -