亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? pc100.c

?? TCPIP協議包
?? C
字號:
/* Interface driver for the PACCOMM PC-100 board for the IBM PC */
/* UNFINISHED, DOESN'T WORK YET - work in progress by Bdale */
/* currently only attempting to use the AMD7910 on Channel A */

#include <stdio.h>
#include <dos.h>
#include "global.h"
#include "mbuf.h"
#include "iface.h"
#include "pktdrvr.h"
#include "netuser.h"
#include "pc100.h"
#include "z8530.h"
#include "ax25.h"
#include "trace.h"
#include "nospc.h"

static void hspint(struct hdlc *hp);
static void hexint(struct hdlc *hp);
static void hrxint(struct hdlc *hp);
static void htxint(register struct hdlc *hp);
static void rts(uint16 base,int x);
static void hdlcparam(struct hdlc *hp);
static int pc_raw(struct iface *iface,struct mbuf **bpp);
static int pc_stop(struct iface *iface);

static struct pc100 Pc100[NPC];
static INTERRUPT (*Pchandle[])() = { pc0vec };
static struct hdlc Hdlc[2*NPC];
static uint16 Npc;

/* Branch table for interrupt handler */
static void (*Svec[])(struct hdlc *hp) = {
	htxint, hexint, hrxint, hspint
};

/* Master interrupt handler for the PC-100 card. All interrupts come
 * here first, then are switched out to the appropriate routine.
 */
INTERRUPT (far *(pcint)(dev))()
int dev;
{
	register char iv;
	register uint16 pcbase;
	struct hdlc *hp;
	struct pc100 *pcp;

	pcp = &Pc100[dev];
	pcp->ints++;
	pcbase = pcp->addr;

	/* Read interrupt vector, including status, from channel B */
	iv = read_scc(CTL+pcbase+CHANB,R2);

	hp = &Hdlc[2 * dev + ((iv & 0x80)? 0 : 1)];

	/* Now switch to appropriate routine */
	(*Svec[(iv>>1) & 0x3])(hp);

	/* Reset interrupt pending state (register A only) */
	write_scc(CTL+pcbase+CHANA,R0,RES_H_IUS);

	/* Wang the 8530 hardware interrupt acknowledge line - Bdale */
	inportb(pcbase+INTACK);

	return pcp->chain ? pcp->oldvec : NULL;
}
/* HDLC Special Receive Condition interrupt
 * The most common event that triggers this interrupt is the
 * end of a frame; it can also be caused by a receiver overflow.
 */
static void
hspint(hp)
register struct hdlc *hp;
{
	register char c;

	hp->spints++;
	c = read_scc(CTL+hp->base,R1);	/* Fetch latched bits */

	if((c & (END_FR|CRC_ERR)) == END_FR && hp->rcvbuf != NULL
		&& hp->rcvbuf->cnt > 1){
		/* End of valid frame */
		hp->rcvbuf->cnt--;	/* Toss 1st crc byte */
		enqueue(&hp->rcvq,&hp->rcvbuf);
		hp->rcvbuf = NULL;
		hp->rcvcnt++;
	} else {
		/* An overflow or CRC error occurred; restart receiver */
		hp->crcerr++;
		if(hp->rcvbuf != NULL){
			hp->rcp = hp->rcvbuf->data;
			hp->rcvbuf->cnt = 0;
		}
	}
	write_scc(CTL+hp->base,R0,ERR_RES);
}
/* HDLC SIO External/Status interrupts
 * The only one of direct interest is a receiver abort; the other
 * usual cause is a change in the modem control leads, so kick the
 * transmit interrupt routine.
 */
static void
hexint(hp)
register struct hdlc *hp;
{
	hp->exints++;
	hp->status = read_scc(CTL+hp->base,R0);	/* Fetch status */
	if((hp->status & BRK_ABRT) && hp->rcvbuf != NULL){
		hp->aborts++;
		/* Restart receiver */
		hp->rcp = hp->rcvbuf->data;
		hp->rcvbuf->cnt = 0;
	}
	write_scc(CTL+hp->base,R0,RES_EXT_INT);
	write_scc(CTL+hp->base,R0,RES_H_IUS);
	/* Kick the transmit interrupt routine for a possible modem change */
	htxint(hp);
}
/* HDLC receiver interrupt handler. Allocates buffers off the freelist,
 * fills them with receive data, and puts them on the receive queue.
 */
