mirror of
https://github.com/reactos/reactos.git
synced 2025-08-03 18:35:41 +00:00
Alex Ionescu <ionucu@videotron.ca>
- Removed ke/alert.c and moved its functions where they belong. - Commented and organized KeInitializeThread. - Began switch to true KOBJECT enumeration used in NT. - Implemented KeAlertResumeThread and NtAlertResumeThread. - Harmonized Formatting in ke/kthread.c svn path=/trunk/; revision=13974
This commit is contained in:
parent
a8f6850b9f
commit
b2a42182ef
10 changed files with 643 additions and 499 deletions
|
@ -58,7 +58,7 @@ static ULONG gNumberOfControllers = 0;
|
||||||
|
|
||||||
/* Queue thread management */
|
/* Queue thread management */
|
||||||
static KEVENT QueueThreadTerminate;
|
static KEVENT QueueThreadTerminate;
|
||||||
static PVOID ThreadObject;
|
static PVOID QueueThreadObject;
|
||||||
|
|
||||||
|
|
||||||
static VOID NTAPI MotorStopDpcFunc(PKDPC UnusedDpc,
|
static VOID NTAPI MotorStopDpcFunc(PKDPC UnusedDpc,
|
||||||
|
@ -378,8 +378,8 @@ static VOID NTAPI Unload(PDRIVER_OBJECT DriverObject)
|
||||||
KdPrint(("floppy: unloading\n"));
|
KdPrint(("floppy: unloading\n"));
|
||||||
|
|
||||||
KeSetEvent(&QueueThreadTerminate, 0, FALSE);
|
KeSetEvent(&QueueThreadTerminate, 0, FALSE);
|
||||||
KeWaitForSingleObject(ThreadObject, Executive, KernelMode, FALSE, 0);
|
KeWaitForSingleObject(QueueThreadObject, Executive, KernelMode, FALSE, 0);
|
||||||
ObDereferenceObject(ThreadObject);
|
ObDereferenceObject(QueueThreadObject);
|
||||||
|
|
||||||
for(i = 0; i < gNumberOfControllers; i++)
|
for(i = 0; i < gNumberOfControllers; i++)
|
||||||
{
|
{
|
||||||
|
@ -1152,7 +1152,7 @@ NTSTATUS NTAPI DriverEntry(PDRIVER_OBJECT DriverObject,
|
||||||
return STATUS_INSUFFICIENT_RESOURCES;
|
return STATUS_INSUFFICIENT_RESOURCES;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ObReferenceObjectByHandle(ThreadHandle, STANDARD_RIGHTS_ALL, NULL, KernelMode, &ThreadObject, NULL) != STATUS_SUCCESS)
|
if(ObReferenceObjectByHandle(ThreadHandle, STANDARD_RIGHTS_ALL, NULL, KernelMode, &QueueThreadObject, NULL) != STATUS_SUCCESS)
|
||||||
{
|
{
|
||||||
KdPrint(("floppy: Unable to reference returned thread handle; failing init\n"));
|
KdPrint(("floppy: Unable to reference returned thread handle; failing init\n"));
|
||||||
return STATUS_UNSUCCESSFUL;
|
return STATUS_UNSUCCESSFUL;
|
||||||
|
|
|
@ -36,23 +36,34 @@ typedef VOID STDCALL_FUNC
|
||||||
|
|
||||||
struct _DISPATCHER_HEADER;
|
struct _DISPATCHER_HEADER;
|
||||||
|
|
||||||
typedef enum _KERNEL_OBJECTS {
|
typedef enum _KOBJECTS {
|
||||||
KNotificationEvent = 0,
|
EventNotificationObject = 0,
|
||||||
KSynchronizationEvent = 1,
|
EventSynchronizationObject = 1,
|
||||||
KMutant = 2,
|
MutantObject = 2,
|
||||||
KProcess = 3,
|
ProcessObject = 3,
|
||||||
KQueue = 4,
|
QueueObject = 4,
|
||||||
KSemaphore = 5,
|
SemaphoreObject = 5,
|
||||||
KThread = 6,
|
ThreadObject = 6,
|
||||||
KNotificationTimer = 8,
|
GateObject = 7,
|
||||||
KSynchronizationTimer = 9,
|
TimerNotificationObject = 8,
|
||||||
KApc = 18,
|
TimerSynchronizationObject = 9,
|
||||||
KDpc = 19,
|
Spare2Object = 10,
|
||||||
KDeviceQueue = 20,
|
Spare3Object = 11,
|
||||||
KEventPair = 21,
|
Spare4Object = 12,
|
||||||
KInterrupt = 22,
|
Spare5Object = 13,
|
||||||
KProfile = 23
|
Spare6Object = 14,
|
||||||
} KERNEL_OBJECTS;
|
Spare7Object = 15,
|
||||||
|
Spare8Object = 16,
|
||||||
|
Spare9Object = 17,
|
||||||
|
ApcObject = 18,
|
||||||
|
DpcObject = 19,
|
||||||
|
DeviceQueueObject = 20,
|
||||||
|
EventPairObject = 21,
|
||||||
|
InterruptObject = 22,
|
||||||
|
ProfileObject = 23,
|
||||||
|
ThreadedDpcObject = 24,
|
||||||
|
MaximumKernelObject = 25
|
||||||
|
} KOBJECTS;
|
||||||
|
|
||||||
#include <pshpack1.h>
|
#include <pshpack1.h>
|
||||||
|
|
||||||
|
|
|
@ -113,8 +113,7 @@ OBJECTS_KE = \
|
||||||
ke/sem.o \
|
ke/sem.o \
|
||||||
ke/spinlock.o \
|
ke/spinlock.o \
|
||||||
ke/timer.o \
|
ke/timer.o \
|
||||||
ke/wait.o \
|
ke/wait.o
|
||||||
ke/alert.o
|
|
||||||
|
|
||||||
# Memory Manager (Mm)
|
# Memory Manager (Mm)
|
||||||
OBJECTS_MM = \
|
OBJECTS_MM = \
|
||||||
|
|
|
@ -498,7 +498,7 @@ VOID STDCALL PsExitSpecialApc(PKAPC Apc,
|
||||||
#define PROCESS_PRIO_RT 18
|
#define PROCESS_PRIO_RT 18
|
||||||
|
|
||||||
|
|
||||||
VOID
|
VOID STDCALL
|
||||||
KeInitializeThread(PKPROCESS Process, PKTHREAD Thread, BOOLEAN First);
|
KeInitializeThread(PKPROCESS Process, PKTHREAD Thread, BOOLEAN First);
|
||||||
NTSTATUS KeReleaseThread(PKTHREAD Thread);
|
NTSTATUS KeReleaseThread(PKTHREAD Thread);
|
||||||
|
|
||||||
|
|
|
@ -1,150 +0,0 @@
|
||||||
/* $Id:$
|
|
||||||
*
|
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
|
||||||
* PROJECT: ReactOS kernel
|
|
||||||
* FILE: ntoskrnl/ke/alert.c
|
|
||||||
* PURPOSE: Alerts
|
|
||||||
*
|
|
||||||
* PROGRAMMERS: Alex Ionescu (alex@relsoft.net)
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* INCLUDES *****************************************************************/
|
|
||||||
|
|
||||||
#include <ntoskrnl.h>
|
|
||||||
#define NDEBUG
|
|
||||||
#include <internal/debug.h>
|
|
||||||
|
|
||||||
/* GLOBALS *******************************************************************/
|
|
||||||
|
|
||||||
|
|
||||||
/* FUNCTIONS *****************************************************************/
|
|
||||||
|
|
||||||
|
|
||||||
BOOLEAN
|
|
||||||
STDCALL
|
|
||||||
KeTestAlertThread(IN KPROCESSOR_MODE AlertMode)
|
|
||||||
/*
|
|
||||||
* FUNCTION: Tests whether there are any pending APCs for the current thread
|
|
||||||
* and if so the APCs will be delivered on exit from kernel mode
|
|
||||||
*/
|
|
||||||
{
|
|
||||||
KIRQL OldIrql;
|
|
||||||
PKTHREAD Thread = KeGetCurrentThread();
|
|
||||||
BOOLEAN OldState;
|
|
||||||
|
|
||||||
ASSERT_IRQL_LESS_OR_EQUAL(DISPATCH_LEVEL);
|
|
||||||
|
|
||||||
OldIrql = KeAcquireDispatcherDatabaseLock();
|
|
||||||
KiAcquireSpinLock(&Thread->ApcQueueLock);
|
|
||||||
|
|
||||||
OldState = Thread->Alerted[AlertMode];
|
|
||||||
|
|
||||||
/* If the Thread is Alerted, Clear it */
|
|
||||||
if (OldState) {
|
|
||||||
Thread->Alerted[AlertMode] = FALSE;
|
|
||||||
} else if ((AlertMode == UserMode) && (!IsListEmpty(&Thread->ApcState.ApcListHead[UserMode]))) {
|
|
||||||
/* If the mode is User and the Queue isn't empty, set Pending */
|
|
||||||
Thread->ApcState.UserApcPending = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
KiReleaseSpinLock(&Thread->ApcQueueLock);
|
|
||||||
KeReleaseDispatcherDatabaseLock(OldIrql);
|
|
||||||
return OldState;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
VOID
|
|
||||||
KeAlertThread(PKTHREAD Thread, KPROCESSOR_MODE AlertMode)
|
|
||||||
{
|
|
||||||
KIRQL oldIrql;
|
|
||||||
|
|
||||||
|
|
||||||
oldIrql = KeAcquireDispatcherDatabaseLock();
|
|
||||||
|
|
||||||
|
|
||||||
/* Return if thread is already alerted. */
|
|
||||||
if (Thread->Alerted[AlertMode] == FALSE)
|
|
||||||
{
|
|
||||||
if (Thread->State == THREAD_STATE_BLOCKED &&
|
|
||||||
(AlertMode == KernelMode || Thread->WaitMode == AlertMode) &&
|
|
||||||
Thread->Alertable)
|
|
||||||
{
|
|
||||||
KiAbortWaitThread(Thread, STATUS_ALERTED);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Thread->Alerted[AlertMode] = TRUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
KeReleaseDispatcherDatabaseLock(oldIrql);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
*
|
|
||||||
* NOT EXPORTED
|
|
||||||
*/
|
|
||||||
NTSTATUS STDCALL
|
|
||||||
NtAlertResumeThread(IN HANDLE ThreadHandle,
|
|
||||||
OUT PULONG SuspendCount)
|
|
||||||
{
|
|
||||||
UNIMPLEMENTED;
|
|
||||||
return(STATUS_NOT_IMPLEMENTED);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @implemented
|
|
||||||
*
|
|
||||||
* EXPORTED
|
|
||||||
*/
|
|
||||||
NTSTATUS STDCALL
|
|
||||||
NtAlertThread (IN HANDLE ThreadHandle)
|
|
||||||
{
|
|
||||||
KPROCESSOR_MODE PreviousMode;
|
|
||||||
PETHREAD Thread;
|
|
||||||
NTSTATUS Status;
|
|
||||||
|
|
||||||
PreviousMode = ExGetPreviousMode();
|
|
||||||
|
|
||||||
Status = ObReferenceObjectByHandle(ThreadHandle,
|
|
||||||
THREAD_SUSPEND_RESUME,
|
|
||||||
PsThreadType,
|
|
||||||
PreviousMode,
|
|
||||||
(PVOID*)&Thread,
|
|
||||||
NULL);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
return(Status);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* do an alert depending on the processor mode. If some kmode code wants to
|
|
||||||
enforce a umode alert it should call KeAlertThread() directly. If kmode
|
|
||||||
code wants to do a kmode alert it's sufficient to call it with Zw or just
|
|
||||||
use KeAlertThread() directly */
|
|
||||||
|
|
||||||
KeAlertThread(&Thread->Tcb, PreviousMode);
|
|
||||||
|
|
||||||
ObDereferenceObject(Thread);
|
|
||||||
return(STATUS_SUCCESS);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* NOT EXPORTED
|
|
||||||
*/
|
|
||||||
NTSTATUS
|
|
||||||
STDCALL
|
|
||||||
NtTestAlert(VOID)
|
|
||||||
{
|
|
||||||
KPROCESSOR_MODE PreviousMode;
|
|
||||||
|
|
||||||
PreviousMode = ExGetPreviousMode();
|
|
||||||
|
|
||||||
/* Check and Alert Thread if needed */
|
|
||||||
|
|
||||||
return KeTestAlertThread(PreviousMode) ? STATUS_ALERTED : STATUS_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
|
@ -58,7 +58,7 @@ KeInitializeApc(
|
||||||
|
|
||||||
/* Set up the basic APC Structure Data */
|
/* Set up the basic APC Structure Data */
|
||||||
RtlZeroMemory(Apc, sizeof(KAPC));
|
RtlZeroMemory(Apc, sizeof(KAPC));
|
||||||
Apc->Type = KApc;
|
Apc->Type = ApcObject;
|
||||||
Apc->Size = sizeof(KAPC);
|
Apc->Size = sizeof(KAPC);
|
||||||
|
|
||||||
/* Set the Environment */
|
/* Set the Environment */
|
||||||
|
|
|
@ -88,7 +88,7 @@ KeInitializeDpc (PKDPC Dpc,
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
DPRINT("DPC Initializing: %x with Routine: %x\n", Dpc, DeferredRoutine);
|
DPRINT("DPC Initializing: %x with Routine: %x\n", Dpc, DeferredRoutine);
|
||||||
Dpc->Type = KDpc;
|
Dpc->Type = DpcObject;
|
||||||
Dpc->Number= 0;
|
Dpc->Number= 0;
|
||||||
Dpc->Importance= MediumImportance;
|
Dpc->Importance= MediumImportance;
|
||||||
Dpc->DeferredRoutine = DeferredRoutine;
|
Dpc->DeferredRoutine = DeferredRoutine;
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -128,7 +128,7 @@ KiSideEffectsBeforeWake(DISPATCHER_HEADER * hdr,
|
||||||
case InternalProcessType:
|
case InternalProcessType:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case InternalThreadType:
|
case ThreadObject:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case InternalNotificationEvent:
|
case InternalNotificationEvent:
|
||||||
|
@ -386,7 +386,7 @@ BOOLEAN KiDispatcherObjectWake(DISPATCHER_HEADER* hdr, KPRIORITY increment)
|
||||||
case InternalProcessType:
|
case InternalProcessType:
|
||||||
return(KeDispatcherObjectWakeAll(hdr, increment));
|
return(KeDispatcherObjectWakeAll(hdr, increment));
|
||||||
|
|
||||||
case InternalThreadType:
|
case ThreadObject:
|
||||||
return(KeDispatcherObjectWakeAll(hdr, increment));
|
return(KeDispatcherObjectWakeAll(hdr, increment));
|
||||||
|
|
||||||
case InternalMutexType:
|
case InternalMutexType:
|
||||||
|
|
|
@ -1055,6 +1055,17 @@ NtYieldExecution(VOID)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* NOT EXPORTED
|
||||||
|
*/
|
||||||
|
NTSTATUS STDCALL
|
||||||
|
NtTestAlert(VOID)
|
||||||
|
{
|
||||||
|
/* Check and Alert Thread if needed */
|
||||||
|
return KeTestAlertThread(ExGetPreviousMode()) ? STATUS_ALERTED : STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @implemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue