root/arch/riscv/include/asm/timex.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. get_cycles
  2. get_cycles64
  3. get_cycles_hi
  4. get_cycles64
  5. read_current_timer

   1 /* SPDX-License-Identifier: GPL-2.0-only */
   2 /*
   3  * Copyright (C) 2012 Regents of the University of California
   4  */
   5 
   6 #ifndef _ASM_RISCV_TIMEX_H
   7 #define _ASM_RISCV_TIMEX_H
   8 
   9 #include <asm/csr.h>
  10 
  11 typedef unsigned long cycles_t;
  12 
  13 static inline cycles_t get_cycles(void)
  14 {
  15         return csr_read(CSR_TIME);
  16 }
  17 #define get_cycles get_cycles
  18 
  19 #ifdef CONFIG_64BIT
  20 static inline u64 get_cycles64(void)
  21 {
  22         return get_cycles();
  23 }
  24 #else /* CONFIG_64BIT */
  25 static inline u32 get_cycles_hi(void)
  26 {
  27         return csr_read(CSR_TIMEH);
  28 }
  29 
  30 static inline u64 get_cycles64(void)
  31 {
  32         u32 hi, lo;
  33 
  34         do {
  35                 hi = get_cycles_hi();
  36                 lo = get_cycles();
  37         } while (hi != get_cycles_hi());
  38 
  39         return ((u64)hi << 32) | lo;
  40 }
  41 #endif /* CONFIG_64BIT */
  42 
  43 #define ARCH_HAS_READ_CURRENT_TIMER
  44 static inline int read_current_timer(unsigned long *timer_val)
  45 {
  46         *timer_val = get_cycles();
  47         return 0;
  48 }
  49 
  50 #endif /* _ASM_RISCV_TIMEX_H */

/* [<][>][^][v][top][bottom][index][help] */