From patchwork Tue Feb 12 05:30:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 158093 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp3439336jaa; Mon, 11 Feb 2019 21:38:55 -0800 (PST) X-Google-Smtp-Source: AHgI3Iaq5pdVBkFOY4Cqmk2VF35+bTwM61adTkzu6AjQH+1IFv+IT1RbXfxcYGXn8HgHZnTaQsHv X-Received: by 2002:a25:7284:: with SMTP id n126mr1515736ybc.504.1549949935344; Mon, 11 Feb 2019 21:38:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549949935; cv=none; d=google.com; s=arc-20160816; b=cOt9GU1qkrSW0dFeZKZcbIXnhE1aRjeVZjBub9yl/z+1dgwgn46nuMJR9Iw+15kTlA hPJ9v5LCDneXoKinLhCwn6bZr5yy+Yq51DHdIt3Dwvvm0w9PezuGQDsC91XNkByqfQfg n5+ErIYBxVso4f9VQszc3vc/tLBMa7iO41Lm5KRcuD5HtwUGqpVLmSadzwnLR8v8QJpP Efrap+wSC9AS+La96QjoN3vBDNi2gIlggXF8QMeVellNhbrrb0gVprEsGdD9sqyoIsr2 7Ea4w0zGU+38I3DQIWhl31hmIaGqiPgIMgPcVdzCr2FWr8Z4lY6Kv5YUKhkRD1f2qQJH HgZA== 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=vLEKYFvAuLQbA+pZwdtsS5qwQxZp0LswOsj4vjwjJCA=; b=QVZ3ukfwm2WPsV0DT2MJjghKWCi3UJG/RRig2xLAg1hJcJjwmGSL6rg+0U9wkLv1ty GQDMWtolcWQfAhsu9urefMx9wKYi4jHYQ5LQeUdK/T3JWppNK4oMQa/FkXAkDpH0G6S8 F1GRgzxr4/8B3p00SxC3rMClcJ0QRHqQGcV+G5oyfu0FOKchJX9PtabVOtBx5V/o32tE ynmRUNVRlgeEN/U+OGo/h6RKJiLQYCVdC21dZPR3daHvmAe9KGJhXQ+PmxR0C0QteV2p 7HorpH3WlkzaNmmzpLZrqfRNdlKPHyoR6cSb0zVm9H9aGzYmbctfXRvzSz7jwJz/cuyK ZHcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=UDRTThdw; 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 6si7015941ybo.316.2019.02.11.21.38.55 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 11 Feb 2019 21:38:55 -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=UDRTThdw; 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]:33615 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gtQmU-0007Qg-SI for patch@linaro.org; Tue, 12 Feb 2019 00:38:54 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45943) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gtQi1-00041D-Ri for qemu-devel@nongnu.org; Tue, 12 Feb 2019 00:34:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gtQel-00076L-Bu for qemu-devel@nongnu.org; Tue, 12 Feb 2019 00:30:57 -0500 Received: from mail-pl1-x643.google.com ([2607:f8b0:4864:20::643]:39457) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gtQek-0006H5-PM for qemu-devel@nongnu.org; Tue, 12 Feb 2019 00:30:54 -0500 Received: by mail-pl1-x643.google.com with SMTP id 101so729882pld.6 for ; Mon, 11 Feb 2019 21:30:49 -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=vLEKYFvAuLQbA+pZwdtsS5qwQxZp0LswOsj4vjwjJCA=; b=UDRTThdwAqR6wleEAJo57z8hl0/TZ2b2dUpWHQ0IGCdJB4pQ/Pj9hwxBjkIPc4M+2J xIS5GXnFufSzKWyepQqQc6RDHWmrJ+d7U7VOtxXDSdA7fk3XF2VvqSO1SR1geZJk7odA ZdgbxuP3cqI7i2+0bAzXSLKEyCH2HCrKZfJ9LgLLlEPH6dvpUziUdzUVy743xrLFPbmF yQIwIBW7mQiqdxOuzc2OCMctRxMPHNqcetHEvrQLq7esfnTcrC5pj38Cyh7QtjVqWBA4 EKW6RAxXrv2Gesl9Ts52JzajbQi65W2Dl297rd/MoIMwgdB29UschuMgqjMwy8oCHZtg pIUw== 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=vLEKYFvAuLQbA+pZwdtsS5qwQxZp0LswOsj4vjwjJCA=; b=K2uN2O7J6KUA7q/KWtQlnT2LkLk02mxx9Jd/P1I9iZXXyUwUBGVY4K0E9ZSQO6k6MY yCWE9bnyc5fYswJD/wQoeBKeOj34pm28gkyodSchSR5BxDk+92hPSRRk9yD4CKIg3nzJ kgQcnSXAMJePMYFVpyZyCCGtnj8FguGgJ55hzM/7Nyl99D6C5+d1+NzvG/Ea6tUoDVJC bbGzbKXZaQ1F1kjyt/XtAHu+HoRDnlVhLEbl4Anz4O6P16oJPg1bdz4/cNH/67XW5nsH SeiRKNHd1M2m2c3IvxejEnRTBIdPTFDAOcGoSskWiSlI7aLazlQc0moI183QhLjqEND5 kUpw== X-Gm-Message-State: AHQUAubBK6Z+k66FCH712MElj0QJjnjbgnydiEzNzy6M+wM4dY0bq2ZY HtJRDOmrMzSTHcm58xUowB76I7oT7wk= X-Received: by 2002:a17:902:704b:: with SMTP id h11mr2199733plt.157.1549949447703; Mon, 11 Feb 2019 21:30:47 -0800 (PST) Received: from cloudburst.twiddle.net (97-113-188-82.tukw.qwest.net. [97.113.188.82]) by smtp.gmail.com with ESMTPSA id d16sm13625036pgj.21.2019.02.11.21.30.46 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 11 Feb 2019 21:30:46 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 11 Feb 2019 21:30:43 -0800 Message-Id: <20190212053044.29015-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190212053044.29015-1-richard.henderson@linaro.org> References: <20190212053044.29015-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::643 Subject: [Qemu-devel] [PATCH v3 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, cohuck@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/. Reviewed-by: Thomas Huth Reviewed-by: David Hildenbrand 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 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