/* Chrysalide - Outil d'analyse de fichiers binaires * operand.h - prototypes pour la gestion des operandes de l'architecture MIPS * * Copyright (C) 2009-2017 Cyrille Bagard * * This file is part of Chrysalide. * * Chrysalide 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. * * Chrysalide 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 . */ #ifndef _ARCH_MIPS_OPERAND_H #define _ARCH_MIPS_OPERAND_H #include #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 */