From 276b75e6e9ff99a930bd36045e55b1117bb29579 Mon Sep 17 00:00:00 2001 From: Cyrille Bagard Date: Mon, 28 Dec 2015 17:56:07 +0100 Subject: Converted ranges length to string. --- ChangeLog | 6 +++++ src/arch/vmpa.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++++-------- src/arch/vmpa.h | 3 +++ 3 files changed, 70 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 37c957a..f1936bb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +15-12-28 Cyrille Bagard + + * src/arch/vmpa.c: + * src/arch/vmpa.h: + Convert ranges length to string. + 15-12-24 Cyrille Bagard * plugins/python/welcome/binary.py: diff --git a/src/arch/vmpa.c b/src/arch/vmpa.c index a289a28..a2430b5 100644 --- a/src/arch/vmpa.c +++ b/src/arch/vmpa.c @@ -38,6 +38,14 @@ +/* ---------------------- DEFINITION D'UNE POSITION EN MEMOIRE ---------------------- */ + + +/* Transforme une position physique en chaîne de caractères. */ +static char *_phys_t_to_string(phys_t, MemoryDataSize, char [VMPA_MAX_LEN], size_t *); + + + /* ---------------------------------------------------------------------------------- */ /* DEFINITION D'UNE POSITION EN MEMOIRE */ /* ---------------------------------------------------------------------------------- */ @@ -366,12 +374,12 @@ bool send_vmpa(const vmpa2t *addr, int fd, int flags) /****************************************************************************** * * -* Paramètres : addr = adresse virtuelle ou physique à traiter. * +* Paramètres : phys = position physique à traiter. * * msize = taille de cette adresse, réelle ou désirée. * * buffer = tampon de sortie utilisé à constituer. [OUT] * * length = transmission de la taille du résultat ou NULL. [OUT]* * * -* Description : Transforme une adresse physique en chaîne de caractères. * +* Description : Transforme une position physique en chaîne de caractères. * * * * Retour : Chaîne de caractères constituée. * * * @@ -379,34 +387,34 @@ bool send_vmpa(const vmpa2t *addr, int fd, int flags) * * ******************************************************************************/ -char *vmpa2_phys_to_string(const vmpa2t *addr, MemoryDataSize msize, char buffer[VMPA_MAX_LEN], size_t *length) +static char *_phys_t_to_string(phys_t phys, MemoryDataSize msize, char buffer[VMPA_MAX_LEN], size_t *length) { size_t ret; /* Retour de l'impression */ - if (addr->physical == VMPA_NO_PHYSICAL) + if (phys == VMPA_NO_PHYSICAL) ret = snprintf(buffer, VMPA_MAX_LEN, _("(none)")); else switch (msize) { case MDS_8_BITS: - ret = snprintf(buffer, VMPA_MAX_LEN,"0x%02" PRIx64, (uint64_t)addr->physical); + ret = snprintf(buffer, VMPA_MAX_LEN,"0x%02" PRIx64, (uint64_t)phys); break; case MDS_16_BITS: - ret = snprintf(buffer, VMPA_MAX_LEN, "0x%04" PRIx64, (uint64_t)addr->physical); + ret = snprintf(buffer, VMPA_MAX_LEN, "0x%04" PRIx64, (uint64_t)phys); break; case MDS_32_BITS: - ret = snprintf(buffer, VMPA_MAX_LEN, "0x%08" PRIx64, (uint64_t)addr->physical); + ret = snprintf(buffer, VMPA_MAX_LEN, "0x%08" PRIx64, (uint64_t)phys); break; case MDS_64_BITS: - ret = snprintf(buffer, VMPA_MAX_LEN, "0x%016" PRIx64, (uint64_t)addr->physical); + ret = snprintf(buffer, VMPA_MAX_LEN, "0x%016" PRIx64, (uint64_t)phys); break; default: - ret = snprintf(buffer, VMPA_MAX_LEN, "0x%" PRIx64, (uint64_t)addr->physical); + ret = snprintf(buffer, VMPA_MAX_LEN, "0x%" PRIx64, (uint64_t)phys); break; } @@ -426,6 +434,28 @@ char *vmpa2_phys_to_string(const vmpa2t *addr, MemoryDataSize msize, char buffer * buffer = tampon de sortie utilisé à constituer. [OUT] * * length = transmission de la taille du résultat ou NULL. [OUT]* * * +* Description : Transforme une adresse physique en chaîne de caractères. * +* * +* Retour : Chaîne de caractères constituée. * +* * +* Remarques : - * +* * +******************************************************************************/ + +char *vmpa2_phys_to_string(const vmpa2t *addr, MemoryDataSize msize, char buffer[VMPA_MAX_LEN], size_t *length) +{ + return _phys_t_to_string(addr->physical, msize, buffer, length); + +} + + +/****************************************************************************** +* * +* Paramètres : addr = adresse virtuelle ou physique à traiter. * +* msize = taille de cette adresse, réelle ou désirée. * +* buffer = tampon de sortie utilisé à constituer. [OUT] * +* length = transmission de la taille du résultat ou NULL. [OUT]* +* * * Description : Transforme une adresse virtuelle en chaîne de caractères. * * * * Retour : Chaîne de caractères constituée. * @@ -1050,3 +1080,25 @@ char *mrange_virt_to_string(const mrange_t *range, MemoryDataSize msize, bool st return buffer; } + + +/****************************************************************************** +* * +* Paramètres : rane = emplacement virtuel ou physique à traiter. * +* msize = taille de cette adresse, réelle ou désirée. * +* buffer = tampon de sortie utilisé à constituer. [OUT] * +* length = transmission de la taille du résultat ou NULL. [OUT]* +* * +* Description : Transforme une taille d'emplacement en chaîne de caractères. * +* * +* Retour : Chaîne de caractères constituée. * +* * +* Remarques : - * +* * +******************************************************************************/ + +char *mrange_length_to_string(const mrange_t *range, MemoryDataSize msize, char buffer[VMPA_MAX_LEN], size_t *length) +{ + return _phys_t_to_string(range->length, msize, buffer, length); + +} diff --git a/src/arch/vmpa.h b/src/arch/vmpa.h index 50a02a2..4470676 100644 --- a/src/arch/vmpa.h +++ b/src/arch/vmpa.h @@ -207,6 +207,9 @@ char *mrange_phys_to_string(const mrange_t *, MemoryDataSize, bool, char [VMPA_M /* Transforme un emplacement virtuel en chaîne de caractères. */ char *mrange_virt_to_string(const mrange_t *, MemoryDataSize, bool, char [VMPA_MAX_LEN], size_t *); +/* Transforme une taille d'emplacement en chaîne de caractères. */ +char *mrange_length_to_string(const mrange_t *, MemoryDataSize, char [VMPA_MAX_LEN], size_t *); + #endif /* _ARCH_VMPA_H */ -- cgit v0.11.2-87-g4458