18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * kexec.h for kexec
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Copyright (C) 2022 Loongson Technology Corporation Limited
68c2ecf20Sopenharmony_ci */
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_ci#ifndef _ASM_KEXEC_H
98c2ecf20Sopenharmony_ci#define _ASM_KEXEC_H
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci#include <asm/stacktrace.h>
128c2ecf20Sopenharmony_ci#include <asm/page.h>
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_ci/* Maximum physical address we can use pages from */
158c2ecf20Sopenharmony_ci#define KEXEC_SOURCE_MEMORY_LIMIT (-1UL)
168c2ecf20Sopenharmony_ci/* Maximum address we can reach in physical address mode */
178c2ecf20Sopenharmony_ci#define KEXEC_DESTINATION_MEMORY_LIMIT (-1UL)
188c2ecf20Sopenharmony_ci /* Maximum address we can use for the control code buffer */
198c2ecf20Sopenharmony_ci#define KEXEC_CONTROL_MEMORY_LIMIT (-1UL)
208c2ecf20Sopenharmony_ci
218c2ecf20Sopenharmony_ci/* Reserve a page for the control code buffer */
228c2ecf20Sopenharmony_ci#define KEXEC_CONTROL_PAGE_SIZE PAGE_SIZE
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_ci/* The native architecture */
258c2ecf20Sopenharmony_ci#define KEXEC_ARCH KEXEC_ARCH_LOONGARCH
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_cistatic inline void crash_setup_regs(struct pt_regs *newregs,
288c2ecf20Sopenharmony_ci				    struct pt_regs *oldregs)
298c2ecf20Sopenharmony_ci{
308c2ecf20Sopenharmony_ci	if (oldregs)
318c2ecf20Sopenharmony_ci		memcpy(newregs, oldregs, sizeof(*newregs));
328c2ecf20Sopenharmony_ci	else
338c2ecf20Sopenharmony_ci		prepare_frametrace(newregs);
348c2ecf20Sopenharmony_ci}
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_ci#define ARCH_HAS_KIMAGE_ARCH
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_cistruct kimage_arch {
398c2ecf20Sopenharmony_ci	unsigned long efi_boot;
408c2ecf20Sopenharmony_ci	unsigned long cmdline_ptr;
418c2ecf20Sopenharmony_ci	unsigned long systable_ptr;
428c2ecf20Sopenharmony_ci};
438c2ecf20Sopenharmony_ci
448c2ecf20Sopenharmony_citypedef void (*do_kexec_t)(unsigned long efi_boot,
458c2ecf20Sopenharmony_ci			   unsigned long cmdline_ptr,
468c2ecf20Sopenharmony_ci			   unsigned long systable_ptr,
478c2ecf20Sopenharmony_ci			   unsigned long start_addr,
488c2ecf20Sopenharmony_ci			   unsigned long first_ind_entry,
498c2ecf20Sopenharmony_ci			   unsigned long kdump_reloc_offset);
508c2ecf20Sopenharmony_ci
518c2ecf20Sopenharmony_cistruct kimage;
528c2ecf20Sopenharmony_ciextern const unsigned char relocate_new_kernel[];
538c2ecf20Sopenharmony_ciextern const size_t relocate_new_kernel_size;
548c2ecf20Sopenharmony_ciextern void kexec_reboot(void);
558c2ecf20Sopenharmony_ci
568c2ecf20Sopenharmony_ci#ifdef CONFIG_SMP
578c2ecf20Sopenharmony_ciextern atomic_t kexec_ready_to_reboot;
588c2ecf20Sopenharmony_ciextern const unsigned char kexec_smp_wait[];
598c2ecf20Sopenharmony_ci#endif
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_ci#endif /* !_ASM_KEXEC_H */
62