mirror of
https://github.com/revyos/thead-kernel.git
synced 2026-09-18 13:22:15 +02:00
Linux_SDK_V1.4.2
Signed-off-by: thead_admin <occ_thead@service.alibaba.com>
This commit is contained in:
82
arch/riscv/include/asm/assembler.h
Normal file
82
arch/riscv/include/asm/assembler.h
Normal file
@@ -0,0 +1,82 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||
/*
|
||||
* Copyright (C) 2023 StarFive Technology Co., Ltd.
|
||||
*
|
||||
* Author: Jee Heng Sia <jeeheng.sia@starfivetech.com>
|
||||
*/
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
#error "Only include this from assembly code"
|
||||
#endif
|
||||
|
||||
#ifndef __ASM_ASSEMBLER_H
|
||||
#define __ASM_ASSEMBLER_H
|
||||
|
||||
#include <asm/asm.h>
|
||||
#include <asm/asm-offsets.h>
|
||||
#include <asm/csr.h>
|
||||
|
||||
/*
|
||||
* suspend_restore_csrs - restore CSRs
|
||||
*/
|
||||
.macro suspend_restore_csrs
|
||||
REG_L t0, (SUSPEND_CONTEXT_REGS + PT_EPC)(a0)
|
||||
csrw CSR_EPC, t0
|
||||
REG_L t0, (SUSPEND_CONTEXT_REGS + PT_STATUS)(a0)
|
||||
csrw CSR_STATUS, t0
|
||||
REG_L t0, (SUSPEND_CONTEXT_REGS + PT_BADADDR)(a0)
|
||||
csrw CSR_TVAL, t0
|
||||
REG_L t0, (SUSPEND_CONTEXT_REGS + PT_CAUSE)(a0)
|
||||
csrw CSR_CAUSE, t0
|
||||
.endm
|
||||
|
||||
/*
|
||||
* suspend_restore_regs - Restore registers (except A0 and T0-T6)
|
||||
*/
|
||||
.macro suspend_restore_regs
|
||||
REG_L ra, (SUSPEND_CONTEXT_REGS + PT_RA)(a0)
|
||||
REG_L sp, (SUSPEND_CONTEXT_REGS + PT_SP)(a0)
|
||||
REG_L gp, (SUSPEND_CONTEXT_REGS + PT_GP)(a0)
|
||||
REG_L tp, (SUSPEND_CONTEXT_REGS + PT_TP)(a0)
|
||||
REG_L s0, (SUSPEND_CONTEXT_REGS + PT_S0)(a0)
|
||||
REG_L s1, (SUSPEND_CONTEXT_REGS + PT_S1)(a0)
|
||||
REG_L a1, (SUSPEND_CONTEXT_REGS + PT_A1)(a0)
|
||||
REG_L a2, (SUSPEND_CONTEXT_REGS + PT_A2)(a0)
|
||||
REG_L a3, (SUSPEND_CONTEXT_REGS + PT_A3)(a0)
|
||||
REG_L a4, (SUSPEND_CONTEXT_REGS + PT_A4)(a0)
|
||||
REG_L a5, (SUSPEND_CONTEXT_REGS + PT_A5)(a0)
|
||||
REG_L a6, (SUSPEND_CONTEXT_REGS + PT_A6)(a0)
|
||||
REG_L a7, (SUSPEND_CONTEXT_REGS + PT_A7)(a0)
|
||||
REG_L s2, (SUSPEND_CONTEXT_REGS + PT_S2)(a0)
|
||||
REG_L s3, (SUSPEND_CONTEXT_REGS + PT_S3)(a0)
|
||||
REG_L s4, (SUSPEND_CONTEXT_REGS + PT_S4)(a0)
|
||||
REG_L s5, (SUSPEND_CONTEXT_REGS + PT_S5)(a0)
|
||||
REG_L s6, (SUSPEND_CONTEXT_REGS + PT_S6)(a0)
|
||||
REG_L s7, (SUSPEND_CONTEXT_REGS + PT_S7)(a0)
|
||||
REG_L s8, (SUSPEND_CONTEXT_REGS + PT_S8)(a0)
|
||||
REG_L s9, (SUSPEND_CONTEXT_REGS + PT_S9)(a0)
|
||||
REG_L s10, (SUSPEND_CONTEXT_REGS + PT_S10)(a0)
|
||||
REG_L s11, (SUSPEND_CONTEXT_REGS + PT_S11)(a0)
|
||||
.endm
|
||||
|
||||
/*
|
||||
* copy_page - copy 1 page (4KB) of data from source to destination
|
||||
* @a0 - destination
|
||||
* @a1 - source
|
||||
*/
|
||||
.macro copy_page a0, a1
|
||||
lui a2, 0x1
|
||||
add a2, a2, a0
|
||||
1 :
|
||||
REG_L t0, 0(a1)
|
||||
REG_L t1, SZREG(a1)
|
||||
|
||||
REG_S t0, 0(a0)
|
||||
REG_S t1, SZREG(a0)
|
||||
|
||||
addi a0, a0, 2 * SZREG
|
||||
addi a1, a1, 2 * SZREG
|
||||
bne a2, a0, 1b
|
||||
.endm
|
||||
|
||||
#endif /* __ASM_ASSEMBLER_H */
|
||||
@@ -46,9 +46,9 @@
|
||||
#define SR_XS_DIRTY _AC(0x00018000, UL)
|
||||
|
||||
#ifndef CONFIG_64BIT
|
||||
#define SR_SD _AC(0x80000000, UL) /* FS/XS dirty */
|
||||
#define SR_SD _AC(0x80000000, UL) /* FS|VS|XS dirty */
|
||||
#else
|
||||
#define SR_SD _AC(0x8000000000000000, UL) /* FS/XS dirty */
|
||||
#define SR_SD _AC(0x8000000000000000, UL) /* FS|VS|XS dirty */
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_COMPAT
|
||||
|
||||
@@ -35,6 +35,11 @@ crash_setup_regs(struct pt_regs *newregs,
|
||||
riscv_crash_save_regs(newregs);
|
||||
}
|
||||
|
||||
#if defined(CONFIG_KEXEC) && defined(CONFIG_HIBERNATION)
|
||||
extern bool crash_is_nosave(unsigned long pfn);
|
||||
#else
|
||||
static inline bool crash_is_nosave(unsigned long pfn) {return false; }
|
||||
#endif
|
||||
|
||||
#define ARCH_HAS_KIMAGE_ARCH
|
||||
|
||||
|
||||
@@ -128,6 +128,8 @@ extern phys_addr_t __phys_addr_symbol(unsigned long x);
|
||||
#define page_to_bus(page) (page_to_phys(page))
|
||||
#define phys_to_page(paddr) (pfn_to_page(phys_to_pfn(paddr)))
|
||||
|
||||
#define sym_to_pfn(x) __phys_to_pfn(__pa_symbol(x))
|
||||
|
||||
#ifdef CONFIG_FLATMEM
|
||||
#define pfn_valid(pfn) \
|
||||
(((pfn) >= ARCH_PFN_OFFSET) && (((pfn) - ARCH_PFN_OFFSET) < max_mapnr))
|
||||
|
||||
@@ -521,6 +521,8 @@ extern uintptr_t dtb_early_pa;
|
||||
void setup_bootmem(void);
|
||||
void paging_init(void);
|
||||
|
||||
extern u64 satp_mode;
|
||||
|
||||
#define FIRST_USER_ADDRESS 0
|
||||
|
||||
/*
|
||||
|
||||
@@ -21,6 +21,11 @@ struct suspend_context {
|
||||
#endif
|
||||
};
|
||||
|
||||
/*
|
||||
* Used by hibernation core and cleared during resume sequence
|
||||
*/
|
||||
extern int in_suspend;
|
||||
|
||||
/* Low-level CPU suspend entry function */
|
||||
int __cpu_suspend_enter(struct suspend_context *context);
|
||||
|
||||
@@ -33,4 +38,21 @@ int cpu_suspend(unsigned long arg,
|
||||
/* Low-level CPU resume entry function */
|
||||
int __cpu_resume_enter(unsigned long hartid, unsigned long context);
|
||||
|
||||
/* Used to save and restore the CSRs */
|
||||
void suspend_save_csrs(struct suspend_context *context);
|
||||
void suspend_restore_csrs(struct suspend_context *context);
|
||||
|
||||
/* Low-level API to support hibernation */
|
||||
int swsusp_arch_suspend(void);
|
||||
int swsusp_arch_resume(void);
|
||||
int arch_hibernation_header_save(void *addr, unsigned int max_size);
|
||||
int arch_hibernation_header_restore(void *addr);
|
||||
int __hibernate_cpu_resume(void);
|
||||
|
||||
/* Used to resume on the CPU we hibernated on */
|
||||
int hibernate_resume_nonboot_cpu_disable(void);
|
||||
|
||||
asmlinkage void hibernate_restore_image(unsigned long resume_satp, unsigned long satp_temp,
|
||||
unsigned long cpu_resume);
|
||||
asmlinkage int hibernate_core_restore_code(void);
|
||||
#endif
|
||||
|
||||
@@ -75,7 +75,7 @@ static inline void __vstate_clean(struct pt_regs *regs)
|
||||
static inline void vstate_save(struct task_struct *task,
|
||||
struct pt_regs *regs)
|
||||
{
|
||||
if ((regs->status & SR_VS) == SR_VS_DIRTY) {
|
||||
if ((regs->status & SR_VS) != SR_VS_OFF) {
|
||||
__vstate_save(task);
|
||||
__vstate_clean(regs);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user