Subversion Repositories HelenOS

Rev

Rev 2023 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2023 Rev 2033
Line 35... Line 35...
35
#ifndef KERN_ppc32_CYCLE_H_
35
#ifndef KERN_ppc32_CYCLE_H_
36
#define KERN_ppc32_CYCLE_H_
36
#define KERN_ppc32_CYCLE_H_
37
 
37
 
38
static inline uint64_t get_cycle(void)
38
static inline uint64_t get_cycle(void)
39
{
39
{
-
 
40
    uint32_t lower;
-
 
41
    uint32_t upper;
-
 
42
    uint32_t upper2;
-
 
43
   
-
 
44
    asm volatile (
-
 
45
        "1: mftbu %0\n"
-
 
46
        "mftb %1\n"
-
 
47
        "mftbu %2\n"
-
 
48
        "cmpw %0, %2\n"
-
 
49
        "bne- 1b\n"
-
 
50
        : "=r" (upper),
-
 
51
          "=r" (lower),
-
 
52
          "=r" (upper2)
40
    return 0;
53
        :: "cr0"
-
 
54
    );
-
 
55
   
-
 
56
    return ((uint64_t) upper << 32) + (uint64_t) lower;
41
}
57
}
42
 
58
 
43
#endif
59
#endif
44
 
60
 
45
/** @}
61
/** @}