Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef _ARM_KEXEC_H
0003 #define _ARM_KEXEC_H
0004 
0005 #ifdef CONFIG_KEXEC
0006 
0007 /* Maximum physical address we can use pages from */
0008 #define KEXEC_SOURCE_MEMORY_LIMIT (-1UL)
0009 /* Maximum address we can reach in physical address mode */
0010 #define KEXEC_DESTINATION_MEMORY_LIMIT (-1UL)
0011 /* Maximum address we can use for the control code buffer */
0012 #define KEXEC_CONTROL_MEMORY_LIMIT (-1UL)
0013 
0014 #define KEXEC_CONTROL_PAGE_SIZE 4096
0015 
0016 #define KEXEC_ARCH KEXEC_ARCH_ARM
0017 
0018 #define KEXEC_ARM_ATAGS_OFFSET  0x1000
0019 #define KEXEC_ARM_ZIMAGE_OFFSET 0x8000
0020 
0021 #ifndef __ASSEMBLY__
0022 
0023 #define ARCH_HAS_KIMAGE_ARCH
0024 struct kimage_arch {
0025     u32 kernel_r2;
0026 };
0027 
0028 /**
0029  * crash_setup_regs() - save registers for the panic kernel
0030  * @newregs: registers are saved here
0031  * @oldregs: registers to be saved (may be %NULL)
0032  *
0033  * Function copies machine registers from @oldregs to @newregs. If @oldregs is
0034  * %NULL then current registers are stored there.
0035  */
0036 static inline void crash_setup_regs(struct pt_regs *newregs,
0037                     struct pt_regs *oldregs)
0038 {
0039     if (oldregs) {
0040         memcpy(newregs, oldregs, sizeof(*newregs));
0041     } else {
0042         __asm__ __volatile__ (
0043             "stmia  %[regs_base], {r0-r12}\n\t"
0044             "mov    %[_ARM_sp], sp\n\t"
0045             "str    lr, %[_ARM_lr]\n\t"
0046             "adr    %[_ARM_pc], 1f\n\t"
0047             "mrs    %[_ARM_cpsr], cpsr\n\t"
0048         "1:"
0049             : [_ARM_pc] "=r" (newregs->ARM_pc),
0050               [_ARM_cpsr] "=r" (newregs->ARM_cpsr),
0051               [_ARM_sp] "=r" (newregs->ARM_sp),
0052               [_ARM_lr] "=o" (newregs->ARM_lr)
0053             : [regs_base] "r" (&newregs->ARM_r0)
0054             : "memory"
0055         );
0056     }
0057 }
0058 
0059 static inline unsigned long phys_to_boot_phys(phys_addr_t phys)
0060 {
0061     return phys_to_idmap(phys);
0062 }
0063 #define phys_to_boot_phys phys_to_boot_phys
0064 
0065 static inline phys_addr_t boot_phys_to_phys(unsigned long entry)
0066 {
0067     return idmap_to_phys(entry);
0068 }
0069 #define boot_phys_to_phys boot_phys_to_phys
0070 
0071 static inline unsigned long page_to_boot_pfn(struct page *page)
0072 {
0073     return page_to_pfn(page) + (arch_phys_to_idmap_offset >> PAGE_SHIFT);
0074 }
0075 #define page_to_boot_pfn page_to_boot_pfn
0076 
0077 static inline struct page *boot_pfn_to_page(unsigned long boot_pfn)
0078 {
0079     return pfn_to_page(boot_pfn - (arch_phys_to_idmap_offset >> PAGE_SHIFT));
0080 }
0081 #define boot_pfn_to_page boot_pfn_to_page
0082 
0083 #endif /* __ASSEMBLY__ */
0084 
0085 #endif /* CONFIG_KEXEC */
0086 
0087 #endif /* _ARM_KEXEC_H */