Add with_value_of and with_value to MSR
This commit is contained in:
parent
aee4e55fdd
commit
4e62566c48
@ -13,6 +13,9 @@ struct MSR
|
||||
static void write_to(uint32_t msr_num, uint64_t value);
|
||||
static uint64_t read_from(uint32_t msr_num);
|
||||
|
||||
static void with_value_of(uint32_t msr_num, void (*callback)(uint64_t&));
|
||||
void with_value(void (*callback)(uint64_t&));
|
||||
|
||||
private:
|
||||
uint32_t m_msr_num;
|
||||
};
|
@ -28,3 +28,18 @@ uint64_t MSR::read()
|
||||
MSR::MSR(uint32_t msr_num) : m_msr_num(msr_num)
|
||||
{
|
||||
}
|
||||
|
||||
void MSR::with_value_of(uint32_t msr_num, void (*callback)(uint64_t&))
|
||||
{
|
||||
MSR msr(msr_num);
|
||||
uint64_t value = msr.read();
|
||||
callback(value);
|
||||
msr.write(value);
|
||||
}
|
||||
|
||||
void MSR::with_value(void (*callback)(uint64_t&))
|
||||
{
|
||||
uint64_t value = read();
|
||||
callback(value);
|
||||
write(value);
|
||||
}
|
Loading…
Reference in New Issue
Block a user