2009-02-05 21:08:46 +00:00
|
|
|
#ifndef _INCLUDE_R_REG_H_
|
|
|
|
#define _INCLUDE_R_REG_H_
|
|
|
|
|
|
|
|
#include <r_types.h>
|
2009-09-19 22:28:06 +00:00
|
|
|
#include <r_util.h>
|
2009-09-13 22:37:28 +00:00
|
|
|
#include <list.h>
|
2009-02-05 21:08:46 +00:00
|
|
|
|
|
|
|
enum {
|
2009-09-18 18:11:42 +00:00
|
|
|
R_REG_TYPE_GPR,
|
|
|
|
R_REG_TYPE_DRX,
|
|
|
|
R_REG_TYPE_FPU,
|
|
|
|
R_REG_TYPE_MMX,
|
|
|
|
R_REG_TYPE_XMM,
|
2009-09-19 21:41:25 +00:00
|
|
|
R_REG_TYPE_FLG,
|
2009-09-21 13:39:10 +00:00
|
|
|
R_REG_TYPE_SEG,
|
2009-09-18 18:11:42 +00:00
|
|
|
R_REG_TYPE_LAST,
|
2009-09-20 00:16:14 +00:00
|
|
|
R_REG_TYPE_ALL = -1,
|
2009-02-05 21:08:46 +00:00
|
|
|
};
|
|
|
|
|
2010-02-03 13:34:00 +00:00
|
|
|
enum {
|
2010-02-22 03:02:13 +00:00
|
|
|
R_REG_NAME_PC, // program counter
|
|
|
|
R_REG_NAME_SP, // stack pointer
|
|
|
|
R_REG_NAME_SR, // status register
|
|
|
|
R_REG_NAME_BP, // base pointer
|
|
|
|
R_REG_NAME_A0, // arguments
|
2010-02-03 13:34:00 +00:00
|
|
|
R_REG_NAME_A1,
|
|
|
|
R_REG_NAME_A2,
|
|
|
|
R_REG_NAME_A3,
|
|
|
|
R_REG_NAME_LAST,
|
|
|
|
};
|
|
|
|
|
2009-12-24 02:17:53 +00:00
|
|
|
typedef struct r_reg_item_t {
|
2009-09-17 09:48:36 +00:00
|
|
|
char *name;
|
2009-09-18 18:11:42 +00:00
|
|
|
int type;
|
|
|
|
int size; /* 8,16,32,64 ... 128/256 ??? */
|
|
|
|
int offset; // offset in data structure
|
|
|
|
int packed_size; /* 0 means no packed register, 1byte pack, 2b pack... */
|
2010-09-24 02:09:39 +00:00
|
|
|
char *flags;
|
2010-09-18 00:51:17 +00:00
|
|
|
} RRegItem;
|
2009-09-13 22:37:28 +00:00
|
|
|
|
2009-12-24 02:17:53 +00:00
|
|
|
typedef struct r_reg_arena_t {
|
2009-09-18 18:11:42 +00:00
|
|
|
ut8 *bytes;
|
|
|
|
int size;
|
2010-09-18 00:51:17 +00:00
|
|
|
} RRegArena;
|
2009-09-13 22:37:28 +00:00
|
|
|
|
2009-12-24 02:17:53 +00:00
|
|
|
typedef struct r_reg_set_t {
|
2010-09-18 00:51:17 +00:00
|
|
|
RRegArena *arena;
|
|
|
|
RList *pool; /* RRegArena */
|
|
|
|
RList *regs; /* RRegItem */
|
|
|
|
} RRegSet;
|
2009-09-13 22:37:28 +00:00
|
|
|
|
2009-12-24 02:17:53 +00:00
|
|
|
typedef struct r_reg_t {
|
2009-09-18 18:11:42 +00:00
|
|
|
char *profile;
|
2010-02-03 13:34:00 +00:00
|
|
|
char *name[R_REG_NAME_LAST];
|
2010-09-18 00:51:17 +00:00
|
|
|
RRegSet regset[R_REG_TYPE_LAST];
|
2010-09-23 18:42:35 +00:00
|
|
|
int iters;
|
2010-09-18 00:51:17 +00:00
|
|
|
} RReg;
|
2009-02-05 21:08:46 +00:00
|
|
|
|
2010-01-19 10:25:17 +00:00
|
|
|
|
2009-12-24 02:17:53 +00:00
|
|
|
#ifdef R_API
|
2010-02-18 15:36:55 +00:00
|
|
|
R_API const char *r_reg_get_type(int idx);
|
2009-09-19 19:54:22 +00:00
|
|
|
R_API struct r_reg_t *r_reg_free(struct r_reg_t *reg);
|
2010-09-18 00:51:17 +00:00
|
|
|
R_API struct r_reg_t *r_reg_new();
|
2010-01-19 10:25:17 +00:00
|
|
|
//R_API struct r_reg_t *r_reg_new();
|
2009-09-19 19:54:22 +00:00
|
|
|
R_API int r_reg_set_profile_string(struct r_reg_t *reg, const char *profile);
|
|
|
|
R_API int r_reg_set_profile(struct r_reg_t *reg, const char *profile);
|
2010-02-03 17:15:31 +00:00
|
|
|
|
|
|
|
R_API int r_reg_get_name_idx(const char *type);
|
2010-02-03 13:34:00 +00:00
|
|
|
R_API const char *r_reg_get_name(struct r_reg_t *reg, int kind);
|
2010-02-03 17:15:31 +00:00
|
|
|
R_API int r_reg_set_name(struct r_reg_t *reg, int role, const char *name);
|
|
|
|
|
2009-10-12 15:41:52 +00:00
|
|
|
R_API struct r_reg_item_t *r_reg_get(struct r_reg_t *reg, const char *name, int type);
|
2010-09-18 00:51:17 +00:00
|
|
|
R_API RList *r_reg_get_list(struct r_reg_t *reg, int type);
|
2009-09-25 02:04:51 +00:00
|
|
|
R_API int r_reg_type_by_name(const char *str);
|
2009-09-19 19:54:22 +00:00
|
|
|
|
|
|
|
/* value */
|
|
|
|
R_API ut64 r_reg_get_value(struct r_reg_t *reg, struct r_reg_item_t *item);
|
|
|
|
R_API int r_reg_set_value(struct r_reg_t *reg, struct r_reg_item_t *item, ut64 value);
|
|
|
|
R_API float r_reg_get_fvalue(struct r_reg_t *reg, struct r_reg_item_t *item);
|
|
|
|
R_API int r_reg_set_fvalue(struct r_reg_t *reg, struct r_reg_item_t *item, float value);
|
2010-01-24 22:47:18 +00:00
|
|
|
R_API ut64 r_reg_get_pvalue(struct r_reg_t *reg, struct r_reg_item_t *item, int packidx);
|
2010-09-24 02:09:39 +00:00
|
|
|
R_API char *r_reg_get_bvalue(RReg *reg, RRegItem *item);
|
2009-09-19 19:54:22 +00:00
|
|
|
R_API int r_reg_set_pvalue(struct r_reg_t *reg, struct r_reg_item_t *item, ut64 value, int packidx);
|
|
|
|
|
|
|
|
/* byte arena */
|
|
|
|
R_API ut8* r_reg_get_bytes(struct r_reg_t *reg, int type, int *size);
|
|
|
|
R_API int r_reg_set_bytes(struct r_reg_t *reg, int type, const ut8* buf, int len);
|
2010-09-18 00:51:17 +00:00
|
|
|
R_API RRegArena *r_reg_arena_new (int size);
|
|
|
|
R_API void r_reg_arena_free(RRegArena* ra);
|
2010-02-05 11:21:37 +00:00
|
|
|
R_API int r_reg_fit_arena(struct r_reg_t *reg);
|
2010-09-23 18:42:35 +00:00
|
|
|
R_API int r_reg_arena_set(RReg *reg, int n, int copy);
|
|
|
|
R_API void r_reg_arena_swap(RReg *reg, int copy);
|
|
|
|
R_API int r_reg_arena_push(RReg *reg);
|
|
|
|
R_API void r_reg_arena_pop(RReg *reg);
|
2010-09-24 14:45:56 +00:00
|
|
|
R_API ut64 r_reg_cmp(RReg *reg, RRegItem *item);
|
2009-12-24 02:17:53 +00:00
|
|
|
#endif
|
2009-09-19 19:54:22 +00:00
|
|
|
|
2009-02-05 21:08:46 +00:00
|
|
|
#endif
|