mirror of
https://github.com/reactos/reactos.git
synced 2024-09-30 14:37:45 +00:00
Alex Ionescu <ionucu@videotron.ca>
- Add KeGetCurrentPrcb function and use it where appropriate. - Fix returning of values in ExGetCurrentProcessorCpuUsage and ExGetCurrentProcessorCounts. - Move ExIsProcessorFeaturePresent from ex/init.c to ex/sysinfo.c. svn path=/trunk/; revision=13965
This commit is contained in:
parent
17f773cb7d
commit
466b206539
File diff suppressed because it is too large
Load diff
|
@ -38,19 +38,6 @@ ExInit3 (VOID)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @implemented
|
|
||||||
*/
|
|
||||||
BOOLEAN STDCALL
|
|
||||||
ExIsProcessorFeaturePresent(IN ULONG ProcessorFeature)
|
|
||||||
{
|
|
||||||
if (ProcessorFeature >= PROCESSOR_FEATURE_MAX)
|
|
||||||
return(FALSE);
|
|
||||||
|
|
||||||
return(SharedUserData->ProcessorFeatures[ProcessorFeature]);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
VOID STDCALL
|
VOID STDCALL
|
||||||
ExPostSystemEvent (ULONG Unknown1,
|
ExPostSystemEvent (ULONG Unknown1,
|
||||||
ULONG Unknown2,
|
ULONG Unknown2,
|
||||||
|
|
|
@ -46,17 +46,18 @@ ExGetCurrentProcessorCpuUsage (
|
||||||
PULONG CpuUsage
|
PULONG CpuUsage
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
PKPCR Pcr;
|
PKPRCB Prcb;
|
||||||
ULONG TotalTime;
|
ULONG TotalTime;
|
||||||
ULONG PercentTime = 0;
|
|
||||||
ULONGLONG ScaledIdle;
|
ULONGLONG ScaledIdle;
|
||||||
|
|
||||||
Pcr = KeGetCurrentKPCR();
|
Prcb = KeGetCurrentPrcb();
|
||||||
|
|
||||||
ScaledIdle = Pcr->PrcbData.IdleThread->KernelTime * 100;
|
ScaledIdle = Prcb->IdleThread->KernelTime * 100;
|
||||||
TotalTime = Pcr->PrcbData.KernelTime + Pcr->PrcbData.UserTime;
|
TotalTime = Prcb->KernelTime + Prcb->UserTime;
|
||||||
if (TotalTime) PercentTime = 100 - (ScaledIdle / TotalTime);
|
if (TotalTime != 0)
|
||||||
CpuUsage = &PercentTime;
|
*CpuUsage = 100 - (ScaledIdle / TotalTime);
|
||||||
|
else
|
||||||
|
*CpuUsage = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -70,20 +71,27 @@ ExGetCurrentProcessorCounts (
|
||||||
PULONG ProcessorNumber
|
PULONG ProcessorNumber
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
PKPCR Pcr;
|
PKPRCB Prcb;
|
||||||
ULONG TotalTime;
|
|
||||||
ULONG ThreadTime;
|
|
||||||
ULONG ProcNumber;
|
|
||||||
|
|
||||||
Pcr = KeGetCurrentKPCR();
|
Prcb = KeGetCurrentPrcb();
|
||||||
|
|
||||||
TotalTime = Pcr->PrcbData.KernelTime + Pcr->PrcbData.UserTime;
|
*ThreadKernelTime = Prcb->KernelTime + Prcb->UserTime;
|
||||||
ThreadTime = Pcr->PrcbData.CurrentThread->KernelTime;
|
*TotalCpuTime = Prcb->CurrentThread->KernelTime;
|
||||||
ProcNumber = Pcr->ProcessorNumber;
|
*ProcessorNumber = KeGetCurrentKPCR()->ProcessorNumber;
|
||||||
|
}
|
||||||
|
|
||||||
ThreadKernelTime = &ThreadTime;
|
/*
|
||||||
TotalCpuTime = &TotalTime;
|
* @implemented
|
||||||
ProcessorNumber = &ProcNumber;
|
*/
|
||||||
|
BOOLEAN
|
||||||
|
STDCALL
|
||||||
|
ExIsProcessorFeaturePresent(IN ULONG ProcessorFeature)
|
||||||
|
{
|
||||||
|
/* Quick check to see if it exists at all */
|
||||||
|
if (ProcessorFeature >= PROCESSOR_FEATURE_MAX) return(FALSE);
|
||||||
|
|
||||||
|
/* Return our support for it */
|
||||||
|
return(SharedUserData->ProcessorFeatures[ProcessorFeature]);
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS STDCALL
|
NTSTATUS STDCALL
|
||||||
|
@ -363,7 +371,7 @@ QSI_DEF(SystemProcessorInformation)
|
||||||
{
|
{
|
||||||
PSYSTEM_PROCESSOR_INFORMATION Spi
|
PSYSTEM_PROCESSOR_INFORMATION Spi
|
||||||
= (PSYSTEM_PROCESSOR_INFORMATION) Buffer;
|
= (PSYSTEM_PROCESSOR_INFORMATION) Buffer;
|
||||||
PKPCR Pcr;
|
PKPRCB Prcb;
|
||||||
*ReqSize = sizeof (SYSTEM_PROCESSOR_INFORMATION);
|
*ReqSize = sizeof (SYSTEM_PROCESSOR_INFORMATION);
|
||||||
/*
|
/*
|
||||||
* Check user buffer's size
|
* Check user buffer's size
|
||||||
|
@ -372,12 +380,12 @@ QSI_DEF(SystemProcessorInformation)
|
||||||
{
|
{
|
||||||
return (STATUS_INFO_LENGTH_MISMATCH);
|
return (STATUS_INFO_LENGTH_MISMATCH);
|
||||||
}
|
}
|
||||||
Pcr = KeGetCurrentKPCR();
|
Prcb = KeGetCurrentPrcb();
|
||||||
Spi->ProcessorArchitecture = 0; /* Intel Processor */
|
Spi->ProcessorArchitecture = 0; /* Intel Processor */
|
||||||
Spi->ProcessorLevel = Pcr->PrcbData.CpuType;
|
Spi->ProcessorLevel = Prcb->CpuType;
|
||||||
Spi->ProcessorRevision = Pcr->PrcbData.CpuStep;
|
Spi->ProcessorRevision = Prcb->CpuStep;
|
||||||
Spi->Unknown = 0;
|
Spi->Unknown = 0;
|
||||||
Spi->FeatureBits = Pcr->PrcbData.FeatureBits;
|
Spi->FeatureBits = Prcb->FeatureBits;
|
||||||
|
|
||||||
DPRINT("Arch %d Level %d Rev 0x%x\n", Spi->ProcessorArchitecture,
|
DPRINT("Arch %d Level %d Rev 0x%x\n", Spi->ProcessorArchitecture,
|
||||||
Spi->ProcessorLevel, Spi->ProcessorRevision);
|
Spi->ProcessorLevel, Spi->ProcessorRevision);
|
||||||
|
@ -713,7 +721,7 @@ QSI_DEF(SystemProcessorPerformanceInformation)
|
||||||
|
|
||||||
ULONG i;
|
ULONG i;
|
||||||
LARGE_INTEGER CurrentTime;
|
LARGE_INTEGER CurrentTime;
|
||||||
PKPCR Pcr;
|
PKPRCB Prcb;
|
||||||
|
|
||||||
*ReqSize = KeNumberProcessors * sizeof (SYSTEM_PROCESSORTIME_INFO);
|
*ReqSize = KeNumberProcessors * sizeof (SYSTEM_PROCESSORTIME_INFO);
|
||||||
/*
|
/*
|
||||||
|
@ -725,19 +733,17 @@ QSI_DEF(SystemProcessorPerformanceInformation)
|
||||||
}
|
}
|
||||||
|
|
||||||
CurrentTime.QuadPart = KeQueryInterruptTime();
|
CurrentTime.QuadPart = KeQueryInterruptTime();
|
||||||
Pcr = (PKPCR)KPCR_BASE;
|
Prcb = ((PKPCR)KPCR_BASE)->Prcb;
|
||||||
for (i = 0; i < KeNumberProcessors; i++)
|
for (i = 0; i < KeNumberProcessors; i++)
|
||||||
{
|
{
|
||||||
|
Spi->TotalProcessorRunTime.QuadPart = (Prcb->IdleThread->KernelTime + Prcb->IdleThread->UserTime) * 100000LL; // IdleTime
|
||||||
Spi->TotalProcessorRunTime.QuadPart = (Pcr->PrcbData.IdleThread->KernelTime + Pcr->PrcbData.IdleThread->UserTime) * 100000LL; // IdleTime
|
Spi->TotalProcessorTime.QuadPart = Prcb->KernelTime * 100000LL; // KernelTime
|
||||||
Spi->TotalProcessorTime.QuadPart = Pcr->PrcbData.KernelTime * 100000LL; // KernelTime
|
Spi->TotalProcessorUserTime.QuadPart = Prcb->UserTime * 100000LL;
|
||||||
Spi->TotalProcessorUserTime.QuadPart = Pcr->PrcbData.UserTime * 100000LL;
|
Spi->TotalDPCTime.QuadPart = Prcb->DpcTime * 100000LL;
|
||||||
Spi->TotalDPCTime.QuadPart = Pcr->PrcbData.DpcTime * 100000LL;
|
Spi->TotalInterruptTime.QuadPart = Prcb->InterruptTime * 100000LL;
|
||||||
Spi->TotalInterruptTime.QuadPart = Pcr->PrcbData.InterruptTime * 100000LL;
|
Spi->TotalInterrupts = Prcb->InterruptCount; // Interrupt Count
|
||||||
Spi->TotalInterrupts = Pcr->PrcbData.InterruptCount; // Interrupt Count
|
|
||||||
Spi++;
|
Spi++;
|
||||||
// Pcr++;
|
Prcb = (PKPRCB)((ULONG_PTR)Prcb + PAGE_SIZE);
|
||||||
Pcr = (PKPCR)((ULONG_PTR)Pcr + PAGE_SIZE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (STATUS_SUCCESS);
|
return (STATUS_SUCCESS);
|
||||||
|
|
|
@ -217,7 +217,7 @@ typedef struct _KPCR_TIB {
|
||||||
typedef struct _KPCR {
|
typedef struct _KPCR {
|
||||||
KPCR_TIB Tib; /* 00 */
|
KPCR_TIB Tib; /* 00 */
|
||||||
struct _KPCR *Self; /* 1C */
|
struct _KPCR *Self; /* 1C */
|
||||||
struct _KPRCB *PCRCB; /* 20 */
|
struct _KPRCB *Prcb; /* 20 */
|
||||||
KIRQL Irql; /* 24 */
|
KIRQL Irql; /* 24 */
|
||||||
ULONG IRR; /* 28 */
|
ULONG IRR; /* 28 */
|
||||||
ULONG IrrActive; /* 2C */
|
ULONG IrrActive; /* 2C */
|
||||||
|
@ -269,9 +269,28 @@ static inline PKPCR KeGetCurrentKPCR(VOID)
|
||||||
return((PKPCR)value);
|
return((PKPCR)value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline PKPRCB KeGetCurrentPrcb(VOID)
|
||||||
|
{
|
||||||
|
ULONG value;
|
||||||
|
|
||||||
|
#if defined(__GNUC__)
|
||||||
|
__asm__ __volatile__ ("movl %%fs:0x20, %0\n\t"
|
||||||
|
: "=r" (value)
|
||||||
|
: /* no inputs */
|
||||||
|
);
|
||||||
|
#elif defined(_MSC_VER)
|
||||||
|
__asm mov eax, fs:0x20;
|
||||||
|
__asm mov value, eax;
|
||||||
|
#else
|
||||||
|
#error Unknown compiler for inline assembler
|
||||||
|
#endif
|
||||||
|
return((PKPRCB)value);
|
||||||
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#define KeGetCurrentKPCR(X) ((PKPCR)KPCR_BASE)
|
#define KeGetCurrentKPCR(X) ((PKPCR)KPCR_BASE)
|
||||||
|
#define KeGetCurrentPrcb() (((PKPCR)KPCR_BASE)->Prcb)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -242,22 +242,22 @@ KeUpdateRunTime(
|
||||||
IN KIRQL Irql
|
IN KIRQL Irql
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
PKPCR Pcr;
|
PKPRCB Prcb;
|
||||||
PKTHREAD CurrentThread;
|
PKTHREAD CurrentThread;
|
||||||
PKPROCESS CurrentProcess;
|
PKPROCESS CurrentProcess;
|
||||||
#if 0
|
#if 0
|
||||||
ULONG DpcLastCount;
|
ULONG DpcLastCount;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Pcr = KeGetCurrentKPCR();
|
Prcb = KeGetCurrentPrcb();
|
||||||
|
|
||||||
/* Make sure we don't go further if we're in early boot phase. */
|
/* Make sure we don't go further if we're in early boot phase. */
|
||||||
if (Pcr == NULL || Pcr->PrcbData.CurrentThread == NULL)
|
if (Prcb == NULL || Prcb->CurrentThread == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
DPRINT("KernelTime %u, UserTime %u \n", Pcr->PrcbData.KernelTime, Pcr->PrcbData.UserTime);
|
DPRINT("KernelTime %u, UserTime %u \n", Prcb->KernelTime, Prcb->UserTime);
|
||||||
|
|
||||||
CurrentThread = Pcr->PrcbData.CurrentThread;
|
CurrentThread = Prcb->CurrentThread;
|
||||||
CurrentProcess = CurrentThread->ApcState.Process;
|
CurrentProcess = CurrentThread->ApcState.Process;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -269,36 +269,36 @@ KeUpdateRunTime(
|
||||||
{
|
{
|
||||||
InterlockedIncrementUL(&CurrentThread->UserTime);
|
InterlockedIncrementUL(&CurrentThread->UserTime);
|
||||||
InterlockedIncrementUL(&CurrentProcess->UserTime);
|
InterlockedIncrementUL(&CurrentProcess->UserTime);
|
||||||
Pcr->PrcbData.UserTime++;
|
Prcb->UserTime++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (Irql > DISPATCH_LEVEL)
|
if (Irql > DISPATCH_LEVEL)
|
||||||
{
|
{
|
||||||
Pcr->PrcbData.InterruptTime++;
|
Prcb->InterruptTime++;
|
||||||
}
|
}
|
||||||
else if (Irql == DISPATCH_LEVEL)
|
else if (Irql == DISPATCH_LEVEL)
|
||||||
{
|
{
|
||||||
Pcr->PrcbData.DpcTime++;
|
Prcb->DpcTime++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
InterlockedIncrementUL(&CurrentThread->KernelTime);
|
InterlockedIncrementUL(&CurrentThread->KernelTime);
|
||||||
InterlockedIncrementUL(&CurrentProcess->KernelTime);
|
InterlockedIncrementUL(&CurrentProcess->KernelTime);
|
||||||
Pcr->PrcbData.KernelTime++;
|
Prcb->KernelTime++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
DpcLastCount = Pcr->PrcbData.DpcLastCount;
|
DpcLastCount = Prcb->DpcLastCount;
|
||||||
Pcr->PrcbData.DpcLastCount = Pcr->PrcbData.DpcCount;
|
Prcb->DpcLastCount = Prcb->DpcCount;
|
||||||
Pcr->PrcbData.DpcRequestRate = ((Pcr->PrcbData.DpcCount - DpcLastCount) +
|
Prcb->DpcRequestRate = ((Prcb->DpcCount - DpcLastCount) +
|
||||||
Pcr->PrcbData.DpcRequestRate) / 2;
|
Prcb->DpcRequestRate) / 2;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (Pcr->PrcbData.DpcData[0].DpcQueueDepth > 0 &&
|
if (Prcb->DpcData[0].DpcQueueDepth > 0 &&
|
||||||
Pcr->PrcbData.DpcRoutineActive == FALSE &&
|
Prcb->DpcRoutineActive == FALSE &&
|
||||||
Pcr->PrcbData.DpcInterruptRequested == FALSE)
|
Prcb->DpcInterruptRequested == FALSE)
|
||||||
{
|
{
|
||||||
HalRequestSoftwareInterrupt(DISPATCH_LEVEL);
|
HalRequestSoftwareInterrupt(DISPATCH_LEVEL);
|
||||||
}
|
}
|
||||||
|
@ -311,7 +311,7 @@ KeUpdateRunTime(
|
||||||
*/
|
*/
|
||||||
if ((CurrentThread->Quantum -= 3) <= 0)
|
if ((CurrentThread->Quantum -= 3) <= 0)
|
||||||
{
|
{
|
||||||
Pcr->PrcbData.QuantumEnd = TRUE;
|
Prcb->QuantumEnd = TRUE;
|
||||||
HalRequestSoftwareInterrupt(DISPATCH_LEVEL);
|
HalRequestSoftwareInterrupt(DISPATCH_LEVEL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id:$
|
/* $Id$
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -228,7 +228,7 @@ KiCheckFPU(VOID)
|
||||||
unsigned short int status;
|
unsigned short int status;
|
||||||
int cr0;
|
int cr0;
|
||||||
ULONG Flags;
|
ULONG Flags;
|
||||||
PKPCR Pcr = KeGetCurrentKPCR();
|
PKPRCB Prcb = KeGetCurrentPrcb();
|
||||||
|
|
||||||
Ke386SaveFlags(Flags);
|
Ke386SaveFlags(Flags);
|
||||||
Ke386DisableInterrupts();
|
Ke386DisableInterrupts();
|
||||||
|
@ -275,7 +275,7 @@ KiCheckFPU(VOID)
|
||||||
HardwareMathSupport = 1;
|
HardwareMathSupport = 1;
|
||||||
|
|
||||||
/* check for and enable MMX/SSE support if possible */
|
/* check for and enable MMX/SSE support if possible */
|
||||||
if ((Pcr->PrcbData.FeatureBits & X86_FEATURE_FXSR) != 0)
|
if ((Prcb->FeatureBits & X86_FEATURE_FXSR) != 0)
|
||||||
{
|
{
|
||||||
BYTE DummyArea[sizeof(FX_SAVE_AREA) + 15];
|
BYTE DummyArea[sizeof(FX_SAVE_AREA) + 15];
|
||||||
PFX_SAVE_AREA FxSaveArea;
|
PFX_SAVE_AREA FxSaveArea;
|
||||||
|
@ -300,7 +300,7 @@ KiCheckFPU(VOID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* FIXME: Check for SSE3 in Ke386CpuidFlags2! */
|
/* FIXME: Check for SSE3 in Ke386CpuidFlags2! */
|
||||||
if (Pcr->PrcbData.FeatureBits & (X86_FEATURE_SSE | X86_FEATURE_SSE2))
|
if (Prcb->FeatureBits & (X86_FEATURE_SSE | X86_FEATURE_SSE2))
|
||||||
{
|
{
|
||||||
Ke386SetCr4(Ke386GetCr4() | X86_CR4_OSXMMEXCPT);
|
Ke386SetCr4(Ke386GetCr4() | X86_CR4_OSXMMEXCPT);
|
||||||
|
|
||||||
|
@ -401,7 +401,7 @@ KiHandleFpuFault(PKTRAP_FRAME Tf, ULONG ExceptionNr)
|
||||||
|
|
||||||
CurrentThread = KeGetCurrentThread();
|
CurrentThread = KeGetCurrentThread();
|
||||||
#ifndef CONFIG_SMP
|
#ifndef CONFIG_SMP
|
||||||
NpxThread = KeGetCurrentKPCR()->PrcbData.NpxThread;
|
NpxThread = KeGetCurrentPrcb()->NpxThread;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ASSERT(CurrentThread != NULL);
|
ASSERT(CurrentThread != NULL);
|
||||||
|
@ -414,7 +414,7 @@ KiHandleFpuFault(PKTRAP_FRAME Tf, ULONG ExceptionNr)
|
||||||
/* save the FPU state into the owner's save area */
|
/* save the FPU state into the owner's save area */
|
||||||
if (NpxThread != NULL)
|
if (NpxThread != NULL)
|
||||||
{
|
{
|
||||||
KeGetCurrentKPCR()->PrcbData.NpxThread = NULL;
|
KeGetCurrentPrcb()->NpxThread = NULL;
|
||||||
FxSaveArea = (PFX_SAVE_AREA)((char *)NpxThread->InitialStack - sizeof (FX_SAVE_AREA));
|
FxSaveArea = (PFX_SAVE_AREA)((char *)NpxThread->InitialStack - sizeof (FX_SAVE_AREA));
|
||||||
/* the fnsave might raise a delayed #MF exception */
|
/* the fnsave might raise a delayed #MF exception */
|
||||||
if (FxsrSupport)
|
if (FxsrSupport)
|
||||||
|
@ -463,7 +463,7 @@ KiHandleFpuFault(PKTRAP_FRAME Tf, ULONG ExceptionNr)
|
||||||
asm volatile("finit");
|
asm volatile("finit");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
KeGetCurrentKPCR()->PrcbData.NpxThread = CurrentThread;
|
KeGetCurrentPrcb()->NpxThread = CurrentThread;
|
||||||
#ifndef CONFIG_SMP
|
#ifndef CONFIG_SMP
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -487,7 +487,7 @@ KiHandleFpuFault(PKTRAP_FRAME Tf, ULONG ExceptionNr)
|
||||||
|
|
||||||
KeRaiseIrql(DISPATCH_LEVEL, &oldIrql);
|
KeRaiseIrql(DISPATCH_LEVEL, &oldIrql);
|
||||||
|
|
||||||
NpxThread = KeGetCurrentKPCR()->PrcbData.NpxThread;
|
NpxThread = KeGetCurrentPrcb()->NpxThread;
|
||||||
CurrentThread = KeGetCurrentThread();
|
CurrentThread = KeGetCurrentThread();
|
||||||
if (NpxThread == NULL)
|
if (NpxThread == NULL)
|
||||||
{
|
{
|
||||||
|
|
|
@ -315,7 +315,7 @@ KiInterruptDispatch (ULONG vector, PKIRQ_TRAPFRAME Trapframe)
|
||||||
* the PIC.
|
* the PIC.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
KeGetCurrentKPCR()->PrcbData.InterruptCount++;
|
KeGetCurrentPrcb()->InterruptCount++;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Notify the rest of the kernel of the raised irq level. For the
|
* Notify the rest of the kernel of the raised irq level. For the
|
||||||
|
|
|
@ -146,6 +146,7 @@ KePrepareForApplicationProcessorInit(ULONG Id)
|
||||||
Pcr->ProcessorNumber = Id;
|
Pcr->ProcessorNumber = Id;
|
||||||
Pcr->Tib.Self = &Pcr->Tib;
|
Pcr->Tib.Self = &Pcr->Tib;
|
||||||
Pcr->Self = Pcr;
|
Pcr->Self = Pcr;
|
||||||
|
Pcr->Prcb = &Pcr->PrcbData;
|
||||||
Pcr->Irql = SYNCH_LEVEL;
|
Pcr->Irql = SYNCH_LEVEL;
|
||||||
|
|
||||||
Pcr->PrcbData.MHz = BootPcr->PrcbData.MHz;
|
Pcr->PrcbData.MHz = BootPcr->PrcbData.MHz;
|
||||||
|
@ -238,6 +239,7 @@ KeInit1(PCHAR CommandLine, PULONG LastKernelAddress)
|
||||||
KPCR = (PKPCR)KPCR_BASE;
|
KPCR = (PKPCR)KPCR_BASE;
|
||||||
memset(KPCR, 0, PAGE_SIZE);
|
memset(KPCR, 0, PAGE_SIZE);
|
||||||
KPCR->Self = KPCR;
|
KPCR->Self = KPCR;
|
||||||
|
KPCR->Prcb = &KPCR->PrcbData;
|
||||||
KPCR->Irql = SYNCH_LEVEL;
|
KPCR->Irql = SYNCH_LEVEL;
|
||||||
KPCR->Tib.Self = &KPCR->Tib;
|
KPCR->Tib.Self = &KPCR->Tib;
|
||||||
KPCR->GDT = KiBootGdt;
|
KPCR->GDT = KiBootGdt;
|
||||||
|
|
|
@ -32,7 +32,7 @@ KiIpiSendRequest(ULONG TargetSet, ULONG IpiRequest)
|
||||||
if (TargetSet & (1 << i))
|
if (TargetSet & (1 << i))
|
||||||
{
|
{
|
||||||
Pcr = (PKPCR)(KPCR_BASE + i * PAGE_SIZE);
|
Pcr = (PKPCR)(KPCR_BASE + i * PAGE_SIZE);
|
||||||
Ke386TestAndSetBit(IpiRequest, &Pcr->PrcbData.IpiFrozen);
|
Ke386TestAndSetBit(IpiRequest, &Pcr->Prcb->IpiFrozen);
|
||||||
HalRequestIpi(i);
|
HalRequestIpi(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,34 +50,34 @@ KiIpiServiceRoutine(IN PKTRAP_FRAME TrapFrame,
|
||||||
LARGE_INTEGER StartTime, CurrentTime, Frequency;
|
LARGE_INTEGER StartTime, CurrentTime, Frequency;
|
||||||
ULONG Count = 5;
|
ULONG Count = 5;
|
||||||
#endif
|
#endif
|
||||||
PKPCR Pcr;
|
PKPRCB Prcb;
|
||||||
|
|
||||||
ASSERT(KeGetCurrentIrql() == IPI_LEVEL);
|
ASSERT(KeGetCurrentIrql() == IPI_LEVEL);
|
||||||
|
|
||||||
DPRINT("KiIpiServiceRoutine\n");
|
DPRINT("KiIpiServiceRoutine\n");
|
||||||
|
|
||||||
Pcr = KeGetCurrentKPCR();
|
Prcb = KeGetCurrentPrcb();
|
||||||
|
|
||||||
if (Ke386TestAndClearBit(IPI_REQUEST_APC, &Pcr->PrcbData.IpiFrozen))
|
if (Ke386TestAndClearBit(IPI_REQUEST_APC, &Prcb->IpiFrozen))
|
||||||
{
|
{
|
||||||
HalRequestSoftwareInterrupt(APC_LEVEL);
|
HalRequestSoftwareInterrupt(APC_LEVEL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Ke386TestAndClearBit(IPI_REQUEST_DPC, &Pcr->PrcbData.IpiFrozen))
|
if (Ke386TestAndClearBit(IPI_REQUEST_DPC, &Prcb->IpiFrozen))
|
||||||
{
|
{
|
||||||
Pcr->PrcbData.DpcInterruptRequested = TRUE;
|
Prcb->DpcInterruptRequested = TRUE;
|
||||||
HalRequestSoftwareInterrupt(DISPATCH_LEVEL);
|
HalRequestSoftwareInterrupt(DISPATCH_LEVEL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Ke386TestAndClearBit(IPI_REQUEST_FUNCTIONCALL, &Pcr->PrcbData.IpiFrozen))
|
if (Ke386TestAndClearBit(IPI_REQUEST_FUNCTIONCALL, &Prcb->IpiFrozen))
|
||||||
{
|
{
|
||||||
InterlockedDecrementUL(&Pcr->PrcbData.SignalDone->CurrentPacket[1]);
|
InterlockedDecrementUL(&Prcb->SignalDone->CurrentPacket[1]);
|
||||||
if (InterlockedCompareExchangeUL(&Pcr->PrcbData.SignalDone->CurrentPacket[2], 0, 0))
|
if (InterlockedCompareExchangeUL(&Prcb->SignalDone->CurrentPacket[2], 0, 0))
|
||||||
{
|
{
|
||||||
#ifdef DBG
|
#ifdef DBG
|
||||||
StartTime = KeQueryPerformanceCounter(&Frequency);
|
StartTime = KeQueryPerformanceCounter(&Frequency);
|
||||||
#endif
|
#endif
|
||||||
while (0 != InterlockedCompareExchangeUL(&Pcr->PrcbData.SignalDone->CurrentPacket[1], 0, 0))
|
while (0 != InterlockedCompareExchangeUL(&Prcb->SignalDone->CurrentPacket[1], 0, 0))
|
||||||
{
|
{
|
||||||
#ifdef DBG
|
#ifdef DBG
|
||||||
CurrentTime = KeQueryPerformanceCounter(NULL);
|
CurrentTime = KeQueryPerformanceCounter(NULL);
|
||||||
|
@ -89,14 +89,14 @@ KiIpiServiceRoutine(IN PKTRAP_FRAME TrapFrame,
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
((VOID STDCALL(*)(PVOID))(Pcr->PrcbData.SignalDone->WorkerRoutine))(Pcr->PrcbData.SignalDone->CurrentPacket[0]);
|
((VOID STDCALL(*)(PVOID))(Prcb->SignalDone->WorkerRoutine))(Prcb->SignalDone->CurrentPacket[0]);
|
||||||
Ke386TestAndClearBit(KeGetCurrentProcessorNumber(), &Pcr->PrcbData.SignalDone->TargetSet);
|
Ke386TestAndClearBit(KeGetCurrentProcessorNumber(), &Prcb->SignalDone->TargetSet);
|
||||||
if (InterlockedCompareExchangeUL(&Pcr->PrcbData.SignalDone->CurrentPacket[2], 0, 0))
|
if (InterlockedCompareExchangeUL(&Prcb->SignalDone->CurrentPacket[2], 0, 0))
|
||||||
{
|
{
|
||||||
#ifdef DBG
|
#ifdef DBG
|
||||||
StartTime = KeQueryPerformanceCounter(&Frequency);
|
StartTime = KeQueryPerformanceCounter(&Frequency);
|
||||||
#endif
|
#endif
|
||||||
while (0 != InterlockedCompareExchangeUL(&Pcr->PrcbData.SignalDone->TargetSet, 0, 0))
|
while (0 != InterlockedCompareExchangeUL(&Prcb->SignalDone->TargetSet, 0, 0))
|
||||||
{
|
{
|
||||||
#ifdef DBG
|
#ifdef DBG
|
||||||
CurrentTime = KeQueryPerformanceCounter(NULL);
|
CurrentTime = KeQueryPerformanceCounter(NULL);
|
||||||
|
@ -108,7 +108,7 @@ KiIpiServiceRoutine(IN PKTRAP_FRAME TrapFrame,
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
InterlockedExchangePointer(&Pcr->PrcbData.SignalDone, NULL);
|
InterlockedExchangePointer(&Prcb->SignalDone, NULL);
|
||||||
}
|
}
|
||||||
DPRINT("KiIpiServiceRoutine done\n");
|
DPRINT("KiIpiServiceRoutine done\n");
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -119,18 +119,18 @@ STDCALL
|
||||||
KiIpiSendPacket(ULONG TargetSet, VOID STDCALL (*WorkerRoutine)(PVOID), PVOID Argument, ULONG Count, BOOLEAN Synchronize)
|
KiIpiSendPacket(ULONG TargetSet, VOID STDCALL (*WorkerRoutine)(PVOID), PVOID Argument, ULONG Count, BOOLEAN Synchronize)
|
||||||
{
|
{
|
||||||
ULONG i, Processor, CurrentProcessor;
|
ULONG i, Processor, CurrentProcessor;
|
||||||
PKPCR Pcr, CurrentPcr;
|
PKPRCB Prcb, CurrentPrcb;
|
||||||
KIRQL oldIrql;
|
KIRQL oldIrql;
|
||||||
|
|
||||||
|
|
||||||
ASSERT(KeGetCurrentIrql() == SYNCH_LEVEL);
|
ASSERT(KeGetCurrentIrql() == SYNCH_LEVEL);
|
||||||
|
|
||||||
CurrentPcr = KeGetCurrentKPCR();
|
CurrentPrcb = KeGetCurrentPrcb();
|
||||||
InterlockedExchangeUL(&CurrentPcr->PrcbData.TargetSet, TargetSet);
|
InterlockedExchangeUL(&CurrentPrcb->TargetSet, TargetSet);
|
||||||
InterlockedExchangeUL(&CurrentPcr->PrcbData.WorkerRoutine, (ULONG_PTR)WorkerRoutine);
|
InterlockedExchangeUL(&CurrentPrcb->WorkerRoutine, (ULONG_PTR)WorkerRoutine);
|
||||||
InterlockedExchangePointer(&CurrentPcr->PrcbData.CurrentPacket[0], Argument);
|
InterlockedExchangePointer(&CurrentPrcb->CurrentPacket[0], Argument);
|
||||||
InterlockedExchangeUL(&CurrentPcr->PrcbData.CurrentPacket[1], Count);
|
InterlockedExchangeUL(&CurrentPrcb->CurrentPacket[1], Count);
|
||||||
InterlockedExchangeUL(&CurrentPcr->PrcbData.CurrentPacket[2], Synchronize ? 1 : 0);
|
InterlockedExchangeUL(&CurrentPrcb->CurrentPacket[2], Synchronize ? 1 : 0);
|
||||||
|
|
||||||
CurrentProcessor = 1 << KeGetCurrentProcessorNumber();
|
CurrentProcessor = 1 << KeGetCurrentProcessorNumber();
|
||||||
|
|
||||||
|
@ -138,9 +138,9 @@ KiIpiSendPacket(ULONG TargetSet, VOID STDCALL (*WorkerRoutine)(PVOID), PVOID Arg
|
||||||
{
|
{
|
||||||
if (TargetSet & Processor)
|
if (TargetSet & Processor)
|
||||||
{
|
{
|
||||||
Pcr = (PKPCR)(KPCR_BASE + i * PAGE_SIZE);
|
Prcb = ((PKPCR)(KPCR_BASE + i * PAGE_SIZE))->Prcb;
|
||||||
while(0 != InterlockedCompareExchangeUL(&Pcr->PrcbData.SignalDone, (LONG)&CurrentPcr->PrcbData, 0));
|
while(0 != InterlockedCompareExchangeUL(&Prcb->SignalDone, (LONG)CurrentPrcb, 0));
|
||||||
Ke386TestAndSetBit(IPI_REQUEST_FUNCTIONCALL, &Pcr->PrcbData.IpiFrozen);
|
Ke386TestAndSetBit(IPI_REQUEST_FUNCTIONCALL, &Prcb->IpiFrozen);
|
||||||
if (Processor != CurrentProcessor)
|
if (Processor != CurrentProcessor)
|
||||||
{
|
{
|
||||||
HalRequestIpi(i);
|
HalRequestIpi(i);
|
||||||
|
|
|
@ -67,9 +67,9 @@ NtContinue (
|
||||||
{
|
{
|
||||||
Thread->NpxState = NPX_STATE_VALID;
|
Thread->NpxState = NPX_STATE_VALID;
|
||||||
KeRaiseIrql(DISPATCH_LEVEL, &oldIrql);
|
KeRaiseIrql(DISPATCH_LEVEL, &oldIrql);
|
||||||
if (KeGetCurrentKPCR()->PrcbData.NpxThread == Thread)
|
if (KeGetCurrentPrcb()->NpxThread == Thread)
|
||||||
{
|
{
|
||||||
KeGetCurrentKPCR()->PrcbData.NpxThread = NULL;
|
KeGetCurrentPrcb()->NpxThread = NULL;
|
||||||
Ke386SetCr0(Ke386GetCr0() | X86_CR0_TS);
|
Ke386SetCr0(Ke386GetCr0() | X86_CR0_TS);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id:$
|
/* $Id$
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -26,11 +26,11 @@ PsIdleThreadMain(PVOID Context)
|
||||||
{
|
{
|
||||||
KIRQL oldlvl;
|
KIRQL oldlvl;
|
||||||
|
|
||||||
PKPCR Pcr = KeGetCurrentKPCR();
|
PKPRCB Prcb = KeGetCurrentPrcb();
|
||||||
|
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
if (Pcr->PrcbData.DpcData[0].DpcQueueDepth > 0)
|
if (Prcb->DpcData[0].DpcQueueDepth > 0)
|
||||||
{
|
{
|
||||||
KeRaiseIrql(DISPATCH_LEVEL,&oldlvl);
|
KeRaiseIrql(DISPATCH_LEVEL,&oldlvl);
|
||||||
KiDispatchInterrupt();
|
KiDispatchInterrupt();
|
||||||
|
@ -80,7 +80,7 @@ PsInitIdleThread(VOID)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
NtClose(IdleThreadHandle);
|
NtClose(IdleThreadHandle);
|
||||||
KeGetCurrentKPCR()->PrcbData.IdleThread = &IdleThread->Tcb;
|
KeGetCurrentPrcb()->IdleThread = &IdleThread->Tcb;
|
||||||
KeSetPriorityThread(&IdleThread->Tcb, LOW_PRIORITY);
|
KeSetPriorityThread(&IdleThread->Tcb, LOW_PRIORITY);
|
||||||
KeSetAffinityThread(&IdleThread->Tcb, 1 << 0);
|
KeSetAffinityThread(&IdleThread->Tcb, 1 << 0);
|
||||||
|
|
||||||
|
|
|
@ -151,7 +151,7 @@ PsTerminateCurrentThread(NTSTATUS ExitStatus)
|
||||||
/* If the ProcessoR Control Block's NpxThread points to the current thread
|
/* If the ProcessoR Control Block's NpxThread points to the current thread
|
||||||
* unset it.
|
* unset it.
|
||||||
*/
|
*/
|
||||||
InterlockedCompareExchangePointer(&KeGetCurrentKPCR()->PrcbData.NpxThread,
|
InterlockedCompareExchangePointer(&KeGetCurrentPrcb()->NpxThread,
|
||||||
NULL, ETHREAD_TO_KTHREAD(CurrentThread));
|
NULL, ETHREAD_TO_KTHREAD(CurrentThread));
|
||||||
|
|
||||||
KeReleaseDispatcherDatabaseLock(oldIrql);
|
KeReleaseDispatcherDatabaseLock(oldIrql);
|
||||||
|
|
|
@ -1769,7 +1769,7 @@ NtQueryInformationProcess(IN HANDLE ProcessHandle,
|
||||||
|
|
||||||
KeQuerySystemTime(&SystemTime);
|
KeQuerySystemTime(&SystemTime);
|
||||||
|
|
||||||
Prcb = &KeGetCurrentKPCR()->PrcbData;
|
Prcb = KeGetCurrentPrcb();
|
||||||
|
|
||||||
NewCookie = Prcb->KeSystemCalls ^ Prcb->InterruptTime ^
|
NewCookie = Prcb->KeSystemCalls ^ Prcb->InterruptTime ^
|
||||||
SystemTime.u.LowPart ^ SystemTime.u.HighPart;
|
SystemTime.u.LowPart ^ SystemTime.u.HighPart;
|
||||||
|
|
|
@ -129,7 +129,7 @@ NtCallbackReturn (PVOID Result,
|
||||||
*/
|
*/
|
||||||
KeRaiseIrql(HIGH_LEVEL, &oldIrql);
|
KeRaiseIrql(HIGH_LEVEL, &oldIrql);
|
||||||
if ((Thread->Tcb.NpxState & NPX_STATE_VALID) &&
|
if ((Thread->Tcb.NpxState & NPX_STATE_VALID) &&
|
||||||
ETHREAD_TO_KTHREAD(Thread) != KeGetCurrentKPCR()->PrcbData.NpxThread)
|
ETHREAD_TO_KTHREAD(Thread) != KeGetCurrentPrcb()->NpxThread)
|
||||||
{
|
{
|
||||||
RtlCopyMemory((char*)InitialStack - sizeof(FX_SAVE_AREA),
|
RtlCopyMemory((char*)InitialStack - sizeof(FX_SAVE_AREA),
|
||||||
(char*)Thread->Tcb.InitialStack - sizeof(FX_SAVE_AREA),
|
(char*)Thread->Tcb.InitialStack - sizeof(FX_SAVE_AREA),
|
||||||
|
@ -317,7 +317,7 @@ NtW32Call (IN ULONG RoutineIndex,
|
||||||
SavedState.SavedCallbackStack = Thread->Tcb.CallbackStack;
|
SavedState.SavedCallbackStack = Thread->Tcb.CallbackStack;
|
||||||
SavedState.SavedExceptionStack = (PVOID)KeGetCurrentKPCR()->TSS->Esp0;
|
SavedState.SavedExceptionStack = (PVOID)KeGetCurrentKPCR()->TSS->Esp0;
|
||||||
if ((Thread->Tcb.NpxState & NPX_STATE_VALID) &&
|
if ((Thread->Tcb.NpxState & NPX_STATE_VALID) &&
|
||||||
ETHREAD_TO_KTHREAD(Thread) != KeGetCurrentKPCR()->PrcbData.NpxThread)
|
ETHREAD_TO_KTHREAD(Thread) != KeGetCurrentPrcb()->NpxThread)
|
||||||
{
|
{
|
||||||
RtlCopyMemory((char*)NewStack + StackSize - sizeof(FX_SAVE_AREA),
|
RtlCopyMemory((char*)NewStack + StackSize - sizeof(FX_SAVE_AREA),
|
||||||
(char*)SavedState.SavedInitialStack - sizeof(FX_SAVE_AREA),
|
(char*)SavedState.SavedInitialStack - sizeof(FX_SAVE_AREA),
|
||||||
|
|
Loading…
Reference in a new issue