1 /* 2 * Copyright 2004-2011, Haiku, Inc. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef POWER_MANAGMENT_H 6 #define POWER_MANAGMENT_H 7 8 9 #include <Drivers.h> 10 11 12 // io controls 13 enum { 14 // ioctl response with kMagicFreqID 15 IDENTIFY_DEVICE = B_DEVICE_OP_CODES_END + 20001, 16 17 GET_BATTERY_INFO, 18 GET_EXTENDED_BATTERY_INFO, 19 WATCH_BATTERY, 20 STOP_WATCHING_BATTERY 21 }; 22 23 24 // ACPI Battery: 25 // magic id returned by IDENTIFY_DEVICE 26 const uint32 kMagicACPIBatteryID = 17822; 27 28 29 // Our known battery states 30 #define BATTERY_DISCHARGING 0x01 31 #define BATTERY_CHARGING 0x02 32 #define BATTERY_CRITICAL_STATE 0x04 33 34 #define BATTERY_MAX_STRING_LENGTH 32 35 36 37 typedef struct { 38 uint32 state; 39 uint32 current_rate; 40 uint32 capacity; 41 uint32 voltage; 42 } acpi_battery_info; 43 44 45 typedef struct { 46 uint32 power_unit; 47 #define ACPI_BATTERY_UNIT_MW 0 48 #define ACPI_BATTERY_UNIT_MA 1 49 uint32 design_capacity; 50 uint32 last_full_charge; 51 uint32 technology; 52 uint32 design_voltage; 53 uint32 design_capacity_warning; 54 uint32 design_capacity_low; 55 uint32 capacity_granularity_1; 56 uint32 capacity_granularity_2; 57 char model_number[BATTERY_MAX_STRING_LENGTH]; 58 char serial_number[BATTERY_MAX_STRING_LENGTH]; 59 char type[BATTERY_MAX_STRING_LENGTH]; 60 char oem_info[BATTERY_MAX_STRING_LENGTH]; 61 // ACPI 4.0 and later 62 uint16 revision; 63 #define ACPI_BATTERY_REVISION_0 0 64 #define ACPI_BATTERY_REVISION_1 1 65 #define ACPI_BATTERY_REVISION_BIF 0xffff 66 uint32 cycles; 67 uint32 accuracy; 68 uint32 max_sampling_time; 69 uint32 min_sampling_time; 70 uint32 max_average_interval; 71 uint32 min_average_interval; 72 // ACPI 6.0 and later 73 uint32 swapping_capability; 74 #define ACPI_BATTERY_SWAPPING_NO 0 75 #define ACPI_BATTERY_SWAPPING_COLD 1 76 #define ACPI_BATTERY_SWAPPING_HOT 2 77 } acpi_extended_battery_info; 78 79 80 #endif 81