void mips_disasm(unsigned int buf, unsigned int ip, volatile struct mips_inst_t *inst) { struct mips_inst_info_t *current_table; /* We start with the first table mips_asm_table, with the * opcode field as argument */ current_table = mips_asm_table; int current_table_low = 26; int current_table_high = 31; unsigned int mips_table_arg; int loop_iteration = 0; inst->addr = ip; inst->dword.bytes = (unsigned int)(buf); mips_table_arg = BITS32(inst->dword.bytes, current_table_high, current_table_low); /* Find next tables if the instruction belongs to another table */ while (1) { if (current_table[mips_table_arg].next_table && loop_iteration < 4) { current_table_high = current_table[mips_table_arg].next_table_high; current_table_low = current_table[mips_table_arg].next_table_low; current_table = current_table[mips_table_arg].next_table; mips_table_arg = BITS32(inst->dword.bytes, current_table_high, current_table_low); loop_iteration++; } else if (loop_iteration > 4) { fatal("Cannot find the correct table containing the instruction\n"); } else break; } inst->info = ¤t_table[mips_table_arg]; }
void hw_qspi_set_wrapping_burst_instruction(uint8_t inst, HW_QSPI_WRAP_LEN len, HW_QSPI_WRAP_SIZE size) { HW_QSPIC_REG_SETF(BURSTCMDA, INST_WB, inst); QSPIC->QSPIC_BURSTCMDB_REG = (QSPIC->QSPIC_BURSTCMDB_REG & ~(REG_MSK(QSPIC, QSPIC_BURSTCMDB_REG, QSPIC_WRAP_SIZE) | REG_MSK(QSPIC, QSPIC_BURSTCMDB_REG, QSPIC_WRAP_LEN))) | BITS32(QSPIC, QSPIC_BURSTCMDB_REG, QSPIC_WRAP_SIZE, size) | BITS32(QSPIC, QSPIC_BURSTCMDB_REG, QSPIC_WRAP_LEN, len) | BITS32(QSPIC, QSPIC_BURSTCMDB_REG, QSPIC_WRAP_MD, 1); }
void dump_dump_page_v8(char *s, void *dpp) { dump_page_t *dp; uint32_t flags; int others; console(s); dp = (dump_page_t *)dpp; others = 0; console(BITS32() ? "dp_address: %llx " : "dp_address: %lx ", dp->dp_address); console("dp_size: %ld ", dp->dp_size); console("dp_flags: %lx (", flags = dp->dp_flags); if (flags & DUMP_DH_COMPRESSED) console("DUMP_DH_COMPRESSED", others++); if (flags & DUMP_DH_RAW) console("%sDUMP_DH_RAW", others++ ? "|" : ""); if (flags & DUMP_DH_END) console("%sDUMP_DH_END", others++ ? "|" : ""); if (flags & LKCD_DUMP_MCLX_V0) console("%sLKCD_DUMP_MCLX_V0", others++ ? "|" : ""); console(")\n"); }
void mips_isa_JAL_impl(struct mips_ctx_t *ctx) { unsigned int reg_no = 31; unsigned int value = ctx->regs->pc + 8; unsigned int dest = (BITS32(ctx->regs->pc + 4, 31, 28) << 28) | (TARGET << 2); // mips_gpr_set_value(ctx,31, ctx->regs->pc + 8); mips_gpr_set_value(ctx, reg_no, value); mips_isa_branch(ctx, dest); }
void mips_isa_LW_impl(struct mips_ctx_t *ctx) { unsigned int temp; unsigned int addr = mips_gpr_get_value(ctx,RS) + SEXT32((signed)IMM,16); if ((BITS32(addr, 1, 0) | 0) == 1 ) fatal("LW: address error, effective address must be naturallty-aligned\n"); mem_read(ctx->mem, addr, 4, &temp); mips_gpr_set_value(ctx,RT, temp); mips_isa_inst_debug(" $0x%x=>tmp0, tmp0+r%d=>tmp0, tmp0=>r%d\n", SEXT32(IMM,16), RS, RT); mips_isa_inst_debug(" value loaded: %x", temp); }
void hw_qspi_set_dummy_bytes_count(uint8_t count) { if (count == 3) { HW_QSPIC_REG_SETF(BURSTCMDB, DMY_FORCE, 1); } else { QSPIC->QSPIC_BURSTCMDB_REG = (QSPIC->QSPIC_BURSTCMDB_REG & ~(REG_MSK(QSPIC, QSPIC_BURSTCMDB_REG, QSPIC_DMY_FORCE) | REG_MSK(QSPIC, QSPIC_BURSTCMDB_REG, QSPIC_DMY_NUM))) | BITS32(QSPIC, QSPIC_BURSTCMDB_REG, QSPIC_DMY_NUM, dummy_num[count]); } }
/* * help -S output, or as specified by arg. */ void dump_lkcd_environment_v8(ulong arg) { int others; dump_header_t *dh; dump_page_t *dp; struct timeval tv; dh = (dump_header_t *)lkcd->dump_header; dp = (dump_page_t *)lkcd->dump_page; if (arg == LKCD_DUMP_HEADER_ONLY) goto dump_header_only; if (arg == LKCD_DUMP_PAGE_ONLY) goto dump_page_only; dump_header_only: lkcd_print(" dump_header:\n"); lkcd_print(" dh_magic_number: "); lkcd_print(BITS32() ? "%llx " : "%lx ", dh->dh_magic_number); if (dh->dh_magic_number == DUMP_MAGIC_NUMBER) lkcd_print("(DUMP_MAGIC_NUMBER)\n"); else if (dh->dh_magic_number == DUMP_MAGIC_LIVE) lkcd_print("(DUMP_MAGIC_LIVE)\n"); else lkcd_print("(?)\n"); others = 0; lkcd_print(" dh_version: "); lkcd_print(BITS32() ? "%lx (" : "%x (", dh->dh_version); switch (dh->dh_version & LKCD_DUMP_VERSION_NUMBER_MASK) { case LKCD_DUMP_V1: lkcd_print("%sLKCD_DUMP_V1", others++ ? "|" : ""); break; case LKCD_DUMP_V2: lkcd_print("%sLKCD_DUMP_V2", others++ ? "|" : ""); break; case LKCD_DUMP_V3: lkcd_print("%sLKCD_DUMP_V3", others++ ? "|" : ""); break; case LKCD_DUMP_V5: lkcd_print("%sLKCD_DUMP_V5", others++ ? "|" : ""); break; case LKCD_DUMP_V7: lkcd_print("%sLKCD_DUMP_V7", others++ ? "|" : ""); break; case LKCD_DUMP_V8: lkcd_print("%sLKCD_DUMP_V8", others++ ? "|" : ""); break; case LKCD_DUMP_V9: lkcd_print("%sLKCD_DUMP_V9", others++ ? "|" : ""); break; } if (dh->dh_version & LKCD_DUMP_MCLX_V0) lkcd_print("%sLKCD_DUMP_MCLX_V0", others++ ? "|" : ""); if (dh->dh_version & LKCD_DUMP_MCLX_V1) lkcd_print("%sLKCD_DUMP_MCLX_V1", others++ ? "|" : ""); lkcd_print(")\n"); lkcd_print(" dh_header_size: "); lkcd_print(BITS32() ? "%ld\n" : "%d\n", dh->dh_header_size); lkcd_print(" dh_dump_level: "); lkcd_print(BITS32() ? "%lx (" : "%x (", dh->dh_dump_level); others = 0; if (dh->dh_dump_level & DUMP_LEVEL_HEADER) lkcd_print("%sDUMP_LEVEL_HEADER", others++ ? "|" : ""); if (dh->dh_dump_level & DUMP_LEVEL_KERN) lkcd_print("%sDUMP_LEVEL_KERN", others++ ? "|" : ""); if (dh->dh_dump_level & DUMP_LEVEL_USED) lkcd_print("%sDUMP_LEVEL_USED", others++ ? "|" : ""); if (dh->dh_dump_level & DUMP_LEVEL_ALL) lkcd_print("%sDUMP_LEVEL_ALL", others++ ? "|" : ""); lkcd_print(")\n"); lkcd_print(" dh_page_size: "); lkcd_print(BITS32() ? "%ld\n" : "%d\n", dh->dh_page_size); lkcd_print(" dh_memory_size: "); lkcd_print(BITS32() ? "%lld\n" : "%ld\n", dh->dh_memory_size); lkcd_print(" dh_memory_start: "); lkcd_print(BITS32() ? "%llx\n" : "%lx\n", dh->dh_memory_start); lkcd_print(" dh_memory_end: "); lkcd_print(BITS32() ? "%llx\n" : "%lx\n", dh->dh_memory_end); lkcd_print(" dh_num_pages: "); lkcd_print(BITS32() ? "%ld\n" : "%d\n", dh->dh_num_pages); lkcd_print(" dh_panic_string: %s%s", dh->dh_panic_string, dh && dh->dh_panic_string && strstr(dh->dh_panic_string, "\n") ? "" : "\n"); tv.tv_sec = dh->dh_time.tv_sec; lkcd_print(" dh_time: %s\n", strip_linefeeds(ctime(&(tv.tv_sec)))); lkcd_print("dh_utsname_sysname: %s\n", dh->dh_utsname_sysname); lkcd_print("dh_utsname_nodename: %s\n", dh->dh_utsname_nodename); lkcd_print("dh_utsname_release: %s\n", dh->dh_utsname_release); lkcd_print("dh_utsname_version: %s\n", dh->dh_utsname_version); lkcd_print("dh_utsname_machine: %s\n", dh->dh_utsname_machine); lkcd_print("dh_utsname_domainname: %s\n", dh->dh_utsname_domainname); lkcd_print(" dh_current_task: %lx\n", dh->dh_current_task); lkcd_print(" dh_dump_compress: "); lkcd_print(BITS32() ? "%lx (" : "%x (", dh->dh_dump_compress); others = 0; if (dh->dh_dump_compress == DUMP_COMPRESS_NONE) lkcd_print("%sDUMP_COMPRESS_NONE", others++ ? "|" : ""); if (dh->dh_dump_compress & DUMP_COMPRESS_RLE) lkcd_print("%sDUMP_COMPRESS_RLE", others++ ? "|" : ""); if (dh->dh_dump_compress & DUMP_COMPRESS_GZIP) lkcd_print("%sDUMP_COMPRESS_GZIP", others++ ? "|" : ""); lkcd_print(")\n"); lkcd_print(" dh_dump_flags: "); others = 0; lkcd_print(BITS32() ? "%lx (" : "%x (", dh->dh_dump_flags); if (dh->dh_dump_flags & DUMP_FLAGS_NONDISRUPT) lkcd_print("%sDUMP_FLAGS_NONDISRUPT", others++ ? "|" : ""); lkcd_print(")\n"); lkcd_print(" dh_dump_device: "); lkcd_print(BITS32() ? "%lx\n" : "%x\n", dh->dh_dump_device); if (arg == LKCD_DUMP_HEADER_ONLY) return; dump_page_only: lkcd_print(" dump_page:\n"); lkcd_print(" dp_address: "); lkcd_print(BITS32() ? "%llx\n" : "%lx\n", dp->dp_address); lkcd_print(" dp_size: "); lkcd_print(BITS32() ? "%ld\n" : "%d\n", dp->dp_size); lkcd_print(" dp_flags: "); lkcd_print(BITS32() ? "%lx (" : "%x (", dp->dp_flags); others = 0; if (dp->dp_flags & DUMP_DH_COMPRESSED) lkcd_print("DUMP_DH_COMPRESSED", others++); if (dp->dp_flags & DUMP_DH_RAW) lkcd_print("%sDUMP_DH_RAW", others++ ? "|" : ""); if (dp->dp_flags & DUMP_DH_END) lkcd_print("%sDUMP_DH_END", others++ ? "|" : ""); if (dp->dp_flags & LKCD_DUMP_MCLX_V0) lkcd_print("%sLKCD_DUMP_MCLX_V0", others++ ? "|" : ""); lkcd_print(")\n"); }
void mips_isa_J_impl(struct mips_ctx_t *ctx) { unsigned int dest; dest = BITS32(ctx->regs->pc + 4, 31, 28) << 28 | (TARGET << 2); mips_isa_branch(ctx,dest); }
/* * help -S output, or as specified by arg. */ void dump_lkcd_environment_v2_v3(ulong arg) { int others; dump_header_t *dh; dump_header_asm_t *dha; dump_page_t *dp; dh = (dump_header_t *)lkcd->dump_header; dha = (dump_header_asm_t *)lkcd->dump_header_asm; dp = (dump_page_t *)lkcd->dump_page; if (arg == LKCD_DUMP_HEADER_ONLY) goto dump_header_only; if (arg == LKCD_DUMP_PAGE_ONLY) goto dump_page_only; dump_header_only: lkcd_print(" dump_header:\n"); lkcd_print(" dh_magic_number: "); lkcd_print(BITS32() ? "%llx " : "%lx ", dh->dh_magic_number); if (dh->dh_magic_number == DUMP_MAGIC_NUMBER) lkcd_print("(DUMP_MAGIC_NUMBER)\n"); else lkcd_print("(?)\n"); others = 0; lkcd_print(" dh_version: "); lkcd_print(BITS32() ? "%lx (" : "%x (", dh->dh_version); switch (dh->dh_version & LKCD_DUMP_VERSION_NUMBER_MASK) { case LKCD_DUMP_V1: lkcd_print("%sLKCD_DUMP_V1", others++ ? "|" : ""); break; case LKCD_DUMP_V2: lkcd_print("%sLKCD_DUMP_V2", others++ ? "|" : ""); break; case LKCD_DUMP_V3: lkcd_print("%sLKCD_DUMP_V3", others++ ? "|" : ""); break; } if (dh->dh_version & LKCD_DUMP_MCLX_V0) lkcd_print("%sLKCD_DUMP_MCLX_V0", others++ ? "|" : ""); if (dh->dh_version & LKCD_DUMP_MCLX_V1) lkcd_print("%sLKCD_DUMP_MCLX_V1", others++ ? "|" : ""); lkcd_print(")\n"); lkcd_print(" dh_header_size: "); lkcd_print(BITS32() ? "%ld\n" : "%d\n", dh->dh_header_size); lkcd_print(" dh_dump_level: "); lkcd_print(BITS32() ? "%lx (" : "%x (", dh->dh_dump_level); others = 0; if (dh->dh_dump_level & DUMP_HEADER) lkcd_print("%sDUMP_HEADER", others++ ? "|" : ""); if (dh->dh_dump_level & DUMP_KERN) lkcd_print("%sDUMP_KERN", others++ ? "|" : ""); if (dh->dh_dump_level & DUMP_USED) lkcd_print("%sDUMP_USED", others++ ? "|" : ""); if (dh->dh_dump_level & DUMP_ALL) lkcd_print("%sDUMP_ALL", others++ ? "|" : ""); lkcd_print(")\n"); lkcd_print(" dh_page_size: "); lkcd_print(BITS32() ? "%ld\n" : "%d\n", dh->dh_page_size); lkcd_print(" dh_memory_size: "); lkcd_print(BITS32() ? "%lld\n" : "%ld\n", dh->dh_memory_size); lkcd_print(" dh_memory_start: "); lkcd_print(BITS32() ? "%llx\n" : "%lx\n", dh->dh_memory_start); lkcd_print(" dh_memory_end: "); lkcd_print(BITS32() ? "%llx\n" : "%lx\n", dh->dh_memory_end); lkcd_print(" dh_num_pages: "); lkcd_print(BITS32() ? "%ld\n" : "%d\n", dh->dh_num_pages); lkcd_print(" dh_panic_string: %s%s", dh->dh_panic_string, dh && dh->dh_panic_string && strstr(dh->dh_panic_string, "\n") ? "" : "\n"); lkcd_print(" dh_time: %s\n", strip_linefeeds(ctime(&(dh->dh_time.tv_sec)))); lkcd_print(" dh_utsname:\n"); lkcd_print(" sysname: %s\n", dh->dh_utsname.sysname); lkcd_print(" nodename: %s\n", dh->dh_utsname.nodename); lkcd_print(" release: %s\n", dh->dh_utsname.release); lkcd_print(" version: %s\n", dh->dh_utsname.version); lkcd_print(" machine: %s\n", dh->dh_utsname.machine); lkcd_print(" domainname: %s\n", dh->dh_utsname.domainname); lkcd_print(" dh_current_task: %lx\n", dh->dh_current_task); lkcd_print("dha_magic_number: "); lkcd_print(BITS32() ? "%llx " : "%lx ", dha->dha_magic_number); if (dha->dha_magic_number == DUMP_ASM_MAGIC_NUMBER) lkcd_print("(DUMP_ASM_MAGIC_NUMBER)\n"); else lkcd_print("(?)\n"); lkcd_print(" dha_version: "); lkcd_print(BITS32() ? "%ld\n" : "%d\n", dha->dha_version); lkcd_print(" dha_header_size: "); lkcd_print(BITS32() ? "%ld\n" : "%d\n", dha->dha_header_size); #ifdef X86 lkcd_print(" dha_esp: %lx\n", dha->dha_esp); lkcd_print(" dha_eip: %lx\n", dha->dha_eip); #endif #if defined PPC || ALPHA || IA64 /* TBD */ #endif lkcd_print(" dha_regs:\n"); #ifdef PPC lkcd_print(" (PowerPC register display TBD)\n"); #endif #ifdef IA64 lkcd_print(" (IA64 register display TBD)\n"); #endif #ifdef X86 lkcd_print(" ebx: %lx\n", dha->dha_regs.ebx); lkcd_print(" ecx: %lx\n", dha->dha_regs.ecx); lkcd_print(" edx: %lx\n", dha->dha_regs.edx); lkcd_print(" esi: %lx\n", dha->dha_regs.esi); lkcd_print(" edi: %lx\n", dha->dha_regs.edi); lkcd_print(" eax: %lx\n", dha->dha_regs.eax); lkcd_print(" xds: %x\n", dha->dha_regs.xds); lkcd_print(" xes: %x\n", dha->dha_regs.xes); lkcd_print(" orig_eax: %lx\n", dha->dha_regs.orig_eax); lkcd_print(" eip: %lx\n", dha->dha_regs.eip); lkcd_print(" xcs: %x\n", dha->dha_regs.xcs); lkcd_print(" eflags: %lx\n", dha->dha_regs.eflags); lkcd_print(" esp: %lx\n", dha->dha_regs.esp); lkcd_print(" xss: %x\n", dha->dha_regs.xss); #endif #ifdef ALPHA lkcd_print(" r0: %lx\n", dha->dha_regs.r0); lkcd_print(" r1: %lx\n", dha->dha_regs.r1); lkcd_print(" r2: %lx\n", dha->dha_regs.r2); lkcd_print(" r3: %lx\n", dha->dha_regs.r3); lkcd_print(" r4: %lx\n", dha->dha_regs.r4); lkcd_print(" r5: %lx\n", dha->dha_regs.r5); lkcd_print(" r6: %lx\n", dha->dha_regs.r6); lkcd_print(" r7: %lx\n", dha->dha_regs.r7); lkcd_print(" r8: %lx\n", dha->dha_regs.r8); lkcd_print(" r19: %lx\n", dha->dha_regs.r19); lkcd_print(" r20: %lx\n", dha->dha_regs.r20); lkcd_print(" r21: %lx\n", dha->dha_regs.r21); lkcd_print(" r22: %lx\n", dha->dha_regs.r22); lkcd_print(" r23: %lx\n", dha->dha_regs.r23); lkcd_print(" r24: %lx\n", dha->dha_regs.r24); lkcd_print(" r25: %lx\n", dha->dha_regs.r25); lkcd_print(" r26: %lx\n", dha->dha_regs.r26); lkcd_print(" r27: %lx\n", dha->dha_regs.r27); lkcd_print(" r28: %lx\n", dha->dha_regs.r28); lkcd_print(" hae: %lx\n", dha->dha_regs.hae); lkcd_print(" trap_a0: %lx\n", dha->dha_regs.trap_a0); lkcd_print(" trap_a1: %lx\n", dha->dha_regs.trap_a1); lkcd_print(" trap_a2: %lx\n", dha->dha_regs.trap_a2); lkcd_print(" ps: %lx\n", dha->dha_regs.ps); lkcd_print(" pc: %lx\n", dha->dha_regs.pc); lkcd_print(" gp: %lx\n", dha->dha_regs.gp); lkcd_print(" r16: %lx\n", dha->dha_regs.r16); lkcd_print(" r17: %lx\n", dha->dha_regs.r17); lkcd_print(" r18: %lx\n", dha->dha_regs.r18); #endif if (arg == LKCD_DUMP_HEADER_ONLY) return; dump_page_only: lkcd_print(" dump_page:\n"); lkcd_print(" dp_address: "); lkcd_print(BITS32() ? "%llx\n" : "%lx\n", dp->dp_address); lkcd_print(" dp_size: "); lkcd_print(BITS32() ? "%ld\n" : "%d\n", dp->dp_size); lkcd_print(" dp_flags: "); lkcd_print(BITS32() ? "%lx (" : "%x (", dp->dp_flags); others = 0; if (dp->dp_flags & DUMP_COMPRESSED) lkcd_print("DUMP_COMPRESSED", others++); if (dp->dp_flags & DUMP_RAW) lkcd_print("%sDUMP_RAW", others++ ? "|" : ""); if (dp->dp_flags & DUMP_END) lkcd_print("%sDUMP_END", others++ ? "|" : ""); if (dp->dp_flags & LKCD_DUMP_MCLX_V0) lkcd_print("%sLKCD_DUMP_MCLX_V0", others++ ? "|" : ""); lkcd_print(")\n"); }