OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [linux-2.4/] [include/] [asm-s390/] [processor.h] - Blame information for rev 1774

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1276 phoenix
/*
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
#ifdef __KERNEL__
20
/*
21
 * Default implementation of macro that returns current
22
 * instruction pointer ("program counter").
23
 */
24
#define current_text_addr() ({ void *pc; __asm__("basr %0,0":"=a"(pc)); pc; })
25
 
26
/*
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]
30
 */
31
 
32
typedef struct
33
{
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;
39
 
40
struct cpuinfo_S390
41
{
42
        cpuid_t  cpu_id;
43
        __u16    cpu_addr;
44
        __u16    cpu_nr;
45
        unsigned long loops_per_jiffy;
46
        unsigned long *pgd_quick;
47
        unsigned long *pte_quick;
48
        unsigned long pgtable_cache_sz;
49
};
50
 
51
extern void print_cpu_info(struct cpuinfo_S390 *);
52
 
53
/* Lazy FPU handling on uni-processor */
54
extern struct task_struct *last_task_used_math;
55
 
56
/*
57
 * User space process size: 2GB (default).
58
 */
59
#define TASK_SIZE       (0x80000000)
60
/* This decides where the kernel will search for a free chunk of vm
61
 * space during mmap's.
62
 */
63
#define TASK_UNMAPPED_BASE      (TASK_SIZE / 2)
64
 
65
#define THREAD_SIZE (2*PAGE_SIZE)
66
 
67
typedef struct {
68
        unsigned long ar4;
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
        s390_fp_regs fp_regs;
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.     */
84
        __u32   trap_no;
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 */
89
        addr_t  pfault_wait;
90
};
91
 
92
typedef struct thread_struct thread_struct;
93
 
94
#define INIT_THREAD {{0,{{0},{0},{0},{0},{0},{0},{0},{0},{0},{0}, \
95
                            {0},{0},{0},{0},{0},{0}}},            \
96
                     0, 0,                                        \
97
                    sizeof(init_stack) + (__u32) &init_stack,     \
98
              (__pa((__u32) &swapper_pg_dir[0]) + _SEGMENT_TABLE),\
99
                     0,0,0,                                       \
100
                     (per_struct) {{{{0,}}},0,0,0,0,{{0,}}},      \
101
                     0, 0                                         \
102
}
103
 
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 ;                          \
109
} while (0)
110
 
111
/* Forward declaration, a strange C thing */
112
struct mm_struct;
113
 
114
/* Free all resources held by a thread. */
115
extern void release_thread(struct task_struct *);
116
extern int arch_kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
117
 
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)
121
 
122
/*
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.
129
 */
130
extern inline unsigned long thread_saved_pc(struct thread_struct *t)
131
{
132
        unsigned long bc;
133
        bc = *((unsigned long *) t->ksp);
134
        return *((unsigned long *) (bc+56));
135
}
136
 
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])
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
#define cpu_relax()     do { } while (0)
156
 
157
/*
158
 * Set of msr bits that gdb can change on behalf of a process.
159
 */
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
169
 
170
/*
171
 * Set PSW mask to specified value, while leaving the
172
 * PSW addr pointing to the next instruction.
173
 */
174
 
175
static inline void __load_psw_mask (unsigned long mask)
176
{
177
        unsigned long addr;
178
 
179
        psw_t psw;
180
        psw.mask = mask;
181
 
182
        asm volatile (
183
                "    basr %0,0\n"
184
                "0:  ahi  %0,1f-0b\n"
185
                "    st   %0,4(%1)\n"
186
                "    lpsw 0(%1)\n"
187
                "1:"
188
                : "=&d" (addr) : "a" (&psw) : "memory", "cc" );
189
}
190
 
191
/*
192
 * Function to stop a processor until an interruption occured
193
 */
194
static inline void enabled_wait(void)
195
{
196
        unsigned long reg;
197
        psw_t wait_psw;
198
 
199
        wait_psw.mask = 0x070e0000;
200
        asm volatile (
201
                "    basr %0,0\n"
202
                "0:  la   %0,1f-0b(%0)\n"
203
                "    st   %0,4(%1)\n"
204
                "    oi   4(%1),0x80\n"
205
                "    lpsw 0(%1)\n"
206
                "1:"
207
                : "=&a" (reg) : "a" (&wait_psw) : "memory", "cc" );
208
}
209
 
210
/*
211
 * Function to drop a processor into disabled wait state
212
 */
213
 
214
static inline void disabled_wait(unsigned long code)
215
{
216
        char psw_buffer[2*sizeof(psw_t)];
217
        char ctl_buf[4];
218
        psw_t *dw_psw = (psw_t *)(((unsigned long) &psw_buffer+sizeof(psw_t)-1)
219
                                  & -sizeof(psw_t));
220
 
221
        dw_psw->mask = 0x000a0000;
222
        dw_psw->addr = code;
223
        /*
224
         * Store status and then load disabled wait psw,
225
         * the processor is dead afterwards
226
         */
227
 
228
        asm volatile ("    stctl 0,0,0(%1)\n"
229
                      "    ni    0(%1),0xef\n" /* switch off protection */
230
                      "    lctl  0,0,0(%1)\n"
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 */
242
                      "    lpsw 0(%0)"
243
                      : : "a" (dw_psw), "a" (&ctl_buf) : "cc" );
244
}
245
 
246
#endif
247
 
248
#endif                                 /* __ASM_S390_PROCESSOR_H           */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.