add support for MSRs and basic bitwise ops
This commit is contained in:
parent
198da59763
commit
d5ea43e05a
3 changed files with 52 additions and 0 deletions
11
include/kernel/bitwise.h
Normal file
11
include/kernel/bitwise.h
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
#ifndef _BITWISE_H_
|
||||
#define _BITWISE_H_
|
||||
|
||||
#ifndef __ASM__
|
||||
|
||||
#define BIT_SET(_v, _bit) ((_v) |= (1 << (_bit)))
|
||||
#define BIT_CLEAR(_v, _bit) ((_v) &= (~(1 << (_bit))))
|
||||
#define BIT_FLIP(_v, _bit) ((_v) ^= (1 << (_bit)))
|
||||
|
||||
#endif /* __ASM__ */
|
||||
#endif /* _BITWISE_H_ */
|
||||
12
include/kernel/msr.h
Normal file
12
include/kernel/msr.h
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
#ifndef _MSR_H_
|
||||
#define _MSR_H_
|
||||
|
||||
#include <kernel/common.h>
|
||||
|
||||
#ifndef __ASM__
|
||||
|
||||
uint64_t rdmsr(uint32_t msr);
|
||||
void wrmsr(uint32_t msr, uint64_t val);
|
||||
|
||||
#endif /* __ASM__ */
|
||||
#endif /* _MSR_H_ */
|
||||
29
init/msr.S
Normal file
29
init/msr.S
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
.global rdmsr
|
||||
rdmsr:
|
||||
pushq %rbp
|
||||
movq %rsp, %rbp
|
||||
|
||||
movl %edi, %ecx
|
||||
rdmsr
|
||||
shlq $20, %rdx
|
||||
orq %rdx, %rax
|
||||
|
||||
popq %rbp
|
||||
|
||||
ret
|
||||
|
||||
.global wrmsr
|
||||
wrmsr:
|
||||
pushq %rbp
|
||||
movq %rsp, %rbp
|
||||
|
||||
movq %rsi, %rdx
|
||||
shrq $20, %rdx
|
||||
movl %esi, %eax
|
||||
movl %edi, %ecx
|
||||
wrmsr
|
||||
|
||||
popq %rbp
|
||||
|
||||
ret
|
||||
|
||||
Loading…
Reference in a new issue