blob: fd5f331a39126d2aca7d9c16852c80cd24931bf3 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Paul Mundt4d5ade52007-04-27 11:25:57 +09002#ifndef __ASM_SH_KEXEC_H
3#define __ASM_SH_KEXEC_H
4
5#include <asm/ptrace.h>
6#include <asm/string.h>
kogiidena9d441902006-01-16 22:14:10 -08007
8/*
9 * KEXEC_SOURCE_MEMORY_LIMIT maximum page get_free_page can return.
10 * I.e. Maximum page that is mapped directly into kernel memory,
11 * and kmap is not required.
12 *
13 * Someone correct me if FIXADDR_START - PAGEOFFSET is not the correct
14 * calculation for the amount of memory directly mappable into the
15 * kernel memory space.
16 */
17
18/* Maximum physical address we can use pages from */
19#define KEXEC_SOURCE_MEMORY_LIMIT (-1UL)
20/* Maximum address we can reach in physical address mode */
21#define KEXEC_DESTINATION_MEMORY_LIMIT (-1UL)
22/* Maximum address we can use for the control code buffer */
23#define KEXEC_CONTROL_MEMORY_LIMIT TASK_SIZE
24
Huang Ying163f6872008-08-15 00:40:22 -070025#define KEXEC_CONTROL_PAGE_SIZE 4096
kogiidena9d441902006-01-16 22:14:10 -080026
27/* The native architecture */
28#define KEXEC_ARCH KEXEC_ARCH_SH
29
Paul Mundta5ec3952010-05-07 14:54:55 +090030#ifdef CONFIG_KEXEC
31/* arch/sh/kernel/machine_kexec.c */
32void reserve_crashkernel(void);
33
Paul Mundt9d549a72006-09-27 18:26:05 +090034static inline void crash_setup_regs(struct pt_regs *newregs,
Paul Mundt4d5ade52007-04-27 11:25:57 +090035 struct pt_regs *oldregs)
36{
37 if (oldregs)
38 memcpy(newregs, oldregs, sizeof(*newregs));
39 else {
40 __asm__ __volatile__ ("mov r0, %0" : "=r" (newregs->regs[0]));
41 __asm__ __volatile__ ("mov r1, %0" : "=r" (newregs->regs[1]));
42 __asm__ __volatile__ ("mov r2, %0" : "=r" (newregs->regs[2]));
43 __asm__ __volatile__ ("mov r3, %0" : "=r" (newregs->regs[3]));
44 __asm__ __volatile__ ("mov r4, %0" : "=r" (newregs->regs[4]));
45 __asm__ __volatile__ ("mov r5, %0" : "=r" (newregs->regs[5]));
46 __asm__ __volatile__ ("mov r6, %0" : "=r" (newregs->regs[6]));
47 __asm__ __volatile__ ("mov r7, %0" : "=r" (newregs->regs[7]));
48 __asm__ __volatile__ ("mov r8, %0" : "=r" (newregs->regs[8]));
49 __asm__ __volatile__ ("mov r9, %0" : "=r" (newregs->regs[9]));
50 __asm__ __volatile__ ("mov r10, %0" : "=r" (newregs->regs[10]));
51 __asm__ __volatile__ ("mov r11, %0" : "=r" (newregs->regs[11]));
52 __asm__ __volatile__ ("mov r12, %0" : "=r" (newregs->regs[12]));
53 __asm__ __volatile__ ("mov r13, %0" : "=r" (newregs->regs[13]));
54 __asm__ __volatile__ ("mov r14, %0" : "=r" (newregs->regs[14]));
55 __asm__ __volatile__ ("mov r15, %0" : "=r" (newregs->regs[15]));
kogiidena9d441902006-01-16 22:14:10 -080056
Paul Mundt4d5ade52007-04-27 11:25:57 +090057 __asm__ __volatile__ ("sts pr, %0" : "=r" (newregs->pr));
58 __asm__ __volatile__ ("sts macl, %0" : "=r" (newregs->macl));
59 __asm__ __volatile__ ("sts mach, %0" : "=r" (newregs->mach));
60
61 __asm__ __volatile__ ("stc gbr, %0" : "=r" (newregs->gbr));
62 __asm__ __volatile__ ("stc sr, %0" : "=r" (newregs->sr));
63
64 newregs->pc = (unsigned long)current_text_addr();
65 }
66}
Paul Mundta5ec3952010-05-07 14:54:55 +090067#else
68static inline void reserve_crashkernel(void) { }
69#endif /* CONFIG_KEXEC */
70
Paul Mundt4d5ade52007-04-27 11:25:57 +090071#endif /* __ASM_SH_KEXEC_H */