arch/powerpc/kernel/rtasd.c
Source file repositories/reference/linux-study-clean/arch/powerpc/kernel/rtasd.c
File Facts
- System
- Linux kernel
- Corpus path
arch/powerpc/kernel/rtasd.c- Extension
.c- Size
- 14565 bytes
- Lines
- 587
- 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.
- 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/types.hlinux/errno.hlinux/sched.hlinux/kernel.hlinux/of.hlinux/poll.hlinux/proc_fs.hlinux/init.hlinux/vmalloc.hlinux/spinlock.hlinux/cpu.hlinux/workqueue.hlinux/slab.hlinux/topology.hlinux/uaccess.hasm/io.hasm/rtas.hasm/nvram.hlinux/atomic.hasm/machdep.hasm/topology.h
Detected Declarations
function bytesfunction log_rtas_lenfunction panicfunction handle_rtas_eventfunction rtas_log_openfunction rtas_log_releasefunction rtas_log_readfunction rtas_log_pollfunction enable_surveillancefunction do_event_scanfunction rtas_event_scanfunction retrieve_nvram_error_logfunction retrieve_nvram_error_logfunction rtas_cancel_event_scanfunction rtas_event_scan_initfunction rtas_initfunction surveillance_setupfunction rtasmsgs_setupexport rtas_cancel_event_scan
Annotated Snippet
if (j == 0) {
memset(buffer, 0, sizeof(buffer));
n = sprintf(buffer, "RTAS %d:", i/perline);
}
if ((i % 4) == 0)
n += sprintf(buffer+n, " ");
n += sprintf(buffer+n, "%02x", (unsigned char)buf[i]);
if (j == (perline-1))
printk(KERN_DEBUG "%s\n", buffer);
}
if ((i % perline) != 0)
printk(KERN_DEBUG "%s\n", buffer);
printk(RTAS_DEBUG "%d -------- %s end ----------\n",
error_log_cnt, str);
} else {
struct rtas_error_log *errlog = (struct rtas_error_log *)buf;
printk(RTAS_DEBUG "event: %d, Type: %s (%d), Severity: %d\n",
error_log_cnt,
rtas_event_type(rtas_error_type(errlog)),
rtas_error_type(errlog),
rtas_error_severity(errlog));
}
}
static int log_rtas_len(char * buf)
{
int len;
struct rtas_error_log *err;
uint32_t extended_log_length;
/* rtas fixed header */
len = 8;
err = (struct rtas_error_log *)buf;
extended_log_length = rtas_error_extended_log_length(err);
if (rtas_error_extended(err) && extended_log_length) {
/* extended header */
len += extended_log_length;
}
if (rtas_error_log_max == 0)
rtas_error_log_max = rtas_get_error_log_max();
if (len > rtas_error_log_max)
len = rtas_error_log_max;
return len;
}
/*
* First write to nvram, if fatal error, that is the only
* place we log the info. The error will be picked up
* on the next reboot by rtasd. If not fatal, run the
* method for the type of error. Currently, only RTAS
* errors have methods implemented, but in the future
* there might be a need to store data in nvram before a
* call to panic().
*
* XXX We write to nvram periodically, to indicate error has
* been written and sync'd, but there is a possibility
* that if we don't shutdown correctly, a duplicate error
* record will be created on next reboot.
*/
void pSeries_log_error(char *buf, unsigned int err_type, int fatal)
{
unsigned long offset;
unsigned long s;
int len = 0;
pr_debug("rtasd: logging event\n");
if (buf == NULL)
return;
spin_lock_irqsave(&rtasd_log_lock, s);
/* get length and increase count */
switch (err_type & ERR_TYPE_MASK) {
case ERR_TYPE_RTAS_LOG:
len = log_rtas_len(buf);
if (!(err_type & ERR_FLAG_BOOT))
error_log_cnt++;
break;
case ERR_TYPE_KERNEL_PANIC:
default:
WARN_ON_ONCE(!irqs_disabled()); /* @@@ DEBUG @@@ */
Annotation
- Immediate include surface: `linux/types.h`, `linux/errno.h`, `linux/sched.h`, `linux/kernel.h`, `linux/of.h`, `linux/poll.h`, `linux/proc_fs.h`, `linux/init.h`.
- Detected declarations: `function bytes`, `function log_rtas_len`, `function panic`, `function handle_rtas_event`, `function rtas_log_open`, `function rtas_log_release`, `function rtas_log_read`, `function rtas_log_poll`, `function enable_surveillance`, `function do_event_scan`.
- Atlas domain: Architecture Layer / arch/powerpc.
- Implementation status: integration 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.