arch/loongarch/kernel/proc.c

Source file repositories/reference/linux-study-clean/arch/loongarch/kernel/proc.c

File Facts

System
Linux kernel
Corpus path
arch/loongarch/kernel/proc.c
Extension
.c
Size
3585 bytes
Lines
133
Domain
Architecture Layer
Bucket
arch/loongarch
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.

Dependency Surface

Detected Declarations

Annotated Snippet

// SPDX-License-Identifier: GPL-2.0
/*
 * Copyright (C) 2020-2022 Loongson Technology Corporation Limited
 */
#include <linux/delay.h>
#include <linux/kernel.h>
#include <linux/sched.h>
#include <linux/seq_file.h>
#include <asm/bootinfo.h>
#include <asm/cpu.h>
#include <asm/cpu-features.h>
#include <asm/idle.h>
#include <asm/processor.h>
#include <asm/time.h>

static int show_cpuinfo(struct seq_file *m, void *v)
{
	unsigned long n = (unsigned long) v - 1;
	unsigned int isa = cpu_data[n].isa_level;
	unsigned int prid = cpu_data[n].processor_id;
	unsigned int version = cpu_data[n].processor_id & 0xff;
	unsigned int fp_version = cpu_data[n].fpu_vers;
	u64 freq = cpu_clock_freq, bogomips = lpj_fine * cpu_clock_freq;

#ifdef CONFIG_SMP
	if (!cpu_online(n))
		return 0;
#endif
	do_div(freq, 10000);
	do_div(bogomips, const_clock_freq * (5000/HZ));

	/*
	 * For the first processor also print the system type
	 */
	if (n == 0)
		seq_printf(m, "system type\t\t: %s\n\n", get_system_type());

	seq_printf(m, "processor\t\t: %ld\n", n);
	seq_printf(m, "package\t\t\t: %d\n", cpu_data[n].package);
	seq_printf(m, "core\t\t\t: %d\n", cpu_data[n].core);
	seq_printf(m, "global_id\t\t: %d\n", cpu_data[n].global_id);
	seq_printf(m, "CPU Family\t\t: %s\n", __cpu_family[n]);
	seq_printf(m, "Model Name\t\t: %s\n", __cpu_full_name[n]);
	seq_printf(m, "PRID\t\t\t: %s (%08x)\n", id_to_core_name(prid), prid);
	seq_printf(m, "CPU Revision\t\t: 0x%02x\n", version);
	seq_printf(m, "FPU Revision\t\t: 0x%02x\n", fp_version);
	seq_printf(m, "CPU MHz\t\t\t: %u.%02u\n", (u32)freq / 100, (u32)freq % 100);
	seq_printf(m, "BogoMIPS\t\t: %u.%02u\n", (u32)bogomips / 100, (u32)bogomips % 100);
	seq_printf(m, "TLB Entries\t\t: %d\n", cpu_data[n].tlbsize);
	seq_printf(m, "Address Sizes\t\t: %d bits physical, %d bits virtual\n",
		      cpu_pabits + 1, cpu_vabits + 1);

	seq_puts(m, "ISA\t\t\t:");
	if (isa & LOONGARCH_CPU_ISA_LA32R)
		seq_puts(m, " loongarch32r");
	if (isa & LOONGARCH_CPU_ISA_LA32S)
		seq_puts(m, " loongarch32s");
	if (isa & LOONGARCH_CPU_ISA_LA64)
		seq_puts(m, " loongarch64");
	seq_puts(m, "\n");

	seq_puts(m, "Features\t\t:");
	if (cpu_has_cpucfg)
		seq_puts(m, " cpucfg");
	if (cpu_has_lam)
		seq_puts(m, " lam");
	if (cpu_has_lam_bh)
		seq_puts(m, " lam_bh");
	if (cpu_has_scq)
		seq_puts(m, " scq");
	if (cpu_has_ual)
		seq_puts(m, " ual");
	if (cpu_has_fpu)
		seq_puts(m, " fpu");
	if (cpu_has_lsx)
		seq_puts(m, " lsx");
	if (cpu_has_lasx)
		seq_puts(m, " lasx");
	if (cpu_has_crc32)
		seq_puts(m, " crc32");
	if (cpu_has_complex)
		seq_puts(m, " complex");
	if (cpu_has_crypto)
		seq_puts(m, " crypto");
	if (cpu_has_ptw)
		seq_puts(m, " ptw");
	if (cpu_has_lspw)
		seq_puts(m, " lspw");
	if (cpu_has_lvz)
		seq_puts(m, " lvz");

Annotation

Implementation Notes