15 #include <linux/kernel.h>
16 #include <linux/types.h>
48 #define IMM_MASK 0xffff
50 #define JIMM_MASK 0x3ffffff
52 #define FUNC_MASK 0x3f
56 #define SCIMM_MASK 0xfffff
81 #define M(a, b, c, d, e, f) \
189 WARN(arg > 0x7fff || arg < -0x8000,
204 WARN(arg > 0x1ffff || arg < -0x20000,
209 return ((arg < 0) ? (1 << 15) : 0) | ((arg >> 2) & 0x7fff);
254 if (insn_table[i].
opcode == opc) {
259 if (!ip || (opc ==
insn_daddiu && r4k_daddiu_bug()))
260 panic(
"Unsupported Micro-assembler instruction %d", opc);
292 #define I_u1u2u3(op) \
295 build_insn(buf, insn##op, a, b, c); \
297 UASM_EXPORT_SYMBOL(uasm_i##op);
299 #define I_u2u1u3(op) \
302 build_insn(buf, insn##op, b, a, c); \
304 UASM_EXPORT_SYMBOL(uasm_i##op);
306 #define I_u3u1u2(op) \
309 build_insn(buf, insn##op, b, c, a); \
311 UASM_EXPORT_SYMBOL(uasm_i##op);
313 #define I_u1u2s3(op) \
316 build_insn(buf, insn##op, a, b, c); \
318 UASM_EXPORT_SYMBOL(uasm_i##op);
320 #define I_u2s3u1(op) \
323 build_insn(buf, insn##op, c, a, b); \
325 UASM_EXPORT_SYMBOL(uasm_i##op);
327 #define I_u2u1s3(op) \
330 build_insn(buf, insn##op, b, a, c); \
332 UASM_EXPORT_SYMBOL(uasm_i##op);
334 #define I_u2u1msbu3(op) \
337 build_insn(buf, insn##op, b, a, c+d-1, c); \
339 UASM_EXPORT_SYMBOL(uasm_i##op);
341 #define I_u2u1msb32u3(op) \
344 build_insn(buf, insn##op, b, a, c+d-33, c); \
346 UASM_EXPORT_SYMBOL(uasm_i##op);
348 #define I_u2u1msbdu3(op) \
351 build_insn(buf, insn##op, b, a, d-1, c); \
353 UASM_EXPORT_SYMBOL(uasm_i##op);
358 build_insn(buf, insn##op, a, b); \
360 UASM_EXPORT_SYMBOL(uasm_i##op);
365 build_insn(buf, insn##op, a, b); \
367 UASM_EXPORT_SYMBOL(uasm_i##op);
372 build_insn(buf, insn##op, a); \
374 UASM_EXPORT_SYMBOL(uasm_i##op);
379 build_insn(buf, insn##op); \
381 UASM_EXPORT_SYMBOL(uasm_i##op);
446 #ifdef CONFIG_CPU_CAVIUM_OCTEON
478 return (((addr) & 0xffffffff00000000L) == 0xffffffff00000000L);
488 return ((((val + 0x800080008000L) >> 48) & 0xffff) ^ 0x8000) - 0x8000;
494 static int __uasminit uasm_rel_higher(
long val)
497 return ((((val + 0x80008000L) >> 32) & 0xffff) ^ 0x8000) - 0x8000;
505 return ((((val + 0x8000L) >> 16) & 0xffff) ^ 0x8000) - 0x8000;
511 return ((val & 0xffff) ^ 0x8000) - 0x8000;
518 uasm_i_lui(buf, rs, uasm_rel_highest(addr));
519 if (uasm_rel_higher(addr))
520 uasm_i_daddiu(buf, rs, rs, uasm_rel_higher(addr));
522 uasm_i_dsll(buf, rs, rs, 16);
524 uasm_i_dsll(buf, rs, rs, 16);
526 uasm_i_dsll32(buf, rs, rs, 0);
563 *rel->
addr |= build_bimm(laddr - (
raddr + 4));
567 panic(
"Unsupported Micro-assembler relocation %d",
580 __resolve_relocs(rel, l);
588 if (rel->
addr >= first && rel->
addr < end)
597 if (lab->
addr >= first && lab->
addr < end)
606 long off = (
long)(target - first);
608 memcpy(target, first, (end - first) *
sizeof(
u32));
618 if (rel->
addr == addr
633 uasm_i_bltz(p, reg, 0);
666 uasm_i_bne(p, reg1, reg2, 0);
682 uasm_i_bgezl(p, reg, 0);
690 uasm_i_bgez(p, reg, 0);
696 unsigned int bit,
int lid)
699 uasm_i_bbit0(p, reg, bit, 0);
705 unsigned int bit,
int lid)
708 uasm_i_bbit1(p, reg, bit, 0);