xref: /haiku/headers/os/drivers/ACPI.h (revision d3d8b26997fac34a84981e6d2b649521de2cc45a)
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 <bus_manager.h>
10 #include <KernelExport.h>
11 
12 typedef struct acpi_module_info acpi_module_info;
13 typedef struct acpi_object_type acpi_object_type;
14 
15 struct acpi_module_info {
16 	bus_manager_info	binfo;
17 
18 	/* Fixed Event Management */
19 
20 	void				(*enable_fixed_event) (uint32 event);
21 	void				(*disable_fixed_event) (uint32 event);
22 
23 	uint32				(*fixed_event_status) (uint32 event);
24 						/* Returns 1 if event set, 0 otherwise */
25 	void				(*reset_fixed_event) (uint32 event);
26 
27 	status_t			(*install_fixed_event_handler)	(uint32 event, interrupt_handler *handler, void *data);
28 	status_t			(*remove_fixed_event_handler)	(uint32 event, interrupt_handler *handler);
29 
30 	/* Namespace Access */
31 
32 	status_t			(*get_next_entry) (uint32 object_type, const char *base, char *result, size_t len, void **counter);
33 	status_t			(*get_device) (const char *hid, uint32 index, char *result);
34 
35 	status_t			(*get_device_hid) (const char *path, char *hid);
36 	uint32				(*get_object_type) (const char *path);
37 	status_t			(*get_object) (const char *path, acpi_object_type **return_value);
38 	status_t			(*get_object_typed) (const char *path, acpi_object_type **return_value, uint32 object_type);
39 
40 	/* Control method execution and data acquisition */
41 
42 	status_t			(*evaluate_object) (const char *object, acpi_object_type *return_value, size_t buf_len);
43 	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);
44 	/* Power state setting */
45 
46 	status_t			(*enter_sleep_state) (uint8 state);
47 		/* Sleep state values:
48 			0: On (Working)
49 			1: Sleep
50 			2: Software Off
51 			3: Mechanical Off
52 			4: Hibernate
53 			5: Software Off */
54 };
55 
56 
57 #ifndef __ACTYPES_H__
58 
59 /* ACPI fixed event types */
60 
61 enum {
62 	ACPI_EVENT_PMTIMER = 0,
63 	ACPI_EVENT_GLOBAL,
64 	ACPI_EVENT_POWER_BUTTON,
65 	ACPI_EVENT_SLEEP_BUTTON,
66 	ACPI_EVENT_RTC
67 };
68 
69 /* ACPI Object Types */
70 
71 enum {
72 	ACPI_TYPE_ANY = 0,
73 	ACPI_TYPE_INTEGER,
74 	ACPI_TYPE_STRING,
75 	ACPI_TYPE_BUFFER,
76 	ACPI_TYPE_PACKAGE,
77 	ACPI_TYPE_FIELD_UNIT,
78 	ACPI_TYPE_DEVICE,
79 	ACPI_TYPE_EVENT,
80 	ACPI_TYPE_METHOD,
81 	ACPI_TYPE_MUTEX,
82 	ACPI_TYPE_REGION,
83 	ACPI_TYPE_POWER,
84 	ACPI_TYPE_PROCESSOR,
85 	ACPI_TYPE_THERMAL,
86 	ACPI_TYPE_BUFFER_FIELD
87 };
88 
89 /* ACPI control method arg type */
90 
91 struct acpi_object_type {
92 	uint32 object_type;
93 	union {
94 		uint32 integer;
95 		struct {
96 			uint32 len;
97 			char *string; /* You have to allocate string space yourself */
98 		} string;
99 		struct {
100 			size_t length;
101 			void *buffer;
102 		} buffer;
103 		struct {
104 			uint32 count;
105 			acpi_object_type *objects;
106 		} package;
107 		struct {
108 			uint32 cpu_id;
109 
110 			int pblk_address;
111 			size_t pblk_length;
112 		} processor;
113 		struct {
114 			uint32 min_power_state;
115 			uint32 resource_order;
116 		} power_resource;
117 	} data;
118 };
119 
120 #endif
121 
122 #define B_ACPI_MODULE_NAME	"bus_managers/acpi/v1"
123 
124 #endif /* _ACPI_H */
125