test: po.h Source File

Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

# po.h

Go to the documentation of this file.

    00001 /*++ BUILD Version: 0001    // Increment this if a change has global effects
    00002
    00003 Copyright (c) 1994  Microsoft Corporation
    00004 Copyright (c) 1994  International Business Machines Corporation
    00005
    00006 Module Name:
    00007
    00008     po.h
    00009
    00010 Abstract:
    00011
    00012     This module contains the internal structure definitions and APIs used by
    00013     the NT Poewr Management.
    00014
    00015 Author:
    00016
    00017     Ken Reneris (kenr) 19-July-1994
    00018     N. Yoshiyama [IBM Corp.] 01-Mar-1994
    00019
    00020
    00021 Revision History:
    00022
    00023
    00024 --*/
    00025
    00026
    00027
    00028 #ifndef _PO_
    00029 #define _PO_
    00030
    00031 #if DBG
    00032
    00033 VOID
    00034 PoPowerTracePrint(
    00035     ULONG    TracePoint,
    00036     ULONG_PTR Caller,
    00037     ULONG_PTR CallerCaller,
    00038     ULONG_PTR DeviceObject,
    00039     ULONG_PTR Irp,
    00040     ULONG_PTR Ios
    00041     );
    00042
    00043 #define PoPowerTrace(TracePoint,DevObj,Arg1,Arg2) \
    00044 {\
    00045     PVOID pptcCaller;      \
    00046     PVOID pptcCallerCaller;  \
    00047     RtlGetCallersAddress(&pptcCaller, &pptcCallerCaller); \
    00048     PoPowerTracePrint(TracePoint, (ULONG_PTR)pptcCaller, (ULONG_PTR)pptcCallerCaller, (ULONG_PTR)DevObj, (ULONG_PTR)Arg1, (ULONG_PTR)Arg2); \
    00049 }
    00050 #else
    00051 #define PoPowerTrace(TracePoint,DevObj,Arg1,Arg2)
    00052 #endif
    00053
    00054 #define POWERTRACE_CALL         0x1
    00055 #define POWERTRACE_PRESENT      0x2
    00056 #define POWERTRACE_STARTNEXT    0x4
    00057 #define POWERTRACE_SETSTATE     0x8
    00058 #define POWERTRACE_COMPLETE     0x10
    00059
    00060
    00061 VOID
    00062 FASTCALL
    00063 PoInitializePrcb (
    00064     PKPRCB      Prcb
    00065     );
    00066
    00067 NTKERNELAPI
    00068 BOOLEAN
    00069 PoInitSystem (
    00070     IN ULONG    Phase
    00071     );
    00072
    00073 VOID
    00074 PoInitDriverServices (
    00075     IN ULONG    Phase
    00076     );
    00077
    00078 VOID
    00079 PoInitHiberServices (
    00080     IN BOOLEAN  Setup
    00081     );
    00082
    00083 NTKERNELAPI
    00084 VOID
    00085 PoInitializeDeviceObject (
    00086     IN PDEVOBJ_EXTENSION   DeviceObjectExtension
    00087     );
    00088
    00089 NTKERNELAPI
    00090 VOID
    00091 PoRunDownDeviceObject (
    00092     IN PDEVICE_OBJECT   DeviceObject
    00093     );
    00094
    00095 NTKERNELAPI
    00096 VOID
    00097 PopCleanupPowerState (
    00098     IN OUT PUCHAR PowerState
    00099     );
    00100
    00101 #define PoRundownThread(Thread)     \
    00102         PopCleanupPowerState(&Thread->Tcb.PowerState)
    00103
    00104 #define PoRundownProcess(Process)   \
    00105         PopCleanupPowerState(&Process->Pcb.PowerState)
    00106
    00107 VOID
    00108 PoNotifySystemTimeSet (
    00109     VOID
    00110     );
    00111
    00112 VOID
    00113 PoInvalidateDevicePowerRelations(
    00114     PDEVICE_OBJECT  DeviceObject
    00115     );
    00116
    00117 VOID
    00118 PoShutdownBugCheck (
    00119     IN BOOLEAN  AllowCrashDump,
    00120     IN ULONG    BugCheckCode,
    00121     IN ULONG_PTR BugCheckParameter1,
    00122     IN ULONG_PTR BugCheckParameter2,
    00123     IN ULONG_PTR BugCheckParameter3,
    00124     IN ULONG_PTR BugCheckParameter4
    00125     );
    00126
    00127 // begin_nthal
    00128
    00129 NTKERNELAPI
    00130 VOID
    00131 PoSetHiberRange (
    00132     IN PVOID     MemoryMap,
    00133     IN ULONG     Flags,
    00134     IN PVOID     Address,
    00135     IN ULONG_PTR Length,
    00136     IN ULONG     Tag
    00137     );
    00138
    00139 // memory_range.Type
    00140 #define PO_MEM_PRESERVE         0x00000001      // memory range needs preserved
    00141 #define PO_MEM_CLONE            0x00000002      // Clone this range
    00142 #define PO_MEM_CL_OR_NCHK       0x00000004      // Either clone or do not checksum
    00143 #define PO_MEM_DISCARD          0x00008000      // This range to be removed
    00144 #define PO_MEM_PAGE_ADDRESS     0x00004000      // Arguments passed are physical pages
    00145
    00146 // end_nthal
    00147
    00148 #define PoWakeTimerSupported()  \
    00149     (PopCapabilities.RtcWake >= PowerSystemSleeping1)
    00150
    00151 ULONG
    00152 PoSimpleCheck (
    00153     IN ULONG                PatialSum,
    00154     IN PVOID                StartVa,
    00155     IN ULONG_PTR            Length
    00156     );
    00157
    00158 BOOLEAN
    00159 PoSystemIdleWorker (
    00160     IN BOOLEAN IdleWorker
    00161     );
    00162
    00163 VOID
    00164 PoVolumeDevice(
    00165     IN PDEVICE_OBJECT DeviceObject
    00166     );
    00167
    00168 VOID
    00169 PoSetWarmEjectDevice(
    00170     IN PDEVICE_OBJECT DeviceObject
    00171     ) ;
    00172
    00173 NTSTATUS
    00174 PoGetLightestSystemStateForEject(
    00175     IN   BOOLEAN              DockBeingEjected,
    00176     IN   BOOLEAN              HotEjectSupported,
    00177     IN   BOOLEAN              WarmEjectSupported,
    00178     OUT  PSYSTEM_POWER_STATE  LightestSleepState
    00179     );
    00180
    00181 // begin_ntddk begin_wdm
    00182
    00183 NTKERNELAPI
    00184 VOID
    00185 PoSetSystemState (
    00186     IN EXECUTION_STATE Flags
    00187     );
    00188
    00189 NTKERNELAPI
    00190 PVOID
    00191 PoRegisterSystemState (
    00192     IN PVOID StateHandle,
    00193     IN EXECUTION_STATE Flags
    00194     );
    00195
    00196 typedef
    00197 VOID
    00198 (*PREQUEST_POWER_COMPLETE) (
    00199     IN PDEVICE_OBJECT DeviceObject,
    00200     IN UCHAR MinorFunction,
    00201     IN POWER_STATE PowerState,
    00202     IN PVOID Context,
    00203     IN PIO_STATUS_BLOCK IoStatus
    00204     );
    00205
    00206 NTKERNELAPI
    00207 NTSTATUS
    00208 PoRequestPowerIrp (
    00209     IN PDEVICE_OBJECT DeviceObject,
    00210     IN UCHAR MinorFunction,
    00211     IN POWER_STATE PowerState,
    00212     IN PREQUEST_POWER_COMPLETE CompletionFunction,
    00213     IN PVOID Context,
    00214     OUT PIRP *Irp OPTIONAL
    00215     );
    00216
    00217 NTKERNELAPI
    00218 VOID
    00219 PoUnregisterSystemState (
    00220     IN PVOID StateHandle
    00221     );
    00222
    00223 // end_ntddk end_wdm
    00224 // begin_ntddk begin_wdm begin_nthal begin_ntifs
    00225
    00226 NTKERNELAPI
    00227 POWER_STATE
    00228 PoSetPowerState (
    00229     IN PDEVICE_OBJECT   DeviceObject,
    00230     IN POWER_STATE_TYPE Type,
    00231     IN POWER_STATE      State
    00232     );
    00233
    00234 NTKERNELAPI
    00235 NTSTATUS
    00236 PoCallDriver (
    00237     IN PDEVICE_OBJECT   DeviceObject,
    00238     IN OUT PIRP         Irp
    00239     );
    00240
    00241 NTKERNELAPI
    00242 VOID
    00243 PoStartNextPowerIrp(
    00244     IN PIRP    Irp
    00245     );
    00246
    00247
    00248 NTKERNELAPI
    00249 PULONG
    00250 PoRegisterDeviceForIdleDetection (
    00251     IN PDEVICE_OBJECT     DeviceObject,
    00252     IN ULONG              ConservationIdleTime,
    00253     IN ULONG              PerformanceIdleTime,
    00254     IN DEVICE_POWER_STATE State
    00255     );
    00256
    00257 #define PoSetDeviceBusy(IdlePointer) \
    00258     *IdlePointer = 0
    00259
    00260 //
    00261 // \Callback\PowerState values
    00262 //
    00263
    00264 #define PO_CB_SYSTEM_POWER_POLICY   0
    00265 #define PO_CB_AC_STATUS             1
    00266 #define PO_CB_BUTTON_COLLISION      2
    00267 #define PO_CB_SYSTEM_STATE_LOCK     3
    00268
    00269
    00270 // end_ntddk end_wdm end_nthal end_ntifs
    00271
    00272 //
    00273 // Broken functions we don't intend on supporting. The code backing these
    00274 // should be ripped out in NT5.1
    00275 //
    00276 typedef
    00277 VOID
    00278 (*PPO_NOTIFY) (
    00279     IN PDEVICE_OBJECT   DeviceObject,
    00280     IN PVOID            Context,
    00281     IN ULONG            Type,
    00282     IN ULONG            Reserved
    00283     );
    00284
    00285 #define PO_NOTIFY_D0                        0x00000001
    00286 #define PO_NOTIFY_TRANSITIONING_FROM_D0     0x00000002
    00287 #define PO_NOTIFY_INVALID                   0x80000000
    00288
    00289 NTKERNELAPI
    00290 NTSTATUS
    00291 PoRegisterDeviceNotify (
    00292     IN PDEVICE_OBJECT   DeviceObject,
    00293     IN PPO_NOTIFY       NotificationFunction,
    00294     IN PVOID            NotificationContext,
    00295     IN ULONG            NotificationType,
    00296     OUT PDEVICE_POWER_STATE  DeviceState,
    00297     OUT PVOID           *NotificationHandle
    00298     );
    00299
    00300 NTKERNELAPI
    00301 NTSTATUS
    00302 PoCancelDeviceNotify (
    00303     IN PVOID            NotificationHandle
    00304     );
    00305
    00306
    00307 //
    00308 // Callout set state failure notification
    00309 //
    00310
    00311 typedef struct {
    00312     NTSTATUS            Status;
    00313     POWER_ACTION        PowerAction;
    00314     SYSTEM_POWER_STATE  MinState;
    00315     ULONG               Flags;
    00316 } PO_SET_STATE_FAILURE, *PPO_SET_STATE_FAILURE;
    00317
    00318
    00319
    00320 //
    00321 // Hibernation file layout:
    00322 //      Page 0  - PO_MEMORY_IMAGE
    00323 //      Page 1  - Free page array
    00324 //      Page 2  - KPROCESSOR_CONTEXT
    00325 //      Page 3  - first memory_range_array page
    00326 //
    00327 // PO_MEMORY_IMAGE:
    00328 //      Header on file which contains some information to identify
    00329 //      the hibernation, as well as a couple of checksums.
    00330 //
    00331 // Free page array:
    00332 //      A page full of page numbers which identify 4MBs worth of
    00333 //      system pages that are not in the restoration image.  These
    00334 //      pages are used by the loader (to its self out of the way)
    00335 //      when restoring the memory image.
    00336 //
    00337 // KPROCESSOR_CONTEST
    00338 //      The context of the processor which hibernated the system.
    00339 //      Rest of page is empty.
    00340 //
    00341 // memory_range_array
    00342 //      A page which contains an array of memory_range_array elements
    00343 //      where element 0 is a Link entry, and all other elements are
    00344 //      Range entries.   The Link entry is used to link to the next
    00345 //      such page, and to supply a count of the number of Range entries
    00346 //      in the current page.   The range entries each describe one
    00347 //      physical memory range which needs restoration and its location
    00348 //      in the file.
    00349 //
    00350
    00351 typedef struct _PO_MEMORY_RANGE_ARRAY {
    00352     union {
    00353         struct {
    00354             PFN_NUMBER      PageNo;
    00355             PFN_NUMBER      StartPage;
    00356             PFN_NUMBER      EndPage;
    00357             ULONG           CheckSum;
    00358         } Range;
    00359         struct {
    00360             struct _PO_MEMORY_RANGE_ARRAY *Next;
    00361             PFN_NUMBER      NextTable;
    00362             ULONG           CheckSum;
    00363             ULONG           EntryCount;
    00364         } Link;
    00365     };
    00366 } PO_MEMORY_RANGE_ARRAY, *PPO_MEMORY_RANGE_ARRAY;
    00367
    00368 #define PO_MAX_RANGE_ARRAY  (PAGE_SIZE / sizeof(PO_MEMORY_RANGE_ARRAY))
    00369 #define PO_ENTRIES_PER_PAGE (PO_MAX_RANGE_ARRAY-1)
    00370
    00371
    00372 #define PO_IMAGE_SIGNATURE          'rbih'
    00373 #define PO_IMAGE_SIGNATURE_WAKE     'ekaw'
    00374 #define PO_IMAGE_SIGNATURE_BREAK    'pkrb'
    00375 #define PO_IMAGE_SIGNATURE_LINK     'knil'
    00376 #define PO_IMAGE_HEADER_PAGE        0
    00377 #define PO_FREE_MAP_PAGE            1
    00378 #define PO_PROCESSOR_CONTEXT_PAGE   2
    00379 #define PO_FIRST_RANGE_TABLE_PAGE   3
    00380
    00381 #define PO_COMPRESS_CHUNK_SIZE      4096
    00382
    00383 //
    00384 // Define various HiberFlags to control the behavior when restoring
    00385 //
    00386 #define PO_HIBER_APM_RECONNECT      1
    00387
    00388 typedef struct {
    00389     ULONG                   Signature;
    00390     ULONG                   Version;
    00391     ULONG                   CheckSum;
    00392     ULONG                   LengthSelf;
    00393     PFN_NUMBER              PageSelf;
    00394     ULONG                   PageSize;
    00395
    00396     ULONG                   ImageType;
    00397     LARGE_INTEGER           SystemTime;
    00398     ULONGLONG               InterruptTime;
    00399     ULONG                   FeatureFlags;
    00400     UCHAR                   HiberFlags;
    00401     UCHAR                   spare[3];
    00402
    00403     ULONG                   NoHiberPtes;
    00404     ULONG_PTR               HiberVa;
    00405     PHYSICAL_ADDRESS        HiberPte;
    00406
    00407     ULONG                   NoFreePages;
    00408     ULONG                   FreeMapCheck;
    00409     ULONG                   WakeCheck;
    00410
    00411     PFN_NUMBER              TotalPages;
    00412     PFN_NUMBER              FirstTablePage;
    00413     PFN_NUMBER              LastFilePage;
    00414 } PO_MEMORY_IMAGE, *PPO_MEMORY_IMAGE;
    00415
    00416 typedef struct {
    00417     ULONG                   Signature;
    00418     WCHAR                   Name[1];
    00419 } PO_IMAGE_LINK, *PPO_IMAGE_LINK;
    00420
    00421 //
    00422 // Returned by Io system
    00423 //
    00424
    00425 typedef struct _PO_DEVICE_NOTIFY {
    00426     LIST_ENTRY              Link;
    00427     PDEVICE_OBJECT          TargetDevice;
    00428
    00429     BOOLEAN                 WakeNeeded;
    00430     UCHAR                   OrderLevel;
    00431
    00432     PDEVICE_OBJECT          DeviceObject;
    00433     PVOID                   Node;
    00434     PWCHAR                  DeviceName;
    00435     PWCHAR                  DriverName;
    00436
    00437     LONG                    NodeLevel;
    00438 } PO_DEVICE_NOTIFY, *PPO_DEVICE_NOTIFY;
    00439
    00440 #define PO_ORDER_NOT_VIDEO          0x0001
    00441 #define PO_ORDER_ROOT_ENUM          0x0002
    00442 #define PO_ORDER_PAGABLE            0x0004
    00443 #define PO_ORDER_MAXIMUM            0x0007
    00444
    00445 // notify GDI before this order level
    00446 #define PO_ORDER_GDI_NOTIFICATION   (PO_ORDER_PAGABLE)
    00447
    00448 typedef struct _PO_DEVICE_NOTIFY_ORDER {
    00449     ULONG                   DevNodeSequence;
    00450     ULONG                   NoLists;
    00451     LONG                    MaxLevel;
    00452     PDEVICE_OBJECT          *WarmEjectPdoPointer;
    00453
    00454     LIST_ENTRY              Partial;
    00455     LIST_ENTRY              Rebase;
    00456     PLIST_ENTRY             Notify;
    00457 } PO_DEVICE_NOTIFY_ORDER, *PPO_DEVICE_NOTIFY_ORDER;
    00458
    00459 extern KAFFINITY        PoSleepingSummary;
    00460 extern BOOLEAN          PoEnabled;
    00461 extern ULONG            PoPowerSequence;
    00462 extern BOOLEAN          PoPageLockData;
    00463 extern KTIMER           PoSystemIdleTimer;
    00464 extern BOOLEAN          PoHiberInProgress;
    00465
    00466 // PopCapabilities used by some internal macros
    00467 extern SYSTEM_POWER_CAPABILITIES PopCapabilities;
    00468
    00469 #endif
    00470