From e7f76b4eb58c6230ce1ffd143f1c8a5a507bdbe9 Mon Sep 17 00:00:00 2001 From: Reza Arbab Date: Wed, 17 Jul 2019 15:44:20 -0500 Subject: hw/phys-map: Add pvr argument to phys_map_init() 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 Acked-by: Michael Neuling Reviewed-by: Andrew Donnellan Acked-by: Stewart Smith Signed-off-by: Oliver O'Halloran --- 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 2c77c15..7fa2fb6 100644 --- a/core/init.c +++ b/core/init.c @@ -982,7 +982,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 56c0429..2c8de61 100644 --- a/hdata/test/hdata_to_dt.c +++ b/hdata/test/hdata_to_dt.c @@ -344,7 +344,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 53b825d..de93bc7 100644 --- a/hw/phys-map.c +++ b/hw/phys-map.c @@ -191,7 +191,7 @@ error: assert(0); } -void phys_map_init(void) +void phys_map_init(unsigned long pvr __unused) { const char *name = "unused"; diff --git a/hw/test/phys-map-test.c b/hw/test/phys-map-test.c index 3356919..8d844ba 100644 --- a/hw/test/phys-map-test.c +++ b/hw/test/phys-map-test.c @@ -163,15 +163,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 6fd8cf5..4e694f6 100644 --- a/include/phys-map.h +++ b/include/phys-map.h @@ -46,7 +46,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 */ -- cgit v1.1