david/ipxe
david
/
ipxe
Archived
1
0
Fork 0

[b44] Eliminate call to get_memmap()

get_memmap() is not available under all runtime environments.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown 2012-07-17 21:20:50 +01:00
parent 88016deccf
commit 73ba154124
1 changed files with 31 additions and 26 deletions

View File

@ -78,24 +78,21 @@ static inline void bflush(const struct b44_private *bp, u32 reg, u32 timeout)
/** /**
* Return non-zero if the installed RAM is within * Check if card can access address
* the limit given and zero if it is outside. *
* Hopefully will be removed soon. * @v address Virtual address
* @v address_ok Card can access address
*/ */
int phys_ram_within_limit(u64 limit) static inline __attribute__ (( always_inline )) int
{ b44_address_ok ( void *address ) {
struct memory_map memmap;
struct memory_region *highest = NULL;
get_memmap(&memmap);
if (memmap.count == 0) /* Card can address anything with a 30-bit address */
return 0; if ( ( virt_to_bus ( address ) & ~B44_30BIT_DMA_MASK ) == 0 )
highest = &memmap.regions[memmap.count - 1]; return 1;
return (highest->end < limit); return 0;
} }
/** /**
* Ring cells waiting to be processed are between 'tx_cur' and 'pending' * Ring cells waiting to be processed are between 'tx_cur' and 'pending'
* indexes in the ring. * indexes in the ring.
@ -404,6 +401,7 @@ static void b44_populate_rx_descriptor(struct b44_private *bp, u32 idx)
*/ */
static void b44_rx_refill(struct b44_private *bp, u32 pending) static void b44_rx_refill(struct b44_private *bp, u32 pending)
{ {
struct io_buffer *iobuf;
u32 i; u32 i;
// skip pending // skip pending
@ -411,11 +409,17 @@ static void b44_rx_refill(struct b44_private *bp, u32 pending)
if (bp->rx_iobuf[i] != NULL) if (bp->rx_iobuf[i] != NULL)
continue; continue;
bp->rx_iobuf[i] = alloc_iob(RX_PKT_BUF_SZ); iobuf = alloc_iob(RX_PKT_BUF_SZ);
if (!bp->rx_iobuf[i]) { if (!iobuf) {
DBG("Refill rx ring failed!!\n"); DBG("Refill rx ring failed!!\n");
break; break;
} }
if (!b44_address_ok(iobuf->data)) {
DBG("Refill rx ring bad address!!\n");
free_iob(iobuf);
break;
}
bp->rx_iobuf[i] = iobuf;
b44_populate_rx_descriptor(bp, i); b44_populate_rx_descriptor(bp, i);
} }
@ -444,6 +448,10 @@ static int b44_init_rx_ring(struct b44_private *bp)
bp->rx = malloc_dma(B44_RX_RING_LEN_BYTES, B44_DMA_ALIGNMENT); bp->rx = malloc_dma(B44_RX_RING_LEN_BYTES, B44_DMA_ALIGNMENT);
if (!bp->rx) if (!bp->rx)
return -ENOMEM; return -ENOMEM;
if (!b44_address_ok(bp->rx)) {
free_dma(bp->rx, B44_RX_RING_LEN_BYTES);
return -ENOTSUP;
}
memset(bp->rx_iobuf, 0, sizeof(bp->rx_iobuf)); memset(bp->rx_iobuf, 0, sizeof(bp->rx_iobuf));
@ -472,6 +480,10 @@ static int b44_init_tx_ring(struct b44_private *bp)
bp->tx = malloc_dma(B44_TX_RING_LEN_BYTES, B44_DMA_ALIGNMENT); bp->tx = malloc_dma(B44_TX_RING_LEN_BYTES, B44_DMA_ALIGNMENT);
if (!bp->tx) if (!bp->tx)
return -ENOMEM; return -ENOMEM;
if (!b44_address_ok(bp->tx)) {
free_dma(bp->tx, B44_TX_RING_LEN_BYTES);
return -ENOTSUP;
}
memset(bp->tx, 0, B44_TX_RING_LEN_BYTES); memset(bp->tx, 0, B44_TX_RING_LEN_BYTES);
memset(bp->tx_iobuf, 0, sizeof(bp->tx_iobuf)); memset(bp->tx_iobuf, 0, sizeof(bp->tx_iobuf));
@ -644,17 +656,6 @@ static int b44_probe(struct pci_device *pci)
struct b44_private *bp; struct b44_private *bp;
int rc; int rc;
/*
* Bail out if more than 1GB of physical RAM is installed.
* This limitation will be removed later when dma mapping
* is merged into mainline.
*/
if (!phys_ram_within_limit(B44_30BIT_DMA_MASK)) {
DBG("Sorry, this version of the driver does not\n"
"support systems with more than 1GB of RAM.\n");
return -ENOMEM;
}
/* Set up netdev */ /* Set up netdev */
netdev = alloc_etherdev(sizeof(*bp)); netdev = alloc_etherdev(sizeof(*bp));
if (!netdev) if (!netdev)
@ -793,6 +794,10 @@ static int b44_transmit(struct net_device *netdev, struct io_buffer *iobuf)
return -ENOBUFS; return -ENOBUFS;
} }
/* Check for addressability */
if (!b44_address_ok(iobuf->data))
return -ENOTSUP;
/* Will call netdev_tx_complete() on the iobuf later */ /* Will call netdev_tx_complete() on the iobuf later */
bp->tx_iobuf[cur] = iobuf; bp->tx_iobuf[cur] = iobuf;