Add xgetbv()/xsetbv()

This commit is contained in:
Josh Holtrop 2022-11-03 22:45:35 -04:00
parent 8eedf4e267
commit 1f2a2bea48

View File

@ -73,6 +73,19 @@ void wrmsr(uint msr, ulong value)
__asm(`wrmsr`, "{ecx},{edx},{eax}", msr, value >> 32u, value); __asm(`wrmsr`, "{ecx},{edx},{eax}", msr, value >> 32u, value);
} }
ulong xgetbv(uint xcr)
{
return __asm!ulong(`
xgetbv
shl $$32, %rdx
or %rdx, %rax`, "={rax},{ecx},~{rdx}", xcr);
}
void xsetbv(uint xcr, ulong value)
{
__asm(`xsetbv`, "{ecx},{edx},{eax}", xcr, value >> 32u, value);
}
ubyte in8(ushort ioaddr) ubyte in8(ushort ioaddr)
{ {
return __asm!ubyte("inb %dx, %al", "={al},{dx}", ioaddr); return __asm!ubyte("inb %dx, %al", "={al},{dx}", ioaddr);