From patchwork Sat Dec 26 19:46:42 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Frysinger X-Patchwork-Id: 10141 Received: (qmail 11997 invoked by alias); 26 Dec 2015 19:47:05 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 11988 invoked by uid 89); 26 Dec 2015 19:47:04 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 spammy=initiated, dma, 2015-12-26 X-HELO: smtp.gentoo.org Received: from smtp.gentoo.org (HELO smtp.gentoo.org) (140.211.166.183) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Sat, 26 Dec 2015 19:47:04 +0000 Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.gentoo.org (Postfix) with ESMTP id C7B963405BB for ; Sat, 26 Dec 2015 19:47:01 +0000 (UTC) From: Mike Frysinger To: gdb-patches@sourceware.org Subject: [PATCH] sim: sim-core: pass down cpu to hw accesses when available [committed] Date: Sat, 26 Dec 2015 14:46:42 -0500 Message-Id: <1451159202-19787-1-git-send-email-vapier@gentoo.org> X-IsSubscribed: yes The bfin port has been using the device callback largely so it could be passed the cpu when available. Add this logic to the common core code so all ports get access to the active cpu. The semantics of these buffer functions are changed slightly in that errors halt the engine synchronously rather than returning the length to the caller. We'll probably adjust this in a follow up commit. The bfin code isn't updated just yet as it has a bit more logic in the device layer that needs to be unwound at which point we can delete it entirely. --- sim/common/ChangeLog | 7 +++++++ sim/common/sim-core.c | 44 ++++++++++++++++++++++++++++++++++---------- 2 files changed, 41 insertions(+), 10 deletions(-) diff --git a/sim/common/ChangeLog b/sim/common/ChangeLog index 3e6e3d9..05cdda8 100644 --- a/sim/common/ChangeLog +++ b/sim/common/ChangeLog @@ -1,3 +1,10 @@ +2015-12-26 Mike Frysinger + + * sim-core.c (sim_core_read_buffer): Move cia decl to top of func. + Call sim_cpu_hw_io_read_buffer if cpu is valid. + (sim_core_write_buffer): Move cia decl to top of func. Call + sim_cpu_hw_io_write_buffer if cpu is valid. + 2015-12-25 Mike Frysinger * hw-properties.c (hw_find_ihandle_runtime_property): Delete diff --git a/sim/common/sim-core.c b/sim/common/sim-core.c index 26fabd5..68212e9 100644 --- a/sim/common/sim-core.c +++ b/sim/common/sim-core.c @@ -511,11 +511,23 @@ sim_core_read_buffer (SIM_DESC sd, int nr_bytes = len - count; if (raddr + nr_bytes - 1> mapping->bound) nr_bytes = mapping->bound - raddr + 1; - if (sim_hw_io_read_buffer (sd, mapping->device, - (unsigned_1*)buffer + count, - mapping->space, - raddr, - nr_bytes) != nr_bytes) + /* If the access was initiated by a cpu, pass it down so errors can + be propagated properly. For other sources (e.g. GDB or DMA), we + can only signal errors via the return value. */ + if (cpu) + { + sim_cia cia = cpu ? CPU_PC_GET (cpu) : NULL_CIA; + sim_cpu_hw_io_read_buffer (cpu, cia, mapping->device, + (unsigned_1*)buffer + count, + mapping->space, + raddr, + nr_bytes); + } + else if (sim_hw_io_read_buffer (sd, mapping->device, + (unsigned_1*)buffer + count, + mapping->space, + raddr, + nr_bytes) != nr_bytes) break; count += nr_bytes; continue; @@ -577,11 +589,23 @@ sim_core_write_buffer (SIM_DESC sd, int nr_bytes = len - count; if (raddr + nr_bytes - 1 > mapping->bound) nr_bytes = mapping->bound - raddr + 1; - if (sim_hw_io_write_buffer (sd, mapping->device, - (unsigned_1*)buffer + count, - mapping->space, - raddr, - nr_bytes) != nr_bytes) + /* If the access was initiated by a cpu, pass it down so errors can + be propagated properly. For other sources (e.g. GDB or DMA), we + can only signal errors via the return value. */ + if (cpu) + { + sim_cia cia = cpu ? CPU_PC_GET (cpu) : NULL_CIA; + sim_cpu_hw_io_write_buffer (cpu, cia, mapping->device, + (unsigned_1*)buffer + count, + mapping->space, + raddr, + nr_bytes); + } + else if (sim_hw_io_write_buffer (sd, mapping->device, + (unsigned_1*)buffer + count, + mapping->space, + raddr, + nr_bytes) != nr_bytes) break; count += nr_bytes; continue;