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 27 __BEGIN_DECLS 28 29 extern device_manager_info* gDeviceManager; 30 extern pci_module_info* gPCIManager; 31 32 // information about one ACPI device 33 typedef struct acpi_device_cookie { 34 char* path; // path 35 acpi_handle handle; 36 uint32 type; // type 37 device_node* node; 38 char name[32]; // name (for fast log) 39 } acpi_device_cookie; 40 41 42 // ACPI root. 43 typedef struct acpi_root_info { 44 driver_module_info info; 45 46 status_t (*get_handle)(acpi_handle parent, const char *pathname, 47 acpi_handle *retHandle); 48 49 /* Global Lock */ 50 51 status_t (*acquire_global_lock)(uint16 timeout, uint32 *handle); 52 status_t (*release_global_lock)(uint32 handle); 53 54 /* Notify Handler */ 55 56 status_t (*install_notify_handler)(acpi_handle device, 57 uint32 handlerType, acpi_notify_handler handler, 58 void *context); 59 status_t (*remove_notify_handler)(acpi_handle device, 60 uint32 handlerType, acpi_notify_handler handler); 61 62 /* GPE Handler */ 63 status_t (*update_all_gpes)(); 64 status_t (*enable_gpe)(acpi_handle handle, uint32 gpeNumber); 65 status_t (*disable_gpe)(acpi_handle handle, uint32 gpeNumber); 66 status_t (*clear_gpe)(acpi_handle handle, uint32 gpeNumber); 67 status_t (*set_gpe)(acpi_handle handle, uint32 gpeNumber, 68 uint8 action); 69 status_t (*finish_gpe)(acpi_handle handle, uint32 gpeNumber); 70 status_t (*install_gpe_handler)(acpi_handle handle, uint32 gpeNumber, 71 uint32 type, acpi_gpe_handler handler, void *data); 72 status_t (*remove_gpe_handler)(acpi_handle handle, uint32 gpeNumber, 73 acpi_gpe_handler address); 74 75 /* Address Space Handler */ 76 77 status_t (*install_address_space_handler)(acpi_handle handle, 78 uint32 spaceId, 79 acpi_adr_space_handler handler, 80 acpi_adr_space_setup setup, void *data); 81 status_t (*remove_address_space_handler)(acpi_handle handle, 82 uint32 spaceId, 83 acpi_adr_space_handler handler); 84 85 /* Fixed Event Management */ 86 87 void (*enable_fixed_event)(uint32 event); 88 void (*disable_fixed_event)(uint32 event); 89 90 uint32 (*fixed_event_status) (uint32 event); 91 /* Returns 1 if event set, 0 otherwise */ 92 void (*reset_fixed_event) (uint32 event); 93 94 status_t (*install_fixed_event_handler)(uint32 event, 95 interrupt_handler *handler, void *data); 96 status_t (*remove_fixed_event_handler)(uint32 event, 97 interrupt_handler *handler); 98 99 /* Namespace Access */ 100 101 status_t (*get_next_entry)(uint32 objectType, const char *base, 102 char *result, size_t length, void **_counter); 103 status_t (*get_device)(const char *hid, uint32 index, char *result, 104 size_t resultLength); 105 106 status_t (*get_device_hid)(const char *path, char *hid, 107 size_t hidLength); 108 uint32 (*get_object_type)(const char *path); 109 status_t (*get_object)(const char *path, 110 acpi_object_type **_returnValue); 111 status_t (*get_object_typed)(const char *path, 112 acpi_object_type **_returnValue, uint32 objectType); 113 status_t (*ns_handle_to_pathname)(acpi_handle targetHandle, 114 acpi_data *buffer); 115 116 /* Control method execution and data acquisition */ 117 118 status_t (*evaluate_object)(const char* object, 119 acpi_object_type *returnValue, size_t bufferLength); 120 status_t (*evaluate_method)(acpi_handle handle, const char *method, 121 acpi_objects *args, acpi_data *returnValue); 122 123 /* Resource info */ 124 125 status_t (*get_irq_routing_table)(acpi_handle busDeviceHandle, 126 acpi_data *retBuffer); 127 status_t (*get_current_resources)(acpi_handle busDeviceHandle, 128 acpi_data *retBuffer); 129 status_t (*get_possible_resources)(acpi_handle busDeviceHandle, 130 acpi_data *retBuffer); 131 status_t (*set_current_resources)(acpi_handle busDeviceHandle, 132 acpi_data *buffer); 133 134 /* Power state setting */ 135 136 status_t (*prepare_sleep_state)(uint8 state, void (*wakeFunc)(void), 137 size_t size); 138 status_t (*enter_sleep_state)(uint8 state); 139 status_t (*reboot)(void); 140 141 /* Table Access */ 142 status_t (*get_table)(const char *signature, uint32 instance, 143 void **tableHeader); 144 } acpi_root_info; 145 146 147 extern struct acpi_module_info gACPIModule; 148 149 extern struct device_module_info acpi_ns_dump_module; 150 151 extern struct driver_module_info embedded_controller_driver_module; 152 extern struct device_module_info embedded_controller_device_module; 153 154 extern acpi_device_module_info gACPIDeviceModule; 155 156 157 status_t get_handle(acpi_handle parent, const char* pathname, 158 acpi_handle* retHandle); 159 160 status_t acquire_global_lock(uint16 timeout, uint32* handle); 161 status_t release_global_lock(uint32 handle); 162 163 status_t install_notify_handler(acpi_handle device, uint32 handlerType, 164 acpi_notify_handler handler, void* context); 165 status_t remove_notify_handler(acpi_handle device, uint32 handlerType, 166 acpi_notify_handler handler); 167 168 status_t update_all_gpes(); 169 status_t enable_gpe(acpi_handle handle, uint32 gpeNumber); 170 status_t disable_gpe(acpi_handle handle, uint32 gpeNumber); 171 status_t clear_gpe(acpi_handle handle, uint32 gpeNumber); 172 status_t set_gpe(acpi_handle handle, uint32 gpeNumber, uint8 action); 173 status_t finish_gpe(acpi_handle handle, uint32 gpeNumber); 174 status_t install_gpe_handler(acpi_handle handle, uint32 gpeNumber, uint32 type, 175 acpi_gpe_handler handler, void* data); 176 status_t remove_gpe_handler(acpi_handle handle, uint32 gpeNumber, 177 acpi_gpe_handler address); 178 179 status_t install_address_space_handler(acpi_handle handle, uint32 spaceID, 180 acpi_adr_space_handler handler, acpi_adr_space_setup setup, void* data); 181 status_t remove_address_space_handler(acpi_handle handle, uint32 spaceID, 182 acpi_adr_space_handler handler); 183 184 void enable_fixed_event(uint32 event); 185 void disable_fixed_event(uint32 event); 186 187 uint32 fixed_event_status(uint32 event); 188 void reset_fixed_event(uint32 event); 189 190 status_t install_fixed_event_handler(uint32 event, interrupt_handler* handler, 191 void* data); 192 status_t remove_fixed_event_handler(uint32 event, interrupt_handler* handler); 193 194 status_t get_next_entry(uint32 object_type, const char* base, char* result, 195 size_t length, void** _counter); 196 status_t get_device(const char* hid, uint32 index, char* result, 197 size_t resultLength); 198 199 status_t get_device_hid(const char* path, char* hid, size_t hidLength); 200 uint32 get_object_type(const char* path); 201 status_t get_object(const char* path, acpi_object_type** _returnValue); 202 status_t get_object_typed(const char* path, acpi_object_type** _returnValue, 203 uint32 object_type); 204 status_t ns_handle_to_pathname(acpi_handle targetHandle, acpi_data* buffer); 205 206 status_t evaluate_object(const char* object, acpi_object_type* returnValue, 207 size_t bufferLength); 208 status_t evaluate_method(acpi_handle handle, const char* method, 209 acpi_objects* args, acpi_data* returnValue); 210 211 status_t get_irq_routing_table(acpi_handle busDeviceHandle, 212 acpi_data* returnValue); 213 status_t get_current_resources(acpi_handle busDeviceHandle, 214 acpi_data* returnValue); 215 status_t get_possible_resources(acpi_handle busDeviceHandle, 216 acpi_data* returnValue); 217 status_t set_current_resources(acpi_handle busDeviceHandle, 218 acpi_data* buffer); 219 220 status_t prepare_sleep_state(uint8 state, void (*wakeFunc)(void), size_t size); 221 status_t enter_sleep_state(uint8 state); 222 223 status_t reboot(void); 224 225 status_t get_table(const char* signature, uint32 instance, void** tableHeader); 226 227 __END_DECLS 228 229 230 #endif /* _ACPI_PRIVATE_H */ 231