include/linux/nvram.h
Source file repositories/reference/linux-study-clean/include/linux/nvram.h
File Facts
- System
- Linux kernel
- Corpus path
include/linux/nvram.h- Extension
.h- Size
- 3550 bytes
- Lines
- 134
- Domain
- Core OS
- Bucket
- Core Kernel Interface
- Inferred role
- Core OS: implementation source
- Status
- source implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/errno.huapi/linux/nvram.hasm/machdep.h
Detected Declarations
struct nvram_opsfunction nvram_get_sizefunction nvram_read_bytefunction nvram_write_bytefunction nvram_read_bytesfunction nvram_write_bytesfunction nvram_readfunction nvram_write
Annotated Snippet
struct nvram_ops {
ssize_t (*get_size)(void);
unsigned char (*read_byte)(int);
void (*write_byte)(unsigned char, int);
ssize_t (*read)(char *, size_t, loff_t *);
ssize_t (*write)(char *, size_t, loff_t *);
#if defined(CONFIG_X86) || defined(CONFIG_M68K)
long (*initialize)(void);
long (*set_checksum)(void);
#endif
};
extern const struct nvram_ops arch_nvram_ops;
static inline ssize_t nvram_get_size(void)
{
#ifdef CONFIG_PPC
if (ppc_md.nvram_size)
return ppc_md.nvram_size();
#else
if (arch_nvram_ops.get_size)
return arch_nvram_ops.get_size();
#endif
return -ENODEV;
}
static inline unsigned char nvram_read_byte(int addr)
{
#ifdef CONFIG_PPC
if (ppc_md.nvram_read_val)
return ppc_md.nvram_read_val(addr);
#else
if (arch_nvram_ops.read_byte)
return arch_nvram_ops.read_byte(addr);
#endif
return 0xFF;
}
static inline void nvram_write_byte(unsigned char val, int addr)
{
#ifdef CONFIG_PPC
if (ppc_md.nvram_write_val)
ppc_md.nvram_write_val(addr, val);
#else
if (arch_nvram_ops.write_byte)
arch_nvram_ops.write_byte(val, addr);
#endif
}
static inline ssize_t nvram_read_bytes(char *buf, size_t count, loff_t *ppos)
{
ssize_t nvram_size = nvram_get_size();
loff_t i;
char *p = buf;
if (nvram_size < 0)
return nvram_size;
for (i = *ppos; count > 0 && i < nvram_size; ++i, ++p, --count)
*p = nvram_read_byte(i);
*ppos = i;
return p - buf;
}
static inline ssize_t nvram_write_bytes(char *buf, size_t count, loff_t *ppos)
{
ssize_t nvram_size = nvram_get_size();
loff_t i;
char *p = buf;
if (nvram_size < 0)
return nvram_size;
for (i = *ppos; count > 0 && i < nvram_size; ++i, ++p, --count)
nvram_write_byte(*p, i);
*ppos = i;
return p - buf;
}
static inline ssize_t nvram_read(char *buf, size_t count, loff_t *ppos)
{
#ifdef CONFIG_PPC
if (ppc_md.nvram_read)
return ppc_md.nvram_read(buf, count, ppos);
#else
if (arch_nvram_ops.read)
return arch_nvram_ops.read(buf, count, ppos);
#endif
return nvram_read_bytes(buf, count, ppos);
}
static inline ssize_t nvram_write(char *buf, size_t count, loff_t *ppos)
Annotation
- Immediate include surface: `linux/errno.h`, `uapi/linux/nvram.h`, `asm/machdep.h`.
- Detected declarations: `struct nvram_ops`, `function nvram_get_size`, `function nvram_read_byte`, `function nvram_write_byte`, `function nvram_read_bytes`, `function nvram_write_bytes`, `function nvram_read`, `function nvram_write`.
- Atlas domain: Core OS / Core Kernel Interface.
- 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.