From patchwork Tue Aug 6 01:37:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Popple X-Patchwork-Id: 1142520 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 462chR07wWz9sN4 for ; Tue, 6 Aug 2019 11:37:43 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=popple.id.au Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 462chQ4wWxzDqWs for ; Tue, 6 Aug 2019 11:37:42 +1000 (AEST) X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [IPv6:2401:3900:2:1::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 462chC1mSvzDqWT for ; Tue, 6 Aug 2019 11:37:31 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=popple.id.au Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 462chB612pz9sN1; Tue, 6 Aug 2019 11:37:30 +1000 (AEST) From: Alistair Popple To: pdbg@lists.ozlabs.org Date: Tue, 6 Aug 2019 11:37:12 +1000 Message-Id: <20190806013723.4047-2-alistair@popple.id.au> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190806013723.4047-1-alistair@popple.id.au> References: <20190806013723.4047-1-alistair@popple.id.au> MIME-Version: 1.0 Subject: [Pdbg] [RFC 01/12] libpdbg: Rename adu class to mem X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: amitay@ozlabs.org Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" The ADU is really an implementation of a method to access system memory. Therefore it should export an interface to access system memory rather than an implementation specific interface. Rename the class from "adu" to "mem" to reflect this. Signed-off-by: Alistair Popple Reviewed-by: Amitay Isaacs --- libpdbg/adu.c | 74 ++++++++++++++++++++++++------------------------ libpdbg/htm.c | 2 +- libpdbg/hwunit.h | 13 ++++----- libpdbg/target.c | 20 ++++++------- src/mem.c | 4 +-- src/pdbgproxy.c | 2 +- src/thread.c | 2 +- 7 files changed, 58 insertions(+), 59 deletions(-) diff --git a/libpdbg/adu.c b/libpdbg/adu.c index 3904265..25f08cd 100644 --- a/libpdbg/adu.c +++ b/libpdbg/adu.c @@ -111,7 +111,7 @@ uint8_t blog2(uint8_t x) } } -static int adu_read(struct adu *adu, uint64_t start_addr, uint8_t *output, +static int adu_read(struct mem *adu, uint64_t start_addr, uint8_t *output, uint64_t size, uint8_t block_size, bool ci) { uint8_t *output0; @@ -164,10 +164,10 @@ static int adu_read(struct adu *adu, uint64_t start_addr, uint8_t *output, int adu_getmem(struct pdbg_target *adu_target, uint64_t start_addr, uint8_t *output, uint64_t size) { - struct adu *adu; + struct mem *adu; - assert(!strcmp(adu_target->class, "adu")); - adu = target_to_adu(adu_target); + assert(!strcmp(adu_target->class, "mem")); + adu = target_to_mem(adu_target); return adu_read(adu, start_addr, output, size, 8, false); } @@ -175,10 +175,10 @@ int adu_getmem(struct pdbg_target *adu_target, uint64_t start_addr, int adu_getmem_ci(struct pdbg_target *adu_target, uint64_t start_addr, uint8_t *output, uint64_t size) { - struct adu *adu; + struct mem *adu; - assert(!strcmp(adu_target->class, "adu")); - adu = target_to_adu(adu_target); + assert(!strcmp(adu_target->class, "mem")); + adu = target_to_mem(adu_target); return adu_read(adu, start_addr, output, size, 8, true); } @@ -186,10 +186,10 @@ int adu_getmem_ci(struct pdbg_target *adu_target, uint64_t start_addr, int adu_getmem_io(struct pdbg_target *adu_target, uint64_t start_addr, uint8_t *output, uint64_t size, uint8_t blocksize) { - struct adu *adu; + struct mem *adu; - assert(!strcmp(adu_target->class, "adu")); - adu = target_to_adu(adu_target); + assert(!strcmp(adu_target->class, "mem")); + adu = target_to_mem(adu_target); /* There is no equivalent for cachable memory as blocksize * does not apply to cachable reads */ @@ -199,15 +199,15 @@ int adu_getmem_io(struct pdbg_target *adu_target, uint64_t start_addr, int __adu_getmem(struct pdbg_target *adu_target, uint64_t start_addr, uint8_t *output, uint64_t size, bool ci) { - struct adu *adu; + struct mem *adu; - assert(!strcmp(adu_target->class, "adu")); - adu = target_to_adu(adu_target); + assert(!strcmp(adu_target->class, "mem")); + adu = target_to_mem(adu_target); return adu_read(adu, start_addr, output, size, 8, ci); } -static int adu_write(struct adu *adu, uint64_t start_addr, uint8_t *input, +static int adu_write(struct mem *adu, uint64_t start_addr, uint8_t *input, uint64_t size, uint8_t block_size, bool ci) { int rc = 0, tsize; @@ -248,10 +248,10 @@ static int adu_write(struct adu *adu, uint64_t start_addr, uint8_t *input, int adu_putmem(struct pdbg_target *adu_target, uint64_t start_addr, uint8_t *input, uint64_t size) { - struct adu *adu; + struct mem *adu; - assert(!strcmp(adu_target->class, "adu")); - adu = target_to_adu(adu_target); + assert(!strcmp(adu_target->class, "mem")); + adu = target_to_mem(adu_target); return adu_write(adu, start_addr, input, size, 8, false); } @@ -259,10 +259,10 @@ int adu_putmem(struct pdbg_target *adu_target, uint64_t start_addr, int adu_putmem_ci(struct pdbg_target *adu_target, uint64_t start_addr, uint8_t *input, uint64_t size) { - struct adu *adu; + struct mem *adu; - assert(!strcmp(adu_target->class, "adu")); - adu = target_to_adu(adu_target); + assert(!strcmp(adu_target->class, "mem")); + adu = target_to_mem(adu_target); return adu_write(adu, start_addr, input, size, 8, true); } @@ -270,10 +270,10 @@ int adu_putmem_ci(struct pdbg_target *adu_target, uint64_t start_addr, int adu_putmem_io(struct pdbg_target *adu_target, uint64_t start_addr, uint8_t *input, uint64_t size, uint8_t block_size) { - struct adu *adu; + struct mem *adu; - assert(!strcmp(adu_target->class, "adu")); - adu = target_to_adu(adu_target); + assert(!strcmp(adu_target->class, "mem")); + adu = target_to_mem(adu_target); return adu_write(adu, start_addr, input, size, block_size, true); } @@ -281,15 +281,15 @@ int adu_putmem_io(struct pdbg_target *adu_target, uint64_t start_addr, int __adu_putmem(struct pdbg_target *adu_target, uint64_t start_addr, uint8_t *input, uint64_t size, bool ci) { - struct adu *adu; + struct mem *adu; - assert(!strcmp(adu_target->class, "adu")); - adu = target_to_adu(adu_target); + assert(!strcmp(adu_target->class, "mem")); + adu = target_to_mem(adu_target); return adu_write(adu, start_addr, input, size, 8, ci); } -static int adu_lock(struct adu *adu) +static int adu_lock(struct mem *adu) { uint64_t val; @@ -304,7 +304,7 @@ static int adu_lock(struct adu *adu) return 0; } -static int adu_unlock(struct adu *adu) +static int adu_unlock(struct mem *adu) { uint64_t val; @@ -321,7 +321,7 @@ static int adu_unlock(struct adu *adu) return 0; } -static int adu_reset(struct adu *adu) +static int adu_reset(struct mem *adu) { uint64_t val; @@ -332,7 +332,7 @@ static int adu_reset(struct adu *adu) return 0; } -static int p8_adu_getmem(struct adu *adu, uint64_t addr, uint64_t *data, +static int p8_adu_getmem(struct mem *adu, uint64_t addr, uint64_t *data, int ci, uint8_t block_size) { uint64_t ctrl_reg, cmd_reg, val; @@ -394,7 +394,7 @@ out: } -int p8_adu_putmem(struct adu *adu, uint64_t addr, uint64_t data, int size, +int p8_adu_putmem(struct mem *adu, uint64_t addr, uint64_t data, int size, int ci, uint8_t block_size) { int rc = 0; @@ -455,7 +455,7 @@ out: return rc; } -static int p9_adu_getmem(struct adu *adu, uint64_t addr, uint64_t *data, +static int p9_adu_getmem(struct mem *adu, uint64_t addr, uint64_t *data, int ci, uint8_t block_size) { uint64_t ctrl_reg, cmd_reg, val; @@ -512,7 +512,7 @@ retry: return 0; } -static int p9_adu_putmem(struct adu *adu, uint64_t addr, uint64_t data, int size, +static int p9_adu_putmem(struct mem *adu, uint64_t addr, uint64_t data, int size, int ci, uint8_t block_size) { uint64_t ctrl_reg, cmd_reg, val; @@ -569,11 +569,11 @@ retry: return 0; } -static struct adu p8_adu = { +static struct mem p8_adu = { .target = { .name = "POWER8 ADU", .compatible = "ibm,power8-adu", - .class = "adu", + .class = "mem", }, .getmem = p8_adu_getmem, .putmem = p8_adu_putmem, @@ -582,11 +582,11 @@ static struct adu p8_adu = { }; DECLARE_HW_UNIT(p8_adu); -static struct adu p9_adu = { +static struct mem p9_adu = { .target = { .name = "POWER9 ADU", .compatible = "ibm,power9-adu", - .class = "adu", + .class = "mem", }, .getmem = p9_adu_getmem, .putmem = p9_adu_putmem, diff --git a/libpdbg/htm.c b/libpdbg/htm.c index 72fe570..4d23e82 100644 --- a/libpdbg/htm.c +++ b/libpdbg/htm.c @@ -782,7 +782,7 @@ static int __do_htm_start(struct htm *htm, bool wrap) /* * Instead of the HTM_TRIG_START, this is where you might want * to call do_adu_magic() - * for_each_child_target("adu", core, do_adu_magic, NULL, NULL); + * for_each_child_target("mem", core, do_adu_magic, NULL, NULL); * see what I mean? */ diff --git a/libpdbg/hwunit.h b/libpdbg/hwunit.h index 1bfb872..2618941 100644 --- a/libpdbg/hwunit.h +++ b/libpdbg/hwunit.h @@ -56,14 +56,14 @@ struct htm { }; #define target_to_htm(x) container_of(x, struct htm, target) -struct adu { +struct mem { struct pdbg_target target; - int (*getmem)(struct adu *, uint64_t, uint64_t *, int, uint8_t); - int (*putmem)(struct adu *, uint64_t, uint64_t, int, int, uint8_t); - int (*read)(struct adu *, uint64_t, uint8_t *, uint64_t, uint8_t, bool); - int (*write)(struct adu *, uint64_t, uint8_t *, uint64_t, uint8_t, bool); + int (*getmem)(struct mem *, uint64_t, uint64_t *, int, uint8_t); + int (*putmem)(struct mem *, uint64_t, uint64_t, int, int, uint8_t); + int (*read)(struct mem *, uint64_t, uint8_t *, uint64_t, uint8_t, bool); + int (*write)(struct mem *, uint64_t, uint8_t *, uint64_t, uint8_t, bool); }; -#define target_to_adu(x) container_of(x, struct adu, target) +#define target_to_mem(x) container_of(x, struct mem, target) struct sbefifo { struct pdbg_target target; @@ -151,4 +151,3 @@ struct xbus { #define target_to_xbus(x) container_of(x, struct xbus, target) #endif /* __HWUNIT_H */ - diff --git a/libpdbg/target.c b/libpdbg/target.c index 9edc0bc..8880bf3 100644 --- a/libpdbg/target.c +++ b/libpdbg/target.c @@ -222,7 +222,7 @@ int mem_read(struct pdbg_target *target, uint64_t addr, uint8_t *output, uint64_ int rc = -1; assert(pdbg_target_is_class(target, "sbefifo") || - pdbg_target_is_class(target, "adu")); + pdbg_target_is_class(target, "mem")); if (pdbg_target_is_class(target, "sbefifo")) { struct sbefifo *sbefifo; @@ -231,11 +231,11 @@ int mem_read(struct pdbg_target *target, uint64_t addr, uint8_t *output, uint64_ rc = sbefifo->mem_read(sbefifo, addr, output, size, ci); } - if (pdbg_target_is_class(target, "adu")) { - struct adu *adu; + if (pdbg_target_is_class(target, "mem")) { + struct mem *mem; - adu = target_to_adu(target); - rc = adu->read(adu, addr, output, size, block_size, ci); + mem = target_to_mem(target); + rc = mem->read(mem, addr, output, size, block_size, ci); } return rc; @@ -246,7 +246,7 @@ int mem_write(struct pdbg_target *target, uint64_t addr, uint8_t *input, uint64_ int rc = -1; assert(pdbg_target_is_class(target, "sbefifo") || - pdbg_target_is_class(target, "adu")); + pdbg_target_is_class(target, "mem")); if (pdbg_target_is_class(target, "sbefifo")) { struct sbefifo *sbefifo; @@ -255,11 +255,11 @@ int mem_write(struct pdbg_target *target, uint64_t addr, uint8_t *input, uint64_ rc = sbefifo->mem_write(sbefifo, addr, input, size, ci); } - if (pdbg_target_is_class(target, "adu")) { - struct adu *adu; + if (pdbg_target_is_class(target, "mem")) { + struct mem *mem; - adu = target_to_adu(target); - rc = adu->write(adu, addr, input, size, block_size, ci); + mem = target_to_mem(target); + rc = mem->write(mem, addr, input, size, block_size, ci); } return rc; diff --git a/src/mem.c b/src/mem.c index 0b8ad7e..cacd394 100644 --- a/src/mem.c +++ b/src/mem.c @@ -112,7 +112,7 @@ static int _getmem(uint64_t addr, uint64_t size, uint8_t block_size, bool ci, bo goto done; } - pdbg_for_each_class_target("adu", target) { + pdbg_for_each_class_target("mem", target) { if (pdbg_target_probe(target) != PDBG_TARGET_ENABLED) continue; @@ -205,7 +205,7 @@ static int _putmem(uint64_t addr, uint8_t block_size, bool ci) goto done; } - pdbg_for_each_class_target("adu", target) { + pdbg_for_each_class_target("mem", target) { if (pdbg_target_probe(target) != PDBG_TARGET_ENABLED) continue; diff --git a/src/pdbgproxy.c b/src/pdbgproxy.c index 5bba03f..4177f01 100644 --- a/src/pdbgproxy.c +++ b/src/pdbgproxy.c @@ -532,7 +532,7 @@ static int gdbserver(uint16_t port) littleendian = 0x01 & msr; /* Select ADU target */ - pdbg_for_each_class_target("adu", adu) { + pdbg_for_each_class_target("mem", adu) { if (pdbg_target_probe(adu) == PDBG_TARGET_ENABLED) break; } diff --git a/src/thread.c b/src/thread.c index 7fd53a8..e44ad42 100644 --- a/src/thread.c +++ b/src/thread.c @@ -340,7 +340,7 @@ static int thread_regs_print(struct reg_flags flags) if (flags.do_backtrace) { struct pdbg_target *adu; - pdbg_for_each_class_target("adu", adu) { + pdbg_for_each_class_target("mem", adu) { if (pdbg_target_probe(adu) == PDBG_TARGET_ENABLED) { dump_stack(®s, adu); break; From patchwork Tue Aug 6 01:37:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Popple X-Patchwork-Id: 1142521 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 462chW3SJ0z9sN6 for ; Tue, 6 Aug 2019 11:37:47 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=popple.id.au Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 462chV1ywZzDqXD for ; Tue, 6 Aug 2019 11:37:46 +1000 (AEST) X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [203.11.71.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 462chC5kjWzDqWT for ; Tue, 6 Aug 2019 11:37:31 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=popple.id.au Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 462chC48TRz9sDB; Tue, 6 Aug 2019 11:37:31 +1000 (AEST) From: Alistair Popple To: pdbg@lists.ozlabs.org Date: Tue, 6 Aug 2019 11:37:13 +1000 Message-Id: <20190806013723.4047-3-alistair@popple.id.au> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190806013723.4047-1-alistair@popple.id.au> References: <20190806013723.4047-1-alistair@popple.id.au> MIME-Version: 1.0 Subject: [Pdbg] [RFC 02/12] sbefifo: Rework the memory interfaces X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: amitay@ozlabs.org Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" The SBEFIFO unit introduced it's own implementation specific interface for accessing memory. Instead it should conform to the existing memory access interfaces. This patch splits the SBEFIFO memory access into it's own hardware unit so that it can conform with the existing interfaces. Signed-off-by: Alistair Popple --- libpdbg/hwunit.h | 2 -- libpdbg/sbefifo.c | 38 ++++++++++++++++++++++++++++++-------- libpdbg/target.c | 38 ++++++++------------------------------ p9-kernel.dts.m4 | 4 ++++ p9-pib.dts.m4 | 5 ----- src/mem.c | 46 ++++++---------------------------------------- 6 files changed, 48 insertions(+), 85 deletions(-) diff --git a/libpdbg/hwunit.h b/libpdbg/hwunit.h index 2618941..a359af0 100644 --- a/libpdbg/hwunit.h +++ b/libpdbg/hwunit.h @@ -68,8 +68,6 @@ struct mem { struct sbefifo { struct pdbg_target target; int (*istep)(struct sbefifo *, uint32_t major, uint32_t minor); - int (*mem_read)(struct sbefifo *, uint64_t, uint8_t *, uint64_t, bool); - int (*mem_write)(struct sbefifo *, uint64_t, uint8_t *, uint64_t, bool); int (*thread_start)(struct sbefifo *, uint32_t core_id, uint32_t thread_id); int (*thread_stop)(struct sbefifo *, uint32_t core_id, uint32_t thread_id); int (*thread_step)(struct sbefifo *, uint32_t core_id, uint32_t thread_id); diff --git a/libpdbg/sbefifo.c b/libpdbg/sbefifo.c index a2442cd..b7f52a1 100644 --- a/libpdbg/sbefifo.c +++ b/libpdbg/sbefifo.c @@ -244,9 +244,9 @@ static int sbefifo_op_istep(struct sbefifo *sbefifo, return 0; } -static int sbefifo_op_getmem(struct sbefifo *sbefifo, +static int sbefifo_op_getmem(struct mem *sbefifo, uint64_t addr, uint8_t *data, uint64_t size, - bool ci) + uint8_t block_size, bool ci) { uint8_t *out; uint64_t start_addr, end_addr; @@ -257,6 +257,11 @@ static int sbefifo_op_getmem(struct sbefifo *sbefifo, align = ci ? 8 : 128; + if (block_size && block_size != 8) { + PR_ERROR("sbefifo: Only 8 byte block sizes are supported\n"); + return -1; + }; + start_addr = addr & (~(uint64_t)(align-1)); end_addr = (addr + size + (align-1)) & (~(uint64_t)(align-1)); @@ -285,7 +290,8 @@ static int sbefifo_op_getmem(struct sbefifo *sbefifo, msg[5] = htobe32(len); out_len = len + 4; - rc = sbefifo_op(sbefifo, msg, sizeof(msg), cmd, &out, &out_len, &status); + rc = sbefifo_op(target_to_sbefifo(sbefifo->target.parent), msg, sizeof(msg), cmd, + &out, &out_len, &status); if (rc) return rc; @@ -304,9 +310,9 @@ static int sbefifo_op_getmem(struct sbefifo *sbefifo, return 0; } -static int sbefifo_op_putmem(struct sbefifo *sbefifo, +static int sbefifo_op_putmem(struct mem *sbefifo, uint64_t addr, uint8_t *data, uint64_t size, - bool ci) + uint8_t block_size, bool ci) { uint8_t *out; uint32_t *msg; @@ -316,6 +322,11 @@ static int sbefifo_op_putmem(struct sbefifo *sbefifo, align = ci ? 8 : 128; + if (block_size && block_size != 8) { + PR_ERROR("sbefifo: Only 8 byte block sizes are supported\n"); + return -1; + }; + if (addr & (align-1)) { PR_ERROR("sbefifo: Address must be aligned to %d bytes\n", align); return -1; @@ -353,7 +364,8 @@ static int sbefifo_op_putmem(struct sbefifo *sbefifo, memcpy(&msg[6], data, len); out_len = 4; - rc = sbefifo_op(sbefifo, msg, msg_len, cmd, &out, &out_len, &status); + rc = sbefifo_op(target_to_sbefifo(sbefifo->target.parent), msg, msg_len, cmd, + &out, &out_len, &status); if (rc) return rc; @@ -479,6 +491,17 @@ static int sbefifo_probe(struct pdbg_target *target) return 0; } +struct mem sbefifo_mem = { + .target = { + .name = "SBE FIFO Chip-op based memory access", + .compatible = "ibm,sbefifo-mem", + .class = "mem", + }, + .read = sbefifo_op_getmem, + .write = sbefifo_op_putmem, +}; +DECLARE_HW_UNIT(sbefifo_mem); + struct sbefifo kernel_sbefifo = { .target = { .name = "Kernel based FSI SBE FIFO", @@ -487,8 +510,6 @@ struct sbefifo kernel_sbefifo = { .probe = sbefifo_probe, }, .istep = sbefifo_op_istep, - .mem_read = sbefifo_op_getmem, - .mem_write = sbefifo_op_putmem, .thread_start = sbefifo_op_thread_start, .thread_stop = sbefifo_op_thread_stop, .thread_step = sbefifo_op_thread_step, @@ -503,4 +524,5 @@ __attribute__((constructor)) static void register_sbefifo(void) { pdbg_hwunit_register(&kernel_sbefifo_hw_unit); + pdbg_hwunit_register(&sbefifo_mem_hw_unit); } diff --git a/libpdbg/target.c b/libpdbg/target.c index 8880bf3..61353bc 100644 --- a/libpdbg/target.c +++ b/libpdbg/target.c @@ -219,48 +219,26 @@ int fsi_write(struct pdbg_target *fsi_dt, uint32_t addr, uint32_t data) int mem_read(struct pdbg_target *target, uint64_t addr, uint8_t *output, uint64_t size, uint8_t block_size, bool ci) { + struct mem *mem; int rc = -1; - assert(pdbg_target_is_class(target, "sbefifo") || - pdbg_target_is_class(target, "mem")); + assert(pdbg_target_is_class(target, "mem")); - if (pdbg_target_is_class(target, "sbefifo")) { - struct sbefifo *sbefifo; - - sbefifo = target_to_sbefifo(target); - rc = sbefifo->mem_read(sbefifo, addr, output, size, ci); - } - - if (pdbg_target_is_class(target, "mem")) { - struct mem *mem; - - mem = target_to_mem(target); - rc = mem->read(mem, addr, output, size, block_size, ci); - } + mem = target_to_mem(target); + rc = mem->read(mem, addr, output, size, block_size, ci); return rc; } int mem_write(struct pdbg_target *target, uint64_t addr, uint8_t *input, uint64_t size, uint8_t block_size, bool ci) { + struct mem *mem; int rc = -1; - assert(pdbg_target_is_class(target, "sbefifo") || - pdbg_target_is_class(target, "mem")); + assert(pdbg_target_is_class(target, "mem")); - if (pdbg_target_is_class(target, "sbefifo")) { - struct sbefifo *sbefifo; - - sbefifo = target_to_sbefifo(target); - rc = sbefifo->mem_write(sbefifo, addr, input, size, ci); - } - - if (pdbg_target_is_class(target, "mem")) { - struct mem *mem; - - mem = target_to_mem(target); - rc = mem->write(mem, addr, input, size, block_size, ci); - } + mem = target_to_mem(target); + rc = mem->write(mem, addr, input, size, block_size, ci); return rc; } diff --git a/p9-kernel.dts.m4 b/p9-kernel.dts.m4 index 9ab46b8..30cde95 100644 --- a/p9-kernel.dts.m4 +++ b/p9-kernel.dts.m4 @@ -28,6 +28,10 @@ index = <0x0>; compatible = "ibm,kernel-sbefifo"; device-path = "/dev/sbefifo1"; + + sbefifo-mem@0 { + compatible = "ibm,sbefifo-mem"; + }; }; hmfsi@100000 { diff --git a/p9-pib.dts.m4 b/p9-pib.dts.m4 index 3e312e5..3a99157 100644 --- a/p9-pib.dts.m4 +++ b/p9-pib.dts.m4 @@ -36,11 +36,6 @@ reg = <0x0 HEX(CHIPLET_BASE($1)) 0xfffff>; }')dnl -adu@90000 { - compatible = "ibm,power9-adu"; - reg = <0x0 0x90000 0x5>; -}; - htm@5012880 { compatible = "ibm,power9-nhtm"; reg = <0x0 0x5012880 0x40>; diff --git a/src/mem.c b/src/mem.c index cacd394..53d33b8 100644 --- a/src/mem.c +++ b/src/mem.c @@ -95,23 +95,6 @@ static int _getmem(uint64_t addr, uint64_t size, uint8_t block_size, bool ci, bo buf = malloc(size); assert(buf); - pdbg_for_each_class_target("sbefifo", target) { - if (pdbg_target_probe(target) != PDBG_TARGET_ENABLED) - continue; - - pdbg_set_progress_tick(progress_tick); - progress_init(); - rc = mem_read(target, addr, buf, size, block_size, ci); - progress_end(); - if (rc) { - PR_ERROR("Unable to read memory using sbefifo\n"); - continue; - } - - count++; - goto done; - } - pdbg_for_each_class_target("mem", target) { if (pdbg_target_probe(target) != PDBG_TARGET_ENABLED) continue; @@ -121,15 +104,15 @@ static int _getmem(uint64_t addr, uint64_t size, uint8_t block_size, bool ci, bo rc = mem_read(target, addr, buf, size, block_size, ci); progress_end(); if (rc) { - PR_ERROR("Unable to read memory using adu\n"); + PR_ERROR("Unable to read memory from %s\n", + pdbg_target_path(target)); continue; } count++; - goto done; + break; } -done: if (count > 0) { uint64_t i; bool printable = true; @@ -188,23 +171,6 @@ static int _putmem(uint64_t addr, uint8_t block_size, bool ci) buf = read_stdin(&buflen); assert(buf); - pdbg_for_each_class_target("sbefifo", target) { - if (pdbg_target_probe(target) != PDBG_TARGET_ENABLED) - continue; - - pdbg_set_progress_tick(progress_tick); - progress_init(); - rc = mem_write(target, addr, buf, buflen, block_size, ci); - progress_end(); - if (rc) { - printf("Unable to write memory using sbefifo\n"); - continue; - } - - count++; - goto done; - } - pdbg_for_each_class_target("mem", target) { if (pdbg_target_probe(target) != PDBG_TARGET_ENABLED) continue; @@ -214,15 +180,15 @@ static int _putmem(uint64_t addr, uint8_t block_size, bool ci) rc = mem_write(target, addr, buf, buflen, block_size, ci); progress_end(); if (rc) { - printf("Unable to write memory using adu\n"); + printf("Unable to write memory using %s\n", + pdbg_target_path(target)); continue; } count++; - goto done; + break; } -done: if (count > 0) printf("Wrote %zu bytes starting at 0x%016" PRIx64 "\n", buflen, addr); From patchwork Tue Aug 6 01:37:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Popple X-Patchwork-Id: 1142522 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 462chZ2FyXz9sDB for ; Tue, 6 Aug 2019 11:37:50 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=popple.id.au Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 462chY52XhzDqX3 for ; Tue, 6 Aug 2019 11:37:49 +1000 (AEST) X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [IPv6:2401:3900:2:1::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 462chD57Z5zDqWT for ; Tue, 6 Aug 2019 11:37:32 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=popple.id.au Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 462chD3cbfz9sDB; Tue, 6 Aug 2019 11:37:32 +1000 (AEST) From: Alistair Popple To: pdbg@lists.ozlabs.org Date: Tue, 6 Aug 2019 11:37:14 +1000 Message-Id: <20190806013723.4047-4-alistair@popple.id.au> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190806013723.4047-1-alistair@popple.id.au> References: <20190806013723.4047-1-alistair@popple.id.au> MIME-Version: 1.0 Subject: [Pdbg] [RFC 03/12] sbefifo: Rework thread functions X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: amitay@ozlabs.org Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" The thread control functions should implement the standard thread control interface rather than an sbefifo specific version. Rework the existing functions to match. Signed-off-by: Alistair Popple --- libpdbg/chip.c | 6 +--- libpdbg/hwunit.h | 5 +--- libpdbg/sbefifo.c | 76 +++++++++++++++++++++++++++++++++++++---------- 3 files changed, 62 insertions(+), 25 deletions(-) diff --git a/libpdbg/chip.c b/libpdbg/chip.c index 67e3afa..259b106 100644 --- a/libpdbg/chip.c +++ b/libpdbg/chip.c @@ -166,11 +166,7 @@ int thread_sreset_all(void) if (!sbefifo) break; - /* - * core_id = 0xff (all SMT4 cores) - * thread_id = 0xf (all 4 threads in the SMT4 core) - */ - rc |= sbefifo->thread_sreset(sbefifo, 0xff, 0xf); + rc |= sbefifo->sreset_all(sbefifo); count++; } diff --git a/libpdbg/hwunit.h b/libpdbg/hwunit.h index a359af0..b8a2dca 100644 --- a/libpdbg/hwunit.h +++ b/libpdbg/hwunit.h @@ -68,11 +68,8 @@ struct mem { struct sbefifo { struct pdbg_target target; int (*istep)(struct sbefifo *, uint32_t major, uint32_t minor); - int (*thread_start)(struct sbefifo *, uint32_t core_id, uint32_t thread_id); - int (*thread_stop)(struct sbefifo *, uint32_t core_id, uint32_t thread_id); - int (*thread_step)(struct sbefifo *, uint32_t core_id, uint32_t thread_id); - int (*thread_sreset)(struct sbefifo *, uint32_t core_id, uint32_t thread_id); int (*chipop)(struct sbefifo *, uint32_t *, uint32_t, uint8_t **, uint32_t *, uint32_t *); + int (*sreset_all)(struct sbefifo *); uint32_t (*ffdc_get)(struct sbefifo *, const uint8_t **, uint32_t *); int fd; uint32_t status; diff --git a/libpdbg/sbefifo.c b/libpdbg/sbefifo.c index b7f52a1..ade2d62 100644 --- a/libpdbg/sbefifo.c +++ b/libpdbg/sbefifo.c @@ -418,28 +418,60 @@ static int sbefifo_op_control(struct sbefifo *sbefifo, return 0; } -static int sbefifo_op_thread_start(struct sbefifo *sbefifo, - uint32_t core_id, uint32_t thread_id) +static int sbefifo_op_thread(struct thread *thread, uint32_t op) { - return sbefifo_op_control(sbefifo, core_id, thread_id, SBEFIFO_INSN_OP_START); + return sbefifo_op_control(target_to_sbefifo(thread->target.parent), + thread->id >> 8, thread->id & 0xff, op); } -static int sbefifo_op_thread_stop(struct sbefifo *sbefifo, - uint32_t core_id, uint32_t thread_id) +static int sbefifo_op_thread_start(struct thread *thread) { - return sbefifo_op_control(sbefifo, core_id, thread_id, SBEFIFO_INSN_OP_STOP); + return sbefifo_op_thread(thread, SBEFIFO_INSN_OP_START); } -static int sbefifo_op_thread_step(struct sbefifo *sbefifo, - uint32_t core_id, uint32_t thread_id) +static int sbefifo_op_thread_stop(struct thread *thread) { - return sbefifo_op_control(sbefifo, core_id, thread_id, SBEFIFO_INSN_OP_STEP); + return sbefifo_op_thread(thread, SBEFIFO_INSN_OP_STOP); } -static int sbefifo_op_thread_sreset(struct sbefifo *sbefifo, - uint32_t core_id, uint32_t thread_id) +static int sbefifo_op_thread_step(struct thread *thread, int count) { - return sbefifo_op_control(sbefifo, core_id, thread_id, SBEFIFO_INSN_OP_SRESET); + int i, rc; + + for (i = 0; i < count; i++) + if ((rc = sbefifo_op_thread(thread, SBEFIFO_INSN_OP_STEP))) + return rc; + + return 0; +} + +static int sbefifo_op_thread_sreset(struct thread *thread) +{ + return sbefifo_op_thread(thread, SBEFIFO_INSN_OP_SRESET); +} + +static int sbefifo_op_sreset_all(struct sbefifo *sbefifo) +{ + /* + * core_id = 0xff (all SMT4 cores) + * thread_id = 0xf (all 4 threads in the SMT4 core) + */ + return sbefifo_op_control(sbefifo, 0xff, 0xf, SBEFIFO_INSN_OP_SRESET); +} + +static int sbefifo_thread_probe(struct pdbg_target *target) +{ + struct thread *thread = target_to_thread(target); + uint32_t core_id, thread_id; + + if (pdbg_target_u32_property(target, "core-id", &core_id)) + return -1; + + if (pdbg_target_u32_property(target, "thread-id", &thread_id)) + return -1; + + thread->id = (core_id << 8) | (thread_id & 0xff); + return 0; } static int sbefifo_op_chipop(struct sbefifo *sbefifo, @@ -502,6 +534,20 @@ struct mem sbefifo_mem = { }; DECLARE_HW_UNIT(sbefifo_mem); +struct thread sbefifo_thread = { + .target = { + .name = "SBE FIFO Chip-op based thread access", + .compatible = "ibm,sbefifo-thread", + .class = "thread", + .probe = sbefifo_thread_probe, + }, + .start = sbefifo_op_thread_start, + .stop = sbefifo_op_thread_stop, + .step = sbefifo_op_thread_step, + .sreset = sbefifo_op_thread_sreset, +}; +DECLARE_HW_UNIT(sbefifo_thread); + struct sbefifo kernel_sbefifo = { .target = { .name = "Kernel based FSI SBE FIFO", @@ -510,10 +556,7 @@ struct sbefifo kernel_sbefifo = { .probe = sbefifo_probe, }, .istep = sbefifo_op_istep, - .thread_start = sbefifo_op_thread_start, - .thread_stop = sbefifo_op_thread_stop, - .thread_step = sbefifo_op_thread_step, - .thread_sreset = sbefifo_op_thread_sreset, + .sreset_all = sbefifo_op_sreset_all, .chipop = sbefifo_op_chipop, .ffdc_get = sbefifo_ffdc_get, .fd = -1, @@ -525,4 +568,5 @@ static void register_sbefifo(void) { pdbg_hwunit_register(&kernel_sbefifo_hw_unit); pdbg_hwunit_register(&sbefifo_mem_hw_unit); + pdbg_hwunit_register(&sbefifo_thread_hw_unit); } From patchwork Tue Aug 6 01:37:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Popple X-Patchwork-Id: 1142523 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 462chd5WbPz9sN1 for ; Tue, 6 Aug 2019 11:37:53 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=popple.id.au Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 462chd3V2JzDqWd for ; Tue, 6 Aug 2019 11:37:53 +1000 (AEST) X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [IPv6:2401:3900:2:1::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 462chF44ltzDqWT for ; Tue, 6 Aug 2019 11:37:33 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=popple.id.au Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 462chF1kgXz9sDB; Tue, 6 Aug 2019 11:37:33 +1000 (AEST) From: Alistair Popple To: pdbg@lists.ozlabs.org Date: Tue, 6 Aug 2019 11:37:15 +1000 Message-Id: <20190806013723.4047-5-alistair@popple.id.au> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190806013723.4047-1-alistair@popple.id.au> References: <20190806013723.4047-1-alistair@popple.id.au> MIME-Version: 1.0 Subject: [Pdbg] [RFC 04/12] libpdbg: Introduce a backend field X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: amitay@ozlabs.org Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" It is useful to be able to override a particular targets access methods with methods specific to a specific runtime environment. This patch introduces a field to every target which can be used for this purpose without affecting the current behaviour. Signed-off-by: Alistair Popple --- libpdbg/target.c | 12 +++++++++--- libpdbg/target.h | 1 + 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/libpdbg/target.c b/libpdbg/target.c index 61353bc..e822d70 100644 --- a/libpdbg/target.c +++ b/libpdbg/target.c @@ -14,8 +14,8 @@ struct list_head empty_list = LIST_HEAD_INIT(empty_list); struct list_head target_classes = LIST_HEAD_INIT(target_classes); -/* Work out the address to access based on the current target and - * final class name */ +/* Work out the target and address to call call access methods on + * based on the current target and final class name */ static struct pdbg_target *get_class_target_addr(struct pdbg_target *target, const char *name, uint64_t *addr) { /* Check class */ @@ -34,7 +34,13 @@ static struct pdbg_target *get_class_target_addr(struct pdbg_target *target, con assert(target != pdbg_target_root()); } - return target; + if (target->backend) { + /* The backend must implement the same interfaces */ + assert(!strcmp(target->class, target->backend->class)); + return target->backend; + } else { + return target; + } } struct pdbg_target *pdbg_address_absolute(struct pdbg_target *target, uint64_t *addr) diff --git a/libpdbg/target.h b/libpdbg/target.h index 9394447..2c76bf9 100644 --- a/libpdbg/target.h +++ b/libpdbg/target.h @@ -46,6 +46,7 @@ struct pdbg_target { struct list_head properties; struct list_head children; struct pdbg_target *parent; + struct pdbg_target *backend; u32 phandle; bool probed; struct list_node class_link; From patchwork Tue Aug 6 01:37:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Popple X-Patchwork-Id: 1142524 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 462chh5xBrz9sN4 for ; Tue, 6 Aug 2019 11:37:56 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=popple.id.au Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 462chh2zdwzDqWn for ; Tue, 6 Aug 2019 11:37:56 +1000 (AEST) X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [IPv6:2401:3900:2:1::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 462chG38JyzDqWT for ; Tue, 6 Aug 2019 11:37:34 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=popple.id.au Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 462chG1RmNz9sDB; Tue, 6 Aug 2019 11:37:34 +1000 (AEST) From: Alistair Popple To: pdbg@lists.ozlabs.org Date: Tue, 6 Aug 2019 11:37:16 +1000 Message-Id: <20190806013723.4047-6-alistair@popple.id.au> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190806013723.4047-1-alistair@popple.id.au> References: <20190806013723.4047-1-alistair@popple.id.au> MIME-Version: 1.0 Subject: [Pdbg] [RFC 05/12] device.c: Extend dt_expand to operate with different root nodes X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: amitay@ozlabs.org Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Signed-off-by: Alistair Popple Reviewed-by: Amitay Isaacs --- libpdbg/device.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libpdbg/device.c b/libpdbg/device.c index 07f373d..2fcb184 100644 --- a/libpdbg/device.c +++ b/libpdbg/device.c @@ -574,11 +574,11 @@ static int dt_expand_node(struct pdbg_target *node, const void *fdt, int fdt_nod return nextoffset; } -static void dt_expand(const void *fdt) +static void dt_expand(void *root, const void *fdt) { PR_DEBUG("FDT: Parsing fdt @%p\n", fdt); - if (dt_expand_node(pdbg_dt_root, fdt, 0) < 0) + if (dt_expand_node(root, fdt, 0) < 0) abort(); } @@ -634,7 +634,7 @@ void pdbg_targets_init(void *fdt) return; } - dt_expand(fdt); + dt_expand(pdbg_dt_root, fdt); } char *pdbg_target_path(const struct pdbg_target *target) From patchwork Tue Aug 6 01:37:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Popple X-Patchwork-Id: 1142525 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 462chm0Cgpz9sDB for ; Tue, 6 Aug 2019 11:38:00 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=popple.id.au Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 462chl5dxyzDqXG for ; Tue, 6 Aug 2019 11:37:59 +1000 (AEST) X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [203.11.71.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 462chH3ZDczDqWT for ; Tue, 6 Aug 2019 11:37:35 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=popple.id.au Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 462chH1mvkz9sN4; Tue, 6 Aug 2019 11:37:35 +1000 (AEST) From: Alistair Popple To: pdbg@lists.ozlabs.org Date: Tue, 6 Aug 2019 11:37:17 +1000 Message-Id: <20190806013723.4047-7-alistair@popple.id.au> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190806013723.4047-1-alistair@popple.id.au> References: <20190806013723.4047-1-alistair@popple.id.au> MIME-Version: 1.0 Subject: [Pdbg] [RFC 06/12] libpdbg: Add infrastructure to link backend nodes X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: amitay@ozlabs.org Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Signed-off-by: Alistair Popple --- Makefile.am | 3 ++- backend.dts.m4 | 4 ++++ libpdbg/device.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++ libpdbg/dtb.c | 6 +++++ libpdbg/libpdbg.h | 3 +++ 5 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 backend.dts.m4 diff --git a/Makefile.am b/Makefile.am index 011e686..0f2906a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -35,6 +35,7 @@ AM_CFLAGS = -I$(top_srcdir)/ccan/array_size -Wall -Werror -O2 EXTRA_DIST = \ fake.dts.m4 \ + backend.dts.m4 \ p8-fsi.dts.m4 \ p8-host.dts.m4 \ p8-i2c.dts.m4 \ @@ -63,7 +64,7 @@ if TARGET_PPC ARCH_FLAGS="-DTARGET_PPC=1" endif -DT = fake.dts p8-cronus.dts p9-cronus.dts \ +DT = fake.dts backend.dts p8-cronus.dts p9-cronus.dts \ p8-fsi.dts p8-i2c.dts p8-kernel.dts \ p9w-fsi.dts p9r-fsi.dts p9z-fsi.dts p9-kernel.dts \ p8-host.dts p9-host.dts diff --git a/backend.dts.m4 b/backend.dts.m4 new file mode 100644 index 0000000..e160dad --- /dev/null +++ b/backend.dts.m4 @@ -0,0 +1,4 @@ +/dts-v1/; + +/ { +}; diff --git a/libpdbg/device.c b/libpdbg/device.c index 2fcb184..7a913b2 100644 --- a/libpdbg/device.c +++ b/libpdbg/device.c @@ -39,6 +39,7 @@ static uint32_t last_phandle = 0; static struct pdbg_target *pdbg_dt_root; +static struct pdbg_target *pdbg_backend_dt_root; /* * An in-memory representation of a node in the device tree. @@ -637,6 +638,65 @@ void pdbg_targets_init(void *fdt) dt_expand(pdbg_dt_root, fdt); } +static struct pdbg_target *pdbg_get_system_target(struct pdbg_target *backend_target) +{ + const char *system_path; + struct pdbg_target *system_target = NULL; + + system_path = pdbg_target_property(backend_target, "system-path", NULL); + + /* This is a backend node that needs to be linked to a system target */ + if (system_path) { + system_target = dt_find_by_path(pdbg_dt_root, system_path); + } + + return system_target; +} + +static void pdbg_link_backend_targets(struct pdbg_target *backend_target) +{ + struct pdbg_target *system_target, *child; + + system_target = pdbg_get_system_target(backend_target); + if (system_target) { + PR_DEBUG("Linking backend target %s to system target %s\n", + pdbg_target_path(backend_target), pdbg_target_path(system_target)); + + /* The backend class must match the system class */ + assert(!strcmp(pdbg_target_class_name(backend_target), + pdbg_target_class_name(system_target))); + system_target->backend = backend_target; + + /* A backend target shoudl always use it's own implementation for access */ + backend_target->backend = backend_target; + } else { + PR_INFO("Unable to match backend at %s to system target %s", + pdbg_target_path(backend_target), pdbg_target_path(system_target)); + } + + /* Recursively link all child targets as well */ + pdbg_for_each_child_target(backend_target, child) + pdbg_link_backend_targets(child); +} + +void pdbg_backend_init(void *fdt) +{ + pdbg_backend_dt_root = dt_new_node("", NULL, 0); + + if (!fdt) + fdt = pdbg_default_backend_dtb(); + + if (!fdt) { + pdbg_log(PDBG_ERROR, "Could not find a system backend to use\n"); + return; + } + + dt_expand(pdbg_backend_dt_root, fdt); + + /* Link the backend nodes to the system targets */ + pdbg_link_backend_targets(pdbg_backend_dt_root); +} + char *pdbg_target_path(const struct pdbg_target *target) { return dt_get_path(target); diff --git a/libpdbg/dtb.c b/libpdbg/dtb.c index 6c4beed..f6b235f 100644 --- a/libpdbg/dtb.c +++ b/libpdbg/dtb.c @@ -41,6 +41,7 @@ #include "p9-host.dt.h" #include "p8-cronus.dt.h" #include "p9-cronus.dt.h" +#include "backend.dt.h" #define AMI_BMC "/proc/ractrends/Helper/FwInfo" #define OPENFSI_BMC "/sys/bus/platform/devices/gpio-fsi/fsi0/" @@ -296,3 +297,8 @@ void *pdbg_default_dtb(void) break; } } + +void *pdbg_default_backend_dtb(void) +{ + return &_binary_backend_dtb_o_start; +} diff --git a/libpdbg/libpdbg.h b/libpdbg/libpdbg.h index 25bfd97..b819c56 100644 --- a/libpdbg/libpdbg.h +++ b/libpdbg/libpdbg.h @@ -102,6 +102,7 @@ uint64_t pdbg_target_address(struct pdbg_target *target, uint64_t *size); /* Misc. */ void pdbg_targets_init(void *fdt); +void pdbg_backend_init(void *fdt); void pdbg_target_probe_all(struct pdbg_target *parent); enum pdbg_target_status pdbg_target_probe(struct pdbg_target *target); void pdbg_target_release(struct pdbg_target *target); @@ -109,6 +110,7 @@ enum pdbg_target_status pdbg_target_status(struct pdbg_target *target); void pdbg_target_status_set(struct pdbg_target *target, enum pdbg_target_status status); int pdbg_set_backend(enum pdbg_backend backend, const char *backend_option); void *pdbg_default_dtb(void); +void *pdbg_default_backend_dtb(void); uint32_t pdbg_target_index(struct pdbg_target *target); char *pdbg_target_path(const struct pdbg_target *target); struct pdbg_target *pdbg_target_from_path(struct pdbg_target *target, const char *path); @@ -119,6 +121,7 @@ const char *pdbg_target_dn_name(struct pdbg_target *target); void *pdbg_target_priv(struct pdbg_target *target); void pdbg_target_priv_set(struct pdbg_target *target, void *priv); struct pdbg_target *pdbg_target_root(void); +struct pdbg_target *pdbg_backend_root(void); bool pdbg_target_compatible(struct pdbg_target *target, const char *compatible); /* Translate an address offset for a target to absolute address in address From patchwork Tue Aug 6 01:37:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Popple X-Patchwork-Id: 1142526 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 462chp4W1Xz9sN4 for ; Tue, 6 Aug 2019 11:38:02 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=popple.id.au Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 462chp3DBKzDqX0 for ; Tue, 6 Aug 2019 11:38:02 +1000 (AEST) X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [IPv6:2401:3900:2:1::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 462chJ2nRVzDqWh for ; Tue, 6 Aug 2019 11:37:36 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=popple.id.au Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 462chJ0F95z9sDB; Tue, 6 Aug 2019 11:37:35 +1000 (AEST) From: Alistair Popple To: pdbg@lists.ozlabs.org Date: Tue, 6 Aug 2019 11:37:18 +1000 Message-Id: <20190806013723.4047-8-alistair@popple.id.au> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190806013723.4047-1-alistair@popple.id.au> References: <20190806013723.4047-1-alistair@popple.id.au> MIME-Version: 1.0 Subject: [Pdbg] [RFC 07/12] libpdbg: Rework dt_new_node() X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: amitay@ozlabs.org Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Simplify the control logic for dt_new_node() by splitting out the initialisation from the HW unit. Should be no functional change. Signed-off-by: Alistair Popple --- libpdbg/device.c | 89 +++++++++++++++++++++++++++++------------------- 1 file changed, 54 insertions(+), 35 deletions(-) diff --git a/libpdbg/device.c b/libpdbg/device.c index 7a913b2..21ec3a3 100644 --- a/libpdbg/device.c +++ b/libpdbg/device.c @@ -65,60 +65,79 @@ static const char *take_name(const char *name) return name; } -static struct pdbg_target *dt_new_node(const char *name, const void *fdt, int node_offset) +/* Adds information representing an actual target */ +static struct pdbg_target *pdbg_target_new(const void *fdt, int node_offset) { + struct pdbg_target *target; + struct pdbg_target_class *target_class; const struct hw_unit_info *hw_info = NULL; const struct fdt_property *prop; - struct pdbg_target *node; - size_t size = sizeof(*node); - - if (fdt) { - prop = fdt_get_property(fdt, node_offset, "compatible", NULL); - if (prop) { - int i, prop_len = fdt32_to_cpu(prop->len); - - /* - * If I understand correctly, the property we have - * here can be a stringlist with a few compatible - * strings - */ - i = 0; - while (i < prop_len) { - hw_info = pdbg_hwunit_find_compatible(&prop->data[i]); - if (hw_info) { - size = hw_info->size; - break; - } - - i += strlen(&prop->data[i]) + 1; + size_t size; + + prop = fdt_get_property(fdt, node_offset, "compatible", NULL); + if (prop) { + int i, prop_len = fdt32_to_cpu(prop->len); + + /* + * If I understand correctly, the property we have + * here can be a stringlist with a few compatible + * strings + */ + i = 0; + while (i < prop_len) { + hw_info = pdbg_hwunit_find_compatible(&prop->data[i]); + if (hw_info) { + size = hw_info->size; + break; } + + i += strlen(&prop->data[i]) + 1; } } - node = calloc(1, size); - if (!node) { + if (!hw_info) + /* Couldn't find anything implementing this target */ + return NULL; + + target = calloc(1, size); + if (!target) { prerror("Failed to allocate node\n"); abort(); } - if (hw_info) { - struct pdbg_target_class *target_class; + /* hw_info->hw_unit points to a per-target struct type. This + * works because the first member in the per-target struct is + * guaranteed to be the struct pdbg_target (see the comment + * above DECLARE_HW_UNIT). */ + memcpy(target, hw_info->hw_unit, size); + target_class = get_target_class(target->class); + list_add_tail(&target_class->targets, &target->class_link); + + return target; +} - /* hw_info->hw_unit points to a per-target struct type. This - * works because the first member in the per-target struct is - * guaranteed to be the struct pdbg_target (see the comment - * above DECLARE_HW_UNIT). */ - memcpy(node, hw_info->hw_unit, size); - target_class = get_target_class(node->class); - list_add_tail(&target_class->targets, &node->class_link); +static struct pdbg_target *dt_new_node(const char *name, const void *fdt, int node_offset) +{ + struct pdbg_target *node = NULL; + size_t size = sizeof(*node); + + if (fdt) + node = pdbg_target_new(fdt, node_offset); + + if (!node) + node = calloc(1, size); + + if (!node) { + prerror("Failed to allocate node\n"); + abort(); } node->dn_name = take_name(name); node->parent = NULL; list_head_init(&node->properties); list_head_init(&node->children); - /* FIXME: locking? */ node->phandle = ++last_phandle; + return node; } From patchwork Tue Aug 6 01:37:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Popple X-Patchwork-Id: 1142527 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 462chs6gcyz9sDB for ; Tue, 6 Aug 2019 11:38:05 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=popple.id.au Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 462chs15kNzDqXf for ; Tue, 6 Aug 2019 11:38:05 +1000 (AEST) X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [203.11.71.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 462chK6X0rzDqWh for ; Tue, 6 Aug 2019 11:37:37 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=popple.id.au Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 462chK1fjdz9sDB; Tue, 6 Aug 2019 11:37:37 +1000 (AEST) From: Alistair Popple To: pdbg@lists.ozlabs.org Date: Tue, 6 Aug 2019 11:37:19 +1000 Message-Id: <20190806013723.4047-9-alistair@popple.id.au> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190806013723.4047-1-alistair@popple.id.au> References: <20190806013723.4047-1-alistair@popple.id.au> MIME-Version: 1.0 Subject: [Pdbg] [RFC 08/12] libpdbg: Change get_target_class() to take a pdbg_target X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: amitay@ozlabs.org Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" No behavioural change. Signed-off-by: Alistair Popple Reviewed-by: Amitay Isaacs --- libpdbg/device.c | 2 +- libpdbg/target.c | 8 ++++---- libpdbg/target.h | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/libpdbg/device.c b/libpdbg/device.c index 21ec3a3..f6d27db 100644 --- a/libpdbg/device.c +++ b/libpdbg/device.c @@ -110,7 +110,7 @@ static struct pdbg_target *pdbg_target_new(const void *fdt, int node_offset) * guaranteed to be the struct pdbg_target (see the comment * above DECLARE_HW_UNIT). */ memcpy(target, hw_info->hw_unit, size); - target_class = get_target_class(target->class); + target_class = get_target_class(target); list_add_tail(&target_class->targets, &target->class_link); return target; diff --git a/libpdbg/target.c b/libpdbg/target.c index e822d70..73ad98f 100644 --- a/libpdbg/target.c +++ b/libpdbg/target.c @@ -334,18 +334,18 @@ struct pdbg_target_class *require_target_class(const char *name) } /* Returns the existing class or allocates space for a new one */ -struct pdbg_target_class *get_target_class(const char *name) +struct pdbg_target_class *get_target_class(struct pdbg_target *target) { struct pdbg_target_class *target_class; - if ((target_class = find_target_class(name))) + if ((target_class = find_target_class(target->class))) return target_class; /* Need to allocate a new class */ - PR_DEBUG("Allocating %s target class\n", name); + PR_DEBUG("Allocating %s target class\n", target->class); target_class = calloc(1, sizeof(*target_class)); assert(target_class); - target_class->name = strdup(name); + target_class->name = strdup(target->class); list_head_init(&target_class->targets); list_add_tail(&target_classes, &target_class->class_head_link); return target_class; diff --git a/libpdbg/target.h b/libpdbg/target.h index 2c76bf9..44cbcde 100644 --- a/libpdbg/target.h +++ b/libpdbg/target.h @@ -56,7 +56,7 @@ struct pdbg_target { struct pdbg_target *require_target_parent(struct pdbg_target *target); struct pdbg_target_class *find_target_class(const char *name); struct pdbg_target_class *require_target_class(const char *name); -struct pdbg_target_class *get_target_class(const char *name); +struct pdbg_target_class *get_target_class(struct pdbg_target *target); bool pdbg_target_is_class(struct pdbg_target *target, const char *class); extern struct list_head empty_list; From patchwork Tue Aug 6 01:37:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Popple X-Patchwork-Id: 1142528 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 462chw5j6kz9sN4 for ; Tue, 6 Aug 2019 11:38:08 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=popple.id.au Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 462chw3LmRzDqXT for ; Tue, 6 Aug 2019 11:38:08 +1000 (AEST) X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [IPv6:2401:3900:2:1::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 462chM25CCzDqXC for ; Tue, 6 Aug 2019 11:37:39 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=popple.id.au Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 462chL72dbz9sN6; Tue, 6 Aug 2019 11:37:38 +1000 (AEST) From: Alistair Popple To: pdbg@lists.ozlabs.org Date: Tue, 6 Aug 2019 11:37:20 +1000 Message-Id: <20190806013723.4047-10-alistair@popple.id.au> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190806013723.4047-1-alistair@popple.id.au> References: <20190806013723.4047-1-alistair@popple.id.au> MIME-Version: 1.0 Subject: [Pdbg] [RFC 09/12] libpdbg: Initialise target class from device-tree X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: amitay@ozlabs.org Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" The target class is usually initialised from the hardware unit description. However if no hardware unit is found no class is assigned. This patch makes it possible to assign one in cases when no hardware unit is available. This is primarily useful for busses and other targets that have drivers assigned via the backend selection logic. Signed-off-by: Alistair Popple Reviewed-by: Amitay Isaacs --- libpdbg/device.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/libpdbg/device.c b/libpdbg/device.c index f6d27db..428d946 100644 --- a/libpdbg/device.c +++ b/libpdbg/device.c @@ -118,6 +118,8 @@ static struct pdbg_target *pdbg_target_new(const void *fdt, int node_offset) static struct pdbg_target *dt_new_node(const char *name, const void *fdt, int node_offset) { + struct pdbg_target_class *target_class; + const struct fdt_property *prop; struct pdbg_target *node = NULL; size_t size = sizeof(*node); @@ -132,6 +134,15 @@ static struct pdbg_target *dt_new_node(const char *name, const void *fdt, int no abort(); } + if (fdt && !node->class) { + prop = fdt_get_property(fdt, node_offset, "class", NULL); + if (prop) { + node->class = (char *) &prop->data[0]; + target_class = get_target_class(node); + list_add_tail(&target_class->targets, &node->class_link); + } + } + node->dn_name = take_name(name); node->parent = NULL; list_head_init(&node->properties); From patchwork Tue Aug 6 01:37:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Popple X-Patchwork-Id: 1142529 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 462chy6prXz9sN4 for ; Tue, 6 Aug 2019 11:38:10 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=popple.id.au Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 462chy4QcBzDqXW for ; Tue, 6 Aug 2019 11:38:10 +1000 (AEST) X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [IPv6:2401:3900:2:1::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 462chN23jnzDqWh for ; Tue, 6 Aug 2019 11:37:40 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=popple.id.au Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 462chM6dF3z9sN1; Tue, 6 Aug 2019 11:37:39 +1000 (AEST) From: Alistair Popple To: pdbg@lists.ozlabs.org Date: Tue, 6 Aug 2019 11:37:21 +1000 Message-Id: <20190806013723.4047-11-alistair@popple.id.au> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190806013723.4047-1-alistair@popple.id.au> References: <20190806013723.4047-1-alistair@popple.id.au> MIME-Version: 1.0 Subject: [Pdbg] [RFC 10/12] libpdbg: Make probe result matches the backend status X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: amitay@ozlabs.org Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" If a target has a backend assigned make sure the status reflects the status of the selected backend. Signed-off-by: Alistair Popple --- libpdbg/target.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/libpdbg/target.c b/libpdbg/target.c index 73ad98f..d6604c2 100644 --- a/libpdbg/target.c +++ b/libpdbg/target.c @@ -402,15 +402,16 @@ enum pdbg_target_status pdbg_target_probe(struct pdbg_target *target) } /* At this point any parents must exist and have already been probed */ - if (target->probe && target->probe(target)) { - /* Could not find the target */ - assert(pdbg_target_status(target) != PDBG_TARGET_MUSTEXIST); + if (target->backend && target->backend->probe && target->backend->probe(target->backend)) + target->backend->status = target->status = PDBG_TARGET_NONEXISTENT; + else if (target->probe && target->probe(target)) target->status = PDBG_TARGET_NONEXISTENT; - return PDBG_TARGET_NONEXISTENT; - } + else + target->status = PDBG_TARGET_ENABLED; + + assert(target->status != PDBG_TARGET_NONEXISTENT && target->status != PDBG_TARGET_MUSTEXIST); - target->status = PDBG_TARGET_ENABLED; - return PDBG_TARGET_ENABLED; + return target->status; } /* Releases a target by first recursively releasing all its children */ From patchwork Tue Aug 6 01:37:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Popple X-Patchwork-Id: 1142530 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 462cj15gfwz9sDB for ; Tue, 6 Aug 2019 11:38:13 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=popple.id.au Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 462cj14VSBzDqWh for ; Tue, 6 Aug 2019 11:38:13 +1000 (AEST) X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [IPv6:2401:3900:2:1::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 462chP3DX5zDqXW for ; Tue, 6 Aug 2019 11:37:41 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=popple.id.au Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 462chP0VT7z9sN6; Tue, 6 Aug 2019 11:37:41 +1000 (AEST) From: Alistair Popple To: pdbg@lists.ozlabs.org Date: Tue, 6 Aug 2019 11:37:22 +1000 Message-Id: <20190806013723.4047-12-alistair@popple.id.au> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190806013723.4047-1-alistair@popple.id.au> References: <20190806013723.4047-1-alistair@popple.id.au> MIME-Version: 1.0 Subject: [Pdbg] [RFC 11/12] libpdbg: Implement logic to link backends with each target X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: amitay@ozlabs.org Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Signed-off-by: Alistair Popple --- libpdbg/device.c | 37 +++++++++++++++++++++++++------------ libpdbg/target.c | 7 ++++++- 2 files changed, 31 insertions(+), 13 deletions(-) diff --git a/libpdbg/device.c b/libpdbg/device.c index 428d946..720a81b 100644 --- a/libpdbg/device.c +++ b/libpdbg/device.c @@ -686,27 +686,40 @@ static struct pdbg_target *pdbg_get_system_target(struct pdbg_target *backend_ta static void pdbg_link_backend_targets(struct pdbg_target *backend_target) { struct pdbg_target *system_target, *child; + char *target_path; + + /* Recursively link all child targets */ + pdbg_for_each_child_target(backend_target, child) + pdbg_link_backend_targets(child); system_target = pdbg_get_system_target(backend_target); - if (system_target) { + target_path = pdbg_target_property(backend_target, "target", NULL); + if (target_path) + backend_target = pdbg_target_from_path(pdbg_dt_root, target_path); + + if (system_target && backend_target) { PR_DEBUG("Linking backend target %s to system target %s\n", pdbg_target_path(backend_target), pdbg_target_path(system_target)); - /* The backend class must match the system class */ - assert(!strcmp(pdbg_target_class_name(backend_target), - pdbg_target_class_name(system_target))); + /* If the backend target actually implements the + * access methods (as indicated by the presence of a + * compatible property) make sure it matches the + * class. */ + if (backend_target->compatible) { + assert(get_target_class(backend_target) == get_target_class(system_target)); + } else { + assert(system_target->class); + backend_target->class = system_target->class; + } system_target->backend = backend_target; - /* A backend target shoudl always use it's own implementation for access */ + /* A backend target should always use it's own implementation for access */ backend_target->backend = backend_target; - } else { - PR_INFO("Unable to match backend at %s to system target %s", - pdbg_target_path(backend_target), pdbg_target_path(system_target)); + } else if (system_target) { + PR_INFO("Unable to find backend for %s at %s\n", pdbg_target_path(system_target), + target_path); + system_target->status = PDBG_TARGET_NONEXISTENT; } - - /* Recursively link all child targets as well */ - pdbg_for_each_child_target(backend_target, child) - pdbg_link_backend_targets(child); } void pdbg_backend_init(void *fdt) diff --git a/libpdbg/target.c b/libpdbg/target.c index d6604c2..5cbddac 100644 --- a/libpdbg/target.c +++ b/libpdbg/target.c @@ -338,6 +338,7 @@ struct pdbg_target_class *get_target_class(struct pdbg_target *target) { struct pdbg_target_class *target_class; + assert(target->class); if ((target_class = find_target_class(target->class))) return target_class; @@ -369,7 +370,11 @@ enum pdbg_target_status pdbg_target_probe(struct pdbg_target *target) * it's status won't have changed */ return status; - parent = target->parent; + if (target->backend) + parent = target->backend->parent; + else + parent = target->parent; + if (parent) { /* Recurse up the tree to probe and set parent target status */ pdbg_target_probe(parent); From patchwork Tue Aug 6 01:37:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Popple X-Patchwork-Id: 1142531 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 462cj40zj1z9sN4 for ; Tue, 6 Aug 2019 11:38:16 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=popple.id.au Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 462cj35pBWzDqWW for ; Tue, 6 Aug 2019 11:38:15 +1000 (AEST) X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [203.11.71.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 462chR07BtzDqXW for ; Tue, 6 Aug 2019 11:37:43 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=popple.id.au Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 462chQ2K9sz9sN1; Tue, 6 Aug 2019 11:37:42 +1000 (AEST) From: Alistair Popple To: pdbg@lists.ozlabs.org Date: Tue, 6 Aug 2019 11:37:23 +1000 Message-Id: <20190806013723.4047-13-alistair@popple.id.au> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190806013723.4047-1-alistair@popple.id.au> References: <20190806013723.4047-1-alistair@popple.id.au> MIME-Version: 1.0 Subject: [Pdbg] [RFC 12/12] libpdbg: Split system and backend definitions X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: amitay@ozlabs.org Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Signed-off-by: Alistair Popple --- Makefile.am | 33 ++++++-------- cronus-backend.dts.m4 | 28 ++++++++++++ host-backend.dts.m4 | 46 ++++++++++++++++++++ libpdbg/dtb.c | 97 +++++++++++++++++++++++++++++------------- obmc-backend.dts.m4 | 36 ++++++++++++++++ p8-fsi-backend.dts.m4 | 32 ++++++++++++++ p8-i2c-backend.dts.m4 | 22 ++++++++++ p8-pib.dts.m4 | 17 ++++++++ p8.dts.m4 | 71 +++++++++++++++++++++++++++++++ p9-fsi.dtsi.m4 | 43 ------------------- p9-pib.dts.m4 | 4 ++ p9.dts.m4 | 80 ++++++++++++++++++++++++++++++++++ p9r-fsi-backend.dts.m4 | 32 ++++++++++++++ p9r-fsi.dts.m4 | 16 ------- p9w-fsi-backend.dts.m4 | 32 ++++++++++++++ p9w-fsi.dts.m4 | 16 ------- p9z-fsi-backend.dts.m4 | 32 ++++++++++++++ p9z-fsi.dts.m4 | 16 ------- src/main.c | 1 + 19 files changed, 514 insertions(+), 140 deletions(-) create mode 100644 cronus-backend.dts.m4 create mode 100644 host-backend.dts.m4 create mode 100644 obmc-backend.dts.m4 create mode 100644 p8-fsi-backend.dts.m4 create mode 100644 p8-i2c-backend.dts.m4 create mode 100644 p8.dts.m4 delete mode 100644 p9-fsi.dtsi.m4 create mode 100644 p9.dts.m4 create mode 100644 p9r-fsi-backend.dts.m4 delete mode 100644 p9r-fsi.dts.m4 create mode 100644 p9w-fsi-backend.dts.m4 delete mode 100644 p9w-fsi.dts.m4 create mode 100644 p9z-fsi-backend.dts.m4 delete mode 100644 p9z-fsi.dts.m4 diff --git a/Makefile.am b/Makefile.am index 0f2906a..14b0a6c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -35,19 +35,17 @@ AM_CFLAGS = -I$(top_srcdir)/ccan/array_size -Wall -Werror -O2 EXTRA_DIST = \ fake.dts.m4 \ - backend.dts.m4 \ - p8-fsi.dts.m4 \ - p8-host.dts.m4 \ - p8-i2c.dts.m4 \ - p8-kernel.dts.m4 \ p8-pib.dts.m4 \ - p9-fsi.dtsi.m4 \ - p9-host.dts.m4 \ - p9-kernel.dts.m4 \ p9-pib.dts.m4 \ - p9r-fsi.dts.m4 \ - p9w-fsi.dts.m4 \ - p9z-fsi.dts.m4 \ + p8-fsi-backend.dts.m4 \ + p9r-fsi-backend.dts.m4 \ + p9w-fsi-backend.dts.m4 \ + p9z-fsi-backend.dts.m4 \ + p9.dts.m4 \ + p8.dts.m4 \ + obmc-backend.dts.m4 \ + host-backend.dts.m4 \ + cronus-backend.dts.m4 \ template.S \ generate_dt_header.sh \ src/gdb_parser.rl \ @@ -64,10 +62,10 @@ if TARGET_PPC ARCH_FLAGS="-DTARGET_PPC=1" endif -DT = fake.dts backend.dts p8-cronus.dts p9-cronus.dts \ - p8-fsi.dts p8-i2c.dts p8-kernel.dts \ - p9w-fsi.dts p9r-fsi.dts p9z-fsi.dts p9-kernel.dts \ - p8-host.dts p9-host.dts +DT = fake.dts \ + p9w-fsi-backend.dts p9r-fsi-backend.dts p9z-fsi-backend.dts p8-fsi-backend.dts \ + p8.dts p9.dts p8-i2c-backend.dts \ + obmc-backend.dts host-backend.dts cronus-backend.dts DT_sources = $(DT:.dts=.dtb.S) DT_headers = $(DT:.dts=.dt.h) @@ -253,11 +251,6 @@ RAGEL_V_0 = @echo " RAGEL " $@; %.dtsi: %.dtsi.m4 $(M4_V)$(M4) -I$(dir $<) $< > $@ -p9-fsi.dtsi: p9-fsi.dtsi.m4 p9-pib.dts.m4 -p9w-fsi.dts: p9w-fsi.dts.m4 p9-fsi.dtsi -p9r-fsi.dts: p9r-fsi.dts.m4 p9-fsi.dtsi -p9z-fsi.dts: p9z-fsi.dts.m4 p9-fsi.dtsi - %.dtb: %.dts $(DTC_V)$(DTC) -i$(dir $@) -I dts $< -O dtb > $@ diff --git a/cronus-backend.dts.m4 b/cronus-backend.dts.m4 new file mode 100644 index 0000000..aa31f85 --- /dev/null +++ b/cronus-backend.dts.m4 @@ -0,0 +1,28 @@ +/dts-v1/; + +/ { + fsi@0 { + compatible = "ibm,cronus-fsi"; + system-path = "/proc@0/fsi@0"; + }; + + pib@0 { + compatible = "ibm,cronus-pib"; + system-path = "/proc@0/pib@0"; + }; + + mem@0 { + system-path = "/mem@0"; + target = "/proc@0/pib@0/adu@90000"; + }; + + fsi@1 { + compatible = "ibm,cronus-fsi"; + system-path = "/proc@1/fsi@0"; + }; + + pib@1 { + compatible = "ibm,cronus-pib"; + system-path = "/proc@1/pib@1"; + }; +}; diff --git a/host-backend.dts.m4 b/host-backend.dts.m4 new file mode 100644 index 0000000..a188045 --- /dev/null +++ b/host-backend.dts.m4 @@ -0,0 +1,46 @@ +define(`HOST_PIB',` + pib@$1 { + #address-cells = <0x2>; + #size-cells = <0x1>; + compatible = "ibm,host-pib"; + reg = <$1>; + index = <$1>; + system-path = "/proc@$1/pib@$1"; + }')dnl + +/dts-v1/; + +/ { + HOST_PIB(0); + HOST_PIB(1); + HOST_PIB(2); + HOST_PIB(3); + HOST_PIB(4); + HOST_PIB(5); + HOST_PIB(6); + HOST_PIB(7); + HOST_PIB(8); + HOST_PIB(9); + HOST_PIB(10); + HOST_PIB(11); + HOST_PIB(12); + HOST_PIB(13); + HOST_PIB(14); + HOST_PIB(15); + HOST_PIB(16); + HOST_PIB(17); + HOST_PIB(18); + HOST_PIB(19); + HOST_PIB(20); + HOST_PIB(21); + HOST_PIB(22); + HOST_PIB(23); + HOST_PIB(24); + HOST_PIB(25); + HOST_PIB(26); + HOST_PIB(27); + HOST_PIB(28); + HOST_PIB(29); + HOST_PIB(30); + HOST_PIB(31); +}; diff --git a/libpdbg/dtb.c b/libpdbg/dtb.c index f6b235f..98ca374 100644 --- a/libpdbg/dtb.c +++ b/libpdbg/dtb.c @@ -30,18 +30,17 @@ #include "fake.dt.h" -#include "p8-i2c.dt.h" -#include "p8-fsi.dt.h" -#include "p8-kernel.dt.h" -#include "p9w-fsi.dt.h" -#include "p9r-fsi.dt.h" -#include "p9z-fsi.dt.h" -#include "p9-kernel.dt.h" -#include "p8-host.dt.h" -#include "p9-host.dt.h" -#include "p8-cronus.dt.h" -#include "p9-cronus.dt.h" -#include "backend.dt.h" +#include "p9.dt.h" +#include "p8.dt.h" + +#include "obmc-backend.dt.h" +#include "host-backend.dt.h" +#include "cronus-backend.dt.h" +#include "p8-fsi-backend.dt.h" +#include "p8-i2c-backend.dt.h" +#include "p9w-fsi-backend.dt.h" +#include "p9r-fsi-backend.dt.h" +#include "p9z-fsi-backend.dt.h" #define AMI_BMC "/proc/ractrends/Helper/FwInfo" #define OPENFSI_BMC "/sys/bus/platform/devices/gpio-fsi/fsi0/" @@ -85,9 +84,9 @@ static void *ppc_target(void) FILE *cpuinfo; if (!strcmp(pdbg_backend_option, "p8")) - return &_binary_p8_host_dtb_o_start; + return &_binary_p8_dtb_o_start; else if (!strcmp(pdbg_backend_option, "p9")) - return &_binary_p9_host_dtb_o_start; + return &_binary_p9_dtb_o_start; cpuinfo = fopen("/proc/cpuinfo", "r"); if (!cpuinfo) @@ -114,12 +113,12 @@ static void *ppc_target(void) if (strncmp(pos, "POWER8", 6) == 0) { pdbg_log(PDBG_INFO, "Found a POWER8 PPC host system\n"); - return &_binary_p8_host_dtb_o_start; + return &_binary_p8_dtb_o_start; } if (strncmp(pos, "POWER9", 6) == 0) { pdbg_log(PDBG_INFO, "Found a POWER9 PPC host system\n"); - return &_binary_p9_host_dtb_o_start; + return &_binary_p9_dtb_o_start; } pdbg_log(PDBG_ERROR, "Unsupported CPU type '%s'\n", pos); @@ -160,13 +159,13 @@ static void *bmc_target(void) switch(chip_id) { case CHIP_ID_P9: pdbg_log(PDBG_INFO, "Found a POWER9 OpenBMC based system\n"); - return &_binary_p9_kernel_dtb_o_start; + return &_binary_p9_dtb_o_start; break; case CHIP_ID_P8: case CHIP_ID_P8P: pdbg_log(PDBG_INFO, "Found a POWER8/8+ OpenBMC based system\n"); - return &_binary_p8_kernel_dtb_o_start; + return &_binary_p8_dtb_o_start; break; default: @@ -239,7 +238,7 @@ void *pdbg_default_dtb(void) case PDBG_BACKEND_I2C: /* I2C is only supported on POWER8 */ pdbg_log(PDBG_INFO, "Found a POWER8 AMI BMC based system\n"); - return &_binary_p8_i2c_dtb_o_start; + return &_binary_p8_dtb_o_start; break; case PDBG_BACKEND_KERNEL: @@ -254,13 +253,9 @@ void *pdbg_default_dtb(void) } if (!strcmp(pdbg_backend_option, "p8")) - return &_binary_p8_fsi_dtb_o_start; - else if (!strcmp(pdbg_backend_option, "p9w")) - return &_binary_p9w_fsi_dtb_o_start; - else if (!strcmp(pdbg_backend_option, "p9r")) - return &_binary_p9r_fsi_dtb_o_start; - else if (!strcmp(pdbg_backend_option, "p9z")) - return &_binary_p9z_fsi_dtb_o_start; + return &_binary_p8_dtb_o_start; + else if (!strncmp(pdbg_backend_option, "p9", 2)) + return &_binary_p9_dtb_o_start; else { pdbg_log(PDBG_ERROR, "Invalid device type specified\n"); pdbg_log(PDBG_ERROR, "Use 'p8' or 'p9r/p9w/p9z'\n"); @@ -277,9 +272,9 @@ void *pdbg_default_dtb(void) } if (!strncmp(pdbg_backend_option, "p8", 2)) - return &_binary_p8_cronus_dtb_o_start; + return &_binary_p8_dtb_o_start; else if (!strncmp(pdbg_backend_option, "p9", 2)) - return &_binary_p9_cronus_dtb_o_start; + return &_binary_p9_dtb_o_start; else { pdbg_log(PDBG_ERROR, "Invalid device type specified\n"); pdbg_log(PDBG_ERROR, "Use p8@ or p9@\n"); @@ -300,5 +295,49 @@ void *pdbg_default_dtb(void) void *pdbg_default_backend_dtb(void) { - return &_binary_backend_dtb_o_start; + char *dtb = getenv("PDBG_BACKEND_DTB"); + + if (dtb) + return mmap_dtb(dtb); + + switch(pdbg_backend) { + case PDBG_BACKEND_HOST: + return &_binary_host_backend_dtb_o_start; + break; + + case PDBG_BACKEND_I2C: + return &_binary_p8_i2c_backend_dtb_o_start; + break; + + case PDBG_BACKEND_KERNEL: + return &_binary_obmc_backend_dtb_o_start; + break; + + case PDBG_BACKEND_FSI: + if (!strcmp(pdbg_backend_option, "p9w")) + return &_binary_p9w_fsi_backend_dtb_o_start; + else if (!strcmp(pdbg_backend_option, "p9r")) + return &_binary_p9r_fsi_backend_dtb_o_start; + else if (!strcmp(pdbg_backend_option, "p9z")) + return &_binary_p9z_fsi_backend_dtb_o_start; + else if (!strcmp(pdbg_backend_option, "p8")) + return &_binary_p8_fsi_backend_dtb_o_start; + else + /* pdbg_default_dtb() should already have + * logged an error */ + return NULL; + break; + + case PDBG_BACKEND_CRONUS: + return &_binary_cronus_backend_dtb_o_start; + break; + + case PDBG_BACKEND_FAKE: + break; + + default: + assert(0); + } + + return NULL; } diff --git a/obmc-backend.dts.m4 b/obmc-backend.dts.m4 new file mode 100644 index 0000000..a28ef68 --- /dev/null +++ b/obmc-backend.dts.m4 @@ -0,0 +1,36 @@ +/dts-v1/; + +/ { + fsi@0 { + compatible = "ibm,kernel-fsi"; + system-path = "/proc@0/fsi@0"; + }; + + pib@0 { + compatible = "ibm,kernel-pib"; + system-path = "/proc@0/pib@0"; + device-path = "/dev/scom1"; + }; + + sbefifo@0 { + compatible = "ibm,kernel-sbefifo"; + device-path = "/dev/sbefifo1"; + system-path = "/proc@0/fsi@0/sbefifo@0"; + }; + + mem@0 { + system-path = "/mem@0"; + target = "/proc@0/fsi@0/sbefifo@0/sbefifo-mem@0"; + }; + + fsi@1 { + compatible = "ibm,kernel-fsi"; + system-path = "/proc@1/fsi@0"; + }; + + pib@1 { + compatible = "ibm,kernel-pib"; + system-path = "/proc@1/pib@1"; + device-path = "/dev/scom2"; + }; +}; diff --git a/p8-fsi-backend.dts.m4 b/p8-fsi-backend.dts.m4 new file mode 100644 index 0000000..fa5f1f4 --- /dev/null +++ b/p8-fsi-backend.dts.m4 @@ -0,0 +1,32 @@ +/dts-v1/; + +/ { + fsi@0 { + compatible = "ibm,bmcfsi"; + + /* GPIO pin definitions */ + fsi_clk = <0x0 0x4>; /* A4 */ + fsi_dat = <0x0 0x5>; /* A5 */ + fsi_dat_en = <0x20 0x1e>; /* H6 */ + fsi_enable = <0x0 0x18>; /* D0 */ + cronus_sel = <0x0 0x6>; /* A6 */ + clock_delay = <0x14>; + + system-path = "/proc@0/fsi@0"; + }; + + pib@0 { + target = "/proc@0/fsi@0/pib@0"; + system-path = "/proc@0/pib@0"; + }; + + fsi@1 { + target = "/proc@0/pib@0/opb@0/hmfsi@1"; + system-path = "/proc@1/fsi@1"; + }; + + pib@1 { + target = "/proc@1/fsi@1/pib@1"; + system-path = "/proc@1/pib@1"; + }; +}; diff --git a/p8-i2c-backend.dts.m4 b/p8-i2c-backend.dts.m4 new file mode 100644 index 0000000..ffd0b06 --- /dev/null +++ b/p8-i2c-backend.dts.m4 @@ -0,0 +1,22 @@ +/dts-v1/; + +/ { + pib@0 { + compatible = "ibm,power8-i2c-slave"; + bus = "/dev/i2c4"; + reg = <0x50>; + index = <0x0>; + + system-path = "/proc@0/pib@0"; + }; + + fsi@1 { + target = "/proc@0/pib@0/opb@20010/hmfsi@0"; + system-path = "/proc@1/fsi@1"; + }; + + pib@1 { + target = "/proc@1/fsi@1/pib@1000"; + system-path = "/proc@1/pib@1"; + }; +}; diff --git a/p8-pib.dts.m4 b/p8-pib.dts.m4 index 82d11d8..b648d3a 100644 --- a/p8-pib.dts.m4 +++ b/p8-pib.dts.m4 @@ -52,4 +52,21 @@ nhtm@2010880 { index = <0x0>; }; +opb@0 { + #address-cells = <0x1>; + #size-cells = <0x1>; + reg = <0x0 0x20010 0xa>; + compatible = "ibm,power8-opb"; + index = <0x0>; + + hmfsi@1 { + #address-cells = <0x2>; + #size-cells = <0x1>; + compatible = "ibm,power8-opb-hmfsi"; + reg = <0x180000 0x80000>; + port = <0x2>; + index = <0x1>; + }; +}; + PROC_CORES; diff --git a/p8.dts.m4 b/p8.dts.m4 new file mode 100644 index 0000000..320bd0c --- /dev/null +++ b/p8.dts.m4 @@ -0,0 +1,71 @@ +define(`PIB',` + pib@$1 { + #address-cells = <0x2>; + #size-cells = <0x1>; + reg = <$1>; + index = <$1>; + class = "pib"; + include(p8-pib.dts.m4)dnl + }')dnl + +define(`PROC',` + proc@$1 { + class = "proc"; + index = <$1>; + PIB($1); + + fsi@$1 { + #address-cells = <0x2>; + #size-cells = <0x1>; + class = "fsi"; + index = <$1>; + + pib@$1 { + #address-cells = <0x2>; + #size-cells = <0x1>; + reg = <0x0 0x1000 0x7>; + index = <$1>; + compatible = "ibm,fsi-pib"; + }; + }; + }')dnl + +/dts-v1/; + +/ { + #address-cells = <0x1>; + #size-cells = <0x0>; + + PROC(0); + PROC(1); + PROC(2); + PROC(3); + PROC(4); + PROC(5); + PROC(6); + PROC(7); + PROC(8); + PROC(9); + PROC(10); + PROC(11); + PROC(12); + PROC(13); + PROC(14); + PROC(15); + PROC(16); + PROC(17); + PROC(18); + PROC(19); + PROC(20); + PROC(21); + PROC(22); + PROC(23); + PROC(24); + PROC(25); + PROC(26); + PROC(27); + PROC(28); + PROC(29); + PROC(30); + PROC(31); +}; diff --git a/p9-fsi.dtsi.m4 b/p9-fsi.dtsi.m4 deleted file mode 100644 index afa7d39..0000000 --- a/p9-fsi.dtsi.m4 +++ /dev/null @@ -1,43 +0,0 @@ - -/ { - #address-cells = <0x1>; - #size-cells = <0x0>; - - fsi0: fsi@0 { - #address-cells = <0x2>; - #size-cells = <0x1>; - compatible = "ibm,bmcfsi"; - reg = <0x0 0x0 0x0>; - - index = <0x0>; - status = "mustexist"; - - pib@1000 { - #address-cells = <0x2>; - #size-cells = <0x1>; - reg = <0x0 0x1000 0x7>; - index = <0x0>; - compatible = "ibm,fsi-pib", "ibm,power9-fsi-pib"; - include(p9-pib.dts.m4)dnl - }; - - hmfsi@100000 { - #address-cells = <0x2>; - #size-cells = <0x1>; - compatible = "ibm,fsi-hmfsi"; - reg = <0x0 0x100000 0x8000>; - port = <0x1>; - index = <0x1>; - - pib@1000 { - #address-cells = <0x2>; - #size-cells = <0x1>; - reg = <0x0 0x1000 0x7>; - index = <0x1>; - compatible = "ibm,fsi-pib", "ibm,power9-fsi-pib"; - include(p9-pib.dts.m4)dnl - }; - }; - - }; -}; diff --git a/p9-pib.dts.m4 b/p9-pib.dts.m4 index 3a99157..173fa2f 100644 --- a/p9-pib.dts.m4 +++ b/p9-pib.dts.m4 @@ -35,6 +35,10 @@ index = ; reg = <0x0 HEX(CHIPLET_BASE($1)) 0xfffff>; }')dnl +adu@90000 { + compatible = "ibm,power9-adu"; + reg = <0x0 0x90000 0x5>; +}; htm@5012880 { compatible = "ibm,power9-nhtm"; diff --git a/p9.dts.m4 b/p9.dts.m4 new file mode 100644 index 0000000..25f15c0 --- /dev/null +++ b/p9.dts.m4 @@ -0,0 +1,80 @@ +/dts-v1/; + +/ { + #address-cells = <0x1>; + #size-cells = <0x0>; + + proc@0 { + index = <0x0>; + class = "proc"; + + pib@0 { + #address-cells = <0x2>; + #size-cells = <0x1>; + + index = <0x0>; + class = "pib"; + include(p9-pib.dts.m4)dnl + }; + + fsi@0 { + #address-cells = <0x2>; + #size-cells = <0x1>; + + index = <0x0>; + class = "fsi"; + + pib@1000 { + reg = < 0x00 0x1000 0x07 >; + index = < 0x00 >; + compatible = "ibm,fsi-pib", "ibm,power9-fsi-pib"; + }; + + hmfsi@100000 { + #address-cells = <0x2>; + #size-cells = <0x1>; + compatible = "ibm,fsi-hmfsi"; + reg = <0x0 0x100000 0x8000>; + port = <0x1>; + index = <0x1>; + }; + + sbefifo@2400 { + reg = <0x0 0x2400 0x7>; + index = <0x0>; + + sbefifo-mem@0 { + index = <0x0>; + compatible = "ibm,sbefifo-mem"; + }; + }; + }; + }; + + proc@1 { + index = <0x1>; + class = "proc"; + + pib@1 { + #address-cells = <0x2>; + #size-cells = <0x1>; + + index = <0x1>; + class = "pib"; + include(p9-pib.dts.m4)dnl + }; + + fsi@0 { + #address-cells = <0x2>; + #size-cells = <0x1>; + + index = <0x1>; + class = "fsi"; + }; + }; + + mem@0 { + index = <0x0>; + class = "mem"; + }; +}; diff --git a/p9r-fsi-backend.dts.m4 b/p9r-fsi-backend.dts.m4 new file mode 100644 index 0000000..1630823 --- /dev/null +++ b/p9r-fsi-backend.dts.m4 @@ -0,0 +1,32 @@ +/dts-v1/; + +/ { + fsi@0 { + compatible = "ibm,bmcfsi"; + + /* GPIO pin definitions */ + fsi_clk = <0x1e0 0x10>; /* AA0 */ + fsi_dat = <0x1e0 0x12>; /* AA2 */ + fsi_dat_en = <0x80 0xa>; /* R2 */ + fsi_enable = <0x0 0x18>; /* D0 */ + cronus_sel = <0x0 0x6>; /* A6 */ + clock_delay = <0x14>; + + system-path = "/proc@0/fsi@0"; + }; + + pib@0 { + target = "/proc@0/fsi@0/pib@1000"; + system-path = "/proc@0/pib@0"; + }; + + fsi@1 { + target = "/proc@0/fsi@0/hmfsi@0"; + system-path = "/proc@1/fsi@1"; + }; + + pib@1 { + target = "/proc@1/fsi@1/pib@1000"; + system-path = "/proc@1/pib@1"; + }; +}; diff --git a/p9r-fsi.dts.m4 b/p9r-fsi.dts.m4 deleted file mode 100644 index 2165bae..0000000 --- a/p9r-fsi.dts.m4 +++ /dev/null @@ -1,16 +0,0 @@ -/dts-v1/; - -/include/ "p9-fsi.dtsi" - -/ { -}; - -&fsi0 { - /* GPIO pin definitions */ - fsi_clk = <0x1e0 0x10>; /* AA0 */ - fsi_dat = <0x1e0 0x12>; /* AA2 */ - fsi_dat_en = <0x80 0xa>; /* R2 */ - fsi_enable = <0x0 0x18>; /* D0 */ - cronus_sel = <0x0 0x6>; /* A6 */ - clock_delay = <0x14>; -}; diff --git a/p9w-fsi-backend.dts.m4 b/p9w-fsi-backend.dts.m4 new file mode 100644 index 0000000..2696459 --- /dev/null +++ b/p9w-fsi-backend.dts.m4 @@ -0,0 +1,32 @@ +/dts-v1/; + +/ { + fsi@0 { + compatible = "ibm,bmcfsi"; + + /* GPIO pin definitions */ + fsi_clk = <0x1e0 0x10>; /* AA0 */ + fsi_dat = <0x20 0x0>; /* E0 */ + fsi_dat_en = <0x80 0xa>; /* R2 */ + fsi_enable = <0x0 0x18>; /* D0 */ + cronus_sel = <0x0 0x6>; /* A6 */ + clock_delay = <0x14>; + + system-path = "/proc@0/fsi@0"; + }; + + pib@0 { + target = "/proc@0/fsi@0/pib@1000"; + system-path = "/proc@0/pib@0"; + }; + + fsi@1 { + target = "/proc@0/fsi@0/hmfsi@0"; + system-path = "/proc@1/fsi@1"; + }; + + pib@1 { + target = "/proc@1/fsi@1/pib@1000"; + system-path = "/proc@1/pib@1"; + }; +}; diff --git a/p9w-fsi.dts.m4 b/p9w-fsi.dts.m4 deleted file mode 100644 index 224c665..0000000 --- a/p9w-fsi.dts.m4 +++ /dev/null @@ -1,16 +0,0 @@ -/dts-v1/; - -/include/ "p9-fsi.dtsi" - -/ { -}; - -&fsi0 { - /* GPIO pin definitions */ - fsi_clk = <0x1e0 0x10>; /* AA0 */ - fsi_dat = <0x20 0x0>; /* E0 */ - fsi_dat_en = <0x80 0xa>; /* R2 */ - fsi_enable = <0x0 0x18>; /* D0 */ - cronus_sel = <0x0 0x6>; /* A6 */ - clock_delay = <0x14>; -}; diff --git a/p9z-fsi-backend.dts.m4 b/p9z-fsi-backend.dts.m4 new file mode 100644 index 0000000..d0956cf --- /dev/null +++ b/p9z-fsi-backend.dts.m4 @@ -0,0 +1,32 @@ +/dts-v1/; + +/ { + fsi@0 { + compatible = "ibm,bmcfsi"; + + /* GPIO pin definitions */ + fsi_clk = <0x0 0x13>; /* C3 */ + fsi_dat = <0x0 0x12>; /* C2 */ + fsi_dat_en = <0x78 0x16>; /* O6 */ + fsi_enable = <0x0 0x18>; /* D0 */ + cronus_sel = <0x78 0x1e>; /* P6 */ + clock_delay = <0x14>; + + system-path = "/proc@0/fsi@0"; + }; + + pib@0 { + target = "/proc@0/fsi@0/pib@1000"; + system-path = "/proc@0/pib@0"; + }; + + fsi@1 { + target = "/proc@0/fsi@0/hmfsi@0"; + system-path = "/proc@1/fsi@1"; + }; + + pib@1 { + target = "/proc@1/fsi@1/pib@1000"; + system-path = "/proc@1/pib@1"; + }; +}; diff --git a/p9z-fsi.dts.m4 b/p9z-fsi.dts.m4 deleted file mode 100644 index 87ad5c2..0000000 --- a/p9z-fsi.dts.m4 +++ /dev/null @@ -1,16 +0,0 @@ -/dts-v1/; - -/include/ "p9-fsi.dtsi" - -/ { -}; - -&fsi0 { - /* GPIO pin definitions */ - fsi_clk = <0x0 0x13>; /* C3 */ - fsi_dat = <0x0 0x12>; /* C2 */ - fsi_dat_en = <0x78 0x16>; /* O6 */ - fsi_enable = <0x0 0x18>; /* D0 */ - cronus_sel = <0x78 0x1e>; /* P6 */ - clock_delay = <0x14>; -}; diff --git a/src/main.c b/src/main.c index 3a8b0a0..99e4097 100644 --- a/src/main.c +++ b/src/main.c @@ -582,6 +582,7 @@ int main(int argc, char *argv[]) pdbg_set_backend(backend, device_node); pdbg_targets_init(NULL); + pdbg_backend_init(NULL); if (pathsel_count) { if (!path_target_parse(pathsel, pathsel_count))