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;
45 unsigned long loops_per_jiffy;
46 unsigned long *pgd_quick;
47 unsigned long *pte_quick;
48 unsigned long pgtable_cache_sz;
51 extern void print_cpu_info(struct cpuinfo_S390 *);
53 /* Lazy FPU handling on uni-processor */
54 extern struct task_struct *last_task_used_math;
57 * User space process size: 2GB (default).
59 #define TASK_SIZE (0x80000000)
60 /* This decides where the kernel will search for a free chunk of vm
61 * space during mmap's.
63 #define TASK_UNMAPPED_BASE (TASK_SIZE / 2)
65 #define THREAD_SIZE (2*PAGE_SIZE)
71 /* if you change the thread_struct structure, you must
72 * update the _TSS_* defines in entry.S
78 __u32 ar2; /* kernel access register 2 */
79 __u32 ar4; /* kernel access register 4 */
80 __u32 ksp; /* kernel stack pointer */
81 __u32 user_seg; /* HSTD */
82 __u32 error_code; /* error-code of last prog-excep. */
83 __u32 prot_addr; /* address of protection-excep. */
85 per_struct per_info;/* Must be aligned on an 4 byte boundary*/
86 /* Used to give failing instruction back to user for ieee exceptions */
87 addr_t ieee_instruction_pointer;
88 /* pfault_wait is used to block the process on a pfault event */
92 typedef struct thread_struct thread_struct;
94 #define INIT_THREAD {{0,{{0},{0},{0},{0},{0},{0},{0},{0},{0},{0}, \
95 {0},{0},{0},{0},{0},{0}}}, \
97 sizeof(init_stack) + (__u32) &init_stack, \
98 (__pa((__u32) &swapper_pg_dir[0]) + _SEGMENT_TABLE),\
100 (per_struct) {{{{0,}}},0,0,0,0,{{0,}}}, \
104 /* need to define ... */
105 #define start_thread(regs, new_psw, new_stackp) do { \
106 regs->psw.mask = _USER_PSW_MASK; \
107 regs->psw.addr = new_psw | 0x80000000; \
108 regs->gprs[15] = new_stackp ; \
111 /* Forward declaration, a strange C thing */
114 /* Free all resources held by a thread. */
115 extern void release_thread(struct task_struct *);
116 extern int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
118 /* Copy and release all segment info associated with a VM */
119 #define copy_segments(nr, mm) do { } while (0)
120 #define release_segments(mm) do { } while (0)
123 * Return saved PC of a blocked thread. used in kernel/sched.
124 * resume in entry.S does not create a new stack frame, it
125 * just stores the registers %r6-%r15 to the frame given by
126 * schedule. We want to return the address of the caller of
127 * schedule, so we have to walk the backchain one time to
128 * find the frame schedule() store its return address.
130 extern inline unsigned long thread_saved_pc(struct thread_struct *t)
133 bc = *((unsigned long *) t->ksp);
134 return *((unsigned long *) (bc+56));
137 unsigned long get_wchan(struct task_struct *p);
138 #define __KSTK_PTREGS(tsk) ((struct pt_regs *) \
139 (((unsigned long) tsk + THREAD_SIZE - sizeof(struct pt_regs)) & -8L))
140 #define KSTK_EIP(tsk) (__KSTK_PTREGS(tsk)->psw.addr)
141 #define KSTK_ESP(tsk) (__KSTK_PTREGS(tsk)->gprs[15])
143 /* Allocation and freeing of basic task resources. */
145 * NOTE! The task struct and the stack go together
147 #define alloc_task_struct() \
148 ((struct task_struct *) __get_free_pages(GFP_KERNEL,1))
149 #define free_task_struct(p) free_pages((unsigned long)(p),1)
150 #define get_task_struct(tsk) atomic_inc(&virt_to_page(tsk)->count)
152 #define init_task (init_task_union.task)
153 #define init_stack (init_task_union.stack)
155 #define cpu_relax() do { } while (0)
158 * Set of msr bits that gdb can change on behalf of a process.
160 /* Only let our hackers near the condition codes */
161 #define PSW_MASK_DEBUGCHANGE 0x00003000UL
162 /* Don't let em near the addressing mode either */
163 #define PSW_ADDR_DEBUGCHANGE 0x7FFFFFFFUL
164 #define PSW_ADDR_MASK 0x7FFFFFFFUL
165 /* Program event recording mask */
166 #define PSW_PER_MASK 0x40000000UL
167 #define USER_STD_MASK 0x00000080UL
168 #define PSW_PROBLEM_STATE 0x00010000UL
171 * Set PSW mask to specified value, while leaving the
172 * PSW addr pointing to the next instruction.
175 static inline void __load_psw_mask (unsigned long mask)
188 : "=&d" (addr) : "a" (&psw) : "memory", "cc" );
192 * Function to stop a processor until an interruption occured
194 static inline void enabled_wait(void)
199 wait_psw.mask = 0x070e0000;
202 "0: la %0,1f-0b(%0)\n"
207 : "=&a" (reg) : "a" (&wait_psw) : "memory", "cc" );
211 * Function to drop a processor into disabled wait state
214 static inline void disabled_wait(unsigned long code)
216 char psw_buffer[2*sizeof(psw_t)];
218 psw_t *dw_psw = (psw_t *)(((unsigned long) &psw_buffer+sizeof(psw_t)-1)
221 dw_psw->mask = 0x000a0000;
224 * Store status and then load disabled wait psw,
225 * the processor is dead afterwards
228 asm volatile (" stctl 0,0,0(%1)\n"
229 " ni 0(%1),0xef\n" /* switch off protection */
231 " stpt 0xd8\n" /* store timer */
232 " stckc 0xe0\n" /* store clock comparator */
233 " stpx 0x108\n" /* store prefix register */
234 " stam 0,15,0x120\n" /* store access registers */
235 " std 0,0x160\n" /* store f0 */
236 " std 2,0x168\n" /* store f2 */
237 " std 4,0x170\n" /* store f4 */
238 " std 6,0x178\n" /* store f6 */
239 " stm 0,15,0x180\n" /* store general registers */
240 " stctl 0,15,0x1c0\n" /* store control registers */
241 " oi 0(%1),0x10\n" /* fake protection bit */
243 : : "a" (dw_psw), "a" (&ctl_buf) : "cc" );
248 #endif /* __ASM_S390_PROCESSOR_H */