From patchwork Mon Feb 18 11:11:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cornelia Huck X-Patchwork-Id: 158587 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp2365997jaa; Mon, 18 Feb 2019 03:17:36 -0800 (PST) X-Google-Smtp-Source: AHgI3IZm/m2mdp8a5NXWTHIGrTHEY2ApFhJF081/jRE80PELdtSSpqFzu2UTCuQi+Seo4SLHiJ47 X-Received: by 2002:a25:1902:: with SMTP id 2mr18892821ybz.327.1550488655996; Mon, 18 Feb 2019 03:17:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550488655; cv=none; d=google.com; s=arc-20160816; b=WZAd2q7JX6Qig0mt9c1pHq31QWCWkhBtvXml/jhstIDCXu5fEbOaoEaTkYVFLyth/j NGuNP+I4c9Xj1NSPhIZujWpKCTb8EwRq53EQDM9OhHeD8D+9xRXBnFiM2Byj3fhLrNMi phKIWMWUfLKBFjBQJptzrUouGxbRI0U27RkpqxJgt0wffuuzT+r3sb5hrVcU49d8EU7C 0/hzq7xdyvQ1BFrZsrIWWELtfUmNXW/gxWZeGKN5J9oTqTvXxNoc0Jh07TjwLwoDGavf 5V1cr5cANucdtidZqK3JteYBAPd7g6IPswEEfhuw+Z/ZpftVnGdfsbVhbBVmAgr93eR9 /zGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from; bh=wN0qQUTLvWGLpdvauOTBRNA1e6jpbgES7jb2hxxC23M=; b=XT+80xsxvrddFGtINlHmOFPBdNeG0LtWEW24uHFe2YAb7VOOmOsRt59W3pvaUt6y1o cGJiZRHvXdg6Q++mlQKfue7L2MG6u7NGBB5NJ3XoLj1EKrMvoAaT7hiH5+FIof0By627 MdyaWf3lZAEIj7DQEKNH51J9GGrHyFO7+bXjqHnTKVOSddDSPSxxRf0N1sHOG3C6wyrR iCbVLJZOIl94CY+eZEAQaViZ3kHupJDO5EE5OC6RQ42VVKpuOGYcwWi9NR9GcY7oBObg WKpuu1mhCR+jufSHVEwb/k1d/JVbhIo/uixoBQ6kcwtrueR9s9tTjbd9R7M1wPGx3cEM Kclg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id b137si2101955yba.101.2019.02.18.03.17.35 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 18 Feb 2019 03:17:35 -0800 (PST) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from localhost ([127.0.0.1]:56613 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gvgvX-0001pg-FY for patch@linaro.org; Mon, 18 Feb 2019 06:17:35 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52268) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gvgqE-0006q9-HC for qemu-devel@nongnu.org; Mon, 18 Feb 2019 06:12:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gvgqD-0006gP-Ge for qemu-devel@nongnu.org; Mon, 18 Feb 2019 06:12:06 -0500 Received: from mx1.redhat.com ([209.132.183.28]:44610) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gvgqD-0006g3-A6; Mon, 18 Feb 2019 06:12:05 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 743CEC0799B7; Mon, 18 Feb 2019 11:12:04 +0000 (UTC) Received: from localhost (ovpn-116-217.ams2.redhat.com [10.36.116.217]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 10F5D61495; Mon, 18 Feb 2019 11:12:03 +0000 (UTC) From: Cornelia Huck To: Peter Maydell Date: Mon, 18 Feb 2019 12:11:46 +0100 Message-Id: <20190218111153.22681-4-cohuck@redhat.com> In-Reply-To: <20190218111153.22681-1-cohuck@redhat.com> References: <20190218111153.22681-1-cohuck@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 18 Feb 2019 11:12:04 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 03/10] target/s390x: Split out s390-tod.h X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-s390x@nongnu.org, Cornelia Huck , Richard Henderson , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson We will need these from CONFIG_USER_ONLY as well, which cannot access include/hw/. Reviewed-by: Thomas Huth Reviewed-by: David Hildenbrand Signed-off-by: Richard Henderson Message-Id: <20190212053044.29015-2-richard.henderson@linaro.org> Signed-off-by: Cornelia Huck --- include/hw/s390x/tod.h | 16 +--------------- target/s390x/s390-tod.h | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 15 deletions(-) create mode 100644 target/s390x/s390-tod.h -- 2.17.2 diff --git a/include/hw/s390x/tod.h b/include/hw/s390x/tod.h index 47ef9de869cc..9c4a6000c331 100644 --- a/include/hw/s390x/tod.h +++ b/include/hw/s390x/tod.h @@ -12,6 +12,7 @@ #define HW_S390_TOD_H #include "hw/qdev.h" +#include "s390-tod.h" typedef struct S390TOD { uint8_t high; @@ -50,21 +51,6 @@ typedef struct S390TODClass { void (*set)(S390TODState *td, const S390TOD *tod, Error **errp); } S390TODClass; -/* The value of the TOD clock for 1.1.1970. */ -#define TOD_UNIX_EPOCH 0x7d91048bca000000ULL - -/* Converts ns to s390's clock format */ -static inline uint64_t time2tod(uint64_t ns) -{ - return (ns << 9) / 125 + (((ns & 0xff80000000000000ull) / 125) << 9); -} - -/* Converts s390's clock format to ns */ -static inline uint64_t tod2time(uint64_t t) -{ - return ((t >> 9) * 125) + (((t & 0x1ff) * 125) >> 9); -} - void s390_init_tod(void); S390TODState *s390_get_todstate(void); diff --git a/target/s390x/s390-tod.h b/target/s390x/s390-tod.h new file mode 100644 index 000000000000..8b74d6a6d886 --- /dev/null +++ b/target/s390x/s390-tod.h @@ -0,0 +1,29 @@ +/* + * TOD (Time Of Day) clock + * + * Copyright 2018 Red Hat, Inc. + * Author(s): David Hildenbrand + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + +#ifndef TARGET_S390_TOD_H +#define TARGET_S390_TOD_H + +/* The value of the TOD clock for 1.1.1970. */ +#define TOD_UNIX_EPOCH 0x7d91048bca000000ULL + +/* Converts ns to s390's clock format */ +static inline uint64_t time2tod(uint64_t ns) +{ + return (ns << 9) / 125 + (((ns & 0xff80000000000000ull) / 125) << 9); +} + +/* Converts s390's clock format to ns */ +static inline uint64_t tod2time(uint64_t t) +{ + return ((t >> 9) * 125) + (((t & 0x1ff) * 125) >> 9); +} + +#endif