diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2009-05-31 20:58:20 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2009-05-31 20:58:20 (GMT) |
commit | 8724afdc73e0ddad86f46de1a3fbe0254575a76e (patch) | |
tree | de666b66e154c6c6453807d3fa4272efb6877a91 /src/arch/mips/operand.h | |
parent | 0b7d7f26c745ff0f52e9e483a0980351368ca824 (diff) |
Supported a new architecture (MIPS).
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@67 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/arch/mips/operand.h')
-rw-r--r-- | src/arch/mips/operand.h | 156 |
1 files changed, 156 insertions, 0 deletions
diff --git a/src/arch/mips/operand.h b/src/arch/mips/operand.h new file mode 100644 index 0000000..22bd080 --- /dev/null +++ b/src/arch/mips/operand.h @@ -0,0 +1,156 @@ + +/* OpenIDA - Outil d'analyse de fichiers binaires + * operand.h - prototypes pour la gestion des operandes de l'architecture MIPS + * + * Copyright (C) 2008 Cyrille Bagard + * + * This file is part of OpenIDA. + * + * OpenIDA is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * OpenIDA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see <http://www.gnu.org/licenses/>. + */ + + +#ifndef _ARCH_MIPS_OPERAND_H +#define _ARCH_MIPS_OPERAND_H + + +#include <stdbool.h> + + +#include "registers.h" +#include "../instruction.h" + + + +/* ------------------------ COQUILLE VIDE POUR OPERANDE MIPS ------------------------ */ + + +#define G_TYPE_MIPS_OPERAND g_mips_operand_get_type() +#define G_MIPS_OPERAND(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_mips_operand_get_type(), GMipsOperand)) +#define G_IS_MIPS_OPERAND(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_mips_operand_get_type())) +#define G_MIPS_OPERAND_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE((inst), g_mips_operand_get_type(), GMipsOperandIface)) + + +/* Définition d'un opérande de MIPS (instance) */ +typedef struct _GMipsOperand GMipsOperand; + +/* Définition d'un opérande de MIPS (classe) */ +typedef struct _GMipsOperandClass GMipsOperandClass; + + +/* Indique le type défini par la GLib pour un opérande de MIPS. */ +GType g_mips_operand_get_type(void); + + + +/* ----------------------- OPERANDES OFFRANT UN REGISTRE MIPS ----------------------- */ + + +#define G_TYPE_MIPS_REGISTER_OPERAND g_mips_register_operand_get_type() +#define G_MIPS_REGISTER_OPERAND(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_mips_register_operand_get_type(), GMipsRegisterOperand)) +#define G_IS_MIPS_REGISTER_OPERAND(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_mips_register_operand_get_type())) +#define G_MIPS_REGISTER_OPERAND_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE((inst), g_mips_register_operand_get_type(), GMipsRegisterOperandIface)) + + +/* Définition d'un opérande visant un registre MIPS (instance) */ +typedef struct _GMipsRegisterOperand GMipsRegisterOperand; + +/* Définition d'un opérande visant un registre MIPS (classe) */ +typedef struct _GMipsRegisterOperandClass GMipsRegisterOperandClass; + + +/* Indique le type défini par la GLib pour un opérande de registre MIPS. */ +GType g_mips_register_operand_get_type(void); + +/* Crée un opérande visant un registre MIPS. */ +GArchOperand *g_mips_register_operand_new(bin_t); + +/* Fournit le registre MIPS représenté. */ +const mips_register *g_mips_register_operand_get_register(const GMipsRegisterOperand *); + + + +/* -------------------------- OPERANDES DE CONTENU MEMOIRE -------------------------- */ + + +#define G_TYPE_MIPS_MEM_CONTENT_OPERAND g_mips_mem_content_operand_get_type() +#define G_MIPS_MEM_CONTENT_OPERAND(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_mips_mem_content_operand_get_type(), GMipsMemContentOperand)) +#define G_IS_MIPS_MEM_CONTENT_OPERAND(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_mips_mem_content_operand_get_type())) +#define G_MIPS_MEM_CONTENT_OPERAND_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE((inst), g_mips_mem_content_operand_get_type(), GMipsMemContentOperandIface)) + + +/* Définition d'un opérande MIPS pointeur un contenu mémoire (instance) */ +typedef struct _GMipsMemContentOperand GMipsMemContentOperand; + +/* Définition d'un opérande MIPS pointeur un contenu mémoire (classe) */ +typedef struct _GMipsMemContentOperandClass GMipsMemContentOperandClass; + + +/* Indique le type défini par la GLib pour un opérande MIPS de contenu mémoire. */ +GType g_mips_mem_content_operand_get_type(void); + +/* Crée un opérande MIPS de contenu mémoire. */ +GArchOperand *g_mips_mem_content_operand_new(bin_t, int16_t); + + + +/* ----------------------------- OPERANDES DE DECALLAGE ----------------------------- */ + + +#define G_TYPE_MIPS_OFFSET_OPERAND g_mips_offset_operand_get_type() +#define G_MIPS_OFFSET_OPERAND(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_mips_offset_operand_get_type(), GMipsOffsetOperand)) +#define G_IS_MIPS_OFFSET_OPERAND(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_mips_offset_operand_get_type())) +#define G_MIPS_OFFSET_OPERAND_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE((inst), g_mips_offset_operand_get_type(), GMipsOffsetOperandIface)) + + +/* Définition d'un opérande MIPS de décallage (instance) */ +typedef struct _GMipsOffsetOperand GMipsOffsetOperand; + +/* Définition d'un opérande MIPS de décallage (classe) */ +typedef struct _GMipsOffsetOperandClass GMipsOffsetOperandClass; + + +/* Indique le type défini par la GLib pour un opérande MIPS de décallage. */ +GType g_mips_offset_operand_get_type(void); + +/* Crée un opérande MIPS de décallage. */ +GArchOperand *g_mips_offset_operand_new(int16_t); + + + +/* ------------------------- AIDE A LA CREATION D'OPERANDES ------------------------- */ + + +/* Types d'opérandes supportés */ +typedef enum _MIPSOperandType +{ + MIPS_OTP_RS, /* Registre rs (bits 21 -> 25) */ + MIPS_OTP_RT, /* Registre rs (bits 16 -> 20) */ + MIPS_OTP_RD, /* Registre rs (bits 11 -> 15) */ + MIPS_OTP_IMMEDIATE, /* Valeur imm. (bits 0 -> 15) */ + MIPS_OTP_TARGET_ADDRESS, /* Adresse (bits 0 -> 25) */ + + MIPS_OTP_MEM_CONTENT, /* Contenu mémoire [base+off] */ + MIPS_OTP_OFFSET, /* Décallage */ + MIPS_OTP_SA /* Valeur arithmétique */ + +} MipsOperandType; + + +/* Procède à la lecture de n opérandes donnés. */ +bool mips_read_n_operands(GArchInstruction *, const bin_t *data, off_t *pos, off_t, unsigned int, ...); + + + +#endif /* _ARCH_MIPS_OPERAND_H */ |