Changeset 61675 in vbox
- Timestamp:
- Jun 13, 2016 12:39:34 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/vmm/pdmifs.h
r60905 r61675 1469 1469 */ 1470 1470 DECLR3CALLBACKMEMBER(int, pfnMonitorHotPlugEvent,(PPDMIACPIPORT pInterface)); 1471 1472 /** 1473 * Send a battery status change event. 1474 * 1475 * @returns VBox status code 1476 * @param pInterface Pointer to the interface structure containing 1477 * the called function pointer. 1478 */ 1479 DECLR3CALLBACKMEMBER(int, pfnBatteryStatusChangeEvent,(PPDMIACPIPORT pInterface)); 1471 1480 } PDMIACPIPORT; 1472 1481 /** PDMIACPIPORT interface ID. */ … … 1505 1514 } PDMIACPICONNECTOR; 1506 1515 /** PDMIACPICONNECTOR interface ID. */ 1507 #define PDMIACPICONNECTOR_IID " 5f14bf8d-1edf-4e3a-a1e1-cca9fd08e359"1516 #define PDMIACPICONNECTOR_IID "19c7de73-5ae0-4841-a106-21825f43b206" 1508 1517 1509 1518 -
trunk/src/VBox/Devices/PC/DevACPI.cpp
r60404 r61675 902 902 903 903 /** 904 * Send an ACPI battery status change event. 905 * 906 * @returns VBox status code 907 * @param pInterface Pointer to the interface structure containing the 908 * called function pointer. 909 */ 910 static DECLCALLBACK(int) acpiR3Port_BatteryStatusChangeEvent(PPDMIACPIPORT pInterface) 911 { 912 ACPIState *pThis = RT_FROM_MEMBER(pInterface, ACPIState, IACPIPort); 913 DEVACPI_LOCK_R3(pThis); 914 915 apicR3UpdateGpe0(pThis, pThis->gpe0_sts | 0x1, pThis->gpe0_en); 916 917 DEVACPI_UNLOCK(pThis); 918 return VINF_SUCCESS; 919 } 920 921 /** 904 922 * Used by acpiR3PmTimer to re-arm the PM timer. 905 923 * … … 3044 3062 3045 3063 /* IBase */ 3046 pThis->IBase.pfnQueryInterface = acpiR3QueryInterface;3064 pThis->IBase.pfnQueryInterface = acpiR3QueryInterface; 3047 3065 /* IACPIPort */ 3048 pThis->IACPIPort.pfnSleepButtonPress = acpiR3Port_SleepButtonPress; 3049 pThis->IACPIPort.pfnPowerButtonPress = acpiR3Port_PowerButtonPress; 3050 pThis->IACPIPort.pfnGetPowerButtonHandled = acpiR3Port_GetPowerButtonHandled; 3051 pThis->IACPIPort.pfnGetGuestEnteredACPIMode = acpiR3Port_GetGuestEnteredACPIMode; 3052 pThis->IACPIPort.pfnGetCpuStatus = acpiR3Port_GetCpuStatus; 3053 pThis->IACPIPort.pfnMonitorHotPlugEvent = acpiR3Port_MonitorHotPlugEvent; 3066 pThis->IACPIPort.pfnSleepButtonPress = acpiR3Port_SleepButtonPress; 3067 pThis->IACPIPort.pfnPowerButtonPress = acpiR3Port_PowerButtonPress; 3068 pThis->IACPIPort.pfnGetPowerButtonHandled = acpiR3Port_GetPowerButtonHandled; 3069 pThis->IACPIPort.pfnGetGuestEnteredACPIMode = acpiR3Port_GetGuestEnteredACPIMode; 3070 pThis->IACPIPort.pfnGetCpuStatus = acpiR3Port_GetCpuStatus; 3071 pThis->IACPIPort.pfnMonitorHotPlugEvent = acpiR3Port_MonitorHotPlugEvent; 3072 pThis->IACPIPort.pfnBatteryStatusChangeEvent = acpiR3Port_BatteryStatusChangeEvent; 3054 3073 3055 3074 /* -
trunk/src/VBox/Devices/PC/DrvACPI.cpp
r60956 r61675 234 234 */ 235 235 static DECLCALLBACK(int) drvACPIQueryBatteryStatus(PPDMIACPICONNECTOR pInterface, bool *pfPresent, 236 PPDMACPIBATCAPACITY penmRemainingCapacity,237 PPDMACPIBATSTATE penmBatteryState,238 uint32_t *pu32PresentRate)236 PPDMACPIBATCAPACITY penmRemainingCapacity, 237 PPDMACPIBATSTATE penmBatteryState, 238 uint32_t *pu32PresentRate) 239 239 { 240 240 /* default return values for all architectures */ … … 534 534 bool fDischarging = false; /* one or more batteries discharging */ 535 535 bool fCritical = false; /* one or more batteries in critical state */ 536 bool fDataChanged; /* if battery status data changed during last poll */ 536 537 int32_t maxCapacityTotal = 0; /* total capacity of all batteries */ 537 538 int32_t currentCapacityTotal = 0; /* total current capacity of all batteries */ 538 539 int32_t presentRateTotal = 0; /* total present (dis)charging rate of all batts */ 540 PDMACPIBATCAPACITY enmBatteryRemainingCapacity; /* total remaining capacity of vbox batt */ 541 uint32_t u32BatteryPresentRate; /* total present (dis)charging rate of vbox batt */ 539 542 540 543 int rc = RTDirOpen(&pDir, "/sys/class/power_supply/"); … … 856 859 /* atomic update of the state */ 857 860 RTCritSectEnter(&pThis->CritSect); 858 pThis->enmPowerSource = enmPowerSource;859 pThis->fBatteryPresent = fBatteryPresent;860 861 861 862 /* charging/discharging bits are mutual exclusive */ … … 867 868 if (fCritical) 868 869 uBs |= PDM_ACPI_BAT_STATE_CRITICAL; 869 pThis->enmBatteryState = (PDMACPIBATSTATE)uBs;870 870 871 871 if (maxCapacityTotal > 0 && currentCapacityTotal > 0) … … 875 875 876 876 /* calculate the percentage */ 877 pThis->enmBatteryRemainingCapacity = 877 878 enmBatteryRemainingCapacity = 878 879 (PDMACPIBATCAPACITY)( ( (float)currentCapacityTotal 879 880 / (float)maxCapacityTotal) 880 881 * PDM_ACPI_BAT_CAPACITY_MAX); 881 pThis->u32BatteryPresentRate =882 u32BatteryPresentRate = 882 883 (uint32_t)(( (float)presentRateTotal 883 884 / (float)maxCapacityTotal) * 1000); … … 886 887 { 887 888 /* unknown capacity / state */ 888 pThis->enmBatteryRemainingCapacity = PDM_ACPI_BAT_CAPACITY_UNKNOWN; 889 pThis->u32BatteryPresentRate = ~0; 890 } 889 enmBatteryRemainingCapacity = PDM_ACPI_BAT_CAPACITY_UNKNOWN; 890 u32BatteryPresentRate = ~0; 891 } 892 893 if ( pThis->enmPowerSource == enmPowerSource 894 && pThis->fBatteryPresent == fBatteryPresent 895 && pThis->enmBatteryState == (PDMACPIBATSTATE) uBs 896 && pThis->enmBatteryRemainingCapacity == enmBatteryRemainingCapacity 897 && pThis->u32BatteryPresentRate == u32BatteryPresentRate) 898 { 899 fDataChanged = false; 900 } 901 else 902 { 903 fDataChanged = true; 904 905 pThis->enmPowerSource = enmPowerSource; 906 pThis->fBatteryPresent = fBatteryPresent; 907 pThis->enmBatteryState = (PDMACPIBATSTATE)uBs; 908 pThis->enmBatteryRemainingCapacity = enmBatteryRemainingCapacity; 909 pThis->u32BatteryPresentRate = u32BatteryPresentRate; 910 } 911 891 912 RTCritSectLeave(&pThis->CritSect); 913 914 if (fDataChanged) 915 pThis->pPort->pfnBatteryStatusChangeEvent(pThis->pPort); 892 916 893 917 /* wait a bit (e.g. Ubuntu/GNOME polls every 30 seconds) */ -
trunk/src/VBox/Devices/PC/vbox.dsl
r60618 r61675 1362 1362 { 1363 1363 // GPE bit 0 handler 1364 // GPE.0 must be set and SCI raised when 1365 // battery info changed and _BIF must be 1366 // re-evaluated 1367 Method (_L00, 0, NotSerialized) 1368 { 1369 Notify (\_SB.PCI0.BAT0, 0x81) 1364 // GPE.0 must be set and SCI raised when battery info 1365 // changed. Do NOT re-evaluate _BIF (battery info, never 1366 // changes) but DO re-evaluate _BST (dynamic state). Also 1367 // re-evaluate the AC adapter status. 1368 Method (_L00, 0, NotSerialized). 1369 { 1370 // _BST must be re-evaluated (battery state) 1371 Notify (\_SB.PCI0.BAT0, 0x80) 1372 // _PSR must be re-evaluated (AC adapter status) 1373 Notify (\_SB.PCI0.AC, 0x80) 1370 1374 } 1371 1375 }
Note:
See TracChangeset
for help on using the changeset viewer.