arch/powerpc/platforms/powermac/nvram.c
Source file repositories/reference/linux-study-clean/arch/powerpc/platforms/powermac/nvram.c
File Facts
- System
- Linux kernel
- Corpus path
arch/powerpc/platforms/powermac/nvram.c- Extension
.c- Size
- 15328 bytes
- Lines
- 654
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/export.hlinux/kernel.hlinux/stddef.hlinux/string.hlinux/nvram.hlinux/init.hlinux/delay.hlinux/errno.hlinux/adb.hlinux/pmu.hlinux/memblock.hlinux/completion.hlinux/spinlock.hlinux/of_address.hasm/sections.hasm/io.hasm/machdep.hasm/nvram.hpmac.h
Detected Declarations
struct chrp_headerstruct core99_headerfunction core99_nvram_read_bytefunction core99_nvram_write_bytefunction core99_nvram_readfunction core99_nvram_writefunction core99_nvram_sizefunction ppc32_nvram_sizefunction direct_nvram_read_bytefunction direct_nvram_write_bytefunction indirect_nvram_read_bytefunction indirect_nvram_write_bytefunction pmu_nvram_completefunction pmu_nvram_read_bytefunction pmu_nvram_write_bytefunction chrp_checksumfunction core99_calc_adlerfunction core99_checkfunction sm_erase_bankfunction sm_write_bankfunction amd_erase_bankfunction amd_write_bankfunction lookup_partitionsfunction core99_nvram_syncfunction core99_nvram_setupfunction pmac_nvram_initfunction pmac_get_partitionfunction pmac_xpram_readfunction pmac_xpram_writeexport pmac_get_partitionexport pmac_xpram_readexport pmac_xpram_write
Annotated Snippet
struct chrp_header {
u8 signature;
u8 cksum;
u16 len;
char name[12];
u8 data[];
};
struct core99_header {
struct chrp_header hdr;
u32 adler;
u32 generation;
u32 reserved[2];
};
/*
* Read and write the non-volatile RAM on PowerMacs and CHRP machines.
*/
static int nvram_naddrs;
static volatile unsigned char __iomem *nvram_data;
static int is_core_99;
static int core99_bank;
static int nvram_partitions[3];
// XXX Turn that into a sem
static DEFINE_RAW_SPINLOCK(nv_lock);
static int (*core99_write_bank)(int bank, u8* datas);
static int (*core99_erase_bank)(int bank);
static char *nvram_image;
static unsigned char core99_nvram_read_byte(int addr)
{
if (nvram_image == NULL)
return 0xff;
return nvram_image[addr];
}
static void core99_nvram_write_byte(int addr, unsigned char val)
{
if (nvram_image == NULL)
return;
nvram_image[addr] = val;
}
static ssize_t core99_nvram_read(char *buf, size_t count, loff_t *index)
{
int i;
if (nvram_image == NULL)
return -ENODEV;
if (*index > NVRAM_SIZE)
return 0;
i = *index;
if (i + count > NVRAM_SIZE)
count = NVRAM_SIZE - i;
memcpy(buf, &nvram_image[i], count);
*index = i + count;
return count;
}
static ssize_t core99_nvram_write(char *buf, size_t count, loff_t *index)
{
int i;
if (nvram_image == NULL)
return -ENODEV;
if (*index > NVRAM_SIZE)
return 0;
i = *index;
if (i + count > NVRAM_SIZE)
count = NVRAM_SIZE - i;
memcpy(&nvram_image[i], buf, count);
*index = i + count;
return count;
}
static ssize_t core99_nvram_size(void)
{
if (nvram_image == NULL)
return -ENODEV;
return NVRAM_SIZE;
}
#ifdef CONFIG_PPC32
Annotation
- Immediate include surface: `linux/export.h`, `linux/kernel.h`, `linux/stddef.h`, `linux/string.h`, `linux/nvram.h`, `linux/init.h`, `linux/delay.h`, `linux/errno.h`.
- Detected declarations: `struct chrp_header`, `struct core99_header`, `function core99_nvram_read_byte`, `function core99_nvram_write_byte`, `function core99_nvram_read`, `function core99_nvram_write`, `function core99_nvram_size`, `function ppc32_nvram_size`, `function direct_nvram_read_byte`, `function direct_nvram_write_byte`.
- 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.
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.