diff mbox series

[v2,2/9] libpdbg: Enable p10 host backend

Message ID 20211125004138.120917-3-jniethe5@gmail.com
State Accepted
Headers show
Series Add P10 HTM support | expand

Commit Message

Jordan Niethe Nov. 25, 2021, 12:41 a.m. UTC
Signed-off-by: Jordan Niethe <jniethe5@gmail.com>
---
 libpdbg/dtb.c | 16 +++++++++++++++-
 src/main.c    |  8 ++++++++
 2 files changed, 23 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/libpdbg/dtb.c b/libpdbg/dtb.c
index 193b01ad1b38..2b084f74a042 100644
--- a/libpdbg/dtb.c
+++ b/libpdbg/dtb.c
@@ -42,6 +42,7 @@ 
 #include "bmc-kernel.dt.h"
 #include "p8-host.dt.h"
 #include "p9-host.dt.h"
+#include "p10-host.dt.h"
 #include "p8-cronus.dt.h"
 #include "cronus.dt.h"
 #include "bmc-sbefifo.dt.h"
@@ -171,9 +172,15 @@  static void ppc_target(struct pdbg_dtb *dtb)
 				dtb->backend.fdt = &_binary_p9_host_dtb_o_start;
 			if (!dtb->system.fdt)
 				dtb->system.fdt = &_binary_p9_dtb_o_start;
+		} else if (!strcmp(pdbg_backend_option, "p10")) {
+			pdbg_proc = PDBG_PROC_P10;
+			if (!dtb->backend.fdt)
+				dtb->backend.fdt = &_binary_p10_host_dtb_o_start;
+			if (!dtb->system.fdt)
+				dtb->system.fdt = &_binary_p10_dtb_o_start;
 		} else {
 			pdbg_log(PDBG_ERROR, "Invalid system type %s\n", pdbg_backend_option);
-			pdbg_log(PDBG_ERROR, "Use 'p8' or 'p9'\n");
+			pdbg_log(PDBG_ERROR, "Use 'p8' or 'p9' or 'p10'\n");
 		}
 
  		return;
@@ -216,6 +223,13 @@  static void ppc_target(struct pdbg_dtb *dtb)
 			dtb->backend.fdt = &_binary_p9_host_dtb_o_start;
 		if (!dtb->system.fdt)
 			dtb->system.fdt = &_binary_p9_dtb_o_start;
+	} else if (strncmp(pos, "POWER10", 7) == 0) {
+		pdbg_proc = PDBG_PROC_P10;
+		pdbg_log(PDBG_INFO, "Found a POWER10 PPC host system\n");
+		if (!dtb->backend.fdt)
+			dtb->backend.fdt = &_binary_p10_host_dtb_o_start;
+		if (!dtb->system.fdt)
+			dtb->system.fdt = &_binary_p10_dtb_o_start;
 	} else {
 		pdbg_log(PDBG_ERROR, "Unsupported CPU type '%s'\n", pos);
  	}
diff --git a/src/main.c b/src/main.c
index 63eb4075614b..461033e2e317 100644
--- a/src/main.c
+++ b/src/main.c
@@ -205,6 +205,9 @@  out2:
 }
 
 /* Stolen from skiboot */
+#define P10_PIR2GCID(pir) (((pir) >> 8) & 0xf)
+#define P10_PIR2COREID(pir) (((pir) >> 2) & 0x3f)
+#define P10_PIR2THREADID(pir) ((pir) & 0x3)
 #define P9_PIR2GCID(pir) (((pir) >> 8) & 0x7f)
 #define P9_PIR2COREID(pir) (((pir) >> 2) & 0x3f)
 #define P9_PIR2THREADID(pir) ((pir) & 0x3)
@@ -227,6 +230,11 @@  bool pir_map(int pir, int *chip, int *core, int *thread)
 		*core = P8_PIR2COREID(pir);
 		*thread = P8_PIR2THREADID(pir);
 		break;
+	case PDBG_PROC_P10:
+		*chip = P10_PIR2GCID(pir);
+		*core = P10_PIR2COREID(pir);
+		*thread = P10_PIR2THREADID(pir);
+		break;
 	default:
 		PR_ERROR("Unable to determine processor type for mapping to Linux CPU number\n");
 		return false;