Warning: This file is not a C or C++ file. It does not have highlighting.
| 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
|---|---|
| 2 | /* |
| 3 | * Copyright (C) 2020-2022 Loongson Technology Corporation Limited |
| 4 | */ |
| 5 | #ifndef _ASM_TIMEX_H |
| 6 | #define _ASM_TIMEX_H |
| 7 | |
| 8 | #ifdef __KERNEL__ |
| 9 | |
| 10 | #include <linux/compiler.h> |
| 11 | |
| 12 | #include <asm/cpu.h> |
| 13 | #include <asm/cpu-features.h> |
| 14 | |
| 15 | typedef unsigned long cycles_t; |
| 16 | |
| 17 | #define get_cycles get_cycles |
| 18 | |
| 19 | static inline cycles_t get_cycles(void) |
| 20 | { |
| 21 | #ifdef CONFIG_32BIT |
| 22 | return rdtime_l(); |
| 23 | #else |
| 24 | return rdtime_d(); |
| 25 | #endif |
| 26 | } |
| 27 | |
| 28 | #ifdef CONFIG_32BIT |
| 29 | |
| 30 | #define get_cycles_hi get_cycles_hi |
| 31 | |
| 32 | static inline cycles_t get_cycles_hi(void) |
| 33 | { |
| 34 | return rdtime_h(); |
| 35 | } |
| 36 | |
| 37 | #endif |
| 38 | |
| 39 | static inline u64 get_cycles64(void) |
| 40 | { |
| 41 | #ifdef CONFIG_32BIT |
| 42 | u32 hi, lo; |
| 43 | |
| 44 | do { |
| 45 | hi = rdtime_h(); |
| 46 | lo = rdtime_l(); |
| 47 | } while (hi != rdtime_h()); |
| 48 | |
| 49 | return ((u64)hi << 32) | lo; |
| 50 | #else |
| 51 | return rdtime_d(); |
| 52 | #endif |
| 53 | } |
| 54 | |
| 55 | #endif /* __KERNEL__ */ |
| 56 | |
| 57 | #endif /* _ASM_TIMEX_H */ |
| 58 |
Warning: This file is not a C or C++ file. It does not have highlighting.
