Skip to content

Commit 8d033da

Browse files
committed
[COMMANDS] Fixed prints on xxx_addr_t and xxx_size_t to handle both 32bit and 64bit values.
Signed-off-by: Anup Patel <[email protected]>
1 parent 5a37d9b commit 8d033da

File tree

3 files changed

+29
-9
lines changed

3 files changed

+29
-9
lines changed

commands/cmd_devtree.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ void cmd_devtree_print_attribute(struct vmm_chardev *cdev,
8989
vmm_cprintf(cdev, " ");
9090
}
9191
if (sizeof(u64) == sizeof(physical_addr_t)) {
92-
vmm_cprintf(cdev, "0x%llx",
92+
vmm_cprintf(cdev, "0x%llxULL",
9393
((physical_addr_t *)attr->value)[i >> 3]);
9494
} else {
9595
vmm_cprintf(cdev, "0x%x",
@@ -104,7 +104,7 @@ void cmd_devtree_print_attribute(struct vmm_chardev *cdev,
104104
vmm_cprintf(cdev, " ");
105105
}
106106
if (sizeof(u64) == sizeof(physical_size_t)) {
107-
vmm_cprintf(cdev, "0x%llx",
107+
vmm_cprintf(cdev, "0x%llxULL",
108108
((physical_size_t *)attr->value)[i >> 3]);
109109
} else {
110110
vmm_cprintf(cdev, "0x%x",
@@ -119,7 +119,7 @@ void cmd_devtree_print_attribute(struct vmm_chardev *cdev,
119119
vmm_cprintf(cdev, " ");
120120
}
121121
if (sizeof(u64) == sizeof(virtual_addr_t)) {
122-
vmm_cprintf(cdev, "0x%llx",
122+
vmm_cprintf(cdev, "0x%llxULL",
123123
((virtual_addr_t *)attr->value)[i >> 3]);
124124
} else {
125125
vmm_cprintf(cdev, "0x%x",
@@ -134,7 +134,7 @@ void cmd_devtree_print_attribute(struct vmm_chardev *cdev,
134134
vmm_cprintf(cdev, " ");
135135
}
136136
if (sizeof(u64) == sizeof(virtual_size_t)) {
137-
vmm_cprintf(cdev, "0x%llx",
137+
vmm_cprintf(cdev, "0x%llxULL",
138138
((virtual_size_t *)attr->value)[i >> 3]);
139139
} else {
140140
vmm_cprintf(cdev, "0x%x",

commands/cmd_guest.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ int cmd_guest_exec(struct vmm_chardev *cdev, int argc, char **argv)
416416
}
417417
src_addr = (physical_addr_t)vmm_str2ulonglong(argv[3], 10);
418418
if (argc > 4)
419-
size = (physical_size_t)vmm_str2uint(argv[4], 10);
419+
size = (physical_size_t)vmm_str2ulonglong(argv[4], 10);
420420
else
421421
size = 64;
422422
return cmd_guest_dumpmem(cdev, id, src_addr, size);

commands/cmd_host.c

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,11 @@ void cmd_host_ram_stats(struct vmm_chardev *cdev)
8484
u32 free = vmm_host_ram_free_frame_count();
8585
u32 total = vmm_host_ram_total_frame_count();
8686
physical_addr_t base = vmm_host_ram_base();
87-
vmm_cprintf(cdev, "Base Address : 0x%08x\n", base);
87+
if (sizeof(u64) == sizeof(physical_addr_t)) {
88+
vmm_cprintf(cdev, "Base Address : 0x%016llx\n", base);
89+
} else {
90+
vmm_cprintf(cdev, "Base Address : 0x%08x\n", base);
91+
}
8892
vmm_cprintf(cdev, "Frame Size : %d (0x%08x)\n",
8993
VMM_PAGE_SIZE, VMM_PAGE_SIZE);
9094
vmm_cprintf(cdev, "Free Frames : %d (0x%08x)\n", free, free);
@@ -99,7 +103,13 @@ void cmd_host_ram_bitmap(struct vmm_chardev *cdev, int colcnt)
99103
vmm_cprintf(cdev, "1 : used");
100104
for (ite = 0; ite < total; ite++) {
101105
if (vmm_umod32(ite, colcnt) == 0) {
102-
vmm_cprintf(cdev, "\n0x%08x: ", base + ite * VMM_PAGE_SIZE);
106+
if (sizeof(u64) == sizeof(physical_addr_t)) {
107+
vmm_cprintf(cdev, "\n0x%016llx: ",
108+
base + ite * VMM_PAGE_SIZE);
109+
} else {
110+
vmm_cprintf(cdev, "\n0x%08x: ",
111+
base + ite * VMM_PAGE_SIZE);
112+
}
103113
}
104114
if (vmm_host_ram_frame_isfree(base + ite * VMM_PAGE_SIZE)) {
105115
vmm_cprintf(cdev, "0");
@@ -115,7 +125,11 @@ void cmd_host_vapool_stats(struct vmm_chardev *cdev)
115125
u32 free = vmm_host_vapool_free_page_count();
116126
u32 total = vmm_host_vapool_total_page_count();
117127
virtual_addr_t base = vmm_host_vapool_base();
118-
vmm_cprintf(cdev, "Base Address : 0x%08x\n", base);
128+
if (sizeof(u64) == sizeof(virtual_addr_t)) {
129+
vmm_cprintf(cdev, "Base Address : 0x%016llx\n", base);
130+
} else {
131+
vmm_cprintf(cdev, "Base Address : 0x%08x\n", base);
132+
}
119133
vmm_cprintf(cdev, "Page Size : %d (0x%08x)\n",
120134
VMM_PAGE_SIZE, VMM_PAGE_SIZE);
121135
vmm_cprintf(cdev, "Free Pages : %d (0x%08x)\n", free, free);
@@ -130,7 +144,13 @@ void cmd_host_vapool_bitmap(struct vmm_chardev *cdev, int colcnt)
130144
vmm_cprintf(cdev, "1 : used");
131145
for (ite = 0; ite < total; ite++) {
132146
if (vmm_umod32(ite, colcnt) == 0) {
133-
vmm_cprintf(cdev, "\n0x%08x: ", base + ite * VMM_PAGE_SIZE);
147+
if (sizeof(u64) == sizeof(virtual_addr_t)) {
148+
vmm_cprintf(cdev, "\n0x%016llx: ",
149+
base + ite * VMM_PAGE_SIZE);
150+
} else {
151+
vmm_cprintf(cdev, "\n0x%08x: ",
152+
base + ite * VMM_PAGE_SIZE);
153+
}
134154
}
135155
if (vmm_host_vapool_page_isfree(base + ite * VMM_PAGE_SIZE)) {
136156
vmm_cprintf(cdev, "0");

0 commit comments

Comments
 (0)