arch/loongarch/kernel/setup.c
Source file repositories/reference/linux-study-clean/arch/loongarch/kernel/setup.c
File Facts
- System
- Linux kernel
- Corpus path
arch/loongarch/kernel/setup.c- Extension
.c- Size
- 15409 bytes
- Lines
- 621
- 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.
- 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/init.hlinux/acpi.hlinux/cpu.hlinux/dmi.hlinux/efi.hlinux/export.hlinux/memblock.hlinux/initrd.hlinux/ioport.hlinux/kexec.hlinux/crash_dump.hlinux/root_dev.hlinux/console.hlinux/pfn.hlinux/platform_device.hlinux/sizes.hlinux/device.hlinux/dma-map-ops.hlinux/libfdt.hlinux/of_fdt.hlinux/of_address.hlinux/suspend.hlinux/swiotlb.hasm/addrspace.hasm/alternative.hasm/bootinfo.hasm/cache.hasm/cpu.hasm/dma.hasm/efi.hasm/loongson.hasm/numa.h
Detected Declarations
function arch_cpu_finalize_initfunction parse_cpu_tablefunction parse_bios_tablefunction find_tokensfunction smbios_parsefunction setup_writecombinefunction early_parse_memfunction arch_reserve_vmcorefunction arch_reserve_crashkernelfunction fdt_setupfunction bootcmdline_initfunction early_init_dt_scan_chosenfunction platform_initfunction check_kernel_sections_memfunction arch_mem_initfunction resource_initfunction for_each_mem_regionfunction add_legacy_isa_iofunction arch_reserve_pio_rangefunction for_each_node_by_namefunction for_each_of_rangefunction reserve_memblock_reserved_regionsfunction for_each_reserved_mem_rangefunction prefill_possible_mapfunction setup_archexport cpu_dataexport wc_enabled
Annotated Snippet
while (s > 0 && *bp) {
bp += strlen(bp) + 1;
s--;
}
if (*bp != 0) {
size_t len = strlen(bp)+1;
size_t cmp_len = len > 8 ? 8 : len;
if (!memcmp(bp, dmi_empty_string, cmp_len))
return dmi_empty_string;
return bp;
}
}
return "";
}
static void __init parse_cpu_table(const struct dmi_header *dm)
{
long freq_temp = 0;
char *dmi_data = (char *)dm;
freq_temp = ((*(dmi_data + SMBIOS_FREQHIGH_OFFSET) << 8) +
((*(dmi_data + SMBIOS_FREQLOW_OFFSET)) & SMBIOS_FREQLOW_MASK));
cpu_clock_freq = freq_temp * 1000000;
loongson_sysconf.cpuname = (void *)dmi_string_parse(dm, dmi_data[16]);
loongson_sysconf.cores_per_package = *(u8 *)(dmi_data + SMBIOS_THREAD_PACKAGE_OFFSET);
if (dm->length >= 0x30 && loongson_sysconf.cores_per_package == 0xff) {
/* SMBIOS 3.0+ has ThreadCount2 for more than 255 threads */
loongson_sysconf.cores_per_package =
*(u16 *)(dmi_data + SMBIOS_THREAD_PACKAGE_2_OFFSET);
}
pr_info("CpuClock = %llu\n", cpu_clock_freq);
}
static void __init parse_bios_table(const struct dmi_header *dm)
{
char *dmi_data = (char *)dm;
b_info.bios_size = (*(dmi_data + SMBIOS_BIOSSIZE_OFFSET) + 1) << 6;
}
static void __init find_tokens(const struct dmi_header *dm, void *dummy)
{
switch (dm->type) {
case 0x0: /* Extern BIOS */
parse_bios_table(dm);
break;
case 0x4: /* Calling interface */
parse_cpu_table(dm);
break;
}
}
static void __init smbios_parse(void)
{
b_info.bios_vendor = (void *)dmi_get_system_info(DMI_BIOS_VENDOR);
b_info.bios_version = (void *)dmi_get_system_info(DMI_BIOS_VERSION);
b_info.bios_release_date = (void *)dmi_get_system_info(DMI_BIOS_DATE);
b_info.board_vendor = (void *)dmi_get_system_info(DMI_BOARD_VENDOR);
b_info.board_name = (void *)dmi_get_system_info(DMI_BOARD_NAME);
dmi_walk(find_tokens, NULL);
}
#ifdef CONFIG_ARCH_WRITECOMBINE
bool wc_enabled = true;
#else
bool wc_enabled = false;
#endif
EXPORT_SYMBOL(wc_enabled);
static int __init setup_writecombine(char *p)
{
if (!strcmp(p, "on"))
wc_enabled = true;
else if (!strcmp(p, "off"))
wc_enabled = false;
else
pr_warn("Unknown writecombine setting \"%s\".\n", p);
return 0;
}
early_param("writecombine", setup_writecombine);
static int usermem __initdata;
Annotation
- Immediate include surface: `linux/init.h`, `linux/acpi.h`, `linux/cpu.h`, `linux/dmi.h`, `linux/efi.h`, `linux/export.h`, `linux/memblock.h`, `linux/initrd.h`.
- Detected declarations: `function arch_cpu_finalize_init`, `function parse_cpu_table`, `function parse_bios_table`, `function find_tokens`, `function smbios_parse`, `function setup_writecombine`, `function early_parse_mem`, `function arch_reserve_vmcore`, `function arch_reserve_crashkernel`, `function fdt_setup`.
- 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.