drivers/net/ethernet/apple/bmac.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/apple/bmac.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/apple/bmac.c- Extension
.c- Size
- 40343 bytes
- Lines
- 1613
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/interrupt.hlinux/module.hlinux/kernel.hlinux/netdevice.hlinux/etherdevice.hlinux/delay.hlinux/string.hlinux/timer.hlinux/proc_fs.hlinux/init.hlinux/spinlock.hlinux/crc32.hlinux/bitrev.hlinux/ethtool.hlinux/slab.hlinux/pgtable.hasm/dbdma.hasm/io.hasm/page.hasm/machdep.hasm/pmac_feature.hasm/macio.hasm/irq.hbmac.h
Detected Declarations
struct bmac_datafunction dbdma_st32function dbdma_ld32function dbdma_continuefunction dbdma_resetfunction dbdma_setcmdfunction bmwritefunction bmreadfunction bmac_enable_and_reset_chipfunction bmac_mif_readbitsfunction bmac_mif_writebitsfunction bmac_mif_readfunction bmac_mif_writefunction bmac_init_registersfunction bmac_disable_interruptsfunction bmac_enable_interruptsfunction bmac_start_chipfunction bmac_init_phyfunction bmac_init_chipfunction bmac_suspendfunction bmac_resumefunction bmac_set_addressfunction bmac_set_timeoutfunction bmac_construct_xmtfunction bmac_construct_rxbufffunction bmac_init_tx_ringfunction bmac_init_rx_ringfunction bmac_transmit_packetfunction bmac_rxdma_intrfunction bmac_txdma_intrfunction bmac_addhashfunction bmac_removehashfunction bmac_rx_offfunction bmac_rx_onfunction bmac_update_hash_table_maskfunction bmac_add_multifunction bmac_remove_multifunction bmac_set_multicastfunction bmac_set_multicastfunction netdev_for_each_mc_addrfunction bmac_misc_intrfunction bmac_clock_out_bitfunction bmac_clock_in_bitfunction reset_and_select_sromfunction read_sromfunction bmac_verify_checksumfunction bmac_get_station_addressfunction bmac_reset_and_enable
Annotated Snippet
static const struct net_device_ops bmac_netdev_ops = {
.ndo_open = bmac_open,
.ndo_stop = bmac_close,
.ndo_start_xmit = bmac_output,
.ndo_set_rx_mode = bmac_set_multicast,
.ndo_set_mac_address = bmac_set_address,
.ndo_validate_addr = eth_validate_addr,
};
static int bmac_probe(struct macio_dev *mdev, const struct of_device_id *match)
{
int j, rev, ret;
struct bmac_data *bp;
const unsigned char *prop_addr;
unsigned char addr[6];
u8 macaddr[6];
struct net_device *dev;
int is_bmac_plus = ((int)match->data) != 0;
if (macio_resource_count(mdev) != 3 || macio_irq_count(mdev) != 3) {
printk(KERN_ERR "BMAC: can't use, need 3 addrs and 3 intrs\n");
return -ENODEV;
}
prop_addr = of_get_property(macio_get_of_node(mdev),
"mac-address", NULL);
if (prop_addr == NULL) {
prop_addr = of_get_property(macio_get_of_node(mdev),
"local-mac-address", NULL);
if (prop_addr == NULL) {
printk(KERN_ERR "BMAC: Can't get mac-address\n");
return -ENODEV;
}
}
memcpy(addr, prop_addr, sizeof(addr));
dev = alloc_etherdev(PRIV_BYTES);
if (!dev)
return -ENOMEM;
bp = netdev_priv(dev);
SET_NETDEV_DEV(dev, &mdev->ofdev.dev);
macio_set_drvdata(mdev, dev);
bp->mdev = mdev;
spin_lock_init(&bp->lock);
if (macio_request_resources(mdev, "bmac")) {
printk(KERN_ERR "BMAC: can't request IO resource !\n");
goto out_free;
}
dev->base_addr = (unsigned long)
ioremap(macio_resource_start(mdev, 0), macio_resource_len(mdev, 0));
if (dev->base_addr == 0)
goto out_release;
dev->irq = macio_irq(mdev, 0);
bmac_enable_and_reset_chip(dev);
bmwrite(dev, INTDISABLE, DisableAll);
rev = addr[0] == 0 && addr[1] == 0xA0;
for (j = 0; j < 6; ++j)
macaddr[j] = rev ? bitrev8(addr[j]): addr[j];
eth_hw_addr_set(dev, macaddr);
/* Enable chip without interrupts for now */
bmac_enable_and_reset_chip(dev);
bmwrite(dev, INTDISABLE, DisableAll);
dev->netdev_ops = &bmac_netdev_ops;
dev->ethtool_ops = &bmac_ethtool_ops;
bmac_get_station_address(dev, addr);
if (bmac_verify_checksum(dev) != 0)
goto err_out_iounmap;
bp->is_bmac_plus = is_bmac_plus;
bp->tx_dma = ioremap(macio_resource_start(mdev, 1), macio_resource_len(mdev, 1));
if (!bp->tx_dma)
goto err_out_iounmap;
bp->tx_dma_intr = macio_irq(mdev, 1);
bp->rx_dma = ioremap(macio_resource_start(mdev, 2), macio_resource_len(mdev, 2));
if (!bp->rx_dma)
goto err_out_iounmap_tx;
bp->rx_dma_intr = macio_irq(mdev, 2);
bp->tx_cmds = (volatile struct dbdma_cmd *) DBDMA_ALIGN(bp + 1);
bp->rx_cmds = bp->tx_cmds + N_TX_RING + 1;
Annotation
- Immediate include surface: `linux/interrupt.h`, `linux/module.h`, `linux/kernel.h`, `linux/netdevice.h`, `linux/etherdevice.h`, `linux/delay.h`, `linux/string.h`, `linux/timer.h`.
- Detected declarations: `struct bmac_data`, `function dbdma_st32`, `function dbdma_ld32`, `function dbdma_continue`, `function dbdma_reset`, `function dbdma_setcmd`, `function bmwrite`, `function bmread`, `function bmac_enable_and_reset_chip`, `function bmac_mif_readbits`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: pattern implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.