[Skiboot] [PATCH v2 2/8] hw/phys-map: Add pvr argument to phys_map_init()

Reza Arbab arbab at linux.ibm.com
Tue Jul 9 07:07:12 AEST 2019


When new chip types are added, phys_map_init() will need to know which
memory map it should use.

Instead of directly checking PVR, make it an argument to the function,
so that 'make hw-check' can test all the maps.

Signed-off-by: Reza Arbab <arbab at linux.ibm.com>
Acked-by: Michael Neuling <mikey at neuling.org>
Reviewed-by: Andrew Donnellan <ajd at linux.ibm.com>
---
 core/init.c              |  2 +-
 hdata/test/hdata_to_dt.c |  2 +-
 hw/phys-map.c            |  2 +-
 hw/test/phys-map-test.c  | 16 ++++++++++++----
 include/phys-map.h       |  2 +-
 5 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/core/init.c b/core/init.c
index d0f28f26d400..9b84a51b91de 100644
--- a/core/init.c
+++ b/core/init.c
@@ -986,7 +986,7 @@ void __noreturn __nomcount main_cpu_entry(const void *fdt)
 	opal_table_init();
 
 	/* Init the physical map table so we can start mapping things */
-	phys_map_init();
+	phys_map_init(mfspr(SPR_PVR));
 
 	/*
 	 * If we are coming in with a flat device-tree, we expand it
diff --git a/hdata/test/hdata_to_dt.c b/hdata/test/hdata_to_dt.c
index 86921778746f..39912a4cbb5a 100644
--- a/hdata/test/hdata_to_dt.c
+++ b/hdata/test/hdata_to_dt.c
@@ -353,7 +353,7 @@ int main(int argc, char *argv[])
 		     "Pipe to 'dtc -I dtb -O dts' for human readable output\n");
 	}
 
-	phys_map_init();
+	phys_map_init(fake_pvr);
 
 	/* Copy in spira dump (assumes little has changed!). */
 	if (new_spira) {
diff --git a/hw/phys-map.c b/hw/phys-map.c
index 75836297c2f9..a55d8dbfda99 100644
--- a/hw/phys-map.c
+++ b/hw/phys-map.c
@@ -200,7 +200,7 @@ error:
 	assert(0);
 }
 
-void phys_map_init(void)
+void phys_map_init(unsigned long pvr)
 {
 	const char *name = "unused";
 
diff --git a/hw/test/phys-map-test.c b/hw/test/phys-map-test.c
index ab75a1e6e0be..9837bf9c7a8c 100644
--- a/hw/test/phys-map-test.c
+++ b/hw/test/phys-map-test.c
@@ -172,15 +172,23 @@ static void check_map_call(void)
 	free(tbl);
 }
 
+/* Fake PVR definitions. See include/processor.h */
+unsigned long fake_pvr[] = {
+	0x004e0200,	/* PVR_P9 */
+};
+
 int main(void)
 {
 	/* Fake we are POWER9 */
 	proc_gen = proc_gen_p9;
-	phys_map_init();
 
-	/* Run tests */
-	check_table_directly();
-	check_map_call();
+	for (int i = 0; i < ARRAY_SIZE(fake_pvr); i++) {
+		phys_map_init(fake_pvr[i]);
+
+		/* Run tests */
+		check_table_directly();
+		check_map_call();
+	}
 
 	return(0);
 }
diff --git a/include/phys-map.h b/include/phys-map.h
index 0cf48b6628af..ba6597d57cde 100644
--- a/include/phys-map.h
+++ b/include/phys-map.h
@@ -59,7 +59,7 @@ enum phys_map_type {
 extern void phys_map_get(uint64_t gcid, enum phys_map_type type,
 			 int index, uint64_t *addr, uint64_t *size);
 
-extern void phys_map_init(void);
+extern void phys_map_init(unsigned long pvr);
 
 #endif /* __PHYS_MAP_H */
 
-- 
1.8.3.1



More information about the Skiboot mailing list