static void
hrxint(hp)
register struct hdlc *hp;
{
	struct mbuf *bp;
	register uint16 base;

	hp->rxints++;
	base = hp->base;
	/* Allocate a receive buffer if not already present */
	if((bp = hp->rcvbuf) == NULL){
		bp = hp->rcvbuf = alloc_mbuf(hp->bufsiz);
		if(bp == NULL){
			/* No memory, abort receiver */
			hp->nomem++;
			write_scc(CTL+base,R3,ENT_HM|RxENABLE|RxCRC_ENAB|Rx8);
			(void) inportb(base+DATA);
			return;
		}
		hp->rcp = hp->rcvbuf->data;
	}
	while(read_scc(CTL+base,R0) & Rx_CH_AV){
		if(bp->cnt++ >= hp->bufsiz){
			/* Too large; abort the receiver, toss buffer */
			hp->toobig++;
			write_scc(CTL+base,R3,ENT_HM|RxENABLE|RxCRC_ENAB|Rx8);
			(void) inportb(base+DATA);
			free_p(&bp);
			hp->rcvbuf = NULL;
			break;
		}
		/* Normal save */
		*hp->rcp++ = inportb(base+DATA);
	}
}
static int ctswait;
/* HDLC transmit interrupt service routine
 *
 * The state variable tstate, along with some static pointers,
 * represents the state of the transmit "process".
 */
static void
htxint(hp)
register struct hdlc *hp;
{
	register uint16 base;
	int c;
	int i_state;

	hp->txints++;
	base = hp->base;
	i_state = dirps();
	while(read_scc(CTL+base,R0) & Tx_BUF_EMP){
		switch(hp->tstate){
		/* First here for efficiency */
		case ACTIVE:		/* Sending frame */
			if((c = PULLCHAR(&hp->sndbuf)) != -1){
				outportb(base+DATA,c);
			} else {
				/* Do this after sending the last byte */
				write_scc(CTL+base,R0,RES_Tx_P);
				if((hp->sndbuf = dequeue(&hp->sndq)) == NULL){
					switch(hp->mode){
					case CSMA:
						/* Begin transmitter shutdown */
						hp->tstate = FLUSH;
						break;
					case FULLDUP:
						hp->tstate = IDLE;
						break;
					}
				}
			}
			continue;
		case IDLE:
			/* Transmitter idle. Find a frame for transmission */
			if((hp->sndbuf = dequeue(&hp->sndq)) == NULL)
				goto ret;

		case DEFER:	/* note fall-thru */
			if(hp->mode == CSMA && (hp->status & DCD)){
				hp->tstate = DEFER;
				goto ret;
			}
			rts(base,ON);	/* Transmitter on */
		case KEYUP:	/* note fall-thru */
			if((hp->status & CTS) == 0){
				ctswait++;
				hp->tstate = KEYUP;
				goto ret;
			}
			write_scc(CTL+base,R0,RES_Tx_CRC);
			c = PULLCHAR(&hp->sndbuf);
			outportb(hp->base+DATA,c);
			hp->tstate = ACTIVE;
			write_scc(CTL+base,R0,RES_EOM_L);
			continue;
		case FLUSH:	/* Sending flush character */
			outportb(hp->base+DATA,0);
			hp->tstate = FIN2;
			continue;
		case FIN2:
			write_scc(CTL+base,R0,SEND_ABORT);
			hp->tstate = IDLE;
			rts(base,OFF);
			write_scc(CTL+base,R0,RES_Tx_P);
			continue;
		}
	}
ret:	restore(i_state);
}

