[Pdbg] [PATCH] src/main.c: Add detection of host type for kernel backend
Alistair Popple
alistair at popple.id.au
Wed Sep 12 14:15:03 AEST 2018
Signed-off-by: Alistair Popple <alistair at popple.id.au>
---
src/main.c | 40 ++++++++++++++++++++++++++++++++++++++--
1 file changed, 38 insertions(+), 2 deletions(-)
diff --git a/src/main.c b/src/main.c
index 883e892..79f67a5 100644
--- a/src/main.c
+++ b/src/main.c
@@ -52,6 +52,8 @@
#include "p9r-fsi.dt.h"
#include "p9z-fsi.dt.h"
#include "p9-kernel.dt.h"
+
+#define FSI_CFAM_ID "/sys/devices/platform/gpio-fsi/fsi0/slave at 00:00/cfam_id"
#endif
#ifdef TARGET_PPC
@@ -59,6 +61,10 @@
#include "p9-host.dt.h"
#endif
+#define CHIP_ID_P8 0xea
+#define CHIP_ID_P9 0xd1
+#define CHIP_ID_P8P 0xd3
+
#define THREADS_PER_CORE 8
static enum backend backend = KERNEL;
@@ -629,9 +635,39 @@ static int target_selection(void)
case KERNEL:
if (device_node == NULL) {
- PR_ERROR("kernel backend requires a device type\n");
- return -1;
+ FILE *cfam_id_file;
+
+ /* Try and determine the correct device type */
+ cfam_id_file = fopen(FSI_CFAM_ID, "r");
+ if (cfam_id_file) {
+ uint32_t cfam_id = 0;
+
+ fscanf(cfam_id_file, "0x%" PRIx32, &cfam_id);
+ fclose(cfam_id_file);
+
+ switch((cfam_id >> 4) & 0xff) {
+ case CHIP_ID_P9:
+ device_node = "p9";
+ break;
+
+ case CHIP_ID_P8:
+ case CHIP_ID_P8P:
+ device_node = "p8";
+ break;
+
+ default:
+ PR_ERROR("Unknown chip-id detected\n");
+ PR_ERROR("You will need to specify one with -d <host type>\n");
+ return -1;
+ }
+ } else {
+ /* The support for POWER8 included the cfam_id
+ * so if it doesn't exist assume we must be on
+ * P9 */
+ device_node = "p9";
+ }
}
+
if (!strcmp(device_node, "p8"))
pdbg_targets_init(&_binary_p8_kernel_dtb_o_start);
else
--
2.11.0
More information about the Pdbg
mailing list