From patchwork Wed Sep 27 06:13:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 114335 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp4665404qgf; Tue, 26 Sep 2017 23:17:02 -0700 (PDT) X-Received: by 10.36.225.202 with SMTP id n193mr935773ith.106.1506493022891; Tue, 26 Sep 2017 23:17:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506493022; cv=none; d=google.com; s=arc-20160816; b=OYXWT76loBQE5gs+oCx8jPhHVfERgVRWSvVOjePROETQ7l7Ri4cKzprPiYpm644x9W Chbk0gL7OzcWA/5hStpITod2XsVhHB11p3kW1bmcJo1goEzjoZuHWaNULU1h5b7qoWtI rpbdhGH0R3XJoL54sXYKp0YeCrYv1cUpcXpjGSbahfcCJp8GiPnCem0I9OEmAvZqWEQy rOJKXKJ7pjB0g+hoDzvVzPNZBOXTxwNKnPlhl/S8O1Ltg/TcjELpOFexpJ7G6PyYXItc exIg7aE7VfIQomnWK2aCOIv/N17xCr3ASytElMfAWNGbambeIjxq6MNdSfW64VPQOUkX 7CTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:dkim-signature:arc-authentication-results; bh=HCv3UlhcoI7MIaid0Q2Iq9o17QQmhXdFQEnxbwICUws=; b=Kw6Dhg8nq7OuNiUvoBWrtqkk2581DBjY8oIPvgAdNfqIMOMEnSvOQh34jCF9fmhjEO bp2oUd5aJGyJPrSMgn4I4DZMOt/MFnlFidFwYzjIfK+eFbyJBSxYhO5my6CaaLNKhJg/ bO0M5SK1iY1vIRqmmu+mL4qr3djG8G+jzcdtqkQ6wnSC2JpGo8BCbkTZ15o7SUU5A1UM lNQWTnY+M3WofbtX692hDZqIbcOw3bqX9h4jGQmRR1P7wI82d3h1M+C6lHIr3WoBC/is Fw0SrirMoDfiq3r0Mg+nkZHQ+5UfoisJcb+0sAjQtV/llFAT0cQ7xGub0odFMidoomBk jVYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=ACgZigtR; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id e190si3470769itb.85.2017.09.26.23.17.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 26 Sep 2017 23:17:02 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=ACgZigtR; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dx5bc-0002fi-08; Wed, 27 Sep 2017 06:14:00 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dx5ba-0002b2-Cv for xen-devel@lists.xenproject.org; Wed, 27 Sep 2017 06:13:58 +0000 Received: from [85.158.143.35] by server-5.bemta-6.messagelabs.com id FA/2A-03454-6A14BC95; Wed, 27 Sep 2017 06:13:58 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrBIsWRWlGSWpSXmKPExsXiVRusr7vY8XS kwebd4hbft0xmcmD0OPzhCksAYxRrZl5SfkUCa0bDng7GghXiFUfPnGBuYNwl3MXIxSEkMJNR onP2YjYQh0VgHrPE/s2TGUEcCYF+Voktk+6zdjFyAjl5Ek1bLjFC2GkSx9cugbLLJa6cOscGY gsJaEkcPTWbFWLsCiaJU6397F2MHBxsAiYSszokQGpEBJQk7q2azARSwywwn1GiaVIvWLOwQK TEgtU7mEBsFgFVib77l8HivAI+EhMbP7FDLJOTuHmukxnE5gSKn+6/DbXYW+LSyn7WCYyCCxg ZVjGqF6cWlaUW6VrqJRVlpmeU5CZm5ugaGpjp5aYWFyemp+YkJhXrJefnbmIEhhwDEOxgvLsp 4BCjJAeTkihvzf9TkUJ8SfkplRmJxRnxRaU5qcWHGGU4OJQkeOc5nI4UEixKTU+tSMvMAQY/T FqCg0dJhPcaSJq3uCAxtzgzHSJ1itGS40vvjT9MHPv23AKSHTfv/mESYsnLz0uVEuetAmkQAG nIKM2DGweL0EuMslLCvIxABwrxFKQW5WaWoMq/YhTnYFQS5l0IMoUnM68EbusroIOYgA7qnXo C5KCSRISUVANjYkrVx6DSeQ5KwodvvfNdbppVw617Zebf7D291lw/G8+7p6pqLgnS+iC96Pzv hkMVHjW+PAxi2YWaxxk5NR2cmLoeHjy/JuLei5sbvKvM+KavfydjWZR1g3PL0QPm1xdlVVx/G CiT3Ta784ixbJ5adpCENmdCh+6uQGHHuKnWn29Y28T8tVRiKc5INNRiLipOBAC2VxI4ywIAAA == X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-8.tower-21.messagelabs.com!1506492834!84672494!1 X-Originating-IP: [74.125.83.47] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 28061 invoked from network); 27 Sep 2017 06:13:55 -0000 Received: from mail-pg0-f47.google.com (HELO mail-pg0-f47.google.com) (74.125.83.47) by server-8.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 27 Sep 2017 06:13:55 -0000 Received: by mail-pg0-f47.google.com with SMTP id c137so7216449pga.11 for ; Tue, 26 Sep 2017 23:13:55 -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; bh=EtvhJzM3HTL/NgQ6915SS3H5bdB2TB/oZeG6xtku1W0=; b=ACgZigtReMLZNLNAD6D7Z9BSSbnYrGDPUa8YkQuvdbz2dd9e86ZlpGAxahGdaa4Flw Z6jm9hoSZmYGJfhvjhRz3V/MavfYamx5gxAeUyFKjVLNdeKKlDZkR6tq6L8wQWXelQu1 FrKyRR9w3Mqthu0k6RZJNjnrihnPsFcsxoM2s= 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; bh=EtvhJzM3HTL/NgQ6915SS3H5bdB2TB/oZeG6xtku1W0=; b=FXoE+Atm/P0IGNVeSOVE7QVPg9eSzY9T64GBA2T4hu2Mvcoc2TuBJysLxtckwuO96y qr7MoSpZJx6aa4HcJtjWsfU0K4jn60pXNo7nNUVMZhibTpvL0Qwc6JQTSCKnTuqzY6Ic zXJ+jlUGXkNLTxHx0eiXYe/zvkiaW1tDws0+/hriJDFIv1pJydrfCK2BeReu6sO+vqcp btWKgcw9l9p3nCMY6pjTCs01iDJ9enCeVHAYBjg7V9Fz/L8DYMeKHyH66Z1SyIZUvBsi lqzFWJVgMyMl6c07G4L9MMFbkEUFljnoqM2RVMswa53z/dn+UTK74Rn2cT4X9HQwJza+ I4vg== X-Gm-Message-State: AHPjjUi6xi4hUTX8kWpK6azJdHnW6GrPQ4gPk1n5IPstDBTlTcfYWSjT WMubisG6rEbSpZIvbCvbQDTXnNEosLo= X-Google-Smtp-Source: AOwi7QC1GF2V1kWRwmEdi5Dr+JvZAjzVDrM9VM+G5CGCsZnvp95w00eOqBenWiFbW7f9DWvBY2351A== X-Received: by 10.159.252.5 with SMTP id n5mr324029pls.360.1506492833344; Tue, 26 Sep 2017 23:13:53 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com (h3.248.139.40.ip.windstream.net. [40.139.248.3]) by smtp.gmail.com with ESMTPSA id s187sm18013485pgb.82.2017.09.26.23.13.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 26 Sep 2017 23:13:52 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Wed, 27 Sep 2017 11:43:20 +0530 Message-Id: <1506492816-25954-12-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1506492816-25954-1-git-send-email-bhupinder.thakur@linaro.org> References: <1506492816-25954-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 11/27 v11] xen/arm: vpl011: Add a new console_init function in xenconsole 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" This patch introduces a new console_init function. This function initializes the console structure. Signed-off-by: Bhupinder Thakur Acked-by: Wei Liu --- CC: Ian Jackson CC: Wei Liu CC: Stefano Stabellini CC: Julien Grall Changes since v5: - Split this change in a separate patch. tools/console/daemon/io.c | 65 ++++++++++++++++++++++++++++------------------- 1 file changed, 39 insertions(+), 26 deletions(-) diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c index a2a3496..1da08d7 100644 --- a/tools/console/daemon/io.c +++ b/tools/console/daemon/io.c @@ -655,20 +655,51 @@ static bool watch_domain(struct domain *dom, bool watch) return success; } - -static struct domain *create_domain(int domid) +static int console_init(struct console *con, struct domain *dom) { - struct domain *dom; char *s; + int err = -1; struct timespec ts; - struct console *con; if (clock_gettime(CLOCK_MONOTONIC, &ts) < 0) { dolog(LOG_ERR, "Cannot get time of day %s:%s:L%d", __FILE__, __FUNCTION__, __LINE__); - return NULL; + return err; } + con->master_fd = -1; + con->master_pollfd_idx = -1; + con->slave_fd = -1; + con->log_fd = -1; + con->ring_ref = -1; + con->local_port = -1; + con->remote_port = -1; + con->xce_pollfd_idx = -1; + con->next_period = ((long long)ts.tv_sec * 1000) + (ts.tv_nsec / 1000000) + RATE_LIMIT_PERIOD; + con->d = dom; + con->xspath = xs_get_domain_path(xs, dom->domid); + s = realloc(con->xspath, strlen(con->xspath) + + strlen("/console") + 1); + if (s) { + con->xspath = s; + strcat(con->xspath, "/console"); + err = 0; + } + + return err; +} + +static void console_free(struct console *con) +{ + if (con->xspath) + free(con->xspath); +} + +static struct domain *create_domain(int domid) +{ + struct domain *dom; + struct console *con; + dom = calloc(1, sizeof *dom); if (dom == NULL) { dolog(LOG_ERR, "Out of memory %s:%s():L%d", @@ -677,28 +708,10 @@ static struct domain *create_domain(int domid) } dom->domid = domid; - con = &dom->console; - con->xspath = xs_get_domain_path(xs, dom->domid); - s = realloc(con->xspath, strlen(con->xspath) + - strlen("/console") + 1); - if (s == NULL) - goto out; - con->xspath = s; - strcat(con->xspath, "/console"); - - con->master_fd = -1; - con->master_pollfd_idx = -1; - con->slave_fd = -1; - con->log_fd = -1; - con->xce_pollfd_idx = -1; - con->d = dom; - - con->next_period = ((long long)ts.tv_sec * 1000) + (ts.tv_nsec / 1000000) + RATE_LIMIT_PERIOD; - con->ring_ref = -1; - con->local_port = -1; - con->remote_port = -1; + if (console_init(con, dom)) + goto out; if (!watch_domain(dom, true)) goto out; @@ -710,7 +723,7 @@ static struct domain *create_domain(int domid) return dom; out: - free(con->xspath); + console_free(con); free(dom); return NULL; }