[Skiboot] [PATCH v2 06/11] processor.h: implement sndmsg instructions
Joel Stanley
joel at jms.id.au
Fri May 4 12:10:31 AEST 2018
Clang doesn't know about msgsnd, msgclr, msgsync so grab some of the
infrastructure from the powerpc Linux kernel to define them.
Signed-off-by: Joel Stanley <joel at jms.id.au>
---
include/processor.h | 33 ++++++++++++++++++++++++++++++---
1 file changed, 30 insertions(+), 3 deletions(-)
diff --git a/include/processor.h b/include/processor.h
index 925cc7cd8ce1..69ed32df900f 100644
--- a/include/processor.h
+++ b/include/processor.h
@@ -219,6 +219,29 @@
#include <stdint.h>
#include <stdbool.h>
+#ifdef __ASSEMBLY__
+# define stringify_in_c(...) __VA_ARGS__
+# define ASM_CONST(x) x
+#else
+/* This version of stringify will deal with commas... */
+# define __stringify_in_c(...) #__VA_ARGS__
+# define stringify_in_c(...) __stringify_in_c(__VA_ARGS__) " "
+# define __ASM_CONST(x) x##UL
+# define ASM_CONST(x) __ASM_CONST(x)
+#endif
+
+#define PPC_INST_MSGSND 0x7c00019c
+#define PPC_INST_MSGCLR 0x7c0001dc
+#define PPC_INST_MSGSYNC 0x7c0006ec
+
+#define ___PPC_RB(b) (((b) & 0x1f) << 11)
+#define PPC_MSGSND(b) stringify_in_c(.long PPC_INST_MSGSND | \
+ ___PPC_RB(b))
+#define PPC_MSGSYNC stringify_in_c(.long PPC_INST_MSGSYNC)
+#define PPC_MSGCLR(b) stringify_in_c(.long PPC_INST_MSGCLR | \
+ ___PPC_RB(b))
+
+
static inline bool is_power9n(uint32_t version)
{
if (PVR_TYPE(version) != PVR_TYPE_P9)
@@ -328,20 +351,24 @@ static inline void sync_icache(void)
static inline void msgclr(void)
{
uint64_t rb = (0x05 << (63-36));
- asm volatile("msgclr %0" : : "r"(rb));
+ asm volatile(PPC_MSGCLR(%0) : : "r"(rb));
}
static inline void p9_dbell_receive(void)
{
uint64_t rb = (0x05 << (63-36));
/* msgclr ; msgsync ; lwsync */
- asm volatile("msgclr %0 ; .long 0x7c0006ec ; lwsync" : : "r"(rb));
+ asm volatile(PPC_MSGCLR(%0) : : "r"(rb));
+ asm volatile(PPC_MSGSYNC);
+ asm volatile("lwsync");
}
static inline void p9_dbell_send(uint32_t pir)
{
uint64_t rb = (0x05 << (63-36)) | pir;
- asm volatile("sync ; msgsnd %0" : : "r"(rb));
+ /* sync; msgsend %0 */
+ asm volatile("sync" : : );
+ asm volatile(PPC_MSGSND(%0) : : "r"(rb));
}
/*
--
2.17.0
More information about the Skiboot
mailing list