arch/powerpc/platforms/powernv/opal-xscom.c
Source file repositories/reference/linux-study-clean/arch/powerpc/platforms/powernv/opal-xscom.c
File Facts
- System
- Linux kernel
- Corpus path
arch/powerpc/platforms/powernv/opal-xscom.c- Extension
.c- Size
- 4583 bytes
- Lines
- 211
- Domain
- Architecture Layer
- Bucket
- arch/powerpc
- 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.
- 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/of.hlinux/bug.hlinux/gfp.hlinux/slab.hlinux/uaccess.hlinux/debugfs.hasm/machdep.hasm/firmware.hasm/opal.hasm/prom.h
Detected Declarations
struct scom_debug_entryfunction opal_scom_unmanglefunction opal_scom_readfunction opal_scom_writefunction scom_debug_readfunction scom_debug_writefunction scom_debug_init_onefunction scom_debug_initmodule init scom_debug_init
Annotated Snippet
static const struct file_operations scom_debug_fops = {
.read = scom_debug_read,
.write = scom_debug_write,
.open = simple_open,
.llseek = default_llseek,
};
static int scom_debug_init_one(struct dentry *root, struct device_node *dn,
int chip)
{
struct scom_debug_entry *ent;
struct dentry *dir;
ent = kzalloc_obj(*ent);
if (!ent)
return -ENOMEM;
ent->chip = chip;
snprintf(ent->name, 16, "%08x", chip);
ent->path.data = (void *)kasprintf(GFP_KERNEL, "%pOF", dn);
if (!ent->path.data) {
kfree(ent);
return -ENOMEM;
}
ent->path.size = strlen((char *)ent->path.data);
dir = debugfs_create_dir(ent->name, root);
if (IS_ERR(dir)) {
kfree(ent->path.data);
kfree(ent);
return -1;
}
debugfs_create_blob("devspec", 0400, dir, &ent->path);
debugfs_create_file("access", 0600, dir, ent, &scom_debug_fops);
return 0;
}
static int scom_debug_init(void)
{
struct device_node *dn;
struct dentry *root;
int chip, rc;
if (!firmware_has_feature(FW_FEATURE_OPAL))
return 0;
root = debugfs_create_dir("scom", arch_debugfs_dir);
if (IS_ERR(root))
return -1;
rc = 0;
for_each_node_with_property(dn, "scom-controller") {
chip = of_get_ibm_chip_id(dn);
WARN_ON(chip == -1);
rc |= scom_debug_init_one(root, dn, chip);
}
return rc;
}
device_initcall(scom_debug_init);
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/of.h`, `linux/bug.h`, `linux/gfp.h`, `linux/slab.h`, `linux/uaccess.h`, `linux/debugfs.h`, `asm/machdep.h`.
- Detected declarations: `struct scom_debug_entry`, `function opal_scom_unmangle`, `function opal_scom_read`, `function opal_scom_write`, `function scom_debug_read`, `function scom_debug_write`, `function scom_debug_init_one`, `function scom_debug_init`, `module init scom_debug_init`.
- Atlas domain: Architecture Layer / arch/powerpc.
- Implementation status: pattern implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
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.