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

Subversion Repositories or1k

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1276 phoenix
/*
2
 * This file is subject to the terms and conditions of the GNU General Public
3
 * License.  See the file "COPYING" in the main directory of this archive
4
 * for more details.
5
 *
6
 * Copyright (C) 1994 Waldorf GMBH
7
 * Copyright (C) 1995, 1996, 1997, 1998, 1999, 2001, 2002, 2003 Ralf Baechle
8
 * Copyright (C) 1996 Paul M. Antoine
9
 * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
10
 */
11
#ifndef _ASM_PROCESSOR_H
12
#define _ASM_PROCESSOR_H
13
 
14
#include <linux/config.h>
15
#include <linux/cache.h>
16
#include <asm/isadep.h>
17
 
18
/*
19
 * Return current * instruction pointer ("program counter").
20
 */
21
#define current_text_addr() ({ __label__ _l; _l: &&_l;})
22
 
23
#ifndef __ASSEMBLY__
24
#include <linux/smp.h>
25
#include <linux/threads.h>
26
 
27
#include <asm/cachectl.h>
28
#include <asm/cpu.h>
29
#include <asm/mipsregs.h>
30
#include <asm/reg.h>
31
#include <asm/system.h>
32
 
33
/*
34
 * Descriptor for a cache
35
 */
36
struct cache_desc {
37
        unsigned short linesz;  /* Size of line in bytes */
38
        unsigned short ways;    /* Number of ways */
39
        unsigned short sets;    /* Number of lines per set */
40
        unsigned int waysize;   /* Bytes per way */
41
        unsigned int waybit;    /* Bits to select in a cache set */
42
        unsigned int flags;     /* Flags describing cache properties */
43
};
44
 
45
/*
46
 * Flag definitions
47
 */
48
#define MIPS_CACHE_NOT_PRESENT  0x00000001
49
#define MIPS_CACHE_VTAG         0x00000002      /* Virtually tagged cache */
50
#define MIPS_CACHE_ALIASES      0x00000004      /* Cache could have aliases */
51
#define MIPS_CACHE_IC_F_DC      0x00000008      /* Ic can refill from D-cache */
52
 
53
struct cpuinfo_mips {
54
        unsigned long udelay_val;
55
        unsigned long *pgd_quick;
56
        unsigned long *pte_quick;
57
        unsigned long pgtable_cache_sz;
58
        unsigned long asid_cache;
59
        /*
60
         * Capability and feature descriptor structure for MIPS CPU
61
         */
62
        unsigned long options;
63
        unsigned int processor_id;
64
        unsigned int fpu_id;
65
        unsigned int cputype;
66
        int isa_level;
67
        int tlbsize;
68
        struct cache_desc icache;       /* Primary I-cache */
69
        struct cache_desc dcache;       /* Primary D or combined I/D cache */
70
        struct cache_desc scache;       /* Secondary cache */
71
        struct cache_desc tcache;       /* Tertiary/split secondary cache */
72
} __attribute__((aligned(SMP_CACHE_BYTES)));
73
 
74
/*
75
 * Assumption: Options of CPU 0 are a superset of all processors.
76
 * This is true for all known MIPS systems.
77
 */
78
#define cpu_has_tlb             (cpu_data[0].options & MIPS_CPU_TLB)
79
#define cpu_has_4kex            (cpu_data[0].options & MIPS_CPU_4KEX)
80
#define cpu_has_4ktlb           (cpu_data[0].options & MIPS_CPU_4KTLB)
81
#define cpu_has_fpu             (cpu_data[0].options & MIPS_CPU_FPU)
82
#define cpu_has_32fpr           (cpu_data[0].options & MIPS_CPU_32FPR)
83
#define cpu_has_counter         (cpu_data[0].options & MIPS_CPU_COUNTER)
84
#define cpu_has_watch           (cpu_data[0].options & MIPS_CPU_WATCH)
85
#define cpu_has_mips16          (cpu_data[0].options & MIPS_CPU_MIPS16)
86
#define cpu_has_divec           (cpu_data[0].options & MIPS_CPU_DIVEC)
87
#define cpu_has_vce             (cpu_data[0].options & MIPS_CPU_VCE)
88
#define cpu_has_cache_cdex_p    (cpu_data[0].options & MIPS_CPU_CACHE_CDEX_P)
89
#define cpu_has_cache_cdex_s    (cpu_data[0].options & MIPS_CPU_CACHE_CDEX_S)
90
#define cpu_has_prefetch        (cpu_data[0].options & MIPS_CPU_PREFETCH)
91
#define cpu_has_mcheck          (cpu_data[0].options & MIPS_CPU_MCHECK)
92
#define cpu_has_ejtag           (cpu_data[0].options & MIPS_CPU_EJTAG)
93
#define cpu_has_nofpuex         (cpu_data[0].options & MIPS_CPU_NOFPUEX)
94
#define cpu_has_llsc            (cpu_data[0].options & MIPS_CPU_LLSC)
95
#define cpu_has_vtag_icache     (cpu_data[0].icache.flags & MIPS_CACHE_VTAG)
96
#define cpu_has_dc_aliases      (cpu_data[0].dcache.flags & MIPS_CACHE_ALIASES)
97
#define cpu_has_ic_fills_f_dc   (cpu_data[0].dcache.flags & MIPS_CACHE_IC_F_DC)
98
#define cpu_has_64bits          (cpu_data[0].isa_level & MIPS_CPU_ISA_64BIT)
99
#define cpu_has_64bit_addresses 0
100
#define cpu_has_subset_pcaches  (cpu_data[0].options & MIPS_CPU_SUBSET_CACHES)
101
 
