From patchwork Tue May 3 19:47:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 568968 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp9779392map; Tue, 3 May 2022 13:04:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwMLfUBjvbjyTWsN9h5vXX+M00AptOU6wgrFkLtuERqQn34warQ7wXWuAyeC6Ax9sXCTf3g X-Received: by 2002:a05:6214:23c8:b0:450:863a:fa1e with SMTP id hr8-20020a05621423c800b00450863afa1emr14750124qvb.54.1651608296667; Tue, 03 May 2022 13:04:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651608296; cv=none; d=google.com; s=arc-20160816; b=KyMDUwIWccOAK03xSjY4xzQj9xO7Re6PxY59FPqrWI32IWtZ7j2bWaXCOevVCBhtU5 ZJqyVfUi/cbmHhY1LkyYoeNzqRSWypfFhM4k/AFCOMfiMrCrxo5/TaprOZsviJM4m4Sa hZTFcK4XbL4Irkz+ZwC03oaDV+U1tq5OySzPqIZROZ9Q2+v678khCXTC+75Sb7D0ZvE8 1zdCKYKPONRHrvzolfpEOdiT8WFblbGtxl0Zg/gkWFVwHQuBDes88Hfl61zIianhiMhg x8hKIMdGEv91U8n9gtJZURRQwFcouRMf2HVx50v3yaXx2E0//n3QPOfU43oQu8nG7297 4Ysw== 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=KTqJr1ojr+Avm6OwJN9PAVJEmcUCfXozWTlyiMGyM9k=; b=kJTVijwoZs9VNSqKrW5So7ZAySGOs9QZ+kWS/5wcyBrB/m49udKwV+kxPKbT9tqqdK cOuWSj+/4I0wjW0SXjk9RrmkV6NGsBi0+ONhAK63EFrXt6HNJVAOCAgCEypI/SN+RcN5 vgnwM1+7sASWBJBbgvpqXCmVCU+EGiMQ/rLwzCp4N1ja97SJpXk6/YyX2sooFDHbOqPd RFDLX41unXJrio3mE1fOGwc0rKsqO7ODj8+wG7yhfLSlzwrK8Reukc52eHpZP/mTTJsv LcMy9J1KcMSNzd0b28G84Ufy/RU6EbUeguvnoqj1YUSA80FpkRYcUXsF90rTRd2W00m+ rauA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=odW9mdNF; 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 gw5-20020a0562140f0500b0044644eb42e0si9180912qvb.314.2022.05.03.13.04.56 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 03 May 2022 13:04:56 -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=odW9mdNF; 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]:47946 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nlylU-0004zX-45 for patch@linaro.org; Tue, 03 May 2022 16:04:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39192) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nlyWC-0001jR-Um for qemu-devel@nongnu.org; Tue, 03 May 2022 15:49:09 -0400 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]:46894) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nlyWB-0003aL-4r for qemu-devel@nongnu.org; Tue, 03 May 2022 15:49:08 -0400 Received: by mail-pl1-x62f.google.com with SMTP id c11so5631053plg.13 for ; Tue, 03 May 2022 12:49:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=KTqJr1ojr+Avm6OwJN9PAVJEmcUCfXozWTlyiMGyM9k=; b=odW9mdNF/Ot9avhe8ntqbHxp+eu0osB+bvU1Co8fY6ibEH5dDUmkmzIXdRqLylxpGG EWSRmZWY3VdsN/CZ39jX66HOlVKzDdHQV9I52BsfjBJ5nnAHEfDtUBiX1aIyx4lfLowz CUMxT3WmF/Qn0LPDc87Q6HMcgekLsnL7eQnI22VnrG5kUBmAd4NNVLvejdH6tyKOJEBV l/FCRU9hr1sqF14k4YG8hV1wRyIcAD6KtYm7RvqkeDR681CwmBpMTqAVJaqAe9nA22u7 BPNSOe/mij4Y6hr7KitrgezFXFJY4cd+eFdGOesJ7/4hXDjG/mylzsy6sdysHcZbHZIG ze5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=KTqJr1ojr+Avm6OwJN9PAVJEmcUCfXozWTlyiMGyM9k=; b=NDUAoF8XlNTq3BGoTIBEuPeXgNe7WUQ3C8wVNvR2U2LomWUIAWov3FlUjsJuVaDVjV VZGHYNFVQgVin8fdjfcz5yTl9g82Hq1Ws/7ny4fb05MjrVpk8IxC8LWpy5o0Yi18MmMF duzUr9ZkrusKAxXudMOYzvlx5uogRZ93av8NGEOb/RH+9cWVJmbGXpqv5pxRIKlilefU 0L4D/S+L8Xm3OQjFvhwywJint2ooUSRLKupc/tta/yFUcsq+9mUe5fuTRce0ySCbiOqT CZpq5FEEZf+QzATBaZ1wNkxPncPGr/q4XuOJI4ZCSSRLmJ7ZD2VYCJKBRS8V2t8kvQX9 DT0Q== X-Gm-Message-State: AOAM5325j9RK6HGrg0g1uU5tITfo273lYZQU+nvuZaFwTMvUNPAYnYJh YxGU0bve2V81tMFRSx70LLcWdK+dIBJ0tQ== X-Received: by 2002:a17:902:8c8f:b0:15e:ab1c:591b with SMTP id t15-20020a1709028c8f00b0015eab1c591bmr9453232plo.171.1651607345699; Tue, 03 May 2022 12:49:05 -0700 (PDT) Received: from stoup.. ([71.212.142.129]) by smtp.gmail.com with ESMTPSA id p11-20020a17090ad30b00b001cd4989fed3sm1712383pju.31.2022.05.03.12.49.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 May 2022 12:49:05 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 20/74] semihosting: Move GET_ARG/SET_ARG earlier in the file Date: Tue, 3 May 2022 12:47:49 -0700 Message-Id: <20220503194843.1379101-21-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220503194843.1379101-1-richard.henderson@linaro.org> References: <20220503194843.1379101-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62f; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62f.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 --- semihosting/arm-compat-semi.c | 52 +++++++++++++++++------------------ 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/semihosting/arm-compat-semi.c b/semihosting/arm-compat-semi.c index 3a740482f9..49f976cbc5 100644 --- a/semihosting/arm-compat-semi.c +++ b/semihosting/arm-compat-semi.c @@ -181,6 +181,32 @@ 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)) { \ + common_semi_cb(cs, -1, EFAULT); \ + return; \ + } \ + } else { \ + if (get_user_u32(arg ## n, args + (n) * 4)) { \ + common_semi_cb(cs, -1, EFAULT); \ + return; \ + } \ + } \ +} 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 @@ -506,32 +532,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)) { \ - common_semi_cb(cs, -1, EFAULT); \ - return; \ - } \ - } else { \ - if (get_user_u32(arg ## n, args + (n) * 4)) { \ - common_semi_cb(cs, -1, EFAULT); \ - return; \ - } \ - } \ -} 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. *