]> git.saurik.com Git - apple/xnu.git/blobdiff - osfmk/kern/clock.h
xnu-4570.71.2.tar.gz
[apple/xnu.git] / osfmk / kern / clock.h
index ed8218d17d8a2196836ffd4182299aa37dbb0661..3671e5efe6ff5190c76c7f0afa19bc1173941871 100644 (file)
 #include <mach/clock_types.h>
 #include <mach/message.h>
 #include <mach/mach_time.h>
+#include <mach/boolean.h>
 
 #include <kern/kern_types.h>
 
 #include <sys/cdefs.h>
 
+
 #ifdef __LP64__
 
 typedef unsigned long          clock_sec_t;
@@ -77,7 +79,7 @@ struct        clock_ops {
                                clock_attr_t                    attr,
                                mach_msg_type_number_t  *count);
 };
-typedef struct clock_ops       *clock_ops_t;
+typedef const struct clock_ops *clock_ops_t;
 typedef struct clock_ops       clock_ops_data_t;
 
 /*
@@ -85,7 +87,7 @@ typedef struct clock_ops      clock_ops_data_t;
  * dependent operations list and clock operation ports.
  */
 struct clock {
-       clock_ops_t                     cl_ops;                 /* operations list */
+       clock_ops_t             cl_ops;         /* operations list */
        struct ipc_port         *cl_service;    /* service port */
        struct ipc_port         *cl_control;    /* control port */
 };
@@ -110,23 +112,18 @@ extern void               clock_timebase_init(void);
  */
 extern void            clock_service_create(void);
 
-extern void                    clock_gettimeofday_set_commpage(
-                                               uint64_t                                abstime,
-                                               uint64_t                                epoch,
-                                               uint64_t                                offset,
-                                               clock_sec_t                             *secs,
-                                               clock_usec_t                    *microsecs);
+extern void clock_gettimeofday_set_commpage(
+               uint64_t                                abstime,
+               uint64_t                                sec,
+               uint64_t                                frac,
+               uint64_t                                scale,
+               uint64_t                                tick_per_sec);
 
