summaryrefslogtreecommitdiff
path: root/plugins/arm/v7/operands/register.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/arm/v7/operands/register.c')
-rw-r--r--plugins/arm/v7/operands/register.c150
1 files changed, 49 insertions, 101 deletions
diff --git a/plugins/arm/v7/operands/register.c b/plugins/arm/v7/operands/register.c
index bfbaa70..dce8fef 100644
--- a/plugins/arm/v7/operands/register.c
+++ b/plugins/arm/v7/operands/register.c
@@ -29,15 +29,15 @@
+/* -------------------------- DEFINITION D'UN NOUVEAU TYPE -------------------------- */
+
+
/* Définition d'un opérande visant un registre ARMv7 (instance) */
struct _GArmV7RegisterOperand
{
GRegisterOperand parent; /* Instance parente */
unsigned int alignment; /* Eventuel alignement */
- bool has_alignment; /* Validité du champ */
-
- bool write_back; /* Mise à jour du registre ? */
};
@@ -62,22 +62,27 @@ static void g_armv7_register_operand_dispose(GArmV7RegisterOperand *);
/* Procède à la libération totale de la mémoire. */
static void g_armv7_register_operand_finalize(GArmV7RegisterOperand *);
-/* Traduit un opérande en version humainement lisible. */
-static void g_armv7_register_operand_print(const GArmV7RegisterOperand *, GBufferLine *);
+/* --------------------- IMPLEMENTATION DES FONCTIONS DE CLASSE --------------------- */
-/* --------------------- TRANSPOSITIONS VIA CACHE DES OPERANDES --------------------- */
+/* Traduit un opérande en version humainement lisible. */
+static void g_armv7_register_operand_print(const GArmV7RegisterOperand *, GBufferLine *);
-/* Charge un opérande depuis une mémoire tampon. */
-static bool g_armv7_register_operand_unserialize(GArmV7RegisterOperand *, GAsmStorage *, GBinFormat *, packed_buffer_t *);
+/* Charge un contenu depuis une mémoire tampon. */
+static bool g_armv7_register_operand_load(GArmV7RegisterOperand *, GObjectStorage *, packed_buffer_t *);
-/* Sauvegarde un opérande dans une mémoire tampon. */
-static bool g_armv7_register_operand_serialize(const GArmV7RegisterOperand *, GAsmStorage *, packed_buffer_t *);
+/* Sauvegarde un contenu dans une mémoire tampon. */
+static bool g_armv7_register_operand_store(GArmV7RegisterOperand *, GObjectStorage *, packed_buffer_t *);
+/* ---------------------------------------------------------------------------------- */
+/* DEFINITION D'UN NOUVEAU TYPE */
+/* ---------------------------------------------------------------------------------- */
+
+
/* Indique le type défini par la GLib pour un opérande de registre ARMv7. */
G_DEFINE_TYPE(GArmV7RegisterOperand, g_armv7_register_operand, G_TYPE_REGISTER_OPERAND);
@@ -108,8 +113,8 @@ static void g_armv7_register_operand_class_init(GArmV7RegisterOperandClass *klas
operand->print = (operand_print_fc)g_armv7_register_operand_print;
- operand->unserialize = (unserialize_operand_fc)g_armv7_register_operand_unserialize;
- operand->serialize = (serialize_operand_fc)g_armv7_register_operand_serialize;
+ operand->load = (load_operand_fc)g_armv7_register_operand_load;
+ operand->store = (store_operand_fc)g_armv7_register_operand_store;
}
@@ -128,7 +133,6 @@ static void g_armv7_register_operand_class_init(GArmV7RegisterOperandClass *klas
static void g_armv7_register_operand_init(GArmV7RegisterOperand *operand)
{
- operand->write_back = false;
}
@@ -173,33 +177,6 @@ static void g_armv7_register_operand_finalize(GArmV7RegisterOperand *operand)
/******************************************************************************
* *
-* Paramètres : operand = opérande à traiter. *
-* line = ligne tampon où imprimer l'opérande donné. *
-* *
-* Description : Traduit un opérande en version humainement lisible. *
-* *
-* Retour : - *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-static void g_armv7_register_operand_print(const GArmV7RegisterOperand *operand, GBufferLine *line)
-{
- GArchOperandClass *parent; /* Classe parente */
-
- parent = G_ARCH_OPERAND_CLASS(g_armv7_register_operand_parent_class);
-
- parent->print(G_ARCH_OPERAND(operand), line);
-
- if (operand->write_back)
- g_buffer_line_append_text(line, DLC_ASSEMBLY, "!", 1, RTT_PUNCT, NULL);
-
-}
-
-
-/******************************************************************************
-* *
* Paramètres : reg = registre déjà en place. *
* *
* Description : Crée un opérande visant un registre ARMv7. *
@@ -240,7 +217,7 @@ void g_armv7_register_operand_define_alignement(GArmV7RegisterOperand *operand,
{
operand->alignment = align;
- operand->has_alignment = true;
+ g_arch_operand_set_flag(G_ARCH_OPERAND(operand), A7ROF_HAS_ALIGNMENT);
}
@@ -260,48 +237,51 @@ void g_armv7_register_operand_define_alignement(GArmV7RegisterOperand *operand,
void g_armv7_register_operand_write_back(GArmV7RegisterOperand *operand, bool wback)
{
- operand->write_back = wback;
+ g_arch_operand_set_flag(G_ARCH_OPERAND(operand), A7ROF_WRITE_BACK);
}
+
+/* ---------------------------------------------------------------------------------- */
+/* IMPLEMENTATION DES FONCTIONS DE CLASSE */
+/* ---------------------------------------------------------------------------------- */
+
+
/******************************************************************************
* *
-* Paramètres : operand = opérande représentant un registre. *
+* Paramètres : operand = opérande à traiter. *
+* line = ligne tampon où imprimer l'opérande donné. *
* *
-* Description : Indique si le registre est mis à jour après coup. *
+* Description : Traduit un opérande en version humainement lisible. *
* *
-* Retour : Evolution du registre. *
+* Retour : - *
* *
* Remarques : - *
* *
******************************************************************************/
-bool g_armv7_register_operand_is_written_back(const GArmV7RegisterOperand *operand)
+static void g_armv7_register_operand_print(const GArmV7RegisterOperand *operand, GBufferLine *line)
{
- bool result; /* Statut à retourner */
-
- result = operand->write_back;
-
- return result;
+ GArchOperandClass *parent; /* Classe parente */
-}
+ parent = G_ARCH_OPERAND_CLASS(g_armv7_register_operand_parent_class);
+ parent->print(G_ARCH_OPERAND(operand), line);
+ if (g_arch_operand_has_flag(G_ARCH_OPERAND(operand), A7ROF_WRITE_BACK))
+ g_buffer_line_append_text(line, DLC_ASSEMBLY, "!", 1, RTT_PUNCT, NULL);
-/* ---------------------------------------------------------------------------------- */
-/* TRANSPOSITIONS VIA CACHE DES OPERANDES */
-/* ---------------------------------------------------------------------------------- */
+}
/******************************************************************************
* *
-* Paramètres : operand = opérande d'assemblage à constituer. *
-* storage = mécanisme de sauvegarde à manipuler. *
-* format = format binaire chargé associé à l'architecture. *
-* pbuf = zone tampon à remplir. *
+* Paramètres : operand = élément GLib à constuire. *
+* storage = conservateur de données à manipuler ou NULL. *
+* pbuf = zone tampon à lire. *
* *
-* Description : Charge un opérande depuis une mémoire tampon. *
+* Description : Charge un contenu depuis une mémoire tampon. *
* *
* Retour : Bilan de l'opération. *
* *
@@ -309,37 +289,18 @@ bool g_armv7_register_operand_is_written_back(const GArmV7RegisterOperand *opera
* *
******************************************************************************/
-static bool g_armv7_register_operand_unserialize(GArmV7RegisterOperand *operand, GAsmStorage *storage, GBinFormat *format, packed_buffer_t *pbuf)
+static bool g_armv7_register_operand_load(GArmV7RegisterOperand *operand, GObjectStorage *storage, packed_buffer_t *pbuf)
{
bool result; /* Bilan à retourner */
GArchOperandClass *parent; /* Classe parente à consulter */
- uint8_t boolean; /* Valeur booléenne */
parent = G_ARCH_OPERAND_CLASS(g_armv7_register_operand_parent_class);
- result = parent->unserialize(G_ARCH_OPERAND(operand), storage, format, pbuf);
+ result = parent->load(G_ARCH_OPERAND(operand), storage, pbuf);
- if (result)
- {
- result = extract_packed_buffer(pbuf, &boolean, sizeof(uint8_t), false);
-
- if (result)
- operand->has_alignment = (boolean == 1 ? true : false);
-
- }
-
- if (result && operand->has_alignment)
+ if (result && g_arch_operand_has_flag(G_ARCH_OPERAND(operand), A7ROF_HAS_ALIGNMENT))
result = extract_packed_buffer(pbuf, &operand->alignment, sizeof(unsigned int), true);
- if (result)
- {
- result = extract_packed_buffer(pbuf, &boolean, sizeof(uint8_t), false);
-
- if (result)
- operand->write_back = (boolean == 1 ? true : false);
-
- }
-
return result;
}
@@ -347,11 +308,11 @@ static bool g_armv7_register_operand_unserialize(GArmV7RegisterOperand *operand,
/******************************************************************************
* *
-* Paramètres : operand = opérande d'assemblage à consulter. *
-* storage = mécanisme de sauvegarde à manipuler. *
+* Paramètres : operand = élément GLib à consulter. *
+* storage = conservateur de données à manipuler ou NULL. *
* pbuf = zone tampon à remplir. *
* *
-* Description : Sauvegarde un opérande dans une mémoire tampon. *
+* Description : Sauvegarde un contenu dans une mémoire tampon. *
* *
* Retour : Bilan de l'opération. *
* *
@@ -359,31 +320,18 @@ static bool g_armv7_register_operand_unserialize(GArmV7RegisterOperand *operand,
* *
******************************************************************************/
-static bool g_armv7_register_operand_serialize(const GArmV7RegisterOperand *operand, GAsmStorage *storage, packed_buffer_t *pbuf)
+static bool g_armv7_register_operand_store(GArmV7RegisterOperand *operand, GObjectStorage *storage, packed_buffer_t *pbuf)
{
bool result; /* Bilan à retourner */
GArchOperandClass *parent; /* Classe parente à consulter */
- uint8_t boolean; /* Valeur booléenne */
parent = G_ARCH_OPERAND_CLASS(g_armv7_register_operand_parent_class);
- result = parent->serialize(G_ARCH_OPERAND(operand), storage, pbuf);
+ result = parent->store(G_ARCH_OPERAND(operand), storage, pbuf);
- if (result)
- {
- boolean = (operand->has_alignment ? 1 : 0);
- result = extend_packed_buffer(pbuf, &boolean, sizeof(uint8_t), false);
- }
-
- if (result && operand->has_alignment)
+ if (result && g_arch_operand_has_flag(G_ARCH_OPERAND(operand), A7ROF_HAS_ALIGNMENT))
result = extend_packed_buffer(pbuf, &operand->alignment, sizeof(unsigned int), true);
- if (result)
- {
- boolean = (operand->write_back ? 1 : 0);
- result = extend_packed_buffer(pbuf, &boolean, sizeof(uint8_t), false);
- }
-
return result;
}