summaryrefslogtreecommitdiff
path: root/src/arch
diff options
context:
space:
mode:
Diffstat (limited to 'src/arch')
-rw-r--r--src/arch/vmpa.c130
-rw-r--r--src/arch/vmpa.h6
2 files changed, 118 insertions, 18 deletions
diff --git a/src/arch/vmpa.c b/src/arch/vmpa.c
index 46d1a04..c479319 100644
--- a/src/arch/vmpa.c
+++ b/src/arch/vmpa.c
@@ -26,6 +26,7 @@
#include <inttypes.h>
#include <malloc.h>
+#include <sqlite3.h>
#include <stdlib.h>
#include <string.h>
@@ -356,29 +357,33 @@ char *vmpa2_phys_to_string(const vmpa2t *addr, MemoryDataSize msize, char buffer
{
size_t ret; /* Retour de l'impression */
- switch (msize)
- {
- case MDS_8_BITS:
- ret = snprintf(buffer, VMPA_MAX_LEN,"0x%02" PRIx64, (uint64_t)addr->physical);
- break;
+ if (addr->physical == VMPA_NO_PHYSICAL)
+ ret = snprintf(buffer, VMPA_MAX_LEN, _("(none)"));
- case MDS_16_BITS:
- ret = snprintf(buffer, VMPA_MAX_LEN, "0x%04" PRIx64, (uint64_t)addr->physical);
- break;
+ else
+ switch (msize)
+ {
+ case MDS_8_BITS:
+ ret = snprintf(buffer, VMPA_MAX_LEN,"0x%02" PRIx64, (uint64_t)addr->physical);
+ break;
- case MDS_32_BITS:
- ret = snprintf(buffer, VMPA_MAX_LEN, "0x%08" PRIx64, (uint64_t)addr->physical);
- break;
+ case MDS_16_BITS:
+ ret = snprintf(buffer, VMPA_MAX_LEN, "0x%04" PRIx64, (uint64_t)addr->physical);
+ break;
- case MDS_64_BITS:
- ret = snprintf(buffer, VMPA_MAX_LEN, "0x%016" PRIx64, (uint64_t)addr->physical);
- break;
+ case MDS_32_BITS:
+ ret = snprintf(buffer, VMPA_MAX_LEN, "0x%08" PRIx64, (uint64_t)addr->physical);
+ break;
- default:
- ret = snprintf(buffer, VMPA_MAX_LEN, "0x%" PRIx64, (uint64_t)addr->physical);
- break;
+ case MDS_64_BITS:
+ ret = snprintf(buffer, VMPA_MAX_LEN, "0x%016" PRIx64, (uint64_t)addr->physical);
+ break;
- }
+ default:
+ ret = snprintf(buffer, VMPA_MAX_LEN, "0x%" PRIx64, (uint64_t)addr->physical);
+ break;
+
+ }
if (length != NULL)
*length = ret;
@@ -491,6 +496,95 @@ vmpa2t *string_to_vmpa_virt(const char *buffer)
/******************************************************************************
* *
+* Paramètres : addr = localisation dont la définition est à consulter. *
+* values = tableau d'éléments à compléter. [OUT] *
+* count = nombre de descriptions renseignées. [OUT] *
+* *
+* Description : Décrit les colonnes utiles à un chargement de données. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool setup_load_for_vmpa(const vmpa2t *addr, bound_value **values, size_t *count)
+{
+ (*count) += 2;
+
+ *values = (bound_value *)realloc(*values, (*count) * sizeof(bound_value));
+
+ (*values)[*count - 2].name = "phys";
+ (*values)[*count - 1].name = "virt";
+
+ return true;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : addr = localisation dont la définition est à définir. *
+* values = tableau d'éléments à consulter. *
+* count = nombre de descriptions renseignées. *
+* *
+* Description : Charge les valeurs utiles pour une localisation. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool load_vmpa(vmpa2t *addr, const bound_value *values, size_t count)
+{
+ const bound_value *value; /* Valeur à intégrer */
+
+ value = find_bound_value(values, count, "phys");
+ if (value == NULL) return false;
+
+ switch (value->type)
+ {
+ case SQLITE_INT64:
+ addr->physical = value->integer64;
+ break;
+
+ case SQLITE_NULL:
+ addr->physical = VMPA_NO_PHYSICAL;
+ break;
+
+ default:
+ return false;
+ break;
+
+ }
+
+ value = find_bound_value(values, count, "virt");
+ if (value == NULL) return false;
+
+ switch (value->type)
+ {
+ case SQLITE_INT64:
+ addr->virtual = value->integer64;
+ break;
+
+ case SQLITE_NULL:
+ addr->virtual = VMPA_NO_VIRTUAL;
+ break;
+
+ default:
+ return false;
+ break;
+
+ }
+
+ return true;
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : addr = adresse virtuelle ou physique à traiter. *
* create = indique si la préparation vise une création ou non. *
* values = couples de champs et de valeurs à lier. [OUT] *
diff --git a/src/arch/vmpa.h b/src/arch/vmpa.h
index 97b2610..ec356c8 100644
--- a/src/arch/vmpa.h
+++ b/src/arch/vmpa.h
@@ -126,6 +126,12 @@ vmpa2t *string_to_vmpa_virt(const char *);
"phys INTEGER, " \
"virt INTEGER, "
+/* Décrit les colonnes utiles à un chargement de données. */
+bool setup_load_for_vmpa(const vmpa2t *, bound_value **, size_t *);
+
+/* Charge les valeurs utiles pour une localisation. */
+bool load_vmpa(vmpa2t *, const bound_value *, size_t);
+
/* Constitue les champs destinés à une insertion / modification. */
bool prepare_vmpa_db_statement(const vmpa2t *, bool, bound_value **, size_t *);