From: Peter Xu <peterx@redhat.com>
To: qemu-devel@nongnu.org
Cc: pbonzini@redhat.com, marcandre.lureau@gmail.com, peterx@redhat.com
Subject: [Qemu-devel] [PATCH v2 1/2] memory: provide common macros for mtree_print_mr()
Date: Wed, 21 Dec 2016 15:58:56 +0800 [thread overview]
Message-ID: <1482307137-5106-2-git-send-email-peterx@redhat.com> (raw)
In-Reply-To: <1482307137-5106-1-git-send-email-peterx@redhat.com>
mtree_print_mr() has some common codes. Generalize it.
Reviewed-by: Marc-André Lureau <marcandre.lureau@gmail.com>
Signed-off-by: Peter Xu <peterx@redhat.com>
---
memory.c | 34 +++++++++++++++-------------------
1 file changed, 15 insertions(+), 19 deletions(-)
diff --git a/memory.c b/memory.c
index 33110e9..5dcc2e1 100644
--- a/memory.c
+++ b/memory.c
@@ -2450,6 +2450,13 @@ struct MemoryRegionList {
typedef QTAILQ_HEAD(queue, MemoryRegionList) MemoryRegionListHead;
+#define MR_CHAR_RD(mr) ((mr)->romd_mode ? 'R' : '-')
+#define MR_CHAR_WR(mr) (!(mr)->readonly && !((mr)->rom_device && \
+ (mr)->romd_mode) ? 'W' : '-')
+#define MR_SIZE(size) (int128_nz(size) ? (hwaddr)int128_get64( \
+ int128_sub((size), int128_one())) : 0)
+#define MTREE_INDENT " "
+
static void mtree_print_mr(fprintf_function mon_printf, void *f,
const MemoryRegion *mr, unsigned int level,
hwaddr base,
@@ -2465,7 +2472,7 @@ static void mtree_print_mr(fprintf_function mon_printf, void *f,
}
for (i = 0; i < level; i++) {
- mon_printf(f, " ");
+ mon_printf(f, MTREE_INDENT);
}
if (mr->alias) {
@@ -2488,34 +2495,23 @@ static void mtree_print_mr(fprintf_function mon_printf, void *f,
" (prio %d, %c%c): alias %s @%s " TARGET_FMT_plx
"-" TARGET_FMT_plx "%s\n",
base + mr->addr,
- base + mr->addr
- + (int128_nz(mr->size) ?
- (hwaddr)int128_get64(int128_sub(mr->size,
- int128_one())) : 0),
+ base + mr->addr + MR_SIZE(mr->size),
mr->priority,
- mr->romd_mode ? 'R' : '-',
- !mr->readonly && !(mr->rom_device && mr->romd_mode) ? 'W'
- : '-',
+ MR_CHAR_RD(mr),
+ MR_CHAR_WR(mr),
memory_region_name(mr),
memory_region_name(mr->alias),
mr->alias_offset,
- mr->alias_offset
- + (int128_nz(mr->size) ?
- (hwaddr)int128_get64(int128_sub(mr->size,
- int128_one())) : 0),
+ mr->alias_offset + MR_SIZE(mr->size),
mr->enabled ? "" : " [disabled]");
} else {
mon_printf(f,
TARGET_FMT_plx "-" TARGET_FMT_plx " (prio %d, %c%c): %s%s\n",
base + mr->addr,
- base + mr->addr
- + (int128_nz(mr->size) ?
- (hwaddr)int128_get64(int128_sub(mr->size,
- int128_one())) : 0),
+ base + mr->addr + MR_SIZE(mr->size),
mr->priority,
- mr->romd_mode ? 'R' : '-',
- !mr->readonly && !(mr->rom_device && mr->romd_mode) ? 'W'
- : '-',
+ MR_CHAR_RD(mr),
+ MR_CHAR_WR(mr),
memory_region_name(mr),
mr->enabled ? "" : " [disabled]");
}
--
2.7.4
next prev parent reply other threads:[~2016-12-21 7:59 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-21 7:58 [Qemu-devel] [PATCH v2 0/2] memory: extend "info mtree" with flat view dump Peter Xu
2016-12-21 7:58 ` Peter Xu [this message]
2017-01-11 17:21 ` [Qemu-devel] [PATCH v2 1/2] memory: provide common macros for mtree_print_mr() Paolo Bonzini
2017-01-12 5:50 ` Peter Xu
2017-01-12 8:54 ` Paolo Bonzini
2017-01-12 9:46 ` Peter Xu
2017-01-12 11:19 ` Paolo Bonzini
2017-01-12 13:09 ` Peter Xu
2016-12-21 7:58 ` [Qemu-devel] [PATCH v2 2/2] memory: hmp: dump flat view for 'info mtree' Peter Xu
2017-01-11 17:13 ` Paolo Bonzini
2017-01-12 5:53 ` Peter Xu
2017-01-11 6:20 ` [Qemu-devel] [PATCH v2 0/2] memory: extend "info mtree" with flat view dump Peter Xu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1482307137-5106-2-git-send-email-peterx@redhat.com \
--to=peterx@redhat.com \
--cc=marcandre.lureau@gmail.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).