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

📄 t1isa.c

📁 Linux内核源代码 为压缩文件 是<<Linux内核>>一书中的源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
/* * $Id: t1isa.c,v 1.16 2000/11/23 20:45:14 kai Exp $ *  * Module for AVM T1 HEMA-card. *  * (c) Copyright 1999 by Carsten Paeth (calle@calle.in-berlin.de) *  * $Log: t1isa.c,v $ * Revision 1.16  2000/11/23 20:45:14  kai * fixed module_init/exit stuff * Note: compiled-in kernel doesn't work pre 2.2.18 anymore. * * Revision 1.15  2000/11/01 14:05:02  calle * - use module_init/module_exit from linux/init.h. * - all static struct variables are initialized with "membername:" now. * - avm_cs.c, let it work with newer pcmcia-cs. * * Revision 1.14  2000/10/10 17:44:19  kai * changes from/for 2.2.18 * * Revision 1.13  2000/08/04 15:36:31  calle * copied wrong from file to file :-( * * Revision 1.12  2000/08/04 12:20:08  calle * - Fix unsigned/signed warning in the right way ... * * Revision 1.11  2000/04/03 13:29:25  calle * make Tim Waugh happy (module unload races in 2.3.99-pre3). * no real problem there, but now it is much cleaner ... * * Revision 1.10  2000/02/02 18:36:04  calle * - Modules are now locked while init_module is running * - fixed problem with memory mapping if address is not aligned * * Revision 1.9  2000/01/25 14:37:39  calle * new message after successfull detection including card revision and * used resources. * * Revision 1.8  1999/11/05 16:38:01  calle * Cleanups before kernel 2.4: * - Changed all messages to use card->name or driver->name instead of *   constant string. * - Moved some data from struct avmcard into new struct avmctrl_info. *   Changed all lowlevel capi driver to match the new structur. * * Revision 1.7  1999/09/15 08:16:03  calle * Implementation of 64Bit extention complete. * * Revision 1.6  1999/09/07 09:02:53  calle * SETDATA removed. Now inside the kernel the datapart of DATA_B3_REQ and * DATA_B3_IND is always directly after the CAPI message. The "Data" member * ist never used inside the kernel. * * Revision 1.5  1999/08/22 20:26:28  calle * backported changes from kernel 2.3.14: * - several #include "config.h" gone, others come. * - "struct device" changed to "struct net_device" in 2.3.14, added a *   define in isdn_compat.h for older kernel versions. * * Revision 1.4  1999/07/09 15:05:50  keil * compat.h is now isdn_compat.h * * Revision 1.3  1999/07/06 07:42:04  calle * - changes in /proc interface * - check and changed calls to [dev_]kfree_skb and [dev_]alloc_skb. * * Revision 1.2  1999/07/05 15:09:54  calle * - renamed "appl_release" to "appl_released". * - version und profile data now cleared on controller reset * - extended /proc interface, to allow driver and controller specific *   informations to include by driver hackers. * * Revision 1.1  1999/07/01 15:26:44  calle * complete new version (I love it): * + new hardware independed "capi_driver" interface that will make it easy to: *   - support other controllers with CAPI-2.0 (i.e. USB Controller) *   - write a CAPI-2.0 for the passive cards *   - support serial link CAPI-2.0 boxes. * + wrote "capi_driver" for all supported cards. * + "capi_driver" (supported cards) now have to be configured with *   make menuconfig, in the past all supported cards where included *   at once. * + new and better informations in /proc/capi/ * + new ioctl to switch trace of capi messages per controller *   using "avmcapictrl trace [contr] on|off|...." * + complete testcircle with all supported cards and also the *   PCMCIA cards (now patch for pcmcia-cs-3.0.13 needed) done. * * */#include <linux/module.h>#include <linux/kernel.h>#include <linux/skbuff.h>#include <linux/delay.h>#include <linux/mm.h>#include <linux/interrupt.h>#include <linux/ioport.h>#include <linux/capi.h>#include <linux/init.h>#include <asm/io.h>#include "capicmd.h"#include "capiutil.h"#include "capilli.h"#include "avmcard.h"static char *revision = "$Revision: 1.16 $";/* ------------------------------------------------------------- */MODULE_AUTHOR("Carsten Paeth <calle@calle.in-berlin.de>");/* ------------------------------------------------------------- */static struct capi_driver_interface *di;/* ------------------------------------------------------------- */static int hema_irq_table[16] ={0, 0, 0, 0x80,				/* irq 3 */ 0, 0x90,				/* irq 5 */ 0, 0xA0,				/* irq 7 */ 0, 0xB0,				/* irq 9 */ 0xC0,				/* irq 10 */ 0xD0,				/* irq 11 */ 0xE0,				/* irq 12 */ 0, 0, 0xF0,				/* irq 15 */};static int t1_detectandinit(unsigned int base, unsigned irq, int cardnr){	unsigned char cregs[8];	unsigned char reverse_cardnr;	unsigned long flags;	unsigned char dummy;	int i;	reverse_cardnr =   ((cardnr & 0x01) << 3) | ((cardnr & 0x02) << 1)		         | ((cardnr & 0x04) >> 1) | ((cardnr & 0x08) >> 3);	cregs[0] = (HEMA_VERSION_ID << 4) | (reverse_cardnr & 0xf);	cregs[1] = 0x00; /* fast & slow link connected to CON1 */	cregs[2] = 0x05; /* fast link 20MBit, slow link 20 MBit */	cregs[3] = 0;	cregs[4] = 0x11; /* zero wait state */	cregs[5] = hema_irq_table[irq & 0xf];	cregs[6] = 0;	cregs[7] = 0;	save_flags(flags);	cli();	/* board reset */	t1outp(base, T1_RESETBOARD, 0xf);	mdelay(100);	dummy = t1inp(base, T1_FASTLINK+T1_OUTSTAT); /* first read */	/* write config */	dummy = (base >> 4) & 0xff;	for (i=1;i<=0xf;i++) t1outp(base, i, dummy);	t1outp(base, HEMA_PAL_ID & 0xf, dummy);	t1outp(base, HEMA_PAL_ID >> 4, cregs[0]);	for(i=1;i<7;i++) t1outp(base, 0, cregs[i]);	t1outp(base, ((base >> 4)) & 0x3, cregs[7]);	restore_flags(flags);	mdelay(100);	t1outp(base, T1_FASTLINK+T1_RESETLINK, 0);	t1outp(base, T1_SLOWLINK+T1_RESETLINK, 0);	mdelay(10);	t1outp(base, T1_FASTLINK+T1_RESETLINK, 1);	t1outp(base, T1_SLOWLINK+T1_RESETLINK, 1);	mdelay(100);	t1outp(base, T1_FASTLINK+T1_RESETLINK, 0);	t1outp(base, T1_SLOWLINK+T1_RESETLINK, 0);	mdelay(10);	t1outp(base, T1_FASTLINK+T1_ANALYSE, 0);	mdelay(5);	t1outp(base, T1_SLOWLINK+T1_ANALYSE, 0);	if (t1inp(base, T1_FASTLINK+T1_OUTSTAT) != 0x1) /* tx empty */		return 1;	if (t1inp(base, T1_FASTLINK+T1_INSTAT) != 0x0) /* rx empty */		return 2;	if (t1inp(base, T1_FASTLINK+T1_IRQENABLE) != 0x0)		return 3;	if ((t1inp(base, T1_FASTLINK+T1_FIFOSTAT) & 0xf0) != 0x70)		return 4;	if ((t1inp(base, T1_FASTLINK+T1_IRQMASTER) & 0x0e) != 0)		return 5;	if ((t1inp(base, T1_FASTLINK+T1_IDENT) & 0x7d) != 1)		return 6;	if (t1inp(base, T1_SLOWLINK+T1_OUTSTAT) != 0x1) /* tx empty */		return 7;	if ((t1inp(base, T1_SLOWLINK+T1_IRQMASTER) & 0x0e) != 0)		return 8;	if ((t1inp(base, T1_SLOWLINK+T1_IDENT) & 0x7d) != 0)		return 9;        return 0;}static void t1_handle_interrupt(avmcard * card){	avmctrl_info *cinfo = &card->ctrlinfo[0];	struct capi_ctr *ctrl = cinfo->capi_ctrl;	unsigned char b1cmd;	struct sk_buff *skb;	unsigned ApplId;	unsigned MsgLen;	unsigned DataB3Len;	unsigned NCCI;	unsigned WindowSize;	while (b1_rx_full(card->port)) {		b1cmd = b1_get_byte(card->port);		switch (b1cmd) {		case RECEIVE_DATA_B3_IND:			ApplId = (unsigned) b1_get_word(card->port);			MsgLen = t1_get_slice(card->port, card->msgbuf);			DataB3Len = t1_get_slice(card->port, card->databuf);			if (MsgLen < 30) { /* not CAPI 64Bit */				memset(card->msgbuf+MsgLen, 0, 30-MsgLen);				MsgLen = 30;				CAPIMSG_SETLEN(card->msgbuf, 30);			}			if (!(skb = alloc_skb(DataB3Len+MsgLen, GFP_ATOMIC))) {				printk(KERN_ERR "%s: incoming packet dropped\n",					card->name);			} else {				memcpy(skb_put(skb, MsgLen), card->msgbuf, MsgLen);				memcpy(skb_put(skb, DataB3Len), card->databuf, DataB3Len);				ctrl->handle_capimsg(ctrl, ApplId, skb);			}			break;		case RECEIVE_MESSAGE:			ApplId = (unsigned) b1_get_word(card->port);			MsgLen = t1_get_slice(card->port, card->msgbuf);			if (!(skb = alloc_skb(MsgLen, GFP_ATOMIC))) {				printk(KERN_ERR "%s: incoming packet dropped\n",						card->name);			} else {				memcpy(skb_put(skb, MsgLen), card->msgbuf, MsgLen);				ctrl->handle_capimsg(ctrl, ApplId, skb);			}			break;		case RECEIVE_NEW_NCCI:			ApplId = b1_get_word(card->port);			NCCI = b1_get_word(card->port);			WindowSize = b1_get_word(card->port);			ctrl->new_ncci(ctrl, ApplId, NCCI, WindowSize);			break;		case RECEIVE_FREE_NCCI:			ApplId = b1_get_word(card->port);			NCCI = b1_get_word(card->port);			if (NCCI != 0xffffffff)				ctrl->free_ncci(ctrl, ApplId, NCCI);			else ctrl->appl_released(ctrl, ApplId);			break;		case RECEIVE_START:			b1_put_byte(card->port, SEND_POLLACK);			ctrl->resume_output(ctrl);			break;		case RECEIVE_STOP:			ctrl->suspend_output(ctrl);			break;		case RECEIVE_INIT:			cinfo->versionlen = t1_get_slice(card->port, cinfo->versionbuf);			b1_parse_version(cinfo);			printk(KERN_INFO "%s: %s-card (%s) now active\n",			       card->name,			       cinfo->version[VER_CARDTYPE],			       cinfo->version[VER_DRIVER]);			ctrl->ready(ctrl);			break;		case RECEIVE_TASK_READY:			ApplId = (unsigned) b1_get_word(card->port);			MsgLen = t1_get_slice(card->port, card->msgbuf);			card->msgbuf[MsgLen] = 0;			while (    MsgLen > 0			       && (   card->msgbuf[MsgLen-1] == '\n'				   || card->msgbuf[MsgLen-1] == '\r')) {				card->msgbuf[MsgLen-1] = 0;				MsgLen--;			}			printk(KERN_INFO "%s: task %d \"%s\" ready.\n",					card->name, ApplId, card->msgbuf);			break;		case RECEIVE_DEBUGMSG:			MsgLen = t1_get_slice(card->port, card->msgbuf);			card->msgbuf[MsgLen] = 0;			while (    MsgLen > 0			       && (   card->msgbuf[MsgLen-1] == '\n'				   || card->msgbuf[MsgLen-1] == '\r')) {				card->msgbuf[MsgLen-1] = 0;				MsgLen--;			}			printk(KERN_INFO "%s: DEBUG: %s\n", card->name, card->msgbuf);			break;		case 0xff:

⌨️ 快捷键说明

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