Add wrapper for RDTSCP instruction
All checks were successful
Builds / ExectOS (amd64, release) (push) Successful in 35s
Builds / ExectOS (amd64, debug) (push) Successful in 37s
Builds / ExectOS (i686, release) (push) Successful in 34s
Builds / ExectOS (i686, debug) (push) Successful in 36s

This commit is contained in:
2026-04-22 22:58:17 +02:00
parent 76ee56c762
commit 98f2f449f9
4 changed files with 58 additions and 2 deletions

View File

@@ -255,7 +255,7 @@ AR::CpuFunc::LoadLocalDescriptorTable(IN USHORT Source)
XTCDECL
VOID
AR::CpuFunc::LoadSegment(IN USHORT Segment,
IN ULONG Source)
IN ULONG Source)
{
switch(Segment)
{
@@ -543,6 +543,33 @@ AR::CpuFunc::ReadTimeStampCounter(VOID)
return Value;
}
/**
* Reads the current value of the CPU's time-stamp counter and processor ID.
*
* @param TscAux
* Supplies a pointer to a variable that receives the auxiliary TSC information (IA32_TSC_AUX).
*
* @return This routine returns the current instruction cycle count since the processor was last reset.
*
* @since XT 1.0
*/
XTCDECL
ULONGLONG
AR::CpuFunc::ReadTimeStampCounterProcessor(OUT PULONG TscAux)
{
ULONG Low, High;
/* Execute the RDTSCP instruction */
__asm__ volatile("rdtscp"
: "=a" (Low),
"=d" (High),
"=c" (*TscAux)
);
/* Combine the two 32-bit registers into a single 64-bit unsigned integer and return the value */
return ((ULONGLONG)High << 32) | Low;
}
/**
* Orders memory accesses as seen by other processors, without fence.
*
@@ -650,7 +677,7 @@ AR::CpuFunc::StoreLocalDescriptorTable(OUT PVOID Destination)
XTCDECL
VOID
AR::CpuFunc::StoreSegment(IN USHORT Segment,
OUT PVOID Destination)
OUT PVOID Destination)
{
switch(Segment)
{