Implement HlInvalidateTlbEntry(), HlReadModelSpecificRegister() and HlWriteModelSpecificRegister() routines
All checks were successful
ci/woodpecker/push/build Pipeline was successful
All checks were successful
ci/woodpecker/push/build Pipeline was successful
This commit is contained in:
parent
938cd175c8
commit
f46615f92c
@ -30,6 +30,10 @@ XTCDECL
|
|||||||
VOID
|
VOID
|
||||||
HlHalt();
|
HlHalt();
|
||||||
|
|
||||||
|
XTCDECL
|
||||||
|
VOID
|
||||||
|
HlInvalidateTlbEntry(IN PVOID Address);
|
||||||
|
|
||||||
XTCDECL
|
XTCDECL
|
||||||
UCHAR
|
UCHAR
|
||||||
HlIoPortInByte(IN USHORT Port);
|
HlIoPortInByte(IN USHORT Port);
|
||||||
@ -61,6 +65,10 @@ XTCDECL
|
|||||||
ULONG_PTR
|
ULONG_PTR
|
||||||
HlReadControlRegister(IN USHORT ControlRegister);
|
HlReadControlRegister(IN USHORT ControlRegister);
|
||||||
|
|
||||||
|
XTCDECL
|
||||||
|
ULONGLONG
|
||||||
|
HlReadModelSpecificRegister(IN ULONG Register);
|
||||||
|
|
||||||
XTCDECL
|
XTCDECL
|
||||||
VOID
|
VOID
|
||||||
HlSetInterruptFlag();
|
HlSetInterruptFlag();
|
||||||
@ -70,4 +78,9 @@ VOID
|
|||||||
HlWriteControlRegister(IN USHORT ControlRegister,
|
HlWriteControlRegister(IN USHORT ControlRegister,
|
||||||
IN UINT_PTR Value);
|
IN UINT_PTR Value);
|
||||||
|
|
||||||
|
XTCDECL
|
||||||
|
VOID
|
||||||
|
HlWriteModelSpecificRegister(IN ULONG Register,
|
||||||
|
IN ULONGLONG Value);
|
||||||
|
|
||||||
#endif /* __XTDK_AMD64_HLFUNCS_H */
|
#endif /* __XTDK_AMD64_HLFUNCS_H */
|
||||||
|
@ -30,6 +30,10 @@ XTCDECL
|
|||||||
VOID
|
VOID
|
||||||
HlHalt();
|
HlHalt();
|
||||||
|
|
||||||
|
XTCDECL
|
||||||
|
VOID
|
||||||
|
HlInvalidateTlbEntry(IN PVOID Address);
|
||||||
|
|
||||||
XTCDECL
|
XTCDECL
|
||||||
UCHAR
|
UCHAR
|
||||||
HlIoPortInByte(IN USHORT Port);
|
HlIoPortInByte(IN USHORT Port);
|
||||||
@ -61,6 +65,10 @@ XTCDECL
|
|||||||
ULONG_PTR
|
ULONG_PTR
|
||||||
HlReadControlRegister(IN USHORT ControlRegister);
|
HlReadControlRegister(IN USHORT ControlRegister);
|
||||||
|
|
||||||
|
XTCDECL
|
||||||
|
ULONGLONG
|
||||||
|
HlReadModelSpecificRegister(IN ULONG Register);
|
||||||
|
|
||||||
XTCDECL
|
XTCDECL
|
||||||
VOID
|
VOID
|
||||||
HlSetInterruptFlag();
|
HlSetInterruptFlag();
|
||||||
@ -70,4 +78,9 @@ VOID
|
|||||||
HlWriteControlRegister(IN USHORT ControlRegister,
|
HlWriteControlRegister(IN USHORT ControlRegister,
|
||||||
IN UINT_PTR Value);
|
IN UINT_PTR Value);
|
||||||
|
|
||||||
|
XTCDECL
|
||||||
|
VOID
|
||||||
|
HlWriteModelSpecificRegister(IN ULONG Register,
|
||||||
|
IN ULONGLONG Value);
|
||||||
|
|
||||||
#endif /* __XTDK_I686_HLFUNCS_H */
|
#endif /* __XTDK_I686_HLFUNCS_H */
|
||||||
|
@ -75,11 +75,28 @@ HlCpuId(IN OUT PCPUID_REGISTERS Registers)
|
|||||||
XTCDECL
|
XTCDECL
|
||||||
VOID
|
VOID
|
||||||
HlHalt()
|
HlHalt()
|
||||||
{
|
|
||||||
while(TRUE)
|
|
||||||
{
|
{
|
||||||
asm volatile("hlt");
|
asm volatile("hlt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Invalidates the TLB (Translation Lookaside Buffer) for specified virtual address.
|
||||||
|
*
|
||||||
|
* @param Address
|
||||||
|
* Suuplies a virtual address whose associated TLB entry will be invalidated.
|
||||||
|
*
|
||||||
|
* @return This routine does not return any value.
|
||||||
|
*
|
||||||
|
* @since XT 1.0
|
||||||
|
*/
|
||||||
|
XTCDECL
|
||||||
|
VOID
|
||||||
|
HlInvalidateTlbEntry(IN PVOID Address)
|
||||||
|
{
|
||||||
|
asm volatile("invlpg (%0)"
|
||||||
|
:
|
||||||
|
: "b"(Address)
|
||||||
|
: "memory");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -280,6 +297,30 @@ HlReadControlRegister(IN USHORT ControlRegister)
|
|||||||
return Value;
|
return Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reads a 64-bit value from the requested Model Specific Register (MSR).
|
||||||
|
*
|
||||||
|
* @param Register
|
||||||
|
* Supplies the MSR to read.
|
||||||
|
*
|
||||||
|
* @return This routine returns the 64-bit MSR value.
|
||||||
|
*
|
||||||
|
* @since XT 1.0
|
||||||
|
*/
|
||||||
|
XTCDECL
|
||||||
|
ULONGLONG
|
||||||
|
HlReadModelSpecificRegister(IN ULONG Register)
|
||||||
|
{
|
||||||
|
ULONG Low, High;
|
||||||
|
|
||||||
|
asm volatile("rdmsr"
|
||||||
|
: "=a"(Low),
|
||||||
|
"=d"(High)
|
||||||
|
: "c"(Register));
|
||||||
|
|
||||||
|
return ((ULONGLONG)High << 32) | Low;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instructs the processor to set the interrupt flag.
|
* Instructs the processor to set the interrupt flag.
|
||||||
*
|
*
|
||||||
@ -352,3 +393,31 @@ HlWriteControlRegister(IN USHORT ControlRegister,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Writes a 64-bit value to the requested Model Specific Register (MSR).
|
||||||
|
*
|
||||||
|
* @param Register
|
||||||
|
* Supplies the MSR register to write.
|
||||||
|
*
|
||||||
|
* @param Value
|
||||||
|
* Supplies the 64-bit value to write.
|
||||||
|
*
|
||||||
|
* @return This routine does not return any value.
|
||||||
|
*
|
||||||
|
* @since XT 1.0
|
||||||
|
*/
|
||||||
|
XTCDECL
|
||||||
|
VOID
|
||||||
|
HlWriteModelSpecificRegister(IN ULONG Register,
|
||||||
|
IN ULONGLONG Value)
|
||||||
|
{
|
||||||
|
ULONG Low = Value & 0xFFFFFFFF;
|
||||||
|
ULONG High = Value >> 32;
|
||||||
|
|
||||||
|
asm volatile("wrmsr"
|
||||||
|
:
|
||||||
|
: "c"(Register),
|
||||||
|
"a"(Low),
|
||||||
|
"d"(High));
|
||||||
|
}
|
||||||
|
@ -75,11 +75,28 @@ HlCpuId(IN OUT PCPUID_REGISTERS Registers)
|
|||||||
XTCDECL
|
XTCDECL
|
||||||
VOID
|
VOID
|
||||||
HlHalt()
|
HlHalt()
|
||||||
{
|
|
||||||
while(TRUE)
|
|
||||||
{
|
{
|
||||||
asm volatile("hlt");
|
asm volatile("hlt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Invalidates the TLB (Translation Lookaside Buffer) for specified virtual address.
|
||||||
|
*
|
||||||
|
* @param Address
|
||||||
|
* Suuplies a virtual address whose associated TLB entry will be invalidated.
|
||||||
|
*
|
||||||
|
* @return This routine does not return any value.
|
||||||
|
*
|
||||||
|
* @since XT 1.0
|
||||||
|
*/
|
||||||
|
XTCDECL
|
||||||
|
VOID
|
||||||
|
HlInvalidateTlbEntry(PVOID Address)
|
||||||
|
{
|
||||||
|
asm volatile("invlpg (%0)"
|
||||||
|
:
|
||||||
|
: "b"(Address)
|
||||||
|
: "memory");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -274,6 +291,28 @@ HlReadControlRegister(IN USHORT ControlRegister)
|
|||||||
return Value;
|
return Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reads a 64-bit value from the requested Model Specific Register (MSR).
|
||||||
|
*
|
||||||
|
* @param Register
|
||||||
|
* Supplies the MSR to read.
|
||||||
|
*
|
||||||
|
* @return This routine returns the 64-bit MSR value.
|
||||||
|
*
|
||||||
|
* @since XT 1.0
|
||||||
|
*/
|
||||||
|
XTCDECL
|
||||||
|
ULONGLONG
|
||||||
|
HlReadModelSpecificRegister(IN ULONG Register)
|
||||||
|
{
|
||||||
|
ULONGLONG Value;
|
||||||
|
|
||||||
|
asm volatile("rdmsr"
|
||||||
|
: "=A" (Value)
|
||||||
|
: "c" (Register));
|
||||||
|
return Value;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instructs the processor to set the interrupt flag.
|
* Instructs the processor to set the interrupt flag.
|
||||||
*
|
*
|
||||||
@ -339,3 +378,27 @@ HlWriteControlRegister(IN USHORT ControlRegister,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Writes a 64-bit value to the requested Model Specific Register (MSR).
|
||||||
|
*
|
||||||
|
* @param Register
|
||||||
|
* Supplies the MSR register to write.
|
||||||
|
*
|
||||||
|
* @param Value
|
||||||
|
* Supplies the 64-bit value to write.
|
||||||
|
*
|
||||||
|
* @return This routine does not return any value.
|
||||||
|
*
|
||||||
|
* @since XT 1.0
|
||||||
|
*/
|
||||||
|
XTCDECL
|
||||||
|
VOID
|
||||||
|
HlWriteModelSpecificRegister(IN ULONG Register,
|
||||||
|
IN ULONGLONG Value)
|
||||||
|
{
|
||||||
|
asm volatile("wrmsr"
|
||||||
|
:
|
||||||
|
: "c" (Register),
|
||||||
|
"A" (Value));
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user