From patchwork Sat Feb 9 06:31:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 157930 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp347166jaa; Fri, 8 Feb 2019 22:32:31 -0800 (PST) X-Google-Smtp-Source: AHgI3IbDjSvp8k2jq++6ESpL2kqhCp+eoIHMTlQHSpPKtJuDC2YzPRXrxSNlrqZZKlY7dQrlbXQj X-Received: by 2002:a05:6000:1044:: with SMTP id c4mr11578097wrx.296.1549693951853; Fri, 08 Feb 2019 22:32:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549693951; cv=none; d=google.com; s=arc-20160816; b=PqHs5iFmyxOYs/1wmYFmdgRj/wuCpyp4muas99R6c7HAuXyVKvHUs/xt7yD+acUDMm 6ETVi5Fv++jjwH4mjtScE8wsr2TdZKz4LvfN5Hxk6UMHR8z7T/Ypiuncsi+uVWG7fCMX d0WT1nTP8JZtLOkv82UfheytspFckwjHx/vu3ppbk9VHsJK85D2h8nbzMDDKF2nV37zu F2P9MRbA+wBkmlTnjoRoWC5/1Mnv+O6qYt2KD+cUqZvxr387mLyRXb4o52DRhZghu0qD p/Rhgl4xQljavP9ZsA+pSTw+p2oNHP9knX8Dc5xkQwZ6WEIjVi5LOUyvvKYs/WGIXc1m RUaw== 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:dkim-signature; bh=YMqxhfu88Z2kP2dYHld6PH/lBGcNG05WKIQCsarEYBA=; b=ALfXVG96csiNMi9eMvh0ksEyRllmKvs5+TbnprAftRvP/ZJEqSiCYozlOxdFyHdjGn p/xu15og3WBdrL6eTmv7ZeEvkNvRCWLBAypGtihFAmnl6prDVkeAXi/1cSGMRsVrnYZg 7AcIFXzfjj8LBMqul34RNvd8ZAYlK7seHyAHa7Cxx8hw40YEDw5nhWm1QF/dqN9OZC1C wfnhLBB0X7IK5f8JBr/VVUgFonzb/7/wAkczXoYmfXaYgSjpz1wCTQrBVo+QJb9RRLqL Oc/YfFcM7ar/iBfrcDcTBfmC9xLSoM9K5+LM5wDJ1x8328bzQ1oDwX6C31qZqki8MfOH Gn4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=oXmhHonT; 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=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id s12si4169506wrp.99.2019.02.08.22.32.31 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 08 Feb 2019 22:32:31 -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; dkim=fail header.i=@linaro.org header.s=google header.b=oXmhHonT; 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=linaro.org Received: from localhost ([127.0.0.1]:41105 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gsMBi-0000UN-QZ for patch@linaro.org; Sat, 09 Feb 2019 01:32:30 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39308) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gsMBC-0000S4-0f for qemu-devel@nongnu.org; Sat, 09 Feb 2019 01:31:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gsMBB-0007Jj-5u for qemu-devel@nongnu.org; Sat, 09 Feb 2019 01:31:57 -0500 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]:41449) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gsMBB-0007Iq-0x for qemu-devel@nongnu.org; Sat, 09 Feb 2019 01:31:57 -0500 Received: by mail-pg1-x542.google.com with SMTP id m1so2538318pgq.8 for ; Fri, 08 Feb 2019 22:31:56 -0800 (PST) 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=YMqxhfu88Z2kP2dYHld6PH/lBGcNG05WKIQCsarEYBA=; b=oXmhHonTX+V7yN/V/h7M/B36FZQwsyoES9VpHUlGIg93AJpIRZfnxBgQ1QGp7wiN0j K8U/wrsNjmYC2zadNyPa6Xc7rBHQceV//n1hWx1LUU1uDYlSJxzrQ4a1Tv+dLgOXshal ST5ws2I/acsaIBfPbNMujBYvb7tZ48z5UeyGVzaIdOupTIPDMyZyXJrgkVQskYciuR/H +9P0z40aikOkCQJM7jrmcDeZQG5ITdoFpH1wI1k1FU16jYFXEAyYTB2Sljv3l+b6n4we Mg/cxmX5WmhtjB2BUUoTZj4XpjqVVcN9pgXQcXflhlw4ocagMjgODKgymxYZ/E58Kdg0 QbzQ== 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=YMqxhfu88Z2kP2dYHld6PH/lBGcNG05WKIQCsarEYBA=; b=SGSSKd9PvaSH9SFDj2riDgAEUnW9PtfPy0uNlvCl8qTUUQemEOvUqB9oaPwmAeWTJ/ ac2z6WK4IonTvnCADthzT5EkeNRUPwYkwYiOcClzQkToZCgLvtXAGeR2aj7Ed1W1Awa3 ZyhKv2rhld1KbtXAGkXlNht4DJX4yc5GUyigRw/7Ba53jYdJ5+RtJflxiC33oCElBDR8 EJ6Wvk9bawc1M8CLwXRVoXTosjCXzdy4BfB2COsl/PNcrQQ5w4yjTG441uK/jpAhFVHJ IIb8ovu9sHxGnEQ63/rfyvfu0Ztl7vqd/fi1KtrCe3KrHZsiPBlPNggLSml2Egacd/ix L94w== X-Gm-Message-State: AHQUAubCm73wBTQdgDfQM1yBO6zJ6OkWIZvdJPkTTw7rk/G1wOWit4AE Gl5KvBR6qSWbwLCNT3hF8axvLhyPIP4= X-Received: by 2002:a63:2643:: with SMTP id m64mr23624980pgm.35.1549693915614; Fri, 08 Feb 2019 22:31:55 -0800 (PST) Received: from cloudburst.twiddle.net (97-126-115-157.tukw.qwest.net. [97.126.115.157]) by smtp.gmail.com with ESMTPSA id a15sm4777426pgd.4.2019.02.08.22.31.54 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 Feb 2019 22:31:54 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 8 Feb 2019 22:31:51 -0800 Message-Id: <20190209063152.9490-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190209063152.9490-1-richard.henderson@linaro.org> References: <20190209063152.9490-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::542 Subject: [Qemu-devel] [PATCH v2 1/2] 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, thuth@redhat.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" We will need these from CONFIG_USER_ONLY as well, which cannot access include/hw/. Signed-off-by: Richard Henderson --- 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 Reviewed-by: Thomas Huth Reviewed-by: David Hildenbrand diff --git a/include/hw/s390x/tod.h b/include/hw/s390x/tod.h index 47ef9de869..9c4a6000c3 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 0000000000..8b74d6a6d8 --- /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