102
#define cpu_dcache_line_size()  current_cpu_data.dcache.linesz
103
#define cpu_icache_line_size()  current_cpu_data.icache.linesz
104
#define cpu_scache_line_size()  current_cpu_data.scache.linesz
105
 
106
extern struct cpuinfo_mips cpu_data[];
107
#define current_cpu_data cpu_data[smp_processor_id()]
108
 
109
extern void cpu_probe(void);
110
extern void cpu_report(void);
111
 
112
/*
113
 * System setup and hardware flags..
114
 */
115
extern void (*cpu_wait)(void);
116
 
117
extern unsigned int vced_count, vcei_count;
118
 
119
/*
120
 * Bus types (default is ISA, but people can check others with these..)
121
 */
122
#ifdef CONFIG_EISA
123
extern int EISA_bus;
124
#else
125
#define EISA_bus (0)
126
#endif
127
 
128
#define MCA_bus 0
129
#define MCA_bus__is_a_macro /* for versions in ksyms.c */
130
 
131
/*
132
 * User space process size: 2GB. This is hardcoded into a few places,
133
 * so don't change it unless you know what you are doing.  TASK_SIZE
134
 * for a 64 bit kernel expandable to 8192EB, of which the current MIPS
135
 * implementations will "only" be able to use 1TB ...
136
 */
137
#define TASK_SIZE       0x7fff8000UL
138
 
139
/* This decides where the kernel will search for a free chunk of vm
140
 * space during mmap's.
141
 */
142
#define TASK_UNMAPPED_BASE      (TASK_SIZE / 3)
143
 
144
/*
145
 * Size of io_bitmap in longwords: 32 is ports 0-0x3ff.
146
 */
147
#define IO_BITMAP_SIZE  32
148
 
149
#define NUM_FPU_REGS    32
150
 
151
struct mips_fpu_hard_struct {
152
        double fp_regs[NUM_FPU_REGS];
153
        unsigned int control;
154
};
155
 
156
/*
157
 * It would be nice to add some more fields for emulator statistics, but there
158
 * are a number of fixed offsets in offset.h and elsewhere that would have to
159
 * be recalculated by hand.  So the additional information will be private to
160
 * the FPU emulator for now.  See asm-mips/fpu_emulator.h.
161
 */
162
typedef u64 fpureg_t;
163
struct mips_fpu_soft_struct {
164
        fpureg_t        regs[NUM_FPU_REGS];
165
        unsigned int    sr;
166
};
167
 
168
union mips_fpu_union {
169
        struct mips_fpu_hard_struct hard;
170
        struct mips_fpu_soft_struct soft;
171
};
172
 
173
#define INIT_FPU { \
174
        {{0,},} \
175
}
176
 
177
typedef struct {
178
        unsigned long seg;
179
} mm_segment_t;
180
 
181
/*
182
 * If you change thread_struct remember to change the #defines below too!
183
 */
184
struct thread_struct {
185
        /* Saved main processor registers. */
186
        unsigned long reg16;
187
        unsigned long reg17, reg18, reg19, reg20, reg21, reg22, reg23;
188
        unsigned long reg29, reg30, reg31;
189
 
190
        /* Saved cp0 stuff. */
191
        unsigned long cp0_status;
192
 
193
        /* Saved fpu/fpu emulator stuff. */
194
        union mips_fpu_union fpu;
195
 
196
        /* Other stuff associated with the thread. */
197
        unsigned long cp0_badvaddr;     /* Last user fault */
198
        unsigned long cp0_baduaddr;     /* Last kernel fault accessing USEG */
199
        unsigned long error_code;
200
        unsigned long trap_no;
201
#define MF_FIXADE       1               /* Fix address errors in software */
202
#define MF_LOGADE       2               /* Log address errors to syslog */
203
        unsigned long mflags;
204
        mm_segment_t current_ds;
205
        unsigned long irix_trampoline;  /* Wheee... */
206
        unsigned long irix_oldctx;
207
};
208
 
