From patchwork Mon Oct 14 16:03:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 176293 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4739498ill; Mon, 14 Oct 2019 09:35:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqwNGbqioOYpjDSKdiiTpHECyJ3uHfYjRGQCf3B5MVBDUFIBupbXm7K4pZooDRUMO+pCW/yk X-Received: by 2002:a37:6156:: with SMTP id v83mr28260232qkb.99.1571070945307; Mon, 14 Oct 2019 09:35:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571070945; cv=none; d=google.com; s=arc-20160816; b=NY3tM3sOQhiPyzVoXNjcNbezHzIoJQPcbJ0NqdUuMYS7fQU6Rh/8mZsorc/TsDuUOl 4Rjaw+QMj6PPIudsqJWjsoyN/G13Oyt5bX5nSmN0+1yiXtA5DJnxzSEawSjOBsvi2fVd C0YWqsgiJoPoMYwY2fzv8LYgUjnnyXRokhduuvUciSCWj4hbS8PS0JLHiRucjmAcvAWD VWVh4AmvMCFfL+/9vT8pHN1uwfu3TnkJuGYdLpovAC82zgGsYd2oolSZ/QHrpg1QxoVh CTmk+eXJ2IMYO6tOWAiKy6aztmUSpxctA3F+BHnbAhxrW6ZLC/FmucUFWs53iY0/O3w4 glZA== 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=Y5VQqjurmSOPO5D0mi4+9crSz45jTLCKyLfSh1xje4c=; b=HBmRY3iSbVA/qYokJkjF2VUS/UXbrpuZaX9tyPZDkS8X0UTAH16hjWnXDs/qoLm7rq HsLpFs0EsUXHRQJ8kBozh4fZ3EjYnTVg4WXjtRXIx+NCabiMNF6+xI9cqkHOXxAOCecN B+vIvjjhd5K3+LsALeVlEkjvya1GINCaLoc1lr4ZsVze2sk4EUeS4JjBDDXvylBgm5TU IzwVmmSxPm7SaSha8O2M8oPt/iExOsq416nI6Hqn1xkDTtA8/GIT2GC6h0w6v2fdgKJQ Ayrge+EMP+rfRQUCxfCb82VQ7xc80WSECTT5Z/5tCRK8lZm1FgAbbmIArEhqXWNECHzV 9ZjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GRktgzp3; 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 t65si17708591qkf.19.2019.10.14.09.35.45 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Oct 2019 09:35:45 -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=GRktgzp3; 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]:53391 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iK3Jw-0007n5-8i for patch@linaro.org; Mon, 14 Oct 2019 12:35:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37154) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iK2qL-0004XV-1D for qemu-devel@nongnu.org; Mon, 14 Oct 2019 12:05:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iK2qJ-0007j2-S3 for qemu-devel@nongnu.org; Mon, 14 Oct 2019 12:05:08 -0400 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:45257) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iK2qJ-0007i2-Lm for qemu-devel@nongnu.org; Mon, 14 Oct 2019 12:05:07 -0400 Received: by mail-wr1-x444.google.com with SMTP id r5so20332055wrm.12 for ; Mon, 14 Oct 2019 09:05:07 -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=Y5VQqjurmSOPO5D0mi4+9crSz45jTLCKyLfSh1xje4c=; b=GRktgzp3izxBf3fPcIzVVB9HTrZftHVXMc9R2ISWAAu1CmDhl8aM6f/SSHEo/ywAAx T/NVUFbhpCNJ3N8BxWmIebmY/9xO4KKblb6QgeccWVjNkelkfbKjwdHRbLe1E9v8rsKH 3/E9t78baapQUDRH21lGLMYNmQYbolm2sBIDHybgM9locm8L2Zs02QQGFzBW6qFdJ5DQ XeeiyKdGugtQcGRYqiz86j9GBhQ5Ts2mTV4zDWGvxo1yBUeG6e3UESI1UCJ7LRiOIQap Ec+WG9wIsfNLt2pLqZWSeF0GFn47frrswBNYvOuJjcL+VxIgMpznmfDZ9Y0hcjsTDpri zByA== 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=Y5VQqjurmSOPO5D0mi4+9crSz45jTLCKyLfSh1xje4c=; b=CRUZut7pyeRLJijyIJwEup9+KQpDLO6oHNfrv2LKguSsHlKDgest6EE0es65GttBjn NTME9sjRa022sE8PUmps2SLvtSlLIBEhVPbUHObMBzDBqxprTKVAwTSpJda9UhuLenn4 p0taXlurSHx1Nd/p/e1JIZNiY4iCS0JaZkKqrK3xnJma3MBbpOpRsBsYJ0vbBJd3SztW RRAX6zSE/lCYbU3sZyc3TGKonHlnZcpsBkYtKcTaspTpb4BriE3mQx0KzY6wbzRMmvV+ SKAw/Juiaw5AyRWaLC9D34Dqfx+g7b2X4iFcAzuWQdnr5GLOeT0o2FWxv6kWh/JSevWj 1cZQ== X-Gm-Message-State: APjAAAUehtSmx1ElQqAezfJwtIXfKE+bnq5shM7ArNr6dLWMItoEvmBy LXRw5u6XQAXIWCWnQgw8kHo+kwwPDHT8QQ== X-Received: by 2002:adf:e688:: with SMTP id r8mr28620319wrm.342.1571069106020; Mon, 14 Oct 2019 09:05:06 -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.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2019 09:05:05 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 34/68] target/arm/arm-semi: Factor out implementation of SYS_ISTTY Date: Mon, 14 Oct 2019 17:03:30 +0100 Message-Id: <20191014160404.19553-35-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::444 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_ISTTY via the new function tables. Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé Message-id: 20190916141544.17540-11-peter.maydell@linaro.org --- target/arm/arm-semi.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) -- 2.20.1 diff --git a/target/arm/arm-semi.c b/target/arm/arm-semi.c index 958083a105c..ecd51338fd3 100644 --- a/target/arm/arm-semi.c +++ b/target/arm/arm-semi.c @@ -388,6 +388,7 @@ typedef uint32_t sys_writefn(ARMCPU *cpu, GuestFD *gf, target_ulong buf, uint32_t len); typedef uint32_t sys_readfn(ARMCPU *cpu, GuestFD *gf, target_ulong buf, uint32_t len); +typedef uint32_t sys_isattyfn(ARMCPU *cpu, GuestFD *gf); static uint32_t host_closefn(ARMCPU *cpu, GuestFD *gf) { @@ -436,6 +437,11 @@ static uint32_t host_readfn(ARMCPU *cpu, GuestFD *gf, return len - ret; } +static uint32_t host_isattyfn(ARMCPU *cpu, GuestFD *gf) +{ + return isatty(gf->hostfd); +} + static uint32_t gdb_closefn(ARMCPU *cpu, GuestFD *gf) { return arm_gdb_syscall(cpu, arm_semi_cb, "close,%x", gf->hostfd); @@ -457,10 +463,16 @@ static uint32_t gdb_readfn(ARMCPU *cpu, GuestFD *gf, gf->hostfd, buf, len); } +static uint32_t gdb_isattyfn(ARMCPU *cpu, GuestFD *gf) +{ + return arm_gdb_syscall(cpu, arm_semi_cb, "isatty,%x", gf->hostfd); +} + typedef struct GuestFDFunctions { sys_closefn *closefn; sys_writefn *writefn; sys_readfn *readfn; + sys_isattyfn *isattyfn; } GuestFDFunctions; static const GuestFDFunctions guestfd_fns[] = { @@ -468,11 +480,13 @@ static const GuestFDFunctions guestfd_fns[] = { .closefn = host_closefn, .writefn = host_writefn, .readfn = host_readfn, + .isattyfn = host_isattyfn, }, [GuestFDGDB] = { .closefn = gdb_closefn, .writefn = gdb_writefn, .readfn = gdb_readfn, + .isattyfn = gdb_isattyfn, }, }; @@ -631,11 +645,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_cb, "isatty,%x", gf->hostfd); - } else { - return isatty(gf->hostfd); - } + return guestfd_fns[gf->type].isattyfn(cpu, gf); case TARGET_SYS_SEEK: GET_ARG(0); GET_ARG(1);