diff options
Diffstat (limited to 'src/arch/instructions/undefined.c')
-rw-r--r-- | src/arch/instructions/undefined.c | 136 |
1 files changed, 127 insertions, 9 deletions
diff --git a/src/arch/instructions/undefined.c b/src/arch/instructions/undefined.c index 880e338..15c63e7 100644 --- a/src/arch/instructions/undefined.c +++ b/src/arch/instructions/undefined.c @@ -31,7 +31,7 @@ #include "undefined-int.h" -#include "../../gtkext/gtkblockdisplay.h" +#include "../../core/columns.h" @@ -74,6 +74,17 @@ static void g_undef_instruction_print(GUndefInstruction *, GBufferLine *, size_t +/* --------------------- IMPLEMENTATION DES FONCTIONS DE CLASSE --------------------- */ + + +/* Charge un contenu depuis une mémoire tampon. */ +static bool g_undef_instruction_load(GUndefInstruction *, GObjectStorage *, packed_buffer_t *); + +/* Sauvegarde un contenu dans une mémoire tampon. */ +static bool g_undef_instruction_store(GUndefInstruction *, GObjectStorage *, packed_buffer_t *); + + + /* ---------------------------------------------------------------------------------- */ /* INSTRUCTION INCONNUE / DONNEES */ /* ---------------------------------------------------------------------------------- */ @@ -115,6 +126,9 @@ static void g_undef_instruction_class_init(GUndefInstructionClass *klass) instr->print = (print_instruction_fc)g_undef_instruction_print; + instr->load = (load_instruction_fc)g_undef_instruction_load; + instr->store = (store_instruction_fc)g_undef_instruction_store; + } @@ -132,7 +146,7 @@ static void g_undef_instruction_class_init(GUndefInstructionClass *klass) static void g_undef_instruction_init(GUndefInstruction *instr) { - INIT_ARCH_INSTR_EXTRA(instr); + GET_UNDEF_INSTR_EXTRA(instr)->behavior = IEB_UNDEFINED; } @@ -190,7 +204,7 @@ static void g_undef_instruction_finalize(GUndefInstruction *instr) GArchInstruction *g_undef_instruction_new(InstrExpectedBehavior behavior) { GArchInstruction *result; /* Instruction à retourner */ - undef_obj_extra *extra; /* Données insérées à modifier */ + undef_extra_data_t *extra; /* Données insérées à modifier */ result = g_object_new(G_TYPE_UNDEF_INSTRUCTION, NULL); @@ -241,7 +255,7 @@ static const char *g_undef_instruction_get_encoding(const GUndefInstruction *ins const char *g_undef_instruction_get_keyword(const GUndefInstruction *instr) { const char *result; /* Désignation à retourner */ - undef_obj_extra *extra; /* Données insérées à consulter*/ + undef_extra_data_t *extra; /* Données insérées à consulter*/ extra = GET_UNDEF_INSTR_EXTRA(instr); @@ -300,7 +314,8 @@ static bool g_undef_instruction_unserialize(GUndefInstruction *instr, GAsmStorag { bool result; /* Bilan à retourner */ GArchInstructionClass *parent; /* Classe parente à consulter */ - undef_obj_extra *extra; /* Données insérées à modifier */ + undef_extra_data_t *extra; /* Données insérées à consulter*/ + uint8_t val; /* Champ de bits manipulé */ parent = G_ARCH_INSTRUCTION_CLASS(g_undef_instruction_parent_class); @@ -310,7 +325,12 @@ static bool g_undef_instruction_unserialize(GUndefInstruction *instr, GAsmStorag { extra = GET_UNDEF_INSTR_EXTRA(instr); - result = extract_packed_buffer(pbuf, &extra->behavior, sizeof(InstrExpectedBehavior), true); + LOCK_GOBJECT_EXTRA(extra); + + result = extract_packed_buffer(pbuf, &val, sizeof(uint8_t), false); + extra->behavior = val; + + UNLOCK_GOBJECT_EXTRA(extra); } @@ -337,7 +357,7 @@ static bool g_undef_instruction_serialize(GUndefInstruction *instr, GAsmStorage { bool result; /* Bilan à retourner */ GArchInstructionClass *parent; /* Classe parente à consulter */ - undef_obj_extra *extra; /* Données insérées à consulter*/ + undef_extra_data_t *extra; /* Données insérées à consulter*/ parent = G_ARCH_INSTRUCTION_CLASS(g_undef_instruction_parent_class); @@ -347,7 +367,11 @@ static bool g_undef_instruction_serialize(GUndefInstruction *instr, GAsmStorage { extra = GET_UNDEF_INSTR_EXTRA(instr); - result = extend_packed_buffer(pbuf, &extra->behavior, sizeof(InstrExpectedBehavior), true); + LOCK_GOBJECT_EXTRA(extra); + + result = extend_packed_buffer(pbuf, (uint8_t []){ extra->behavior }, sizeof(uint8_t), false); + + UNLOCK_GOBJECT_EXTRA(extra); } @@ -417,12 +441,106 @@ static void g_undef_instruction_print(GUndefInstruction *instr, GBufferLine *lin InstrExpectedBehavior g_undef_instruction_get_behavior(const GUndefInstruction *instr) { InstrExpectedBehavior result; /* Comportement à retourner */ - undef_obj_extra *extra; /* Données insérées à consulter*/ + undef_extra_data_t *extra; /* Données insérées à consulter*/ extra = GET_UNDEF_INSTR_EXTRA(instr); + LOCK_GOBJECT_EXTRA(extra); + result = extra->behavior; + UNLOCK_GOBJECT_EXTRA(extra); + + return result; + +} + + + +/* ---------------------------------------------------------------------------------- */ +/* IMPLEMENTATION DES FONCTIONS DE CLASSE */ +/* ---------------------------------------------------------------------------------- */ + + +/****************************************************************************** +* * +* Paramètres : instr = élément GLib à constuire. * +* storage = conservateur de données à manipuler ou NULL. * +* pbuf = zone tampon à lire. * +* * +* Description : Charge un contenu depuis une mémoire tampon. * +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static bool g_undef_instruction_load(GUndefInstruction *instr, GObjectStorage *storage, packed_buffer_t *pbuf) +{ + bool result; /* Bilan à retourner */ + GArchInstructionClass *parent; /* Classe parente à consulter */ + undef_extra_data_t *extra; /* Données insérées à consulter*/ + uint8_t val; /* Champ de bits manipulé */ + + parent = G_ARCH_INSTRUCTION_CLASS(g_undef_instruction_parent_class); + + result = parent->load(G_ARCH_INSTRUCTION(instr), storage, pbuf); + + if (result) + { + extra = GET_UNDEF_INSTR_EXTRA(instr); + + LOCK_GOBJECT_EXTRA(extra); + + result = extract_packed_buffer(pbuf, &val, sizeof(uint8_t), false); + extra->behavior = val; + + UNLOCK_GOBJECT_EXTRA(extra); + + } + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : instr = élément GLib à consulter. * +* storage = conservateur de données à manipuler ou NULL. * +* pbuf = zone tampon à remplir. * +* * +* Description : Sauvegarde un contenu dans une mémoire tampon. * +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static bool g_undef_instruction_store(GUndefInstruction *instr, GObjectStorage *storage, packed_buffer_t *pbuf) +{ + bool result; /* Bilan à retourner */ + GArchInstructionClass *parent; /* Classe parente à consulter */ + undef_extra_data_t *extra; /* Données insérées à consulter*/ + + parent = G_ARCH_INSTRUCTION_CLASS(g_undef_instruction_parent_class); + + result = parent->store(G_ARCH_INSTRUCTION(instr), storage, pbuf); + + if (result) + { + extra = GET_UNDEF_INSTR_EXTRA(instr); + + LOCK_GOBJECT_EXTRA(extra); + + result = extend_packed_buffer(pbuf, (uint8_t []){ extra->behavior }, sizeof(uint8_t), false); + + UNLOCK_GOBJECT_EXTRA(extra); + + } + return result; } |