diff options
Diffstat (limited to 'plugins/arm/v7/operands/maccess.c')
-rw-r--r-- | plugins/arm/v7/operands/maccess.c | 194 |
1 files changed, 190 insertions, 4 deletions
diff --git a/plugins/arm/v7/operands/maccess.c b/plugins/arm/v7/operands/maccess.c index 0b0d0b4..3eb3116 100644 --- a/plugins/arm/v7/operands/maccess.c +++ b/plugins/arm/v7/operands/maccess.c @@ -29,12 +29,14 @@ #include <stdlib.h> -#include <arch/operand-int.h> #include <common/cpp.h> #include <core/logs.h> #include <gtkext/gtkblockdisplay.h> +#include "../operand-int.h" + + /* -------------------------- DEFINITION D'UN NOUVEAU TYPE -------------------------- */ @@ -42,7 +44,7 @@ /* Définition d'un opérande offrant un accès à la mémoire depuis une base (instance) */ struct _GArmV7MAccessOperand { - GArchOperand parent; /* Instance parente */ + GArmV7Operand parent; /* Instance parente */ GArchOperand *base; /* Base de l'accès en mémoire */ GArchOperand *offset; /* Décalage pour l'adresse */ @@ -54,7 +56,7 @@ struct _GArmV7MAccessOperand /* Définition d'un opérande offrant un accès à la mémoire depuis une base (classe) */ struct _GArmV7MAccessOperandClass { - GArchOperandClass parent; /* Classe parente */ + GArmV7OperandClass parent; /* Classe parente */ }; @@ -88,6 +90,15 @@ static GArchOperand *g_armv7_maccess_operand_get_inner_operand_from_path(const G /* Traduit un opérande en version humainement lisible. */ static void g_armv7_maccess_operand_print(const GArmV7MAccessOperand *, GBufferLine *); +/* Fournit une liste de candidats embarqués par un candidat. */ +static GArchOperand **g_armv7_maccess_operand_list_inner_instances(const GArmV7MAccessOperand *, size_t *); + +/* Met à jour une liste de candidats embarqués par un candidat. */ +static void g_armv7_maccess_operand_update_inner_instances(GArmV7MAccessOperand *, GArchOperand **, size_t); + +/* Fournit l'empreinte d'un candidat à une centralisation. */ +static guint g_armv7_maccess_operand_hash(const GArmV7MAccessOperand *, bool); + /* Charge un contenu depuis une mémoire tampon. */ static bool g_armv7_maccess_operand_load(GArmV7MAccessOperand *, GObjectStorage *, packed_buffer_t *); @@ -102,7 +113,7 @@ static bool g_armv7_maccess_operand_store(GArmV7MAccessOperand *, GObjectStorage /* Indique le type défini par la GLib pour un accès à la mémoire depuis une base. */ -G_DEFINE_TYPE(GArmV7MAccessOperand, g_armv7_maccess_operand, G_TYPE_ARCH_OPERAND); +G_DEFINE_TYPE(GArmV7MAccessOperand, g_armv7_maccess_operand, G_TYPE_ARMV7_OPERAND); /****************************************************************************** @@ -135,6 +146,10 @@ static void g_armv7_maccess_operand_class_init(GArmV7MAccessOperandClass *klass) operand->print = (operand_print_fc)g_armv7_maccess_operand_print; + operand->list_inner = (operand_list_inners_fc)g_armv7_maccess_operand_list_inner_instances; + operand->update_inner = (operand_update_inners_fc)g_armv7_maccess_operand_update_inner_instances; + operand->hash = (operand_hash_fc)g_armv7_maccess_operand_hash; + operand->load = (load_operand_fc)g_armv7_maccess_operand_load; operand->store = (store_operand_fc)g_armv7_maccess_operand_store; @@ -534,6 +549,177 @@ static void g_armv7_maccess_operand_print(const GArmV7MAccessOperand *operand, G /****************************************************************************** * * +* Paramètres : operand = objet dont l'instance se veut unique. * +* count = quantité d'instances à l'unicité internes. * +* * +* Description : Fournit une liste de candidats embarqués par un candidat. * +* * +* Retour : Liste de candidats internes ou NULL si aucun. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static GArchOperand **g_armv7_maccess_operand_list_inner_instances(const GArmV7MAccessOperand *operand, size_t *count) +{ + GArchOperand **result; /* Instances à retourner */ + size_t idx; /* Indice de traitement */ + + *count = 1; + + if (operand->offset != NULL) + (*count)++; + + if (operand->shift != NULL) + (*count)++; + + result = malloc(*count * sizeof(GArchOperand *)); + + result[0] = operand->base; + g_object_ref(G_OBJECT(result[0])); + + if (operand->offset != NULL) + { + result[1] = operand->offset; + g_object_ref(G_OBJECT(result[1])); + + idx = 2; + + } + else + idx = 1; + + if (operand->shift != NULL) + { + result[idx] = operand->shift; + g_object_ref(G_OBJECT(result[idx])); + } + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : operand = objet dont l'instance se veut unique. * +* instances = liste de candidats internes devenus singletons. * +* count = quantité d'instances à l'unicité internes. * +* * +* Description : Met à jour une liste de candidats embarqués par un candidat. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_armv7_maccess_operand_update_inner_instances(GArmV7MAccessOperand *operand, GArchOperand **instances, size_t count) +{ +#ifndef NDEBUG + size_t idx_check; /* Décompte des éléments utiles*/ +#endif + size_t i; /* Boucle de parcours */ + +#ifndef NDEBUG + idx_check = 1; + + if (operand->offset != NULL) + (idx_check)++; + + if (operand->shift != NULL) + (idx_check)++; + + assert(count == idx_check); +#endif + + for (i = 0; i < count; i++) + { + switch (i) + { + case 0: + g_object_unref(G_OBJECT(operand->base)); + operand->base = instances[i]; + break; + + case 1: + if (operand->offset != NULL) + { + g_object_unref(G_OBJECT(operand->offset)); + operand->offset = instances[i]; + } + else + { + assert(count == 2); + + g_object_unref(G_OBJECT(operand->shift)); + operand->shift = instances[i]; + + } + break; + + case 2: + g_object_unref(G_OBJECT(operand->shift)); + operand->shift = instances[i]; + break; + + } + + g_object_ref(G_OBJECT(instances[i])); + + } + +} + + +/****************************************************************************** +* * +* Paramètres : operand = objet dont l'instance se veut unique. * +* lock = précise le besoin en verrouillage. * +* * +* Description : Fournit l'empreinte d'un candidat à une centralisation. * +* * +* Retour : Empreinte de l'élément représenté. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static guint g_armv7_maccess_operand_hash(const GArmV7MAccessOperand *operand, bool lock) +{ + guint result; /* Valeur à retourner */ + lockable_obj_extra_t *extra; /* Données insérées à consulter*/ + GArchOperandClass *class; /* Classe parente normalisée */ + size_t count; /* Quantité d'éléments utiles */ + + extra = GET_GOBJECT_EXTRA(G_OBJECT(operand), lockable_obj_extra_t); + + if (lock) + LOCK_GOBJECT_EXTRA(extra); + + class = G_ARCH_OPERAND_CLASS(g_armv7_maccess_operand_parent_class); + result = class->hash(G_ARCH_OPERAND(operand), false); + + count = 1; + + if (operand->offset != NULL) + (count)++; + + if (operand->shift != NULL) + (count)++; + + result ^= count; + + if (lock) + UNLOCK_GOBJECT_EXTRA(extra); + + return result; + +} + + +/****************************************************************************** +* * * Paramètres : operand = élément GLib à constuire. * * storage = conservateur de données à manipuler ou NULL. * * pbuf = zone tampon à lire. * |