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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rc203soc/] [sw/] [uClinux/] [include/] [asm-mips/] [asm.h] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1633 jcastillo
/*
2
 * include/asm-mips/asm.h
3
 *
4
 * This file is subject to the terms and conditions of the GNU General Public
5
 * License.  See the file "COPYING" in the main directory of this archive
6
 * for more details.
7
 *
8
 * Copyright (C) 1995 by Ralf Baechle
9
 *
10
 * Some useful macros for MIPS assembler code
11
 *
12
 * Some of the routines below contain useless nops that will be optimized
13
 * away by gas in -O mode. These nops are however required to fill delay
14
 * slots in noreorder mode.
15
 */
16
#ifndef __ASM_ASM_H
17
#define __ASM_ASM_H
18
 
19
#include <linux/config.h>
20
#include <asm/regdef.h>
21
#include <asm/fpregdef.h>
22
 
23
#ifndef CAT
24
#ifdef __STDC__
25
#define __CAT(str1,str2) str1##str2
26
#else
27
#define __CAT(str1,str2) str1/**/str2
28
#endif
29
#define CAT(str1,str2) __CAT(str1,str2)
30
#endif
31
 
32
/*
33
 * Macros to handle different pointer sizes for 32/64-bit code
34
 */
35
#if __mips == 3
36
#define PTR     .quad
37
#define PTRSIZE 8
38
#define PTRLOG  3
39
#define lp      ld
40
#else
41
#define PTR     .word
42
#define PTRSIZE 4
43
#define PTRLOG  2
44
#define lp      lw
45
#endif
46
 
47
/*
48
 * ELF specific declarations
49
 */
50
#ifdef __ELF__
51
#define TYPE(symbol,_type)                              \
52
                        .type   symbol,@_type
53
#define SIZE(symbol,_size)                              \
54
                        .size   symbol,_size
55
#else
56
#define TYPE(symbol,type)
57
#define SIZE(symbol,size)
58
#endif
59
 
60
/*
61
 * PIC specific declarations
62
 * Not used for the kernel but here seems to be the right place.
63
 */
64
#ifdef __PIC__
65
#define CPRESTORE(register)                             \
66
                        .cprestore register
67
#define CPADD(register)                                 \
68
                        .cpadd  register
69
#define CPLOAD(register)                                \
70
                        .cpload register
71
#else
72
#define CPRESTORE(register)
73
#define CPADD(register)
74
#define CPLOAD(register)
75
#endif
76
 
77
/*
78
 * LEAF - declare leaf routine
79
 */
80
#define LEAF(symbol)                                    \
81
                        .globl  symbol;                 \
82
                        .align  2;                      \
83
                        TYPE(symbol,function);          \
84
                        .ent    symbol,0;               \
85
symbol:                 .frame  sp,0,ra
86
 
87
/*
88
 * NESTED - declare nested routine entry point
89
 */
90
#define NESTED(symbol, framesize, rpc)                  \
91
                        .globl  symbol;                 \
92
                        .align  2;                      \
93
                        TYPE(symbol,function);          \
94
                        .ent    symbol,0;               \
95
symbol:                 .frame  sp, framesize, rpc
96
 
97
/*
98
 * END - mark end of function
99
 */
100
#define END(function)                                   \
101
                        .end    function;               \
102
                        SIZE(function,.-function)
103
 
104
/*
105
 * EXPORT - export definition of symbol
106
 */
107
#define EXPORT(symbol)                                  \
108
                        .globl  symbol;                 \
109
symbol:
110
 
111
/*
112
 * ABS - export absolute symbol
113
 */
114
#define ABS(symbol,value)                               \
115
                        .globl  symbol;                 \
116
symbol                  =       value
117
 
118
#define PANIC(msg)                                      \
119
                        la      a0,8f;                  \
120
                        jal     panic;                  \
121
                        nop;                            \
122
9:                      b       9b;                     \
123
                        nop;                            \
124
                        TEXT(msg)
125
 
126
/*
127
 * Print formated string
128
 */
129
#define PRINT(string)                                   \
130
                        la      a0,8f;                  \
131
                        jal     printk;                 \
132
                        nop;                            \
133
                        TEXT(string)
134
 
