1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
2f15cbe6fSPaul Mundt #ifndef __ASM_SH_KEXEC_H
3f15cbe6fSPaul Mundt #define __ASM_SH_KEXEC_H
4f15cbe6fSPaul Mundt
5f15cbe6fSPaul Mundt #include <asm/ptrace.h>
6f15cbe6fSPaul Mundt #include <asm/string.h>
7*8d00d0c0SNick Desaulniers #include <linux/kernel.h>
8f15cbe6fSPaul Mundt
9f15cbe6fSPaul Mundt /*
10f15cbe6fSPaul Mundt * KEXEC_SOURCE_MEMORY_LIMIT maximum page get_free_page can return.
11f15cbe6fSPaul Mundt * I.e. Maximum page that is mapped directly into kernel memory,
12f15cbe6fSPaul Mundt * and kmap is not required.
13f15cbe6fSPaul Mundt *
14f15cbe6fSPaul Mundt * Someone correct me if FIXADDR_START - PAGEOFFSET is not the correct
15f15cbe6fSPaul Mundt * calculation for the amount of memory directly mappable into the
16f15cbe6fSPaul Mundt * kernel memory space.
17f15cbe6fSPaul Mundt */
18f15cbe6fSPaul Mundt
19f15cbe6fSPaul Mundt /* Maximum physical address we can use pages from */
20f15cbe6fSPaul Mundt #define KEXEC_SOURCE_MEMORY_LIMIT (-1UL)
21f15cbe6fSPaul Mundt /* Maximum address we can reach in physical address mode */
22f15cbe6fSPaul Mundt #define KEXEC_DESTINATION_MEMORY_LIMIT (-1UL)
23f15cbe6fSPaul Mundt /* Maximum address we can use for the control code buffer */
24f15cbe6fSPaul Mundt #define KEXEC_CONTROL_MEMORY_LIMIT TASK_SIZE
25f15cbe6fSPaul Mundt
26163f6876SHuang Ying #define KEXEC_CONTROL_PAGE_SIZE 4096
27f15cbe6fSPaul Mundt
28f15cbe6fSPaul Mundt /* The native architecture */
29f15cbe6fSPaul Mundt #define KEXEC_ARCH KEXEC_ARCH_SH
30f15cbe6fSPaul Mundt
31a5ec3950SPaul Mundt #ifdef CONFIG_KEXEC
32a5ec3950SPaul Mundt /* arch/sh/kernel/machine_kexec.c */
33a5ec3950SPaul Mundt void reserve_crashkernel(void);
34a5ec3950SPaul Mundt
crash_setup_regs(struct pt_regs * newregs,struct pt_regs * oldregs)35f15cbe6fSPaul Mundt static inline void crash_setup_regs(struct pt_regs *newregs,
36f15cbe6fSPaul Mundt struct pt_regs *oldregs)
37f15cbe6fSPaul Mundt {
38f15cbe6fSPaul Mundt if (oldregs)
39f15cbe6fSPaul Mundt memcpy(newregs, oldregs, sizeof(*newregs));
40f15cbe6fSPaul Mundt else {
41f15cbe6fSPaul Mundt __asm__ __volatile__ ("mov r0, %0" : "=r" (newregs->regs[0]));
42f15cbe6fSPaul Mundt __asm__ __volatile__ ("mov r1, %0" : "=r" (newregs->regs[1]));
43f15cbe6fSPaul Mundt __asm__ __volatile__ ("mov r2, %0" : "=r" (newregs->regs[2]));
44f15cbe6fSPaul Mundt __asm__ __volatile__ ("mov r3, %0" : "=r" (newregs->regs[3]));
45f15cbe6fSPaul Mundt __asm__ __volatile__ ("mov r4, %0" : "=r" (newregs->regs[4]));
46f15cbe6fSPaul Mundt __asm__ __volatile__ ("mov r5, %0" : "=r" (newregs->regs[5]));
47f15cbe6fSPaul Mundt __asm__ __volatile__ ("mov r6, %0" : "=r" (newregs->regs[6]));
48f15cbe6fSPaul Mundt __asm__ __volatile__ ("mov r7, %0" : "=r" (newregs->regs[7]));
49f15cbe6fSPaul Mundt __asm__ __volatile__ ("mov r8, %0" : "=r" (newregs->regs[8]));
50f15cbe6fSPaul Mundt __asm__ __volatile__ ("mov r9, %0" : "=r" (newregs->regs[9]));
51f15cbe6fSPaul Mundt __asm__ __volatile__ ("mov r10, %0" : "=r" (newregs->regs[10]));
52f15cbe6fSPaul Mundt __asm__ __volatile__ ("mov r11, %0" : "=r" (newregs->regs[11]));
53f15cbe6fSPaul Mundt __asm__ __volatile__ ("mov r12, %0" : "=r" (newregs->regs[12]));
54f15cbe6fSPaul Mundt __asm__ __volatile__ ("mov r13, %0" : "=r" (newregs->regs[13]));
55f15cbe6fSPaul Mundt __asm__ __volatile__ ("mov r14, %0" : "=r" (newregs->regs[14]));
56f15cbe6fSPaul Mundt __asm__ __volatile__ ("mov r15, %0" : "=r" (newregs->regs[15]));
57f15cbe6fSPaul Mundt
58f15cbe6fSPaul Mundt __asm__ __volatile__ ("sts pr, %0" : "=r" (newregs->pr));
59f15cbe6fSPaul Mundt __asm__ __volatile__ ("sts macl, %0" : "=r" (newregs->macl));
60f15cbe6fSPaul Mundt __asm__ __volatile__ ("sts mach, %0" : "=r" (newregs->mach));
61f15cbe6fSPaul Mundt
62f15cbe6fSPaul Mundt __asm__ __volatile__ ("stc gbr, %0" : "=r" (newregs->gbr));
63f15cbe6fSPaul Mundt __asm__ __volatile__ ("stc sr, %0" : "=r" (newregs->sr));
64f15cbe6fSPaul Mundt
65*8d00d0c0SNick Desaulniers newregs->pc = _THIS_IP_;
66f15cbe6fSPaul Mundt }
67f15cbe6fSPaul Mundt }
68a5ec3950SPaul Mundt #else
reserve_crashkernel(void)69a5ec3950SPaul Mundt static inline void reserve_crashkernel(void) { }
70a5ec3950SPaul Mundt #endif /* CONFIG_KEXEC */
71a5ec3950SPaul Mundt
72f15cbe6fSPaul Mundt #endif /* __ASM_SH_KEXEC_H */
73