2 * Copyright (c) 2005 SilverStorm Technologies. All rights reserved.
\r
3 * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
\r
5 * This software is available to you under the OpenIB.org BSD license
\r
8 * Redistribution and use in source and binary forms, with or
\r
9 * without modification, are permitted provided that the following
\r
10 * conditions are met:
\r
12 * - Redistributions of source code must retain the above
\r
13 * copyright notice, this list of conditions and the following
\r
16 * - Redistributions in binary form must reproduce the above
\r
17 * copyright notice, this list of conditions and the following
\r
18 * disclaimer in the documentation and/or other materials
\r
19 * provided with the distribution.
\r
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
\r
22 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
\r
23 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
\r
24 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
\r
25 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
\r
26 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
\r
27 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
\r
36 #ifndef _CL_TIMER_OSD_H_
\r
37 #define _CL_TIMER_OSD_H_
\r
40 #include "complib/cl_types.h"
\r
43 /* Timer object definition. */
\r
44 typedef struct _cl_timer
\r
48 cl_pfn_timer_callback_t pfn_callback;
\r
49 const void *context;
\r
50 uint64_t timeout_time;
\r
60 /* 100ns to s conversion */
\r
61 #define HUNDREDNS_TO_SEC 10000000ULL
\r
62 /* s to µs conversion */
\r
63 #define SEC_TO_MICRO 1000000ULL
\r
65 CL_INLINE uint64_t CL_API
\r
66 cl_get_time_stamp( void )
\r
68 LARGE_INTEGER tick_count, frequency;
\r
70 tick_count = KeQueryPerformanceCounter( &frequency );
\r
71 return( tick_count.QuadPart / (frequency.QuadPart / SEC_TO_MICRO) );
\r
74 CL_INLINE uint32_t CL_API
\r
75 cl_get_time_stamp_sec( void )
\r
77 return( (uint32_t)(KeQueryInterruptTime() / HUNDREDNS_TO_SEC) );
\r
84 #endif // _CL_TIMER_OSD_H_