18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci#ifndef __ASM_SH_KEXEC_H 38c2ecf20Sopenharmony_ci#define __ASM_SH_KEXEC_H 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ci#include <asm/ptrace.h> 68c2ecf20Sopenharmony_ci#include <asm/string.h> 78c2ecf20Sopenharmony_ci#include <linux/kernel.h> 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ci/* 108c2ecf20Sopenharmony_ci * KEXEC_SOURCE_MEMORY_LIMIT maximum page get_free_page can return. 118c2ecf20Sopenharmony_ci * I.e. Maximum page that is mapped directly into kernel memory, 128c2ecf20Sopenharmony_ci * and kmap is not required. 138c2ecf20Sopenharmony_ci * 148c2ecf20Sopenharmony_ci * Someone correct me if FIXADDR_START - PAGEOFFSET is not the correct 158c2ecf20Sopenharmony_ci * calculation for the amount of memory directly mappable into the 168c2ecf20Sopenharmony_ci * kernel memory space. 178c2ecf20Sopenharmony_ci */ 188c2ecf20Sopenharmony_ci 198c2ecf20Sopenharmony_ci/* Maximum physical address we can use pages from */ 208c2ecf20Sopenharmony_ci#define KEXEC_SOURCE_MEMORY_LIMIT (-1UL) 218c2ecf20Sopenharmony_ci/* Maximum address we can reach in physical address mode */ 228c2ecf20Sopenharmony_ci#define KEXEC_DESTINATION_MEMORY_LIMIT (-1UL) 238c2ecf20Sopenharmony_ci/* Maximum address we can use for the control code buffer */ 248c2ecf20Sopenharmony_ci#define KEXEC_CONTROL_MEMORY_LIMIT TASK_SIZE 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_ci#define KEXEC_CONTROL_PAGE_SIZE 4096 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_ci/* The native architecture */ 298c2ecf20Sopenharmony_ci#define KEXEC_ARCH KEXEC_ARCH_SH 308c2ecf20Sopenharmony_ci 318c2ecf20Sopenharmony_ci#ifdef CONFIG_KEXEC 328c2ecf20Sopenharmony_ci/* arch/sh/kernel/machine_kexec.c */ 338c2ecf20Sopenharmony_civoid reserve_crashkernel(void); 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_cistatic inline void crash_setup_regs(struct pt_regs *newregs, 368c2ecf20Sopenharmony_ci struct pt_regs *oldregs) 378c2ecf20Sopenharmony_ci{ 388c2ecf20Sopenharmony_ci if (oldregs) 398c2ecf20Sopenharmony_ci memcpy(newregs, oldregs, sizeof(*newregs)); 408c2ecf20Sopenharmony_ci else { 418c2ecf20Sopenharmony_ci __asm__ __volatile__ ("mov r0, %0" : "=r" (newregs->regs[0])); 428c2ecf20Sopenharmony_ci __asm__ __volatile__ ("mov r1, %0" : "=r" (newregs->regs[1])); 438c2ecf20Sopenharmony_ci __asm__ __volatile__ ("mov r2, %0" : "=r" (newregs->regs[2])); 448c2ecf20Sopenharmony_ci __asm__ __volatile__ ("mov r3, %0" : "=r" (newregs->regs[3])); 458c2ecf20Sopenharmony_ci __asm__ __volatile__ ("mov r4, %0" : "=r" (newregs->regs[4])); 468c2ecf20Sopenharmony_ci __asm__ __volatile__ ("mov r5, %0" : "=r" (newregs->regs[5])); 478c2ecf20Sopenharmony_ci __asm__ __volatile__ ("mov r6, %0" : "=r" (newregs->regs[6])); 488c2ecf20Sopenharmony_ci __asm__ __volatile__ ("mov r7, %0" : "=r" (newregs->regs[7])); 498c2ecf20Sopenharmony_ci __asm__ __volatile__ ("mov r8, %0" : "=r" (newregs->regs[8])); 508c2ecf20Sopenharmony_ci __asm__ __volatile__ ("mov r9, %0" : "=r" (newregs->regs[9])); 518c2ecf20Sopenharmony_ci __asm__ __volatile__ ("mov r10, %0" : "=r" (newregs->regs[10])); 528c2ecf20Sopenharmony_ci __asm__ __volatile__ ("mov r11, %0" : "=r" (newregs->regs[11])); 538c2ecf20Sopenharmony_ci __asm__ __volatile__ ("mov r12, %0" : "=r" (newregs->regs[12])); 548c2ecf20Sopenharmony_ci __asm__ __volatile__ ("mov r13, %0" : "=r" (newregs->regs[13])); 558c2ecf20Sopenharmony_ci __asm__ __volatile__ ("mov r14, %0" : "=r" (newregs->regs[14])); 568c2ecf20Sopenharmony_ci __asm__ __volatile__ ("mov r15, %0" : "=r" (newregs->regs[15])); 578c2ecf20Sopenharmony_ci 588c2ecf20Sopenharmony_ci __asm__ __volatile__ ("sts pr, %0" : "=r" (newregs->pr)); 598c2ecf20Sopenharmony_ci __asm__ __volatile__ ("sts macl, %0" : "=r" (newregs->macl)); 608c2ecf20Sopenharmony_ci __asm__ __volatile__ ("sts mach, %0" : "=r" (newregs->mach)); 618c2ecf20Sopenharmony_ci 628c2ecf20Sopenharmony_ci __asm__ __volatile__ ("stc gbr, %0" : "=r" (newregs->gbr)); 638c2ecf20Sopenharmony_ci __asm__ __volatile__ ("stc sr, %0" : "=r" (newregs->sr)); 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_ci newregs->pc = _THIS_IP_; 668c2ecf20Sopenharmony_ci } 678c2ecf20Sopenharmony_ci} 688c2ecf20Sopenharmony_ci#else 698c2ecf20Sopenharmony_cistatic inline void reserve_crashkernel(void) { } 708c2ecf20Sopenharmony_ci#endif /* CONFIG_KEXEC */ 718c2ecf20Sopenharmony_ci 728c2ecf20Sopenharmony_ci#endif /* __ASM_SH_KEXEC_H */ 73