[Skiboot] [PATCH 2/2] hdata/test: Add memory reservations to hdata_to_dt
Oliver O'Halloran
oohall at gmail.com
Fri May 26 16:28:39 AEST 2017
Currently memory reservations are parsed, but since they are not
processed until mem_region_init() they don't appear in the output
device tree blob. Several bugs have been found with memory reservations
so we want them to be part of the test output.
Add them and clean up several usages of printf() since we want only the
dtb to appear in standard out.
Signed-off-by: Oliver O'Halloran <oohall at gmail.com>
---
core/mem_region.c | 22 +++++++++++-----------
hdata/test/hdata_to_dt.c | 10 ++++++++++
hdata/test/stubs.c | 20 +++++++++++++-------
3 files changed, 34 insertions(+), 18 deletions(-)
diff --git a/core/mem_region.c b/core/mem_region.c
index 57d20955cd86..cdb6b96e18ce 100644
--- a/core/mem_region.c
+++ b/core/mem_region.c
@@ -291,23 +291,23 @@ void mem_dump_allocs(void)
struct alloc_hdr *hdr;
/* Second pass: populate property data */
- printf("Memory regions:\n");
+ prlog(PR_INFO, "Memory regions:\n");
list_for_each(®ions, region, list) {
if (!(region->type == REGION_SKIBOOT_HEAP ||
region->type == REGION_MEMORY))
continue;
- printf(" 0x%012llx..%012llx : %s\n",
+ prlog(PR_INFO, " 0x%012llx..%012llx : %s\n",
(long long)region->start,
(long long)(region->start + region->len - 1),
region->name);
if (region->free_list.n.next == NULL) {
- printf(" no allocs\n");
+ prlog(PR_INFO, " no allocs\n");
continue;
}
for (hdr = region_start(region); hdr; hdr = next_hdr(region, hdr)) {
if (hdr->free)
continue;
- printf(" 0x%.8lx %s\n", hdr->num_longs * sizeof(long),
+ prlog(PR_INFO, " 0x%.8lx %s\n", hdr->num_longs * sizeof(long),
hdr_location(hdr));
}
}
@@ -322,7 +322,7 @@ int64_t mem_dump_free(void)
total_free = 0;
- printf("Free space in HEAP memory regions:\n");
+ prlog(PR_INFO, "Free space in HEAP memory regions:\n");
list_for_each(®ions, region, list) {
if (!(region->type == REGION_SKIBOOT_HEAP ||
region->type == REGION_MEMORY))
@@ -338,12 +338,12 @@ int64_t mem_dump_free(void)
region_free+= hdr->num_longs * sizeof(long);
}
- printf("Region %s free: %"PRIx64"\n",
+ prlog(PR_INFO, "Region %s free: %"PRIx64"\n",
region->name, region_free);
total_free += region_free;
}
- printf("Total free: %"PRIu64"\n", total_free);
+ prlog(PR_INFO, "Total free: %"PRIu64"\n", total_free);
return total_free;
}
@@ -1106,7 +1106,7 @@ void mem_region_release_unused(void)
lock(&mem_region_lock);
assert(!mem_regions_finalised);
- printf("Releasing unused memory:\n");
+ prlog(PR_INFO, "Releasing unused memory:\n");
list_for_each(®ions, r, list) {
uint64_t used_len;
@@ -1117,7 +1117,7 @@ void mem_region_release_unused(void)
used_len = allocated_length(r);
- printf(" %s: %llu/%llu used\n",
+ prlog(PR_INFO, " %s: %llu/%llu used\n",
r->name, (long long)used_len, (long long)r->len);
/* We keep the skiboot heap. */
@@ -1221,7 +1221,7 @@ void mem_region_add_dt_reserved(void)
name = names = malloc(names_len);
range = ranges = malloc(ranges_len);
- printf("Reserved regions:\n");
+ prlog(PR_INFO, "Reserved regions:\n");
/* Second pass: populate property data */
list_for_each(®ions, region, list) {
if (!region_is_reservable(region))
@@ -1230,7 +1230,7 @@ void mem_region_add_dt_reserved(void)
memcpy(name, region->name, len);
name += len;
- printf(" 0x%012llx..%012llx : %s\n",
+ prlog(PR_INFO, " 0x%012llx..%012llx : %s\n",
(long long)region->start,
(long long)(region->start + region->len - 1),
region->name);
diff --git a/hdata/test/hdata_to_dt.c b/hdata/test/hdata_to_dt.c
index e8b7ed66242e..3568eb6ceb10 100644
--- a/hdata/test/hdata_to_dt.c
+++ b/hdata/test/hdata_to_dt.c
@@ -67,6 +67,7 @@ unsigned long tb_hz = 512000000;
#define __CPU_H
struct cpu_thread {
uint32_t pir;
+ uint32_t chip_id;
};
struct cpu_thread __boot_cpu, *boot_cpu = &__boot_cpu;
@@ -94,6 +95,11 @@ struct dt_node *add_ics_node(void)
static bool spira_check_ptr(const void *ptr, const char *file, unsigned int line);
+/* should probably check this */
+#define BITS_PER_LONG 64
+/* not used, just needs to exist */
+#define cpu_max_pir 0x7
+
#include "../cpu-common.c"
#include "../fsp.c"
#include "../hdif.c"
@@ -113,6 +119,7 @@ static bool spira_check_ptr(const void *ptr, const char *file, unsigned int line
#include "../../test/dt_common.c"
#include "../../core/fdt.c"
#include "../../hw/phys-map.c"
+#include "../../core/mem_region.c"
#include <err.h>
@@ -335,6 +342,9 @@ int main(int argc, char *argv[])
exit(EXIT_FAILURE);
}
+ mem_region_init();
+ mem_region_release_unused();
+
if (!blobs)
squash_blobs(dt_root);
diff --git a/hdata/test/stubs.c b/hdata/test/stubs.c
index 0777730f418c..169d3f0eece9 100644
--- a/hdata/test/stubs.c
+++ b/hdata/test/stubs.c
@@ -23,8 +23,6 @@
#include "../../ccan/list/list.c"
-unsigned long top_of_ram = 16ULL * 1024 * 1024 * 1024;
-
void _prlog(int log_level __attribute__((unused)), const char* fmt, ...) __attribute__((format (printf, 2, 3)));
#ifndef pr_fmt
@@ -102,9 +100,17 @@ STUB(fsp_adjust_lid_side);
STUB(backtrace);
/* Add HW specific stubs here */
-static void noop_function(void) {}
-#define NOOP_STUB(fnname) \
- void fnname(void) __attribute__((weak, alias ("noop_function")))
-
+static bool true_stub(void) { return true; }
+static bool false_stub(void) { return false; }
+
+#define TRUE_STUB(fnname) \
+ void fnname(void) __attribute__((weak, alias ("true_stub")))
+#define FALSE_STUB(fnname) \
+ void fnname(void) __attribute__((weak, alias ("false_stub")))
+#define NOOP_STUB FALSE_STUB
+
+TRUE_STUB(lock_held_by_me);
+NOOP_STUB(lock);
+NOOP_STUB(unlock);
NOOP_STUB(early_uart_init);
-NOOP_STUB(mem_reserve_hw);
+NOOP_STUB(add_chip_dev_associativity);
--
2.9.3
More information about the Skiboot
mailing list