~ubuntu-branches/ubuntu/trusty/virtualbox-lts-xenial/trusty-proposed

« back to all changes in this revision

Viewing changes to src/VBox/Devices/PC/ipxe/src/arch/i386/include/ipxe/rdtsc_timer.h

  • Committer: Package Import Robot
  • Author(s): Gianfranco Costamagna
  • Date: 2016-02-23 14:28:26 UTC
  • Revision ID: package-import@ubuntu.com-20160223142826-bdu69el2z6wa2a44
Tags: upstream-4.3.36-dfsg
ImportĀ upstreamĀ versionĀ 4.3.36-dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef _IPXE_RDTSC_TIMER_H
 
2
#define _IPXE_RDTSC_TIMER_H
 
3
 
 
4
/** @file
 
5
 *
 
6
 * RDTSC timer
 
7
 *
 
8
 */
 
9
 
 
10
FILE_LICENCE ( GPL2_OR_LATER );
 
11
 
 
12
#ifdef TIMER_RDTSC
 
13
#define TIMER_PREFIX_rdtsc
 
14
#else
 
15
#define TIMER_PREFIX_rdtsc __rdtsc_
 
16
#endif
 
17
 
 
18
/**
 
19
 * RDTSC values can easily overflow an unsigned long.  We discard the
 
20
 * low-order bits in order to obtain sensibly-scaled values.
 
21
 */
 
22
#define TSC_SHIFT 8
 
23
 
 
24
/**
 
25
 * Get current system time in ticks
 
26
 *
 
27
 * @ret ticks           Current time, in ticks
 
28
 */
 
29
static inline __always_inline unsigned long
 
30
TIMER_INLINE ( rdtsc, currticks ) ( void ) {
 
31
        unsigned long ticks;
 
32
 
 
33
        __asm__ __volatile__ ( "rdtsc\n\t"
 
34
                               "shrdl %1, %%edx, %%eax\n\t"
 
35
                               : "=a" ( ticks ) : "i" ( TSC_SHIFT ) : "edx" );
 
36
        return ticks;
 
37
}
 
38
 
 
39
#endif /* _IPXE_RDTSC_TIMER_H */