From nobody Tue Feb 10 01:35:36 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1568644671; cv=none; d=zoho.com; s=zohoarc; b=lqnflXHU1x64F3m4Q3CVqzQJM1DzZG/iGyd0Kqqy8oAbvQheeOgNmH2Tiuu8fEOMmNBUdO2rZ6WRLkvJkj1n4onRkV6UYqjKQy7fVutKR49AuJOZkal8sPWAM+aYzPkQxA7UGqtuGoNO9kcTkEG38jm87YHDCoTSSF7eBB6TAv0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568644671; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=PhdxBnvi4pU80xrRijWpk4YE0MSvzzAfF5L37d1esIU=; b=ToQ/+QEqaJecxPaS2zLBL587VfEdJyNxsnYweDFdYf0giXg4U14487uGHkqOg5ZTLwhBsU5+Alm7xdBIXrl73aT4DkMKOvXFubwAi10te6x+5Q/K0A1Q/Ija6eME4Tj8h3XwXFBZJTET3nrZnzHwIjG5QxgJE4TxGhSkzEsAIW0= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 156864467137652.02997140371758; Mon, 16 Sep 2019 07:37:51 -0700 (PDT) Received: from localhost ([::1]:35236 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i9s8T-0008Qr-Tk for importer@patchew.org; Mon, 16 Sep 2019 10:37:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49834) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i9rnR-0004ZX-6O for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:16:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i9rnP-0006zT-DJ for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:16:05 -0400 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:37257) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i9rnO-0006yR-Pj for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:16:03 -0400 Received: by mail-wr1-x441.google.com with SMTP id i1so38500257wro.4 for ; Mon, 16 Sep 2019 07:16:02 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id s9sm15185884wme.36.2019.09.16.07.16.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Sep 2019 07:16:01 -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=PhdxBnvi4pU80xrRijWpk4YE0MSvzzAfF5L37d1esIU=; b=ZYBVWT0oCbR554Mraq3xgsjVLom0X451QtcoUP0V55L8vYofSszxGYuG4cN6IjvMyY vjaXDVWCNcNOPwtvDFkRikje0q4JzvmbTlgbB7+XDo1XT6ZfzvMWnmJ0BJ5wGMMR9OsV gfvf6Ver1OKOTntV186Mo8XeRm1eGP4VTjcKXxywbAiETEXS5RsE0pN4lz72yfNgij3/ jrE2GKbZuUPujd6CIxyuQduog1ABVhMOop8n2kyAMx2ylQW73fmzMod25q60wGi97PtI iFz4abOaTUr4+WbtJYyF+0v6G8ggwSEPC+2Wg5a4btvSTjXUWmcKl40lHRL3pJqeEeKz GD7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PhdxBnvi4pU80xrRijWpk4YE0MSvzzAfF5L37d1esIU=; b=al9Z34HNMtaIRhQUEuBGbAVPl7O3qWwAk/s5aLKsNv+jrjTW0Eah7z8CBlWvrB0pxg pnRg/3XCa9IGjx5ow96TIMNltUmvrVNysw9eO2IdnVRpqrq6o1lMrmxl+en5g/5WdfR1 Mhs6w3ROxwXfijFjKNkmzKhg6gLS+G5SNFYrI0olcbNBnAxz97y7vh3bwyyrAyWBWSlx B7UKDfM8VG2mcn+/faGRW8SvPDI14fjWR+WO9cRLRYK6u9sr0WYmILEn9xhXKXT2UpTd noD5KC84/jWMYt/AyLcnhDU1qRW5aQjHaVv64w3Pg9U5aJQvHWoli2mihnNs2M8mCvPi 2Ntg== X-Gm-Message-State: APjAAAU60GR50bMDalVz7U/6J9kDrrRT5/G2HAzy0J+yVqZsEiLlJ+JG SCEh4mWNkDZLlnbSiORyjzLK9g== X-Google-Smtp-Source: APXvYqxfpfRFab2EHZqCExuA9zAr3DA1LIcKc07IjxrItyWn7ekDJEY4dFVB/YCycqtFLUgcJjbzAQ== X-Received: by 2002:adf:ed88:: with SMTP id c8mr7303871wro.329.1568643361657; Mon, 16 Sep 2019 07:16:01 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Date: Mon, 16 Sep 2019 15:15:41 +0100 Message-Id: <20190916141544.17540-13-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190916141544.17540-1-peter.maydell@linaro.org> References: <20190916141544.17540-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::441 Subject: [Qemu-devel] [PATCH v2 12/15] target/arm/arm-semi: Factor out implementation of SYS_FLEN 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: =?UTF-8?q?Alex=20Benn=C3=A9e?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Factor out the implementation of SYS_FLEN via the new function tables. Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/arm/arm-semi.c | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/target/arm/arm-semi.c b/target/arm/arm-semi.c index b5e1d73eb80..87c911f0187 100644 --- a/target/arm/arm-semi.c +++ b/target/arm/arm-semi.c @@ -391,6 +391,7 @@ typedef uint32_t sys_readfn(ARMCPU *cpu, GuestFD *gf, typedef uint32_t sys_isattyfn(ARMCPU *cpu, GuestFD *gf); typedef uint32_t sys_seekfn(ARMCPU *cpu, GuestFD *gf, target_ulong offset); +typedef uint32_t sys_flenfn(ARMCPU *cpu, GuestFD *gf); =20 static uint32_t host_closefn(ARMCPU *cpu, GuestFD *gf) { @@ -454,6 +455,17 @@ static uint32_t host_seekfn(ARMCPU *cpu, GuestFD *gf, = target_ulong offset) return 0; } =20 +static uint32_t host_flenfn(ARMCPU *cpu, GuestFD *gf) +{ + CPUARMState *env =3D &cpu->env; + struct stat buf; + uint32_t ret =3D set_swi_errno(env, fstat(gf->hostfd, &buf)); + if (ret =3D=3D (uint32_t)-1) { + return -1; + } + return buf.st_size; +} + static uint32_t gdb_closefn(ARMCPU *cpu, GuestFD *gf) { return arm_gdb_syscall(cpu, arm_semi_cb, "close,%x", gf->hostfd); @@ -486,12 +498,19 @@ static uint32_t gdb_seekfn(ARMCPU *cpu, GuestFD *gf, = target_ulong offset) gf->hostfd, offset); } =20 +static uint32_t gdb_flenfn(ARMCPU *cpu, GuestFD *gf) +{ + return arm_gdb_syscall(cpu, arm_semi_flen_cb, "fstat,%x,%x", + gf->hostfd, arm_flen_buf(cpu)); +} + typedef struct GuestFDFunctions { sys_closefn *closefn; sys_writefn *writefn; sys_readfn *readfn; sys_isattyfn *isattyfn; sys_seekfn *seekfn; + sys_flenfn *flenfn; } GuestFDFunctions; =20 static const GuestFDFunctions guestfd_fns[] =3D { @@ -501,6 +520,7 @@ static const GuestFDFunctions guestfd_fns[] =3D { .readfn =3D host_readfn, .isattyfn =3D host_isattyfn, .seekfn =3D host_seekfn, + .flenfn =3D host_flenfn, }, [GuestFDGDB] =3D { .closefn =3D gdb_closefn, @@ -508,6 +528,7 @@ static const GuestFDFunctions guestfd_fns[] =3D { .readfn =3D gdb_readfn, .isattyfn =3D gdb_isattyfn, .seekfn =3D gdb_seekfn, + .flenfn =3D gdb_flenfn, }, }; =20 @@ -687,16 +708,7 @@ target_ulong do_arm_semihosting(CPUARMState *env) return set_swi_errno(env, -1); } =20 - if (use_gdb_syscalls()) { - return arm_gdb_syscall(cpu, arm_semi_flen_cb, "fstat,%x,%x", - gf->hostfd, arm_flen_buf(cpu)); - } else { - struct stat buf; - ret =3D set_swi_errno(env, fstat(gf->hostfd, &buf)); - if (ret =3D=3D (uint32_t)-1) - return -1; - return buf.st_size; - } + return guestfd_fns[gf->type].flenfn(cpu, gf); case TARGET_SYS_TMPNAM: qemu_log_mask(LOG_UNIMP, "%s: SYS_TMPNAM not implemented", __func_= _); return -1; --=20 2.20.1