2 * IPRT - Power management.
6 * Copyright (C) 2008-2016 Oracle Corporation
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.
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.
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.
26 #ifndef ___iprt_power_h
27 #define ___iprt_power_h
29 #include <iprt/cdefs.h>
30 #include <iprt/types.h>
35 /** @defgroup grp_rt_power RTPower - Power management
43 * MP event, see FNRTPOWERNOTIFICATION.
45 typedef enum RTPOWEREVENT
47 /** The system will go into suspend mode. */
48 RTPOWEREVENT_SUSPEND
= 1,
49 /** The system has resumed. */
54 * Notification callback.
56 * The context this is called in differs a bit from platform to
57 * platform, so be careful while in here.
59 * @param enmEvent The event.
60 * @param pvUser The user argument.
62 typedef DECLCALLBACK(void) FNRTPOWERNOTIFICATION(RTPOWEREVENT enmEvent
, void *pvUser
);
63 /** Pointer to a FNRTPOWERNOTIFICATION(). */
64 typedef FNRTPOWERNOTIFICATION
*PFNRTPOWERNOTIFICATION
;
67 * Registers a notification callback for power events.
69 * @returns IPRT status code.
70 * @retval VINF_SUCCESS on success.
71 * @retval VERR_NO_MEMORY if a registration record cannot be allocated.
72 * @retval VERR_ALREADY_EXISTS if the pfnCallback and pvUser already exist
73 * in the callback list.
75 * @param pfnCallback The callback.
76 * @param pvUser The user argument to the callback function.
78 RTDECL(int) RTPowerNotificationRegister(PFNRTPOWERNOTIFICATION pfnCallback
, void *pvUser
);
81 * This deregisters a notification callback registered via RTPowerNotificationRegister().
83 * The pfnCallback and pvUser arguments must be identical to the registration call
84 * of we won't find the right entry.
86 * @returns IPRT status code.
87 * @retval VINF_SUCCESS on success.
88 * @retval VERR_NOT_FOUND if no matching entry was found.
90 * @param pfnCallback The callback.
91 * @param pvUser The user argument to the callback function.
93 RTDECL(int) RTPowerNotificationDeregister(PFNRTPOWERNOTIFICATION pfnCallback
, void *pvUser
);
96 * This calls all registered power management callback handlers registered via RTPowerNotificationRegister().
98 * @returns IPRT status code.
99 * @retval VINF_SUCCESS on success.
101 * @param enmEvent Power Management event
103 RTDECL(int) RTPowerSignalEvent(RTPOWEREVENT enmEvent
);
105 #endif /* IN_RING0 */