xref: /OK3568_Linux_fs/kernel/arch/openrisc/include/asm/processor.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0-or-later */
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun  * OpenRISC Linux
4*4882a593Smuzhiyun  *
5*4882a593Smuzhiyun  * Linux architectural port borrowing liberally from similar works of
6*4882a593Smuzhiyun  * others.  All original copyrights apply as per the original source
7*4882a593Smuzhiyun  * declaration.
8*4882a593Smuzhiyun  *
9*4882a593Smuzhiyun  * OpenRISC implementation:
10*4882a593Smuzhiyun  * Copyright (C) 2003 Matjaz Breskvar <phoenix@bsemi.com>
11*4882a593Smuzhiyun  * Copyright (C) 2010-2011 Jonas Bonn <jonas@southpole.se>
12*4882a593Smuzhiyun  * et al.
13*4882a593Smuzhiyun  */
14*4882a593Smuzhiyun 
15*4882a593Smuzhiyun #ifndef __ASM_OPENRISC_PROCESSOR_H
16*4882a593Smuzhiyun #define __ASM_OPENRISC_PROCESSOR_H
17*4882a593Smuzhiyun 
18*4882a593Smuzhiyun #include <asm/spr_defs.h>
19*4882a593Smuzhiyun #include <asm/page.h>
20*4882a593Smuzhiyun #include <asm/ptrace.h>
21*4882a593Smuzhiyun 
22*4882a593Smuzhiyun #define STACK_TOP       TASK_SIZE
23*4882a593Smuzhiyun #define STACK_TOP_MAX	STACK_TOP
24*4882a593Smuzhiyun /* Kernel and user SR register setting */
25*4882a593Smuzhiyun #define KERNEL_SR (SPR_SR_DME | SPR_SR_IME | SPR_SR_ICE \
26*4882a593Smuzhiyun 		   | SPR_SR_DCE | SPR_SR_SM)
27*4882a593Smuzhiyun #define USER_SR   (SPR_SR_DME | SPR_SR_IME | SPR_SR_ICE \
28*4882a593Smuzhiyun 		   | SPR_SR_DCE | SPR_SR_IEE | SPR_SR_TEE)
29*4882a593Smuzhiyun 
30*4882a593Smuzhiyun /*
31*4882a593Smuzhiyun  * User space process size. This is hardcoded into a few places,
32*4882a593Smuzhiyun  * so don't change it unless you know what you are doing.
33*4882a593Smuzhiyun  */
34*4882a593Smuzhiyun 
35*4882a593Smuzhiyun #define TASK_SIZE       (0x80000000UL)
36*4882a593Smuzhiyun 
37*4882a593Smuzhiyun /* This decides where the kernel will search for a free chunk of vm
38*4882a593Smuzhiyun  * space during mmap's.
39*4882a593Smuzhiyun  */
40*4882a593Smuzhiyun #define TASK_UNMAPPED_BASE      (TASK_SIZE / 8 * 3)
41*4882a593Smuzhiyun 
42*4882a593Smuzhiyun #ifndef __ASSEMBLY__
43*4882a593Smuzhiyun 
44*4882a593Smuzhiyun struct task_struct;
45*4882a593Smuzhiyun 
46*4882a593Smuzhiyun struct thread_struct {
47*4882a593Smuzhiyun };
48*4882a593Smuzhiyun 
49*4882a593Smuzhiyun /*
50*4882a593Smuzhiyun  * At user->kernel entry, the pt_regs struct is stacked on the top of the
51*4882a593Smuzhiyun  * kernel-stack.  This macro allows us to find those regs for a task.
52*4882a593Smuzhiyun  * Notice that subsequent pt_regs stackings, like recursive interrupts
53*4882a593Smuzhiyun  * occurring while we're in the kernel, won't affect this - only the first
54*4882a593Smuzhiyun  * user->kernel transition registers are reached by this (i.e. not regs
55*4882a593Smuzhiyun  * for running signal handler)
56*4882a593Smuzhiyun  */
57*4882a593Smuzhiyun #define user_regs(thread_info)  (((struct pt_regs *)((unsigned long)(thread_info) + THREAD_SIZE - STACK_FRAME_OVERHEAD)) - 1)
58*4882a593Smuzhiyun 
59*4882a593Smuzhiyun /*
60*4882a593Smuzhiyun  * Dito but for the currently running task
61*4882a593Smuzhiyun  */
62*4882a593Smuzhiyun 
63*4882a593Smuzhiyun #define task_pt_regs(task) user_regs(task_thread_info(task))
64*4882a593Smuzhiyun 
65*4882a593Smuzhiyun #define INIT_SP         (sizeof(init_stack) + (unsigned long) &init_stack)
66*4882a593Smuzhiyun 
67*4882a593Smuzhiyun #define INIT_THREAD  { }
68*4882a593Smuzhiyun 
69*4882a593Smuzhiyun 
70*4882a593Smuzhiyun #define KSTK_EIP(tsk)   (task_pt_regs(tsk)->pc)
71*4882a593Smuzhiyun #define KSTK_ESP(tsk)   (task_pt_regs(tsk)->sp)
72*4882a593Smuzhiyun 
73*4882a593Smuzhiyun 
74*4882a593Smuzhiyun void start_thread(struct pt_regs *regs, unsigned long nip, unsigned long sp);
75*4882a593Smuzhiyun void release_thread(struct task_struct *);
76*4882a593Smuzhiyun unsigned long get_wchan(struct task_struct *p);
77*4882a593Smuzhiyun 
78*4882a593Smuzhiyun #define cpu_relax()     barrier()
79*4882a593Smuzhiyun 
80*4882a593Smuzhiyun #endif /* __ASSEMBLY__ */
81*4882a593Smuzhiyun #endif /* __ASM_OPENRISC_PROCESSOR_H */
82