Rizin
unix-like reverse engineering framework and cli tools
asm_tms320.c File Reference
#include <stdio.h>
#include <rz_types.h>
#include <rz_lib.h>
#include <rz_asm.h>
#include <capstone/capstone.h>
#include "../arch/tms320/tms320_dasm.h"

Go to the source code of this file.

Classes

struct  tms_cs_context_t
 

Macros

#define CAPSTONE_HAS_TMS320C64X   0
 

Typedefs

typedef struct tms_cs_context_t TmsContext
 

Functions

static int tms320_disassemble (RzAsm *a, RzAsmOp *op, const ut8 *buf, int len)
 
static bool tms320_init (void **user)
 
static bool tms320_fini (void *user)
 

Variables

RzAsmPlugin rz_asm_plugin_tms320
 
RZ_API RzLibStruct rizin_plugin
 

Macro Definition Documentation

◆ CAPSTONE_HAS_TMS320C64X

#define CAPSTONE_HAS_TMS320C64X   0

Definition at line 14 of file asm_tms320.c.

Typedef Documentation

◆ TmsContext

typedef struct tms_cs_context_t TmsContext

Function Documentation

◆ tms320_disassemble()

static int tms320_disassemble ( RzAsm a,
RzAsmOp op,
const ut8 buf,
int  len 
)
static

Definition at line 75 of file asm_tms320.c.

75  {
76  TmsContext *ctx = (TmsContext *)a->plugin_data;
77  if (a->cpu && rz_str_casecmp(a->cpu, "c54x") == 0) {
79  } else if (a->cpu && rz_str_casecmp(a->cpu, "c55x+") == 0) {
81  } else if (a->cpu && rz_str_casecmp(a->cpu, "c55x") == 0) {
83  } else {
84 #if CAPSTONE_HAS_TMS320C64X
85  if (a->cpu && !rz_str_casecmp(a->cpu, "c64x")) {
86  return tms320c64x_disassemble(a, op, buf, len);
87  }
88 #endif
89  rz_asm_op_set_asm(op, "unknown asm.cpu");
90  return op->size = -1;
91  }
92  op->size = tms320_dasm(&ctx->engine, buf, len);
93  rz_asm_op_set_asm(op, ctx->engine.syntax);
94  return op->size;
95 }
size_t len
Definition: 6502dis.c:15
RZ_API void rz_asm_op_set_asm(RzAsmOp *op, const char *str)
Definition: aop.c:53
voidpf void * buf
Definition: ioapi.h:138
RZ_API int rz_str_casecmp(const char *dst, const char *orig)
Definition: str.c:121
#define a(i)
Definition: sha256.c:41
int tms320_dasm(tms320_dasm_t *dasm, const ut8 *stream, int len)
Definition: tms320_dasm.c:1154
#define tms320_f_set_cpu(d, v)
Definition: tms320_dasm.h:215
#define TMS320_F_CPU_C55X_PLUS
Definition: tms320_dasm.h:211
#define TMS320_F_CPU_C54X
Definition: tms320_dasm.h:209
#define TMS320_F_CPU_C55X
Definition: tms320_dasm.h:210
Definition: dis.c:32
if(dbg->bits==RZ_SYS_BITS_64)
Definition: windows-arm64.h:4

References a, if(), len, rz_asm_op_set_asm(), rz_str_casecmp(), tms320_dasm(), TMS320_F_CPU_C54X, TMS320_F_CPU_C55X, TMS320_F_CPU_C55X_PLUS, and tms320_f_set_cpu.

◆ tms320_fini()

static bool tms320_fini ( void *  user)
static

Definition at line 107 of file asm_tms320.c.

107  {
108  rz_return_val_if_fail(user, false);
109  TmsContext *ctx = (TmsContext *)user;
110 #if CAPSTONE_HAS_TMS320C64X
111  cs_close(&ctx->cd);
112 #endif
113  tms320_dasm_fini(&ctx->engine);
114  free(ctx);
115  return true;
116 }
CAPSTONE_EXPORT cs_err CAPSTONE_API cs_close(csh *handle)
Definition: cs.c:501
RZ_API void Ht_() free(HtName_(Ht) *ht)
Definition: ht_inc.c:130
#define rz_return_val_if_fail(expr, val)
Definition: rz_assert.h:108
int tms320_dasm_fini(tms320_dasm_t *dasm)
Definition: tms320_dasm.c:1202

References cs_close(), free(), rz_return_val_if_fail, and tms320_dasm_fini().

◆ tms320_init()

static bool tms320_init ( void **  user)
static

Definition at line 97 of file asm_tms320.c.

97  {
99  if (!ctx) {
100  return false;
101  }
102  tms320_dasm_init(&ctx->engine);
103  *user = ctx;
104  return true;
105 }
#define RZ_NEW0(x)
Definition: rz_types.h:284
int tms320_dasm_init(tms320_dasm_t *dasm)
Definition: tms320_dasm.c:1181

References RZ_NEW0, and tms320_dasm_init().

Variable Documentation

◆ rizin_plugin

RZ_API RzLibStruct rizin_plugin
Initial value:
= {
.type = RZ_LIB_TYPE_ASM,
}
RzAsmPlugin rz_asm_plugin_tms320
Definition: asm_tms320.c:118
@ RZ_LIB_TYPE_ASM
Definition: rz_lib.h:72
#define RZ_VERSION
Definition: rz_version.h:8
const char * version
Definition: rz_asm.h:133

Definition at line 137 of file asm_tms320.c.

◆ rz_asm_plugin_tms320

RzAsmPlugin rz_asm_plugin_tms320
Initial value:
= {
.name = "tms320",
.arch = "tms320",
.cpus = "c54x,c55x,c55x+",
.desc = "TMS320 DSP family (c54x,c55x,c55x+)",
.license = "LGPLv3",
.bits = 32,
.init = tms320_init,
.fini = tms320_fini,
.disassemble = &tms320_disassemble,
}
static bool tms320_fini(void *user)
Definition: asm_tms320.c:107
static bool tms320_init(void **user)
Definition: asm_tms320.c:97
static int tms320_disassemble(RzAsm *a, RzAsmOp *op, const ut8 *buf, int len)
Definition: asm_tms320.c:75
#define RZ_SYS_ENDIAN_BIG
Definition: rz_types.h:527
#define RZ_SYS_ENDIAN_LITTLE
Definition: rz_types.h:526

Definition at line 118 of file asm_tms320.c.