Bläddra i källkod

Updated to new ISA API, but this driver probably has deeper problems.

tags/v0.9.3
Michael Brown 19 år sedan
förälder
incheckning
d5e1561fb8
1 ändrade filer med 95 tillägg och 92 borttagningar
  1. 95
    92
      src/drivers/net/depca.c

+ 95
- 92
src/drivers/net/depca.c Visa fil

@@ -1,3 +1,5 @@
1
+#warning "depca.c almost certainly won't work"
2
+
1 3
 /* Not fixed for relocation yet. Probably won't work relocated above 16MB */
2 4
 #ifdef ALLMULTI
3 5
 #error multicast support is not yet implemented
@@ -235,22 +237,23 @@
235 237
 #include "etherboot.h"
236 238
 #include "nic.h"
237 239
 #include "isa.h"
240
+#include "console.h"
238 241
 
239 242
 /*
240 243
 ** I/O addresses. Note that the 2k buffer option is not supported in
241 244
 ** this driver.
242 245
 */
243
-#define DEPCA_NICSR ioaddr+0x00   /* Network interface CSR */
244
-#define DEPCA_RBI   ioaddr+0x02   /* RAM buffer index (2k buffer mode) */
245
-#define DEPCA_DATA  ioaddr+0x04   /* LANCE registers' data port */
246
-#define DEPCA_ADDR  ioaddr+0x06   /* LANCE registers' address port */
247
-#define DEPCA_HBASE ioaddr+0x08   /* EISA high memory base address reg. */
248
-#define DEPCA_PROM  ioaddr+0x0c   /* Ethernet address ROM data port */
249
-#define DEPCA_CNFG  ioaddr+0x0c   /* EISA Configuration port */
250
-#define DEPCA_RBSA  ioaddr+0x0e   /* RAM buffer starting address (2k buff.) */
246
+#define DEPCA_NICSR 0x00   /* Network interface CSR */
247
+#define DEPCA_RBI   0x02   /* RAM buffer index (2k buffer mode) */
248
+#define DEPCA_DATA  0x04   /* LANCE registers' data port */
249
+#define DEPCA_ADDR  0x06   /* LANCE registers' address port */
250
+#define DEPCA_HBASE 0x08   /* EISA high memory base address reg. */
251
+#define DEPCA_PROM  0x0c   /* Ethernet address ROM data port */
252
+#define DEPCA_CNFG  0x0c   /* EISA Configuration port */
253
+#define DEPCA_RBSA  0x0e   /* RAM buffer starting address (2k buff.) */
251 254
 
252 255
 /*
253
-** These are LANCE registers addressable through DEPCA_ADDR 
256
+** These are LANCE registers addressable through nic->ioaddr + DEPCA_ADDR 
254 257
 */
255 258
 #define CSR0       0
256 259
 #define CSR1       1
@@ -375,8 +378,6 @@
375 378
 /*
376 379
 ** ISA Bus defines
377 380
 */
378
-#define DEPCA_IO_PORTS	{0x300, 0x200, 0}
379
-
380 381
 #ifndef	DEPCA_MODEL
381 382
 #define	DEPCA_MODEL	DEPCA
382 383
 #endif
