summaryrefslogtreecommitdiffstats
path: root/private/ntos/po/poinit.c
blob: a61eb2743775b0d4023c891a3edbb7de8b3df9aa (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/*++

Copyright (c) 1990  Microsoft Corporation

Module Name:

    poinit.c

Abstract:

    Initialize power management component

Author:

    Ken Reneris (kenr) 19-July-1994

Revision History:

--*/

#ifdef _PNP_POWER_

#include "pop.h"

#ifdef ALLOC_PRAGMA
#pragma alloc_text(INIT,PoInitSystem)
#endif


BOOLEAN
PoInitSystem(
    IN ULONG  Phase
    )

/*++

Routine Description:

    This routine initializes the Power Manager.

Arguments:

    None

Return Value:

    The function value is a BOOLEAN indicating whether or not the Power Manager
    was successfully initialized.

--*/

{
    if (Phase == 0) {
        //
        // Initialize the Power manager database resource, lock, and the
        // queue headers.
        //

        KeInitializeSpinLock (&PopStateLock);
        InitializeListHead (&PopDeviceList);
        InitializeListHead (&PopAsyncStateChangeQueue);
        InitializeListHead (&PopSyncStateChangeQueue);
        InitializeListHead (&PopStateChangeInProgress);
        InitializeListHead (&PopStateChangeWorkerList);
        KeInitializeEvent  (&PopStateDatabaseIdle, SynchronizationEvent, TRUE);
        ExInitializeWorkItem (&PopStateChangeWorkItem, PopStateChangeWorker, NULL);

        KeInitializeTimer  (&PopStateChangeTimer);
        KeInitializeDpc (&PopStateChangeDpc, PopStateChange, NULL);
        PopStateChangeDpcActive = FALSE;
        PopSyncChangeInProgress = FALSE;

        //
        // idle.c
        //

        InitializeListHead (&PopActiveIdleScanQueue);

        KeInitializeTimer (&PopIdleScanTimer);
        KeInitializeDpc (&PopIdleScanDpc, PopScanForIdleDevices, NULL);

        // bugbug
        PopIdleScanTime.QuadPart = -50000000;

        //
        // Compute scan time in seconds
        //
        PopIdleScanTimeInSeconds = (ULONG) (PopIdleScanTime.QuadPart / -10000000);
    }

    if (Phase == 1) {

        //
        // Set PowerSequence value for suspend/hibernate support
        //

        PoPowerSequence = 1;

        //
        // Enable PowerManagement
        //

        PoSetPowerManagementEnable (TRUE);
    }

    //
    // Success
    //

    return TRUE;
}

#endif // _PNP_POWER_