Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 
0003 #ifndef __ASM_CSKY_PROCESSOR_H
0004 #define __ASM_CSKY_PROCESSOR_H
0005 
0006 #include <linux/bitops.h>
0007 #include <linux/cache.h>
0008 #include <asm/ptrace.h>
0009 #include <asm/current.h>
0010 #include <abi/reg_ops.h>
0011 #include <abi/regdef.h>
0012 #include <abi/switch_context.h>
0013 #ifdef CONFIG_CPU_HAS_FPU
0014 #include <abi/fpu.h>
0015 #endif
0016 
0017 struct cpuinfo_csky {
0018     unsigned long asid_cache;
0019 } __aligned(SMP_CACHE_BYTES);
0020 
0021 extern struct cpuinfo_csky cpu_data[];
0022 
0023 /*
0024  * User space process size: 2GB. This is hardcoded into a few places,
0025  * so don't change it unless you know what you are doing.  TASK_SIZE
0026  * for a 64 bit kernel expandable to 8192EB, of which the current CSKY
0027  * implementations will "only" be able to use 1TB ...
0028  */
0029 #define TASK_SIZE   (PAGE_OFFSET - (PAGE_SIZE * 8))
0030 
0031 #ifdef __KERNEL__
0032 #define STACK_TOP       TASK_SIZE
0033 #define STACK_TOP_MAX   STACK_TOP
0034 #endif
0035 
0036 /* This decides where the kernel will search for a free chunk of vm
0037  * space during mmap's.
0038  */
0039 #define TASK_UNMAPPED_BASE      (TASK_SIZE / 3)
0040 
0041 struct thread_struct {
0042     unsigned long  sp;        /* kernel stack pointer */
0043     unsigned long  trap_no;   /* saved status register */
0044 
0045     /* FPU regs */
0046     struct user_fp __aligned(16) user_fp;
0047 };
0048 
0049 #define INIT_THREAD  { \
0050     .sp = sizeof(init_stack) + (unsigned long) &init_stack, \
0051 }
0052 
0053 /*
0054  * Do necessary setup to start up a newly executed thread.
0055  *
0056  * pass the data segment into user programs if it exists,
0057  * it can't hurt anything as far as I can tell
0058  */
0059 #define start_thread(_regs, _pc, _usp)                  \
0060 do {                                    \
0061     (_regs)->pc = (_pc);                        \
0062     (_regs)->regs[1] = 0; /* ABIV1 is R7, uClibc_main rtdl arg */   \
0063     (_regs)->regs[2] = 0;                       \
0064     (_regs)->regs[3] = 0; /* ABIV2 is R7, use it? */        \
0065     (_regs)->sr &= ~PS_S;                       \
0066     (_regs)->usp = (_usp);                      \
0067 } while (0)
0068 
0069 /* Forward declaration, a strange C thing */
0070 struct task_struct;
0071 
0072 /* Free all resources held by a thread. */
0073 static inline void release_thread(struct task_struct *dead_task)
0074 {
0075 }
0076 
0077 /* Prepare to copy thread state - unlazy all lazy status */
0078 #define prepare_to_copy(tsk)    do { } while (0)
0079 
0080 extern int kernel_thread(int (*fn)(void *), void *arg, unsigned long flags);
0081 
0082 unsigned long __get_wchan(struct task_struct *p);
0083 
0084 #define KSTK_EIP(tsk)       (task_pt_regs(tsk)->pc)
0085 #define KSTK_ESP(tsk)       (task_pt_regs(tsk)->usp)
0086 
0087 #define task_pt_regs(p) \
0088     ((struct pt_regs *)(THREAD_SIZE + task_stack_page(p)) - 1)
0089 
0090 #define cpu_relax() barrier()
0091 
0092 #endif /* __ASM_CSKY_PROCESSOR_H */