@@ -465,15 +466,14 @@ struct depca_private {
465 466
 
466 467
 static Address		mem_start = DEPCA_RAM_BASE;
467 468
 static Address		mem_len, offset;
468
-static unsigned short	ioaddr = 0;
469 469
 static struct depca_private	lp;
470 470
 
471 471
 /*
472 472
 ** Miscellaneous defines...
473 473
 */
474
-#define STOP_DEPCA \
475
-    outw(CSR0, DEPCA_ADDR);\
476
-    outw(STOP, DEPCA_DATA)
474
+#define STOP_DEPCA(ioaddr) \
475
+    outw(CSR0, ioaddr + DEPCA_ADDR);\
476
+    outw(STOP, ioaddr + DEPCA_DATA)
477 477
 
478 478
 /* Initialize the lance Rx and Tx descriptor rings. */
479 479
 static void depca_init_ring(struct nic *nic)
@@ -504,13 +504,13 @@ static void depca_init_ring(struct nic *nic)
504 504
 
505 505
 static void LoadCSRs(void)
506 506
 {
507
-	outw(CSR1, DEPCA_ADDR);	/* initialisation block address LSW */
508
-	outw((u16) (lp.sh_mem & LA_MASK), DEPCA_DATA);
509
-	outw(CSR2, DEPCA_ADDR);	/* initialisation block address MSW */
510
-	outw((u16) ((lp.sh_mem & LA_MASK) >> 16), DEPCA_DATA);
511
-	outw(CSR3, DEPCA_ADDR);	/* ALE control */
512
-	outw(ACON, DEPCA_DATA);
513
-	outw(CSR0, DEPCA_ADDR);	/* Point back to CSR0 */
507
+	outw(CSR1, nic->ioaddr + DEPCA_ADDR);	/* initialisation block address LSW */
508
+	outw((u16) (lp.sh_mem & LA_MASK), nic->ioaddr + DEPCA_DATA);
509
+	outw(CSR2, nic->ioaddr + DEPCA_ADDR);	/* initialisation block address MSW */
510
+	outw((u16) ((lp.sh_mem & LA_MASK) >> 16), nic->ioaddr + DEPCA_DATA);
511
+	outw(CSR3, nic->ioaddr + DEPCA_ADDR);	/* ALE control */
512
+	outw(ACON, nic->ioaddr + DEPCA_DATA);
513
+	outw(CSR0, nic->ioaddr + DEPCA_ADDR);	/* Point back to CSR0 */
514 514
 }
515 515
 
516 516
 static int InitRestartDepca(void)
@@ -519,14 +519,14 @@ static int InitRestartDepca(void)
519 519
 
520 520
 	/* Copy the shadow init_block to shared memory */
521 521
 	memcpy_toio((char *)lp.sh_mem, &lp.init_block, sizeof(struct depca_init));
522
-	outw(CSR0, DEPCA_ADDR);		/* point back to CSR0 */
523
-	outw(INIT, DEPCA_DATA);		/* initialise DEPCA */
522
+	outw(CSR0, nic->ioaddr + DEPCA_ADDR);		/* point back to CSR0 */
523
+	outw(INIT, nic->ioaddr + DEPCA_DATA);		/* initialise DEPCA */
524 524
 
525
-	for (i = 0; i < 100 && !(inw(DEPCA_DATA) & IDON); i++)
525
+	for (i = 0; i < 100 && !(inw(nic->ioaddr + DEPCA_DATA) & IDON); i++)
526 526
 		;
527 527
 	if (i < 100) {
528 528
 		/* clear IDON by writing a 1, and start LANCE */
529
-		outw(IDON | STRT, DEPCA_DATA);
529
+		outw(IDON | STRT, nic->ioaddr + DEPCA_DATA);
530 530
 	} else {
531 531
 		printf("DEPCA not initialised\n");
532 532
 		return (1);
@@ -542,11 +542,11 @@ static void depca_reset(struct nic *nic)
542 542
 	s16	nicsr;
543 543
 	int	i, j;
544 544
 
545
-	STOP_DEPCA;
546
-	nicsr = inb(DEPCA_NICSR);
545
+	STOP_DEPCA(nic->ioaddr);
546
+	nicsr = inb(nic->ioaddr + DEPCA_NICSR);
547 547
 	nicsr = ((nicsr & ~SHE & ~RBE & ~IEN) | IM);
548
-	outb(nicsr, DEPCA_NICSR);
549
-	if (inw(DEPCA_DATA) != STOP)
548
+	outb(nicsr, nic->ioaddr + DEPCA_NICSR);
549
+	if (inw(nic->ioaddr + DEPCA_DATA) != STOP)
550 550
 	{
551 551
 		printf("depca: Cannot stop NIC\n");
552 552
 		return;
@@ -652,7 +652,7 @@ static void depca_disable ( struct nic *nic ) {
652 652
 	/* reset and disable merge */
653 653
 	depca_reset(nic);
654 654
 
655
-	STOP_DEPCA;
655
+	STOP_DEPCA(nic->ioaddr);
656 656
 }
657 657
 
658 658
 /**************************************************************************
@@ -685,24 +685,32 @@ static void depca_irq(struct nic *nic __unused, irq_action_t action __unused)
685 685
 ** PROM address counter is correctly positioned at the start of the
686 686
 ** ethernet address for later read out.
687 687
 */
688
-static int depca_probe1(struct nic *nic)
689
-{
690
-	u8	data, nicsr;
688
+
689
+
690
+/*
691
+ * Ugly, ugly, ugly.  I can't quite make out where the split should be
692
+ * between probe1 and probe()...
693
+ *
694
+ */
695
+static u8 nicsr;
696
+
697
+
698
+static int depca_probe1 ( uint16_t ioaddr ) {
699
+	u8	data;
691 700
 	/* This is only correct for little endian machines, but then
692 701
 	   Etherboot doesn't work on anything but a PC */
693 702
 	u8	sig[] = { 0xFF, 0x00, 0x55, 0xAA, 0xFF, 0x00, 0x55, 0xAA };
694 703
 	int	i, j;
695
-	long	sum, chksum;
696 704
 
697
-	data = inb(DEPCA_PROM);		/* clear counter on DEPCA */
698
-	data = inb(DEPCA_PROM);		/* read data */
705
+	data = inb(ioaddr + DEPCA_PROM);		/* clear counter on DEPCA */
706
+	data = inb(ioaddr + DEPCA_PROM);		/* read data */
699 707
 	if (data == 0x8) {
700
-		nicsr = inb(DEPCA_NICSR);
708
+		nicsr = inb(ioaddr + DEPCA_NICSR);
701 709
 		nicsr |= AAC;
702
-		outb(nicsr, DEPCA_NICSR);
710
+		outb(nicsr, ioaddr + DEPCA_NICSR);
703 711
 	}
704 712
 	for (i = 0, j = 0; j < (int)sizeof(sig) && i < PROBE_LENGTH+((int)sizeof(sig))-1; ++i) {
705
-		data = inb(DEPCA_PROM);
713
+		data = inb(ioaddr + DEPCA_PROM);
706 714
 		if (data == sig[j])		/* track signature */
707 715
 			++j;
708 716
 		else
@@ -711,27 +719,50 @@ static int depca_probe1(struct nic *nic)
711 719
 	if (j != sizeof(sig))
712 720
 		return (0);
713 721
 	/* put the card in its initial state */
714
-	STOP_DEPCA;
715
-	nicsr = ((inb(DEPCA_NICSR) & ~SHE & ~RBE & ~IEN) | IM);
716
-	outb(nicsr, DEPCA_NICSR);
717
-	if (inw(DEPCA_DATA) != STOP)
722
+	STOP_DEPCA(ioaddr);
723
+	nicsr = ((inb(ioaddr + DEPCA_NICSR) & ~SHE & ~RBE & ~IEN) | IM);
724
+	outb(nicsr, ioaddr + DEPCA_NICSR);
725
+	if (inw(ioaddr + DEPCA_DATA) != STOP)
718 726
 		return (0);
719 727
 	memcpy((char *)mem_start, sig, sizeof(sig));
720 728
 	if (memcmp((char *)mem_start, sig, sizeof(sig)) != 0)
721 729
 		return (0);
730
+
731
+	return 1;
732
+}
733
+
734
+static struct nic_operations depca_operations = {
735
+	.connect	= dummy_connect,
736
+	.poll		= depca_poll,
737
+	.transmit	= depca_transmit,
738
+	.irq		= depca_irq,
739
+	.disable	= depca_disable,
740
+};
741
+
742
+/**************************************************************************
743
+PROBE - Look for an adapter, this routine's visible to the outside
744
+***************************************************************************/
745
+static int depca_probe ( struct dev *dev, struct isa_device *isa ) {
746
+	struct nic *nic = nic_device ( dev );
747
+	int	i, j;
748
+	long	sum, chksum;
749
+
750
+	nic->irqno    = 0;
751
+	nic->ioaddr   = isa->ioaddr;
752
+
722 753
 	for (i = 0, j = 0, sum = 0; j < 3; j++) {
723 754
 		sum <<= 1;
724 755
 		if (sum > 0xFFFF)
725 756
 			sum -= 0xFFFF;
726
-		sum += (u8)(nic->node_addr[i++] = inb(DEPCA_PROM));
727
-		sum += (u16)((nic->node_addr[i++] = inb(DEPCA_PROM)) << 8);
757
+		sum += (u8)(nic->node_addr[i++] = inb(nic->ioaddr + DEPCA_PROM));
758
+		sum += (u16)((nic->node_addr[i++] = inb(nic->ioaddr + DEPCA_PROM)) << 8);
728 759
 		if (sum > 0xFFFF)
729 760
 			sum -= 0xFFFF;
730 761
 	}
731 762
 	if (sum == 0xFFFF)
732 763
 		sum = 0;
733
-	chksum = (u8)inb(DEPCA_PROM);
734
-	chksum |= (u16)(inb(DEPCA_PROM) << 8);
764
+	chksum = (u8)inb(nic->ioaddr + DEPCA_PROM);
765
+	chksum |= (u16)(inb(nic->ioaddr + DEPCA_PROM) << 8);
735 766
 	mem_len = (adapter == DEPCA) ? (48 << 10) : (64 << 10);
736 767
 	offset = 0;
737 768
 	if (nicsr & BUF) {
@@ -740,58 +771,30 @@ static int depca_probe1(struct nic *nic)
740 771
 		mem_len -= (32 << 10);
741 772
 	}
742 773
 	if (adapter != DEPCA)	/* enable shadow RAM */
743
-		outb(nicsr |= SHE, DEPCA_NICSR);
774
+		outb(nicsr |= SHE, nic->ioaddr + DEPCA_NICSR);
744 775
 	printf("%s base %#hX, memory [%#hX-%#hX], addr %!",
745
-		adapter_name[adapter], ioaddr, mem_start, mem_start + mem_len,
746
-		nic->node_addr);
776
+	       adapter_name[adapter], nic->ioaddr, mem_start,
777
+	       mem_start + mem_len,
778
+	       nic->node_addr);
747 779
 	if (sum != chksum)
748 780
 		printf(" (bad checksum)");
749 781
 	putchar('\n');
750
-	return (1);
751
-}
752
-
753
-/**************************************************************************
754
-PROBE - Look for an adapter, this routine's visible to the outside
755
-***************************************************************************/
756
-static int depca_probe(struct dev *dev, unsigned short *probe_addrs)
757
-{
758
-	struct nic *nic = (struct nic *)dev;
759
-	static unsigned short	base[] = DEPCA_IO_PORTS;
760
-	int			i;
761
-
762
-	if (probe_addrs == 0 || probe_addrs[0] == 0)
763
-		probe_addrs = base;	/* Use defaults */
764
-	for (i = 0; (ioaddr = base[i]) != 0; ++i) {
765
-		if (depca_probe1(nic))
766
-			break;
767
-	}
768
-	if (ioaddr == 0)
769
-		return (0);
770
-
771
-	nic->irqno    = 0;
772
-	nic->ioaddr   = ioaddr & ~3;
773 782
 
774 783
 	depca_reset(nic);
775
-	/* point to NIC specific routines */
776
-static struct nic_operations depca_operations;
777
-static struct nic_operations depca_operations = {
778
-	.connect	= dummy_connect,
779
-	.poll		= depca_poll,
780
-	.transmit	= depca_transmit,
781
-	.irq		= depca_irq,
782
-	.disable	= depca_disable,
783
-};	nic->nic_op	= &depca_operations;
784 784
 
785
-	/* Based on PnP ISA map */
786
-	dev->devid.vendor_id = htons(GENERIC_ISAPNP_VENDOR);
787
-	dev->devid.device_id = htons(0x80f7);
785
+	/* point to NIC specific routines */
786
+	nic->nic_op	= &depca_operations;
788 787
 	return 1;
789 788
 }
790 789
 
791
-static struct isa_driver depca_driver __isa_driver = {
792
-	.type    = NIC_DRIVER,
793
-	.name    = "DEPCA",
794
-	.probe   = depca_probe,
795
-	.ioaddrs = 0,
790
+static struct isa_probe_addr depca_probe_addrs[] = {
791
+	{ 0x300 }, { 0x200 },
796 792
 };
797
-ISA_ROM("depca","Digital DE100 and DE200");
793
+
794
+static struct isa_driver depca_driver =
795
+	ISA_DRIVER ( "depca", depca_probe_addrs, depca_probe1,
796
+		     GENERIC_ISAPNP_VENDOR, 0x80f7 );
797
+
798
+BOOT_DRIVER ( "depce", find_isa_boot_device, depca_driver, depca_probe );
799
+
800
+ISA_ROM ( "depca", "Digital DE100 and DE200" );

Laddar…
Avbryt
Spara