[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PULL 09/31] hw/core/clock: introduce clock object
From: |
Peter Maydell |
Subject: |
Re: [PULL 09/31] hw/core/clock: introduce clock object |
Date: |
Thu, 30 Apr 2020 15:35:10 +0100 |
On Thu, 30 Apr 2020 at 12:51, Peter Maydell <address@hidden> wrote:
>
> This object may be used to represent a clock inside a clock tree.
>
> A clock may be connected to another clock so that it receives update,
> through a callback, whenever the source/parent clock is updated.
>
> Although only the root clock of a clock tree controls the values
> (represented as periods) of all clocks in tree, each clock holds
> a local state containing the current value so that it can be fetched
> independently. It will allows us to fullfill migration requirements
> by migrating each clock independently of others.
> +#define CLOCK_SECOND (1000000000llu << 32)
It turns out that FreeBSD's time.h defines a CLOCK_SECOND
macro, which means this doesn't compile on that platform.
I'm going to rename it CLOCK_PERIOD_1SEC; it's only used
in include/hw/clock.h so not a big change:
diff --git a/include/hw/clock.h b/include/hw/clock.h
index f3e44e9460c..f822a942209 100644
--- a/include/hw/clock.h
+++ b/include/hw/clock.h
@@ -32,15 +32,15 @@ typedef void ClockCallback(void *opaque);
* + at 1Ghz, resolution is ~0.2Hz
* + at 10Ghz, resolution is ~20Hz
*/
-#define CLOCK_SECOND (1000000000llu << 32)
+#define CLOCK_PERIOD_1SEC (1000000000llu << 32)
/*
* macro helpers to convert to hertz / nanosecond
*/
-#define CLOCK_PERIOD_FROM_NS(ns) ((ns) * (CLOCK_SECOND / 1000000000llu))
-#define CLOCK_PERIOD_TO_NS(per) ((per) / (CLOCK_SECOND / 1000000000llu))
-#define CLOCK_PERIOD_FROM_HZ(hz) (((hz) != 0) ? CLOCK_SECOND / (hz) : 0u)
-#define CLOCK_PERIOD_TO_HZ(per) (((per) != 0) ? CLOCK_SECOND / (per) : 0u)
+#define CLOCK_PERIOD_FROM_NS(ns) ((ns) * (CLOCK_PERIOD_1SEC / 1000000000llu))
+#define CLOCK_PERIOD_TO_NS(per) ((per) / (CLOCK_PERIOD_1SEC / 1000000000llu))
+#define CLOCK_PERIOD_FROM_HZ(hz) (((hz) != 0) ? CLOCK_PERIOD_1SEC / (hz) : 0u)
+#define CLOCK_PERIOD_TO_HZ(per) (((per) != 0) ? CLOCK_PERIOD_1SEC / (per) : 0u)
/**
* Clock:
thanks
-- PMM
- [PULL 02/31] dma/xlnx-zdma: Fix descriptor loading (REG) wrt endianness, (continued)
- [PULL 02/31] dma/xlnx-zdma: Fix descriptor loading (REG) wrt endianness, Peter Maydell, 2020/04/30
- [PULL 05/31] Typo: Correct the name of CPU hotplug memory region, Peter Maydell, 2020/04/30
- [PULL 04/31] bugfix: Use gicr_typer in arm_gicv3_icc_reset, Peter Maydell, 2020/04/30
- [PULL 07/31] msf2: Add EMAC block to SmartFusion2 SoC, Peter Maydell, 2020/04/30
- [PULL 06/31] hw/net: Add Smartfusion2 emac block, Peter Maydell, 2020/04/30
- [PULL 08/31] tests/boot_linux_console: Add ethernet test to SmartFusion2, Peter Maydell, 2020/04/30
- [PULL 10/31] hw/core/clock-vmstate: define a vmstate entry for clock state, Peter Maydell, 2020/04/30
- [PULL 11/31] qdev: add clock input&output support to devices., Peter Maydell, 2020/04/30
- [PULL 12/31] qdev-clock: introduce an init array to ease the device construction, Peter Maydell, 2020/04/30
- [PULL 09/31] hw/core/clock: introduce clock object, Peter Maydell, 2020/04/30
- Re: [PULL 09/31] hw/core/clock: introduce clock object,
Peter Maydell <=
- [PULL 13/31] docs/clocks: add device's clock documentation, Peter Maydell, 2020/04/30
- [PULL 14/31] hw/misc/zynq_slcr: add clock generation for uarts, Peter Maydell, 2020/04/30
- [PULL 16/31] hw/arm/xilinx_zynq: connect uart clocks to slcr, Peter Maydell, 2020/04/30
- [PULL 15/31] hw/char/cadence_uart: add clock support, Peter Maydell, 2020/04/30
- [PULL 18/31] hw/arm: versal: Setup the ADMA with 128bit bus-width, Peter Maydell, 2020/04/30
- [PULL 19/31] Cadence: gem: fix wraparound in 64bit descriptors, Peter Maydell, 2020/04/30
- [PULL 20/31] net: cadence_gem: clear RX control descriptor, Peter Maydell, 2020/04/30
- [PULL 17/31] qdev-monitor: print the device's clock with info qtree, Peter Maydell, 2020/04/30
- [PULL 22/31] hw/arm/virt: dt: move creation of /secure-chosen to create_fdt(), Peter Maydell, 2020/04/30
- [PULL 21/31] target/arm: Vectorize integer comparison vs zero, Peter Maydell, 2020/04/30