209
#endif /* !__ASSEMBLY__ */
210
 
211
#define INIT_THREAD  { \
212
        /* \
213
         * saved main processor registers \
214
         */ \
215
        0, 0, 0, 0, 0, 0, 0, 0, \
216
                       0, 0, 0, \
217
        /* \
218
         * saved cp0 stuff \
219
         */ \
220
        0, \
221
        /* \
222
         * saved fpu/fpu emulator stuff \
223
         */ \
224
        INIT_FPU, \
225
        /* \
226
         * Other stuff associated with the process \
227
         */ \
228
        0, 0, 0, 0, \
229
        /* \
230
         * For now the default is to fix address errors \
231
         */ \
232
        MF_FIXADE, { 0 }, 0, 0 \
233
}
234
 
235
#ifdef __KERNEL__
236
 
237
#define KERNEL_STACK_SIZE       0x2000
238
 
239
#ifndef __ASSEMBLY__
240
 
241
/* Free all resources held by a thread. */
242
#define release_thread(thread) do { } while(0)
243
 
244
extern int arch_kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
245
 
246
/* Copy and release all segment info associated with a VM */
247
#define copy_segments(p, mm) do { } while(0)
248
#define release_segments(mm) do { } while(0)
249
 
250
struct mips_frame_info {
251
        int frame_offset;
252
        int pc_offset;
253
};
254
extern struct mips_frame_info schedule_frame;
255
/*
256
 * Return saved PC of a blocked thread.
257
 */
258
static inline unsigned long thread_saved_pc(struct thread_struct *t)
259
{
260
        extern void ret_from_fork(void);
261
 
262
        /* New born processes are a special case */
263
        if (t->reg31 == (unsigned long) ret_from_fork)
264
                return t->reg31;
265
 
266
        if (schedule_frame.pc_offset < 0)
267
                return 0;
268
        return ((unsigned long *)t->reg29)[schedule_frame.pc_offset];
269
}
270
 
271
/*
272
 * Do necessary setup to start up a newly executed thread.
273
 */
274
extern void start_thread(struct pt_regs * regs, unsigned long pc, unsigned long sp);
275
 
276
struct task_struct;
277
unsigned long get_wchan(struct task_struct *p);
278
 
279
#define __PT_REG(reg) ((long)&((struct pt_regs *)0)->reg - sizeof(struct pt_regs))
280
#define __KSTK_TOS(tsk) ((unsigned long)(tsk) + KERNEL_STACK_SIZE - 32)
281
#define KSTK_EIP(tsk) (*(unsigned long *)(__KSTK_TOS(tsk) + __PT_REG(cp0_epc)))
282
#define KSTK_ESP(tsk) (*(unsigned long *)(__KSTK_TOS(tsk) + __PT_REG(regs[29])))
283
#define KSTK_STATUS(tsk) (*(unsigned long *)(__KSTK_TOS(tsk) + __PT_REG(cp0_status)))
284
 
285
/* Allocation and freeing of basic task resources. */
286
/*
287
 * NOTE! The task struct and the stack go together
288
 */
289
#define THREAD_ORDER            (PAGE_SHIFT >= 14 ? 0 : 1)
290
#define THREAD_SIZE             (PAGE_SIZE << THREAD_ORDER)
291
#define THREAD_MASK             (THREAD_SIZE - 1UL)
292
#define alloc_task_struct() \
293
        ((struct task_struct *) __get_free_pages(GFP_KERNEL,1))
294
#define free_task_struct(p)     free_pages((unsigned long)(p),1)
295
#define get_task_struct(tsk)      atomic_inc(&virt_to_page(tsk)->count)
296
 
297
#define init_task       (init_task_union.task)
298
#define init_stack      (init_task_union.stack)
299
 
300
#define cpu_relax()     barrier()
301
 
302
#endif /* !__ASSEMBLY__ */
303
#endif /* __KERNEL__ */
304
 
305
/*
306
 * Return_address is a replacement for __builtin_return_address(count)
307
 * which on certain architectures cannot reasonably be implemented in GCC
308
 * (MIPS, Alpha) or is unuseable with -fomit-frame-pointer (i386).
309
 * Note that __builtin_return_address(x>=1) is forbidden because GCC
310
 * aborts compilation on some CPUs.  It's simply not possible to unwind
311
 * some CPU's stackframes.
312
 *
313
 * __builtin_return_address works only for non-leaf functions.  We avoid the
314
 * overhead of a function call by forcing the compiler to save the return
315
 * address register on the stack.
316
 */
317
#define return_address() ({__asm__ __volatile__("":::"$31");__builtin_return_address(0);})
318
 
319
#endif /* _ASM_PROCESSOR_H */

powered by: WebSVN 2.1.0

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