UbixOS  2.0
lnc.c
Go to the documentation of this file.
1 /*-
2  * Copyright (c) 2002-2018 The UbixOS Project.
3  * All rights reserved.
4  *
5  * This was developed by Christopher W. Olsen for the UbixOS Project.
6  *
7  * Redistribution and use in source and binary forms, with or without modification, are permitted
8  * provided that the following conditions are met:
9  *
10  * 1) Redistributions of source code must retain the above copyright notice, this list of
11  * conditions, the following disclaimer and the list of authors.
12  * 2) Redistributions in binary form must reproduce the above copyright notice, this list of
13  * conditions, the following disclaimer and the list of authors in the documentation and/or
14  * other materials provided with the distribution.
15  * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to
16  * endorse or promote products derived from this software without specific prior written
17  * permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
20  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
22  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
24  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
26  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  */
28 
29 #include <pci/lnc.h>
30 #include <sys/io.h>
31 #include <sys/types.h>
32 #include <sys/idt.h>
33 #include <sys/gdt.h>
34 #include <lib/kmalloc.h>
35 #include <lib/kprintf.h>
36 #include <sys/video.h>
37 #include <isa/8259.h>
38 #include <net/net.h>
39 #include <net/netif.h>
40 #include <ubixos/spinlock.h>
41 
43 
44 struct lncInfo *lnc = 0x0;
45 
46 //static struct spinLock lnc_intSpinLock = SPIN_LOCK_INITIALIZER;
47 
48 static const char * const nicIdent[] = { "Unknown", "BICC", "NE2100", "DEPCA", "CNET98S" };
49 
50 static const char * const icIdent[] = { "Unknown", "LANCE", "C-LANCE", "PCnet-ISA", "PCnet-ISA+", "PCnet-ISA II", "PCnet-32 VL-Bus", "PCnet-PCI", "PCnet-PCI II", "PCnet-FAST", "PCnet-FAST+", "PCnet-Home", };
51 
52 struct nicBuffer *tmpBuf;
53 
54 void lnc_writeCSR(struct lncInfo *lnc, uint16_t port, uint16_t val) {
55  outportWord(lnc->ioAddr + RAP, port);
56  outportWord(lnc->ioAddr + RDP, val);
57 }
58 
59 void lnc_writeCSR32(struct lncInfo *lnc, uint32_t port, uint32_t val) {
60  outportDWord(lnc->ioAddr + RAP32, port);
61  outportDWord(lnc->ioAddr + RDP32, val);
62 }
63 
65  outportWord(lnc->ioAddr + RAP, port);
66  return (inportWord(lnc->ioAddr + RDP));
67 }
68 
70  outportDWord(lnc->ioAddr + RAP32, port);
71  return (inportDWord(lnc->ioAddr + RDP32));
72 }
73 
74 void lnc_writeBCR(struct lncInfo *lnc, uint16_t port, uint16_t val) {
75  outportWord(lnc->ioAddr + RAP, port);
76  outportWord(lnc->ioAddr + BDP, val);
77 }
78 
79 void lnc_writeBCR32(struct lncInfo *lnc, uint32_t port, uint32_t val) {
80  outportDWord(lnc->ioAddr + RAP32, port);
81  outportDWord(lnc->ioAddr + BDP32, val);
82 }
83 
85  outportWord(lnc->ioAddr + RAP, port);
86  return (inportWord(lnc->ioAddr + BDP));
87 }
88 
90  outportDWord(lnc->ioAddr + RAP32, port);
91  return (inportDWord(lnc->ioAddr + BDP32));
92 }
93 
94 int initLNC() {
95  int i = 0x0;
96 
97  char data[64] = "abcDEFghiJKLmnoPQRstuVWXyz";
98 
99  lnc = kmalloc(sizeof(struct lncInfo));
100  memset(lnc, 0x0, sizeof(struct lncInfo));
101 
102  lnc->bufferSize = 1548;
103  lnc->ioAddr = 0xD020;
104 
105  lnc->nic.ic = lnc_probe(lnc);
106 
107  //kprintf("ID: %i\n", lnc->nic.ic);
108 
109  if ((lnc->nic.ic > 0) && (lnc->nic.ic >= PCnet_32)) {
110  lnc->nic.ident = NE2100;
112 
113  lnc->nrdre = NRDRE;
114  lnc->ntdre = NTDRE;
115 
116  /* Extract MAC address from PROM */
117  for (i = 0; i < ETHER_ADDR_LEN; i++) {
118  lnc->arpcom.ac_enaddr[i] = inportByte(lnc->ioAddr + i);
119  kprintf("[0x%X]", lnc->arpcom.ac_enaddr[i]);
120  }
121  }
122  else {
123  kprintf("LNC Init Error\n");
124  return (-1);
125  }
126 
127  lncAttach(lnc, 0);
128 
129  i = lnc_getMode(lnc);
130  if (i == MODE_16)
131  kprintf("16 Bit");
132  else if (i == MODE_32)
133  kprintf("32 Bit");
134  else
135  kprintf("Invalid Mode: [%i]", i);
136 
138 
139  uint32_t iW = 0;
140 
141  iW = lnc_readBCR32(lnc, 0x2);
142  iW |= 0x2;
143  lnc_writeBCR32(lnc, 0x2, iW);
144  //kprintf("BCR2: [0x%X]", lnc_readBCR32(lnc, 0x2));
145 
146  lnc->init.mode = 0x0;
147 
148  lnc->init.padr[0] = lnc->arpcom.ac_enaddr[0];
149  lnc->init.padr[1] = lnc->arpcom.ac_enaddr[1];
150  lnc->init.padr[2] = lnc->arpcom.ac_enaddr[2];
151  lnc->init.padr[3] = lnc->arpcom.ac_enaddr[3];
152  lnc->init.padr[4] = lnc->arpcom.ac_enaddr[4];
153  lnc->init.padr[5] = lnc->arpcom.ac_enaddr[5];
154 
156  lnc->init.rlen = 3 << 4;
157  //kprintf("Virt Addr: 0x%X, Real Addr: 0x%X", lnc->rxRing, vmm_getRealAddr(lnc->rxRing));
158 
160  lnc->init.tlen = 3 << 4;
161  //kprintf("Virt Addr: 0x%X, Real Addr: 0x%X", lnc->txRing, vmm_getRealAddr(lnc->txRing));
162 
163  //kprintf("Virt Addr: 0x%X, Real Addr: 0x%X", &lnc->init, vmm_getRealAddr(&lnc->init));
164 
165  iW = vmm_getRealAddr(&lnc->init);
166 
167  lnc_writeCSR32(lnc, CSR1, iW & 0xFFFF);
168  lnc_writeCSR32(lnc, CSR2, (iW >> 16) & 0xFFFF);
169 
170  lnc_writeCSR32(lnc, CSR3, 0);
172 
173  for (i = 0; i < 1000; i++)
174  if (lnc_readCSR32(lnc, CSR0) & IDON)
175  break;
176 
177  if (lnc_readCSR32(lnc, CSR0) & IDON) {
178  setVector(&lnc_isr, sVec + 0x1, (dInt + dPresent + dDpl3));
179  irqEnable(2);
180  //irqEnable(0x9);
182  }
183  else {
184  kprintf("LNC: init Error\n");
185  return (-1);
186  }
187 
188  return (0);
189 }
190 
191 int lnc_probe(struct lncInfo *lnc) {
192 
193  uInt32 chipId = 0x0;
194  int type = 0x0;
195 
196  if ((type = lanceProbe(lnc))) {
197  //kprintf("Type: [0x%X]", type);
198  chipId = lnc_readCSR(lnc, CSR89);
199  chipId <<= 16;
200  chipId |= lnc_readCSR(lnc, CSR88);
201  if (chipId & AMD_MASK) {
202  chipId >>= 12;
203  switch (chipId & PART_MASK) {
204  case Am79C960:
205  return (PCnet_ISA);
206  case Am79C961:
207  return (PCnet_ISAplus);
208  case Am79C961A:
209  return (PCnet_ISA_II);
210  case Am79C965:
211  return (PCnet_32);
212  case Am79C970:
213  return (PCnet_PCI);
214  case Am79C970A:
215  return (PCnet_PCI_II);
216  case Am79C971:
217  return (PCnet_FAST);
218  case Am79C972:
219  case Am79C973:
220  return (PCnet_FASTplus);
221  case Am79C978:
222  return (PCnet_Home);
223  default:
224  break;
225  }
226  }
227  }
228  return (type);
229 }
230 
231 int lanceProbe(struct lncInfo *lnc) {
232  uInt16 inW = 0;
233 
235 
236  inW = inportWord(lnc->ioAddr + RDP);
237 
238  if ((inW & CSR0_STOP) && !(lnc_readCSR(lnc, CSR3))) {
239 
241 
242  if (lnc_readCSR(lnc, CSR0) & INEA) {
243  return (C_LANCE);
244  }
245  else {
246  return (LANCE);
247  }
248  }
249  else {
250  return (UNKNOWN);
251  }
252 }
253 
254 void lnc_INT() {
255  uint16_t csr0 = 0x0;
256 
257  //kprintf("\nINTR\n");
258  //while ((csr0 = lnc_readCSR32(lnc, CSR0)) & INTR) {
259  //kprintf("CSR0: [0x%X]\n", csr0);
260  if (csr0 & ERR) {
261  kprintf("Error: [0x%X]\n", csr0);
262  }
263  if (csr0 & RINT) {
264  asm("nop");
265  //lnc_rxINT();
266  }
267  if (csr0 & TINT) {
268  asm("nop");
269  //kprintf("TINT");
270  //lnc_txINT();
271  }
272  // kprintf("CSR0.1: [0x%X]\n", lnc_readCSR32(lnc, CSR0));
273 // }
274  lnc_writeCSR32(lnc, CSR0, 0x7940); //csr0);
275 // kprintf("INT DONE");
276 }
277 
278 void lnc_thread() {
279  int i = 0;
280 
281  if (tmpBuf == 0x0) {
282  tmpBuf = (struct nicBuffer *) kmalloc(sizeof(struct nicBuffer));
283  memset(tmpBuf, 0x0, sizeof(struct nicBuffer));
284  }
285  else {
286  memset(tmpBuf, 0x0, sizeof(struct nicBuffer));
287  }
288 
289  while (1) {
290  while (lnc_driverOwnsRX(lnc)) {
291  //uint16_t plen = 0 + (uint16_t)lnc->rxRing[lnc->rxPtr].md[2];
292  int plen = (lnc->rxRing[lnc->rxPtr].md[2] & 0x0fff) - 4;
293  /*
294  if (plen > 0)
295  kprintf("plen.0: [0x%X]", plen);
296  */
297 
298  tmpBuf->length = plen;
299  tmpBuf->buffer = (void *) (lnc->rxBuffer + (lnc->rxPtr * lnc->bufferSize)); //(char *)kmalloc(length);
300 
301  // kprintf("RINT2\n");
303  //kprintf("RINT3\n");
304  //kprintf("RINT-LOOP[%i][0x%X][0x%X]", lnc->rxPtr,lnc->rxRing[lnc->rxPtr].md[1],plen);
305  lnc->rxRing[lnc->rxPtr].md[1] = 0x80;
306  //kprintf("RINT-LOOP[%i][0x%X][0x%X]", lnc->rxPtr,lnc->rxRing[lnc->rxPtr].md[1],plen);
308  //kprintf("RINT-LOOP[%i][0x%X][0x%X]\n", lnc->rxPtr,lnc->rxRing[lnc->rxPtr].md[1],plen);
309  }
310 // kprintf("RINT-DONE[%i][0x%X]\n", lnc->rxPtr,lnc->rxRing[lnc->rxPtr].md[1]);
311 
312  sched_yield();
313  }
314 }
315 
316 void lnc_rxINT() {
317  int i = 0;
318 
319  if (tmpBuf == 0x0) {
320  tmpBuf = (struct nicBuffer *) kmalloc(sizeof(struct nicBuffer));
321  memset(tmpBuf, 0x0, sizeof(struct nicBuffer));
322  }
323  else {
324  memset(tmpBuf, 0x0, sizeof(struct nicBuffer));
325  }
326 
327  while (lnc_driverOwnsRX(lnc)) {
328  //uint16_t plen = 0 + (uint16_t)lnc->rxRing[lnc->rxPtr].md[2];
329  int plen = (lnc->rxRing[lnc->rxPtr].md[2] & 0x0fff) - 4;
330  /*
331  if (plen > 0)
332  kprintf("plen.0: [0x%X]", plen);
333  */
334 
335  tmpBuf->length = plen;
336  tmpBuf->buffer = (void *) (lnc->rxBuffer + (lnc->rxPtr * lnc->bufferSize)); //(char *)kmalloc(length);
337 
338  // kprintf("RINT2\n");
339  //ethernetif_input(netif_default);
340  //kprintf("RINT3\n");
341  //kprintf("RINT-LOOP[%i][0x%X][0x%X]", lnc->rxPtr,lnc->rxRing[lnc->rxPtr].md[1],plen);
342  lnc->rxRing[lnc->rxPtr].md[1] = 0x80;
343  //kprintf("RINT-LOOP[%i][0x%X][0x%X]", lnc->rxPtr,lnc->rxRing[lnc->rxPtr].md[1],plen);
345  //kprintf("RINT-LOOP[%i][0x%X][0x%X]\n", lnc->rxPtr,lnc->rxRing[lnc->rxPtr].md[1],plen);
346  }
347  // kprintf("RINT-DONE[%i][0x%X]\n", lnc->rxPtr,lnc->rxRing[lnc->rxPtr].md[1]);
348 //while(1);
349 
350 }
351 
352 void lnc_txINT() {
353  uint16_t status = 0x0;
354 
355  kprintf("TINT\n");
356  status = lnc->txRing[lnc->txPtr].md[1] + (lnc->txRing[lnc->txPtr].md[1] << 16);
357  kprintf("Status: [0x%X]\n", status);
358 
359  while (!lnc_driverOwnsTX(lnc)) {
360  status = lnc->txRing[lnc->txPtr].md[1] + (lnc->txRing[lnc->txPtr].md[1] << 16);
361  kprintf("md[1]: 0x%X(%i)[0x%X]\n", lnc->txRing[lnc->txPtr].md[1], lnc->txPtr, status);
362  lnc->txRing[lnc->txPtr].md[1] = 0x0;
364  }
365  kprintf("TINT-DONE\n");
366 }
367 
368 void lncInt() {
369  while (1) {
370  kprintf("Finished!!!\n");
371  }
372  outportByte(0x20, 0x20);
373  return;
374  uInt16 csr0 = 0x0;
375  while ((csr0 = inportWord(lnc->ioAddr + RDP)) & INTR) {
376  outportWord(lnc->ioAddr + RDP, csr0);
377  kprintf("CSR0: [0x%X]\n", csr0);
378  if (csr0 & ERR) {
379  kprintf("Error: [0x%X]\n", csr0);
380  }
381  if (csr0 & RINT) {
382  kprintf("RINT\n");
383  }
384  if (csr0 & TINT) {
385  kprintf("TINT\n");
386  }
387  outportWord(lnc->ioAddr + RDP, csr0);
388  kprintf("CSR0: [0x%X]\n", csr0);
389  }
390  kprintf("Finished!!!\n");
391  return;
392 }
393 
394 asm(
395  ".globl lnc_isr \n"
396  "lnc_isr: \n"
397  " pusha \n" /* Save all registers */
398  " push %ss \n"
399  " push %ds \n"
400  " push %es \n"
401  " push %fs \n"
402  " push %gs \n"
403  " call lnc_INT \n"
404  " mov $0xA0,%dx \n"
405  " mov $0x20,%ax \n"
406  " outb %al,%dx \n"
407  " mov $0x20,%dx \n"
408  " mov $0x20,%ax \n"
409  " outb %al,%dx \n"
410  " pop %gs \n"
411  " pop %fs \n"
412  " pop %es \n"
413  " pop %ds \n"
414  " pop %ss \n"
415  " popa \n"
416  " iret \n" /* Exit interrupt */
417 );
418 
419 int lncAttach(struct lncInfo *lnc, int unit) {
420  int i = 0;
421  uint32_t lncSize = 0x0;
422  uint16_t bcnt = 0x0;
423 
424  /* Initialize rxRing */
425  lncSize = (NDESC(lnc->nrdre) * sizeof(struct hostRingEntry));
426  //kprintf("rxRing Size: [%i]", lncSize);
427  lnc->rxRing = kmalloc(lncSize);
428 
429  if (!lnc->rxRing) {
430  kprintf("lnc%d: Couldn't allocate memory for rxRing\n", unit);
431  return (-1);
432  }
433 
434  memset(lnc->rxRing, 0x0, lncSize);
435 
436  /* Initialize rxBuffer */
437  lncSize = (NDESC(lnc->nrdre) * lnc->bufferSize);
438  //kprintf("rxBuffer Size: [%i]\n", lncSize);
439  lnc->rxBuffer = kmalloc(lncSize);
440  if (!lnc->rxBuffer) {
441  kprintf("lnc%d: Couldn't allocate memory for rXBuffer\n", unit);
442  return (-1);
443  }
444  memset(lnc->rxBuffer, 0x0, lncSize);
445 
446  /* Setup the RX Ring */
447  for (i = 0; i < NDESC(lnc->nrdre); i++) {
449  bcnt = (uint16_t) (-lnc->bufferSize);
450  bcnt &= 0x0FFF;
451  bcnt |= 0xF000;
452  //kprintf("rxR[%i].addr = 0x%X, BCNT 0x%X", i, lnc->rxRing[i].addr,bcnt);
453  lnc->rxRing[i].bcnt = bcnt;
454  lnc->rxRing[i].md[1] = 0x80;
455  }
456 
457  /* Initialize txRing */
458  lncSize = (NDESC(lnc->ntdre) * sizeof(struct hostRingEntry));
459  //kprintf("txRing Size: [%i]", lncSize);
460  lnc->txRing = kmalloc(lncSize);
461 
462  if (!lnc->txRing) {
463  kprintf("lnc%d: Couldn't allocate memory for txRing\n", unit);
464  return (-1);
465  }
466 
467  memset(lnc->txRing, 0x0, lncSize);
468 
469  /* Initialize txBuffer */
470  lncSize = (NDESC(lnc->ntdre) * lnc->bufferSize);
471  //kprintf("txBuffer Size: [%i]\n", lncSize);
472  lnc->txBuffer = kmalloc(lncSize);
473  if (!lnc->txBuffer) {
474  kprintf("lnc%d: Couldn't allocate memory for txBuffer\n", unit);
475  return (-1);
476  }
477  memset(lnc->txBuffer, 0x0, lncSize);
478 
479  /* Setup the TX Ring */
480  for (i = 0; i < NDESC(lnc->ntdre); i++) {
482  bcnt = (uint16_t) (-lnc->bufferSize);
483  bcnt &= 0x0FFF;
484  bcnt |= 0xF000;
485  //kprintf("txR[%i].addr = 0x%X, BCNT 0x%X", i, lnc->txRing[i].addr,bcnt);
486  lnc->txRing[i].bcnt = bcnt;
487  }
488 
489  /* MrOlsen 2017-12-16
490  if (lnc->nic.memMode != SHMEM)
491  lncMemSize += sizeof(struct initBlock) + (sizeof(struct mds) * (NDESC(lnc->nrdre) + NDESC(lnc->ntdre))) + MEM_SLEW;
492  if (lnc->nic.memMode == DMA_FIXED)
493  lncMemSize += (NDESC(lnc->nrdre) * RECVBUFSIZE) + (NDESC(lnc->ntdre) * TRANSBUFSIZE);
494  */
495 
496  if (lnc->nic.memMode != SHMEM)
497  if (lnc->nic.ic < PCnet_32)
498  kprintf("ISA Board\n");
499  else
500  kprintf("PCI Board\n");
501 
502  lnc->nic.mode = NORMAL;
503 
504  kprintf("lnc%d: ", unit);
505  if (lnc->nic.ic == LANCE || lnc->nic.ic == C_LANCE)
506  kprintf("%s (%s)", nicIdent[lnc->nic.ident], icIdent[lnc->nic.ic]);
507  else
508  kprintf("%s", icIdent[lnc->nic.ic]);
509 
510  kprintf(" address %x:%x:%x:%x:%x:%x\n", lnc->arpcom.ac_enaddr[0], lnc->arpcom.ac_enaddr[1], lnc->arpcom.ac_enaddr[2], lnc->arpcom.ac_enaddr[3], lnc->arpcom.ac_enaddr[4], lnc->arpcom.ac_enaddr[5]);
511  return (1);
512 }
513 
515  return (lnc->txRing[lnc->txPtr].md[1] & 0x80) == 0;
516 }
517 
519  return (lnc->rxRing[lnc->rxPtr].md[1] & 0x80) == 0;
520 }
521 
522 int lnc_nextTxPtr(struct lncInfo *lnc) {
523  int ret = lnc->txPtr + 1;
524 
525  if (ret == NDESC(lnc->ntdre)) {
526  ret = 0;
527  }
528 
529  lnc->txPtr = ret;
530 
531  return (0);
532 }
533 
534 int lnc_nextRxPtr(struct lncInfo *lnc) {
535  int ret = lnc->rxPtr + 1;
536 
537  if (ret == NDESC(lnc->nrdre)) {
538  ret = 0;
539  }
540 
541  lnc->rxPtr = ret;
542 
543  return (0);
544 }
545 
546 int lnc_sendPacket(struct lncInfo *lnc, void *packet, size_t len, uint8_t *dest) {
547  //kprintf("SEND PACKET1![%i]\n", lnc->txPtr);
548  if (!lnc_driverOwnsTX(lnc)) {
549  kpanic("NO TX BUFFERS");
550  return (0);
551  }
552 
553  //kprintf("SEND PACKET2![%i]\n", lnc->txPtr);
554 
555  memcpy((void *) (lnc->txBuffer + (lnc->txPtr * lnc->bufferSize)), packet, len);
556 
557  lnc->txRing[lnc->txPtr].md[1] |= 0x2;
558  lnc->txRing[lnc->txPtr].md[1] |= 0x1;
559 
560  uint16_t bcnt = (uint16_t) (-len);
561  bcnt &= 0xFFF;
562  bcnt |= 0xF000;
563  lnc->txRing[lnc->txPtr].bcnt = bcnt;
564 
565  lnc->txRing[lnc->txPtr].md[1] |= 0x80;
566 
568 
569  //kprintf("SEND PACKET3![%i]\n", lnc->txPtr);
570  return (len);
571 }
572 
573 int lnc_getMode(struct lncInfo *lnc) {
574  lnc_reset32(lnc);
575  if (lnc_readCSR32(lnc, CSR0) == CSR0_STOP)
576  return MODE_32;
577 
578  lnc_reset(lnc);
579  if (lnc_readCSR(lnc, CSR0) == CSR0_STOP)
580  return MODE_16;
581 
582  return (MODE_INVALID);
583 }
584 
585 void lnc_reset(struct lncInfo *lnc) {
587 }
588 
589 void lnc_reset32(struct lncInfo *lnc) {
591 }
592 
596  outportDWord(lnc->ioAddr + RDP, 0);
597 
598  /* a dword write to RDP sets controller into 32-bit I/O mode */
599  if (!(lnc_readBCR32(lnc, BCR18) & BCR18_DWIO)) {
600  kprintf("Cannot Swithc To 32 Bit");
601  }
602  uint32_t _csr58 = lnc_readCSR32(lnc, CSR58);
603  _csr58 &= 0xFFF0;
604  _csr58 |= 2;
605  lnc_writeCSR32(lnc, CSR58, _csr58);
606 
607  return (0);
608 
609 }
8259.h
Am79C972
#define Am79C972
Definition: lnc.h:241
CSR3
#define CSR3
Definition: lnc.h:210
CSR58
#define CSR58
Definition: lnc.h:67
lnc_writeCSR32
void lnc_writeCSR32(struct lncInfo *lnc, uint32_t port, uint32_t val)
Definition: lnc.c:59
lncInfo::txRing
struct hostRingEntry * txRing
Definition: lnc.h:132
lnc_driverOwnsTX
int lnc_driverOwnsTX(struct lncInfo *lnc)
Definition: lnc.c:514
lncInt
void lncInt()
Definition: lnc.c:368
lncInfo::rxRing
struct hostRingEntry * rxRing
Definition: lnc.h:130
RESET32
#define RESET32
Definition: lnc.h:40
CSR0
#define CSR0
Definition: lnc.h:57
spinlock.h
outportDWord
void outportDWord(unsigned int port, unsigned long value)
outputut one double word to specified port
Definition: io.c:118
UNKNOWN
#define UNKNOWN
Definition: lnc.h:194
lnc_nextTxPtr
int lnc_nextTxPtr(struct lncInfo *lnc)
Definition: lnc.c:522
gdt.h
BCR18
#define BCR18
Definition: lnc.h:45
CSR1
#define CSR1
Definition: lnc.h:208
uInt32
unsigned long int uInt32
Definition: objgfx30.h:49
inportDWord
unsigned long inportDWord(unsigned int)
input one double word from specified port
Definition: io.c:133
PCnet_FAST
#define PCnet_FAST
Definition: lnc.h:203
NDESC
#define NDESC(len2)
Definition: lnc.h:175
Am79C965
#define Am79C965
Definition: lnc.h:237
lnc_reset
void lnc_reset(struct lncInfo *lnc)
Definition: lnc.c:585
Am79C973
#define Am79C973
Definition: lnc.h:242
nicBuffer::buffer
char * buffer
Definition: netif.h:55
PCnet_FASTplus
#define PCnet_FASTplus
Definition: lnc.h:204
dPresent
#define dPresent
Definition: gdt.h:54
lnc_netif
struct netif lnc_netif
Definition: lnc.c:42
MODE_INVALID
#define MODE_INVALID
Definition: lnc.h:54
ethernetif_input
void ethernetif_input(struct netif *)
Definition: ethernetif.c:270
BCR18_DWIO
#define BCR18_DWIO
Definition: lnc.h:46
PCnet_Home
#define PCnet_Home
Definition: lnc.h:205
C_LANCE
#define C_LANCE
Definition: lnc.h:196
idt.h
uInt16
unsigned short int uInt16
Definition: objgfx30.h:48
outportWord
void outportWord(unsigned int, unsigned short)
outputut one word to specified port
Definition: io.c:103
MODE_32
#define MODE_32
Definition: lnc.h:53
video.h
ETHER_ADDR_LEN
#define ETHER_ADDR_LEN
Definition: lnc.h:182
RAP32
#define RAP32
Definition: lnc.h:38
lnc_probe
int lnc_probe(struct lncInfo *lnc)
Definition: lnc.c:191
outportByte
void outportByte(unsigned int, unsigned char)
outputut one byte to specified port
Definition: io.c:72
PART_MASK
#define PART_MASK
Definition: lnc.h:233
Am79C978
#define Am79C978
Definition: lnc.h:243
Am79C970
#define Am79C970
Definition: lnc.h:238
NTDRE
#define NTDRE
Definition: lnc.h:181
lnc_readBCR
uint16_t lnc_readBCR(struct lncInfo *lnc, uint16_t port)
Definition: lnc.c:84
nicInfo::ic
int ic
Definition: lnc.h:100
RESET
#define RESET
Definition: lnc.h:39
hostRingEntry::bcnt
uint16_t bcnt
Definition: lnc.h:86
lncInfo::init
struct initBlock32 init
Definition: lnc.h:134
PCnet_ISAplus
#define PCnet_ISAplus
Definition: lnc.h:198
lncInfo
Definition: lnc.h:127
nicInfo::ident
int ident
Definition: lnc.h:99
CSR89
#define CSR89
Definition: lnc.h:212
kpanic
void kpanic(const char *fmt,...)
print panic message and halt system
Definition: kpanic.c:41
types.h
initBlock32::mode
uint16_t mode
Definition: lnc.h:117
lnc
struct lncInfo * lnc
Definition: lnc.c:44
PCnet_ISA_II
#define PCnet_ISA_II
Definition: lnc.h:199
memcpy
void * memcpy(const void *dst, const void *src, size_t length)
Am79C961
#define Am79C961
Definition: lnc.h:235
DMA_FIXED
#define DMA_FIXED
Definition: lnc.h:189
inportByte
unsigned char inportByte(unsigned int)
input one byte from specified port
Definition: io.c:38
lnc_isr
void lnc_isr()
lncInfo::rxBuffer
char * rxBuffer
Definition: lnc.h:131
IDON
#define IDON
Definition: lnc.h:221
uint16_t
__uint16_t uint16_t
Definition: types.h:45
lncInfo::nrdre
int nrdre
Definition: lnc.h:136
lnc_writeBCR32
void lnc_writeBCR32(struct lncInfo *lnc, uint32_t port, uint32_t val)
Definition: lnc.c:79
nicInfo::memMode
int memMode
Definition: lnc.h:101
lnc_readCSR32
uint32_t lnc_readCSR32(struct lncInfo *lnc, uint32_t port)
Definition: lnc.c:69
lnc_writeBCR
void lnc_writeBCR(struct lncInfo *lnc, uint16_t port, uint16_t val)
Definition: lnc.c:74
netif.h
INEA
#define INEA
Definition: lnc.h:223
CSR88
#define CSR88
Definition: lnc.h:211
lncInfo::rxPtr
int rxPtr
Definition: lnc.h:140
STRT
#define STRT
Definition: lnc.h:228
kprintf.h
PCnet_PCI_II
#define PCnet_PCI_II
Definition: lnc.h:202
RDP
#define RDP
Definition: lnc.h:35
NE2100
#define NE2100
Definition: lnc.h:186
nicBuffer
Definition: netif.h:52
lncAttach
int lncAttach(struct lncInfo *lnc, int unit)
Definition: lnc.c:419
BDP
#define BDP
Definition: lnc.h:41
lnc_reset32
void lnc_reset32(struct lncInfo *lnc)
Definition: lnc.c:589
lncInfo::nic
struct nicInfo nic
Definition: lnc.h:129
lncInfo::arpcom
struct arpcom arpcom
Definition: lnc.h:128
netif
Definition: netif.h:233
PCnet_32
#define PCnet_32
Definition: lnc.h:200
initBlock32::padr
uint8_t padr[6]
Definition: lnc.h:120
Am79C971
#define Am79C971
Definition: lnc.h:240
INIT
#define INIT
Definition: lnc.h:229
vmm_getRealAddr
uint32_t vmm_getRealAddr(uint32_t)
Definition: getphysicaladdr.c:56
uint32_t
__uint32_t uint32_t
Definition: types.h:46
lncInfo::ioAddr
unsigned int ioAddr
Definition: lnc.h:135
lnc_nextRxPtr
int lnc_nextRxPtr(struct lncInfo *lnc)
Definition: lnc.c:534
MODE_16
#define MODE_16
Definition: lnc.h:52
lncInfo::bufferSize
int bufferSize
Definition: lnc.h:138
PCnet_PCI
#define PCnet_PCI
Definition: lnc.h:201
lnc_switchDWord
int lnc_switchDWord(struct lncInfo *lnc)
Definition: lnc.c:593
lnc_sendPacket
int lnc_sendPacket(struct lncInfo *lnc, void *packet, size_t len, uint8_t *dest)
Definition: lnc.c:546
inportWord
unsigned short inportWord(unsigned int)
input one word from specified port
Definition: io.c:55
RAP
#define RAP
Definition: lnc.h:37
initLNC
int initLNC()
Definition: lnc.c:94
lnc_driverOwnsRX
int lnc_driverOwnsRX(struct lncInfo *lnc)
Definition: lnc.c:518
lnc_INT
void lnc_INT()
Definition: lnc.c:254
nicBuffer::length
int length
Definition: netif.h:54
dInt
#define dInt
Definition: gdt.h:43
LANCE
#define LANCE
Definition: lnc.h:195
NORMAL
#define NORMAL
Definition: lnc.h:176
lncInfo::ntdre
int ntdre
Definition: lnc.h:137
hostRingEntry::addr
uint32_t addr
Definition: lnc.h:85
lnc_readCSR
uint16_t lnc_readCSR(struct lncInfo *lnc, uint16_t port)
Definition: lnc.c:64
arpcom::ac_enaddr
uint8_t ac_enaddr[6]
Definition: lnc.h:93
initBlock32::rdra
uint32_t rdra
Definition: lnc.h:123
sVec
#define sVec
Definition: 8259.h:42
lnc_txINT
void lnc_txINT()
Definition: lnc.c:352
lnc_writeCSR
void lnc_writeCSR(struct lncInfo *lnc, uint16_t port, uint16_t val)
Definition: lnc.c:54
lnc_getMode
int lnc_getMode(struct lncInfo *lnc)
Definition: lnc.c:573
kmalloc
void * kmalloc(uInt32 len)
Definition: kmalloc.c:241
lnc_thread
void lnc_thread()
Definition: lnc.c:278
setVector
void setVector(void *handler, unsigned char interrupt, unsigned short controlMajor)
Definition: idt.c:208
PCnet_ISA
#define PCnet_ISA
Definition: lnc.h:197
io.h
Am79C960
#define Am79C960
Definition: lnc.h:234
memset
void * memset(void *dst, int c, size_t length)
initBlock32::tdra
uint32_t tdra
Definition: lnc.h:124
AMD_MASK
#define AMD_MASK
Definition: lnc.h:232
lncInfo::txPtr
int txPtr
Definition: lnc.h:139
irqEnable
void irqEnable(uInt16 irqNo)
BDP32
#define BDP32
Definition: lnc.h:42
INTR
#define INTR
Definition: lnc.h:222
CSR2
#define CSR2
Definition: lnc.h:209
hostRingEntry::md
uint8_t md[6]
Definition: lnc.h:87
initBlock32::tlen
uint8_t tlen
Definition: lnc.h:119
TINT
#define TINT
Definition: lnc.h:220
lncInfo::txBuffer
char * txBuffer
Definition: lnc.h:133
uint8_t
__uint8_t uint8_t
Definition: types.h:44
tmpBuf
struct nicBuffer * tmpBuf
Definition: lnc.c:52
lnc_rxINT
void lnc_rxINT()
Definition: lnc.c:316
hostRingEntry
Definition: lnc.h:84
NRDRE
#define NRDRE
Definition: lnc.h:180
kprintf
int kprintf(const char *,...)
Definition: kprintf.c:259
net.h
SHMEM
#define SHMEM
Definition: lnc.h:191
CSR0_STOP
#define CSR0_STOP
Definition: lnc.h:58
kmalloc.h
initBlock32::rlen
uint8_t rlen
Definition: lnc.h:118
Am79C961A
#define Am79C961A
Definition: lnc.h:236
Am79C970A
#define Am79C970A
Definition: lnc.h:239
nicInfo::mode
int mode
Definition: lnc.h:103
RDP32
#define RDP32
Definition: lnc.h:36
RINT
#define RINT
Definition: lnc.h:219
lnc_readBCR32
uint32_t lnc_readBCR32(struct lncInfo *lnc, uint32_t port)
Definition: lnc.c:89
sched_yield
void sched_yield()
Definition: sched.c:244
dDpl3
#define dDpl3
Definition: gdt.h:50
lnc.h
ERR
#define ERR
Definition: lnc.h:214
lanceProbe
int lanceProbe(struct lncInfo *lnc)
Definition: lnc.c:231