Merge tag 'for-linus' of git://linux-c6x.org/git/projects/linux-c6x-upstreaming
[sfrench/cifs-2.6.git] / arch / h8300 / include / asm / processor.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * include/asm-h8300/processor.h
4  *
5  * Copyright (C) 2002 Yoshinori Sato
6  *
7  * Based on: linux/asm-m68nommu/processor.h
8  *
9  * Copyright (C) 1995 Hamish Macdonald
10  */
11
12 #ifndef __ASM_H8300_PROCESSOR_H
13 #define __ASM_H8300_PROCESSOR_H
14
15 #include <linux/compiler.h>
16 #include <asm/segment.h>
17 #include <asm/ptrace.h>
18 #include <asm/current.h>
19
20 static inline unsigned long rdusp(void)
21 {
22         extern unsigned int     _sw_usp;
23
24         return _sw_usp;
25 }
26
27 static inline void wrusp(unsigned long usp)
28 {
29         extern unsigned int     _sw_usp;
30
31         _sw_usp = usp;
32 }
33
34 /*
35  * User space process size: 3.75GB. This is hardcoded into a few places,
36  * so don't change it unless you know what you are doing.
37  */
38 #define TASK_SIZE       (0xFFFFFFFFUL)
39
40 #ifdef __KERNEL__
41 #define STACK_TOP       TASK_SIZE
42 #define STACK_TOP_MAX   STACK_TOP
43 #endif
44
45 /*
46  * This decides where the kernel will search for a free chunk of vm
47  * space during mmap's. We won't be using it
48  */
49 #define TASK_UNMAPPED_BASE      0
50
51 struct thread_struct {
52         unsigned long  ksp;             /* kernel stack pointer */
53         unsigned long  usp;             /* user stack pointer */
54         unsigned long  ccr;             /* saved status register */
55         unsigned long  esp0;            /* points to SR of stack frame */
56         struct {
57                 unsigned short *addr;
58                 unsigned short inst;
59         } breakinfo;
60 };
61
62 #define INIT_THREAD  {                                          \
63         .ksp  = sizeof(init_stack) + (unsigned long)init_stack, \
64         .usp  = 0,                                              \
65         .ccr  = PS_S,                                           \
66         .esp0 = 0,                                              \
67         .breakinfo = {                                          \
68                 .addr = (unsigned short *)-1,                   \
69                 .inst = 0                                       \
70         }                                                       \
71 }
72
73 /*
74  * Do necessary setup to start up a newly executed thread.
75  *
76  * pass the data segment into user programs if it exists,
77  * it can't hurt anything as far as I can tell
78  */
79 #if defined(CONFIG_CPU_H8300H)
80 #define start_thread(_regs, _pc, _usp)                          \
81 do {                                                            \
82         (_regs)->pc = (_pc);                                    \
83         (_regs)->ccr = 0x00;       /* clear all flags */        \
84         (_regs)->er5 = current->mm->start_data; /* GOT base */  \
85         (_regs)->sp = ((unsigned long)(_usp)) - sizeof(unsigned long) * 3; \
86 } while (0)
87 #endif
88 #if defined(CONFIG_CPU_H8S)
89 #define start_thread(_regs, _pc, _usp)                          \
90 do {                                                            \
91         (_regs)->pc = (_pc);                                    \
92         (_regs)->ccr = 0x00;       /* clear kernel flag */      \
93         (_regs)->exr = 0x78;       /* enable all interrupts */  \
94         (_regs)->er5 = current->mm->start_data; /* GOT base */  \
95         /* 14 = space for retaddr(4), vector(4), er0(4) and exr(2) on stack */ \
96         (_regs)->sp = ((unsigned long)(_usp)) - 14;             \
97 } while (0)
98 #endif
99
100 /* Forward declaration, a strange C thing */
101 struct task_struct;
102
103 /* Free all resources held by a thread. */
104 static inline void release_thread(struct task_struct *dead_task)
105 {
106 }
107
108 unsigned long get_wchan(struct task_struct *p);
109
110 #define KSTK_EIP(tsk)   \
111         ({                       \
112                 unsigned long eip = 0;        \
113                 if ((tsk)->thread.esp0 > PAGE_SIZE &&   \
114                     MAP_NR((tsk)->thread.esp0) < max_mapnr)      \
115                         eip = ((struct pt_regs *) (tsk)->thread.esp0)->pc; \
116                 eip; })
117
118 #define KSTK_ESP(tsk)   ((tsk) == current ? rdusp() : (tsk)->thread.usp)
119
120 #define cpu_relax()    barrier()
121
122 #define HARD_RESET_NOW() ({             \
123         local_irq_disable();            \
124         asm("jmp @@0");                 \
125 })
126
127 #endif