diff options
Diffstat (limited to 'plugins/arm/v7/operands/it.c')
-rw-r--r-- | plugins/arm/v7/operands/it.c | 210 |
1 files changed, 113 insertions, 97 deletions
diff --git a/plugins/arm/v7/operands/it.c b/plugins/arm/v7/operands/it.c index 6fab598..54e15ed 100644 --- a/plugins/arm/v7/operands/it.c +++ b/plugins/arm/v7/operands/it.c @@ -33,6 +33,9 @@ +/* -------------------------- DEFINITION D'UN NOUVEAU TYPE -------------------------- */ + + /* Définition d'un opérande organisant l'application d'une instruction IT (instance) */ struct _GArmV7ITCondOperand { @@ -64,23 +67,28 @@ static void g_armv7_itcond_operand_dispose(GArmV7ITCondOperand *); /* Procède à la libération totale de la mémoire. */ static void g_armv7_itcond_operand_finalize(GArmV7ITCondOperand *); + + +/* --------------------- IMPLEMENTATION DES FONCTIONS DE CLASSE --------------------- */ + + /* Compare un opérande avec un autre. */ -static int g_armv7_itcond_operand_compare(const GArmV7ITCondOperand *, const GArmV7ITCondOperand *); +static int g_armv7_itcond_operand_compare(const GArmV7ITCondOperand *, const GArmV7ITCondOperand *, bool); /* Traduit un opérande en version humainement lisible. */ static void g_armv7_itcond_operand_print(const GArmV7ITCondOperand *, GBufferLine *); +/* Charge un contenu depuis une mémoire tampon. */ +static bool g_armv7_itcond_operand_load(GArmV7ITCondOperand *, GObjectStorage *, packed_buffer_t *); +/* Sauvegarde un contenu dans une mémoire tampon. */ +static bool g_armv7_itcond_operand_store(GArmV7ITCondOperand *, GObjectStorage *, packed_buffer_t *); -/* --------------------- TRANSPOSITIONS VIA CACHE DES OPERANDES --------------------- */ - - -/* Charge un opérande depuis une mémoire tampon. */ -static bool g_armv7_itcond_operand_unserialize(GArmV7ITCondOperand *, GAsmStorage *, GBinFormat *, packed_buffer_t *); -/* Sauvegarde un opérande dans une mémoire tampon. */ -static bool g_armv7_itcond_operand_serialize(const GArmV7ITCondOperand *, GAsmStorage *, packed_buffer_t *); +/* ---------------------------------------------------------------------------------- */ +/* DEFINITION D'UN NOUVEAU TYPE */ +/* ---------------------------------------------------------------------------------- */ /* Indique le type défini par la GLib pour l'application d'une instruction IT. */ @@ -105,16 +113,17 @@ static void g_armv7_itcond_operand_class_init(GArmV7ITCondOperandClass *klass) GArchOperandClass *operand; /* Version de classe parente */ object = G_OBJECT_CLASS(klass); - operand = G_ARCH_OPERAND_CLASS(klass); object->dispose = (GObjectFinalizeFunc/* ! */)g_armv7_itcond_operand_dispose; object->finalize = (GObjectFinalizeFunc)g_armv7_itcond_operand_finalize; + operand = G_ARCH_OPERAND_CLASS(klass); + operand->compare = (operand_compare_fc)g_armv7_itcond_operand_compare; operand->print = (operand_print_fc)g_armv7_itcond_operand_print; - operand->unserialize = (unserialize_operand_fc)g_armv7_itcond_operand_unserialize; - operand->serialize = (serialize_operand_fc)g_armv7_itcond_operand_serialize; + operand->load = (load_operand_fc)g_armv7_itcond_operand_load; + operand->store = (store_operand_fc)g_armv7_itcond_operand_store; } @@ -177,127 +186,115 @@ static void g_armv7_itcond_operand_finalize(GArmV7ITCondOperand *operand) /****************************************************************************** * * -* Paramètres : a = premier opérande à consulter. * -* b = second opérande à consulter. * +* Paramètres : firstcond = valeur brute de la condition d'exécution. * +* mask = masque d'interprétation pour l'instruction. * * * -* Description : Compare un opérande avec un autre. * +* Description : Crée un opérande lié à une instruction IT. * * * -* Retour : Bilan de la comparaison. * +* Retour : Opérande mis en place. * * * * Remarques : - * * * ******************************************************************************/ -static int g_armv7_itcond_operand_compare(const GArmV7ITCondOperand *a, const GArmV7ITCondOperand *b) +GArchOperand *g_armv7_itcond_operand_new(uint8_t firstcond, uint8_t mask) { - int result; /* Bilan à faire remonter */ + GArmV7ITCondOperand *result; /* Structure à retourner */ - result = sort_boolean(a->firstcond, b->firstcond); + if (firstcond > ACC_NV) + return NULL; - if (result == 0) - result = sort_unsigned_long(a->mask, b->mask); + result = g_object_new(G_TYPE_ARMV7_ITCOND_OPERAND, NULL); - return result; + result->firstcond = firstcond; + result->mask = mask; + + return G_ARCH_OPERAND(result); } /****************************************************************************** * * -* Paramètres : operand = opérande à traiter. * -* line = ligne tampon où imprimer l'opérande donné. * +* Paramètres : operand = opérande à consulter. * * * -* Description : Traduit un opérande en version humainement lisible. * +* Description : Fournit la condition associée à l'opérande. * * * -* Retour : - * +* Retour : Condition classique pour ARMv7. * * * * Remarques : - * * * ******************************************************************************/ -static void g_armv7_itcond_operand_print(const GArmV7ITCondOperand *operand, GBufferLine *line) +ArmCondCode g_armv7_itcond_operand_get_firstcond(const GArmV7ITCondOperand *operand) { - const char *kw; /* Mot clef à imprimer */ - - switch (operand->firstcond) - { - case ACC_EQ: kw = "EQ"; break; - case ACC_NE: kw = "NE"; break; - case ACC_HS: kw = "HS"; break; - case ACC_LO: kw = "LO"; break; - case ACC_MI: kw = "MI"; break; - case ACC_PL: kw = "PL"; break; - case ACC_VS: kw = "VS"; break; - case ACC_VC: kw = "VC"; break; - case ACC_HI: kw = "HI"; break; - case ACC_LS: kw = "LS"; break; - case ACC_GE: kw = "GE"; break; - case ACC_LT: kw = "LT"; break; - case ACC_GT: kw = "GT"; break; - case ACC_LE: kw = "LE"; break; - case ACC_AL: kw = NULL; break; - case ACC_NV: kw = "NV"; break; - - default: /* Pour GCC... */ - assert(false); - kw = NULL; - break; + ArmCondCode result; /* Condition à renvoyer */ - } + result = operand->firstcond; - if (kw != NULL) - g_buffer_line_append_text(line, DLC_ASSEMBLY, kw, 2, RTT_KEY_WORD, NULL); + return result; } /****************************************************************************** * * -* Paramètres : firstcond = valeur brute de la condition d'exécution. * -* mask = masque d'interprétation pour l'instruction. * +* Paramètres : operand = opérande à consulter. * * * -* Description : Crée un opérande lié à une instruction IT. * +* Description : Fournit le masque d'interprétation de la condition. * * * -* Retour : Opérande mis en place. * +* Retour : Masque de bits. * * * * Remarques : - * * * ******************************************************************************/ -GArchOperand *g_armv7_itcond_operand_new(uint8_t firstcond, uint8_t mask) +uint8_t g_armv7_itcond_operand_get_mask(const GArmV7ITCondOperand *operand) { - GArmV7ITCondOperand *result; /* Structure à retourner */ + uint8_t result; /* Valeur à retourner */ - if (firstcond > ACC_NV) - return NULL; + result = operand->mask; - result = g_object_new(G_TYPE_ARMV7_ITCOND_OPERAND, NULL); + return result; - result->firstcond = firstcond; - result->mask = mask; +} - return G_ARCH_OPERAND(result); -} + +/* ---------------------------------------------------------------------------------- */ +/* IMPLEMENTATION DES FONCTIONS DE CLASSE */ +/* ---------------------------------------------------------------------------------- */ /****************************************************************************** * * -* Paramètres : operand = opérande à consulter. * +* Paramètres : a = premier opérande à consulter. * +* b = second opérande à consulter. * +* lock = précise le besoin en verrouillage. * * * -* Description : Fournit la condition associée à l'opérande. * +* Description : Compare un opérande avec un autre. * * * -* Retour : Condition classique pour ARMv7. * +* Retour : Bilan de la comparaison. * * * * Remarques : - * * * ******************************************************************************/ -ArmCondCode g_armv7_itcond_operand_get_firstcond(const GArmV7ITCondOperand *operand) +static int g_armv7_itcond_operand_compare(const GArmV7ITCondOperand *a, const GArmV7ITCondOperand *b, bool lock) { - ArmCondCode result; /* Condition à renvoyer */ + int result; /* Bilan à faire remonter */ + GArchOperandClass *class; /* Classe parente normalisée */ - result = operand->firstcond; + result = sort_boolean(a->firstcond, b->firstcond); + + if (result == 0) + result = sort_unsigned_long(a->mask, b->mask); + + if (result == 0) + { + class = G_ARCH_OPERAND_CLASS(g_armv7_itcond_operand_parent_class); + result = class->compare(G_ARCH_OPERAND(a), G_ARCH_OPERAND(b), false); + } return result; @@ -306,41 +303,60 @@ ArmCondCode g_armv7_itcond_operand_get_firstcond(const GArmV7ITCondOperand *oper /****************************************************************************** * * -* Paramètres : operand = opérande à consulter. * +* Paramètres : operand = opérande à traiter. * +* line = ligne tampon où imprimer l'opérande donné. * * * -* Description : Fournit le masque d'interprétation de la condition. * +* Description : Traduit un opérande en version humainement lisible. * * * -* Retour : Masque de bits. * +* Retour : - * * * * Remarques : - * * * ******************************************************************************/ -uint8_t g_armv7_itcond_operand_get_mask(const GArmV7ITCondOperand *operand) +static void g_armv7_itcond_operand_print(const GArmV7ITCondOperand *operand, GBufferLine *line) { - uint8_t result; /* Valeur à retourner */ - - result = operand->mask; + const char *kw; /* Mot clef à imprimer */ - return result; + switch (operand->firstcond) + { + case ACC_EQ: kw = "EQ"; break; + case ACC_NE: kw = "NE"; break; + case ACC_HS: kw = "HS"; break; + case ACC_LO: kw = "LO"; break; + case ACC_MI: kw = "MI"; break; + case ACC_PL: kw = "PL"; break; + case ACC_VS: kw = "VS"; break; + case ACC_VC: kw = "VC"; break; + case ACC_HI: kw = "HI"; break; + case ACC_LS: kw = "LS"; break; + case ACC_GE: kw = "GE"; break; + case ACC_LT: kw = "LT"; break; + case ACC_GT: kw = "GT"; break; + case ACC_LE: kw = "LE"; break; + case ACC_AL: kw = NULL; break; + case ACC_NV: kw = "NV"; break; -} + default: /* Pour GCC... */ + assert(false); + kw = NULL; + break; + } + if (kw != NULL) + g_buffer_line_append_text(line, DLC_ASSEMBLY, kw, 2, RTT_KEY_WORD, 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. * * * @@ -348,14 +364,14 @@ uint8_t g_armv7_itcond_operand_get_mask(const GArmV7ITCondOperand *operand) * * ******************************************************************************/ -static bool g_armv7_itcond_operand_unserialize(GArmV7ITCondOperand *operand, GAsmStorage *storage, GBinFormat *format, packed_buffer_t *pbuf) +static bool g_armv7_itcond_operand_load(GArmV7ITCondOperand *operand, GObjectStorage *storage, packed_buffer_t *pbuf) { bool result; /* Bilan à retourner */ GArchOperandClass *parent; /* Classe parente à consulter */ parent = G_ARCH_OPERAND_CLASS(g_armv7_itcond_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, &operand->firstcond, sizeof(ArmCondCode), true); @@ -370,11 +386,11 @@ static bool g_armv7_itcond_operand_unserialize(GArmV7ITCondOperand *operand, GAs /****************************************************************************** * * -* 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. * * * @@ -382,14 +398,14 @@ static bool g_armv7_itcond_operand_unserialize(GArmV7ITCondOperand *operand, GAs * * ******************************************************************************/ -static bool g_armv7_itcond_operand_serialize(const GArmV7ITCondOperand *operand, GAsmStorage *storage, packed_buffer_t *pbuf) +static bool g_armv7_itcond_operand_store(GArmV7ITCondOperand *operand, GObjectStorage *storage, packed_buffer_t *pbuf) { bool result; /* Bilan à retourner */ GArchOperandClass *parent; /* Classe parente à consulter */ parent = G_ARCH_OPERAND_CLASS(g_armv7_itcond_operand_parent_class); - result = parent->serialize(G_ARCH_OPERAND(operand), storage, pbuf); + result = parent->store(G_ARCH_OPERAND(operand), storage, pbuf); if (result) result = extend_packed_buffer(pbuf, &operand->firstcond, sizeof(ArmCondCode), true); |