/* Set request-to-send on modem */
static void
rts(base,x)
uint16 base;
int x;
{
	uint16 cmd;

	if(x)
		cmd = TxCRC_ENAB | RTS | TxENAB | Tx8 | DTR;
	else
		cmd = TxCRC_ENAB | TxENAB | Tx8 | DTR;
	write_scc(CTL+base,R5,cmd);
}
/* (re)Initialize HDLC controller parameters */
static void
hdlcparam(hp)
register struct hdlc *hp;
{
	uint16 tc;
	register uint16 base;
	int i_state;

	/* Initialize 8530 channel for SDLC operation */
	base = hp->base;
	i_state = dirps();

	switch(base & 2){
	case 0:
		write_scc(CTL+base,R9,CHRA);	/* Reset channel A */
		break;
	case 2:
		write_scc(CTL+base,R9,CHRB);	/* Reset channel B */
		break;
	}
	/* Wait/DMA disable, Int on all Rx chars + spec condition,
	 * parity NOT spec condition, TxINT enable, Ext Int enable
	 */
	write_scc(CTL+base,R1,INT_ALL_Rx | TxINT_ENAB | EXT_INT_ENAB);

	/* Dummy interrupt vector, will be modified by interrupt type
	 * (This probably isn't necessary)
	 */
	write_scc(CTL+base,R2,0);

	/* 8 bit RX chars, auto enables off, no hunt mode, RxCRC enable,
	 * no address search, no inhibit sync chars, enable RX
	 */
	write_scc(CTL+base,R3,Rx8|RxCRC_ENAB|RxENABLE);

	/* X1 clock, SDLC mode, Sync modes enable, parity disable
	 * (Note: the DPLL does a by-32 clock division, so it's not necessary
	 * to divide here).
	 */
	write_scc(CTL+base,R4,X1CLK | SDLC | SYNC_ENAB);

	/* DTR On, 8 bit TX chars, no break, TX enable, SDLC CRC,
	 * RTS off, TxCRC enable
	 */
	write_scc(CTL+base,R5,DTR|Tx8|TxENAB|TxCRC_ENAB);

	/* SDLC flag */
	write_scc(CTL+base,R7,FLAG);

	/* No reset, status low, master int enable, enable lower chain,
	 * no vector, vector includes status
	 */
	write_scc(CTL+base,R9,MIE|NV|VIS);
	/* CRC preset 1, NRZI encoding, no active on poll, flag idle,
	 * flag on underrun, no loop mode, 8 bit sync
	 */
	write_scc(CTL+base,R10,CRCPS|NRZI);

	/* Board no longer channel-specific for clk.  The board should be set
	 * up to run from the 4.9152Mhz onboard crystal connected to PCLK.
	 * Both channels get receive clock at 32x from PCLK via the DPLL,
	 * with TRxC as an output, via a 4040 div by 32 counter to RTxC set
	 * us as an input to provide the transmit clock.
	 */

	/*            TRxC = BR Generator Output, TRxC O/I,
	 *	      transmit clock = RTxC pin, 
	 *	      receive clock = DPLL output
	 */
	write_scc(CTL+base,R11,TRxCBR|TRxCOI|TCRTxCP|RCDPLL);

	/* Compute and load baud rate generator time constant
	 * DPLL needs x32 clock
	 * XTAL is defined in pc100.h to be the crystal clock / (2 * 32)
	 */
	tc = XTAL/(hp->speed) - 2;
	write_scc(CTL+base,R12,tc);
	write_scc(CTL+base,R13,tc >> 8);

	write_scc(CTL+base,R14,SNRZI);	/* Set NRZI mode */
	write_scc(CTL+base,R14,SSBR);	/* Set DPLL source = BR generator */
	write_scc(CTL+base,R14,SEARCH);	/* Enter search mode */
	/* Set baud rate gen source = PCLK, enable baud rate gen */
	write_scc(CTL+base,R14,BRENABL|BRSRC);

	/* Break/abort IE, TX EOM IE, CTS IE, no SYNC/HUNT IE, DCD IE,
	 * no Zero Count IE
	 */
	write_scc(CTL+base,R15,BRKIE|TxUIE|CTSIE|DCDIE);

	restore(i_state);
	if(hp->mode == FULLDUP){
		rts(base,ON);
	} else if(hp->tstate == IDLE){
		rts(base,OFF);
	}
}
/* Attach a PC-100 interface to the system
 * argv[0]: hardware type, must be "pc100"
 * argv[1]: I/O address, e.g., "0x380"
 * argv[2]: vector, e.g., "2"
 * argv[3]: mode, must be:
 *	    "ax25ui" (AX.25 UI frame format)
 *	    "ax25i" (AX.25 I frame format)
 * argv[4]: interface label, e.g., "pc0"
 * argv[5]: receiver packet buffer size in bytes
 * argv[6]: maximum transmission unit, bytes
 * argv[7]: interface speed, e.g, "9600"
 * argv[8]: First IP address, optional (defaults to Ip_addr)
 * argv[9]: Second IP address, optional (defaults to Ip_addr)
 */
