1e9564df7SGuo Ren /* SPDX-License-Identifier: GPL-2.0 */ 2e9564df7SGuo Ren 3e9564df7SGuo Ren #ifndef __ASM_CSKY_PROCESSOR_H 4e9564df7SGuo Ren #define __ASM_CSKY_PROCESSOR_H 5e9564df7SGuo Ren 6e9564df7SGuo Ren #include <linux/bitops.h> 7534aa1dcSPeter Collingbourne #include <linux/cache.h> 8e9564df7SGuo Ren #include <asm/ptrace.h> 9e9564df7SGuo Ren #include <asm/current.h> 10e9564df7SGuo Ren #include <abi/reg_ops.h> 11e9564df7SGuo Ren #include <abi/regdef.h> 12789154c2SGuo Ren #include <abi/switch_context.h> 13e9564df7SGuo Ren #ifdef CONFIG_CPU_HAS_FPU 14e9564df7SGuo Ren #include <abi/fpu.h> 15e9564df7SGuo Ren #endif 16e9564df7SGuo Ren 17e9564df7SGuo Ren struct cpuinfo_csky { 18e9564df7SGuo Ren unsigned long asid_cache; 19e9564df7SGuo Ren } __aligned(SMP_CACHE_BYTES); 20e9564df7SGuo Ren 21e9564df7SGuo Ren extern struct cpuinfo_csky cpu_data[]; 22e9564df7SGuo Ren 23e9564df7SGuo Ren /* 24e9564df7SGuo Ren * User space process size: 2GB. This is hardcoded into a few places, 25e9564df7SGuo Ren * so don't change it unless you know what you are doing. TASK_SIZE 26e9564df7SGuo Ren * for a 64 bit kernel expandable to 8192EB, of which the current CSKY 27e9564df7SGuo Ren * implementations will "only" be able to use 1TB ... 28e9564df7SGuo Ren */ 290c8a32eeSGuo Ren #define TASK_SIZE (PAGE_OFFSET - (PAGE_SIZE * 8)) 30e9564df7SGuo Ren 31e9564df7SGuo Ren #ifdef __KERNEL__ 32e9564df7SGuo Ren #define STACK_TOP TASK_SIZE 33e9564df7SGuo Ren #define STACK_TOP_MAX STACK_TOP 34e9564df7SGuo Ren #endif 35e9564df7SGuo Ren 36e9564df7SGuo Ren /* This decides where the kernel will search for a free chunk of vm 37e9564df7SGuo Ren * space during mmap's. 38e9564df7SGuo Ren */ 39e9564df7SGuo Ren #define TASK_UNMAPPED_BASE (TASK_SIZE / 3) 40e9564df7SGuo Ren 41e9564df7SGuo Ren struct thread_struct { 4267002814SGuo Ren unsigned long sp; /* kernel stack pointer */ 439c0e343dSGuo Ren unsigned long trap_no; /* saved status register */ 44e9564df7SGuo Ren 45e9564df7SGuo Ren /* FPU regs */ 46e9564df7SGuo Ren struct user_fp __aligned(16) user_fp; 47e9564df7SGuo Ren }; 48e9564df7SGuo Ren 49e9564df7SGuo Ren #define INIT_THREAD { \ 5067002814SGuo Ren .sp = sizeof(init_stack) + (unsigned long) &init_stack, \ 51e9564df7SGuo Ren } 52e9564df7SGuo Ren 53e9564df7SGuo Ren /* 54e9564df7SGuo Ren * Do necessary setup to start up a newly executed thread. 55e9564df7SGuo Ren * 56e9564df7SGuo Ren * pass the data segment into user programs if it exists, 57e9564df7SGuo Ren * it can't hurt anything as far as I can tell 58e9564df7SGuo Ren */ 59e9564df7SGuo Ren #define start_thread(_regs, _pc, _usp) \ 60e9564df7SGuo Ren do { \ 61e9564df7SGuo Ren (_regs)->pc = (_pc); \ 62e9564df7SGuo Ren (_regs)->regs[1] = 0; /* ABIV1 is R7, uClibc_main rtdl arg */ \ 63e9564df7SGuo Ren (_regs)->regs[2] = 0; \ 64e9564df7SGuo Ren (_regs)->regs[3] = 0; /* ABIV2 is R7, use it? */ \ 65e9564df7SGuo Ren (_regs)->sr &= ~PS_S; \ 66e9564df7SGuo Ren (_regs)->usp = (_usp); \ 67e9564df7SGuo Ren } while (0) 68e9564df7SGuo Ren 69e9564df7SGuo Ren /* Forward declaration, a strange C thing */ 70e9564df7SGuo Ren struct task_struct; 71e9564df7SGuo Ren 72e9564df7SGuo Ren /* Prepare to copy thread state - unlazy all lazy status */ 73e9564df7SGuo Ren #define prepare_to_copy(tsk) do { } while (0) 74e9564df7SGuo Ren 7542a20f86SKees Cook unsigned long __get_wchan(struct task_struct *p); 76e9564df7SGuo Ren 77e9564df7SGuo Ren #define KSTK_EIP(tsk) (task_pt_regs(tsk)->pc) 78e9564df7SGuo Ren #define KSTK_ESP(tsk) (task_pt_regs(tsk)->usp) 79e9564df7SGuo Ren 80e9564df7SGuo Ren #define task_pt_regs(p) \ 810f231dcfSGuo Ren ((struct pt_regs *)(THREAD_SIZE + task_stack_page(p)) - 1) 82e9564df7SGuo Ren 83e9564df7SGuo Ren #define cpu_relax() barrier() 84e9564df7SGuo Ren 85*b203c67eSTong Tiangen register unsigned long current_stack_pointer __asm__("sp"); 86*b203c67eSTong Tiangen 87e9564df7SGuo Ren #endif /* __ASM_CSKY_PROCESSOR_H */ 88