1 | /** @file
|
---|
2 | * IPRT - Power management.
|
---|
3 | */
|
---|
4 |
|
---|
5 | /*
|
---|
6 | * Copyright (C) 2008-2022 Oracle Corporation
|
---|
7 | *
|
---|
8 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
9 | * available from http://www.virtualbox.org. This file is free software;
|
---|
10 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
11 | * General Public License (GPL) as published by the Free Software
|
---|
12 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
13 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
14 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
15 | *
|
---|
16 | * The contents of this file may alternatively be used under the terms
|
---|
17 | * of the Common Development and Distribution License Version 1.0
|
---|
18 | * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
19 | * VirtualBox OSE distribution, in which case the provisions of the
|
---|
20 | * CDDL are applicable instead of those of the GPL.
|
---|
21 | *
|
---|
22 | * You may elect to license modified versions of this file under the
|
---|
23 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
24 | */
|
---|
25 |
|
---|
26 | #ifndef IPRT_INCLUDED_power_h
|
---|
27 | #define IPRT_INCLUDED_power_h
|
---|
28 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
29 | # pragma once
|
---|
30 | #endif
|
---|
31 |
|
---|
32 | #include <iprt/cdefs.h>
|
---|
33 | #include <iprt/types.h>
|
---|
34 |
|
---|
35 |
|
---|
36 | RT_C_DECLS_BEGIN
|
---|
37 |
|
---|
38 | /** @defgroup grp_rt_power RTPower - Power management
|
---|
39 | * @ingroup grp_rt
|
---|
40 | * @{
|
---|
41 | */
|
---|
42 |
|
---|
43 | #ifdef IN_RING0
|
---|
44 |
|
---|
45 | /**
|
---|
46 | * MP event, see FNRTPOWERNOTIFICATION.
|
---|
47 | */
|
---|
48 | typedef enum RTPOWEREVENT
|
---|
49 | {
|
---|
50 | /** The system will go into suspend mode. */
|
---|
51 | RTPOWEREVENT_SUSPEND = 1,
|
---|
52 | /** The system has resumed. */
|
---|
53 | RTPOWEREVENT_RESUME
|
---|
54 | } RTPOWEREVENT;
|
---|
55 |
|
---|
56 | /**
|
---|
57 | * Notification callback.
|
---|
58 | *
|
---|
59 | * The context this is called in differs a bit from platform to
|
---|
60 | * platform, so be careful while in here.
|
---|
61 | *
|
---|
62 | * @param enmEvent The event.
|
---|
63 | * @param pvUser The user argument.
|
---|
64 | */
|
---|
65 | typedef DECLCALLBACKTYPE(void, FNRTPOWERNOTIFICATION,(RTPOWEREVENT enmEvent, void *pvUser));
|
---|
66 | /** Pointer to a FNRTPOWERNOTIFICATION(). */
|
---|
67 | typedef FNRTPOWERNOTIFICATION *PFNRTPOWERNOTIFICATION;
|
---|
68 |
|
---|
69 | /**
|
---|
70 | * Registers a notification callback for power events.
|
---|
71 | *
|
---|
72 | * @returns IPRT status code.
|
---|
73 | * @retval VINF_SUCCESS on success.
|
---|
74 | * @retval VERR_NO_MEMORY if a registration record cannot be allocated.
|
---|
75 | * @retval VERR_ALREADY_EXISTS if the pfnCallback and pvUser already exist
|
---|
76 | * in the callback list.
|
---|
77 | *
|
---|
78 | * @param pfnCallback The callback.
|
---|
79 | * @param pvUser The user argument to the callback function.
|
---|
80 | */
|
---|
81 | RTDECL(int) RTPowerNotificationRegister(PFNRTPOWERNOTIFICATION pfnCallback, void *pvUser);
|
---|
82 |
|
---|
83 | /**
|
---|
84 | * This deregisters a notification callback registered via RTPowerNotificationRegister().
|
---|
85 | *
|
---|
86 | * The pfnCallback and pvUser arguments must be identical to the registration call
|
---|
87 | * of we won't find the right entry.
|
---|
88 | *
|
---|
89 | * @returns IPRT status code.
|
---|
90 | * @retval VINF_SUCCESS on success.
|
---|
91 | * @retval VERR_NOT_FOUND if no matching entry was found.
|
---|
92 | *
|
---|
93 | * @param pfnCallback The callback.
|
---|
94 | * @param pvUser The user argument to the callback function.
|
---|
95 | */
|
---|
96 | RTDECL(int) RTPowerNotificationDeregister(PFNRTPOWERNOTIFICATION pfnCallback, void *pvUser);
|
---|
97 |
|
---|
98 | /**
|
---|
99 | * This calls all registered power management callback handlers registered via RTPowerNotificationRegister().
|
---|
100 | *
|
---|
101 | * @returns IPRT status code.
|
---|
102 | * @retval VINF_SUCCESS on success.
|
---|
103 | *
|
---|
104 | * @param enmEvent Power Management event
|
---|
105 | */
|
---|
106 | RTDECL(int) RTPowerSignalEvent(RTPOWEREVENT enmEvent);
|
---|
107 |
|
---|
108 | #endif /* IN_RING0 */
|
---|
109 |
|
---|
110 | /** @} */
|
---|
111 |
|
---|
112 | RT_C_DECLS_END
|
---|
113 |
|
---|
114 | #endif /* !IPRT_INCLUDED_power_h */
|
---|
115 |
|
---|