mirror of
https://github.com/justinian/jsix.git
synced 2025-12-10 00:14:32 -08:00
Add rdmsr/wrmsr to io.cpp
This commit is contained in:
@@ -14,3 +14,19 @@ outb(uint16_t port, uint8_t val)
|
||||
__asm__ __volatile__ ( "outb %0, %1" :: "a"(val), "Nd"(port) );
|
||||
}
|
||||
|
||||
uint64_t
|
||||
rdmsr(uint64_t addr)
|
||||
{
|
||||
uint32_t low, high;
|
||||
__asm__ __volatile__ ("rdmsr" : "=a"(low), "=d"(high) : "c"(addr));
|
||||
return (static_cast<uint64_t>(high) << 32) | low;
|
||||
}
|
||||
|
||||
void
|
||||
wrmsr(uint64_t addr, uint64_t value)
|
||||
{
|
||||
uint32_t low = value & 0xffffffff;
|
||||
uint32_t high = value >> 32;
|
||||
__asm__ __volatile__ ("wrmsr" :: "c"(addr), "a"(low), "d"(high));
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,16 @@ uint8_t inb(uint16_t port);
|
||||
/// \arg val The byte to write
|
||||
void outb(uint16_t port, uint8_t val);
|
||||
|
||||
/// Read the value of a MSR
|
||||
/// \arg addr The MSR address
|
||||
/// \returns The current value of the MSR
|
||||
uint64_t rdmsr(uint64_t addr);
|
||||
|
||||
/// Write to a MSR
|
||||
/// \arg addr The MSR address
|
||||
/// \arg value The value to write
|
||||
void wrmsr(uint64_t addr, uint64_t value);
|
||||
|
||||
}
|
||||
|
||||
const uint16_t COM1 = 0x03f8;
|
||||
|
||||
Reference in New Issue
Block a user