From patchwork Mon Oct 14 16:03:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 176322 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4764600ill; Mon, 14 Oct 2019 09:59:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqx6f7q+0iVw/1EgwF8Hj6Tn3Q1Pet+YRwjwERp9i8Liw+A0ziG0aw5A3B3uNHdaBh7pB3ED X-Received: by 2002:a37:9d85:: with SMTP id g127mr29720007qke.158.1571072392068; Mon, 14 Oct 2019 09:59:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571072392; cv=none; d=google.com; s=arc-20160816; b=ZV44Qo1S13ZNr/YlI7mAFENxZJI6Drx6rlcauLzt39CVhfQs17cYe1mIjQKwBWZcDw NsJoxNp4ZRdPvwAHPa5fVYVa6SRVxAe0ppT0t5eXMojWOACawYmgWRqZoNP5QLkHgbbh vLiNyZ5A18tfXik+f8eysXeqg6+wor1cjiLE+loBKo6P1cxeFqXeOeZV3p8L6cJhq0Cb kxJIUiAInJas8bbg0JfA+8CRw66xZebPDw1P3iTWOYb5RhJq4TuXsGen+gvb51XTMaWv cHx6PctVPowdjDWRWN81vDyBsBota9+QdtyMvPvE0ancYFRwE+axjyb2ygB8q6PdILFJ I1Eg== 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=8G3roByUGItcwQtca2zwULbmKM2iR6HUV7McNJf7Obk=; b=Kg1vnSpS8M7OaLe2DgBC9mvYLCdn6Y386EDCqJ3TB4kbft6ZzOjPq3lmw7TmAI7iv5 GwFN1O/mvvPgWtlmssiPCmJgTiv5dvJgvwti6zMQ/z5VwRfVOFQNvt+uXcbmJeEC4u5y O61FwGTuktDE+Qr5q9k7up0f+gGiENjqw1f7rGcneI8rjRSsN3YsaXSvVj0o6SGq/wu0 33qNY3xtqyvA7zs2B0qJghP6jNAOkrU7cTAYnjLrGWYoYU6j9Srmpu7XYxTp84ijbv7C JBojcuQFAeLdA5OnYEx1pdTbBf0/BS1n26VBxKWJQzye0CTJPfzYoQVOlwvaD+LIQUYl ZEeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OT1zxDqD; 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 k8si16107760qtq.21.2019.10.14.09.59.51 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Oct 2019 09:59:52 -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=OT1zxDqD; 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]:53906 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iK3hH-0007wA-F1 for patch@linaro.org; Mon, 14 Oct 2019 12:59:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37176) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iK2qN-0004a1-KD for qemu-devel@nongnu.org; Mon, 14 Oct 2019 12:05:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iK2qM-0007oS-Dl for qemu-devel@nongnu.org; Mon, 14 Oct 2019 12:05:11 -0400 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:35144) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iK2qM-0007my-71 for qemu-devel@nongnu.org; Mon, 14 Oct 2019 12:05:10 -0400 Received: by mail-wr1-x442.google.com with SMTP id v8so20392627wrt.2 for ; Mon, 14 Oct 2019 09:05:10 -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=8G3roByUGItcwQtca2zwULbmKM2iR6HUV7McNJf7Obk=; b=OT1zxDqDPBU3AN+lfEC4VQEcIGPKj/tQ1YKOHwRRb/L4Cp4OVWhGsNSgBzRKx+84ak pJaDWBGcu0O0ZQAWOM2ETAM666TRmU728lsb9a5kI6BDltZ1uiKQ6/5UFxVu/oLZi6Lx duVv56bB3ixEK1J01zH8lCA5u3eoamPUmv+cht3AQIwuYNwEVJwq8kGP2YkEHUfIPIM0 LVxRT43nLn8Y2t4E4Jj9a/eDuq/b5ugZQDcIQ24WWCzx0/yuSm4zcEIt093QeyIh++8/ lTf3jCiFeV+tV47DeHtyTY2HPe9c5Mzm1JkJ4gt4x11syMszZmswb+JaNFlemeFmEdGO qXJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=8G3roByUGItcwQtca2zwULbmKM2iR6HUV7McNJf7Obk=; b=KbncdyGIVaGfTlctKh92EKVM1qjwjt2/y8v7USrEGYjZ1N79WC+Y7eYGgD6uKyivmB 2VkUrhCX4kJYy6tlrVFFDdEqn+mpoj4lwEakp80wxciQicc9yP78US60AgOD3jqhxCZt iw5L4HoHCa1bvl9Dd21lqf7RvPnm6OaKCqsEK0x5uip7Z1h5LbyoMdgDkZALFibVhUjB 3f5R6nWDEoorMgTqXtOxoDmUPUTmqRuNHQNiI8+hXc9V1uoJ9UO0rgr5ZsP7JEOyiRYA MPhmVXBcmEIfAjRvj38wX4O9VKYtcTFdc8ZAElDx3Iz+chdoHRuC3j5f62V4LM7HcoI3 zVXw== X-Gm-Message-State: APjAAAV4fjdoDY8HWhiax/ry6SDwHA1F4aqqHBSIRSDKt7qV3nuVWMse QIKRVW9oel4mXK2ZTK+1YRnplWlCrl9vpw== X-Received: by 2002:adf:de85:: with SMTP id w5mr25896216wrl.278.1571069108940; Mon, 14 Oct 2019 09:05:08 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id 5sm18029779wrk.86.2019.10.14.09.05.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2019 09:05:07 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 36/68] target/arm/arm-semi: Factor out implementation of SYS_FLEN Date: Mon, 14 Oct 2019 17:03:32 +0100 Message-Id: <20191014160404.19553-37-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191014160404.19553-1-peter.maydell@linaro.org> References: <20191014160404.19553-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::442 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Factor out the implementation of SYS_FLEN via the new function tables. Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé Message-id: 20190916141544.17540-13-peter.maydell@linaro.org --- target/arm/arm-semi.c | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) -- 2.20.1 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); 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; } +static uint32_t host_flenfn(ARMCPU *cpu, GuestFD *gf) +{ + CPUARMState *env = &cpu->env; + struct stat buf; + uint32_t ret = set_swi_errno(env, fstat(gf->hostfd, &buf)); + if (ret == (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); } +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; static const GuestFDFunctions guestfd_fns[] = { @@ -501,6 +520,7 @@ static const GuestFDFunctions guestfd_fns[] = { .readfn = host_readfn, .isattyfn = host_isattyfn, .seekfn = host_seekfn, + .flenfn = host_flenfn, }, [GuestFDGDB] = { .closefn = gdb_closefn, @@ -508,6 +528,7 @@ static const GuestFDFunctions guestfd_fns[] = { .readfn = gdb_readfn, .isattyfn = gdb_isattyfn, .seekfn = gdb_seekfn, + .flenfn = gdb_flenfn, }, }; @@ -687,16 +708,7 @@ target_ulong do_arm_semihosting(CPUARMState *env) return set_swi_errno(env, -1); } - 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 = set_swi_errno(env, fstat(gf->hostfd, &buf)); - if (ret == (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;