VirtualBox

source: vbox/trunk/include/iprt/power.h@ 55435

Last change on this file since 55435 was 55435, checked in by vboxsync, 9 years ago

Bad commit, reverted with following changeset

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.2 KB
Line 
1/** @file
2 * IPRT - Power management.
3 */
4
5/*
6 * Copyright (C) 2008-2010 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_power_h
27#define ___iprt_power_h
28
29#include <iprt/cdefs.h>
30#include <iprt/types.h>
31
32
33RT_C_DECLS_BEGIN
34
35/** @defgroup grp_rt_power RTPower - Power management
36 * @ingroup grp_rt
37 * @{
38 */
39
40/**
41 * MP event, see FNRTPOWERNOTIFICATION.
42 */
43typedef enum RTPOWEREVENT
44{
45 /** Invalid power event. */
46 RTPOWEREVENT_INVALID = 1,
47 /** The system is preparing for a suspend operation.
48 * If supported, this should arrive earlier than RTPOWEREVENT_SUSPEND. */
49 RTPOWEREVENT_PRE_SUSPEND,
50 /** The system will go into suspend mode. */
51 RTPOWEREVENT_SUSPEND,
52 /** The system has resumed. */
53 RTPOWEREVENT_RESUME
54} RTPOWEREVENT;
55/** Pointer to a power event. */
56typedef RTPOWEREVENT *PRTPOWEREVENT;
57
58/**
59 * Gets the descriptive power event name.
60 *
61 * @returns The name.
62 * @param enmEvent The power event.
63 */
64DECLINLINE(const char *) RTPowerGetEventName(RTPOWEREVENT enmEvent)
65{
66 switch (enmEvent)
67 {
68 case RTPOWEREVENT_INVALID: return "Invalid";
69 case RTPOWEREVENT_PRE_SUSPEND: return "Pre-suspend";
70 case RTPOWEREVENT_SUSPEND: return "Suspend";
71 case RTPOWEREVENT_RESUME: return "Resume";
72 default: return "???";
73 }
74}
75
76
77#ifdef IN_RING0
78
79/**
80 * Notification callback.
81 *
82 * The context this is called in differs a bit from platform to
83 * platform, so be careful while in here.
84 *
85 * On Linux, the pre-suspend, suspend and resume events fire with preemption
86 * enabled on any CPU.
87 *
88 * @param enmEvent The event.
89 * @param pvUser The user argument.
90 */
91typedef DECLCALLBACK(void) FNRTPOWERNOTIFICATION(RTPOWEREVENT enmEvent, void *pvUser);
92/** Pointer to a FNRTPOWERNOTIFICATION(). */
93typedef FNRTPOWERNOTIFICATION *PFNRTPOWERNOTIFICATION;
94
95/**
96 * Registers a notification callback for power events.
97 *
98 * @returns IPRT status code.
99 * @retval VINF_SUCCESS on success.
100 * @retval VERR_NO_MEMORY if a registration record cannot be allocated.
101 * @retval VERR_ALREADY_EXISTS if the pfnCallback and pvUser already exist
102 * in the callback list.
103 *
104 * @param pfnCallback The callback.
105 * @param pvUser The user argument to the callback function.
106 */
107RTDECL(int) RTPowerNotificationRegister(PFNRTPOWERNOTIFICATION pfnCallback, void *pvUser);
108
109/**
110 * This deregisters a notification callback registered via RTPowerNotificationRegister().
111 *
112 * The pfnCallback and pvUser arguments must be identical to the registration call
113 * of we won't find the right entry.
114 *
115 * @returns IPRT status code.
116 * @retval VINF_SUCCESS on success.
117 * @retval VERR_NOT_FOUND if no matching entry was found.
118 *
119 * @param pfnCallback The callback.
120 * @param pvUser The user argument to the callback function.
121 */
122RTDECL(int) RTPowerNotificationDeregister(PFNRTPOWERNOTIFICATION pfnCallback, void *pvUser);
123
124/**
125 * This calls all registered power management callback handlers registered via RTPowerNotificationRegister().
126 *
127 * @returns IPRT status code.
128 * @retval VINF_SUCCESS on success.
129 *
130 * @param enmEvent Power Management event
131 */
132RTDECL(int) RTPowerSignalEvent(RTPOWEREVENT enmEvent);
133
134#endif /* IN_RING0 */
135
136/** @} */
137
138RT_C_DECLS_END
139
140#endif
141
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette