1 /* 2 * Copyright 2009, Clemens Zeidler. All rights reserved. 3 * Copyright 2006, Jérôme Duval. All rights reserved. 4 * Distributed under the terms of the MIT License. 5 */ 6 #ifndef _ACPI_PRIVATE_H 7 #define _ACPI_PRIVATE_H 8 9 10 #include <sys/cdefs.h> 11 12 #include <device_manager.h> 13 #include <KernelExport.h> 14 #include <ACPI.h> 15 #include <PCI.h> 16 17 // name of ACPI root module 18 #define ACPI_ROOT_MODULE_NAME "bus_managers/acpi/root/driver_v1" 19 20 // name of ACPI device modules 21 #define ACPI_DEVICE_MODULE_NAME "bus_managers/acpi/driver_v1" 22 23 // name of the ACPI namespace device 24 #define ACPI_NS_DUMP_DEVICE_MODULE_NAME "bus_managers/acpi/namespace/device_v1" 25 26 // name of the ACPI call device 27 #define ACPI_CALL_DEVICE_MODULE_NAME "bus_managers/acpi/call/device_v1" 28 29 30 __BEGIN_DECLS 31 32 extern device_manager_info* gDeviceManager; 33 extern pci_module_info* gPCIManager; 34 35 // information about one ACPI device 36 typedef struct acpi_device_cookie { 37 char* path; // path 38 acpi_handle handle; 39 uint32 type; // type 40 device_node* node; 41 char name[32]; // name (for fast log) 42 } acpi_device_cookie; 43 44 45 typedef struct acpi_resource acpi_resource; 46 typedef acpi_status (*acpi_walk_resources_callback)(acpi_resource* resource, 47 void* context); 48 49 50 // ACPI root. 51 typedef struct acpi_root_info { 52 driver_module_info info; 53 54 status_t (*get_handle)(acpi_handle parent, const char *pathname, 55 acpi_handle *retHandle); 56 status_t (*get_name)(acpi_handle handle, uint32 nameType, 57 char* returnedName, size_t bufferLength); 58 59 /* Global Lock */ 60 61 status_t (*acquire_global_lock)(uint16 timeout, uint32 *handle); 62 status_t (*release_global_lock)(uint32 handle); 63 64 /* Notify Handler */ 65 66 status_t (*install_notify_handler)(acpi_handle device, 67 uint32 handlerType, acpi_notify_handler handler, 68 void *context); 69 status_t (*remove_notify_handler)(acpi_handle device, 70 uint32 handlerType, acpi_notify_handler handler); 71 72 /* GPE Handler */ 73 status_t (*update_all_gpes)(); 74 status_t (*enable_gpe)(acpi_handle handle, uint32 gpeNumber); 75 status_t (*disable_gpe)(acpi_handle handle, uint32 gpeNumber); 76 status_t (*clear_gpe)(acpi_handle handle, uint32 gpeNumber); 77 status_t (*set_gpe)(acpi_handle handle, uint32 gpeNumber, 78 uint8 action); 79 status_t (*finish_gpe)(acpi_handle handle, uint32 gpeNumber); 80 status_t (*install_gpe_handler)(acpi_handle handle, uint32 gpeNumber, 81 uint32 type, acpi_gpe_handler handler, void *data); 82 status_t (*remove_gpe_handler)(acpi_handle handle, uint32 gpeNumber, 83 acpi_gpe_handler address); 84 85 /* Address Space Handler */ 86 87 status_t (*install_address_space_handler)(acpi_handle handle, 88 uint32 spaceId, 89 acpi_adr_space_handler handler, 90 acpi_adr_space_setup setup, void *data); 91 status_t (*remove_address_space_handler)(acpi_handle handle, 92 uint32 spaceId, 93 acpi_adr_space_handler handler); 94 95 /* Fixed Event Management */ 96 97 void (*enable_fixed_event)(uint32 event); 98 void (*disable_fixed_event)(uint32 event); 99 100 uint32 (*fixed_event_status) (uint32 event); 101 /* Returns 1 if event set, 0 otherwise */ 102 void (*reset_fixed_event) (uint32 event); 103 104 status_t (*install_fixed_event_handler)(uint32 event, 105 acpi_event_handler handler, void *data); 106 status_t (*remove_fixed_event_handler)(uint32 event, 107 acpi_event_handler handler); 108 109 /* Namespace Access */ 110 111 status_t (*get_next_entry)(uint32 objectType, const char *base, 112 char *result, size_t length, void **_counter); 113 status_t (*get_next_object)(uint32 objectType, acpi_handle parent, 114 acpi_handle* currentChild); 115 status_t (*get_device)(const char *hid, uint32 index, char *result, 116 size_t resultLength); 117 118 status_t (*get_device_info)(const char *path, char **hid, 119 char** cidList, size_t cidListCount, char** uid); 120 uint32 (*get_object_type)(const char *path); 121 status_t (*get_object)(const char *path, 122 acpi_object_type **_returnValue); 123 status_t (*get_object_typed)(const char *path, 124 acpi_object_type **_returnValue, uint32 objectType); 125 status_t (*ns_handle_to_pathname)(acpi_handle targetHandle, 126 acpi_data *buffer); 127 128 /* Control method execution and data acquisition */ 129 130 status_t (*evaluate_object)(acpi_handle handle, const char* object, 131 acpi_objects *args, acpi_object_type *returnValue, 132 size_t bufferLength); 133 status_t (*evaluate_method)(acpi_handle handle, const char *method, 134 acpi_objects *args, acpi_data *returnValue); 135 136 /* Resource info */ 137 138 status_t (*get_irq_routing_table)(acpi_handle busDeviceHandle, 139 acpi_data *retBuffer); 140 status_t (*get_current_resources)(acpi_handle busDeviceHandle, 141 acpi_data *retBuffer); 142 status_t (*get_possible_resources)(acpi_handle busDeviceHandle, 143 acpi_data *retBuffer); 144 status_t (*set_current_resources)(acpi_handle busDeviceHandle, 145 acpi_data *buffer); 146 status_t (*walk_resources)(acpi_handle busDeviceHandle, 147 char *method, acpi_walk_resources_callback callback, 148 void* context); 149 150 /* Power state setting */ 151 152 status_t (*prepare_sleep_state)(uint8 state, void (*wakeFunc)(void), 153 size_t size); 154 status_t (*enter_sleep_state)(uint8 state); 155 status_t (*reboot)(void); 156 157 /* Table Access */ 158 status_t (*get_table)(const char *signature, uint32 instance, 159 void **tableHeader); 160 } acpi_root_info; 161 162 163 extern struct acpi_module_info gACPIModule; 164 165 extern struct device_module_info acpi_ns_dump_module; 166 167 extern struct driver_module_info embedded_controller_driver_module; 168 extern struct device_module_info embedded_controller_device_module; 169 170 extern acpi_device_module_info gACPIDeviceModule; 171 172 extern struct device_module_info gAcpiCallDeviceModule; 173 174 175 status_t get_handle(acpi_handle parent, const char* pathname, 176 acpi_handle* retHandle); 177 status_t get_name(acpi_handle handle, uint32 nameType, 178 char* returnedName, size_t bufferLength); 179 180 status_t acquire_global_lock(uint16 timeout, uint32* handle); 181 status_t release_global_lock(uint32 handle); 182 183 status_t install_notify_handler(acpi_handle device, uint32 handlerType, 184 acpi_notify_handler handler, void* context); 185 status_t remove_notify_handler(acpi_handle device, uint32 handlerType, 186 acpi_notify_handler handler); 187 188 status_t update_all_gpes(); 189 status_t enable_gpe(acpi_handle handle, uint32 gpeNumber); 190 status_t disable_gpe(acpi_handle handle, uint32 gpeNumber); 191 status_t clear_gpe(acpi_handle handle, uint32 gpeNumber); 192 status_t set_gpe(acpi_handle handle, uint32 gpeNumber, uint8 action); 193 status_t finish_gpe(acpi_handle handle, uint32 gpeNumber); 194 status_t install_gpe_handler(acpi_handle handle, uint32 gpeNumber, uint32 type, 195 acpi_gpe_handler handler, void* data); 196 status_t remove_gpe_handler(acpi_handle handle, uint32 gpeNumber, 197 acpi_gpe_handler address); 198 199 status_t install_address_space_handler(acpi_handle handle, uint32 spaceID, 200 acpi_adr_space_handler handler, acpi_adr_space_setup setup, void* data); 201 status_t remove_address_space_handler(acpi_handle handle, uint32 spaceID, 202 acpi_adr_space_handler handler); 203 204 void enable_fixed_event(uint32 event); 205 void disable_fixed_event(uint32 event); 206 207 uint32 fixed_event_status(uint32 event); 208 void reset_fixed_event(uint32 event); 209 210 status_t install_fixed_event_handler(uint32 event, acpi_event_handler handler, 211 void* data); 212 status_t remove_fixed_event_handler(uint32 event, acpi_event_handler handler); 213 214 status_t get_next_entry(uint32 object_type, const char* base, char* result, 215 size_t length, void** _counter); 216 status_t get_next_object(uint32 object_type, acpi_handle parent, 217 acpi_handle* currentChild); 218 status_t get_device(const char* hid, uint32 index, char* result, 219 size_t resultLength); 220 221 status_t get_device_info(const char* path, char** hid, char** cidList, 222 size_t cidListCount, char** uniqueId); 223 status_t get_device_addr(const char* path, uint32* addr); 224 uint32 get_object_type(const char* path); 225 status_t get_object(const char* path, acpi_object_type** _returnValue); 226 status_t get_object_typed(const char* path, acpi_object_type** _returnValue, 227 uint32 object_type); 228 status_t ns_handle_to_pathname(acpi_handle targetHandle, acpi_data* buffer); 229 status_t walk_namespace(acpi_handle busDeviceHandle, uint32 objectType, 230 uint32 maxDepth, acpi_walk_callback descendingCallback, 231 acpi_walk_callback ascendingCallback, void* context, void** returnValue); 232 233 234 status_t evaluate_object(acpi_handle handle, const char* object, 235 acpi_objects* args, acpi_object_type* returnValue, size_t bufferLength); 236 status_t evaluate_method(acpi_handle handle, const char* method, 237 acpi_objects* args, acpi_data* returnValue); 238 239 status_t get_irq_routing_table(acpi_handle busDeviceHandle, 240 acpi_data* returnValue); 241 status_t get_current_resources(acpi_handle busDeviceHandle, 242 acpi_data* returnValue); 243 status_t get_possible_resources(acpi_handle busDeviceHandle, 244 acpi_data* returnValue); 245 status_t set_current_resources(acpi_handle busDeviceHandle, 246 acpi_data* buffer); 247 status_t walk_resources(acpi_handle busDeviceHandle, char* method, 248 acpi_walk_resources_callback callback, void* context); 249 250 status_t prepare_sleep_state(uint8 state, void (*wakeFunc)(void), size_t size); 251 status_t enter_sleep_state(uint8 state); 252 253 status_t reboot(void); 254 255 status_t get_table(const char* signature, uint32 instance, void** tableHeader); 256 257 __END_DECLS 258 259 260 #endif /* _ACPI_PRIVATE_H */ 261