diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2015-02-09 22:07:42 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2015-02-09 22:07:42 (GMT) |
commit | 1d79469f69bba33a2280d4bd531652b71148029f (patch) | |
tree | e81c094d6e829fb1a79d4c413c1cd162e14868a3 /src/arch | |
parent | 8d326041a0379b87e54be44506d544367567e89b (diff) |
Created a dialog box to create new bookmarks.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@468 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/arch')
-rw-r--r-- | src/arch/vmpa.c | 130 | ||||
-rw-r--r-- | src/arch/vmpa.h | 6 |
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 *); |