From e81fb68357f8e7bae5dcb480c4fc2069822952f3 Mon Sep 17 00:00:00 2001 From: belliash Date: Thu, 2 Mar 2023 16:25:41 +0100 Subject: [PATCH] Initial support processor idle functionality --- xtoskrnl/CMakeLists.txt | 1 + xtoskrnl/includes/globals.h | 1 - xtoskrnl/includes/popfuncs.h | 23 +++++++++++++++++ xtoskrnl/includes/xtos.h | 2 ++ xtoskrnl/po/idle.c | 50 ++++++++++++++++++++++++++++++++++++ 5 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 xtoskrnl/includes/popfuncs.h create mode 100644 xtoskrnl/po/idle.c diff --git a/xtoskrnl/CMakeLists.txt b/xtoskrnl/CMakeLists.txt index 63d35ee..d5be385 100644 --- a/xtoskrnl/CMakeLists.txt +++ b/xtoskrnl/CMakeLists.txt @@ -29,6 +29,7 @@ list(APPEND XTOSKRNL_SOURCE ${XTOSKRNL_SOURCE_DIR}/ke/${ARCH}/proc.c ${XTOSKRNL_SOURCE_DIR}/mm/kpools.c ${XTOSKRNL_SOURCE_DIR}/mm/${ARCH}/pages.c + ${XTOSKRNL_SOURCE_DIR}/po/idle.c ${XTOSKRNL_SOURCE_DIR}/rtl/atomic.c ${XTOSKRNL_SOURCE_DIR}/rtl/byteswap.c ${XTOSKRNL_SOURCE_DIR}/rtl/memory.c diff --git a/xtoskrnl/includes/globals.h b/xtoskrnl/includes/globals.h index 6fb1d39..d84d7bd 100644 --- a/xtoskrnl/includes/globals.h +++ b/xtoskrnl/includes/globals.h @@ -10,7 +10,6 @@ #define __XTOSKRNL_GLOBALS_H #include -#include ARCH_HEADER(globals.h) /* FrameBuffer information */ diff --git a/xtoskrnl/includes/popfuncs.h b/xtoskrnl/includes/popfuncs.h new file mode 100644 index 0000000..c86ec86 --- /dev/null +++ b/xtoskrnl/includes/popfuncs.h @@ -0,0 +1,23 @@ +/** + * PROJECT: ExectOS + * COPYRIGHT: See COPYING.md in the top level directory + * FILE: xtoskrnl/includes/popfuncs.h + * DESCRIPTION: Private routine definitions for kernel power manager + * DEVELOPERS: Rafal Kupiec + */ + +#ifndef __XTOSKRNL_POPFUNCS_H +#define __XTOSKRNL_POPFUNCS_H + +#include + + +XTAPI +VOID +PoInitializeProcessorControlBlock(IN OUT PKPROCESSOR_CONTROL_BLOCK Prcb); + +XTFASTCALL +VOID +PopIdle0Function(IN PPROCESSOR_POWER_STATE PowerState); + +#endif /* __XTOSKRNL_POPFUNCS_H */ diff --git a/xtoskrnl/includes/xtos.h b/xtoskrnl/includes/xtos.h index 9d45b5f..5ed93f3 100644 --- a/xtoskrnl/includes/xtos.h +++ b/xtoskrnl/includes/xtos.h @@ -13,6 +13,8 @@ #include "globals.h" #include "arpfuncs.h" #include "kepfuncs.h" +#include "popfuncs.h" +#include ARCH_HEADER(globals.h) #include ARCH_HEADER(arpfuncs.h) #include ARCH_HEADER(kepfuncs.h) diff --git a/xtoskrnl/po/idle.c b/xtoskrnl/po/idle.c new file mode 100644 index 0000000..4acc665 --- /dev/null +++ b/xtoskrnl/po/idle.c @@ -0,0 +1,50 @@ +/** + * PROJECT: ExectOS + * COPYRIGHT: See COPYING.md in the top level directory + * FILE: xtoskrnl/po/idle.c + * DESCRIPTION: Processor idle functionality support + * DEVELOPERS: Rafal Kupiec + */ + +#include + + +/** + * Initializes Processor Control Block's (PRCB) power state structures. + * + * @param Prcb + * Supplies a pointer to the PRCB being initialized. + * + * @return This routine does not return any value. + * + * @since XT 1.0 + */ +XTAPI +VOID +PoInitializeProcessorControlBlock(IN OUT PKPROCESSOR_CONTROL_BLOCK Prcb) +{ + RtlZeroMemory(&Prcb->PowerState, sizeof(Prcb->PowerState)); + + Prcb->PowerState.Idle0TimeLimit = 0xFFFFFFFF; + Prcb->PowerState.CurrentThrottle = 100; + Prcb->PowerState.IdleFunction = PopIdle0Function; + + KeInitializeTimerEx(&Prcb->PowerState.PerfTimer, SynchronizationTimer); +} + +/** + * Processor idle loop routine. + * + * @param PowerState + * Supplies a pointer to the structere containing current processor power state. + * + * @return This routine does not return any value. + * + * @since XT 1.0 + */ +XTFASTCALL +VOID +PopIdle0Function(IN PPROCESSOR_POWER_STATE PowerState) +{ + UNIMPLEMENTED; +}