1 /* ACPI Bus Manger Interface 2 * Copyright 2005, Haiku Inc. All Rights Reserved. 3 * Distributed under the terms of the MIT License 4 */ 5 6 #ifndef _ACPI_H 7 #define _ACPI_H 8 9 #include <device_manager.h> 10 #include <bus_manager.h> 11 #include <KernelExport.h> 12 13 typedef struct acpi_module_info acpi_module_info; 14 typedef struct acpi_object_type acpi_object_type; 15 16 struct acpi_module_info { 17 bus_manager_info binfo; 18 19 /* Fixed Event Management */ 20 21 void (*enable_fixed_event) (uint32 event); 22 void (*disable_fixed_event) (uint32 event); 23 24 uint32 (*fixed_event_status) (uint32 event); 25 /* Returns 1 if event set, 0 otherwise */ 26 void (*reset_fixed_event) (uint32 event); 27 28 status_t (*install_fixed_event_handler) (uint32 event, interrupt_handler *handler, void *data); 29 status_t (*remove_fixed_event_handler) (uint32 event, interrupt_handler *handler); 30 31 /* Namespace Access */ 32 33 status_t (*get_next_entry) (uint32 object_type, const char *base, char *result, size_t len, void **counter); 34 status_t (*get_device) (const char *hid, uint32 index, char *result); 35 36 status_t (*get_device_hid) (const char *path, char *hid); 37 uint32 (*get_object_type) (const char *path); 38 status_t (*get_object) (const char *path, acpi_object_type **return_value); 39 status_t (*get_object_typed) (const char *path, acpi_object_type **return_value, uint32 object_type); 40 41 /* Control method execution and data acquisition */ 42 43 status_t (*evaluate_object) (const char *object, acpi_object_type *return_value, size_t buf_len); 44 status_t (*evaluate_method) (const char *object, const char *method, acpi_object_type *return_value, size_t buf_len, acpi_object_type *args, int num_args); 45 /* Power state setting */ 46 47 status_t (*enter_sleep_state) (uint8 state); 48 /* Sleep state values: 49 0: On (Working) 50 1: Sleep 51 2: Software Off 52 3: Mechanical Off 53 4: Hibernate 54 5: Software Off */ 55 }; 56 57 58 #ifndef __ACTYPES_H__ 59 60 /* ACPI fixed event types */ 61 62 enum { 63 ACPI_EVENT_PMTIMER = 0, 64 ACPI_EVENT_GLOBAL, 65 ACPI_EVENT_POWER_BUTTON, 66 ACPI_EVENT_SLEEP_BUTTON, 67 ACPI_EVENT_RTC 68 }; 69 70 /* ACPI Object Types */ 71 72 enum { 73 ACPI_TYPE_ANY = 0, 74 ACPI_TYPE_INTEGER, 75 ACPI_TYPE_STRING, 76 ACPI_TYPE_BUFFER, 77 ACPI_TYPE_PACKAGE, 78 ACPI_TYPE_FIELD_UNIT, 79 ACPI_TYPE_DEVICE, 80 ACPI_TYPE_EVENT, 81 ACPI_TYPE_METHOD, 82 ACPI_TYPE_MUTEX, 83 ACPI_TYPE_REGION, 84 ACPI_TYPE_POWER, 85 ACPI_TYPE_PROCESSOR, 86 ACPI_TYPE_THERMAL, 87 ACPI_TYPE_BUFFER_FIELD 88 }; 89 90 /* ACPI control method arg type */ 91 92 struct acpi_object_type { 93 uint32 object_type; 94 union { 95 uint32 integer; 96 struct { 97 uint32 len; 98 char *string; /* You have to allocate string space yourself */ 99 } string; 100 struct { 101 size_t length; 102 void *buffer; 103 } buffer; 104 struct { 105 uint32 count; 106 acpi_object_type *objects; 107 } package; 108 struct { 109 uint32 cpu_id; 110 111 int pblk_address; 112 size_t pblk_length; 113 } processor; 114 struct { 115 uint32 min_power_state; 116 uint32 resource_order; 117 } power_resource; 118 } data; 119 }; 120 121 #endif 122 123 #define B_ACPI_MODULE_NAME "bus_managers/acpi/v1" 124 125 #define ACPI_DEVICE_HID_ITEM "acpi/hid" 126 #define ACPI_DEVICE_PATH_ITEM "acpi/path" 127 #define ACPI_DEVICE_TYPE_ITEM "acpi/type" 128 129 130 typedef struct acpi_device_info *acpi_device; 131 132 // Interface to one ACPI device. 133 typedef struct acpi_device_module_info { 134 driver_module_info info; 135 136 /* Namespace Access */ 137 uint32 (*get_object_type) (acpi_device device); 138 status_t (*get_object) (acpi_device device, const char *path, acpi_object_type **return_value); 139 140 /* Control method execution and data acquisition */ 141 status_t (*evaluate_method) (acpi_device device, const char *method, acpi_object_type *return_value, size_t buf_len, acpi_object_type *args, int num_args); 142 143 } acpi_device_module_info; 144 145 146 #endif /* _ACPI_H */ 147