- Kai Germaschewski: ymfpci cleanups and resource leak fixes
[davej-history.git] / include / asm-s390 / processor.h
blob5cb89c8a3db95d94c11c6486227d6a6115db84da
1 /*
2 * include/asm-s390/processor.h
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)
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
16 #include <asm/page.h>
17 #include <asm/ptrace.h>
20 * Default implementation of macro that returns current
21 * instruction pointer ("program counter").
23 #define current_text_addr() ({ void *pc; __asm__("basr %0,0":"=a"(pc)); pc; })
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]
31 typedef struct
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;
39 struct cpuinfo_S390
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;
50 extern void print_cpu_info(struct cpuinfo_S390 *);
52 /* Lazy FPU handling on uni-processor */
53 extern struct task_struct *last_task_used_math;
56 * User space process size: 2GB (default).
58 #define TASK_SIZE (0x80000000)
59 /* This decides where the kernel will search for a free chunk of vm
60 * space during mmap's.
62 #define TASK_UNMAPPED_BASE (TASK_SIZE / 2)
64 #define THREAD_SIZE (2*PAGE_SIZE)
66 typedef struct {
67 unsigned long seg;
68 unsigned long acc4;
69 } mm_segment_t;
71 /* if you change the thread_struct structure, you must
72 * update the _TSS_* defines in entry.S
75 struct thread_struct
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*/
92 typedef struct thread_struct thread_struct;
94 #define INIT_MMAP \
95 { &init_mm, 0, 0, NULL, PAGE_SHARED, \
96 VM_READ | VM_WRITE | VM_EXEC, 1, NULL, &init_mm.mmap }
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,}}} \
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)
120 /* Forward declaration, a strange C thing */
121 struct mm_struct;
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);
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 #define forget_segments() do { } while (0)
134 * Return saved PC of a blocked thread. used in kernel/sched
136 extern inline unsigned long thread_saved_pc(struct thread_struct *t)
138 return (t->regs) ? ((unsigned long)t->regs->psw.addr) : 0;
141 unsigned long get_wchan(struct task_struct *p);
142 #define KSTK_EIP(tsk) ((tsk)->thread.regs->psw.addr)
143 #define KSTK_ESP(tsk) ((tsk)->thread.ksp)
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)
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 * Function to drop a processor into disabled wait state
174 static inline void disabled_wait(unsigned long code)
176 char psw_buffer[2*sizeof(psw_t)];
177 psw_t *dw_psw = (psw_t *)(((unsigned long) &psw_buffer+sizeof(psw_t)-1)
178 & -sizeof(psw_t));
180 dw_psw->mask = 0x000a0000;
181 dw_psw->addr = code;
182 /* load disabled wait psw, the processor is dead afterwards */
183 asm volatile ("lpsw 0(%0)" : : "a" (dw_psw));
186 #endif /* __ASM_S390_PROCESSOR_H */