Browse Source

[b44] Eliminate call to get_memmap()

get_memmap() is not available under all runtime environments.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 12 years ago
parent
commit
73ba154124
1 changed files with 31 additions and 26 deletions
  1. 31
    26
      src/drivers/net/b44.c

+ 31
- 26
src/drivers/net/b44.c View File

78
 
78
 
79
 
79
 
80
 /**
80
 /**
81
- * Return non-zero if the installed RAM is within
82
- * the limit given and zero if it is outside.
83
- * Hopefully will be removed soon.
81
+ * Check if card can access address
82
+ *
83
+ * @v address		Virtual address
84
+ * @v address_ok	Card can access address
84
  */
85
  */
85
-int phys_ram_within_limit(u64 limit)
86
-{
87
-	struct memory_map memmap;
88
-	struct memory_region *highest = NULL;
89
-	get_memmap(&memmap);
86
+static inline __attribute__ (( always_inline )) int
87
+b44_address_ok ( void *address ) {
90
 
88
 
91
-	if (memmap.count == 0)
92
-		return 0;
93
-	highest = &memmap.regions[memmap.count - 1];
89
+	/* Card can address anything with a 30-bit address */
90
+	if ( ( virt_to_bus ( address ) & ~B44_30BIT_DMA_MASK ) == 0 )
91
+		return 1;
94
 
92
 
95
-	return (highest->end < limit);
93
+	return 0;
96
 }
94
 }
97
 
95
 
98
-
99
 /**
96
 /**
100
  * Ring cells waiting to be processed are between 'tx_cur' and 'pending'
97
  * Ring cells waiting to be processed are between 'tx_cur' and 'pending'
101
  * indexes in the ring.
98
  * indexes in the ring.
404
  */
401
  */
405
 static void b44_rx_refill(struct b44_private *bp, u32 pending)
402
 static void b44_rx_refill(struct b44_private *bp, u32 pending)
406
 {
403
 {
404
+	struct io_buffer *iobuf;
407
 	u32 i;
405
 	u32 i;
408
 
406
 
409
 	// skip pending
407
 	// skip pending
411
 		if (bp->rx_iobuf[i] != NULL)
409
 		if (bp->rx_iobuf[i] != NULL)
412
 			continue;
410
 			continue;
413
 
411
 
414
-		bp->rx_iobuf[i] = alloc_iob(RX_PKT_BUF_SZ);
415
-		if (!bp->rx_iobuf[i]) {
412
+		iobuf = alloc_iob(RX_PKT_BUF_SZ);
413
+		if (!iobuf) {
416
 			DBG("Refill rx ring failed!!\n");
414
 			DBG("Refill rx ring failed!!\n");
417
 			break;
415
 			break;
418
 		}
416
 		}
417
+		if (!b44_address_ok(iobuf->data)) {
418
+			DBG("Refill rx ring bad address!!\n");
419
+			free_iob(iobuf);
420
+			break;
421
+		}
422
+		bp->rx_iobuf[i] = iobuf;
419
 
423
 
420
 		b44_populate_rx_descriptor(bp, i);
424
 		b44_populate_rx_descriptor(bp, i);
421
 	}
425
 	}
444
 	bp->rx = malloc_dma(B44_RX_RING_LEN_BYTES, B44_DMA_ALIGNMENT);
448
 	bp->rx = malloc_dma(B44_RX_RING_LEN_BYTES, B44_DMA_ALIGNMENT);
445
 	if (!bp->rx)
449
 	if (!bp->rx)
446
 		return -ENOMEM;
450
 		return -ENOMEM;
451
+	if (!b44_address_ok(bp->rx)) {
452
+		free_dma(bp->rx, B44_RX_RING_LEN_BYTES);
453
+		return -ENOTSUP;
454
+	}
447
 
455
 
448
 	memset(bp->rx_iobuf, 0, sizeof(bp->rx_iobuf));
456
 	memset(bp->rx_iobuf, 0, sizeof(bp->rx_iobuf));
449
 
457
 
472
 	bp->tx = malloc_dma(B44_TX_RING_LEN_BYTES, B44_DMA_ALIGNMENT);
480
 	bp->tx = malloc_dma(B44_TX_RING_LEN_BYTES, B44_DMA_ALIGNMENT);
473
 	if (!bp->tx)
481
 	if (!bp->tx)
474
 		return -ENOMEM;
482
 		return -ENOMEM;
483
+	if (!b44_address_ok(bp->tx)) {
484
+		free_dma(bp->tx, B44_TX_RING_LEN_BYTES);
485
+		return -ENOTSUP;
486
+	}
475
 
487
 
476
 	memset(bp->tx, 0, B44_TX_RING_LEN_BYTES);
488
 	memset(bp->tx, 0, B44_TX_RING_LEN_BYTES);
477
 	memset(bp->tx_iobuf, 0, sizeof(bp->tx_iobuf));
489
 	memset(bp->tx_iobuf, 0, sizeof(bp->tx_iobuf));
644
 	struct b44_private *bp;
656
 	struct b44_private *bp;
645
 	int rc;
657
 	int rc;
646
 
658
 
647
-	/*
648
-	 * Bail out if more than 1GB of physical RAM is installed.
649
-	 * This limitation will be removed later when dma mapping
650
-	 * is merged into mainline.
651
-	 */
652
-	if (!phys_ram_within_limit(B44_30BIT_DMA_MASK)) {
653
-		DBG("Sorry, this version of the driver does not\n"
654
-		    "support systems with more than 1GB of RAM.\n");
655
-		return -ENOMEM;
656
-	}
657
-
658
 	/* Set up netdev */
659
 	/* Set up netdev */
659
 	netdev = alloc_etherdev(sizeof(*bp));
660
 	netdev = alloc_etherdev(sizeof(*bp));
660
 	if (!netdev)
661
 	if (!netdev)
793
 		return -ENOBUFS;
794
 		return -ENOBUFS;
794
 	}
795
 	}
795
 
796
 
797
+	/* Check for addressability */
798
+	if (!b44_address_ok(iobuf->data))
799
+		return -ENOTSUP;
800
+
796
 	/* Will call netdev_tx_complete() on the iobuf later */
801
 	/* Will call netdev_tx_complete() on the iobuf later */
797
 	bp->tx_iobuf[cur] = iobuf;
802
 	bp->tx_iobuf[cur] = iobuf;
798
 
803
 

Loading…
Cancel
Save