drivers/net/ethernet/cirrus/mac89x0.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/cirrus/mac89x0.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/cirrus/mac89x0.c- Extension
.c- Size
- 17162 bytes
- Lines
- 578
- 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.
- 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/module.hlinux/kernel.hlinux/types.hlinux/fcntl.hlinux/interrupt.hlinux/ioport.hlinux/in.hlinux/string.hlinux/nubus.hlinux/errno.hlinux/init.hlinux/netdevice.hlinux/platform_device.hlinux/etherdevice.hlinux/skbuff.hlinux/delay.hlinux/bitops.hlinux/gfp.hasm/io.hasm/hwtest.hasm/macints.hcs89x0.h
Detected Declarations
struct net_localfunction readreg_iofunction writereg_iofunction readregfunction writeregfunction mac89x0_device_probefunction net_openfunction net_send_packetfunction net_interruptfunction net_rxfunction net_closefunction net_get_statsfunction set_multicast_listfunction set_mac_addressfunction mac89x0_device_remove
Annotated Snippet
static const struct net_device_ops mac89x0_netdev_ops = {
.ndo_open = net_open,
.ndo_stop = net_close,
.ndo_start_xmit = net_send_packet,
.ndo_get_stats = net_get_stats,
.ndo_set_rx_mode = set_multicast_list,
.ndo_set_mac_address = set_mac_address,
.ndo_validate_addr = eth_validate_addr,
};
/* Probe for the CS8900 card in slot E. We won't bother looking
anywhere else until we have a really good reason to do so. */
static int mac89x0_device_probe(struct platform_device *pdev)
{
struct net_device *dev;
struct net_local *lp;
int i, slot;
unsigned rev_type = 0;
unsigned long ioaddr;
unsigned short sig;
int err = -ENODEV;
struct nubus_rsrc *fres;
dev = alloc_etherdev(sizeof(struct net_local));
if (!dev)
return -ENOMEM;
/* We might have to parameterize this later */
slot = 0xE;
/* Get out now if there's a real NuBus card in slot E */
for_each_func_rsrc(fres)
if (fres->board->slot == slot)
goto out;
/* The pseudo-ISA bits always live at offset 0x300 (gee,
wonder why...) */
ioaddr = (unsigned long)
nubus_slot_addr(slot) | (((slot&0xf) << 20) + DEFAULTIOBASE);
{
int card_present;
card_present = (hwreg_present((void *)ioaddr + 4) &&
hwreg_present((void *)ioaddr + DATA_PORT));
if (!card_present)
goto out;
}
nubus_writew(0, ioaddr + ADD_PORT);
sig = nubus_readw(ioaddr + DATA_PORT);
if (sig != swab16(CHIP_EISA_ID_SIG))
goto out;
SET_NETDEV_DEV(dev, &pdev->dev);
/* Initialize the net_device structure. */
lp = netdev_priv(dev);
lp->msg_enable = netif_msg_init(debug, 0);
/* Fill in the 'dev' fields. */
dev->base_addr = ioaddr;
dev->mem_start = (unsigned long)
nubus_slot_addr(slot) | (((slot&0xf) << 20) + MMIOBASE);
dev->mem_end = dev->mem_start + 0x1000;
/* Turn on shared memory */
writereg_io(dev, PP_BusCTL, MEMORY_ON);
/* get the chip type */
rev_type = readreg(dev, PRODUCT_ID_ADD);
lp->chip_type = rev_type &~ REVISON_BITS;
lp->chip_revision = ((rev_type & REVISON_BITS) >> 8) + 'A';
/* Check the chip type and revision in order to set the correct send command
CS8920 revision C and CS8900 revision F can use the faster send. */
lp->send_cmd = TX_AFTER_381;
if (lp->chip_type == CS8900 && lp->chip_revision >= 'F')
lp->send_cmd = TX_NOW;
if (lp->chip_type != CS8900 && lp->chip_revision >= 'C')
lp->send_cmd = TX_NOW;
netif_dbg(lp, drv, dev, "%s", version);
pr_info("cs89%c0%s rev %c found at %#8lx\n",
lp->chip_type == CS8900 ? '0' : '2',
lp->chip_type == CS8920M ? "M" : "",
lp->chip_revision, dev->base_addr);
/* Try to read the MAC address */
if ((readreg(dev, PP_SelfST) & (EEPROM_PRESENT | EEPROM_OK)) == 0) {
Annotation
- Immediate include surface: `linux/module.h`, `linux/kernel.h`, `linux/types.h`, `linux/fcntl.h`, `linux/interrupt.h`, `linux/ioport.h`, `linux/in.h`, `linux/string.h`.
- Detected declarations: `struct net_local`, `function readreg_io`, `function writereg_io`, `function readreg`, `function writereg`, `function mac89x0_device_probe`, `function net_open`, `function net_send_packet`, `function net_interrupt`, `function net_rx`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: pattern implementation candidate.
- 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.