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 29extern device_manager_info* gDeviceManager; 30extern pci_module_info* gPCIManager; 31 32// information about one ACPI device 33typedef 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. 43typedef 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)(acpi_handle handle, const char* object, 119 acpi_objects *args, acpi_object_type *returnValue, 120 size_t bufferLength); 121 status_t (*evaluate_method)(acpi_handle handle, const char *method, 122 acpi_objects *args, acpi_data *returnValue); 123 124 /* Resource info */ 125 126 status_t (*get_irq_routing_table)(acpi_handle busDeviceHandle, 127 acpi_data *retBuffer); 128 status_t (*get_current_resources)(acpi_handle busDeviceHandle, 129 acpi_data *retBuffer); 130 status_t (*get_possible_resources)(acpi_handle busDeviceHandle, 131 acpi_data *retBuffer); 132 status_t (*set_current_resources)(acpi_handle busDeviceHandle, 133 acpi_data *buffer); 134 135 /* Power state setting */ 136 137 status_t (*prepare_sleep_state)(uint8 state, void (*wakeFunc)(void), 138 size_t size); 139 status_t (*enter_sleep_state)(uint8 state); 140 status_t (*reboot)(void); 141 142 /* Table Access */ 143 status_t (*get_table)(const char *signature, uint32 instance, 144 void **tableHeader); 145} acpi_root_info; 146 147 148extern struct acpi_module_info gACPIModule; 149 150extern struct device_module_info acpi_ns_dump_module; 151 152extern struct driver_module_info embedded_controller_driver_module; 153extern struct device_module_info embedded_controller_device_module; 154 155extern acpi_device_module_info gACPIDeviceModule; 156 157 158status_t get_handle(acpi_handle parent, const char* pathname, 159 acpi_handle* retHandle); 160 161status_t acquire_global_lock(uint16 timeout, uint32* handle); 162status_t release_global_lock(uint32 handle); 163 164status_t install_notify_handler(acpi_handle device, uint32 handlerType, 165 acpi_notify_handler handler, void* context); 166status_t remove_notify_handler(acpi_handle device, uint32 handlerType, 167 acpi_notify_handler handler); 168 169status_t update_all_gpes(); 170status_t enable_gpe(acpi_handle handle, uint32 gpeNumber); 171status_t disable_gpe(acpi_handle handle, uint32 gpeNumber); 172status_t clear_gpe(acpi_handle handle, uint32 gpeNumber); 173status_t set_gpe(acpi_handle handle, uint32 gpeNumber, uint8 action); 174status_t finish_gpe(acpi_handle handle, uint32 gpeNumber); 175status_t install_gpe_handler(acpi_handle handle, uint32 gpeNumber, uint32 type, 176 acpi_gpe_handler handler, void* data); 177status_t remove_gpe_handler(acpi_handle handle, uint32 gpeNumber, 178 acpi_gpe_handler address); 179 180status_t install_address_space_handler(acpi_handle handle, uint32 spaceID, 181 acpi_adr_space_handler handler, acpi_adr_space_setup setup, void* data); 182status_t remove_address_space_handler(acpi_handle handle, uint32 spaceID, 183 acpi_adr_space_handler handler); 184 185void enable_fixed_event(uint32 event); 186void disable_fixed_event(uint32 event); 187 188uint32 fixed_event_status(uint32 event); 189void reset_fixed_event(uint32 event); 190 191status_t install_fixed_event_handler(uint32 event, interrupt_handler* handler, 192 void* data); 193status_t remove_fixed_event_handler(uint32 event, interrupt_handler* handler); 194 195status_t get_next_entry(uint32 object_type, const char* base, char* result, 196 size_t length, void** _counter); 197status_t get_device(const char* hid, uint32 index, char* result, 198 size_t resultLength); 199 200status_t get_device_hid(const char* path, char* hid, size_t hidLength); 201uint32 get_object_type(const char* path); 202status_t get_object(const char* path, acpi_object_type** _returnValue); 203status_t get_object_typed(const char* path, acpi_object_type** _returnValue, 204 uint32 object_type); 205status_t ns_handle_to_pathname(acpi_handle targetHandle, acpi_data* buffer); 206 207status_t evaluate_object(acpi_handle handle, const char* object, 208 acpi_objects* args, acpi_object_type* returnValue, size_t bufferLength); 209status_t evaluate_method(acpi_handle handle, const char* method, 210 acpi_objects* args, acpi_data* returnValue); 211 212status_t get_irq_routing_table(acpi_handle busDeviceHandle, 213 acpi_data* returnValue); 214status_t get_current_resources(acpi_handle busDeviceHandle, 215 acpi_data* returnValue); 216status_t get_possible_resources(acpi_handle busDeviceHandle, 217 acpi_data* returnValue); 218status_t set_current_resources(acpi_handle busDeviceHandle, 219 acpi_data* buffer); 220 221status_t prepare_sleep_state(uint8 state, void (*wakeFunc)(void), size_t size); 222status_t enter_sleep_state(uint8 state); 223 224status_t reboot(void); 225 226status_t get_table(const char* signature, uint32 instance, void** tableHeader); 227 228__END_DECLS 229 230 231#endif /* _ACPI_PRIVATE_H */ 232