2 * include/asm-s390/processor.h
5 * Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation
6 * Author(s): Hartmut Penner (hp@de.ibm.com),
7 * Martin Schwidefsky (schwidefsky@de.ibm.com)
9 * Derived from "include/asm-i386/processor.h"
10 * Copyright (C) 1994, Linus Torvalds
13 #ifndef __ASM_S390_PROCESSOR_H
14 #define __ASM_S390_PROCESSOR_H
17 #include <asm/ptrace.h>
21 * Default implementation of macro that returns current
22 * instruction pointer ("program counter").
24 #define current_text_addr() ({ void *pc; __asm__("basr %0,0":"=a"(pc)); pc; })
27 * CPU type and hardware bug flags. Kept separately for each CPU.
28 * Members of this structure are referenced in head.S, so think twice
29 * before touching them. [mj]
34 unsigned int version : 8;
35 unsigned int ident : 24;
36 unsigned int machine : 16;
37 unsigned int unused : 16;
38 } __attribute__ ((packed)) cpuid_t;
43 unsigned long loops_per_jiffy;
44 unsigned long *pgd_quick;
45 unsigned long *pmd_quick;
46 unsigned long *pte_quick;
47 unsigned long pgtable_cache_sz;
53 extern void print_cpu_info(struct cpuinfo_S390 *);
55 /* Lazy FPU handling on uni-processor */
56 extern struct task_struct *last_task_used_math;
58 #define S390_FLAG_31BIT 0x01UL
61 * User space process size: 4TB (default).
63 #define TASK_SIZE (0x20000000000UL)
64 #define TASK31_SIZE (0x80000000UL)
66 /* This decides where the kernel will search for a free chunk of vm
67 * space during mmap's.
69 #define TASK_UNMAPPED_BASE ((current->thread.flags & S390_FLAG_31BIT) ? \
70 (TASK31_SIZE / 2) : (TASK_SIZE / 2))
72 #define THREAD_SIZE (4*PAGE_SIZE)
78 /* if you change the thread_struct structure, you must
79 * update the _TSS_* defines in entry.S
85 __u32 ar2; /* kernel access register 2 */
86 __u32 ar4; /* kernel access register 4 */
87 addr_t ksp; /* kernel stack pointer */
88 addr_t user_seg; /* HSTD */
89 addr_t prot_addr; /* address of protection-excep. */
90 __u32 error_code; /* error-code of last prog-excep. */
92 per_struct per_info;/* Must be aligned on an 4 byte boundary*/
93 /* Used to give failing instruction back to user for ieee exceptions */
94 addr_t ieee_instruction_pointer;
95 unsigned long flags; /* various flags */
96 /* pfault_wait is used to block the process on a pfault event */
100 typedef struct thread_struct thread_struct;
102 #define INIT_THREAD {{0,{{0},{0},{0},{0},{0},{0},{0},{0},{0},{0}, \
103 {0},{0},{0},{0},{0},{0}}}, \
105 sizeof(init_stack) + (addr_t) &init_stack, \
106 (__pa((addr_t) &swapper_pg_dir[0]) + _REGION_TABLE),\
108 (per_struct) {{{{0,}}},0,0,0,0,{{0,}}}, \
112 /* need to define ... */
113 #define start_thread(regs, new_psw, new_stackp) do { \
114 regs->psw.mask = _USER_PSW_MASK; \
115 regs->psw.addr = new_psw; \
116 regs->gprs[15] = new_stackp; \
119 #define start_thread31(regs, new_psw, new_stackp) do { \
120 regs->psw.mask = _USER_PSW_MASK & ~(1L << 32); \
121 regs->psw.addr = new_psw; \
122 regs->gprs[15] = new_stackp; \
126 /* Forward declaration, a strange C thing */
129 /* Free all resources held by a thread. */
130 extern void release_thread(struct task_struct *);
131 extern int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
133 /* Copy and release all segment info associated with a VM */
134 #define copy_segments(nr, mm) do { } while (0)
135 #define release_segments(mm) do { } while (0)
138 * Return saved PC of a blocked thread. used in kernel/sched
139 * resume in entry.S does not create a new stack frame, it
140 * just stores the registers %r6-%r15 to the frame given by
141 * schedule. We want to return the address of the caller of
142 * schedule, so we have to walk the backchain one time to
143 * find the frame schedule() store its return address.
145 extern inline unsigned long thread_saved_pc(struct thread_struct *t)
148 bc = *((unsigned long *) t->ksp);
149 return *((unsigned long *) (bc+112));
152 unsigned long get_wchan(struct task_struct *p);
153 #define __KSTK_PTREGS(tsk) ((struct pt_regs *) \
154 (((unsigned long) tsk + THREAD_SIZE - sizeof(struct pt_regs)) & -8L))
155 #define KSTK_EIP(tsk) (__KSTK_PTREGS(tsk)->psw.addr)
156 #define KSTK_ESP(tsk) (__KSTK_PTREGS(tsk)->gprs[15])
158 /* Allocation and freeing of basic task resources. */
159 extern struct task_struct *alloc_task_struct(void);
160 extern void free_task_struct(struct task_struct *tsk);
161 extern void get_task_struct(struct task_struct *tsk);
163 #define init_task (init_task_union.task)
164 #define init_stack (init_task_union.stack)
166 #define cpu_relax() do { } while (0)
169 * Set of msr bits that gdb can change on behalf of a process.
171 /* Only let our hackers near the condition codes */
172 #define PSW_MASK_DEBUGCHANGE 0x0000300000000000UL
173 /* Don't let em near the addressing mode either */
174 #define PSW_ADDR_DEBUGCHANGE 0xFFFFFFFFFFFFFFFFUL
175 #define PSW_ADDR_MASK 0xFFFFFFFFFFFFFFFFUL
176 /* Program event recording mask */
177 #define PSW_PER_MASK 0x4000000000000000UL
178 #define USER_STD_MASK 0x0000000000000080UL
179 #define PSW_PROBLEM_STATE 0x0001000000000000UL
182 * Set PSW mask to specified value, while leaving the
183 * PSW addr pointing to the next instruction.
186 static inline void __load_psw_mask (unsigned long mask)
198 : "=&d" (addr) : "a" (&psw) : "memory", "cc" );
202 * Function to stop a processor until an interruption occured
204 static inline void enabled_wait(void)
209 wait_psw.mask = 0x0706000180000000;
215 : "=&a" (reg) : "a" (&wait_psw) : "memory", "cc" );
219 * Function to drop a processor into disabled wait state
222 static inline void disabled_wait(addr_t code)
224 char psw_buffer[2*sizeof(psw_t)];
226 psw_t *dw_psw = (psw_t *)(((unsigned long) &psw_buffer+sizeof(psw_t)-1)
229 dw_psw->mask = 0x0002000180000000;
232 * Store status and then load disabled wait psw,
233 * the processor is dead afterwards
235 asm volatile (" stctg 0,0,0(%1)\n"
236 " ni 4(%1),0xef\n" /* switch off protection */
239 " stpt 0x328(1)\n" /* store timer */
240 " stckc 0x330(1)\n" /* store clock comparator */
241 " stpx 0x318(1)\n" /* store prefix register */
242 " stam 0,15,0x340(1)\n" /* store access registers */
243 " stfpc 0x31c(1)\n" /* store fpu control */
244 " std 0,0x200(1)\n" /* store f0 */
245 " std 1,0x208(1)\n" /* store f1 */
246 " std 2,0x210(1)\n" /* store f2 */
247 " std 3,0x218(1)\n" /* store f3 */
248 " std 4,0x220(1)\n" /* store f4 */
249 " std 5,0x228(1)\n" /* store f5 */
250 " std 6,0x230(1)\n" /* store f6 */
251 " std 7,0x238(1)\n" /* store f7 */
252 " std 8,0x240(1)\n" /* store f8 */
253 " std 9,0x248(1)\n" /* store f9 */
254 " std 10,0x250(1)\n" /* store f10 */
255 " std 11,0x258(1)\n" /* store f11 */
256 " std 12,0x260(1)\n" /* store f12 */
257 " std 13,0x268(1)\n" /* store f13 */
258 " std 14,0x270(1)\n" /* store f14 */
259 " std 15,0x278(1)\n" /* store f15 */
260 " stmg 0,15,0x280(1)\n" /* store general registers */
261 " stctg 0,15,0x380(1)\n" /* store control registers */
262 " oi 0x384(1),0x10\n" /* fake protection bit */
264 : : "a" (dw_psw), "a" (&ctl_buf) : "cc", "0", "1");
269 #endif /* __ASM_S390_PROCESSOR_H */