From a32e18b2379ff82da118bba30694627f259f497f Mon Sep 17 00:00:00 2001 From: belliash Date: Tue, 7 Feb 2023 23:19:22 +0100 Subject: [PATCH] Implement ArReadFSDualWord() routine --- sdk/xtdk/i686/arfuncs.h | 4 ++++ xtoskrnl/ar/i686/cpufunc.c | 21 +++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/sdk/xtdk/i686/arfuncs.h b/sdk/xtdk/i686/arfuncs.h index 7e9d976..603240d 100644 --- a/sdk/xtdk/i686/arfuncs.h +++ b/sdk/xtdk/i686/arfuncs.h @@ -57,6 +57,10 @@ XTCDECL ULONG_PTR ArReadControlRegister(IN USHORT ControlRegister); +XTCDECL +ULONG +ArReadFSDualWord(ULONG Offset); + XTCDECL ULONGLONG ArReadModelSpecificRegister(IN ULONG Register); diff --git a/xtoskrnl/ar/i686/cpufunc.c b/xtoskrnl/ar/i686/cpufunc.c index b2d3312..9afc616 100644 --- a/xtoskrnl/ar/i686/cpufunc.c +++ b/xtoskrnl/ar/i686/cpufunc.c @@ -270,6 +270,27 @@ ArReadControlRegister(IN USHORT ControlRegister) return Value; } +/** + * Reads dualword from a memory location specified by an offset relative to the beginning of the FS segment. + * + * @param Offset + * Specifies the offset from the beginning of FS segment. + * + * @return Returns the value read from the specified memory location relative to FS segment. + * + * @since XT 1.0 + */ +XTCDECL +ULONG +ArReadFSDualWord(ULONG Offset) +{ + ULONG Value; + asm volatile("movl %%fs:%a[Offset], %k[Value]" + : [Value] "=r" (Value) + : [Offset] "ir" (Offset)); + return Value; +} + /** * Reads a 64-bit value from the requested Model Specific Register (MSR). *