RT-AC66 3.0.0.4.374.130 core
[tomato.git] / release / src-rt-6.x / linux / linux-2.6 / include / asm-mips / uasm.h
blobbf14a4be426815282a6c61d820dd6a07fd7ad62a
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.
6 * Copyright (C) 2004, 2005, 2006, 2008 Thiemo Seufer
7 * Copyright (C) 2005 Maciej W. Rozycki
8 * Copyright (C) 2006 Ralf Baechle (ralf@linux-mips.org)
9 */
11 #include <linux/types.h>
14 enum opcode {
15 insn_invalid,
16 insn_addu, insn_addiu, insn_and, insn_andi, insn_beq,
17 insn_beql, insn_bgez, insn_bgezl, insn_bltz, insn_bltzl,
18 insn_bne, insn_daddu, insn_daddiu, insn_dmfc0, insn_dmtc0,
19 insn_dsll, insn_dsll32, insn_dsra, insn_dsrl, insn_dsrl32,
20 insn_dsubu, insn_eret, insn_j, insn_jal, insn_jr, insn_ld,
21 insn_ll, insn_lld, insn_lui, insn_lw, insn_mfc0, insn_mtc0,
22 insn_or, insn_ori, insn_rfe, insn_sc, insn_scd, insn_sd, insn_sll,
23 insn_sra, insn_srl, insn_subu, insn_sw, insn_tlbp, insn_tlbwi,
24 insn_tlbwr, insn_xor, insn_xori,
25 insn_syscall
28 void __cpuinit build_insn(u32 **buf, enum opcode opc, ...);
30 #define I_u1u2u3(op) \
31 static inline void __cpuinit i##op(u32 **buf, unsigned int a, \
32 unsigned int b, unsigned int c) \
33 { \
34 build_insn(buf, insn##op, a, b, c); \
37 #define I_u2u1u3(op) \
38 static inline void __cpuinit i##op(u32 **buf, unsigned int a, \
39 unsigned int b, unsigned int c) \
40 { \
41 build_insn(buf, insn##op, b, a, c); \
44 #define I_u3u1u2(op) \
45 static inline void __cpuinit i##op(u32 **buf, unsigned int a, \
46 unsigned int b, unsigned int c) \
47 { \
48 build_insn(buf, insn##op, b, c, a); \
51 #define I_u1u2s3(op) \
52 static inline void __cpuinit i##op(u32 **buf, unsigned int a, \
53 unsigned int b, signed int c) \
54 { \
55 build_insn(buf, insn##op, a, b, c); \
58 #define I_u2s3u1(op) \
59 static inline void __cpuinit i##op(u32 **buf, unsigned int a, \
60 signed int b, unsigned int c) \
61 { \
62 build_insn(buf, insn##op, c, a, b); \
65 #define I_u2u1s3(op) \
66 static inline void __cpuinit i##op(u32 **buf, unsigned int a, \
67 unsigned int b, signed int c) \
68 { \
69 build_insn(buf, insn##op, b, a, c); \
72 #define I_u1u2(op) \
73 static inline void __cpuinit i##op(u32 **buf, unsigned int a, \
74 unsigned int b) \
75 { \
76 build_insn(buf, insn##op, a, b); \
79 #define I_u1s2(op) \
80 static inline void __cpuinit i##op(u32 **buf, unsigned int a, \
81 signed int b) \
82 { \
83 build_insn(buf, insn##op, a, b); \
86 #define I_u1(op) \
87 static inline void __cpuinit i##op(u32 **buf, unsigned int a) \
88 { \
89 build_insn(buf, insn##op, a); \
92 #define I_0(op) \
93 static inline void __cpuinit i##op(u32 **buf) \
94 { \
95 build_insn(buf, insn##op); \
98 I_u2u1s3(_addiu);
99 I_u3u1u2(_addu);
100 I_u2u1u3(_andi);
101 I_u3u1u2(_and);
102 I_u1u2s3(_beq);
103 I_u1u2s3(_beql);
104 I_u1s2(_bgez);
105 I_u1s2(_bgezl);
106 I_u1s2(_bltz);
107 I_u1s2(_bltzl);
108 I_u1u2s3(_bne);
109 I_u1u2u3(_dmfc0);
110 I_u1u2u3(_dmtc0);
111 I_u2u1s3(_daddiu);
112 I_u3u1u2(_daddu);
113 I_u2u1u3(_dsll);
114 I_u2u1u3(_dsll32);
115 I_u2u1u3(_dsra);
116 I_u2u1u3(_dsrl);
117 I_u2u1u3(_dsrl32);
118 I_u3u1u2(_dsubu);
119 I_0(_eret);
120 I_u1(_j);
121 I_u1(_jal);
122 I_u1(_jr);
123 I_u2s3u1(_ld);
124 I_u2s3u1(_ll);
125 I_u2s3u1(_lld);
126 I_u1s2(_lui);
127 I_u2s3u1(_lw);
128 I_u1u2u3(_mfc0);
129 I_u1u2u3(_mtc0);
130 I_u2u1u3(_ori);
131 I_u3u1u2(_or)
132 I_0(_rfe);
133 I_u2s3u1(_sc);
134 I_u2s3u1(_scd);
135 I_u2s3u1(_sd);
136 I_u2u1u3(_sll);
137 I_u2u1u3(_sra);
138 I_u2u1u3(_srl);
139 I_u3u1u2(_subu);
140 I_u2s3u1(_sw);
141 I_0(_tlbp);
142 I_0(_tlbwi);
143 I_0(_tlbwr);
144 I_u3u1u2(_xor)
145 I_u2u1u3(_xori);
146 I_u1(_syscall);
149 * handling labels
152 enum label_id {
153 label_invalid,
154 label_second_part,
155 label_leave,
156 #ifdef MODULE_START
157 label_module_alloc,
158 #endif
159 label_vmalloc,
160 label_vmalloc_done,
161 label_tlbw_hazard,
162 label_split,
163 label_nopage_tlbl,
164 label_nopage_tlbs,
165 label_nopage_tlbm,
166 label_smp_pgtable_change,
167 label_r3000_write_probe_fail,
170 struct label {
171 u32 *addr;
172 enum label_id lab;
175 static __cpuinit void build_label(struct label **lab, u32 *addr,
176 enum label_id l)
178 (*lab)->addr = addr;
179 (*lab)->lab = l;
180 (*lab)++;
183 #define L_LA(lb) \
184 static inline void l##lb(struct label **lab, u32 *addr) \
186 build_label(lab, addr, label##lb); \
189 L_LA(_second_part)
190 L_LA(_leave)
191 #ifdef MODULE_START
192 L_LA(_module_alloc)
193 #endif
194 L_LA(_vmalloc)
195 L_LA(_vmalloc_done)
196 L_LA(_tlbw_hazard)
197 L_LA(_split)
198 L_LA(_nopage_tlbl)
199 L_LA(_nopage_tlbs)
200 L_LA(_nopage_tlbm)
201 L_LA(_smp_pgtable_change)
202 L_LA(_r3000_write_probe_fail)
204 /* convenience macros for instructions */
205 #ifdef CONFIG_64BIT
206 # define i_LW(buf, rs, rt, off) i_ld(buf, rs, rt, off)
207 # define i_SW(buf, rs, rt, off) i_sd(buf, rs, rt, off)
208 # define i_SLL(buf, rs, rt, sh) i_dsll(buf, rs, rt, sh)
209 # define i_SRA(buf, rs, rt, sh) i_dsra(buf, rs, rt, sh)
210 # define i_SRL(buf, rs, rt, sh) i_dsrl(buf, rs, rt, sh)
211 # define i_MFC0(buf, rt, rd...) i_dmfc0(buf, rt, rd)
212 # define i_MTC0(buf, rt, rd...) i_dmtc0(buf, rt, rd)
213 # define i_ADDIU(buf, rs, rt, val) i_daddiu(buf, rs, rt, val)
214 # define i_ADDU(buf, rs, rt, rd) i_daddu(buf, rs, rt, rd)
215 # define i_SUBU(buf, rs, rt, rd) i_dsubu(buf, rs, rt, rd)
216 # define i_LL(buf, rs, rt, off) i_lld(buf, rs, rt, off)
217 # define i_SC(buf, rs, rt, off) i_scd(buf, rs, rt, off)
218 #else
219 # define i_LW(buf, rs, rt, off) i_lw(buf, rs, rt, off)
220 # define i_SW(buf, rs, rt, off) i_sw(buf, rs, rt, off)
221 # define i_SLL(buf, rs, rt, sh) i_sll(buf, rs, rt, sh)
222 # define i_SRA(buf, rs, rt, sh) i_sra(buf, rs, rt, sh)
223 # define i_SRL(buf, rs, rt, sh) i_srl(buf, rs, rt, sh)
224 # define i_MFC0(buf, rt, rd...) i_mfc0(buf, rt, rd)
225 # define i_MTC0(buf, rt, rd...) i_mtc0(buf, rt, rd)
226 # define i_ADDIU(buf, rs, rt, val) i_addiu(buf, rs, rt, val)
227 # define i_ADDU(buf, rs, rt, rd) i_addu(buf, rs, rt, rd)
228 # define i_SUBU(buf, rs, rt, rd) i_subu(buf, rs, rt, rd)
229 # define i_LL(buf, rs, rt, off) i_ll(buf, rs, rt, off)
230 # define i_SC(buf, rs, rt, off) i_sc(buf, rs, rt, off)
231 #endif
233 #define i_b(buf, off) i_beq(buf, 0, 0, off)
234 #define i_beqz(buf, rs, off) i_beq(buf, rs, 0, off)
235 #define i_beqzl(buf, rs, off) i_beql(buf, rs, 0, off)
236 #define i_bnez(buf, rs, off) i_bne(buf, rs, 0, off)
237 #define i_bnezl(buf, rs, off) i_bnel(buf, rs, 0, off)
238 #define i_move(buf, a, b) i_ADDU(buf, a, 0, b)
239 #define i_nop(buf) i_sll(buf, 0, 0, 0)
240 #define i_ssnop(buf) i_sll(buf, 0, 0, 1)
241 #define i_ehb(buf) i_sll(buf, 0, 0, 3)