arch/sparc/kernel/devices.c
Source file repositories/reference/linux-study-clean/arch/sparc/kernel/devices.c
File Facts
- System
- Linux kernel
- Corpus path
arch/sparc/kernel/devices.c- Extension
.c- Size
- 3119 bytes
- Lines
- 139
- Domain
- Architecture Layer
- Bucket
- arch/sparc
- Inferred role
- Architecture Layer: implementation source
- Status
- source 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hlinux/threads.hlinux/string.hlinux/init.hlinux/errno.hasm/page.hasm/oplib.hasm/prom.hasm/smp.hasm/cpudata.hasm/cpu_type.hasm/setup.hkernel.h
Detected Declarations
function Copyrightfunction check_cpu_nodefunction __cpu_find_byfunction cpu_instance_comparefunction cpu_find_by_instancefunction cpu_mid_comparefunction cpu_find_by_midfunction addressfunction device_scan
Annotated Snippet
if (mid) {
*mid = prom_getintdefault(nd, cpu_mid_prop(), 0);
if (sparc_cpu_model == sun4m)
*mid &= 3;
}
return 0;
}
(*cur_inst)++;
return -ENODEV;
}
static int __cpu_find_by(int (*compare)(phandle, int, void *),
void *compare_arg, phandle *prom_node, int *mid)
{
struct device_node *dp;
int cur_inst;
cur_inst = 0;
for_each_node_by_type(dp, "cpu") {
int err = check_cpu_node(dp->phandle, &cur_inst,
compare, compare_arg,
prom_node, mid);
if (!err) {
of_node_put(dp);
return 0;
}
}
return -ENODEV;
}
static int cpu_instance_compare(phandle nd, int instance, void *_arg)
{
int desired_instance = (int) _arg;
if (instance == desired_instance)
return 0;
return -ENODEV;
}
int cpu_find_by_instance(int instance, phandle *prom_node, int *mid)
{
return __cpu_find_by(cpu_instance_compare, (void *)instance,
prom_node, mid);
}
static int cpu_mid_compare(phandle nd, int instance, void *_arg)
{
int desired_mid = (int) _arg;
int this_mid;
this_mid = prom_getintdefault(nd, cpu_mid_prop(), 0);
if (this_mid == desired_mid
|| (sparc_cpu_model == sun4m && (this_mid & 3) == desired_mid))
return 0;
return -ENODEV;
}
int cpu_find_by_mid(int mid, phandle *prom_node)
{
return __cpu_find_by(cpu_mid_compare, (void *)mid,
prom_node, NULL);
}
/* sun4m uses truncated mids since we base the cpuid on the ttable/irqset
* address (0-3). This gives us the true hardware mid, which might have
* some other bits set. On 4d hardware and software mids are the same.
*/
int cpu_get_hwmid(phandle prom_node)
{
return prom_getintdefault(prom_node, cpu_mid_prop(), -ENODEV);
}
void __init device_scan(void)
{
printk(KERN_NOTICE "Booting Linux...\n");
#ifndef CONFIG_SMP
{
phandle cpu_node;
int err;
err = cpu_find_by_instance(0, &cpu_node, NULL);
if (err) {
/* Probably a sun4e, Sun is trying to trick us ;-) */
prom_printf("No cpu nodes, cannot continue\n");
prom_halt();
}
cpu_data(0).clock_tick = prom_getintdefault(cpu_node,
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/threads.h`, `linux/string.h`, `linux/init.h`, `linux/errno.h`, `asm/page.h`, `asm/oplib.h`, `asm/prom.h`.
- Detected declarations: `function Copyright`, `function check_cpu_node`, `function __cpu_find_by`, `function cpu_instance_compare`, `function cpu_find_by_instance`, `function cpu_mid_compare`, `function cpu_find_by_mid`, `function address`, `function device_scan`.
- Atlas domain: Architecture Layer / arch/sparc.
- Implementation status: source 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.