plan 9 kernel history: overview | file list | diff list

1992/0904/pc/io.h (diff list | history)

1992/0904/sys/src/9/pc/io.h:1,261992/0922/sys/src/9/pc/io.h:1,120 (short | long | prev | next)
Add generic ethernet structures.
rsc Fri Mar 4 12:44:25 2005
1991/0703    
/* 
1991/0731    
 *  programmable interrupt vectors (for the 8259's) 
1991/0703    
 */ 
1991/0704    
enum 
{ 
1991/1112    
	Bptvec=		3,		/* breakpoints */ 
1991/0906    
	Mathemuvec=	7,		/* math coprocessor emulation interrupt */ 
	Mathovervec=	9,		/* math coprocessor overrun interrupt */ 
1991/0912    
	Matherr1vec=	16,		/* math coprocessor error interrupt */ 
1991/0710    
	Faultvec=	14,		/* page fault */ 
1991/0905    
 
1991/0904    
	Int0vec=	24,		/* first 8259 */ 
1991/0731    
	 Clockvec=	Int0vec+0,	/*  clock interrupts */ 
	 Kbdvec=	Int0vec+1,	/*  keyboard interrupts */ 
1991/0810    
	 Uart1vec=	Int0vec+3,	/*  modem line */ 
1991/0811    
	 Uart0vec=	Int0vec+4,	/*  serial line */ 
1991/0731    
	 Floppyvec=	Int0vec+6,	/*  floppy interrupts */ 
1991/1127    
	 Parallelvec=	Int0vec+7,	/*  parallel port interrupts */ 
1992/0904    
	Int1vec=	Int0vec+8, 
	 Ethervec=	Int0vec+10,	/*  ethernet interrupt */ 
	 Mousevec=	Int0vec+12,	/*  mouse interrupt */ 
	 Matherr2vec=	Int0vec+13,	/*  math coprocessor */ 
	 Hardvec=	Int0vec+14,	/*  hard disk */ 
1991/0910    
 
	Syscallvec=	64, 
1991/0704    
}; 
1992/0922    
 
typedef struct EtherHw EtherHw; 
typedef struct EtherBuf EtherBuf; 
typedef struct EtherType EtherType; 
typedef struct EtherCtlr EtherCtlr; 
 
struct EtherHw { 
	int	(*reset)(EtherCtlr*); 
	void	(*init)(EtherCtlr*); 
	void	(*mode)(EtherCtlr*, int); 
	void	(*online)(EtherCtlr*, int); 
	void	(*receive)(EtherCtlr*); 
	void	(*transmit)(EtherCtlr*); 
	void	(*intr)(EtherCtlr*); 
	void	(*tweak)(EtherCtlr*); 
	int	addr;			/* interface address */ 
	uchar	*ram;			/* interface shared memory address */ 
	int	bt16;			/* true if a 16 bit interface */ 
	int	irq;			/* interrupt level */ 
	int	size; 
	uchar	tstart; 
	uchar	pstart; 
	uchar	pstop; 
}; 
 
struct EtherBuf { 
	uchar	owner; 
	uchar	busy; 
	ushort	len; 
	uchar	pkt[sizeof(Etherpkt)]; 
}; 
 
enum { 
	Host		= 0,		/* buffer owned by host */ 
	Interface	= 1,		/* buffer owned by interface */ 
 
	NType		= 9,		/* types/interface */ 
}; 
 
/* 
 * one per ethernet packet type 
 */ 
struct EtherType { 
	QLock; 
	Netprot;			/* stat info */ 
	int	type;			/* ethernet type */ 
	int	prom;			/* promiscuous mode */ 
	Queue	*q; 
	int	inuse; 
	EtherCtlr *ctlr; 
}; 
 
/* 
 * per ethernet 
 */ 
struct EtherCtlr { 
	QLock; 
 
	EtherHw	*hw; 
	int	present; 
 
	ushort	nrb;		/* number of software receive buffers */ 
	ushort	ntb;		/* number of software transmit buffers */ 
	EtherBuf *rb;		/* software receive buffers */ 
	EtherBuf *tb;		/* software transmit buffers */ 
 
	uchar	ea[6];		/* ethernet address */ 
	uchar	ba[6];		/* broadcast address */ 
 
	Rendez	rr;		/* rendezvous for a receive buffer */ 
	ushort	rh;		/* first receive buffer belonging to host */ 
	ushort	ri;		/* first receive buffer belonging to interface */	 
 
	Rendez	tr;		/* rendezvous for a transmit buffer */ 
	QLock	tlock;		/* semaphore on th */ 
	ushort	th;		/* first transmit buffer belonging to host */	 
	ushort	ti;		/* first transmit buffer belonging to interface */	 
 
	EtherType type[NType]; 
	uchar	prom;		/* true if promiscuous mode */ 
	uchar	kproc;		/* true if kproc started */ 
	char	name[NAMELEN];	/* name of kproc */ 
	Network	net; 
 
	Queue	lbq;		/* software loopback packet queue */ 
 
	int	inpackets; 
	int	outpackets; 
	int	crcs;		/* input crc errors */ 
	int	oerrs;		/* output errors */ 
	int	frames;		/* framing errors */ 
	int	overflows;	/* packet overflows */ 
	int	buffs;		/* buffering errors */ 
}; 


source code copyright © 1990-2005 Lucent Technologies; see license
Plan 9 distribution
comments to russ cox (rsc@swtch.com)