mirror of
https://github.com/reactos/reactos.git
synced 2025-02-23 08:55:19 +00:00
[NTOS]: Implement CmSetLazyFlushState to disable lazy writing in the Cm.
[NTOS]: Implement ExSwapInWorkerThreads to in-swap any worker threads when needed. [NTOS]: Add HAL stubs for HalEndOfBoot and HalSetWakeEnable since most HALs set this to NULL. [DDK]: Add some missing definitions. svn path=/trunk/; revision=46001
This commit is contained in:
parent
95a13b7f8f
commit
a15d2634ea
7 changed files with 169 additions and 4 deletions
|
@ -898,6 +898,41 @@ typedef union _POWER_STATE {
|
|||
DEVICE_POWER_STATE DeviceState;
|
||||
} POWER_STATE, *PPOWER_STATE;
|
||||
|
||||
typedef struct _POWER_ACTION_POLICY {
|
||||
POWER_ACTION Action;
|
||||
ULONG Flags;
|
||||
ULONG EventCode;
|
||||
} POWER_ACTION_POLICY, *PPOWER_ACTION_POLICY;
|
||||
|
||||
/* POWER_ACTION_POLICY.Flags constants */
|
||||
#define POWER_ACTION_QUERY_ALLOWED 0x00000001
|
||||
#define POWER_ACTION_UI_ALLOWED 0x00000002
|
||||
#define POWER_ACTION_OVERRIDE_APPS 0x00000004
|
||||
#define POWER_ACTION_LIGHTEST_FIRST 0x10000000
|
||||
#define POWER_ACTION_LOCK_CONSOLE 0x20000000
|
||||
#define POWER_ACTION_DISABLE_WAKES 0x40000000
|
||||
#define POWER_ACTION_CRITICAL 0x80000000
|
||||
|
||||
/* POWER_ACTION_POLICY.EventCode constants */
|
||||
#define POWER_LEVEL_USER_NOTIFY_TEXT 0x00000001
|
||||
#define POWER_LEVEL_USER_NOTIFY_SOUND 0x00000002
|
||||
#define POWER_LEVEL_USER_NOTIFY_EXEC 0x00000004
|
||||
#define POWER_USER_NOTIFY_BUTTON 0x00000008
|
||||
#define POWER_USER_NOTIFY_SHUTDOWN 0x00000010
|
||||
#define POWER_FORCE_TRIGGER_RESET 0x80000000
|
||||
|
||||
#define DISCHARGE_POLICY_CRITICAL 0
|
||||
#define DISCHARGE_POLICY_LOW 1
|
||||
#define NUM_DISCHARGE_POLICIES 4
|
||||
|
||||
#define PO_THROTTLE_NONE 0
|
||||
#define PO_THROTTLE_CONSTANT 1
|
||||
#define PO_THROTTLE_DEGRADE 2
|
||||
#define PO_THROTTLE_ADAPTIVE 3
|
||||
#define PO_THROTTLE_MAXIMUM 4
|
||||
|
||||
|
||||
|
||||
typedef enum _POWER_STATE_TYPE {
|
||||
SystemPowerState,
|
||||
DevicePowerState
|
||||
|
|
|
@ -298,4 +298,12 @@ CmpShutdownWorkers(VOID)
|
|||
KeCancelTimer(&CmpLazyFlushTimer);
|
||||
}
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
CmSetLazyFlushState(IN BOOLEAN Enable)
|
||||
{
|
||||
/* Set state for lazy flusher */
|
||||
CmpHoldLazyFlush = !Enable;
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
|
|
|
@ -43,7 +43,7 @@ ULONG ExpAdditionalDelayedWorkerThreads;
|
|||
/* Future support for stack swapping worker threads */
|
||||
BOOLEAN ExpWorkersCanSwap;
|
||||
LIST_ENTRY ExpWorkerListHead;
|
||||
KMUTANT ExpWorkerSwapinMutex;
|
||||
FAST_MUTEX ExpWorkerSwapinMutex;
|
||||
|
||||
/* The worker balance set manager events */
|
||||
KEVENT ExpThreadSetManagerEvent;
|
||||
|
@ -513,7 +513,7 @@ ExpInitializeWorkerThreads(VOID)
|
|||
ULONG i;
|
||||
|
||||
/* Setup the stack swap support */
|
||||
KeInitializeMutex(&ExpWorkerSwapinMutex, FALSE);
|
||||
ExInitializeFastMutex(&ExpWorkerSwapinMutex);
|
||||
InitializeListHead(&ExpWorkerListHead);
|
||||
ExpWorkersCanSwap = TRUE;
|
||||
|
||||
|
@ -589,6 +589,89 @@ ExpInitializeWorkerThreads(VOID)
|
|||
ObCloseHandle(ThreadHandle, KernelMode);
|
||||
}
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
ExpSetSwappingKernelApc(IN PKAPC Apc,
|
||||
OUT PKNORMAL_ROUTINE *NormalRoutine,
|
||||
IN OUT PVOID *NormalContext,
|
||||
IN OUT PVOID *SystemArgument1,
|
||||
IN OUT PVOID *SystemArgument2)
|
||||
{
|
||||
PBOOLEAN AllowSwap;
|
||||
PKEVENT Event = (PKEVENT)*SystemArgument1;
|
||||
|
||||
/* Make sure it's an active worker */
|
||||
if (PsGetCurrentThread()->ActiveExWorker)
|
||||
{
|
||||
/* Read the setting from the context flag */
|
||||
AllowSwap = (PBOOLEAN)NormalContext;
|
||||
KeSetKernelStackSwapEnable(*AllowSwap);
|
||||
}
|
||||
|
||||
/* Let caller know that we're done */
|
||||
KeSetEvent(Event, 0, FALSE);
|
||||
}
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
ExSwapinWorkerThreads(IN BOOLEAN AllowSwap)
|
||||
{
|
||||
KEVENT Event;
|
||||
PETHREAD CurrentThread = PsGetCurrentThread(), Thread;
|
||||
PEPROCESS Process = PsInitialSystemProcess;
|
||||
KAPC Apc;
|
||||
PAGED_CODE();
|
||||
|
||||
/* Initialize an event so we know when we're done */
|
||||
KeInitializeEvent(&Event, NotificationEvent, FALSE);
|
||||
|
||||
/* Lock this routine */
|
||||
ExAcquireFastMutex(&ExpWorkerSwapinMutex);
|
||||
|
||||
/* New threads cannot swap anymore */
|
||||
ExpWorkersCanSwap = AllowSwap;
|
||||
|
||||
/* Loop all threads in the system process */
|
||||
Thread = PsGetNextProcessThread(Process, NULL);
|
||||
while (Thread)
|
||||
{
|
||||
/* Skip threads with explicit permission to do this */
|
||||
if (Thread->ExWorkerCanWaitUser) goto Next;
|
||||
|
||||
/* Check if we reached ourselves */
|
||||
if (Thread == CurrentThread)
|
||||
{
|
||||
/* Do it inline */
|
||||
KeSetKernelStackSwapEnable(AllowSwap);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Queue an APC */
|
||||
KeInitializeApc(&Apc,
|
||||
&Thread->Tcb,
|
||||
InsertApcEnvironment,
|
||||
ExpSetSwappingKernelApc,
|
||||
NULL,
|
||||
NULL,
|
||||
KernelMode,
|
||||
&AllowSwap);
|
||||
if (KeInsertQueueApc(&Apc, &Event, NULL, 3))
|
||||
{
|
||||
/* Wait for the APC to run */
|
||||
KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL);
|
||||
KeClearEvent(&Event);
|
||||
}
|
||||
}
|
||||
|
||||
/* Next thread */
|
||||
Next:
|
||||
Thread = PsGetNextProcessThread(Process, Thread);
|
||||
}
|
||||
|
||||
/* Release the lock */
|
||||
ExReleaseFastMutex(&ExpWorkerSwapinMutex);
|
||||
}
|
||||
|
||||
/* PUBLIC FUNCTIONS **********************************************************/
|
||||
|
||||
/*++
|
||||
|
|
|
@ -36,7 +36,7 @@ HAL_DISPATCH HalDispatchTable =
|
|||
(pHalStartMirroring)NULL,
|
||||
(pHalEndMirroring)NULL,
|
||||
(pHalMirrorPhysicalMemory)NULL,
|
||||
(pHalEndOfBoot)NULL,
|
||||
xHalEndOfBoot,
|
||||
(pHalMirrorVerify)NULL
|
||||
};
|
||||
|
||||
|
@ -47,7 +47,7 @@ HAL_PRIVATE_DISPATCH HalPrivateDispatchTable =
|
|||
(pHalHandlerForConfigSpace)NULL,
|
||||
(pHalLocateHiberRanges)NULL,
|
||||
(pHalRegisterBusHandler)NULL,
|
||||
(pHalSetWakeEnable)NULL,
|
||||
xHalSetWakeEnable,
|
||||
(pHalSetWakeAlarm)NULL,
|
||||
(pHalTranslateBusAddress)NULL,
|
||||
(pHalAssignSlotResources)NULL,
|
||||
|
@ -81,3 +81,19 @@ xHalHaltSystem(VOID)
|
|||
/* Halt execution */
|
||||
while (TRUE);
|
||||
}
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
xHalEndOfBoot(VOID)
|
||||
{
|
||||
/* Nothing */
|
||||
return;
|
||||
}
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
xHalSetWakeEnable(IN BOOLEAN Enable)
|
||||
{
|
||||
/* Nothing */
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1454,6 +1454,12 @@ CmShutdownSystem(
|
|||
VOID
|
||||
);
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
CmSetLazyFlushState(
|
||||
IN BOOLEAN Enable
|
||||
);
|
||||
|
||||
//
|
||||
// Global variables accessible from all of Cm
|
||||
//
|
||||
|
|
|
@ -26,6 +26,7 @@ extern ULONG NtGlobalFlag;
|
|||
extern ULONG ExpInitializationPhase;
|
||||
extern ULONG ExpAltTimeZoneBias;
|
||||
extern LIST_ENTRY ExSystemLookasideListHead;
|
||||
extern PCALLBACK_OBJECT PowerStateCallback;
|
||||
|
||||
typedef struct _EXHANDLE
|
||||
{
|
||||
|
@ -158,6 +159,10 @@ VOID
|
|||
NTAPI
|
||||
ExpInitializeWorkerThreads(VOID);
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
ExSwapinWorkerThreads(IN BOOLEAN AllowSwap);
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
ExpInitLookasideLists(VOID);
|
||||
|
|
|
@ -53,6 +53,18 @@ xHalHaltSystem(
|
|||
VOID
|
||||
);
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
xHalEndOfBoot(
|
||||
VOID
|
||||
);
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
xHalSetWakeEnable(
|
||||
IN BOOLEAN Enable
|
||||
);
|
||||
|
||||
UCHAR
|
||||
NTAPI
|
||||
xHalVectorToIDTEntry(
|
||||
|
|
Loading…
Reference in a new issue