at v4.20 3.2 kB view raw
1/* SPDX-License-Identifier: GPL-2.0 */ 2// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd. 3 4#ifndef __ASM_CSKY_PROCESSOR_H 5#define __ASM_CSKY_PROCESSOR_H 6 7#include <linux/bitops.h> 8#include <asm/segment.h> 9#include <asm/ptrace.h> 10#include <asm/current.h> 11#include <asm/cache.h> 12#include <abi/reg_ops.h> 13#include <abi/regdef.h> 14#ifdef CONFIG_CPU_HAS_FPU 15#include <abi/fpu.h> 16#endif 17 18struct cpuinfo_csky { 19 unsigned long udelay_val; 20 unsigned long asid_cache; 21 /* 22 * Capability and feature descriptor structure for CSKY CPU 23 */ 24 unsigned long options; 25 unsigned int processor_id[4]; 26 unsigned int fpu_id; 27} __aligned(SMP_CACHE_BYTES); 28 29extern struct cpuinfo_csky cpu_data[]; 30 31/* 32 * User space process size: 2GB. This is hardcoded into a few places, 33 * so don't change it unless you know what you are doing. TASK_SIZE 34 * for a 64 bit kernel expandable to 8192EB, of which the current CSKY 35 * implementations will "only" be able to use 1TB ... 36 */ 37#define TASK_SIZE 0x7fff8000UL 38 39#ifdef __KERNEL__ 40#define STACK_TOP TASK_SIZE 41#define STACK_TOP_MAX STACK_TOP 42#endif 43 44/* This decides where the kernel will search for a free chunk of vm 45 * space during mmap's. 46 */ 47#define TASK_UNMAPPED_BASE (TASK_SIZE / 3) 48 49struct thread_struct { 50 unsigned long ksp; /* kernel stack pointer */ 51 unsigned long sr; /* saved status register */ 52 unsigned long esp0; /* points to SR of stack frame */ 53 unsigned long hi; 54 unsigned long lo; 55 56 /* Other stuff associated with the thread. */ 57 unsigned long address; /* Last user fault */ 58 unsigned long error_code; 59 60 /* FPU regs */ 61 struct user_fp __aligned(16) user_fp; 62}; 63 64#define INIT_THREAD { \ 65 .ksp = (unsigned long) init_thread_union.stack + THREAD_SIZE, \ 66 .sr = DEFAULT_PSR_VALUE, \ 67} 68 69/* 70 * Do necessary setup to start up a newly executed thread. 71 * 72 * pass the data segment into user programs if it exists, 73 * it can't hurt anything as far as I can tell 74 */ 75#define start_thread(_regs, _pc, _usp) \ 76do { \ 77 set_fs(USER_DS); /* reads from user space */ \ 78 (_regs)->pc = (_pc); \ 79 (_regs)->regs[1] = 0; /* ABIV1 is R7, uClibc_main rtdl arg */ \ 80 (_regs)->regs[2] = 0; \ 81 (_regs)->regs[3] = 0; /* ABIV2 is R7, use it? */ \ 82 (_regs)->sr &= ~PS_S; \ 83 (_regs)->usp = (_usp); \ 84} while (0) 85 86/* Forward declaration, a strange C thing */ 87struct task_struct; 88 89/* Free all resources held by a thread. */ 90static inline void release_thread(struct task_struct *dead_task) 91{ 92} 93 94/* Prepare to copy thread state - unlazy all lazy status */ 95#define prepare_to_copy(tsk) do { } while (0) 96 97extern int kernel_thread(int (*fn)(void *), void *arg, unsigned long flags); 98 99#define copy_segments(tsk, mm) do { } while (0) 100#define release_segments(mm) do { } while (0) 101#define forget_segments() do { } while (0) 102 103extern unsigned long thread_saved_pc(struct task_struct *tsk); 104 105unsigned long get_wchan(struct task_struct *p); 106 107#define KSTK_EIP(tsk) (task_pt_regs(tsk)->pc) 108#define KSTK_ESP(tsk) (task_pt_regs(tsk)->usp) 109 110#define task_pt_regs(p) \ 111 ((struct pt_regs *)(THREAD_SIZE + p->stack) - 1) 112 113#define cpu_relax() barrier() 114 115#endif /* __ASM_CSKY_PROCESSOR_H */