diff --git a/xtoskrnl/CMakeLists.txt b/xtoskrnl/CMakeLists.txt index 2137316..bc9d777 100644 --- a/xtoskrnl/CMakeLists.txt +++ b/xtoskrnl/CMakeLists.txt @@ -18,6 +18,7 @@ list(APPEND XTOSKRNL_SOURCE ${XTOSKRNL_SOURCE_DIR}/ke/globals.c ${XTOSKRNL_SOURCE_DIR}/ke/krnlinit.c ${XTOSKRNL_SOURCE_DIR}/ke/${ARCH}/krnlinit.c + ${XTOSKRNL_SOURCE_DIR}/ke/${ARCH}/proc.c ${XTOSKRNL_SOURCE_DIR}/rtl/byteswap.c ${XTOSKRNL_SOURCE_DIR}/rtl/memory.c ${XTOSKRNL_SOURCE_DIR}/rtl/plist.c diff --git a/xtoskrnl/includes/kepfuncs.h b/xtoskrnl/includes/kepfuncs.h index e20b2b8..99d83ba 100644 --- a/xtoskrnl/includes/kepfuncs.h +++ b/xtoskrnl/includes/kepfuncs.h @@ -12,6 +12,14 @@ #include +XTAPI +PKPROCESSOR_BLOCK +KeGetCurrentProcessorBlock(VOID); + +XTAPI +PKPROCESSOR_CONTROL_BLOCK +KeGetCurrentProcessorControlBlock(VOID); + XTAPI VOID KepArchInitialize(VOID); diff --git a/xtoskrnl/ke/amd64/proc.c b/xtoskrnl/ke/amd64/proc.c new file mode 100644 index 0000000..a3684d2 --- /dev/null +++ b/xtoskrnl/ke/amd64/proc.c @@ -0,0 +1,39 @@ +/** + * PROJECT: ExectOS + * COPYRIGHT: See COPYING.md in the top level directory + * FILE: xtoskrnl/ke/amd64/proc.c + * DESCRIPTION: AMD64 processor-related functionality for the kernel + * DEVELOPERS: Rafal Kupiec + */ + +#include + + +/** + * Gets the processor block for the currently executing processor. + * + * @return This routine returns the current processor block read from the GS register. + * + * @since XT 1.0 + */ +XTAPI +PKPROCESSOR_BLOCK +KeGetCurrentProcessorBlock(VOID) +{ + /* Get processor block from GS register */ + return (PKPROCESSOR_BLOCK)ArReadGSQuadWord(FIELD_OFFSET(KPROCESSOR_BLOCK, Self)); +} + +/** + * Gets the processor control block for the currently executing processor. + * + * @return This routine returns the current processor control block read from the GS register. + * + * @since XT 1.0 + */ +XTAPI +PKPROCESSOR_CONTROL_BLOCK +KeGetCurrentProcessorControlBlock(VOID) +{ + return (PKPROCESSOR_CONTROL_BLOCK)ArReadGSQuadWord(FIELD_OFFSET(KPROCESSOR_BLOCK, Prcb)); +} diff --git a/xtoskrnl/ke/i686/proc.c b/xtoskrnl/ke/i686/proc.c new file mode 100644 index 0000000..840afaf --- /dev/null +++ b/xtoskrnl/ke/i686/proc.c @@ -0,0 +1,39 @@ +/** + * PROJECT: ExectOS + * COPYRIGHT: See COPYING.md in the top level directory + * FILE: xtoskrnl/ke/i686/proc.c + * DESCRIPTION: I686 processor-related functionality for the kernel + * DEVELOPERS: Rafal Kupiec + */ + +#include + + +/** + * Gets the processor block for the currently executing processor. + * + * @return This routine returns the current processor block read from the FS register. + * + * @since XT 1.0 + */ +XTAPI +PKPROCESSOR_BLOCK +KeGetCurrentProcessorBlock(VOID) +{ + /* Get processor block from FS register */ + return (PKPROCESSOR_BLOCK)ArReadFSDualWord(FIELD_OFFSET(KPROCESSOR_BLOCK, Self)); +} + +/** + * Gets the processor control block for the currently executing processor. + * + * @return This routine returns the current processor control block read from the FS register. + * + * @since XT 1.0 + */ +XTAPI +PKPROCESSOR_CONTROL_BLOCK +KeGetCurrentProcessorControlBlock(VOID) +{ + return (PKPROCESSOR_CONTROL_BLOCK)ArReadFSDualWord(FIELD_OFFSET(KPROCESSOR_BLOCK, Prcb)); +}