arch/loongarch/kernel/env.c
Source file repositories/reference/linux-study-clean/arch/loongarch/kernel/env.c
File Facts
- System
- Linux kernel
- Corpus path
arch/loongarch/kernel/env.c- Extension
.c- Size
- 2841 bytes
- Lines
- 120
- Domain
- Architecture Layer
- Bucket
- arch/loongarch
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/acpi.hlinux/clk.hlinux/efi.hlinux/export.hlinux/memblock.hlinux/of_clk.hasm/early_ioremap.hasm/bootinfo.hasm/loongson.hasm/setup.hasm/time.h
Detected Declarations
function init_environfunction init_cpu_fullnamefunction fdt_cpu_clk_initfunction boardinfo_showfunction boardinfo_initexport loongson_sysconf
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/*
* Author: Huacai Chen <chenhuacai@loongson.cn>
*
* Copyright (C) 2020-2022 Loongson Technology Corporation Limited
*/
#include <linux/acpi.h>
#include <linux/clk.h>
#include <linux/efi.h>
#include <linux/export.h>
#include <linux/memblock.h>
#include <linux/of_clk.h>
#include <asm/early_ioremap.h>
#include <asm/bootinfo.h>
#include <asm/loongson.h>
#include <asm/setup.h>
#include <asm/time.h>
u64 efi_system_table;
struct loongson_system_configuration loongson_sysconf;
EXPORT_SYMBOL(loongson_sysconf);
void __init init_environ(void)
{
int efi_boot = fw_arg0;
char *cmdline = early_memremap_ro(fw_arg1, COMMAND_LINE_SIZE);
if (efi_boot)
set_bit(EFI_BOOT, &efi.flags);
else
clear_bit(EFI_BOOT, &efi.flags);
strscpy(boot_command_line, cmdline, COMMAND_LINE_SIZE);
strscpy(init_command_line, cmdline, COMMAND_LINE_SIZE);
early_memunmap(cmdline, COMMAND_LINE_SIZE);
efi_system_table = fw_arg2;
}
static int __init init_cpu_fullname(void)
{
int cpu, ret;
char *cpuname;
const char *model;
/* Parsing cpuname from DTS model property */
ret = of_property_read_string(of_root, "model", &model);
if (ret == 0) {
cpuname = kstrdup(model, GFP_KERNEL);
if (!cpuname)
return -ENOMEM;
loongson_sysconf.cpuname = strsep(&cpuname, " ");
}
if (loongson_sysconf.cpuname && !strncmp(loongson_sysconf.cpuname, "Loongson", 8)) {
for (cpu = 0; cpu < NR_CPUS; cpu++)
__cpu_full_name[cpu] = loongson_sysconf.cpuname;
}
return 0;
}
arch_initcall(init_cpu_fullname);
static int __init fdt_cpu_clk_init(void)
{
struct clk *clk;
struct device_node *np;
np = of_get_cpu_node(0, NULL);
if (!np)
return -ENODEV;
clk = of_clk_get(np, 0);
of_node_put(np);
cpu_clock_freq = 200 * 1000 * 1000;
if (IS_ERR(clk)) {
pr_warn("No valid CPU clock freq, assume 200MHz.\n");
return -ENODEV;
}
cpu_clock_freq = clk_get_rate(clk);
clk_put(clk);
return 0;
}
late_initcall(fdt_cpu_clk_init);
static ssize_t boardinfo_show(struct kobject *kobj,
struct kobj_attribute *attr, char *buf)
{
Annotation
- Immediate include surface: `linux/acpi.h`, `linux/clk.h`, `linux/efi.h`, `linux/export.h`, `linux/memblock.h`, `linux/of_clk.h`, `asm/early_ioremap.h`, `asm/bootinfo.h`.
- Detected declarations: `function init_environ`, `function init_cpu_fullname`, `function fdt_cpu_clk_init`, `function boardinfo_show`, `function boardinfo_init`, `export loongson_sysconf`.
- Atlas domain: Architecture Layer / arch/loongarch.
- Implementation status: integration 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.