arch/sparc/kernel/of_device_32.c
Source file repositories/reference/linux-study-clean/arch/sparc/kernel/of_device_32.c
File Facts
- System
- Linux kernel
- Corpus path
arch/sparc/kernel/of_device_32.c- Extension
.c- Size
- 9247 bytes
- Lines
- 435
- Domain
- Architecture Layer
- Bucket
- arch/sparc
- Inferred role
- Architecture Layer: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/string.hlinux/kernel.hlinux/of.hlinux/init.hlinux/mod_devicetable.hlinux/slab.hlinux/errno.hlinux/irq.hlinux/of_platform.hlinux/platform_device.hlinux/dma-mapping.hasm/leon.hasm/leon_amba.hof_device_common.hirq.h
Detected Declarations
function of_bus_pci_matchfunction of_bus_pci_count_cellsfunction of_bus_pci_mapfunction of_bus_pci_get_flagsfunction of_bus_sbus_get_flagsfunction of_bus_ambapp_matchfunction of_bus_ambapp_count_cellsfunction of_bus_ambapp_mapfunction of_bus_ambapp_get_flagsfunction build_one_resourcefunction use_1to1_mappingfunction build_device_resourcesfunction scan_one_devicefunction scan_treefunction scan_of_devicesfunction of_debug
Annotated Snippet
if (use_1to1_mapping(pp)) {
result = of_read_addr(addr, na);
goto build_res;
}
dna = na;
dns = ns;
dbus = bus;
while (1) {
dp = pp;
pp = dp->parent;
if (!pp) {
result = of_read_addr(addr, dna);
break;
}
pbus = of_match_bus(pp);
pbus->count_cells(dp, &pna, &pns);
if (build_one_resource(dp, dbus, pbus, addr,
dna, dns, pna))
break;
flags = pbus->get_flags(addr, flags);
dna = pna;
dns = pns;
dbus = pbus;
}
build_res:
memset(r, 0, sizeof(*r));
if (of_resource_verbose)
printk("%pOF reg[%d] -> %llx\n",
op->dev.of_node, index,
result);
if (result != OF_BAD_ADDR) {
r->start = result & 0xffffffff;
r->end = result + size - 1;
r->flags = flags | ((result >> 32ULL) & 0xffUL);
}
r->name = op->dev.of_node->full_name;
}
}
static struct platform_device * __init scan_one_device(struct device_node *dp,
struct device *parent)
{
struct platform_device *op = kzalloc_obj(*op);
const struct linux_prom_irqs *intr;
struct dev_archdata *sd;
int len, i;
if (!op)
return NULL;
sd = &op->dev.archdata;
sd->op = op;
op->dev.of_node = dp;
intr = of_get_property(dp, "intr", &len);
if (intr) {
op->archdata.num_irqs = len / sizeof(struct linux_prom_irqs);
for (i = 0; i < op->archdata.num_irqs; i++)
op->archdata.irqs[i] =
sparc_config.build_device_irq(op, intr[i].pri);
} else {
const unsigned int *irq =
of_get_property(dp, "interrupts", &len);
if (irq) {
op->archdata.num_irqs = len / sizeof(unsigned int);
for (i = 0; i < op->archdata.num_irqs; i++)
op->archdata.irqs[i] =
sparc_config.build_device_irq(op, irq[i]);
} else {
op->archdata.num_irqs = 0;
}
}
build_device_resources(op, parent);
op->dev.parent = parent;
op->dev.bus = &platform_bus_type;
if (!parent)
dev_set_name(&op->dev, "root");
Annotation
- Immediate include surface: `linux/string.h`, `linux/kernel.h`, `linux/of.h`, `linux/init.h`, `linux/mod_devicetable.h`, `linux/slab.h`, `linux/errno.h`, `linux/irq.h`.
- Detected declarations: `function of_bus_pci_match`, `function of_bus_pci_count_cells`, `function of_bus_pci_map`, `function of_bus_pci_get_flags`, `function of_bus_sbus_get_flags`, `function of_bus_ambapp_match`, `function of_bus_ambapp_count_cells`, `function of_bus_ambapp_map`, `function of_bus_ambapp_get_flags`, `function build_one_resource`.
- Atlas domain: Architecture Layer / arch/sparc.
- Implementation status: integration implementation candidate.
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.