rioparam.c

来自「LINUX 2.6.17.4的源码」· C语言 代码 · 共 670 行 · 第 1/2 页

C
670
字号
	} else {		rio_dprintk(RIO_DEBUG_PARAM, "Possible Modem line\n");	}	/*	 ** COR 4 (there is no COR 3)	 */	if (TtyP->termios->c_iflag & IGNBRK) {		rio_dprintk(RIO_DEBUG_PARAM, "Ignore break condition\n");		Cor4 |= COR4_IGNBRK;	}	if (!(TtyP->termios->c_iflag & BRKINT)) {		rio_dprintk(RIO_DEBUG_PARAM, "Break generates NULL condition\n");		Cor4 |= COR4_NBRKINT;	} else {		rio_dprintk(RIO_DEBUG_PARAM, "Interrupt on	break condition\n");	}	if (TtyP->termios->c_iflag & INLCR) {		rio_dprintk(RIO_DEBUG_PARAM, "Map newline to carriage return on input\n");		Cor4 |= COR4_INLCR;	}	if (TtyP->termios->c_iflag & IGNCR) {		rio_dprintk(RIO_DEBUG_PARAM, "Ignore carriage return on input\n");		Cor4 |= COR4_IGNCR;	}	if (TtyP->termios->c_iflag & ICRNL) {		rio_dprintk(RIO_DEBUG_PARAM, "Map carriage return to newline on input\n");		Cor4 |= COR4_ICRNL;	}	if (TtyP->termios->c_iflag & IGNPAR) {		rio_dprintk(RIO_DEBUG_PARAM, "Ignore characters with parity errors\n");		Cor4 |= COR4_IGNPAR;	}	if (TtyP->termios->c_iflag & PARMRK) {		rio_dprintk(RIO_DEBUG_PARAM, "Mark parity errors\n");		Cor4 |= COR4_PARMRK;	}	/*	 ** Set the RAISEMOD flag to ensure that the modem lines are raised	 ** on reception of a config packet.	 ** The download code handles the zero baud condition.	 */	Cor4 |= COR4_RAISEMOD;	/*	 ** COR 5	 */	Cor5 = COR5_CMOE;	/*	 ** Set to monitor tbusy/tstop (or not).	 */	if (PortP->MonitorTstate)		Cor5 |= COR5_TSTATE_ON;	else		Cor5 |= COR5_TSTATE_OFF;	/*	 ** Could set LNE here if you wanted LNext processing. SVR4 will use it.	 */	if (TtyP->termios->c_iflag & ISTRIP) {		rio_dprintk(RIO_DEBUG_PARAM, "Strip input characters\n");		if (!(PortP->State & RIO_TRIAD_MODE)) {			Cor5 |= COR5_ISTRIP;		}	}	if (TtyP->termios->c_oflag & ONLCR) {		rio_dprintk(RIO_DEBUG_PARAM, "Map newline to carriage-return, newline on output\n");		if (PortP->CookMode == COOK_MEDIUM)			Cor5 |= COR5_ONLCR;	}	if (TtyP->termios->c_oflag & OCRNL) {		rio_dprintk(RIO_DEBUG_PARAM, "Map carriage return to newline on output\n");		if (PortP->CookMode == COOK_MEDIUM)			Cor5 |= COR5_OCRNL;	}	if ((TtyP->termios->c_oflag & TABDLY) == TAB3) {		rio_dprintk(RIO_DEBUG_PARAM, "Tab delay 3 set\n");		if (PortP->CookMode == COOK_MEDIUM)			Cor5 |= COR5_TAB3;	}	/*	 ** Flow control bytes.	 */	TxXon = TtyP->termios->c_cc[VSTART];	TxXoff = TtyP->termios->c_cc[VSTOP];	RxXon = TtyP->termios->c_cc[VSTART];	RxXoff = TtyP->termios->c_cc[VSTOP];	/*	 ** LNEXT byte	 */	LNext = 0;	/*	 ** Baud rate bytes	 */	rio_dprintk(RIO_DEBUG_PARAM, "Mapping of rx/tx baud %x (%x)\n", TtyP->termios->c_cflag, CBAUD);	switch (TtyP->termios->c_cflag & CBAUD) {#define e(b) case B ## b : RxBaud = TxBaud = RIO_B ## b ;break		e(50);		e(75);		e(110);		e(134);		e(150);		e(200);		e(300);		e(600);		e(1200);		e(1800);		e(2400);		e(4800);		e(9600);		e(19200);		e(38400);		e(57600);		e(115200);	/* e(230400);e(460800); e(921600);  */	}	rio_dprintk(RIO_DEBUG_PARAM, "tx baud 0x%x, rx baud 0x%x\n", TxBaud, RxBaud);	/*	 ** Leftovers	 */	if (TtyP->termios->c_cflag & CREAD)		rio_dprintk(RIO_DEBUG_PARAM, "Enable receiver\n");#ifdef RCV1EN	if (TtyP->termios->c_cflag & RCV1EN)		rio_dprintk(RIO_DEBUG_PARAM, "RCV1EN (?)\n");#endif#ifdef XMT1EN	if (TtyP->termios->c_cflag & XMT1EN)		rio_dprintk(RIO_DEBUG_PARAM, "XMT1EN (?)\n");#endif	if (TtyP->termios->c_lflag & ISIG)		rio_dprintk(RIO_DEBUG_PARAM, "Input character signal generating enabled\n");	if (TtyP->termios->c_lflag & ICANON)		rio_dprintk(RIO_DEBUG_PARAM, "Canonical input: erase and kill enabled\n");	if (TtyP->termios->c_lflag & XCASE)		rio_dprintk(RIO_DEBUG_PARAM, "Canonical upper/lower presentation\n");	if (TtyP->termios->c_lflag & ECHO)		rio_dprintk(RIO_DEBUG_PARAM, "Enable input echo\n");	if (TtyP->termios->c_lflag & ECHOE)		rio_dprintk(RIO_DEBUG_PARAM, "Enable echo erase\n");	if (TtyP->termios->c_lflag & ECHOK)		rio_dprintk(RIO_DEBUG_PARAM, "Enable echo kill\n");	if (TtyP->termios->c_lflag & ECHONL)		rio_dprintk(RIO_DEBUG_PARAM, "Enable echo newline\n");	if (TtyP->termios->c_lflag & NOFLSH)		rio_dprintk(RIO_DEBUG_PARAM, "Disable flush after interrupt or quit\n");#ifdef TOSTOP	if (TtyP->termios->c_lflag & TOSTOP)		rio_dprintk(RIO_DEBUG_PARAM, "Send SIGTTOU for background output\n");#endif#ifdef XCLUDE	if (TtyP->termios->c_lflag & XCLUDE)		rio_dprintk(RIO_DEBUG_PARAM, "Exclusive use of this line\n");#endif	if (TtyP->termios->c_iflag & IUCLC)		rio_dprintk(RIO_DEBUG_PARAM, "Map uppercase to lowercase on input\n");	if (TtyP->termios->c_oflag & OPOST)		rio_dprintk(RIO_DEBUG_PARAM, "Enable output post-processing\n");	if (TtyP->termios->c_oflag & OLCUC)		rio_dprintk(RIO_DEBUG_PARAM, "Map lowercase to uppercase on output\n");	if (TtyP->termios->c_oflag & ONOCR)		rio_dprintk(RIO_DEBUG_PARAM, "No carriage return output at column 0\n");	if (TtyP->termios->c_oflag & ONLRET)		rio_dprintk(RIO_DEBUG_PARAM, "Newline performs carriage return function\n");	if (TtyP->termios->c_oflag & OFILL)		rio_dprintk(RIO_DEBUG_PARAM, "Use fill characters for delay\n");	if (TtyP->termios->c_oflag & OFDEL)		rio_dprintk(RIO_DEBUG_PARAM, "Fill character is DEL\n");	if (TtyP->termios->c_oflag & NLDLY)		rio_dprintk(RIO_DEBUG_PARAM, "Newline delay set\n");	if (TtyP->termios->c_oflag & CRDLY)		rio_dprintk(RIO_DEBUG_PARAM, "Carriage return delay set\n");	if (TtyP->termios->c_oflag & TABDLY)		rio_dprintk(RIO_DEBUG_PARAM, "Tab delay set\n");	/*	 ** These things are kind of useful in a later life!	 */	PortP->Cor2Copy = Cor2;	if (PortP->State & RIO_DELETED) {		rio_spin_unlock_irqrestore(&PortP->portSem, flags);		func_exit();		return RIO_FAIL;	}	/*	 ** Actually write the info into the packet to be sent	 */	writeb(cmd, &phb_param_ptr->Cmd);	writeb(Cor1, &phb_param_ptr->Cor1);	writeb(Cor2, &phb_param_ptr->Cor2);	writeb(Cor4, &phb_param_ptr->Cor4);	writeb(Cor5, &phb_param_ptr->Cor5);	writeb(TxXon, &phb_param_ptr->TxXon);	writeb(RxXon, &phb_param_ptr->RxXon);	writeb(TxXoff, &phb_param_ptr->TxXoff);	writeb(RxXoff, &phb_param_ptr->RxXoff);	writeb(LNext, &phb_param_ptr->LNext);	writeb(TxBaud, &phb_param_ptr->TxBaud);	writeb(RxBaud, &phb_param_ptr->RxBaud);	/*	 ** Set the length/command field	 */	writeb(12 | PKT_CMD_BIT, &PacketP->len);	/*	 ** The packet is formed - now, whack it off	 ** to its final destination:	 */	add_transmit(PortP);	/*	 ** Count characters transmitted for port statistics reporting	 */	if (PortP->statsGather)		PortP->txchars += 12;	rio_spin_unlock_irqrestore(&PortP->portSem, flags);	rio_dprintk(RIO_DEBUG_PARAM, "add_transmit returned.\n");	/*	 ** job done.	 */	func_exit();	return 0;}/*** We can add another packet to a transmit queue if the packet pointer pointed** to by the TxAdd pointer has PKT_IN_USE clear in its address.*/int can_add_transmit(struct PKT **PktP, struct Port *PortP){	struct PKT *tp;	*PktP = tp = (struct PKT *) RIO_PTR(PortP->Caddr, readw(PortP->TxAdd));	return !((unsigned long) tp & PKT_IN_USE);}/*** To add a packet to the queue, you set the PKT_IN_USE bit in the address,** and then move the TxAdd pointer along one position to point to the next** packet pointer. You must wrap the pointer from the end back to the start.*/void add_transmit(struct Port *PortP){	if (readw(PortP->TxAdd) & PKT_IN_USE) {		rio_dprintk(RIO_DEBUG_PARAM, "add_transmit: Packet has been stolen!");	}	writew(readw(PortP->TxAdd) | PKT_IN_USE, PortP->TxAdd);	PortP->TxAdd = (PortP->TxAdd == PortP->TxEnd) ? PortP->TxStart : PortP->TxAdd + 1;	writew(RIO_OFF(PortP->Caddr, PortP->TxAdd), &PortP->PhbP->tx_add);}/**************************************** * Put a packet onto the end of the * free list ****************************************/void put_free_end(struct Host *HostP, struct PKT *PktP){	struct rio_free_list *tmp_pointer;	unsigned short old_end, new_end;	unsigned long flags;	rio_spin_lock_irqsave(&HostP->HostLock, flags);	 /*************************************************	* Put a packet back onto the back of the free list	*	************************************************/	rio_dprintk(RIO_DEBUG_PFE, "put_free_end(PktP=%p)\n", PktP);	if ((old_end = readw(&HostP->ParmMapP->free_list_end)) != TPNULL) {		new_end = RIO_OFF(HostP->Caddr, PktP);		tmp_pointer = (struct rio_free_list *) RIO_PTR(HostP->Caddr, old_end);		writew(new_end, &tmp_pointer->next);		writew(old_end, &((struct rio_free_list *) PktP)->prev);		writew(TPNULL, &((struct rio_free_list *) PktP)->next);		writew(new_end, &HostP->ParmMapP->free_list_end);	} else {		/* First packet on the free list this should never happen! */		rio_dprintk(RIO_DEBUG_PFE, "put_free_end(): This should never happen\n");		writew(RIO_OFF(HostP->Caddr, PktP), &HostP->ParmMapP->free_list_end);		tmp_pointer = (struct rio_free_list *) PktP;		writew(TPNULL, &tmp_pointer->prev);		writew(TPNULL, &tmp_pointer->next);	}	rio_dprintk(RIO_DEBUG_CMD, "Before unlock: %p\n", &HostP->HostLock);	rio_spin_unlock_irqrestore(&HostP->HostLock, flags);}/*** can_remove_receive(PktP,P) returns non-zero if PKT_IN_USE is set** for the next packet on the queue. It will also set PktP to point to the** relevant packet, [having cleared the PKT_IN_USE bit]. If PKT_IN_USE is clear,** then can_remove_receive() returns 0.*/int can_remove_receive(struct PKT **PktP, struct Port *PortP){	if (readw(PortP->RxRemove) & PKT_IN_USE) {		*PktP = (struct PKT *) RIO_PTR(PortP->Caddr, readw(PortP->RxRemove) & ~PKT_IN_USE);		return 1;	}	return 0;}/*** To remove a packet from the receive queue you clear its PKT_IN_USE bit,** and then bump the pointers. Once the pointers get to the end, they must** be wrapped back to the start.*/void remove_receive(struct Port *PortP){	writew(readw(PortP->RxRemove) & ~PKT_IN_USE, PortP->RxRemove);	PortP->RxRemove = (PortP->RxRemove == PortP->RxEnd) ? PortP->RxStart : PortP->RxRemove + 1;	writew(RIO_OFF(PortP->Caddr, PortP->RxRemove), &PortP->PhbP->rx_remove);}

⌨️ 快捷键说明

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