@@ -9,13 +9,43 @@ void handle_exception(int trap, void (*func)(struct pt_regs *, void *), void *);
void do_handle_exception(struct pt_regs *regs);
#endif /* __ASSEMBLY__ */
-static inline uint64_t get_tb(void)
+#define SPR_TB 0x10c
+#define SPR_SPRG0 0x110
+#define SPR_SPRG1 0x111
+#define SPR_SPRG2 0x112
+#define SPR_SPRG3 0x113
+
+static inline uint64_t mfspr(int nr)
{
- uint64_t tb;
+ uint64_t ret;
+
+ asm volatile("mfspr %0,%1" : "=r"(ret) : "i"(nr) : "memory");
+
+ return ret;
+}
- asm volatile ("mfspr %[tb],268" : [tb] "=r" (tb));
+static inline void mtspr(int nr, uint64_t val)
+{
+ asm volatile("mtspr %0,%1" : : "i"(nr), "r"(val) : "memory");
+}
+
+static inline uint64_t mfmsr(void)
+{
+ uint64_t msr;
- return tb;
+ asm volatile ("mfmsr %[msr]" : [msr] "=r" (msr) :: "memory");
+
+ return msr;
+}
+
+static inline void mtmsr(uint64_t msr)
+{
+ asm volatile ("mtmsrd %[msr]" :: [msr] "r" (msr) : "memory");
+}
+
+static inline uint64_t get_tb(void)
+{
+ return mfspr(SPR_TB);
}
extern void delay(uint64_t cycles);
@@ -9,20 +9,13 @@
#include <util.h>
#include <alloc.h>
#include <asm/hcall.h>
+#include <asm/processor.h>
#define PAGE_SIZE 4096
#define H_ZERO_PAGE (1UL << (63-48))
#define H_COPY_PAGE (1UL << (63-49))
-#define mfspr(nr) ({ \
- uint64_t ret; \
- asm volatile("mfspr %0,%1" : "=r"(ret) : "i"(nr)); \
- ret; \
-})
-
-#define SPR_SPRG0 0x110
-
/**
* Test the H_SET_SPRG0 h-call by setting some values and checking whether
* the SPRG0 register contains the correct values afterwards
@@ -28,15 +28,6 @@
#include <asm/processor.h>
#include <asm/barrier.h>
-#define mfspr(nr) ({ \
- uint64_t ret; \
- asm volatile("mfspr %0,%1" : "=r"(ret) : "i"(nr)); \
- ret; \
-})
-
-#define mtspr(nr, val) \
- asm volatile("mtspr %0,%1" : : "i"(nr), "r"(val))
-
uint64_t before[1024], after[1024];
/* Common SPRs for all PowerPC CPUs */
Move some common helpers and defines to processor.h. Signed-off-by: Nicholas Piggin <npiggin@gmail.com> --- lib/powerpc/asm/processor.h | 38 +++++++++++++++++++++++++++++++++---- powerpc/spapr_hcall.c | 9 +-------- powerpc/sprs.c | 9 --------- 3 files changed, 35 insertions(+), 21 deletions(-)