diff options
author | Jens Wiklander <jens.wiklander@linaro.org> | 2015-02-02 10:51:13 +0100 |
---|---|---|
committer | Jens Wiklander <jens.wiklander@linaro.org> | 2015-02-26 07:36:49 +0100 |
commit | 7eaee2d7837a4565fd745cd0993c9c67608a6c13 (patch) | |
tree | f9fec411fcc74558fd56972c830a5acde64b2017 | |
parent | ca50fe049a98232d72863dab470590f3fc7c54f7 (diff) |
arm32: move some inline assembly into arm32.h
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
Reviewed-by: Pascal Brand <pascal.brand@linaro.org>
Tested-by: Jens Wiklander <jens.wiklander@linaro.org> (QEMU)
-rw-r--r-- | core/arch/arm32/include/arm32.h | 15 | ||||
-rw-r--r-- | core/arch/arm32/kernel/tee_time_arm_cntpct.c | 23 |
2 files changed, 16 insertions, 22 deletions
diff --git a/core/arch/arm32/include/arm32.h b/core/arch/arm32/include/arm32.h index 1a37373..d6a12ac 100644 --- a/core/arch/arm32/include/arm32.h +++ b/core/arch/arm32/include/arm32.h @@ -491,6 +491,21 @@ static inline void write_nsacr(uint32_t nsacr) ); } +static inline uint64_t read_cntpct(void) +{ + uint64_t val; + + asm volatile("mrrc p15, 0, %Q0, %R0, c14" : "=r" (val)); + return val; +} + +static inline uint32_t read_cntfrq(void) +{ + uint32_t frq; + + asm volatile("mrc p15, 0, %0, c14, c0, 0" : "=r" (frq)); + return frq; +} #endif /*ASM*/ #endif /*ARM32_H*/ diff --git a/core/arch/arm32/kernel/tee_time_arm_cntpct.c b/core/arch/arm32/kernel/tee_time_arm_cntpct.c index 2cd2661..4f6aef3 100644 --- a/core/arch/arm32/kernel/tee_time_arm_cntpct.c +++ b/core/arch/arm32/kernel/tee_time_arm_cntpct.c @@ -35,6 +35,7 @@ #include <assert.h> #include <stdint.h> #include <mpa.h> +#include <arm32.h> static uint32_t do_div(uint64_t *dividend, uint32_t divisor) { @@ -45,28 +46,6 @@ static uint32_t do_div(uint64_t *dividend, uint32_t divisor) return remainder; } -static uint64_t read_cntpct(void) -{ - uint64_t val; - uint32_t low, high; - __asm__ volatile("mrrc p15, 0, %0, %1, c14\n" - : "=r"(low), "=r"(high) - : - : "memory"); - val = low | ((uint64_t)high << WORD_SIZE); - return val; -} - -static uint32_t read_cntfrq(void) -{ - uint32_t frq; - __asm__ volatile("mrc p15, 0, %0, c14, c0, 0\n" - : "=r"(frq) - : - : "memory"); - return frq; -} - static TEE_Result arm_cntpct_get_sys_time(TEE_Time *time) { uint64_t cntpct = read_cntpct(); |