diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/arch/Makefile.am | 5 | ||||
-rw-r--r-- | src/arch/instructions/Makefile.am | 23 | ||||
-rw-r--r-- | src/arch/instructions/undefined-int.h (renamed from src/arch/undefined-int.h) | 53 | ||||
-rw-r--r-- | src/arch/instructions/undefined.c (renamed from src/arch/undefined.c) | 48 | ||||
-rw-r--r-- | src/arch/instructions/undefined.h (renamed from src/arch/undefined.h) | 24 | ||||
-rw-r--r-- | src/core/processors.c | 2 |
6 files changed, 123 insertions, 32 deletions
diff --git a/src/arch/Makefile.am b/src/arch/Makefile.am index e22c1d8..46f78e8 100644 --- a/src/arch/Makefile.am +++ b/src/arch/Makefile.am @@ -23,11 +23,10 @@ libarch_la_SOURCES = \ register.h register.c \ storage.h storage.c \ target.h target.c \ - undefined-int.h \ - undefined.h undefined.c \ vmpa.h vmpa.c libarch_la_LIBADD = \ + instructions/libarchinstructions.la \ operands/libarchoperands.la libarch_la_LDFLAGS = @@ -43,4 +42,4 @@ AM_CPPFLAGS = $(LIBGTK_CFLAGS) $(LIBXML_CFLAGS) AM_CFLAGS = $(DEBUG_CFLAGS) $(WARNING_FLAGS) $(COMPLIANCE_FLAGS) -SUBDIRS = operands +SUBDIRS = instructions operands diff --git a/src/arch/instructions/Makefile.am b/src/arch/instructions/Makefile.am new file mode 100644 index 0000000..c060c7e --- /dev/null +++ b/src/arch/instructions/Makefile.am @@ -0,0 +1,23 @@ + +noinst_LTLIBRARIES = libarchinstructions.la + +libarchinstructions_la_SOURCES = \ + undefined-int.h \ + undefined.h undefined.c + +libarchinstructions_la_LIBADD = + +libarchinstructions_la_LDFLAGS = + + +devdir = $(includedir)/chrysalide/$(subdir:src/%=%) + +dev_HEADERS = $(libarchinstructions_la_SOURCES:%c=) + + +AM_CPPFLAGS = $(LIBGTK_CFLAGS) $(LIBXML_CFLAGS) + +AM_CFLAGS = $(DEBUG_CFLAGS) $(WARNING_FLAGS) $(COMPLIANCE_FLAGS) + + +SUBDIRS = diff --git a/src/arch/undefined-int.h b/src/arch/instructions/undefined-int.h index 0bd3e0c..8a648cf 100644 --- a/src/arch/undefined-int.h +++ b/src/arch/instructions/undefined-int.h @@ -21,24 +21,67 @@ */ -#ifndef _ARCH_UNDEFINED_INT_H -#define _ARCH_UNDEFINED_INT_H +#ifndef _ARCH_INSTRUCTIONS_UNDEFINED_INT_H +#define _ARCH_INSTRUCTIONS_UNDEFINED_INT_H #include "undefined.h" -#include "instruction-int.h" +#include "../instruction-int.h" +#include "../../glibext/objhole.h" +/* Informations glissées dans la structure GObject de GArchInstruction */ +typedef union _undef_obj_extra +{ + struct + { + InstrExpectedBehavior behavior; /* Conséquences réelles */ + + }; + + gint lock; /* Gestion d'accès aux fanions */ + +} undef_obj_extra; + /* Définition générique d'une instruction au comportement non défini (instance) */ struct _GUndefInstruction { GArchInstruction parent; /* A laisser en premier */ - InstrBehaviorStatus status; /* Conséquences réelles */ +#if __SIZEOF_INT__ == __SIZEOF_LONG__ + + /** + * L'inclusion des informations suivantes dépend de l'architecture. + * + * Si la structure GObject possède un trou, on remplit de préférence + * ce dernier. + */ + + undef_obj_extra extra; /* Externalisation embarquée */ + +#endif }; +/** + * Accès aux informations éventuellement déportées. + */ + +#if __SIZEOF_INT__ == __SIZEOF_LONG__ + +# define INIT_UNDEF_INSTR_EXTRA(ins) ins->extra.lock = 0 + +# define GET_UNDEF_INSTR_EXTRA(ins) &ins->extra + +#else + +# define INIT_UNDEF_INSTR_EXTRA(ins) INIT_GOBJECT_EXTRA(G_OBJECT(ins)) + +# define GET_UNDEF_INSTR_EXTRA(ins) GET_GOBJECT_EXTRA(G_OBJECT(ins), undef_obj_extra) + +#endif + /* Définition générique d'une instruction au comportement non défini (classe) */ struct _GUndefInstructionClass { @@ -48,4 +91,4 @@ struct _GUndefInstructionClass -#endif /* _ARCH_UNDEFINED_INT_H */ +#endif /* _ARCH_INSTRUCTIONS_UNDEFINED_INT_H */ diff --git a/src/arch/undefined.c b/src/arch/instructions/undefined.c index e64bffd..da2f73e 100644 --- a/src/arch/undefined.c +++ b/src/arch/instructions/undefined.c @@ -131,6 +131,7 @@ static void g_undef_instruction_class_init(GUndefInstructionClass *klass) static void g_undef_instruction_init(GUndefInstruction *instr) { + INIT_ARCH_INSTR_EXTRA(instr); } @@ -175,7 +176,7 @@ static void g_undef_instruction_finalize(GUndefInstruction *instr) /****************************************************************************** * * -* Paramètres : status = état réel du CPU après le passage de l'instruction. * +* Paramètres : behavior = état réel du CPU après une passe de l'instruction.* * * * Description : Crée une instruction au comportement nominalement indéfini. * * * @@ -185,13 +186,16 @@ static void g_undef_instruction_finalize(GUndefInstruction *instr) * * ******************************************************************************/ -GArchInstruction *g_undef_instruction_new(InstrBehaviorStatus status) +GArchInstruction *g_undef_instruction_new(InstrExpectedBehavior behavior) { GArchInstruction *result; /* Instruction à retourner */ + undef_obj_extra *extra; /* Données insérées à modifier */ result = g_object_new(G_TYPE_UNDEF_INSTRUCTION, NULL); - G_UNDEF_INSTRUCTION(result)->status = status; + extra = GET_UNDEF_INSTR_EXTRA(result); + + extra->behavior = behavior; return result; @@ -236,18 +240,21 @@ 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*/ + + extra = GET_UNDEF_INSTR_EXTRA(instr); - switch (instr->status) + switch (extra->behavior) { - case IBS_NOP: + case IEB_NOP: result = "nop"; break; - case IBS_UNDEFINED: + case IEB_UNDEFINED: result = "undefined"; break; - case IBS_UNPREDICTABLE: + case IEB_UNPREDICTABLE: result = "unpredictable"; break; @@ -288,13 +295,19 @@ 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 */ parent = G_ARCH_INSTRUCTION_CLASS(g_undef_instruction_parent_class); result = parent->unserialize(G_ARCH_INSTRUCTION(instr), storage, format, pbuf); if (result) - result = extract_packed_buffer(pbuf, &instr->status, sizeof(InstrBehaviorStatus), true); + { + extra = GET_UNDEF_INSTR_EXTRA(instr); + + result = extract_packed_buffer(pbuf, &extra->behavior, sizeof(InstrExpectedBehavior), true); + + } return result; @@ -319,13 +332,19 @@ 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*/ parent = G_ARCH_INSTRUCTION_CLASS(g_undef_instruction_parent_class); result = parent->serialize(G_ARCH_INSTRUCTION(instr), storage, pbuf); if (result) - result = extend_packed_buffer(pbuf, &instr->status, sizeof(InstrBehaviorStatus), true); + { + extra = GET_UNDEF_INSTR_EXTRA(instr); + + result = extend_packed_buffer(pbuf, &extra->behavior, sizeof(InstrExpectedBehavior), true); + + } return result; @@ -388,8 +407,15 @@ static void g_undef_instruction_print(GUndefInstruction *instr, GBufferLine *lin * * ******************************************************************************/ -InstrBehaviorStatus g_undef_instruction_get_status(const GUndefInstruction *instr) +InstrExpectedBehavior g_undef_instruction_get_behavior(const GUndefInstruction *instr) { - return instr->status; + InstrExpectedBehavior result; /* Comportement à retourner */ + undef_obj_extra *extra; /* Données insérées à consulter*/ + + extra = GET_UNDEF_INSTR_EXTRA(instr); + + result = extra->behavior; + + return result; } diff --git a/src/arch/undefined.h b/src/arch/instructions/undefined.h index 1b32fb9..5aa9bec 100644 --- a/src/arch/undefined.h +++ b/src/arch/instructions/undefined.h @@ -21,15 +21,15 @@ */ -#ifndef _ARCH_UNDEFINED_H -#define _ARCH_UNDEFINED_H +#ifndef _ARCH_INSTRUCTIONS_UNDEFINED_H +#define _ARCH_INSTRUCTIONS_UNDEFINED_H #include <glib-object.h> -#include "instruction.h" -#include "vmpa.h" +#include "../instruction.h" +#include "../vmpa.h" @@ -49,24 +49,24 @@ typedef struct _GUndefInstructionClass GUndefInstructionClass; /* Etat précis de l'instruction */ -typedef enum _InstrBehaviorStatus +typedef enum _InstrExpectedBehavior { - IBS_NOP, - IBS_UNDEFINED, - IBS_UNPREDICTABLE, + IEB_NOP, + IEB_UNDEFINED, + IEB_UNPREDICTABLE, -} InstrBehaviorStatus; +} InstrExpectedBehavior; /* Indique le type défini pour une instruction au comportement non défini. */ GType g_undef_instruction_get_type(void); /* Crée une instruction au comportement nominalement indéfini. */ -GArchInstruction *g_undef_instruction_new(InstrBehaviorStatus); +GArchInstruction *g_undef_instruction_new(InstrExpectedBehavior); /* Indique le type de conséquences réél de l'instruction. */ -InstrBehaviorStatus g_undef_instruction_get_status(const GUndefInstruction *); +InstrExpectedBehavior g_undef_instruction_get_behavior(const GUndefInstruction *); -#endif /* _ARCH_UNDEFINED_H */ +#endif /* _ARCH_INSTRUCTIONS_UNDEFINED_H */ diff --git a/src/core/processors.c b/src/core/processors.c index c6f3f8a..c03b98f 100644 --- a/src/core/processors.c +++ b/src/core/processors.c @@ -31,7 +31,7 @@ #include "../arch/raw.h" #include "../arch/target.h" -#include "../arch/undefined.h" +#include "../arch/instructions/undefined.h" #include "../arch/operands/immediate.h" #include "../arch/operands/register.h" |