Import changeset
[linux-flexiantxendom0-3.2.10.git] / include / asm-s390 / processor.h
1 /*
2  *  include/asm-s390/processor.h
3  *
4  *  S390 version
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)
8  *
9  *  Derived from "include/asm-i386/processor.h"
10  *    Copyright (C) 1994, Linus Torvalds
11  */
12
13 #ifndef __ASM_S390_PROCESSOR_H
14 #define __ASM_S390_PROCESSOR_H
15
16 #include <asm/page.h>
17 #include <asm/ptrace.h>
18
19 /*
20  * Default implementation of macro that returns current
21  * instruction pointer ("program counter").
22  */
23 #define current_text_addr() ({ void *pc; __asm__("basr %0,0":"=a"(pc)); pc; })
24
25 /*
26  *  CPU type and hardware bug flags. Kept separately for each CPU.
27  *  Members of this structure are referenced in head.S, so think twice
28  *  before touching them. [mj]
29  */
30
31 typedef struct
32 {
33         unsigned int version :  8;
34         unsigned int ident   : 24;
35         unsigned int machine : 16;
36         unsigned int unused  : 16;
37 } __attribute__ ((packed)) cpuid_t;
38
39 struct cpuinfo_S390
40 {
41         cpuid_t  cpu_id;
42         __u16    cpu_addr;
43         __u16    cpu_nr;
44         unsigned long loops_per_sec;
45         unsigned long *pgd_quick;
46         unsigned long *pte_quick;
47         unsigned long pgtable_cache_sz;
48 };
49
50 extern void print_cpu_info(struct cpuinfo_S390 *);
51
52 /* Lazy FPU handling on uni-processor */
53 extern struct task_struct *last_task_used_math;
54
55 /*
56  * User space process size: 2GB (default).
57  */
58 #define TASK_SIZE       (0x80000000)
59 /* This decides where the kernel will search for a free chunk of vm
60  * space during mmap's.
61  */
62 #define TASK_UNMAPPED_BASE      (TASK_SIZE / 2)
63
64 #define THREAD_SIZE (2*PAGE_SIZE)
65
66 typedef struct {
67         unsigned long seg;
68         unsigned long acc4;
69 } mm_segment_t;
70
71 /* if you change the thread_struct structure, you must
72  * update the _TSS_* defines in entry.S
73  */
74
75 struct thread_struct
76  {
77
78         struct pt_regs *regs;         /* the user registers can be found on*/
79         s390_fp_regs fp_regs;
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.     */
86         __u32   trap_no;
87         /* perform syscall argument validation (get/set_fs) */
88         mm_segment_t fs;
89         per_struct per_info;/* Must be aligned on an 4 byte boundary*/
90 };
91
92 typedef struct thread_struct thread_struct;
93
94 #define INIT_MMAP \
95 { &init_mm, 0, 0, NULL, PAGE_SHARED, \
96 VM_READ | VM_WRITE | VM_EXEC, 1, NULL, &init_mm.mmap }
97
98 #define INIT_THREAD { (struct pt_regs *) 0,                       \
99                     { 0,{{0},{0},{0},{0},{0},{0},{0},{0},{0},{0}, \
100                             {0},{0},{0},{0},{0},{0}}},            \
101                      0, 0,                                        \
102                     sizeof(init_stack) + (__u32) &init_stack,     \
103               (__pa((__u32) &swapper_pg_dir[0]) + _SEGMENT_TABLE),\
104                      0,0,0,                                       \
105                      (mm_segment_t) { 0,1},                       \
106                      (per_struct) {{{{0,}}},0,0,0,0,{{0,}}}       \
107 }
108
109 /* need to define ... */
110 #define start_thread(regs, new_psw, new_stackp) do {            \
111         unsigned long *u_stack = new_stackp;                    \
112         regs->psw.mask  = _USER_PSW_MASK;                       \
113         regs->psw.addr  = new_psw | 0x80000000 ;                \
114         get_user(regs->gprs[2],u_stack);                        \
115         get_user(regs->gprs[3],u_stack+1);                      \
116         get_user(regs->gprs[4],u_stack+2);                      \
117         regs->gprs[15]  = new_stackp ;                          \
118 } while (0)
119
120 /* Forward declaration, a strange C thing */
121 struct mm_struct;
122
123 /* Free all resources held by a thread. */
124 extern void release_thread(struct task_struct *);
125 extern int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
126
127 /* Copy and release all segment info associated with a VM */
128 #define copy_segments(nr, mm)           do { } while (0)
129 #define release_segments(mm)            do { } while (0)
130
131 /*
132  * Return saved PC of a blocked thread. used in kernel/sched
133  */
134 extern inline unsigned long thread_saved_pc(struct thread_struct *t)
135 {
136         return (t->regs) ? ((unsigned long)t->regs->psw.addr) : 0;
137 }
138
139 unsigned long get_wchan(struct task_struct *p);
140 #define KSTK_EIP(tsk)   ((tsk)->thread.regs->psw.addr)
141 #define KSTK_ESP(tsk)   ((tsk)->thread.ksp)
142
143 /* Allocation and freeing of basic task resources. */
144 /*
145  * NOTE! The task struct and the stack go together
146  */
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)
151
152 #define init_task       (init_task_union.task)
153 #define init_stack      (init_task_union.stack)
154
155 /*
156  * Set of msr bits that gdb can change on behalf of a process.
157  */
158 /* Only let our hackers near the condition codes */
159 #define PSW_MASK_DEBUGCHANGE    0x00003000UL
160 /* Don't let em near the addressing mode either */    
161 #define PSW_ADDR_DEBUGCHANGE    0x7FFFFFFFUL
162 #define PSW_ADDR_MASK           0x7FFFFFFFUL
163 /* Program event recording mask */    
164 #define PSW_PER_MASK            0x40000000UL
165 #define USER_STD_MASK           0x00000080UL
166 #define PSW_PROBLEM_STATE       0x00010000UL
167
168 /*
169  * Function to drop a processor into disabled wait state
170  */
171
172 static inline void disabled_wait(unsigned long code)
173 {
174         char psw_buffer[2*sizeof(psw_t)];
175         psw_t *dw_psw = (psw_t *)(((unsigned long) &psw_buffer+sizeof(psw_t)-1)
176                                   & -sizeof(psw_t));
177
178         dw_psw->mask = 0x000a0000;
179         dw_psw->addr = code;
180         /* load disabled wait psw, the processor is dead afterwards */
181         asm volatile ("lpsw 0(%0)" : : "a" (dw_psw));
182 }
183
184 #endif                                 /* __ASM_S390_PROCESSOR_H           */