diff options
Diffstat (limited to 'plugins/arm/v7/operands/maccess.c')
-rw-r--r-- | plugins/arm/v7/operands/maccess.c | 205 |
1 files changed, 138 insertions, 67 deletions
diff --git a/plugins/arm/v7/operands/maccess.c b/plugins/arm/v7/operands/maccess.c index 0b0d0b4..77d031f 100644 --- a/plugins/arm/v7/operands/maccess.c +++ b/plugins/arm/v7/operands/maccess.c @@ -29,10 +29,12 @@ #include <stdlib.h> -#include <arch/operand-int.h> #include <common/cpp.h> +#include <core/columns.h> #include <core/logs.h> -#include <gtkext/gtkblockdisplay.h> + + +#include "../operand-int.h" @@ -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,11 +90,14 @@ 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 *); -/* Charge un contenu depuis une mémoire tampon. */ -static bool g_armv7_maccess_operand_load(GArmV7MAccessOperand *, GObjectStorage *, packed_buffer_t *); +/* Fournit une liste de candidats embarqués par un candidat. */ +static GArchOperand **g_armv7_maccess_operand_list_inner_instances(const GArmV7MAccessOperand *, size_t *); -/* Sauvegarde un contenu dans une mémoire tampon. */ -static bool g_armv7_maccess_operand_store(GArmV7MAccessOperand *, GObjectStorage *, packed_buffer_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); @@ -102,7 +107,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,8 +140,12 @@ static void g_armv7_maccess_operand_class_init(GArmV7MAccessOperandClass *klass) operand->print = (operand_print_fc)g_armv7_maccess_operand_print; - operand->load = (load_operand_fc)g_armv7_maccess_operand_load; - operand->store = (store_operand_fc)g_armv7_maccess_operand_store; + 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 = g_arch_operand_load_generic_fixed_3; + operand->store = g_arch_operand_store_generic_fixed; } @@ -534,107 +543,169 @@ static void g_armv7_maccess_operand_print(const GArmV7MAccessOperand *operand, G /****************************************************************************** * * -* Paramètres : operand = élément GLib à constuire. * -* storage = conservateur de données à manipuler ou NULL. * -* pbuf = zone tampon à lire. * +* Paramètres : operand = objet dont l'instance se veut unique. * +* count = quantité d'instances à l'unicité internes. * * * -* Description : Charge un contenu depuis une mémoire tampon. * +* Description : Fournit une liste de candidats embarqués par un candidat. * * * -* Retour : Bilan de l'opération. * +* Retour : Liste de candidats internes ou NULL si aucun. * * * * Remarques : - * * * ******************************************************************************/ -static bool g_armv7_maccess_operand_load(GArmV7MAccessOperand *operand, GObjectStorage *storage, packed_buffer_t *pbuf) +static GArchOperand **g_armv7_maccess_operand_list_inner_instances(const GArmV7MAccessOperand *operand, size_t *count) { - bool result; /* Bilan à retourner */ - GArchOperandClass *parent; /* Classe parente à consulter */ - GSerializableObject *obj; /* Instance à manipuler */ + GArchOperand **result; /* Instances à retourner */ + size_t idx; /* Indice de traitement */ - parent = G_ARCH_OPERAND_CLASS(g_armv7_maccess_operand_parent_class); + *count = 1; - result = parent->load(G_ARCH_OPERAND(operand), storage, pbuf); + if (operand->offset != NULL) + (*count)++; - if (result) - { - obj = g_object_storage_unpack_object(storage, "operands", pbuf); + if (operand->shift != NULL) + (*count)++; - result = (obj != NULL); + result = malloc(*count * sizeof(GArchOperand *)); - if (result) - operand->base = G_ARCH_OPERAND(obj); + 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 (result) + if (operand->shift != NULL) { - obj = g_object_storage_unpack_object(storage, "operands", pbuf); + result[idx] = operand->shift; + g_object_ref(G_OBJECT(result[idx])); + } - result = (obj != NULL); + return result; - if (result) - operand->offset = G_ARCH_OPERAND(obj); +} - } - if (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++) { - obj = g_object_storage_unpack_object(storage, "operands", pbuf); + switch (i) + { + case 0: + g_clear_object(&operand->base); + operand->base = instances[i]; + break; + + case 1: + if (operand->offset != NULL) + { + g_clear_object(&operand->offset); + operand->offset = instances[i]; + } + else + { + assert(count == 2); + + g_clear_object(&operand->shift); + operand->shift = instances[i]; + + } + break; + + case 2: + g_clear_object(&operand->shift); + operand->shift = instances[i]; + break; - result = (obj != NULL); + } - if (result) - operand->shift = G_ARCH_OPERAND(obj); + g_object_ref(G_OBJECT(instances[i])); } - return result; - } /****************************************************************************** * * -* Paramètres : operand = élément GLib à consulter. * -* storage = conservateur de données à manipuler ou NULL. * -* pbuf = zone tampon à remplir. * +* Paramètres : operand = objet dont l'instance se veut unique. * +* lock = précise le besoin en verrouillage. * * * -* Description : Sauvegarde un contenu dans une mémoire tampon. * +* Description : Fournit l'empreinte d'un candidat à une centralisation. * * * -* Retour : Bilan de l'opération. * +* Retour : Empreinte de l'élément représenté. * * * * Remarques : - * * * ******************************************************************************/ -static bool g_armv7_maccess_operand_store(GArmV7MAccessOperand *operand, GObjectStorage *storage, packed_buffer_t *pbuf) +static guint g_armv7_maccess_operand_hash(const GArmV7MAccessOperand *operand, bool lock) { - bool result; /* Bilan à retourner */ - GArchOperandClass *parent; /* Classe parente à consulter */ - GSerializableObject *obj; /* Instance à manipuler */ + guint result; /* Valeur à retourner */ + operand_extra_data_t *extra; /* Données insérées à consulter*/ + GArchOperandClass *class; /* Classe parente normalisée */ + size_t count; /* Quantité d'éléments utiles */ - parent = G_ARCH_OPERAND_CLASS(g_armv7_maccess_operand_parent_class); + extra = GET_ARCH_OP_EXTRA(G_ARCH_OPERAND(operand)); - result = parent->store(G_ARCH_OPERAND(operand), storage, pbuf); + if (lock) + LOCK_GOBJECT_EXTRA(extra); - if (result) - { - obj = G_SERIALIZABLE_OBJECT(operand->base); - result = g_object_storage_pack_object(storage, "operands", obj, pbuf); - } + class = G_ARCH_OPERAND_CLASS(g_armv7_maccess_operand_parent_class); + result = class->hash(G_ARCH_OPERAND(operand), false); - if (result) - { - obj = G_SERIALIZABLE_OBJECT(operand->offset); - result = g_object_storage_pack_object(storage, "operands", obj, pbuf); - } + count = 1; - if (result) - { - obj = G_SERIALIZABLE_OBJECT(operand->shift); - result = g_object_storage_pack_object(storage, "operands", obj, pbuf); - } + if (operand->offset != NULL) + (count)++; + + if (operand->shift != NULL) + (count)++; + + result ^= count; + + if (lock) + UNLOCK_GOBJECT_EXTRA(extra); return result; |