int
pc_attach(argc,argv,p)
int argc;
char *argv[];
void *p;
{
	register struct iface *if_pca,*if_pcb;
	struct hdlc *hp;
	int dev;
	char *cp;

	if(Npc >= NPC){
		printf("Too many pc100 controllers\n");
		return -1;
	}
	if(if_lookup(argv[4]) != NULL){
		printf("Interface %s already exists\n",argv[4]);
		return -1;
	}
	if(setencap(NULL,argv[3]) == -1){
		printf("Mode %s unknown for interface %s\n",
			argv[3],argv[4]);
		return -1;
	}
	if(Mycall[0] == '\0'){
		printf("set mycall first\n");
		return -1;
	}
	dev = Npc++;

	/* Initialize hardware-level control structure */
	Pc100[dev].addr = htoi(argv[1]);
	Pc100[dev].vec = atoi(argv[2]);
	if(strchr(argv[2],'c') != NULL)
		Pc100[dev].chain = 1;
	else
		Pc100[dev].chain = 0;

	/* Initialize modems */
	outportb(Pc100[dev].addr + MODEM_CTL,0x22);

	/* Save original interrupt vector */
	Pc100[dev].oldvec = getirq(Pc100[dev].vec);
	/* Set new interrupt vector */
	if(setirq(Pc100[dev].vec,Pchandle[dev]) == -1){
		printf("IRQ %u out of range\n",Pc100[dev].vec);
		Npc--;
		return -1;
	}
	/* Create interface structures and fill in details */
	if_pca = (struct iface *)callocw(1,sizeof(struct iface));
	if_pcb = (struct iface *)callocw(1,sizeof(struct iface));

	if_pca->addr = if_pcb->addr = Ip_addr;
	if(argc > 8)
		if_pca->addr = resolve(argv[8]);

	if(argc > 9)
		if_pcb->addr = resolve(argv[9]);
	if(if_pca->addr == 0 || if_pcb->addr == 0){
		printf(Noipaddr);
		free(if_pca);
		free(if_pcb);
		return -1;
	}
	if_pca->name = strdup(argv[4]);
	if_pcb->name = strdup(argv[4]);
	if_pcb->name[strlen(argv[4]) - 1]++;	/* kludge */
	if_pcb->mtu = if_pca->mtu = atoi(argv[6]);
	if_pca->dev = 2*dev;
	if_pcb->dev = 2*dev + 1;
	if_pcb->stop = if_pca->stop = pc_stop;
	if_pcb->raw = pc_raw;

	setencap(if_pca,argv[3]);
	setencap(if_pcb,argv[3]);
	if(if_pcb->hwaddr == NULL)
		if_pcb->hwaddr = mallocw(AXALEN);
	memcpy(if_pcb->hwaddr,Mycall,AXALEN);

	if_pca->next = if_pcb;
	if_pcb->next = Ifaces;
	Ifaces = if_pca;

	hp = &Hdlc[2*dev+1];
	hp->speed = (uint16)atoi(argv[7]);
	hp->base = Pc100[dev].addr + CHANB;
	hp->bufsiz = atoi(argv[5]);
	hdlcparam(hp);

	hp = &Hdlc[2*dev];
	hp->speed = (uint16)atoi(argv[7]);
	hp->base = Pc100[dev].addr + CHANA;
	hp->bufsiz = atoi(argv[5]);
	hdlcparam(hp);

	/* Clear mask (enable interrupt) in 8259 interrupt controller */
	clrbit(INTMASK,(char)(1<<Pc100[dev].vec));

	cp = if_name(if_pca," tx");
	if_pca->txproc = newproc(cp,512,if_tx,0,if_pca,NULL,0);
	free(cp);
	cp = if_name(if_pcb," tx");
	if_pcb->txproc = newproc(cp,512,if_tx,0,if_pcb,NULL,0);
	free(cp);
	
	return 0;
}
static int
pc_stop(iface)
struct iface *iface;
{
	int dev;

