arch/powerpc/platforms/powernv/opal.c
Source file repositories/reference/linux-study-clean/arch/powerpc/platforms/powernv/opal.c
File Facts
- System
- Linux kernel
- Corpus path
arch/powerpc/platforms/powernv/opal.c- Extension
.c- Size
- 30124 bytes
- Lines
- 1243
- Domain
- Architecture Layer
- Bucket
- arch/powerpc
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/printk.hlinux/types.hlinux/of.hlinux/of_fdt.hlinux/of_platform.hlinux/of_address.hlinux/interrupt.hlinux/notifier.hlinux/slab.hlinux/sched.hlinux/kobject.hlinux/delay.hlinux/memblock.hlinux/kthread.hlinux/freezer.hlinux/kmsg_dump.hlinux/console.hlinux/sched/debug.hasm/machdep.hasm/opal.hasm/firmware.hasm/mce.hasm/imc-pmu.hasm/bug.hpowernv.h
Detected Declarations
struct opal_msg_nodestruct opalstruct mcheck_recoverable_rangefunction opal_configure_coresfunction early_init_dt_scan_opalfunction early_init_dt_scan_recoverable_rangesfunction opal_register_exception_handlersfunction newerfunction queue_replay_msgfunction dequeue_replay_msgfunction list_for_each_entry_safefunction opal_message_notifier_registerfunction opal_message_notifier_unregisterfunction opal_message_do_notifyfunction opal_handle_messagefunction opal_message_notifyfunction opal_message_initfunction opal_get_charsfunction __opal_put_charsfunction opal_put_charsfunction opal_put_chars_atomicfunction __opal_flush_consolefunction opal_flush_consolefunction opal_flush_charsfunction opal_recover_mcefunction pnv_platform_error_rebootfunction opal_machine_checkfunction opal_hmi_exception_earlyfunction opal_hmi_exception_early2function opal_handle_hmi_exceptionfunction find_recovery_addressfunction opal_mce_check_early_recoveryfunction opal_sysfs_initfunction opal_add_one_exportfunction opal_add_exported_attrsfunction for_each_property_of_nodefunction for_each_child_of_nodefunction regionsfunction opal_dump_region_initfunction opal_pdev_initfunction opal_imc_init_devfunction kopaldfunction opal_wake_pollerfunction opal_init_heartbeatfunction opal_initfunction for_each_child_of_nodefunction opal_shutdownfunction opal_free_sg_list
Annotated Snippet
struct opal_msg_node {
struct list_head list;
struct opal_msg msg;
};
static DEFINE_SPINLOCK(msg_list_lock);
static LIST_HEAD(msg_list);
/* /sys/firmware/opal */
struct kobject *opal_kobj;
struct opal {
u64 base;
u64 entry;
u64 size;
} opal;
struct mcheck_recoverable_range {
u64 start_addr;
u64 end_addr;
u64 recover_addr;
};
static int msg_list_size;
static struct mcheck_recoverable_range *mc_recoverable_range;
static int mc_recoverable_range_len;
struct device_node *opal_node;
static DEFINE_SPINLOCK(opal_write_lock);
static struct atomic_notifier_head opal_msg_notifier_head[OPAL_MSG_TYPE_MAX];
static uint32_t opal_heartbeat;
static struct task_struct *kopald_tsk;
static struct opal_msg *opal_msg;
static u32 opal_msg_size __ro_after_init;
void __init opal_configure_cores(void)
{
u64 reinit_flags = 0;
/* Do the actual re-init, This will clobber all FPRs, VRs, etc...
*
* It will preserve non volatile GPRs and HSPRG0/1. It will
* also restore HIDs and other SPRs to their original value
* but it might clobber a bunch.
*/
#ifdef __BIG_ENDIAN__
reinit_flags |= OPAL_REINIT_CPUS_HILE_BE;
#else
reinit_flags |= OPAL_REINIT_CPUS_HILE_LE;
#endif
/*
* POWER9 always support running hash:
* ie. Host hash supports hash guests
* Host radix supports hash/radix guests
*/
if (early_cpu_has_feature(CPU_FTR_ARCH_300)) {
reinit_flags |= OPAL_REINIT_CPUS_MMU_HASH;
if (early_radix_enabled())
reinit_flags |= OPAL_REINIT_CPUS_MMU_RADIX;
}
opal_reinit_cpus(reinit_flags);
/* Restore some bits */
if (cur_cpu_spec->cpu_restore)
cur_cpu_spec->cpu_restore();
}
int __init early_init_dt_scan_opal(unsigned long node,
const char *uname, int depth, void *data)
{
const void *basep, *entryp, *sizep;
int basesz, entrysz, runtimesz;
if (depth != 1 || strcmp(uname, "ibm,opal") != 0)
return 0;
basep = of_get_flat_dt_prop(node, "opal-base-address", &basesz);
entryp = of_get_flat_dt_prop(node, "opal-entry-address", &entrysz);
sizep = of_get_flat_dt_prop(node, "opal-runtime-size", &runtimesz);
if (!basep || !entryp || !sizep)
return 1;
opal.base = of_read_number(basep, basesz/4);
opal.entry = of_read_number(entryp, entrysz/4);
opal.size = of_read_number(sizep, runtimesz/4);
Annotation
- Immediate include surface: `linux/printk.h`, `linux/types.h`, `linux/of.h`, `linux/of_fdt.h`, `linux/of_platform.h`, `linux/of_address.h`, `linux/interrupt.h`, `linux/notifier.h`.
- Detected declarations: `struct opal_msg_node`, `struct opal`, `struct mcheck_recoverable_range`, `function opal_configure_cores`, `function early_init_dt_scan_opal`, `function early_init_dt_scan_recoverable_ranges`, `function opal_register_exception_handlers`, `function newer`, `function queue_replay_msg`, `function dequeue_replay_msg`.
- Atlas domain: Architecture Layer / arch/powerpc.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- 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.