135
#define TEXT(msg)                                       \
136
                        .data;                          \
137
8:                      .asciiz msg;                    \
138
                        .text
139
 
140
/*
141
 * Build text tables
142
 */
143
#define TTABLE(string)                                  \
144
                .text;                                  \
145
                .word   1f;                             \
146
                .data;                                  \
147
1:              .asciz  string;                         \
148
                .text;
149
 
150
/*
151
 * Move to kernel mode and disable interrupts
152
 * Set cp0 enable bit as sign that we're running on the kernel stack
153
 * Use with .set noat!
154
 * Note that the mtc0 will be effective on R4000 pipeline stage 7. This
155
 * means that another three instructions will be executed with interrupts
156
 * disabled.
157
 */
158
#define CLI                                             \
159
                mfc0    AT,CP0_STATUS;                  \
160
                li      t0,ST0_CU0|0x1f;                \
161
                or      AT,t0;                          \
162
                xori    AT,0x1f;                        \
163
                mtc0    AT,CP0_STATUS;                  \
164
 
165
/*
166
 * Move to kernel mode and enable interrupts
167
 * Set cp0 enable bit as sign that we're running on the kernel stack
168
 * Use with .set noat!
169
 * Note that the mtc0 will be effective on R4000 pipeline stage 7. This
170
 * means that another three instructions will be executed with interrupts
171
 * disabled.  Arch/mips/kernel/r4xx0.S makes use of this fact.
172
 */
173
#define STI                                             \
174
                mfc0    AT,CP0_STATUS;                  \
175
                li      t0,ST0_CU0|0x1f;                \
176
                or      AT,t0;                          \
177
                xori    AT,0x1e;                        \
178
                mtc0    AT,CP0_STATUS;                  \
179
 
180
/*
181
 * Special nop to fill load delay slots
182
 */
183
#ifndef __R4000__
184
#define NOP     nop
185
#else
186
#define NOP
187
#endif
188
 
189
/*
190
 * Return from exception
191
 */
192
#if defined (CONFIG_CPU_R3000)
193
#define ERET rfe
194
#elif defined (CONFIG_CPU_R4X00) || defined (CONFIG_CPU_R4600)
195
#define ERET                                            \
196
                .set    mips3;                          \
197
                eret;                                   \
198
                .set    mips0
199
#else
200
#error "Implement ERET macro!"
201
#endif
202
 
203
/*
204
 * R8000/R10000 (MIPS ISA IV) pref instruction.
205
 * Use with .set noreorder only!
206
 */
207
#if defined (CONFIG_CPU_R8000) || defined(CONFIG_CPU_R10000)
208
#define PREF(hint,addr)                                 \
209
                pref    hint,addr
210
#define PREFX(hint,addr)                                \
211
                prefx   hint,addr
212
#else
213
#define PREF
214
#define PREFX
215
#endif
216
 
217
/*
218
 * R8000/R10000 (MIPS ISA IV) movn/movz instructions and
219
 * equivalents for old CPUs. Use with .set noreorder only!
220
 */
221
#if defined (CONFIG_CPU_R8000) || defined (CONFIG_CPU_R10000)
222
#define MOVN(rd,rs,rt)                                  \
223
                movn    rd,rs,rt
224
#define MOVZ(rd,rs,rt)                                  \
225
                movz    rd,rs,rt
226
#elif defined (CONFIG_CPU_R4000) || defined (CONFIG_CPU_R6000)
227
#define MOVN(rd,rs,rt)                                  \
228
                bnezl   rt,9f                           \
229
                move    rd,rs                           \
230
9:
231
#define MOVZ(rd,rs,rt)                                  \
232
                beqzl   rt,9f                           \
233
                movz    rd,rt                           \
234
9:
235
#else /* R2000, R3000 */
236
#define MOVN(rd,rs,rt)                                  \
237
                beqz    rt,9f                           \
238
                nop                                     \
239
                move    rd,rs                           \
240
9:
241
#define MOVZ(rd,rs,rt)                                  \
242
                bneqz   rt,9f                           \
243
                nop                                     \
244
                movz    rd,rt                           \
245
9:
246
#endif
247
 
248
#endif /* __ASM_ASM_H */

powered by: WebSVN 2.1.0

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