	dev = iface->dev;
	if(dev & 1)
		return 0;
	dev >>= 1;	/* Convert back into PC100 number */
	/* Turn off interrupts */
	maskoff(Pc100[dev].vec);

	/* Restore original interrupt vector */
	setirq(Pc100[dev].vec,Pc100[dev].oldvec);

	/* Force hardware reset */
	write_scc(CTL+Pc100[dev].addr + CHANA,R9,FHWRES);
	return 0;
}
	
/* Send raw packet on PC-100 */
static int
pc_raw(
struct iface *iface,
struct mbuf **bpp
){
	char kickflag;
	struct hdlc *hp;

	dump(iface,IF_TRACE_OUT,*bpp);
	iface->rawsndcnt++;
	iface->lastsent = secclock();
	hp = &Hdlc[iface->dev];
	kickflag = (hp->sndq == NULL);
	enqueue(&hp->sndq,bpp);
	if(kickflag)
		htxint(&Hdlc[iface->dev]);
	return 0;
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产日韩欧美一区二区三区乱码 | 欧美一区永久视频免费观看| 国产不卡视频在线播放| 不卡影院免费观看| 国产精品一卡二| 六月婷婷色综合| 免费三级欧美电影| 青草国产精品久久久久久| 免费成人av在线| 美女视频免费一区| 国产精品1区2区3区在线观看| 琪琪久久久久日韩精品| 久久99热这里只有精品| 国产一区二区电影| 99麻豆久久久国产精品免费优播| av成人免费在线观看| 色域天天综合网| 欧美日韩在线三区| 91精品福利在线一区二区三区| 欧美一区二区三区白人| 欧美v亚洲v综合ⅴ国产v| 久久亚洲一级片| 欧美国产精品久久| 亚洲欧美激情一区二区| 亚洲国产日韩综合久久精品| 日韩精品成人一区二区在线| 久草在线在线精品观看| 99久久精品免费看| 欧美日韩大陆一区二区| 久久免费美女视频| 亚洲精品中文字幕在线观看| 日韩精品一二区| 国产成人精品亚洲777人妖| 不卡电影一区二区三区| 91精品视频网| 国产视频在线观看一区二区三区| 一区二区三区中文在线观看| 蜜桃视频在线一区| 91欧美一区二区| 日韩色视频在线观看| 亚洲日本在线视频观看| 乱一区二区av| 欧美色大人视频| 国产精品久久久久婷婷| 日韩成人午夜精品| 91免费观看视频| 久久久久免费观看| 午夜精品影院在线观看| 成人免费精品视频| 久久综合九色综合97婷婷女人 | 久久久久九九视频| 亚洲国产精品久久人人爱| 国产精品69毛片高清亚洲| 在线观看成人小视频| 日本一区二区成人| 国产在线看一区| 欧美一区二区黄色| 亚洲影视在线播放| 91免费观看视频| 国产精品美女久久久久久2018 | 成人免费毛片app| 精品美女在线观看| 亚洲成人av免费| 91久久精品一区二区三区| 中文字幕免费不卡| 九九热在线视频观看这里只有精品| 精品视频123区在线观看| 亚洲黄色录像片| 成人ar影院免费观看视频| 久久久久久久久久久电影| 久久 天天综合| 日韩女同互慰一区二区| 蜜臀久久久久久久| 欧美一区二区三区啪啪| 日韩电影免费一区| 欧美一区2区视频在线观看| 首页国产欧美久久| 88在线观看91蜜桃国自产| 亚洲成在人线免费| 欧美一区二视频| 五月综合激情网| 欧美日韩不卡在线| 丝袜亚洲精品中文字幕一区| 欧美日韩性生活| 日韩精品久久久久久| 日韩美女一区二区三区四区| 精品一区二区三区在线视频| 26uuu亚洲综合色| 国产精品影视网| 国产精品久久久久久久久搜平片| 成人免费视频免费观看| 一区二区理论电影在线观看| 欧美色图激情小说| 免费三级欧美电影| 国产精品五月天| 一本一本久久a久久精品综合麻豆| 一区二区三区在线观看视频| 欧美日韩精品一区视频| 国产呦精品一区二区三区网站| 国产日本欧美一区二区| 97久久人人超碰| 婷婷久久综合九色国产成人 | 99精品视频一区二区| 一区二区成人在线| 欧美大片在线观看| 色综合久久久久综合99| 日一区二区三区| 亚洲国产精品99久久久久久久久| 91电影在线观看| 国产一区视频导航| 一区二区三区四区乱视频| 欧美成人vps| 91看片淫黄大片一级| 人人爽香蕉精品| 中文字幕视频一区二区三区久| 欧美丝袜丝nylons| 成人在线一区二区三区| 无码av免费一区二区三区试看 | 国产日韩亚洲欧美综合| 在线观看免费视频综合| 国产在线精品视频| 视频一区二区不卡| 亚洲人成网站在线| 久久久美女毛片| 在线播放日韩导航| 99国产欧美久久久精品| 国产乱码精品1区2区3区| 日韩经典一区二区| 自拍偷拍欧美激情| 欧美高清在线一区二区| 日韩美女主播在线视频一区二区三区| 欧洲精品在线观看| jiyouzz国产精品久久| 国产乱人伦精品一区二区在线观看| 亚洲一区中文在线| 日韩理论片网站| 国产精品理伦片| 久久久精品黄色| 欧美精品一区二区三区高清aⅴ| 欧美日韩久久久久久| 91传媒视频在线播放| 色婷婷av一区二区三区大白胸| 成人永久免费视频| 国产91丝袜在线播放九色| 久久国产精品72免费观看| 秋霞电影一区二区| 日韩激情av在线| 婷婷丁香激情综合| 亚洲大尺度视频在线观看| 亚洲国产精品一区二区久久| 一区二区三区高清| 亚洲国产裸拍裸体视频在线观看乱了| 亚洲欧美色一区| 亚洲精品国产品国语在线app| 亚洲欧美另类图片小说| 亚洲一区二区三区不卡国产欧美 | 国内精品国产三级国产a久久| 老司机精品视频导航| 久久精品国产在热久久| 精品一区二区三区在线视频| 久久国产精品99精品国产 | 综合电影一区二区三区| 国产精品久久看| 亚洲欧洲综合另类| 亚洲一区影音先锋| 毛片一区二区三区| 国产美女在线观看一区| 99视频一区二区| 色婷婷av一区二区| 欧美日本在线播放| 精品精品国产高清a毛片牛牛| 久久久不卡网国产精品二区| 欧美国产激情二区三区| 亚洲女女做受ⅹxx高潮| 夜夜揉揉日日人人青青一国产精品 | 欧美午夜在线一二页| 在线播放国产精品二区一二区四区 | 亚洲一区二区精品3399| 免费不卡在线观看| 成人一区二区三区| 欧美亚洲动漫精品| 26uuu久久综合| 亚洲视频在线一区二区| 秋霞电影一区二区| 成人精品国产福利| 欧美精品在欧美一区二区少妇| 精品国产一区二区在线观看| 中文字幕在线播放不卡一区| 亚洲一区二区欧美激情| 国产精品一区二区在线观看不卡 | 国产精品免费av| 日韩精品亚洲一区| 99精品在线免费| 精品国产伦理网| 一区二区三区不卡在线观看| 国内成+人亚洲+欧美+综合在线| 91亚洲男人天堂| 日韩三级视频中文字幕| 亚洲同性gay激情无套| 麻豆精品久久精品色综合|