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