CNDP  22.08.0
cne_isa.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright (c) 2019-2022 Intel Corporation
3  */
4 
5 #include <sys/syscall.h>
6 #include <stdint.h> // for uint64_t
7 
8 #ifndef _CNE_ISA_H_
9 #define _CNE_ISA_H_
10 
11 #include <cne_common.h> // for CNDP_API
12 
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23 
35 static __cne_always_inline void
36 cne_umonitor(volatile void *addr)
37 {
38  /* UMONITOR */
39  asm volatile(".byte 0xf3, 0x0f, 0xae, 0xf7;" : : "D"(addr));
40 }
41 
55 static __cne_always_inline void
56 cne_umwait(const uint64_t timestamp)
57 {
58  const uint32_t l = (uint32_t)timestamp;
59  const uint32_t h = (uint32_t)(timestamp >> 32);
60 
61  /* UMWAIT */
62  asm volatile(".byte 0xf2, 0x0f, 0xae, 0xf7;"
63  : /* ignore rflags */
64  : "D"(0), /* enter C0.2 */
65  "a"(l), "d"(h));
66 }
67 
80 static __cne_always_inline void
81 cne_tpause(const uint64_t timestamp)
82 {
83  const uint32_t l = (uint32_t)timestamp;
84  const uint32_t h = (uint32_t)(timestamp >> 32);
85 
86  /* TPAUSE */
87  asm volatile(".byte 0x66, 0x0f, 0xae, 0xf7;"
88  : /* ignore rflags */
89  : "D"(0), /* enter C0.2 */
90  "a"(l), "d"(h));
91 }
92 
103 static __cne_always_inline void
104 cne_movdiri(volatile void *addr, uint32_t value)
105 {
106  /* MOVDIRI */
107  asm volatile(".byte 0x40, 0x0f, 0x38, 0xf9, 0x02" : : "a"(value), "d"(addr));
108 }
109 
120 static __cne_always_inline void
121 cne_movdir64b(volatile void *dst, const void *src)
122 {
123  /* MOVDIR64B */
124  asm volatile(".byte 0x66, 0x0f, 0x38, 0xf8, 0x02" : : "a"(dst), "d"(src) : "memory");
125 }
126 
135 static __cne_always_inline void
136 cne_cldemote(const volatile void *p)
137 {
138  /* CLDEMOTE */
139  asm volatile(".byte 0x0f, 0x1c, 0x06" ::"S"(p));
140 }
141 
142 #ifdef __cplusplus
143 }
144 #endif
145 
146 #endif /* _CNE_ISA_H_ */
#define __cne_always_inline
Definition: cne_common.h:218
static __cne_always_inline void cne_umwait(const uint64_t timestamp)
Definition: cne_isa.h:56
static __cne_always_inline void cne_tpause(const uint64_t timestamp)
Definition: cne_isa.h:81
static __cne_always_inline void cne_cldemote(const volatile void *p)
Definition: cne_isa.h:136
static __cne_always_inline void cne_movdiri(volatile void *addr, uint32_t value)
Definition: cne_isa.h:104
static __cne_always_inline void cne_umonitor(volatile void *addr)
Definition: cne_isa.h:36
static __cne_always_inline void cne_movdir64b(volatile void *dst, const void *src)
Definition: cne_isa.h:121