arch/sparc/kernel/mdesc.c
Source file repositories/reference/linux-study-clean/arch/sparc/kernel/mdesc.c
File Facts
- System
- Linux kernel
- Corpus path
arch/sparc/kernel/mdesc.c- Extension
.c- Size
- 30931 bytes
- Lines
- 1352
- Domain
- Architecture Layer
- Bucket
- arch/sparc
- Inferred role
- Architecture Layer: operation-table or driver-model contract
- Status
- pattern 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 an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/kernel.hlinux/types.hlinux/log2.hlinux/list.hlinux/slab.hlinux/mm.hlinux/miscdevice.hlinux/memblock.hlinux/export.hlinux/refcount.hasm/cpudata.hasm/hypervisor.hasm/mdesc.hasm/prom.hlinux/uaccess.hasm/oplib.hasm/smp.hasm/adi.h
Detected Declarations
struct mdesc_hdrstruct mdesc_elemstruct mdesc_mem_opsstruct mdesc_handlestruct md_node_opsfunction mdesc_get_node_opsfunction mdesc_handle_initfunction mdesc_memblock_allocfunction mdesc_memblock_freefunction mdesc_kfreefunction mdesc_freefunction mdesc_releasefunction mdesc_register_notifierfunction get_vdev_port_node_infofunction rel_vdev_port_node_infofunction vdev_port_node_matchfunction get_ds_port_node_infofunction rel_ds_port_node_infofunction invoke_on_missingfunction mdesc_for_each_node_by_namefunction mdesc_for_each_node_by_namefunction notify_onefunction mdesc_notify_clientsfunction mdesc_updatefunction mdesc_get_nodefunction mdesc_for_each_node_by_namefunction mdesc_get_node_infofunction mdesc_node_by_namefunction mdesc_next_arcfunction mdesc_arc_targetfunction report_platform_propertiesfunction fill_in_one_cachefunction mdesc_for_each_arcfunction find_back_node_valuefunction mdesc_for_each_arcfunction __mark_core_idfunction __mark_max_cache_idfunction mark_core_idsfunction mark_max_cache_idsfunction set_core_idsfunction set_max_cache_ids_by_cachefunction set_sock_ids_by_socketfunction mdesc_for_each_node_by_namefunction mdesc_for_each_arcfunction set_sock_idsfunction mark_proc_idsfunction mdesc_for_each_arcfunction __set_proc_ids
Annotated Snippet
static const struct file_operations mdesc_fops = {
.open = mdesc_open,
.read = mdesc_read,
.llseek = mdesc_llseek,
.release = mdesc_close,
.owner = THIS_MODULE,
};
static struct miscdevice mdesc_misc = {
.minor = MISC_DYNAMIC_MINOR,
.name = "mdesc",
.fops = &mdesc_fops,
};
static int __init mdesc_misc_init(void)
{
return misc_register(&mdesc_misc);
}
__initcall(mdesc_misc_init);
void __init sun4v_mdesc_init(void)
{
struct mdesc_handle *hp;
unsigned long len, real_len, status;
(void) sun4v_mach_desc(0UL, 0UL, &len);
printk("MDESC: Size is %lu bytes.\n", len);
hp = mdesc_alloc(len, &memblock_mdesc_ops);
if (hp == NULL) {
prom_printf("MDESC: alloc of %lu bytes failed.\n", len);
prom_halt();
}
status = sun4v_mach_desc(__pa(&hp->mdesc), len, &real_len);
if (status != HV_EOK || real_len > len) {
prom_printf("sun4v_mach_desc fails, err(%lu), "
"len(%lu), real_len(%lu)\n",
status, len, real_len);
mdesc_free(hp);
prom_halt();
}
cur_mdesc = hp;
mdesc_adi_init();
report_platform_properties();
}
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/types.h`, `linux/log2.h`, `linux/list.h`, `linux/slab.h`, `linux/mm.h`, `linux/miscdevice.h`, `linux/memblock.h`.
- Detected declarations: `struct mdesc_hdr`, `struct mdesc_elem`, `struct mdesc_mem_ops`, `struct mdesc_handle`, `struct md_node_ops`, `function mdesc_get_node_ops`, `function mdesc_handle_init`, `function mdesc_memblock_alloc`, `function mdesc_memblock_free`, `function mdesc_kfree`.
- Atlas domain: Architecture Layer / arch/sparc.
- Implementation status: pattern implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.