From patchwork Tue Jul 18 14:53:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Schmoll X-Patchwork-Id: 9848675 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3CEEB600CC for ; Tue, 18 Jul 2017 14:56:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1DE1426E40 for ; Tue, 18 Jul 2017 14:56:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 12A1F2852B; Tue, 18 Jul 2017 14:56:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.6 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8D2CF26E40 for ; Tue, 18 Jul 2017 14:56:02 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dXTsb-0006TT-J2; Tue, 18 Jul 2017 14:53:41 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dXTsZ-0006TN-HT for xen-devel@lists.xenproject.org; Tue, 18 Jul 2017 14:53:39 +0000 Received: from [85.158.143.35] by server-5.bemta-6.messagelabs.com id 2A/AB-03368-2F02E695; Tue, 18 Jul 2017 14:53:38 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprEIsWRWlGSWpSXmKPExsVyMfS6i+4nhbx Ig40XhS2+b5nM5MDocfjDFZYAxijWzLyk/IoE1owfB60L1vJW3Ph6iLGBsYW7i5GLQ0hgOqPE hLXrWUEcFoFLLBLLjj5kBHEkBN6xSDy/8B4owwnkpEnc67zG3MXIAWRXSjTvtAUJCwloSnzp7 mKEmDSfSeLX/wNMIAk2AQOJ2SsvMoPYIgJKEvdWTQaLMwskSNzreMcKMkcYqPn8dCuQMIuAqs TrrmNgq3gF7CWO3/wLtVZeYlfbRdYJjHwLGBlWMWoUpxaVpRbpGproJRVlpmeU5CZm5ugaGpj p5aYWFyemp+YkJhXrJefnbmIEhgkDEOxgvL4x4BCjJAeTkijv6gO5kUJ8SfkplRmJxRnxRaU5 qcWHGGU4OJQkeAXl8yKFBItS01Mr0jJzgAELk5bg4FES4W0GSfMWFyTmFmemQ6ROMVpyXLmy7 gsTx5QD24Hkqwn/vzEJseTl56VKifNOB2kQAGnIKM2DGweLqkuMslLCvIxABwrxFKQW5WaWoM q/YhTnYFQS5j0OMoUnM68EbusroIOYgA4S9s0BOagkESEl1cB4+Pi8d6oXbx5pSr35Kfuu1oq XjxXzr6x+OXHPN7lZ8qGzW+TF2hZXbX7mvmfSnus3ImaKtBbFNfTtnrahoXbLNN9PR/fnz4ja /caY4/eZTSJ9bz8oCX6Z+SJtfq+5fuCPY0p5z0TXr5rJ+vKtOxtH6/LPlfNmL9v1Lf3IZ9bMz VNOrDlzVoWVuVyJpTgj0VCLuag4EQARcMgLpQIAAA== X-Env-Sender: eggi.innovations@gmail.com X-Msg-Ref: server-14.tower-21.messagelabs.com!1500389617!67164972!1 X-Originating-IP: [209.85.215.68] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 38611 invoked from network); 18 Jul 2017 14:53:38 -0000 Received: from mail-lf0-f68.google.com (HELO mail-lf0-f68.google.com) (209.85.215.68) by server-14.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 18 Jul 2017 14:53:38 -0000 Received: by mail-lf0-f68.google.com with SMTP id z78so2096724lff.2 for ; Tue, 18 Jul 2017 07:53:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=tLVKlWMcBq9gSqqnYQBEP8EoWJw17QlIWaw/KL+Caws=; b=UFCszjG8REcv9x+Ovwzwu5MPHOA5Ev2WuxywNIl7CI5YxHuWzAkm4NYw6TanOJD65Z QvtO8JI2H1rEN01yrpTFxfTX2mCFGpv7oS1dPmR9spJinj8TgsLu04TtrahYJFzEWWLr jdcJi3YzmJc86UNfyUEULWgP5P+8WH8XuChjzw9Kpm59oweZplMYBOyK/slFrqx4U72F hbuICCeah10Ytzyp3MtPB8zy7N265U2axqn85Tt2yQ/WBPkItxy0tGGB5JwST1CAcice tHEx/AnUTHK/gsMR/Vw8jtPpr5dZWYAv7e6/m3VYxw3J4aqRgLomCC26X07ICFNxJhsV tLWA== 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; bh=tLVKlWMcBq9gSqqnYQBEP8EoWJw17QlIWaw/KL+Caws=; b=YHvUjrrE7C6GHqeevpn+SxRW4rDKQeg/7vdlKFmNNi3XKJfqxzUUzXIZyEswIrk5Fo ge4iPQiO+NHGZntAT4m9bE3NtRv5YRHApraQTbr1qv98ppcytDXGkkWgYHATiR2BKGw5 bZJctwfEla6Fe3ndYVHbHuJ0Zg4W64RN1X0hizexo6oK4R+RxtPFdhq5bxasrtVfp0Gz I3UA0FhECqg2C5BKoZnsnai9EhR4vSGyklazGtBVj4gjvZrnunCdjdRai5g16OeIhuex r29uOSSWcBOIOuIG+7Eqka68XOKKc93Bi9kGkV5CXThX/9gWNzHGkRiDNLI6jfJyxa4T PsuQ== X-Gm-Message-State: AIVw111qyd5Zz5JwNRBzt/2JdTEtgDcUW8waUMBqUddDdf9a08F5WCH8 VzqcG9qx0KMhP6cnN0RmOg== X-Received: by 10.80.174.233 with SMTP id f38mr1077549edd.77.1500389617190; Tue, 18 Jul 2017 07:53:37 -0700 (PDT) Received: from localhost.localdomain (ip-109-47-2-190.web.vodafone.de. [109.47.2.190]) by smtp.gmail.com with ESMTPSA id h58sm1937688edh.52.2017.07.18.07.53.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 18 Jul 2017 07:53:36 -0700 (PDT) From: Felix Schmoll To: xen-devel@lists.xenproject.org Date: Tue, 18 Jul 2017 16:53:29 +0200 Message-Id: <20170718145329.22717-1-eggi.innovations@gmail.com> X-Mailer: git-send-email 2.11.0 Cc: andrew.cooper3@citrix.com, wei.liu2@citrix.com, Felix Schmoll Subject: [Xen-devel] [PATCH XTF v2] Implement pv_read X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Implement reading from PV console. Making use of polling. Signed-off-by: Felix Schmoll --- common/console.c | 22 ++++++++++++++++++++++ include/xtf/console.h | 2 ++ 2 files changed, 24 insertions(+) diff --git a/common/console.c b/common/console.c index 7cb2361..5895ccc 100644 --- a/common/console.c +++ b/common/console.c @@ -7,6 +7,8 @@ #include #include +#include + /* * Output functions, registered if/when available. * Possibilities: @@ -45,6 +47,26 @@ static size_t pv_console_write_some(const char *buf, size_t len) return s; } +extern shared_info_t shared_info; +size_t pv_console_read(char *buf, size_t len) +{ + size_t s = 0; + uint32_t cons, prod; + + while ( !test_and_clear_bit(pv_evtchn, shared_info.evtchn_pending) || + (pv_ring->in_cons == pv_ring->in_prod) ) + hypercall_poll(pv_evtchn); + + cons = pv_ring->in_cons, prod = LOAD_ACQUIRE(&pv_ring->in_prod); + + while ( (s < len) && (0 < (prod - cons)) ) + buf[s++] = pv_ring->in[cons++ & (sizeof(pv_ring->in) - 1)]; + + STORE_RELEASE(&pv_ring->in_cons, cons); + + return s; +} + /* * Write some data into the pv ring, synchronously waiting for all data to be * consumed. diff --git a/include/xtf/console.h b/include/xtf/console.h index 2a93c06..9b3f85d 100644 --- a/include/xtf/console.h +++ b/include/xtf/console.h @@ -25,6 +25,8 @@ void init_pv_console(xencons_interface_t *ring, void vprintk(const char *fmt, va_list args) __printf(1, 0); void printk(const char *fmt, ...) __printf(1, 2); +size_t pv_console_read(char *buf, size_t len); + #endif /* XTF_CONSOLE_H */ /*