From patchwork Fri Feb 28 16:43:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taylor Simpson X-Patchwork-Id: 11412987 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6AB7F138D for ; Fri, 28 Feb 2020 17:15:35 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4289A246A2 for ; Fri, 28 Feb 2020 17:15:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="UP3xBp8O" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4289A246A2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=quicinc.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:51112 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j7jEc-0002NR-E1 for patchwork-qemu-devel@patchwork.kernel.org; Fri, 28 Feb 2020 12:15:34 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58378) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j7im1-0005ax-0m for qemu-devel@nongnu.org; Fri, 28 Feb 2020 11:46:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j7ilz-00079p-Pv for qemu-devel@nongnu.org; Fri, 28 Feb 2020 11:46:00 -0500 Received: from alexa-out-sd-02.qualcomm.com ([199.106.114.39]:27026) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j7ilz-0005U4-GM for qemu-devel@nongnu.org; Fri, 28 Feb 2020 11:45:59 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1582908359; x=1614444359; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=DFiYq/TqpVVEyNz6Bpz3GlX93C54CgCm5kaxbuGCrBA=; b=UP3xBp8Oew2St3TcWoHwUnD1Nl7+QmV+4LaKtx7BwdC10hY1f7S1J7aK +6p0iDbNu+eGd0/mQZACpUxSuI/wx0QaeS8fXIvx5HAvqeEKSQuRArYjQ fZ2RDw6wK8agqC9k7kBT5zQuQUBu7+djA7Nc9bdfvFWmEhBTB2Id9nxbe U=; Received: from unknown (HELO ironmsg01-sd.qualcomm.com) ([10.53.140.141]) by alexa-out-sd-02.qualcomm.com with ESMTP; 28 Feb 2020 08:44:34 -0800 Received: from vu-tsimpson-aus.qualcomm.com (HELO vu-tsimpson1-aus.qualcomm.com) ([10.222.150.1]) by ironmsg01-sd.qualcomm.com with ESMTP; 28 Feb 2020 08:44:33 -0800 Received: by vu-tsimpson1-aus.qualcomm.com (Postfix, from userid 47164) id E515D1110; Fri, 28 Feb 2020 10:44:32 -0600 (CST) From: Taylor Simpson To: qemu-devel@nongnu.org Subject: [RFC PATCH v2 55/67] Hexagon HVX support in gdbstub Date: Fri, 28 Feb 2020 10:43:51 -0600 Message-Id: <1582908244-304-56-git-send-email-tsimpson@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1582908244-304-1-git-send-email-tsimpson@quicinc.com> References: <1582908244-304-1-git-send-email-tsimpson@quicinc.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: FreeBSD 9.x [fuzzy] X-Received-From: 199.106.114.39 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: riku.voipio@iki.fi, richard.henderson@linaro.org, laurent@vivier.eu, Taylor Simpson , philmd@redhat.com, aleksandar.m.mail@gmail.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Taylor Simpson --- target/hexagon/gdbstub.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/target/hexagon/gdbstub.c b/target/hexagon/gdbstub.c index e678aea..79a4f33 100644 --- a/target/hexagon/gdbstub.c +++ b/target/hexagon/gdbstub.c @@ -21,6 +21,28 @@ #include "cpu.h" #include "internal.h" +static int gdb_get_vreg(CPUHexagonState *env, uint8_t *mem_buf, int n) +{ + int total = 0; + int i; + for (i = 0; i < MAX_VEC_SIZE_BYTES / 4; i++) { + total += gdb_get_regl(mem_buf, env->VRegs[n].uw[i]); + mem_buf += 4; + } + return total; +} + +static int gdb_get_qreg(CPUHexagonState *env, uint8_t *mem_buf, int n) +{ + int total = 0; + int i; + for (i = 0; i < MAX_VEC_SIZE_BYTES / 4 / 8; i++) { + total += gdb_get_regl(mem_buf, env->QRegs[n].uw[i]); + mem_buf += 4; + } + return total; +} + int hexagon_gdb_read_register(CPUState *cs, uint8_t *mem_buf, int n) { HexagonCPU *cpu = HEXAGON_CPU(cs); @@ -29,11 +51,41 @@ int hexagon_gdb_read_register(CPUState *cs, uint8_t *mem_buf, int n) if (n < TOTAL_PER_THREAD_REGS) { return gdb_get_regl(mem_buf, env->gpr[n]); } + n -= TOTAL_PER_THREAD_REGS; + + if (n < NUM_VREGS) { + return gdb_get_vreg(env, mem_buf, n); + } + n -= NUM_VREGS; + + if (n < NUM_QREGS) { + return gdb_get_qreg(env, mem_buf, n); + } g_assert_not_reached(); return 0; } +static int gdb_put_vreg(CPUHexagonState *env, uint8_t *mem_buf, int n) +{ + int i; + for (i = 0; i < MAX_VEC_SIZE_BYTES / 4; i++) { + env->VRegs[n].uw[i] = ldtul_p(mem_buf); + mem_buf += 4; + } + return MAX_VEC_SIZE_BYTES; +} + +static int gdb_put_qreg(CPUHexagonState *env, uint8_t *mem_buf, int n) +{ + int i; + for (i = 0; i < MAX_VEC_SIZE_BYTES / 4 / 8; i++) { + env->QRegs[n].uw[i] = ldtul_p(mem_buf); + mem_buf += 4; + } + return MAX_VEC_SIZE_BYTES / 8; +} + int hexagon_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) { HexagonCPU *cpu = HEXAGON_CPU(cs); @@ -43,6 +95,16 @@ int hexagon_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) env->gpr[n] = ldtul_p(mem_buf); return sizeof(target_ulong); } + n -= TOTAL_PER_THREAD_REGS; + + if (n < NUM_VREGS) { + return gdb_put_vreg(env, mem_buf, n); + } + n -= NUM_VREGS; + + if (n < NUM_QREGS) { + return gdb_put_qreg(env, mem_buf, n); + } g_assert_not_reached(); return 0;