From b2456fd18a62a98e91a46ed2ee4ba0e18db3bab1 Mon Sep 17 00:00:00 2001 From: belliash Date: Thu, 16 Feb 2023 17:56:35 +0100 Subject: [PATCH] Implement kernel timer initialization routines --- sdk/xtdk/kefuncs.h | 10 +++++++ xtoskrnl/CMakeLists.txt | 1 + xtoskrnl/ke/timer.c | 60 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 71 insertions(+) create mode 100644 xtoskrnl/ke/timer.c diff --git a/sdk/xtdk/kefuncs.h b/sdk/xtdk/kefuncs.h index 4edc14f..984d141 100644 --- a/sdk/xtdk/kefuncs.h +++ b/sdk/xtdk/kefuncs.h @@ -12,9 +12,19 @@ #include #include #include +#include /* Kernel services routines forward references */ +XTAPI +VOID +KeInitializeTimer(OUT PKTIMER Timer); + +XTAPI +VOID +KeInitializeTimerEx(OUT PKTIMER Timer, + IN KTIMER_TYPE Type); + XTAPI VOID KeStartXtSystem(IN PKERNEL_INITIALIZATION_BLOCK Parameters); diff --git a/xtoskrnl/CMakeLists.txt b/xtoskrnl/CMakeLists.txt index 889feae..50d3223 100644 --- a/xtoskrnl/CMakeLists.txt +++ b/xtoskrnl/CMakeLists.txt @@ -18,6 +18,7 @@ list(APPEND XTOSKRNL_SOURCE ${XTOSKRNL_SOURCE_DIR}/hl/${ARCH}/ioport.c ${XTOSKRNL_SOURCE_DIR}/ke/globals.c ${XTOSKRNL_SOURCE_DIR}/ke/krnlinit.c + ${XTOSKRNL_SOURCE_DIR}/ke/timer.c ${XTOSKRNL_SOURCE_DIR}/ke/${ARCH}/krnlinit.c ${XTOSKRNL_SOURCE_DIR}/ke/${ARCH}/proc.c ${XTOSKRNL_SOURCE_DIR}/mm/kpools.c diff --git a/xtoskrnl/ke/timer.c b/xtoskrnl/ke/timer.c new file mode 100644 index 0000000..2ae2a96 --- /dev/null +++ b/xtoskrnl/ke/timer.c @@ -0,0 +1,60 @@ +/** + * PROJECT: ExectOS + * COPYRIGHT: See COPYING.md in the top level directory + * FILE: xtoskrnl/ke/timer.c + * DESCRIPTION: Kernel timer object support + * DEVELOPERS: Rafal Kupiec + */ + +#include + + +/** + * Initializes a kernel timer. + * + * @param Timer + * Supplies a pointer to a time object. + * + * @return This routine does not return any value. + * + * @since NT 3.5 + */ +XTAPI +VOID +KeInitializeTimer(OUT PKTIMER Timer) +{ + /* Initialize the timer */ + KeInitializeTimerEx(Timer, NotificationTimer); +} + +/** + * Initializes an extended kernel timer. + * + * @param Timer + * Supplies a pointer to a timer object. + * + * @param Type + * Supplies the type of the timer. + * + * @return This routine does not return any value. + * + * @since NT 3.5 + */ +XTAPI +VOID +KeInitializeTimerEx(OUT PKTIMER Timer, + IN KTIMER_TYPE Type) +{ + /* Initialize the header */ + Timer->Header.Type = TimerNotificationObject + Type; + Timer->Header.Inserted = 0; + Timer->Header.SignalState = 0; + + /* Initialize the timer data */ + Timer->DueTime.QuadPart = 0; + Timer->Period = 0; + + /* Initialize linked lists */ + RtlInitializeListHead(&Timer->Header.WaitListHead); + RtlInitializeListHead(&Timer->TimerListEntry); +}