From patchwork Wed Sep 14 13:22:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 605739 Delivered-To: patch@linaro.org Received: by 2002:ab3:1c02:0:b0:1e7:4ce8:c350 with SMTP id u2csp772896lth; Wed, 14 Sep 2022 07:14:28 -0700 (PDT) X-Google-Smtp-Source: AA6agR61sEl5XAz2KIrbT2+CSJ2ar0Q18I/KRZk302Bw6cvooq5ywGl+X+l46mjaTXpP7mNE2Rmw X-Received: by 2002:a05:620a:1a17:b0:6ce:7c1b:c27f with SMTP id bk23-20020a05620a1a1700b006ce7c1bc27fmr4901203qkb.42.1663164868275; Wed, 14 Sep 2022 07:14:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663164868; cv=none; d=google.com; s=arc-20160816; b=iLq6vv6PXXMP9fQDcel7aUFDyaj8vQ7Ebr+6DndigHCIgOwb8aEnIZxYoRKV7Du4kV F/OGWWpK/tOR8p0GopcB1gwERFC4iNhRR9APizYiV5RlmrWvQgA2hpz2RvFpMdmbJe/r wMGJEU7T6YYCzjlOAkBck1JJMBoYq/HJ+3m1Qsg97pCoreYOUQjyCC9VJyAZ31BCS9ta 1a6S4l3EiCoNbuKrxPV6lTyuZb7Y9xZzSf1Dql6I2THxHj67WN9+wh6A5/ZYOL7xELsM dh6dNJ0P3vLmiLsR5k5oYkKkBEpc2J5SBjxbuDDQxWlT3mYD2FUA0eXLqXWPhWg85N9S Pogg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=KfQlb4Kf/qCPlICOyHg/LYLEi3mUvRQuhI0h+42sfkk=; b=ox710UOYe0ePxfq/Ai2F7e1H14BjgwaDkCxRMGvprPoxhJV6IImo1hsPygSzpfp5r9 H7KIaA+uApv5iQpS9fNzCVpZk97mFuyNSCab850K8+LzishFdnVXR+98+QhEak8s0YHj wfKIXmoFedMPsHByWAsblDpfmXBABLz63PRbIg8UMISqm4cDoGEy7Jy0WiUtKHVsZExV fVyCg4HaG4qNCyzBDA6qj3iXx1htsoVhfr0svDurxuJtaXYts/zemNNeTQh5kBkjez1F wvRWayRuvc01vO5I8VUluXzvZF/NP3lHKwH3DhRnS0iUcbAxwHLzPr14rqNMzhaCNW17 ad0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jvpEOt99; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id f11-20020a05620a280b00b006b9524ce6c2si1581213qkp.61.2022.09.14.07.14.28 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 14 Sep 2022 07:14:28 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jvpEOt99; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:46060 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oYT9n-0005OZ-Oh for patch@linaro.org; Wed, 14 Sep 2022 10:14:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48356) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oYSMF-0007sP-QV for qemu-devel@nongnu.org; Wed, 14 Sep 2022 09:23:15 -0400 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]:34397) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oYSME-0000aW-5k for qemu-devel@nongnu.org; Wed, 14 Sep 2022 09:23:15 -0400 Received: by mail-wr1-x431.google.com with SMTP id bo13so9176147wrb.1 for ; Wed, 14 Sep 2022 06:23:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date; bh=KfQlb4Kf/qCPlICOyHg/LYLEi3mUvRQuhI0h+42sfkk=; b=jvpEOt99C5m7h8E77uvE264WK2oedEd/sTUfW1MGIytU3fVdm0OmRrk9OTNR+Gu7x5 A11Kp32L354S7DWiCPrTEcHHAjwPXhsC9ffZzVMSvWwTaUqeupujsu7CLc09xKBlRZma vCGlQIHKPkntz5BvA0o3txCvgzvLqYhfZBrn2CkBoYSTHnoEj49F2zz1zWPRxFjim14N sHT1pjJuYFWA4faZG6tltGd8JmIR8ADODoiWPdszQX1kVShXSCKqIH9iTgc3E0fqI8o/ w+0FqeDBsgy2fuYhH52BR8+lWXlmA9M75Z50OH6J52VWafB6VKVogiU9E5tNpHoGyicG G9PA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date; bh=KfQlb4Kf/qCPlICOyHg/LYLEi3mUvRQuhI0h+42sfkk=; b=2W+zXrrOA486BebAP9gKsKIJYiY2TiyZwPB+hflGt2nHWCTvoGLxw313enKsKqrnZg ZHF1xD5Gpn1Ybu/6jhwu0aljjNKvFMQr4b4ZwlEJnCn5w9E1kGH/6c7qYwyi3dG8D4CY Jm3owfD40hnx7CThb2YX0Au/aE0T4nKXlCD3dX9t4e8nDz8S5t+gDvLmvAgo3C4Zi2L3 WfznuVXj2CtL5wQ9zj/+gNmxE7WV0dK6Ni161L+FBWv8pItsaaBEjnlAgpWUnPARo5Rt 3u2SzfIGlbvjkRyjzmlbhvUbje6gTjP1mj/wmPcpiElBdfw+pQ2k14pP1qd2ECVnaaAw cG2w== X-Gm-Message-State: ACgBeo0nRINrnlIwdIHZYi/CJwpqHXNh0SIynjz2IDWpWcJtZK+CL2U3 eG6QcqKn22WF+kfKZ1aoQoP9RPaCpRG4goW1 X-Received: by 2002:a05:6000:1189:b0:228:62c7:7e6c with SMTP id g9-20020a056000118900b0022862c77e6cmr22490110wrx.716.1663161792683; Wed, 14 Sep 2022 06:23:12 -0700 (PDT) Received: from stoup.. ([89.101.193.70]) by smtp.gmail.com with ESMTPSA id p15-20020a5d48cf000000b00226dedf1ab7sm13768244wrs.76.2022.09.14.06.23.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Sep 2022 06:23:12 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 02/11] target/nios2: Convert semihosting errno to gdb remote errno Date: Wed, 14 Sep 2022 14:22:59 +0100 Message-Id: <20220914132308.118495-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220914132308.118495-1-richard.henderson@linaro.org> References: <20220914132308.118495-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::431; envelope-from=richard.henderson@linaro.org; helo=mail-wr1-x431.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The semihosting abi used by nios2 uses the gdb remote protocol filesys errnos. Signed-off-by: Richard Henderson --- target/nios2/nios2-semi.c | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/target/nios2/nios2-semi.c b/target/nios2/nios2-semi.c index 614fd76695..f76e8588c5 100644 --- a/target/nios2/nios2-semi.c +++ b/target/nios2/nios2-semi.c @@ -43,6 +43,35 @@ #define HOSTED_ISATTY 12 #define HOSTED_SYSTEM 13 +static int host_to_gdb_errno(int err) +{ +#define E(X) case E##X: return GDB_E##X + switch (err) { + E(PERM); + E(NOENT); + E(INTR); + E(BADF); + E(ACCES); + E(FAULT); + E(BUSY); + E(EXIST); + E(NODEV); + E(NOTDIR); + E(ISDIR); + E(INVAL); + E(NFILE); + E(MFILE); + E(FBIG); + E(NOSPC); + E(SPIPE); + E(ROFS); + E(NAMETOOLONG); + default: + return GDB_EUNKNOWN; + } +#undef E +} + static void nios2_semi_u32_cb(CPUState *cs, uint64_t ret, int err) { Nios2CPU *cpu = NIOS2_CPU(cs); @@ -50,7 +79,7 @@ static void nios2_semi_u32_cb(CPUState *cs, uint64_t ret, int err) target_ulong args = env->regs[R_ARG1]; if (put_user_u32(ret, args) || - put_user_u32(err, args + 4)) { + put_user_u32(host_to_gdb_errno(err), args + 4)) { /* * The nios2 semihosting ABI does not provide any way to report this * error to the guest, so the best we can do is log it in qemu. @@ -69,7 +98,7 @@ static void nios2_semi_u64_cb(CPUState *cs, uint64_t ret, int err) if (put_user_u32(ret >> 32, args) || put_user_u32(ret, args + 4) || - put_user_u32(err, args + 8)) { + put_user_u32(host_to_gdb_errno(err), args + 8)) { /* No way to report this via nios2 semihosting ABI; just log it */ qemu_log_mask(LOG_GUEST_ERROR, "nios2-semihosting: return value " "discarded because argument block not writable\n");