[NTOSKRNL]

- Rename KTHREAD.DispatchHeader to Header
- Remove KeInitializeDispatcherHeader and initialize dispatcher headers depending on object type. Fixes all ntos:KeEvent and KeTimer kmtests.

svn path=/trunk/; revision=54048
This commit is contained in:
Rafal Harabien 2011-10-07 16:18:52 +00:00
parent b2b0280779
commit 3e65380ea6
19 changed files with 68 additions and 72 deletions

View File

@ -391,7 +391,7 @@ CONSTANT(EXCEPTION_RECORD_LENGTH),
//#define EXCEPTION_RECORD_LENGTH 0x50
HEADER("KTHREAD"),
OFFSET(KTHREAD_DEBUG_ACTIVE, KTHREAD, DispatcherHeader.DebugActive),
OFFSET(KTHREAD_DEBUG_ACTIVE, KTHREAD, Header.DebugActive),
OFFSET(KTHREAD_INITIAL_STACK, KTHREAD, InitialStack),
OFFSET(KTHREAD_STACK_LIMIT, KTHREAD, StackLimit),
OFFSET(KTHREAD_TEB, KTHREAD, Teb),

View File

@ -592,13 +592,13 @@ OFFSET(TfYear, TIME_FIELDS, Year),
OFFSET(TfMilliseconds, TIME_FIELDS, Milliseconds),
HEADER("KTHREAD"),
OFFSET(ThType, KTHREAD, DispatcherHeader.Type),
OFFSET(ThType, KTHREAD, Header.Type),
//OFFSET(ThNpxIrql, KTHREAD, NpxIrql),
OFFSET(ThSize, KTHREAD, DispatcherHeader.Size),
OFFSET(ThLock, KTHREAD, DispatcherHeader.Lock),
OFFSET(ThDebugActive, KTHREAD, DispatcherHeader.DebugActive),
OFFSET(ThSize, KTHREAD, Header.Size),
OFFSET(ThLock, KTHREAD, Header.Lock),
OFFSET(ThDebugActive, KTHREAD, Header.DebugActive),
//OFFSET(ThThreadControlFlags, KTHREAD, DispatcherHeader.ThreadControlFlags),
OFFSET(ThSignalState, KTHREAD, DispatcherHeader.SignalState),
OFFSET(ThSignalState, KTHREAD, Header.SignalState),
#if (NTDDI_VERSION >= NTDDI_LONGHORN)
OFFSET(ThCycleTime, KTHREAD, CycleTime),
OFFSET(ThHighCycleTime, KTHREAD, HighCycleTime),

View File

@ -681,7 +681,7 @@ typedef struct _KEXECUTE_OPTIONS
//
typedef struct _KTHREAD
{
DISPATCHER_HEADER DispatcherHeader;
DISPATCHER_HEADER Header;
#if (NTDDI_VERSION >= NTDDI_LONGHORN)
ULONGLONG CycleTime;
ULONG HighCycleTime;
@ -929,7 +929,7 @@ typedef struct _KTHREAD
} KTHREAD;
#define ASSERT_THREAD(object) \
ASSERT((((object)->DispatcherHeader.Type & KOBJECT_TYPE_MASK) == ThreadObject))
ASSERT((((object)->Header.Type & KOBJECT_TYPE_MASK) == ThreadObject))
//
// Kernel Process (KPROCESS)

View File