-extern void                    machine_delay_until(
+extern void                    machine_delay_until(uint64_t interval,
                                                uint64_t                deadline);
 
 extern uint32_t                hz_tick_interval;
 
-extern void            absolutetime_to_nanotime(
-                                       uint64_t                abstime,
-                                       clock_sec_t             *secs,
-                                       clock_nsec_t    *nanosecs);
-
 extern void            nanotime_to_absolutetime(
                                        clock_sec_t             secs,
                                        clock_nsec_t    nanosecs,
@@ -146,10 +143,22 @@ extern void                       clock_initialize_calendar(void);
 
 extern void                    clock_wakeup_calendar(void);
 
+extern void                    clock_update_calendar(void);
+
+extern void                    clock_get_calendar_uptime(clock_sec_t           *secs);
+
+extern void clock_gettimeofday_new(clock_sec_t         *secs,
+       clock_usec_t    *microsecs);
 extern void                    clock_gettimeofday(
                                                clock_sec_t                     *secs,
                                                clock_usec_t            *microsecs);
 
+extern void                    clock_gettimeofday_and_absolute_time(
+                                               clock_sec_t                     *secs,
+                                               clock_usec_t            *microsecs,
+                                               uint64_t                        *absolute_time);
+
+
 extern void                    clock_set_calendar_microtime(
                                                clock_sec_t                     secs,
                                                clock_usec_t            microsecs);
@@ -158,6 +167,10 @@ extern void                        clock_get_boottime_nanotime(
                                                clock_sec_t                     *secs,
                                                clock_nsec_t            *nanosecs);
 
+extern void                    clock_get_boottime_microtime(
+                                               clock_sec_t                     *secs,
+                                               clock_nsec_t            *microsecs);
+
 extern void                    absolutetime_to_microtime(
                                                uint64_t                        abstime,
                                                clock_sec_t                     *secs,
@@ -176,12 +189,19 @@ extern void                       clock_get_calendar_nanotime_nowait(
 
 #endif /* CONFIG_DTRACE */
 
+boolean_t kdp_clock_is_locked(void);
+
 #endif /* XNU_KERNEL_PRIVATE */
 
 extern void                    clock_get_calendar_microtime(
                                                clock_sec_t                     *secs,
                                                clock_usec_t            *microsecs);
 
+extern void                    clock_get_calendar_absolute_and_microtime(
+                                               clock_sec_t                     *secs,
+                                               clock_usec_t            *microsecs,
+                                               uint64_t                *abstime);
+
 extern void                    clock_get_calendar_nanotime(
                                                clock_sec_t                     *secs,
                                                clock_nsec_t            *nanosecs);
@@ -214,6 +234,10 @@ extern void                                clock_absolutetime_interval_to_deadline(
                                                        uint64_t                abstime,
                                                        uint64_t                *result);
 
+extern void                            clock_continuoustime_interval_to_deadline(
+                                                       uint64_t                abstime,
+                                                       uint64_t                *result);
+
 extern void                            clock_delay_until(
                                                        uint64_t                deadline);
 
@@ -221,10 +245,31 @@ extern void                               absolutetime_to_nanoseconds(
                                                        uint64_t                abstime,
                                                        uint64_t                *result);
 
-extern void             nanoseconds_to_absolutetime(
+extern void                            nanoseconds_to_absolutetime(
                                                        uint64_t                nanoseconds,
                                                        uint64_t                *result);
 
+/*
+ * Absolute <-> Continuous Time conversion routines
+ *
+ * It is the caller's responsibility to ensure that these functions are
+ * synchronized with respect to updates to the continuous timebase.  The
+ * returned value is only valid until the next update to the continuous
+ * timebase.
+ *
+ * If the value to be returned by continuoustime_to_absolutetime would be
+ * negative, zero is returned.  This occurs when the provided continuous time
+ * is less the amount of the time the system spent asleep and /must/ be
+ * handled.
+ */
+extern uint64_t                        absolutetime_to_continuoustime(
+                                                       uint64_t                abstime);
+extern uint64_t                        continuoustime_to_absolutetime(
+                                                       uint64_t                conttime);
+
+extern uint64_t mach_absolutetime_asleep;
+extern uint64_t mach_absolutetime_last_sleep;
+
 #ifdef KERNEL_PRIVATE
 
 /*
@@ -259,9 +304,9 @@ extern void             nanoseconds_to_absolutetime(
 #include <Availability.h>
 
 /* Use mach_absolute_time() */
-extern mach_timespec_t clock_get_system_value(void) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_8, __IPHONE_2_0, __IPHONE_NA);
+extern mach_timespec_t clock_get_system_value(void) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_8, __IPHONE_2_0, __IPHONE_6_0);
 
-extern mach_timespec_t clock_get_calendar_value(void) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_8, __IPHONE_2_0, __IPHONE_NA);
+extern mach_timespec_t clock_get_calendar_value(void) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_8, __IPHONE_2_0, __IPHONE_6_0);
 
 #else  /* __LP64__ */
 
@@ -277,41 +322,14 @@ extern void                               delay_for_interval(
                                                        uint32_t                interval,
                                                        uint32_t                scale_factor);
 
-#ifndef        MACH_KERNEL_PRIVATE
-
-#ifndef        __LP64__
-
-#ifndef        ABSOLUTETIME_SCALAR_TYPE
-
-#define clock_get_uptime(a)            \
-       clock_get_uptime(__OSAbsoluteTimePtr(a))
-
-#define clock_interval_to_deadline(a, b, c)            \
-       clock_interval_to_deadline((a), (b), __OSAbsoluteTimePtr(c))
-
-#define clock_interval_to_absolutetime_interval(a, b, c)       \
-       clock_interval_to_absolutetime_interval((a), (b), __OSAbsoluteTimePtr(c))
-
-#define clock_absolutetime_interval_to_deadline(a, b)  \
-       clock_absolutetime_interval_to_deadline(__OSAbsoluteTime(a), __OSAbsoluteTimePtr(b))
-
-#define clock_deadline_for_periodic_event(a, b, c)     \
-       clock_deadline_for_periodic_event(__OSAbsoluteTime(a), __OSAbsoluteTime(b), __OSAbsoluteTimePtr(c))
-
-#define clock_delay_until(a)   \
-       clock_delay_until(__OSAbsoluteTime(a))
-
-#define absolutetime_to_nanoseconds(a, b)      \
-       absolutetime_to_nanoseconds(__OSAbsoluteTime(a), (b))
-
-#define nanoseconds_to_absolutetime(a, b)      \
-       nanoseconds_to_absolutetime((a), __OSAbsoluteTimePtr(b))
-
-#endif /* ABSOLUTETIME_SCALAR_TYPE */
-
-#endif /* __LP64__ */
+extern void                            delay_for_interval_with_leeway(
+                                                       uint32_t                interval,
+                                                       uint32_t                leeway,
+                                                       uint32_t                scale_factor);
 
-#endif /* MACH_KERNEL_PRIVATE */
+#ifdef XNU_KERNEL_PRIVATE
+extern void delay(int usec);
+#endif /* XNU_KERNEL_PRIVATE */
 
 #endif /* KERNEL_PRIVATE */