arch/mips/loongson64/reset.c
Source file repositories/reference/linux-study-clean/arch/mips/loongson64/reset.c
File Facts
- System
- Linux kernel
- Corpus path
arch/mips/loongson64/reset.c- Extension
.c- Size
- 4297 bytes
- Lines
- 180
- Domain
- Architecture Layer
- Bucket
- arch/mips
- 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/cpu.hlinux/delay.hlinux/init.hlinux/kexec.hlinux/pm.hlinux/reboot.hlinux/slab.hasm/bootinfo.hasm/idle.hasm/reboot.hasm/bug.hloongson.hboot_param.h
Detected Declarations
function Copyrightfunction firmware_powerofffunction loongson_kexec_preparefunction loongson_kexec_shutdownfunction loongson_crash_shutdownfunction mips_reboot_setup
Annotated Snippet
strlen(bootloader))) {
/*
* convert command line string to array
* of parameters (as bootloader does).
*/
int offt;
str = (char *)argv + KEXEC_ARGV_SIZE/2;
memcpy(str, image->segment[i].buf, KEXEC_ARGV_SIZE/2);
ptr = strchr(str, ' ');
while (ptr && (argc < MAX_ARGS)) {
*ptr = '\0';
if (ptr[1] != ' ') {
offt = (int)(ptr - str + 1);
argv[argc] = KEXEC_ARGV_ADDR + KEXEC_ARGV_SIZE/2 + offt;
argc++;
}
ptr = strchr(ptr + 1, ' ');
}
break;
}
}
if (image->type == KEXEC_TYPE_DEFAULT)
kexec_argc = argc;
else
kdump_argc = argc;
/* kexec/kdump need a safe page to save reboot_code_buffer */
image->control_code_page = virt_to_page((void *)KEXEC_CTRL_CODE);
return 0;
}
static void loongson_kexec_shutdown(void)
{
#ifdef CONFIG_SMP
int cpu;
/* All CPUs go to reboot_code_buffer */
for_each_possible_cpu(cpu)
if (!cpu_online(cpu))
cpu_device_up(get_cpu_device(cpu));
secondary_kexec_args[0] = TO_UNCAC(0x3ff01000);
#endif
kexec_args[0] = kexec_argc;
kexec_args[1] = fw_arg1;
kexec_args[2] = fw_arg2;
memcpy((void *)fw_arg1, kexec_argv, KEXEC_ARGV_SIZE);
memcpy((void *)fw_arg2, kexec_envp, KEXEC_ENVP_SIZE);
}
static void loongson_crash_shutdown(struct pt_regs *regs)
{
default_machine_crash_shutdown(regs);
kexec_args[0] = kdump_argc;
kexec_args[1] = fw_arg1;
kexec_args[2] = fw_arg2;
#ifdef CONFIG_SMP
secondary_kexec_args[0] = TO_UNCAC(0x3ff01000);
#endif
memcpy((void *)fw_arg1, kdump_argv, KEXEC_ARGV_SIZE);
memcpy((void *)fw_arg2, kexec_envp, KEXEC_ENVP_SIZE);
}
#endif
static int __init mips_reboot_setup(void)
{
if (loongson_sysconf.restart_addr) {
register_sys_off_handler(SYS_OFF_MODE_RESTART,
SYS_OFF_PRIO_FIRMWARE,
firmware_restart, NULL);
}
if (loongson_sysconf.poweroff_addr) {
register_sys_off_handler(SYS_OFF_MODE_POWER_OFF,
SYS_OFF_PRIO_FIRMWARE,
firmware_poweroff, NULL);
}
#ifdef CONFIG_KEXEC_CORE
kexec_argv = kmalloc(KEXEC_ARGV_SIZE, GFP_KERNEL);
if (WARN_ON(!kexec_argv))
return -ENOMEM;
kdump_argv = kmalloc(KEXEC_ARGV_SIZE, GFP_KERNEL);
if (WARN_ON(!kdump_argv))
return -ENOMEM;
Annotation
- Immediate include surface: `linux/cpu.h`, `linux/delay.h`, `linux/init.h`, `linux/kexec.h`, `linux/pm.h`, `linux/reboot.h`, `linux/slab.h`, `asm/bootinfo.h`.
- Detected declarations: `function Copyright`, `function firmware_poweroff`, `function loongson_kexec_prepare`, `function loongson_kexec_shutdown`, `function loongson_crash_shutdown`, `function mips_reboot_setup`.
- Atlas domain: Architecture Layer / arch/mips.
- 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.