@ -288,7 +288,7 @@ KiEnterInterruptTrap(IN PKTRAP_FRAME TrapFrame)
/* Flush DR7 and check for debugging */
TrapFrame->Dr7 = 0;
if (__builtin_expect(KeGetCurrentThread()->DispatcherHeader.DebugActive & 0xFF, 0))
if (__builtin_expect(KeGetCurrentThread()->Header.DebugActive & 0xFF, 0))
{
DbgPrint("Need Hardware Breakpoint Support!\n");
while (TRUE);
@ -310,7 +310,7 @@ KiEnterTrap(IN PKTRAP_FRAME TrapFrame)
/* Flush DR7 and check for debugging */
TrapFrame->Dr7 = 0;
if (__builtin_expect(KeGetCurrentThread()->DispatcherHeader.DebugActive & 0xFF, 0))
if (__builtin_expect(KeGetCurrentThread()->Header.DebugActive & 0xFF, 0))
{
DbgPrint("Need Hardware Breakpoint Support!\n");
while (TRUE);

View File

@ -146,17 +146,6 @@ extern VOID __cdecl KiInterruptTemplate(VOID);
#define AFFINITY_MASK(Id) KiMask32Array[Id]
#define PRIORITY_MASK(Id) KiMask32Array[Id]
/* The following macro initializes a dispatcher object's header */
#define KeInitializeDispatcherHeader(Header, t, s, State) \
{ \
(Header)->Type = t; \
(Header)->Absolute = 0; \
(Header)->Size = s; \
(Header)->Inserted = 0; \
(Header)->SignalState = State; \
InitializeListHead(&((Header)->WaitListHead)); \
}
/* Tells us if the Timer or Event is a Syncronization or Notification Object */
#define TIMER_OR_EVENT_TYPE 0x7L

View File

@ -37,10 +37,11 @@ KeInitializeEvent(OUT PKEVENT Event,
IN BOOLEAN State)
{
/* Initialize the Dispatcher Header */
KeInitializeDispatcherHeader(&Event->Header,
Type,
sizeof(*Event) / sizeof(ULONG),
State);
Event->Header.Type = Type;
//Event->Header.Signalling = FALSE; // fails in kmtest
Event->Header.Size = sizeof(KEVENT) / sizeof(ULONG);
Event->Header.SignalState = State;
InitializeListHead(&(Event->Header.WaitListHead));
}
/*

View File

@ -19,10 +19,11 @@ FASTCALL
KeInitializeGate(IN PKGATE Gate)
{
/* Initialize the Dispatcher Header */
KeInitializeDispatcherHeader(&Gate->Header,
GateObject,
sizeof(KGATE) / sizeof(ULONG),
0);
Gate->Header.Type = GateObject;
Gate->Header.Signalling = FALSE;
Gate->Header.Size = sizeof(KGATE) / sizeof(ULONG);
Gate->Header.SignalState = 0;
InitializeListHead(&(Gate->Header.WaitListHead));
}
VOID

View File

@ -1431,7 +1431,7 @@ KeSaveFloatingPointState(OUT PKFLOATING_SAVE Save)
};
#endif
KeGetCurrentThread()->DispatcherHeader.NpxIrql = KeGetCurrentIrql();
KeGetCurrentThread()->Header.NpxIrql = KeGetCurrentIrql();
return STATUS_SUCCESS;
}
@ -1443,7 +1443,7 @@ NTAPI
KeRestoreFloatingPointState(IN PKFLOATING_SAVE Save)
{
PFNSAVE_FORMAT FpState = *((PVOID *) Save);
ASSERT(KeGetCurrentThread()->DispatcherHeader.NpxIrql == KeGetCurrentIrql());
ASSERT(KeGetCurrentThread()->Header.NpxIrql == KeGetCurrentIrql());
DPRINT1("%s is not really implemented\n", __FUNCTION__);
#ifdef __GNUC__

View File

@ -70,7 +70,7 @@ ULONG
FASTCALL
KiUpdateDr7(IN ULONG Dr7)
{
ULONG DebugMask = KeGetCurrentThread()->DispatcherHeader.DebugActive;
ULONG DebugMask = KeGetCurrentThread()->Header.DebugActive;
/* Check if debugging is enabled */
if (DebugMask & DR_MASK(DR7_OVERRIDE_V))
@ -97,7 +97,7 @@ KiRecordDr7(OUT PULONG Dr7Ptr,
if (!DrMask)
{
/* He didn't, use the one from the thread */
Mask = KeGetCurrentThread()->DispatcherHeader.DebugActive;
Mask = KeGetCurrentThread()->Header.DebugActive;
}
else
{
@ -153,7 +153,7 @@ KiRecordDr7(OUT PULONG Dr7Ptr,
if (Mask != NewMask)
{
/* Update it */
KeGetCurrentThread()->DispatcherHeader.DebugActive =
KeGetCurrentThread()->Header.DebugActive =
(BOOLEAN)NewMask;
}
}
@ -611,7 +611,7 @@ KeContextToTrapFrame(IN PCONTEXT Context,
if (PreviousMode != KernelMode)
{
/* Save the mask */
KeGetCurrentThread()->DispatcherHeader.DebugActive = (DrMask != 0);
KeGetCurrentThread()->Header.DebugActive = (DrMask != 0);
}
}

View File

@ -163,7 +163,7 @@ KiInitializeContextThread(IN PKTHREAD Thread,
/* Set the Thread's NPX State */
Thread->NpxState = NPX_STATE_NOT_LOADED;
Thread->DispatcherHeader.NpxIrql = PASSIVE_LEVEL;
Thread->Header.NpxIrql = PASSIVE_LEVEL;
}
else
{

View File

@ -1523,7 +1523,7 @@ KiSystemCall(IN PKTRAP_FRAME TrapFrame,
/* Clear DR7 and check for debugging */
TrapFrame->Dr7 = 0;
if (__builtin_expect(Thread->DispatcherHeader.DebugActive & 0xFF, 0))
if (__builtin_expect(Thread->Header.DebugActive & 0xFF, 0))
{
UNIMPLEMENTED;
while (TRUE);

View File

@ -49,10 +49,11 @@ KeInitializeMutant(IN PKMUTANT Mutant,
}
/* Now we set up the Dispatcher Header */
KeInitializeDispatcherHeader(&Mutant->Header,
MutantObject,
sizeof(KMUTANT) / sizeof(ULONG),
InitialOwner ? FALSE : TRUE);
Mutant->Header.Type = MutantObject;
Mutant->Header.Size = sizeof(KMUTANT) / sizeof(ULONG);
Mutant->Header.DpcActive = FALSE;
Mutant->Header.SignalState = InitialOwner ? 0 : 1;
InitializeListHead(&(Mutant->Header.WaitListHead));
/* Initialize the default data */
Mutant->Abandoned = FALSE;
@ -68,10 +69,11 @@ KeInitializeMutex(IN PKMUTEX Mutex,
IN ULONG Level)
{
/* Set up the Dispatcher Header */
KeInitializeDispatcherHeader(&Mutex->Header,
MutantObject,
sizeof(KMUTEX) / sizeof(ULONG),
TRUE);
Mutex->Header.Type = MutantObject;
Mutex->Header.Size = sizeof(KMUTEX) / sizeof(ULONG);
Mutex->Header.DpcActive = FALSE;
Mutex->Header.SignalState = 1;
InitializeListHead(&(Mutex->Header.WaitListHead));
/* Initialize the default data */
Mutex->OwnerThread = NULL;

View File

@ -125,10 +125,10 @@ KeInitializeProcess(IN OUT PKPROCESS Process,
#endif
/* Initialize the Dispatcher Header */
KeInitializeDispatcherHeader(&Process->Header,
ProcessObject,
sizeof(KPROCESS),
FALSE);
Process->Header.Type = ProcessObject;
Process->Header.Size = sizeof(KPROCESS) / sizeof(ULONG);
Process->Header.SignalState = 0;
InitializeListHead(&(Process->Header.WaitListHead));
/* Initialize Scheduler Data, Alignment Faults and Set the PDE */
Process->Affinity = Affinity;

View File

@ -149,10 +149,11 @@ KeInitializeQueue(IN PKQUEUE Queue,
IN ULONG Count OPTIONAL)
{
/* Initialize the Header */
KeInitializeDispatcherHeader(&Queue->Header,
QueueObject,
sizeof(KQUEUE) / sizeof(ULONG),
0);
Queue->Header.Type = QueueObject;
Queue->Header.Abandoned = 0;
Queue->Header.Size = sizeof(KQUEUE) / sizeof(ULONG);
Queue->Header.SignalState = 0;
InitializeListHead(&(Queue->Header.WaitListHead));
/* Initialize the Lists */
InitializeListHead(&Queue->EntryListHead);

View File

@ -24,10 +24,10 @@ KeInitializeSemaphore(IN PKSEMAPHORE Semaphore,
IN LONG Limit)
{
/* Simply Initialize the Header */
KeInitializeDispatcherHeader(&Semaphore->Header,
SemaphoreObject,
sizeof(KSEMAPHORE) / sizeof(ULONG),
Count);
Semaphore->Header.Type = SemaphoreObject;
Semaphore->Header.Size = sizeof(KSEMAPHORE) / sizeof(ULONG);
Semaphore->Header.SignalState = 0;
InitializeListHead(&(Semaphore->Header.WaitListHead));
/* Set the Limit */
Semaphore->Limit = Limit;

View File

@ -46,7 +46,6 @@ KeFindNextRightSetAffinity(IN UCHAR Number,
return (UCHAR)Result;
}
BOOLEAN
NTAPI
KeReadStateThread(IN PKTHREAD Thread)
@ -54,7 +53,7 @@ KeReadStateThread(IN PKTHREAD Thread)
ASSERT_THREAD(Thread);
/* Return signal state */
return (BOOLEAN)Thread->DispatcherHeader.SignalState;
return (BOOLEAN)Thread->Header.SignalState;
}
KPRIORITY
@ -726,10 +725,11 @@ KeInitThread(IN OUT PKTHREAD Thread,
NTSTATUS Status;
/* Initalize the Dispatcher Header */
KeInitializeDispatcherHeader(&Thread->DispatcherHeader,
ThreadObject,
sizeof(KTHREAD) / sizeof(LONG),
FALSE);
Thread->Header.Type = ThreadObject;
Thread->Header.ThreadControlFlags = 0;
Thread->Header.DebugActive = FALSE;
Thread->Header.SignalState = 0;
InitializeListHead(&(Thread->Header.WaitListHead));
/* Initialize the Mutant List */
InitializeListHead(&Thread->MutantListHead);
@ -1381,11 +1381,11 @@ KeTerminateThread(IN KPRIORITY Increment)
}
/* Signal the thread */
Thread->DispatcherHeader.SignalState = TRUE;
if (!IsListEmpty(&Thread->DispatcherHeader.WaitListHead))
Thread->Header.SignalState = TRUE;
if (!IsListEmpty(&Thread->Header.WaitListHead))
{
/* Unwait the threads */
KxUnwaitThread(&Thread->DispatcherHeader, Increment);
KxUnwaitThread(&Thread->Header, Increment);
}
/* Remove the thread from the list */

View File

@ -249,10 +249,12 @@ KeInitializeTimerEx(OUT PKTIMER Timer,
"NotificationTimer" : "SynchronizationTimer");
/* Initialize the Dispatch Header */
KeInitializeDispatcherHeader(&Timer->Header,
TimerNotificationObject + Type,
sizeof(KTIMER) / sizeof(ULONG),
FALSE);
Timer->Header.Type = TimerNotificationObject + Type;
//Timer->Header.TimerControlFlags = 0; // win does not init this field
Timer->Header.Hand = sizeof(KTIMER) / sizeof(ULONG);
Timer->Header.Inserted = 0; // win7: Timer->Header.TimerMiscFlags = 0;
Timer->Header.SignalState = 0;
InitializeListHead(&(Timer->Header.WaitListHead));
/* Initalize the Other data */
Timer->DueTime.QuadPart = 0;

View File

@ -958,7 +958,7 @@ PsLookupProcessThreadByCid(IN PCLIENT_ID Cid,
FoundThread = CidEntry->Object;
/* Make sure it's really a thread and this process' */
if ((FoundThread->Tcb.DispatcherHeader.Type == ThreadObject) &&
if ((FoundThread->Tcb.Header.Type == ThreadObject) &&
(FoundThread->Cid.UniqueProcess == Cid->UniqueProcess))
{
/* Safe Reference and return it */

View File

@ -647,7 +647,7 @@ PsLookupThreadByThreadId(IN HANDLE ThreadId,
FoundThread = CidEntry->Object;
/* Make sure it's really a process */
if (FoundThread->Tcb.DispatcherHeader.Type == ThreadObject)
if (FoundThread->Tcb.Header.Type == ThreadObject)
{
/* Safe Reference and return it */
if (ObReferenceObjectSafe(FoundThread))