From patchwork Sat May 21 00:03:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 574932 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1f0e:0:0:0:0 with SMTP id hs14csp2676808mab; Fri, 20 May 2022 17:47:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzMvXqbfqC1uqtPaM0/2mPBET8iLUweebYchDydTwMEuHMYklAwyfGaFvFR1txq2OOL6phs X-Received: by 2002:a05:622a:44a:b0:2f3:b5b5:d42c with SMTP id o10-20020a05622a044a00b002f3b5b5d42cmr9602618qtx.30.1653094041580; Fri, 20 May 2022 17:47:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653094041; cv=none; d=google.com; s=arc-20160816; b=C5HaUIP1j4PMyT/lF74o6t709ozQGilwFfQu9EeRssfngdz4gCTGS39bcXl1q6Ann2 zy6DKun5pmbuSCk4H3BvB3tDHRdAbLe6vzUlWL/ckf0RTS1nA7rU3Z/xhtsQ3geK1mUK Buy+kulFsvyCbFcIKq3Vmo29HSbEfIClaLC0dJQpYCXRNDE4XRLPBGnrFZrd2tixsf96 mVjtufPeE8jKJRl1cIrOIsFPTm7OF5fchKkkzxo2K9twzFOsRZaZFpf/SnRc/19ugpfq /RObI6ZkT/i03o12yjLvcaYlD6T5K+weyzmCZfP8cTBU5w1N/JKc7h0Xrn6xGfm2nN9/ D6wg== 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:cc:to :from:dkim-signature; bh=Am6ZQ75YNAJ1iQQvd/m4L79xzkPVsPgjLxYKlB9VWSI=; b=TAF9WS7MEQGsaWSVgJ5FN/3Or/aERD4XDOFPdyRqFfn80reSFNPLcx8/JJwYkBG5Zu qazVErvAJB49Vd3xoQh7Hi1Nr/qJccQcUT7xbBybzLeRHuG+OYf9ICeA4LEn6QSXUpij meHrAXoQ94JTDDOJtMrPZwwR/EHmB0FWClaTc/9pfZBLPXLUeelp7WG+pNqB5OghazW/ KxxJ77RVlh1lycaN4/A6jFvzWNkXy52A45ssr/NSk0Zw7Cx1Nv4L522vCw7QGKgb6TPh qYSmx1vLNFpg92vn6KWdQdo2cvyB2Q4fMY0rdOJ39DQJ2CRVHWv63hAjEHq39MmNMU2V 415Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pM0NEPnq; 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 e10-20020ac85dca000000b002f3db6df0dbsi336977qtx.595.2022.05.20.17.47.21 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 20 May 2022 17:47:21 -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=pM0NEPnq; 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]:53358 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nsDH7-00087e-5z for patch@linaro.org; Fri, 20 May 2022 20:47:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59472) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nsCbw-0008Bd-5x for qemu-devel@nongnu.org; Fri, 20 May 2022 20:04:56 -0400 Received: from mail-pf1-x430.google.com ([2607:f8b0:4864:20::430]:35814) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nsCbd-00040g-Mc for qemu-devel@nongnu.org; Fri, 20 May 2022 20:04:43 -0400 Received: by mail-pf1-x430.google.com with SMTP id c14so8985529pfn.2 for ; Fri, 20 May 2022 17:04:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Am6ZQ75YNAJ1iQQvd/m4L79xzkPVsPgjLxYKlB9VWSI=; b=pM0NEPnqVlRIMiHOsUggQ1EB89PmjqoQXvu4WzrCAGC6zcnef/odKzYWkJCjK5AL4W ojr8kXbxsWcAM8NurjLWmDUjW6yGgxsWBY9xySIbc/1lr9HuJOllL5WkI0j/r6vINPoK o1H/DFiAjgfCTByDLUKRVc8VlaVu2vF1QRdMqj07tZBMDJEhxBLBygtniT4vVCZ4vQ1j NpPjWkiMUbo4n7KzTkUCiRpjBmBhlFAImPj/qh0QslTfrCQgyilcbdxdVj3keUHC6gsJ CnNcCs/rpir83PNOuUpIke9L+OcJumi9tKptQxr5YCl82bRGiI3utTzn01caihcKjiBt 1v7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Am6ZQ75YNAJ1iQQvd/m4L79xzkPVsPgjLxYKlB9VWSI=; b=00TR/ysyfHFV80M9CcD8nfvyo728UN47dQt3kskRKbVQB0cSFCEss20HNo5SluE8A0 ncxoms5KT9blaDQJQYYHztk8HdYK/yDOLmhEXtR4MN2qetK/WNI2O5VUXF/9EVR6EAyp 0QX/F+hJLRsuun1IZCJLtoYKtXEPg3l9u+HHBVmCqGQyISPgVGIQn208nz9yaERi4mMy utGq9RKUjgWXEN7yf1VLYEkdMN0xB2eW5HTSTb334/oeEgb+JgI/4KZvL4Xq2tjL+W8L QD2z85QjN7xpG9WxBYh1xqV9yPI7nMq5UgSsI7CAdTP/eFu0XHwH2EenZuGU20e+HUFE gBvA== X-Gm-Message-State: AOAM532jXmgZMv1EeaTj8jdX6CReeBsA0zx/wXTBtKaQegyc11cuUHiL 4xCvXNjHdOsPebM2KVdRkUHCTJ8acniUeg== X-Received: by 2002:a05:6a00:1501:b0:510:7ab8:71c8 with SMTP id q1-20020a056a00150100b005107ab871c8mr12381316pfu.63.1653091467792; Fri, 20 May 2022 17:04:27 -0700 (PDT) Received: from stoup.. ([71.212.142.129]) by smtp.gmail.com with ESMTPSA id h8-20020a654808000000b003f9d1c020cbsm306369pgs.51.2022.05.20.17.04.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 May 2022 17:04:27 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, alex.bennee@linaro.org Subject: [PATCH v3 22/49] semihosting: Move GET_ARG/SET_ARG earlier in the file Date: Fri, 20 May 2022 17:03:33 -0700 Message-Id: <20220521000400.454525-23-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220521000400.454525-1-richard.henderson@linaro.org> References: <20220521000400.454525-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::430; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x430.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" Moving this to be useful for another function besides do_common_semihosting. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- semihosting/arm-compat-semi.c | 48 +++++++++++++++++------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/semihosting/arm-compat-semi.c b/semihosting/arm-compat-semi.c index 9c6fe7ffd7..7a7468799f 100644 --- a/semihosting/arm-compat-semi.c +++ b/semihosting/arm-compat-semi.c @@ -181,6 +181,30 @@ static LayoutInfo common_semi_find_bases(CPUState *cs) #include "common-semi-target.h" +/* + * Read the input value from the argument block; fail the semihosting + * call if the memory read fails. Eventually we could use a generic + * CPUState helper function here. + */ + +#define GET_ARG(n) do { \ + if (is_64bit_semihosting(env)) { \ + if (get_user_u64(arg ## n, args + (n) * 8)) { \ + goto do_fault; \ + } \ + } else { \ + if (get_user_u32(arg ## n, args + (n) * 4)) { \ + goto do_fault; \ + } \ + } \ +} while (0) + +#define SET_ARG(n, val) \ + (is_64bit_semihosting(env) ? \ + put_user_u64(val, args + (n) * 8) : \ + put_user_u32(val, args + (n) * 4)) + + /* * The semihosting API has no concept of its errno being thread-safe, * as the API design predates SMP CPUs and was intended as a simple @@ -507,30 +531,6 @@ static const GuestFDFunctions guestfd_fns[] = { }, }; -/* - * Read the input value from the argument block; fail the semihosting - * call if the memory read fails. Eventually we could use a generic - * CPUState helper function here. - */ - -#define GET_ARG(n) do { \ - if (is_64bit_semihosting(env)) { \ - if (get_user_u64(arg ## n, args + (n) * 8)) { \ - goto do_fault; \ - } \ - } else { \ - if (get_user_u32(arg ## n, args + (n) * 4)) { \ - goto do_fault; \ - } \ - } \ -} while (0) - -#define SET_ARG(n, val) \ - (is_64bit_semihosting(env) ? \ - put_user_u64(val, args + (n) * 8) : \ - put_user_u32(val, args + (n) * 4)) - - /* * Do a semihosting call. *