summaryrefslogtreecommitdiff
path: root/os/boot/pc/etherif.h
diff options
context:
space:
mode:
Diffstat (limited to 'os/boot/pc/etherif.h')
-rw-r--r--os/boot/pc/etherif.h46
1 files changed, 46 insertions, 0 deletions
diff --git a/os/boot/pc/etherif.h b/os/boot/pc/etherif.h
new file mode 100644
index 00000000..522fd9b0
--- /dev/null
+++ b/os/boot/pc/etherif.h
@@ -0,0 +1,46 @@
+typedef struct RingBuf {
+ uchar owner;
+ uchar unused;
+ ushort len;
+ uchar pkt[sizeof(Etherpkt)];
+} RingBuf;
+
+enum {
+ Host = 0, /* buffer owned by host */
+ Interface = 1, /* buffer owned by card */
+
+ Nrb = 32, /* default number of receive buffers */
+ Ntb = 8, /* default number of transmit buffers */
+};
+
+typedef struct Ether Ether;
+struct Ether {
+ ISAConf; /* hardware info */
+ int ctlrno;
+ int state;
+ int tbdf;
+
+ void (*attach)(Ether*); /* filled in by reset routine */
+ void (*transmit)(Ether*);
+ void (*interrupt)(Ureg*, void*);
+ void (*detach)(Ether*);
+ void *ctlr;
+
+ ushort nrb; /* number of software receive buffers */
+ ushort ntb; /* number of software transmit buffers */
+ RingBuf *rb; /* software receive buffers */
+ RingBuf *tb; /* software transmit buffers */
+
+ ushort rh; /* first receive buffer belonging to host */
+ ushort ri; /* first receive buffer belonging to card */
+
+ ushort th; /* first transmit buffer belonging to host */
+ ushort ti; /* first transmit buffer belonging to card */
+ int tbusy; /* transmitter is busy */
+};
+
+extern void etherrloop(Ether*, Etherpkt*, long);
+extern void addethercard(char*, int(*)(Ether*));
+
+#define NEXT(x, l) (((x)+1)%(l))
+#define PREV(x, l) (((x) == 0) ? (l)-1: (x)-1)