Initial Asynchronous Procedure Call (APC) support
All checks were successful
ci/woodpecker/push/build Pipeline was successful

This commit is contained in:
Rafal Kupiec 2023-02-18 00:04:51 +01:00
parent 3ba3a57881
commit 3354075900
Signed by: belliash
GPG Key ID: 4E829243E0CFE6B4
5 changed files with 108 additions and 1 deletions

View File

@ -16,6 +16,17 @@
/* Kernel services routines forward references */
XTAPI
VOID
KeInitializeApc(IN PKAPC Apc,
IN PKTHREAD Thread,
IN KAPC_ENVIRONMENT Environment,
IN PKKERNEL_ROUTINE KernelRoutine,
IN PKRUNDOWN_ROUTINE RundownRoutine,
IN PKNORMAL_ROUTINE NormalRoutine,
IN KPROCESSOR_MODE ApcMode,
IN PVOID Context);
XTAPI
VOID
KeInitializeSemaphore(IN PKSEMAPHORE Semaphore,

View File

@ -17,7 +17,7 @@
/* Maximum number of exception parameters */
#define EXCEPTION_MAXIMUM_PARAMETERS 15
#define EXCEPTION_MAXIMUM_PARAMETERS 15
/* Exception disposition return values */
typedef enum _EXCEPTION_DISPOSITION
@ -171,11 +171,14 @@ typedef struct _KPROCESS
typedef struct _KTHREAD
{
DISPATCHER_HEADER Header;
LIST_ENTRY MutantListHead;
PVOID InitialStack;
PVOID KernelStack;
PVOID StackBase;
PVOID StackLimit;
KSPIN_LOCK ThreadLock;
KAPC_STATE ApcState;
UCHAR ApcStateIndex;
} KTHREAD, *PKTHREAD;
#endif /* __XTDK_KEFUNCS_H */

View File

@ -16,6 +16,7 @@ list(APPEND XTOSKRNL_SOURCE
${XTOSKRNL_SOURCE_DIR}/hl/efifb.c
${XTOSKRNL_SOURCE_DIR}/hl/globals.c
${XTOSKRNL_SOURCE_DIR}/hl/${ARCH}/ioport.c
${XTOSKRNL_SOURCE_DIR}/ke/apc.c
${XTOSKRNL_SOURCE_DIR}/ke/globals.c
${XTOSKRNL_SOURCE_DIR}/ke/krnlinit.c
${XTOSKRNL_SOURCE_DIR}/ke/semphore.c

91
xtoskrnl/ke/apc.c Normal file
View File

@ -0,0 +1,91 @@
/**
* PROJECT: ExectOS
* COPYRIGHT: See COPYING.md in the top level directory
* FILE: xtoskrnl/ke/apc.c
* DESCRIPTION: Kernel APC objects support
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
*/
#include <xtos.h>
/**
* Initializes an APC object.
*
* @param Apc
* Supplies a pointer to the APC object.
*
* @param Thread
* Suppliws a pointer to the thread object.
*
* @param Environment
* Specifies an environment in which the APC will run.
*
* @param KernelRoutine
* Supplies a pointer to routine called at APC_LEVEL.
*
* @param RundownRoutine
* Supplies a pointer to routine called on thread exit.
*
* @param NormalRoutine
* Supplies a pointer to routine called at IRQL 0.
*
* @param ApcMode
* Specifies processor mode, in which NormalRoutine gets called.
*
* @param Context
* Supplies a pointer to memory area containing data passed to NormalRoutine.
*
* @return This routine does not return any value.
*
* @since NT 3.5
*/
XTAPI
VOID
KeInitializeApc(IN PKAPC Apc,
IN PKTHREAD Thread,
IN KAPC_ENVIRONMENT Environment,
IN PKKERNEL_ROUTINE KernelRoutine,
IN PKRUNDOWN_ROUTINE RundownRoutine,
IN PKNORMAL_ROUTINE NormalRoutine,
IN KPROCESSOR_MODE ApcMode,
IN PVOID Context)
{
/* Set APC type and thread */
Apc->Type = ApcObject;
Apc->Thread = Thread;
/* Set routines */
Apc->KernelRoutine = KernelRoutine;
Apc->RundownRoutine = RundownRoutine;
Apc->NormalRoutine = NormalRoutine;
/* Check target environment */
if(Environment == CurrentApcEnvironment)
{
/* Use current APC environment taken from thread */
Apc->ApcStateIndex = Thread->ApcStateIndex;
}
else
{
/* Use new APC environment */
Apc->ApcStateIndex = Environment;
}
/* Check if normal routine specified */
if(NormalRoutine)
{
/* Set context and mode for notmal APC */
Apc->ApcMode = ApcMode;
Apc->NormalContext = Context;
}
else
{
/* Set context and mode for special APC */
Apc->ApcMode = KernelMode;
Apc->NormalContext = NULL;
}
/* Mark APC as not inserted yet */
Apc->Inserted = FALSE;
}

View File

@ -4,6 +4,7 @@
@ cdecl HlIoPortOutByte(ptr long)
@ cdecl HlIoPortOutLong(ptr long)
@ cdecl HlIoPortOutShort(ptr long)
@ stdcall KeInitializeApc(ptr ptr long ptr ptr ptr long ptr)
@ stdcall KeInitializeSemaphore(ptr long long)
@ stdcall KeInitializeSpinLock(ptr)
@ stdcall KeInitializeTimer(ptr)