Extend KSD with InterruptTime
All checks were successful
Builds / ExectOS (amd64, release) (push) Successful in -59m26s
Builds / ExectOS (amd64, debug) (push) Successful in -59m24s
Builds / ExectOS (i686, release) (push) Successful in -59m28s
Builds / ExectOS (i686, debug) (push) Successful in -59m26s

This commit is contained in:
2026-04-30 13:00:59 +02:00
parent 6cbda52d6b
commit d1eed619a7
3 changed files with 52 additions and 0 deletions

View File

@@ -460,6 +460,7 @@ typedef struct _KSYSTEM_TIME
/* Kernel Shared Data (KSD) structure definition */
typedef struct _KSHARED_DATA
{
VOLATILE KSYSTEM_TIME InterruptTime;
VOLATILE KSYSTEM_TIME SystemTime;
ULONG XtMajorVersion;
ULONG XtMinorVersion;

View File

@@ -21,9 +21,11 @@ namespace KE
STATIC PKSHARED_DATA KernelSharedData;
public:
STATIC XTAPI LARGE_INTEGER GetInterruptTime(VOID);
STATIC XTAPI PKSHARED_DATA GetKernelSharedData(VOID);
STATIC XTAPI LARGE_INTEGER GetSystemTime(VOID);
STATIC XTAPI VOID InitializeKernelSharedData(VOID);
STATIC XTAPI VOID SetInterruptTime(IN LARGE_INTEGER Time);
STATIC XTAPI VOID SetSystemTime(IN LARGE_INTEGER Time);
};
}

View File

@@ -9,6 +9,35 @@
#include <xtos.hh>
/**
* Retrieves the current interrupt time using a lock-free read mechanism.
*
* @return This routine returns a LARGE_INTEGER containing the interrupt time.
*
* @since XT 1.0
*/
XTAPI
LARGE_INTEGER
KE::SharedData::GetInterruptTime(VOID)
{
LARGE_INTEGER InterruptTime;
/* Initialize to zero */
InterruptTime.QuadPart = 0;
/* Perform a lock-free read sequence */
do
{
/* Read the primary high part and low part */
InterruptTime.HighPart = KernelSharedData->SystemTime.High1Part;
InterruptTime.LowPart = KernelSharedData->SystemTime.LowPart;
}
while(InterruptTime.HighPart != KernelSharedData->SystemTime.High2Part);
/* Return the 64-bit time */
return InterruptTime;
}
/**
* Retrieves a pointer to the memory-mapped Kernel Shared Data.
*
@@ -108,6 +137,26 @@ KE::SharedData::InitializeKernelSharedData(VOID)
(sizeof(KernelSharedData->XtFullDate) / sizeof(WCHAR)) - 1);
}
/**
* Updates the global interrupt time using a strict lock-free write mechanism.
*
* @param Time
* Supplies the new interrupt time as a 64-bit LARGE_INTEGER value.
*
* @return This routine does not return any value.
*
* @since XT 1.0
*/
XTAPI
VOID
KE::SharedData::SetInterruptTime(IN LARGE_INTEGER Time)
{
/* Set the new interrupt time */
KernelSharedData->InterruptTime.High2Part = Time.HighPart;
KernelSharedData->InterruptTime.LowPart = Time.LowPart;
KernelSharedData->InterruptTime.High1Part = Time.HighPart;
}
/**
* Updates the global system time using a strict lock-free write mechanism.
*