Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenacpi_bus.h
Go to the documentation of this file.
00001 /* 00002 * acpi_bus.h - ACPI Bus Driver ($Revision: 22 $) 00003 * 00004 * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com> 00005 * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com> 00006 * 00007 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 00008 * 00009 * This program is free software; you can redistribute it and/or modify 00010 * it under the terms of the GNU General Public License as published by 00011 * the Free Software Foundation; either version 2 of the License, or (at 00012 * your option) any later version. 00013 * 00014 * This program is distributed in the hope that it will be useful, but 00015 * WITHOUT ANY WARRANTY; without even the implied warranty of 00016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00017 * General Public License for more details. 00018 * 00019 * You should have received a copy of the GNU General Public License along 00020 * with this program; if not, write to the Free Software Foundation, Inc., 00021 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. 00022 * 00023 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 00024 */ 00025 00026 #ifndef __ACPI_BUS_H__ 00027 #define __ACPI_BUS_H__ 00028 00029 #include <acpi.h> 00030 00031 #include "list.h" 00032 00033 00034 /* TBD: Make dynamic */ 00035 #define ACPI_MAX_HANDLES 10 00036 struct acpi_handle_list { 00037 UINT32 count; 00038 ACPI_HANDLE handles[ACPI_MAX_HANDLES]; 00039 }; 00040 00041 00042 /* acpi_utils.h */ 00043 ACPI_STATUS 00044 acpi_extract_package ( 00045 ACPI_OBJECT *package, 00046 ACPI_BUFFER *format, 00047 ACPI_BUFFER *buffer); 00048 ACPI_STATUS 00049 acpi_evaluate_integer ( 00050 ACPI_HANDLE handle, 00051 ACPI_STRING pathname, 00052 struct acpi_object_list *arguments, 00053 unsigned long long *data); 00054 ACPI_STATUS 00055 acpi_evaluate_reference ( 00056 ACPI_HANDLE handle, 00057 ACPI_STRING pathname, 00058 struct acpi_object_list *arguments, 00059 struct acpi_handle_list *list); 00060 00061 enum acpi_bus_removal_type { 00062 ACPI_BUS_REMOVAL_NORMAL = 0, 00063 ACPI_BUS_REMOVAL_EJECT, 00064 ACPI_BUS_REMOVAL_SUPRISE, 00065 ACPI_BUS_REMOVAL_TYPE_COUNT 00066 }; 00067 00068 enum acpi_bus_device_type { 00069 ACPI_BUS_TYPE_DEVICE = 0, 00070 ACPI_BUS_TYPE_POWER, 00071 ACPI_BUS_TYPE_PROCESSOR, 00072 ACPI_BUS_TYPE_THERMAL, 00073 ACPI_BUS_TYPE_SYSTEM, 00074 ACPI_BUS_TYPE_POWER_BUTTON, 00075 ACPI_BUS_TYPE_SLEEP_BUTTON, 00076 ACPI_BUS_TYPE_POWER_BUTTONF, 00077 ACPI_BUS_TYPE_SLEEP_BUTTONF, 00078 ACPI_BUS_DEVICE_TYPE_COUNT 00079 }; 00080 00081 struct acpi_driver; 00082 struct acpi_device; 00083 00084 00085 /* 00086 * ACPI Driver 00087 * ----------- 00088 */ 00089 00090 typedef int (*acpi_op_add) (struct acpi_device *device); 00091 typedef int (*acpi_op_remove) (struct acpi_device *device, int type); 00092 typedef int (*acpi_op_start) (struct acpi_device *device); 00093 typedef int (*acpi_op_suspend) (struct acpi_device *device, int state); 00094 typedef int (*acpi_op_resume) (struct acpi_device *device, int state); 00095 typedef int (*acpi_op_scan) (struct acpi_device *device); 00096 typedef int (*acpi_op_bind) (struct acpi_device *device); 00097 typedef int (*acpi_op_unbind) (struct acpi_device * device); 00098 typedef void (*acpi_op_notify) (struct acpi_device * device, UINT32 event); 00099 00100 struct acpi_bus_ops { 00101 UINT32 acpi_op_add:1; 00102 UINT32 acpi_op_start:1; 00103 }; 00104 00105 struct acpi_device_ops { 00106 acpi_op_add add; 00107 acpi_op_remove remove; 00108 acpi_op_start start; 00109 acpi_op_suspend suspend; 00110 acpi_op_resume resume; 00111 acpi_op_bind bind; 00112 acpi_op_unbind unbind; 00113 acpi_op_notify notify; 00114 acpi_op_scan scan; 00115 }; 00116 00117 #define ACPI_DRIVER_ALL_NOTIFY_EVENTS 0x1 /* system AND device events */ 00118 00119 struct acpi_driver { 00120 struct list_head node; 00121 char name[80]; 00122 char class[80]; 00123 int references; 00124 unsigned int flags; 00125 char *ids; /* Supported Hardware IDs */ 00126 struct acpi_device_ops ops; 00127 }; 00128 00129 /* 00130 * ACPI Device 00131 * ----------- 00132 */ 00133 00134 /* Status (_STA) */ 00135 00136 struct acpi_device_status { 00137 UINT32 present:1; 00138 UINT32 enabled:1; 00139 UINT32 show_in_ui:1; 00140 UINT32 functional:1; 00141 UINT32 battery_present:1; 00142 UINT32 reserved:27; 00143 }; 00144 00145 00146 /* Flags */ 00147 00148 struct acpi_device_flags { 00149 UINT32 dynamic_status:1; 00150 UINT32 hardware_id:1; 00151 UINT32 compatible_ids:1; 00152 UINT32 bus_address:1; 00153 UINT32 unique_id:1; 00154 UINT32 removable:1; 00155 UINT32 ejectable:1; 00156 UINT32 lockable:1; 00157 UINT32 suprise_removal_ok:1; 00158 UINT32 power_manageable:1; 00159 UINT32 performance_manageable:1; 00160 UINT32 wake_capable:1; 00161 UINT32 force_power_state:1; 00162 UINT32 reserved:20; 00163 }; 00164 00165 /* Plug and Play */ 00166 00167 typedef char acpi_bus_id[8]; 00168 typedef unsigned long acpi_bus_address; 00169 typedef char acpi_hardware_id[9]; 00170 typedef char acpi_unique_id[9]; 00171 typedef char acpi_device_name[40]; 00172 typedef char acpi_device_class[20]; 00173 00174 struct acpi_device_pnp { 00175 acpi_bus_id bus_id; /* Object name */ 00176 acpi_bus_address bus_address; /* _ADR */ 00177 acpi_hardware_id hardware_id; /* _HID */ 00178 ACPI_DEVICE_ID_LIST *cid_list; /* _CIDs */ 00179 acpi_unique_id unique_id; /* _UID */ 00180 acpi_device_name device_name; /* Driver-determined */ 00181 acpi_device_class device_class; /* " */ 00182 }; 00183 00184 #define acpi_device_bid(d) ((d)->pnp.bus_id) 00185 #define acpi_device_adr(d) ((d)->pnp.bus_address) 00186 #define acpi_device_hid(d) ((d)->pnp.hardware_id) 00187 #define acpi_device_uid(d) ((d)->pnp.unique_id) 00188 #define acpi_device_name(d) ((d)->pnp.device_name) 00189 #define acpi_device_class(d) ((d)->pnp.device_class) 00190 00191 00192 /* Power Management */ 00193 00194 struct acpi_device_power_flags { 00195 UINT32 explicit_get:1; /* _PSC present? */ 00196 UINT32 power_resources:1; /* Power resources */ 00197 UINT32 inrush_current:1; /* Serialize Dx->D0 */ 00198 UINT32 power_removed:1; /* Optimize Dx->D0 */ 00199 UINT32 reserved:28; 00200 }; 00201 00202 struct acpi_device_power_state { 00203 struct { 00204 UINT8 valid:1; 00205 UINT8 explicit_set:1; /* _PSx present? */ 00206 UINT8 reserved:6; 00207 } flags; 00208 int power; /* % Power (compared to D0) */ 00209 int latency; /* Dx->D0 time (microseconds) */ 00210 struct acpi_handle_list resources; /* Power resources referenced */ 00211 }; 00212 00213 struct acpi_device_power { 00214 int state; /* Current state */ 00215 struct acpi_device_power_flags flags; 00216 struct acpi_device_power_state states[4]; /* Power states (D0-D3) */ 00217 }; 00218 00219 00220 /* Performance Management */ 00221 00222 struct acpi_device_perf_flags { 00223 UINT8 reserved:8; 00224 }; 00225 00226 struct acpi_device_perf_state { 00227 struct { 00228 UINT8 valid:1; 00229 UINT8 reserved:7; 00230 } flags; 00231 UINT8 power; /* % Power (compared to P0) */ 00232 UINT8 performance; /* % Performance ( " ) */ 00233 int latency; /* Px->P0 time (microseconds) */ 00234 }; 00235 00236 struct acpi_device_perf { 00237 int state; 00238 struct acpi_device_perf_flags flags; 00239 int state_count; 00240 struct acpi_device_perf_state *states; 00241 }; 00242 00243 /* Wakeup Management */ 00244 struct acpi_device_wakeup_flags { 00245 UINT8 valid:1; /* Can successfully enable wakeup? */ 00246 UINT8 run_wake:1; /* Run-Wake GPE devices */ 00247 }; 00248 00249 struct acpi_device_wakeup_state { 00250 UINT8 enabled:1; 00251 }; 00252 00253 struct acpi_device_wakeup { 00254 ACPI_HANDLE gpe_device; 00255 ACPI_INTEGER gpe_number; 00256 ACPI_INTEGER sleep_state; 00257 struct acpi_handle_list resources; 00258 struct acpi_device_wakeup_state state; 00259 struct acpi_device_wakeup_flags flags; 00260 int prepare_count; 00261 }; 00262 00263 00264 /* Device */ 00265 00266 struct acpi_device { 00267 int device_type; 00268 ACPI_HANDLE handle; 00269 struct acpi_device *parent; 00270 struct list_head children; 00271 struct list_head node; 00272 struct list_head wakeup_list; 00273 struct acpi_device_status status; 00274 struct acpi_device_flags flags; 00275 struct acpi_device_pnp pnp; 00276 struct acpi_device_power power; 00277 struct acpi_device_wakeup wakeup; 00278 struct acpi_device_perf performance; 00279 struct acpi_device_ops ops; 00280 struct acpi_driver *driver; 00281 void *driver_data; 00282 struct acpi_bus_ops bus_ops; /* workaround for different code path for hotplug */ 00283 enum acpi_bus_removal_type removal_type; /* indicate for different removal type */ 00284 00285 }; 00286 00287 #define acpi_driver_data(d) ((d)->driver_data) 00288 00289 #define to_acpi_device(d) container_of(d, struct acpi_device, dev) 00290 #define to_acpi_driver(d) container_of(d, struct acpi_driver, drv) 00291 00292 /* acpi_device.dev.bus == &acpi_bus_type */ 00293 extern struct bus_type acpi_bus_type; 00294 00295 /* 00296 * Events 00297 * ------ 00298 */ 00299 00300 struct acpi_bus_event { 00301 struct list_head node; 00302 acpi_device_class device_class; 00303 acpi_bus_id bus_id; 00304 UINT32 type; 00305 UINT32 data; 00306 }; 00307 00308 00309 /* 00310 * External Functions 00311 */ 00312 int acpi_bus_get_private_data(ACPI_HANDLE, void **); 00313 00314 void acpi_bus_data_handler(ACPI_HANDLE handle, void *context); 00315 ACPI_STATUS acpi_bus_get_status_handle(ACPI_HANDLE handle, 00316 unsigned long long *sta); 00317 int acpi_bus_get_status(struct acpi_device *device); 00318 int acpi_bus_get_power(ACPI_HANDLE handle, int *state); 00319 int acpi_bus_set_power(ACPI_HANDLE handle, int state); 00320 BOOLEAN acpi_bus_power_manageable(ACPI_HANDLE handle); 00321 BOOLEAN acpi_bus_can_wakeup(ACPI_HANDLE handle); 00322 int acpi_bus_generate_proc_event(struct acpi_device *device, UINT8 type, int data); 00323 int acpi_bus_generate_event(struct acpi_device *device, UINT8 type, int data); 00324 int acpi_bus_receive_event(struct acpi_bus_event *event); 00325 int acpi_bus_register_driver(struct acpi_driver *driver); 00326 void acpi_bus_unregister_driver(struct acpi_driver *driver); 00327 int acpi_bus_add(struct acpi_device **child, struct acpi_device *parent, 00328 ACPI_HANDLE handle, int type); 00329 int acpi_bus_trim(struct acpi_device *start, int rmdevice); 00330 int acpi_bus_start(struct acpi_device *device); 00331 ACPI_STATUS acpi_bus_get_ejd(ACPI_HANDLE handle, ACPI_HANDLE * ejd); 00332 int acpi_match_device_ids(struct acpi_device *device, 00333 const struct acpi_device_id *ids); 00334 int acpi_bus_get_device(ACPI_HANDLE handle, struct acpi_device **device); 00335 int acpi_init(void); 00336 ACPI_STATUS acpi_suspend (UINT32 state); 00337 00338 /* 00339 * Bind physical devices with ACPI devices 00340 */ 00341 //struct acpi_bus_type { 00342 // struct list_head list; 00343 // struct bus_type *bus; 00344 // /* For general devices under the bus */ 00345 // int (*find_device) (struct device *, ACPI_HANDLE *); 00346 // /* For bridges, such as PCI root bridge, IDE controller */ 00347 // int (*find_bridge) (struct device *, ACPI_HANDLE *); 00348 //}; 00349 //int register_acpi_bus_type(struct acpi_bus_type *); 00350 //int unregister_acpi_bus_type(struct acpi_bus_type *); 00351 //struct device *acpi_get_physical_device(ACPI_HANDLE); 00352 00353 struct acpi_pci_root { 00354 struct list_head node; 00355 struct acpi_device * device; 00356 struct acpi_pci_id id; 00357 struct pci_bus *bus; 00358 UINT16 segment; 00359 UINT8 bus_nr; 00360 00361 UINT32 osc_support_set; /* _OSC state of support bits */ 00362 UINT32 osc_control_set; /* _OSC state of control bits */ 00363 UINT32 osc_control_qry; /* the latest _OSC query result */ 00364 00365 UINT32 osc_queried:1; /* has _OSC control been queried? */ 00366 }; 00367 00368 //static inline int acpi_pm_device_sleep_state(struct device *d, int *p) 00369 //{ 00370 // if (p) 00371 // *p = ACPI_STATE_D0; 00372 // return ACPI_STATE_D3; 00373 //} 00374 //static inline int acpi_pm_device_sleep_wake(struct device *dev, bool enable) 00375 //{ 00376 // return -1; 00377 //} 00378 00379 /* system defines: move to bigger header */ 00380 extern enum acpi_irq_model_id acpi_irq_model; 00381 00382 enum acpi_irq_model_id { 00383 ACPI_IRQ_MODEL_PIC = 0, 00384 ACPI_IRQ_MODEL_IOAPIC, 00385 ACPI_IRQ_MODEL_IOSAPIC, 00386 ACPI_IRQ_MODEL_COUNT 00387 }; 00388 00389 00390 00391 #endif /*__ACPI_BUS_H__*/ Generated on Sun May 27 2012 04:27:26 for ReactOS by
1.7.6.1
|