From patchwork Thu Jul 20 08:09:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Schmoll X-Patchwork-Id: 9854107 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 01FE8602BA for ; Thu, 20 Jul 2017 08:12:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E6C1222638 for ; Thu, 20 Jul 2017 08:12:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DB3DD2877A; Thu, 20 Jul 2017 08:12:22 +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 6198722638 for ; Thu, 20 Jul 2017 08:12:21 +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 1dY6Wv-0000VF-6s; Thu, 20 Jul 2017 08:09:53 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dY6Wu-0000V9-B5 for xen-devel@lists.xenproject.org; Thu, 20 Jul 2017 08:09:52 +0000 Received: from [85.158.143.35] by server-3.bemta-6.messagelabs.com id 91/CA-03044-F4560795; Thu, 20 Jul 2017 08:09:51 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFuphkeJIrShJLcpLzFFi42Lxqg1y0vVPLYg 0eGNk8X3LZCYHRo/DH66wBDBGsWbmJeVXJLBmrO5dx1qwlq/i7sGlTA2Mz7m7GLk4hASmMUr0 N69kAXFYBC6xSOz+38sG4kgIvGOR+Pf4FXsXIyeQkybx9vMFFgi7UqL9yxpmEFtIQFPiS3cXI 4S9gEli41IpEJtNwEBi9sqLYDUiAkoS91ZNZgKxmQUSJO51vGMFsYUF9CReLGgGquEA2qwq8W B+FkiYV8BOYu/xc8wQq+QldrVdZJ3AyLeAkWEVo0ZxalFZapGukbFeUlFmekZJbmJmjq6hgZl ebmpxcWJ6ak5iUrFecn7uJkZgmDAAwQ7GP/MDDzFKcjApifKyBBZECvEl5adUZiQWZ8QXleak Fh9ilOHgUJLgPZkMlBMsSk1PrUjLzAEGLExagoNHSYRXPwUozVtckJhbnJkOkTrFaMwx6cD2L 0wcryb8/8YkxJKXn5cqJc67G2SSAEhpRmke3CBYJF1ilJUS5mUEOk2IpyC1KDezBFX+FaM4B6 OSMO9hkCk8mXklcPteAZ3CBHTKIzewU0oSEVJSDYxMNSwNS7c9XDxl2tG9VTmyFR0/Vt7P2aU 3y8PxwIqpzsc0V+8WmXFl+42T8/nuHBbSP2RgVbBJZHuRwJWJ0wJePb+rue/7iehHM/tbU0zP O7je+9n9wlnwIfOzg2fOx2vktV6XLLh4WfxZ7uaCq+cf5K3Zm7Um+c16T157A3k3Q/kFK9gjs wT2KbEUZyQaajEXFScCAKQnAVKfAgAA X-Env-Sender: eggi.innovations@gmail.com X-Msg-Ref: server-11.tower-21.messagelabs.com!1500538190!70995551!1 X-Originating-IP: [74.125.82.66] 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 56722 invoked from network); 20 Jul 2017 08:09:50 -0000 Received: from mail-wm0-f66.google.com (HELO mail-wm0-f66.google.com) (74.125.82.66) by server-11.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 20 Jul 2017 08:09:50 -0000 Received: by mail-wm0-f66.google.com with SMTP id m4so2596658wmi.4 for ; Thu, 20 Jul 2017 01:09:50 -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=0hDCx+F849usX/q6BivH7saFiWNO90GCrocaYk+sDKA=; b=E/TW9JrWoeRYEWH5nE+GWKSp0NsapugwtmYpi7GT8+PAnFp5UE8pgiVvGcmQZaxexq 3OqgOklYLRkozwoQsQK44A6C4gw1LOmyzUwERwYxGczyudtYZIu9dwyZPWDvk23dRC5H 3iwiDoNn8h3tcVETawWYJkVwXdWdp5vZMP7bg6zoREr+Q8a5YRhKcKO2v5SuIsqKVgrx JrdOM/S/oxwyKVhkH8VyX3I+UzcPLByA8ztz6Y06JmPQFqTEi1fO6Hz6Tym28wI1wDtW 6Ezh5AhtIp7/LFes2hOQfZG0c7fazcSEDeLzSBtVFuKOH63BM/cim3V1Qh9zXzn8Sd0d 2rcQ== 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=0hDCx+F849usX/q6BivH7saFiWNO90GCrocaYk+sDKA=; b=uUPUF7NJoBzOAD3z0ZqXpclcReYtXk3kCi96Uf3m4EQEJnHLDg5g2iDt3nUgVVXvGq bTur13agMCzNrK/l86vxsIOF4fpui3BKRI8snTka5aHxi+ILbzy+TpAo0unYs7vqjCZx B5OFxV7ou0h1NCbC1cL00v0KAV+MnMyVxeKZzMrPbrDAtGq7bAnURH8d6F6agJ7RleoC 2bjrNsQEfCNDePPablPTnhDwzPcrClptsdXG9PoFct+0lCyAmZWkV4htBrOua9Cy7uJD ZKHFmaSGM5VAh9pb7TdALc64obWJY15+W3XEo2gDqFmtf9p5k7KWEHAH1JmK+YZLAkEK NPWg== X-Gm-Message-State: AIVw112fOMZcvtrFhsBXjR6kndvekok9GP51eXs4NY4V93Z5f/Cre5DW VBWv+e0vt0EGup3Fubvt+Q== X-Received: by 10.28.99.215 with SMTP id x206mr1638626wmb.21.1500538190311; Thu, 20 Jul 2017 01:09:50 -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 r128sm1513548wmb.27.2017.07.20.01.09.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Jul 2017 01:09:49 -0700 (PDT) From: Felix Schmoll To: xen-devel@lists.xenproject.org Date: Thu, 20 Jul 2017 10:09:42 +0200 Message-Id: <20170720080942.4137-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 v3] Implement pv_read_some 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 --- Changed since v2: * Change function name from pv_read to pv_read_some * Add comment to function name * Remove unnecessary code --- common/console.c | 24 ++++++++++++++++++++++++ include/xtf/console.h | 2 ++ 2 files changed, 26 insertions(+) diff --git a/common/console.c b/common/console.c index 7cb2361..1b79652 100644 --- a/common/console.c +++ b/common/console.c @@ -46,6 +46,30 @@ static size_t pv_console_write_some(const char *buf, size_t len) } /* + * Read out data from the pv ring, either until buffer is filled or no + * more data are available. Might result in partial strings, depending + * on how xenconsoled passes in data. + */ +size_t pv_console_read_some(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..caec790 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_some(char *buf, size_t len); + #endif /* XTF_CONSOLE_H */ /*