Move xrstor/xsave/xsetbv into fpu.c and reorder them.

Requested by:	bde
MFC after:	1 month
This commit is contained in:
Konstantin Belousov 2012-01-30 07:53:33 +00:00
parent a045432a58
commit 94818d19c3
2 changed files with 38 additions and 38 deletions

View File

@ -78,6 +78,41 @@ __FBSDID("$FreeBSD$");
: : "n" (CR0_TS) : "ax")
#define stop_emulating() __asm __volatile("clts")
static __inline void
xrstor(char *addr, uint64_t mask)
{
uint32_t low, hi;
low = mask;
hi = mask >> 32;
/* xrstor (%rdi) */
__asm __volatile(".byte 0x0f,0xae,0x2f" : :
"a" (low), "d" (hi), "D" (addr));
}
static __inline void
xsave(char *addr, uint64_t mask)
{
uint32_t low, hi;
low = mask;
hi = mask >> 32;
/* xsave (%rdi) */
__asm __volatile(".byte 0x0f,0xae,0x27" : :
"a" (low), "d" (hi), "D" (addr) : "memory");
}
static __inline void
xsetbv(uint32_t reg, uint64_t val)
{
uint32_t low, hi;
low = val;
hi = val >> 32;
__asm __volatile(".byte 0x0f,0x01,0xd1" : :
"c" (reg), "a" (low), "d" (hi));
}
#else /* !(__GNUCLIKE_ASM && !lint) */
void fldcw(u_short cw);
@ -90,6 +125,9 @@ void fxrstor(caddr_t addr);
void ldmxcsr(u_int csr);
void start_emulating(void);
void stop_emulating(void);
void xrstor(char *addr, uint64_t mask);
void xsave(char *addr, uint64_t mask);
void xsetbv(uint32_t reg, uint64_t val);
#endif /* __GNUCLIKE_ASM && !lint */

View File

@ -669,41 +669,6 @@ intr_restore(register_t rflags)
write_rflags(rflags);
}
static __inline void
xsave(char *addr, uint64_t mask)
{
uint32_t low, hi;
low = mask;
hi = mask >> 32;
/* xsave (%rdi) */
__asm __volatile(".byte 0x0f,0xae,0x27" : :
"a" (low), "d" (hi), "D" (addr) : "memory");
}
static __inline void
xsetbv(uint32_t reg, uint64_t val)
{
uint32_t low, hi;
low = val;
hi = val >> 32;
__asm __volatile(".byte 0x0f,0x01,0xd1" : :
"c" (reg), "a" (low), "d" (hi));
}
static __inline void
xrstor(char *addr, uint64_t mask)
{
uint32_t low, hi;
low = mask;
hi = mask >> 32;
/* xrstor (%rdi) */
__asm __volatile(".byte 0x0f,0xae,0x2f" : :
"a" (low), "d" (hi), "D" (addr));
}
#else /* !(__GNUCLIKE_ASM && __CC_SUPPORTS___INLINE) */
int breakpoint(void);
@ -768,9 +733,6 @@ u_int rgs(void);
void wbinvd(void);
void write_rflags(u_int rf);
void wrmsr(u_int msr, uint64_t newval);
void xsave(char *addr, uint64_t mask);
void xsetbv(uint32_t reg, uint64_t val);
void xrstor(char *addr, uint64_t mask);
#endif /* __GNUCLIKE_ASM && __CC_SUPPORTS___INLINE */