From 7bad67256e0bb113a5e9a09c3866c7d976c0d662 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Tue, 23 Dec 2014 08:30:40 +0100 Subject: bsps/powerpc: Add TMR access macros --- .../powerpc/shared/include/powerpc-utility.h | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/c/src/lib/libcpu/powerpc/shared/include/powerpc-utility.h b/c/src/lib/libcpu/powerpc/shared/include/powerpc-utility.h index 1cceb75512..331aa58057 100644 --- a/c/src/lib/libcpu/powerpc/shared/include/powerpc-utility.h +++ b/c/src/lib/libcpu/powerpc/shared/include/powerpc-utility.h @@ -627,6 +627,34 @@ static inline void ppc_set_decrementer_register(uint32_t dec) _ISR_Enable_without_giant(level); \ } while (0) +/** + * @brief Returns the value of the Thread Management Register with number @a tmr. + * + * @note This macro uses a GNU C extension. + */ +#define PPC_THREAD_MGMT_REGISTER(tmr) \ + ({ \ + uint32_t val; \ + __asm__ volatile (\ + "mftmr %0, " PPC_STRINGOF(tmr) \ + : "=r" (val) \ + ); \ + val;\ + } ) + +/** + * @brief Sets the Thread Management Register with number @a tmr to the value in + * @a val. + */ +#define PPC_SET_THREAD_MGMT_REGISTER(tmr, val) \ + do { \ + __asm__ volatile (\ + "mttmr " PPC_STRINGOF(tmr) ", %0" \ + : \ + : "r" (val) \ + ); \ + } while (0) + /** * @brief Returns the value of the Device Control Register with number @a dcr. * -- cgit v1.2.3