arch/powerpc/kernel/nvram_64.c
Source file repositories/reference/linux-study-clean/arch/powerpc/kernel/nvram_64.c
File Facts
- System
- Linux kernel
- Corpus path
arch/powerpc/kernel/nvram_64.c- Extension
.c- Size
- 28143 bytes
- Lines
- 1056
- Domain
- Architecture Layer
- Bucket
- arch/powerpc
- 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.
- 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/fs.hlinux/miscdevice.hlinux/fcntl.hlinux/nvram.hlinux/init.hlinux/slab.hlinux/spinlock.hlinux/kmsg_dump.hlinux/pagemap.hlinux/pstore.hlinux/zlib.hlinux/uaccess.hlinux/of.hasm/nvram.hasm/rtas.hasm/machdep.h
Detected Declarations
struct nvram_headerstruct nvram_partitionfunction Headerfunction nvram_read_partitionfunction nvram_init_os_partitionfunction nvram_compressfunction zip_oopsfunction nvram_pstore_openfunction pstore_dumpfunction nvram_pstore_readfunction nvram_pstore_initfunction nvram_pstore_initfunction nvram_init_oops_partitionfunction oops_to_nvramfunction nvram_print_partitionsfunction nvram_write_headerfunction nvram_checksumfunction nvram_remove_partitionfunction nvram_remove_partitionfunction list_for_each_entryfunction nvram_partition_get_sizefunction nvram_create_partitionfunction list_for_each_entryfunction nvram_find_partitionfunction list_for_each_entryfunction nvram_scan_partitions
Annotated Snippet
struct nvram_header {
unsigned char signature;
unsigned char checksum;
unsigned short length;
/* Terminating null required only for names < 12 chars. */
char name[12];
};
struct nvram_partition {
struct list_head partition;
struct nvram_header header;
unsigned int index;
};
static LIST_HEAD(nvram_partitions);
#ifdef CONFIG_PPC_PSERIES
struct nvram_os_partition rtas_log_partition = {
.name = "ibm,rtas-log",
.req_size = 2079,
.min_size = 1055,
.index = -1,
.os_partition = true
};
#endif
struct nvram_os_partition oops_log_partition = {
.name = "lnx,oops-log",
.req_size = 4000,
.min_size = 2000,
.index = -1,
.os_partition = true
};
static const char *nvram_os_partitions[] = {
#ifdef CONFIG_PPC_PSERIES
"ibm,rtas-log",
#endif
"lnx,oops-log",
NULL
};
static void oops_to_nvram(struct kmsg_dumper *dumper,
struct kmsg_dump_detail *detail);
static struct kmsg_dumper nvram_kmsg_dumper = {
.dump = oops_to_nvram
};
/*
* For capturing and compressing an oops or panic report...
* big_oops_buf[] holds the uncompressed text we're capturing.
*
* oops_buf[] holds the compressed text, preceded by a oops header.
* oops header has u16 holding the version of oops header (to differentiate
* between old and new format header) followed by u16 holding the length of
* the compressed* text (*Or uncompressed, if compression fails.) and u64
* holding the timestamp. oops_buf[] gets written to NVRAM.
*
* oops_log_info points to the header. oops_data points to the compressed text.
*
* +- oops_buf
* | +- oops_data
* v v
* +-----------+-----------+-----------+------------------------+
* | version | length | timestamp | text |
* | (2 bytes) | (2 bytes) | (8 bytes) | (oops_data_sz bytes) |
* +-----------+-----------+-----------+------------------------+
* ^
* +- oops_log_info
*
* We preallocate these buffers during init to avoid kmalloc during oops/panic.
*/
static size_t big_oops_buf_sz;
static char *big_oops_buf, *oops_buf;
static char *oops_data;
static size_t oops_data_sz;
/* Compression parameters */
#define COMPR_LEVEL 6
#define WINDOW_BITS 12
#define MEM_LEVEL 4
static struct z_stream_s stream;
#ifdef CONFIG_PSTORE
#ifdef CONFIG_PPC_POWERNV
static struct nvram_os_partition skiboot_partition = {
.name = "ibm,skiboot",
.index = -1,
Annotation
- Immediate include surface: `linux/types.h`, `linux/errno.h`, `linux/fs.h`, `linux/miscdevice.h`, `linux/fcntl.h`, `linux/nvram.h`, `linux/init.h`, `linux/slab.h`.
- Detected declarations: `struct nvram_header`, `struct nvram_partition`, `function Header`, `function nvram_read_partition`, `function nvram_init_os_partition`, `function nvram_compress`, `function zip_oops`, `function nvram_pstore_open`, `function pstore_dump`, `function nvram_pstore_read`.
- Atlas domain: Architecture Layer / arch/powerpc.
- 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.