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