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

@@ -573,6 +573,33 @@ AR::CpuFunc::ReadTimeStampCounter(VOID)
return ((ULONGLONG)High << 32) | Low; return ((ULONGLONG)High << 32) | Low;
} }
/**
* 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. * Orders memory accesses as seen by other processors, without fence.
* *

View File

@@ -255,7 +255,7 @@ AR::CpuFunc::LoadLocalDescriptorTable(IN USHORT Source)
XTCDECL XTCDECL
VOID VOID
AR::CpuFunc::LoadSegment(IN USHORT Segment, AR::CpuFunc::LoadSegment(IN USHORT Segment,
IN ULONG Source) IN ULONG Source)
{ {
switch(Segment) switch(Segment)
{ {
@@ -543,6 +543,33 @@ AR::CpuFunc::ReadTimeStampCounter(VOID)
return Value; 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. * Orders memory accesses as seen by other processors, without fence.
* *
@@ -650,7 +677,7 @@ AR::CpuFunc::StoreLocalDescriptorTable(OUT PVOID Destination)
XTCDECL XTCDECL
VOID VOID
AR::CpuFunc::StoreSegment(IN USHORT Segment, AR::CpuFunc::StoreSegment(IN USHORT Segment,
OUT PVOID Destination) OUT PVOID Destination)
{ {
switch(Segment) switch(Segment)
{ {

View File

@@ -40,6 +40,7 @@ namespace AR
STATIC XTCDECL ULONGLONG ReadModelSpecificRegister(IN ULONG Register); STATIC XTCDECL ULONGLONG ReadModelSpecificRegister(IN ULONG Register);
STATIC XTCDECL UINT ReadMxCsrRegister(VOID); STATIC XTCDECL UINT ReadMxCsrRegister(VOID);
STATIC XTCDECL ULONGLONG ReadTimeStampCounter(VOID); STATIC XTCDECL ULONGLONG ReadTimeStampCounter(VOID);
STATIC XTCDECL ULONGLONG ReadTimeStampCounterProcessor(OUT PULONG TscAux);
STATIC XTCDECL VOID ReadWriteBarrier(VOID); STATIC XTCDECL VOID ReadWriteBarrier(VOID);
STATIC XTCDECL VOID SetInterruptFlag(VOID); STATIC XTCDECL VOID SetInterruptFlag(VOID);
STATIC XTCDECL VOID StoreGlobalDescriptorTable(OUT PVOID Destination); STATIC XTCDECL VOID StoreGlobalDescriptorTable(OUT PVOID Destination);

View File

@@ -39,6 +39,7 @@ namespace AR
STATIC XTCDECL ULONGLONG ReadModelSpecificRegister(IN ULONG Register); STATIC XTCDECL ULONGLONG ReadModelSpecificRegister(IN ULONG Register);
STATIC XTCDECL UINT ReadMxCsrRegister(VOID); STATIC XTCDECL UINT ReadMxCsrRegister(VOID);
STATIC XTCDECL ULONGLONG ReadTimeStampCounter(VOID); STATIC XTCDECL ULONGLONG ReadTimeStampCounter(VOID);
STATIC XTCDECL ULONGLONG ReadTimeStampCounterProcessor(OUT PULONG TscAux);
STATIC XTCDECL VOID ReadWriteBarrier(VOID); STATIC XTCDECL VOID ReadWriteBarrier(VOID);
STATIC XTCDECL VOID SetInterruptFlag(VOID); STATIC XTCDECL VOID SetInterruptFlag(VOID);
STATIC XTCDECL VOID StoreGlobalDescriptorTable(OUT PVOID Destination); STATIC XTCDECL VOID StoreGlobalDescriptorTable(OUT PVOID Destination);