arch/m68k/kernel/bootinfo_proc.c
Source file repositories/reference/linux-study-clean/arch/m68k/kernel/bootinfo_proc.c
File Facts
- System
- Linux kernel
- Corpus path
arch/m68k/kernel/bootinfo_proc.c- Extension
.c- Size
- 1705 bytes
- Lines
- 80
- Domain
- Architecture Layer
- Bucket
- arch/m68k
- 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/fs.hlinux/init.hlinux/printk.hlinux/proc_fs.hlinux/slab.hlinux/string.hasm/bootinfo.hasm/byteorder.h
Detected Declarations
function bootinfo_readfunction save_bootinfofunction init_bootinfo_procfs
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/*
* Based on arch/arm/kernel/atags_proc.c
*/
#include <linux/fs.h>
#include <linux/init.h>
#include <linux/printk.h>
#include <linux/proc_fs.h>
#include <linux/slab.h>
#include <linux/string.h>
#include <asm/bootinfo.h>
#include <asm/byteorder.h>
static char bootinfo_tmp[1536] __initdata;
static void *bootinfo_copy;
static size_t bootinfo_size;
static ssize_t bootinfo_read(struct file *file, char __user *buf,
size_t count, loff_t *ppos)
{
return simple_read_from_buffer(buf, count, ppos, bootinfo_copy,
bootinfo_size);
}
static const struct proc_ops bootinfo_proc_ops = {
.proc_read = bootinfo_read,
.proc_lseek = default_llseek,
};
void __init save_bootinfo(const struct bi_record *bi)
{
const void *start = bi;
size_t size = sizeof(bi->tag);
while (be16_to_cpu(bi->tag) != BI_LAST) {
uint16_t n = be16_to_cpu(bi->size);
size += n;
bi = (struct bi_record *)((unsigned long)bi + n);
}
if (size > sizeof(bootinfo_tmp)) {
pr_err("Cannot save %zu bytes of bootinfo\n", size);
return;
}
pr_info("Saving %zu bytes of bootinfo\n", size);
memcpy(bootinfo_tmp, start, size);
bootinfo_size = size;
}
static int __init init_bootinfo_procfs(void)
{
/*
* This cannot go into save_bootinfo() because kmalloc and proc don't
* work yet when it is called.
*/
struct proc_dir_entry *pde;
if (!bootinfo_size)
return -EINVAL;
bootinfo_copy = kmemdup(bootinfo_tmp, bootinfo_size, GFP_KERNEL);
if (!bootinfo_copy)
return -ENOMEM;
pde = proc_create_data("bootinfo", 0400, NULL, &bootinfo_proc_ops, NULL);
if (!pde) {
kfree(bootinfo_copy);
return -ENOMEM;
}
return 0;
}
arch_initcall(init_bootinfo_procfs);
Annotation
- Immediate include surface: `linux/fs.h`, `linux/init.h`, `linux/printk.h`, `linux/proc_fs.h`, `linux/slab.h`, `linux/string.h`, `asm/bootinfo.h`, `asm/byteorder.h`.
- Detected declarations: `function bootinfo_read`, `function save_bootinfo`, `function init_bootinfo_procfs`.
- Atlas domain: Architecture Layer / arch/m68k.
- 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.