[Skiboot] [PATCH 1/2] hw/phys_map: Use raw chip IDs

Oliver O'Halloran oohall at gmail.com
Tue May 16 19:03:20 AEST 2017


We need to be able to query the BAR mapping from the HDAT parser which
is run prior the the proc_chip structures being initialised. Define
a wrapper for the existing usages and provide a low-level function
that allows the map the be queried with the global hardware chip ID
itself.

Cc: Michael Neuling <mikey at neuling.org>
Signed-off-by: Oliver O'Halloran <oohall at gmail.com>
---
 hw/phys-map.c      |  9 +++++----
 include/phys-map.h | 11 ++++++++++-
 2 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/hw/phys-map.c b/hw/phys-map.c
index 768f464f4682..65c440178283 100644
--- a/hw/phys-map.c
+++ b/hw/phys-map.c
@@ -134,10 +134,11 @@ static inline bool phys_map_entry_null(const struct phys_map_entry *e)
 	return false;
 }
 
+
 /* This crashes skiboot on error as any bad calls here are almost
  *  certainly a developer error
  */
-void phys_map_get(struct proc_chip *chip, enum phys_map_type type,
+void __phys_map_get(uint64_t gcid, enum phys_map_type type,
 		  int index, uint64_t *addr, uint64_t *size) {
 	const struct phys_map_entry *e;
 	uint64_t a;
@@ -162,16 +163,16 @@ void phys_map_get(struct proc_chip *chip, enum phys_map_type type,
 		break;
 	}
 	a = e->addr;
-	a += (uint64_t)chip->id << phys_map->chip_select_shift;
+	a += gcid << phys_map->chip_select_shift;
 
 	if (addr)
 		*addr = a;
 	if (size)
 		*size = e->size;
 
-	prlog(PR_TRACE, "Assigning BAR [%x] type:%02i index:%x "
+	prlog(PR_TRACE, "Assigning BAR [%"PRIx64"] type:%02i index:%x "
 	      "0x%016"PRIx64" for 0x%016"PRIx64"\n",
-	      chip->id, type, index, a, e->size);
+	      gcid, type, index, a, e->size);
 
 	return;
 
diff --git a/include/phys-map.h b/include/phys-map.h
index a0124322a608..5738a5456900 100644
--- a/include/phys-map.h
+++ b/include/phys-map.h
@@ -53,9 +53,18 @@ enum phys_map_type {
 	RESV
 };
 
-extern void phys_map_get(struct proc_chip *chip, enum phys_map_type type,
+/*
+ * Use this to query the phys map before we've done per-cpu init.
+ */
+extern void __phys_map_get(uint64_t gcid, enum phys_map_type type,
 			 int index, uint64_t *addr, uint64_t *size);
 
+static inline void phys_map_get(struct proc_chip *chip, enum phys_map_type type,
+			 int index, uint64_t *addr, uint64_t *size)
+{
+	__phys_map_get(chip->id, type, index, addr, size);
+}
+
 extern void phys_map_init(void);
 
 #endif /* __PHYS_MAP_H */
-- 
2.9.3



More information about the Skiboot mailing list