summaryrefslogtreecommitdiff
path: root/src/arch
diff options
context:
space:
mode:
Diffstat (limited to 'src/arch')
-rw-r--r--src/arch/processor-int.h27
-rw-r--r--src/arch/processor.c48
-rw-r--r--src/arch/processor.h2
3 files changed, 58 insertions, 19 deletions
diff --git a/src/arch/processor-int.h b/src/arch/processor-int.h
index 34ba66a..6187ff0 100644
--- a/src/arch/processor-int.h
+++ b/src/arch/processor-int.h
@@ -36,6 +36,18 @@
/* Fournit la désignation interne du processeur d'architecture. */
typedef char * (* get_processor_key_fc) (const GArchProcessor *);
+/* Fournit le nom humain de l'architecture visée. */
+typedef char * (* get_processor_desc_fc) (const GArchProcessor *);
+
+/* Fournit la taille de l'espace mémoire d'une architecture. */
+typedef MemoryDataSize (* get_processor_memsize_fc) (const GArchProcessor *);
+
+/* Fournit la taille min. des instructions d'une architecture. */
+typedef MemoryDataSize (* get_processor_inssize_fc) (const GArchProcessor *);
+
+/* Indique si l'architecture possède un espace virtuel ou non. */
+typedef bool (* has_processor_vspace_fc) (const GArchProcessor *);
+
/* Fournit un contexte propre au processeur d'une architecture. */
typedef GProcContext * (* get_processor_context_fc) (const GArchProcessor *);
@@ -69,6 +81,8 @@ struct _GArchProcessor
{
GObject parent; /* A laisser en premier */
+ SourceEndian endianness; /* Boutisme de l'architecture */
+
GArchInstruction **instructions; /* Instructions désassemblées */
size_t instr_count; /* Taille de la liste aplatie */
unsigned int stamp; /* Marque de suivi des modifs */
@@ -95,16 +109,13 @@ struct _GArchProcessorClass
{
GObjectClass parent; /* A laisser en premier */
- const char *desc; /* Description humaine liée */
-
- SourceEndian endianness; /* Boutisme de l'architecture */
- MemoryDataSize memsize; /* Taille de l'espace mémoire */
- MemoryDataSize inssize; /* Taille min. d'encodage */
- bool virt_space; /* Présence d'espace virtuel ? */
-
get_processor_key_fc get_key; /* Code représentant la classe */
- get_processor_context_fc get_ctx; /* Obtention d'un contexte */
+ get_processor_desc_fc get_desc; /* Description humaine */
+ get_processor_memsize_fc get_memsize; /* Taille d'un mot classique */
+ get_processor_inssize_fc get_inssize; /* Taille minimale d'instruct° */
+ has_processor_vspace_fc has_vspace; /* Présence d'un espace virtuel*/
+ get_processor_context_fc get_ctx; /* Obtention d'un contexte */
disass_instr_fc disassemble; /* Traduction en instructions */
/* Signaux */
diff --git a/src/arch/processor.c b/src/arch/processor.c
index 7dbd8eb..59af6cd 100644
--- a/src/arch/processor.c
+++ b/src/arch/processor.c
@@ -290,7 +290,10 @@ char *g_arch_processor_get_key(const GArchProcessor *proc)
class = G_ARCH_PROCESSOR_GET_CLASS(proc);
if (class->get_key == NULL)
+ {
+ assert(false);
result = NULL;
+ }
else
result = class->get_key(proc);
@@ -312,14 +315,21 @@ char *g_arch_processor_get_key(const GArchProcessor *proc)
* *
******************************************************************************/
-const char *g_arch_processor_get_desc(const GArchProcessor *proc)
+char *g_arch_processor_get_desc(const GArchProcessor *proc)
{
- const char *result; /* Désignation à renvoyer */
+ char *result; /* Désignation à renvoyer */
GArchProcessorClass *class; /* Classe de l'instance */
class = G_ARCH_PROCESSOR_GET_CLASS(proc);
- result = class->desc;
+ if (class->get_desc == NULL)
+ {
+ assert(false);
+ result = NULL;
+ }
+
+ else
+ result = class->get_desc(proc);
return result;
@@ -341,11 +351,8 @@ const char *g_arch_processor_get_desc(const GArchProcessor *proc)
SourceEndian g_arch_processor_get_endianness(const GArchProcessor *proc)
{
SourceEndian result; /* Boutisme à retourner */
- GArchProcessorClass *class; /* Classe de l'instance */
- class = G_ARCH_PROCESSOR_GET_CLASS(proc);
-
- result = class->endianness;
+ result = proc->endianness;
return result;
@@ -371,7 +378,14 @@ MemoryDataSize g_arch_processor_get_memory_size(const GArchProcessor *proc)
class = G_ARCH_PROCESSOR_GET_CLASS(proc);
- result = class->memsize;
+ if (class->get_memsize == NULL)
+ {
+ assert(false);
+ result = MDS_UNDEFINED;
+ }
+
+ else
+ result = class->get_memsize(proc);
return result;
@@ -397,7 +411,14 @@ MemoryDataSize g_arch_processor_get_instruction_min_size(const GArchProcessor *p
class = G_ARCH_PROCESSOR_GET_CLASS(proc);
- result = class->inssize;
+ if (class->get_inssize == NULL)
+ {
+ assert(false);
+ result = MDS_UNDEFINED;
+ }
+
+ else
+ result = class->get_inssize(proc);
return result;
@@ -423,7 +444,14 @@ bool g_arch_processor_has_virtual_space(const GArchProcessor *proc)
class = G_ARCH_PROCESSOR_GET_CLASS(proc);
- result = class->virt_space;
+ if (class->has_vspace == NULL)
+ {
+ assert(false);
+ result = false;
+ }
+
+ else
+ result = class->has_vspace(proc);
return result;
diff --git a/src/arch/processor.h b/src/arch/processor.h
index 7edf341..b88fa6f 100644
--- a/src/arch/processor.h
+++ b/src/arch/processor.h
@@ -59,7 +59,7 @@ GType g_arch_processor_get_type(void);
char *g_arch_processor_get_key(const GArchProcessor *);
/* Fournit le nom humain de l'architecture visée. */
-const char *g_arch_processor_get_desc(const GArchProcessor *);
+char *g_arch_processor_get_desc(const GArchProcessor *);
/* Fournit le boustime du processeur d'une architecture. */
SourceEndian g_arch_processor_get_endianness(const GArchProcessor *);