X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/c0fea4742e91338fffdcf79f86a7c1d5e2b97eb1..490019cf9519204c5fb36b2fba54ceb983bb6b72:/osfmk/kern/clock.h diff --git a/osfmk/kern/clock.h b/osfmk/kern/clock.h index ee52ad8f2..8918ca3c1 100644 --- a/osfmk/kern/clock.h +++ b/osfmk/kern/clock.h @@ -1,23 +1,29 @@ /* - * Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved. + * Copyright (c) 2000-2008 Apple Inc. All rights reserved. * - * @APPLE_LICENSE_HEADER_START@ + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ * - * The contents of this file constitute Original Code as defined in and - * are subject to the Apple Public Source License Version 1.1 (the - * "License"). You may not use this file except in compliance with the - * License. Please obtain a copy of the License at - * http://www.apple.com/publicsource and read it before using this file. + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. * - * This Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * - * @APPLE_LICENSE_HEADER_END@ + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ */ /* * @OSF_COPYRIGHT@ @@ -38,8 +44,22 @@ #include +#ifdef __LP64__ + +typedef unsigned long clock_sec_t; +typedef unsigned int clock_usec_t, clock_nsec_t; + +#else /* __LP64__ */ + +typedef uint32_t clock_sec_t; +typedef uint32_t clock_usec_t, clock_nsec_t; + +#endif /* __LP64__ */ + #ifdef MACH_KERNEL_PRIVATE +#include + /* * Clock operations list structure. Contains vectors to machine * dependent clock routines. @@ -90,47 +110,21 @@ extern void clock_timebase_init(void); */ extern void clock_service_create(void); -typedef void (*clock_timer_func_t)( - uint64_t timestamp); - -extern void clock_set_timer_func( - clock_timer_func_t func); - -extern void clock_set_timer_deadline( - uint64_t deadline); - extern void clock_gettimeofday_set_commpage( uint64_t abstime, uint64_t epoch, uint64_t offset, - uint32_t *secs, - uint32_t *microsecs); + clock_sec_t *secs, + clock_usec_t *microsecs); -extern void machine_delay_until( +extern void machine_delay_until(uint64_t interval, uint64_t deadline); -#include - -extern void hertz_tick( -#if STAT_TIME - natural_t ticks, -#endif /* STAT_TIME */ - boolean_t usermode, /* executing user code */ - natural_t pc); - -extern void absolutetime_to_microtime( - uint64_t abstime, - uint32_t *secs, - uint32_t *microsecs); - -extern void absolutetime_to_nanotime( - uint64_t abstime, - uint32_t *secs, - uint32_t *nanosecs); +extern uint32_t hz_tick_interval; extern void nanotime_to_absolutetime( - uint32_t secs, - uint32_t nanosecs, + clock_sec_t secs, + clock_nsec_t nanosecs, uint64_t *result); #endif /* MACH_KERNEL_PRIVATE */ @@ -140,48 +134,65 @@ __BEGIN_DECLS #ifdef XNU_KERNEL_PRIVATE extern void clock_adjtime( - int32_t *secs, - int32_t *microsecs); + long *secs, + int *microsecs); extern void clock_initialize_calendar(void); extern void clock_wakeup_calendar(void); extern void clock_gettimeofday( - uint32_t *secs, - uint32_t *microsecs); + clock_sec_t *secs, + clock_usec_t *microsecs); extern void clock_set_calendar_microtime( - uint32_t secs, - uint32_t microsecs); + clock_sec_t secs, + clock_usec_t microsecs); extern void clock_get_boottime_nanotime( - uint32_t *secs, - uint32_t *nanosecs); + clock_sec_t *secs, + clock_nsec_t *nanosecs); + +extern void absolutetime_to_microtime( + uint64_t abstime, + clock_sec_t *secs, + clock_usec_t *microsecs); extern void clock_deadline_for_periodic_event( uint64_t interval, uint64_t abstime, uint64_t *deadline); -#endif /* XNU_KERNEL_PRIVATE */ +#if CONFIG_DTRACE + +extern void clock_get_calendar_nanotime_nowait( + clock_sec_t *secs, + clock_nsec_t *nanosecs); +#endif /* CONFIG_DTRACE */ + +#endif /* XNU_KERNEL_PRIVATE */ extern void clock_get_calendar_microtime( - uint32_t *secs, - uint32_t *microsecs); + 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( - uint32_t *secs, - uint32_t *nanosecs); + clock_sec_t *secs, + clock_nsec_t *nanosecs); extern void clock_get_system_microtime( - uint32_t *secs, - uint32_t *microsecs); + clock_sec_t *secs, + clock_usec_t *microsecs); extern void clock_get_system_nanotime( - uint32_t *secs, - uint32_t *nanosecs); + clock_sec_t *secs, + clock_nsec_t *nanosecs); extern void clock_timebase_info( mach_timebase_info_t info); @@ -214,12 +225,17 @@ extern void nanoseconds_to_absolutetime( uint64_t nanoseconds, uint64_t *result); +extern uint64_t mach_absolutetime_asleep; +extern uint64_t mach_absolutetime_last_sleep; + #ifdef KERNEL_PRIVATE /* * Obsolete interfaces. */ +#ifndef __LP64__ + #define MACH_TIMESPEC_SEC_MAX (0 - 1) #define MACH_TIMESPEC_NSEC_MAX (NSEC_PER_SEC - 1) @@ -243,45 +259,31 @@ extern void nanoseconds_to_absolutetime( } \ } while (0) +#include -extern mach_timespec_t clock_get_system_value(void); - -extern mach_timespec_t clock_get_calendar_value(void); - -extern void delay_for_interval( - uint32_t interval, - uint32_t scale_factor); -#ifndef MACH_KERNEL_PRIVATE - -#ifndef ABSOLUTETIME_SCALAR_TYPE - -#define clock_get_uptime(a) \ - clock_get_uptime(__OSAbsoluteTimePtr(a)) +/* 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_6_0); -#define clock_interval_to_deadline(a, b, c) \ - clock_interval_to_deadline((a), (b), __OSAbsoluteTimePtr(c)) +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); -#define clock_interval_to_absolutetime_interval(a, b, c) \ - clock_interval_to_absolutetime_interval((a), (b), __OSAbsoluteTimePtr(c)) +#else /* __LP64__ */ -#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)) +#ifdef XNU_KERNEL_PRIVATE -#define clock_delay_until(a) \ - clock_delay_until(__OSAbsoluteTime(a)) +#define MACH_TIMESPEC_ZERO ((mach_timespec_t) { 0, 0 } ) -#define absolutetime_to_nanoseconds(a, b) \ - absolutetime_to_nanoseconds(__OSAbsoluteTime(a), (b)) +#endif /* XNU_KERNEL_PRIVATE */ -#define nanoseconds_to_absolutetime(a, b) \ - nanoseconds_to_absolutetime((a), __OSAbsoluteTimePtr(b)) +#endif /* __LP64__ */ -#endif /* ABSOLUTETIME_SCALAR_TYPE */ +extern void delay_for_interval( + uint32_t interval, + uint32_t scale_factor); -#endif /* !MACH_KERNEL_PRIVATE */ +extern void delay_for_interval_with_leeway( + uint32_t interval, + uint32_t leeway, + uint32_t scale_factor); #endif /* KERNEL_PRIVATE */