1 typedef struct RingBuf { 2 uchar owner; 3 uchar unused; 4 ushort len; 5 uchar pkt[sizeof(Etherpkt)]; 6 } RingBuf; 7 8 enum { 9 Host = 0, /* buffer owned by host */ 10 Interface = 1, /* buffer owned by card */ 11 12 Nrb = 32, /* default number of receive buffers */ 13 Ntb = 8, /* default number of transmit buffers */ 14 }; 15 16 /* 17 * a parsed .ini line 18 */ 19 #define ISAOPTLEN 32 20 #define NISAOPT 8 21 #define NAMELEN 28 22 23 typedef struct ISAConf { 24 char type[NAMELEN]; 25 ulong port; 26 // ulong irq; 27 ulong mem; 28 ulong size; 29 uchar ea[6]; 30 31 int nopt; 32 char opt[NISAOPT][ISAOPTLEN]; 33 } ISAConf; 34 35 #define CONFADDR (0x2200) /* above ppc vectors */ 36 #define BOOTLINE ((char*)CONFADDR) 37 38 typedef struct Ether Ether; 39 struct Ether { 40 ISAConf; /* hardware info */ 41 ushort ctlrno; 42 ushort state; /* 0: unfound, 1: found, 2: attaching */ 43 44 void (*attach)(Ether*); /* filled in by reset routine */ 45 void (*transmit)(Ether*); 46 int (*interrupt)(ulong bit); 47 void (*detach)(Ether*); 48 void *ctlr; 49 50 ushort nrb; /* number of software receive buffers */ 51 ushort ntb; /* number of software transmit buffers */ 52 RingBuf *rb; /* software receive buffers */ 53 RingBuf *tb; /* software transmit buffers */ 54 55 ushort rh; /* first receive buffer belonging to host */ 56 ushort ri; /* first receive buffer belonging to card */ 57 58 ushort th; /* first transmit buffer belonging to host */ 59 ushort ti; /* first transmit buffer belonging to card */ 60 ushort tbusy; /* transmitter is busy */ 61 ushort mbps; /* zero means link down */ 62 }; 63 64 extern void etherrloop(Ether*, Etherpkt*, long); 65 extern void addethercard(char*, int(*)(Ether*)); 66 67 #define NEXT(x, l) (((x)+1)%(l)) 68 #define PREV(x, l) (((x) == 0) ? (l)-1: (x)-1) 69