source: svn/trunk/newcon3bcm2_21bu/toolchain/mips-linux-uclibc/include/asm/processor.h

Last change on this file was 2, checked in by jglee, 11 years ago

first commit

  • Property svn:executable set to *
File size: 5.9 KB
Line 
1/*
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/threads.h>
15
16#include <asm/cachectl.h>
17#include <asm/cpu.h>
18#include <asm/cpu-info.h>
19#include <asm/mipsregs.h>
20#include <asm/prefetch.h>
21#include <asm/system.h>
22
23/*
24 * Return current * instruction pointer ("program counter").
25 */
26#define current_text_addr() ({ __label__ _l; _l: &&_l;})
27
28/*
29 * System setup and hardware flags..
30 */
31extern void (*cpu_wait)(void);
32
33extern unsigned int vced_count, vcei_count;
34
35#ifndef __mips64
36/*
37 * User space process size: 2GB. This is hardcoded into a few places,
38 * so don't change it unless you know what you are doing.
39 */
40#define TASK_SIZE       0x7fff8000UL
41
42/*
43 * This decides where the kernel will search for a free chunk of vm
44 * space during mmap's.
45 */
46#define TASK_UNMAPPED_BASE      (PAGE_ALIGN(TASK_SIZE / 3))
47#endif
48
49#ifdef __mips64
50/*
51 * User space process size: 1TB. This is hardcoded into a few places,
52 * so don't change it unless you know what you are doing.  TASK_SIZE
53 * is limited to 1TB by the R4000 architecture; R10000 and better can
54 * support 16TB; the architectural reserve for future expansion is
55 * 8192EB ...
56 */
57#define TASK_SIZE32     0x7fff8000UL
58#define TASK_SIZE       0x10000000000UL
59
60/*
61 * This decides where the kernel will search for a free chunk of vm
62 * space during mmap's.
63 */
64#define TASK_UNMAPPED_BASE      ((current->thread.mflags & MF_32BIT_ADDR) ? \
65        PAGE_ALIGN(TASK_SIZE32 / 3) : PAGE_ALIGN(TASK_SIZE / 3))
66#endif
67
68#define NUM_FPU_REGS    32
69
70typedef __u64 fpureg_t;
71
72struct mips_fpu_hard_struct {
73        fpureg_t        fpr[NUM_FPU_REGS];
74        unsigned int    fcr31;
75};
76
77/*
78 * It would be nice to add some more fields for emulator statistics, but there
79 * are a number of fixed offsets in offset.h and elsewhere that would have to
80 * be recalculated by hand.  So the additional information will be private to
81 * the FPU emulator for now.  See asm-mips/fpu_emulator.h.
82 */
83
84struct mips_fpu_soft_struct {
85        fpureg_t        fpr[NUM_FPU_REGS];
86        unsigned int    fcr31;
87};
88
89union mips_fpu_union {
90        struct mips_fpu_hard_struct hard;
91        struct mips_fpu_soft_struct soft;
92};
93
94#define INIT_FPU { \
95        {{0,},} \
96}
97
98typedef struct {
99        unsigned long seg;
100} mm_segment_t;
101
102#define ARCH_MIN_TASKALIGN      8
103
104/*
105 * If you change thread_struct remember to change the #defines below too!
106 */
107struct thread_struct {
108        /* Saved main processor registers. */
109        unsigned long reg16;
110        unsigned long reg17, reg18, reg19, reg20, reg21, reg22, reg23;
111        unsigned long reg29, reg30, reg31;
112
113        /* Saved cp0 stuff. */
114        unsigned long cp0_status;
115
116        /* Saved fpu/fpu emulator stuff. */
117        union mips_fpu_union fpu;
118
119        /* Other stuff associated with the thread. */
120        unsigned long cp0_badvaddr;     /* Last user fault */
121        unsigned long cp0_baduaddr;     /* Last kernel fault accessing USEG */
122        unsigned long error_code;
123        unsigned long trap_no;
124#define MF_FIXADE       1               /* Fix address errors in software */
125#define MF_LOGADE       2               /* Log address errors to syslog */
126#define MF_32BIT_REGS   4               /* also implies 16/32 fprs */
127#define MF_32BIT_ADDR   8               /* 32-bit address space (o32/n32) */
128        unsigned long mflags;
129        unsigned long irix_trampoline;  /* Wheee... */
130        unsigned long irix_oldctx;
131};
132
133#define MF_ABI_MASK     (MF_32BIT_REGS | MF_32BIT_ADDR)
134#define MF_O32          (MF_32BIT_REGS | MF_32BIT_ADDR)
135#define MF_N32          MF_32BIT_ADDR
136#define MF_N64          0
137
138#define INIT_THREAD  { \
139        /* \
140         * saved main processor registers \
141         */ \
142        0, 0, 0, 0, 0, 0, 0, 0, \
143                       0, 0, 0, \
144        /* \
145         * saved cp0 stuff \
146         */ \
147        0, \
148        /* \
149         * saved fpu/fpu emulator stuff \
150         */ \
151        INIT_FPU, \
152        /* \
153         * Other stuff associated with the process \
154         */ \
155        0, 0, 0, 0, \
156        /* \
157         * For now the default is to fix address errors \
158         */ \
159        MF_FIXADE, 0, 0 \
160}
161
162struct task_struct;
163
164/* Free all resources held by a thread. */
165#define release_thread(thread) do { } while(0)
166
167/* Prepare to copy thread state - unlazy all lazy status */
168#define prepare_to_copy(tsk)    do { } while (0)
169
170extern long kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
171
172extern unsigned long thread_saved_pc(struct task_struct *tsk);
173
174/*
175 * Do necessary setup to start up a newly executed thread.
176 */
177extern void start_thread(struct pt_regs * regs, unsigned long pc, unsigned long sp);
178
179unsigned long get_wchan(struct task_struct *p);
180
181#define __PT_REG(reg) ((long)&((struct pt_regs *)0)->reg - sizeof(struct pt_regs))
182#define __KSTK_TOS(tsk) ((unsigned long)(tsk->thread_info) + THREAD_SIZE - 32)
183#define KSTK_EIP(tsk) (*(unsigned long *)(__KSTK_TOS(tsk) + __PT_REG(cp0_epc)))
184#define KSTK_ESP(tsk) (*(unsigned long *)(__KSTK_TOS(tsk) + __PT_REG(regs[29])))
185#define KSTK_STATUS(tsk) (*(unsigned long *)(__KSTK_TOS(tsk) + __PT_REG(cp0_status)))
186
187#define cpu_relax()     barrier()
188
189/*
190 * Return_address is a replacement for __builtin_return_address(count)
191 * which on certain architectures cannot reasonably be implemented in GCC
192 * (MIPS, Alpha) or is unuseable with -fomit-frame-pointer (i386).
193 * Note that __builtin_return_address(x>=1) is forbidden because GCC
194 * aborts compilation on some CPUs.  It's simply not possible to unwind
195 * some CPU's stackframes.
196 *
197 * __builtin_return_address works only for non-leaf functions.  We avoid the
198 * overhead of a function call by forcing the compiler to save the return
199 * address register on the stack.
200 */
201#define return_address() ({__asm__ __volatile__("":::"$31");__builtin_return_address(0);})
202
203#ifdef CONFIG_CPU_HAS_PREFETCH
204
205#define ARCH_HAS_PREFETCH
206
207extern inline void prefetch(const void *addr)
208{
209        __asm__ __volatile__(
210        "       .set    mips4           \n"
211        "       pref    %0, (%1)        \n"
212        "       .set    mips0           \n"
213        :
214        : "i" (Pref_Load), "r" (addr));
215}
216
217#endif
218
219#endif /* _ASM_PROCESSOR_H */
Note: See TracBrowser for help on using the repository browser.