xref: /linux/include/acpi/acpiosxf.h (revision 20d0021394c1b070bf04b22c5bc8fdb437edd4c5)
1 
2 /******************************************************************************
3  *
4  * Name: acpiosxf.h - All interfaces to the OS Services Layer (OSL).  These
5  *                    interfaces must be implemented by OSL to interface the
6  *                    ACPI components to the host operating system.
7  *
8  *****************************************************************************/
9 
10 
11 /*
12  * Copyright (C) 2000 - 2005, R. Byron Moore
13  * All rights reserved.
14  *
15  * Redistribution and use in source and binary forms, with or without
16  * modification, are permitted provided that the following conditions
17  * are met:
18  * 1. Redistributions of source code must retain the above copyright
19  *    notice, this list of conditions, and the following disclaimer,
20  *    without modification.
21  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
22  *    substantially similar to the "NO WARRANTY" disclaimer below
23  *    ("Disclaimer") and any redistribution must be conditioned upon
24  *    including a substantially similar Disclaimer requirement for further
25  *    binary redistribution.
26  * 3. Neither the names of the above-listed copyright holders nor the names
27  *    of any contributors may be used to endorse or promote products derived
28  *    from this software without specific prior written permission.
29  *
30  * Alternatively, this software may be distributed under the terms of the
31  * GNU General Public License ("GPL") version 2 as published by the Free
32  * Software Foundation.
33  *
34  * NO WARRANTY
35  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
36  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
37  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
38  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
39  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
40  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
41  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
42  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
43  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
44  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
45  * POSSIBILITY OF SUCH DAMAGES.
46  */
47 
48 #ifndef __ACPIOSXF_H__
49 #define __ACPIOSXF_H__
50 
51 #include "platform/acenv.h"
52 #include "actypes.h"
53 
54 
55 /* Priorities for acpi_os_queue_for_execution */
56 
57 #define OSD_PRIORITY_GPE            1
58 #define OSD_PRIORITY_HIGH           2
59 #define OSD_PRIORITY_MED            3
60 #define OSD_PRIORITY_LO             4
61 
62 #define ACPI_NO_UNIT_LIMIT          ((u32) -1)
63 #define ACPI_MUTEX_SEM              1
64 
65 
66 /* Functions for acpi_os_signal */
67 
68 #define ACPI_SIGNAL_FATAL           0
69 #define ACPI_SIGNAL_BREAKPOINT      1
70 
71 struct acpi_signal_fatal_info
72 {
73 	u32                             type;
74 	u32                             code;
75 	u32                             argument;
76 };
77 
78 
79 /*
80  * OSL Initialization and shutdown primitives
81  */
82 acpi_status
83 acpi_os_initialize (
84 	void);
85 
86 acpi_status
87 acpi_os_terminate (
88 	void);
89 
90 
91 /*
92  * ACPI Table interfaces
93  */
94 acpi_status
95 acpi_os_get_root_pointer (
96 	u32                             flags,
97 	struct acpi_pointer             *address);
98 
99 acpi_status
100 acpi_os_predefined_override (
101 	const struct acpi_predefined_names *init_val,
102 	acpi_string                         *new_val);
103 
104 acpi_status
105 acpi_os_table_override (
106 	struct acpi_table_header        *existing_table,
107 	struct acpi_table_header        **new_table);
108 
109 
110 /*
111  * Synchronization primitives
112  */
113 acpi_status
114 acpi_os_create_semaphore (
115 	u32                             max_units,
116 	u32                             initial_units,
117 	acpi_handle                     *out_handle);
118 
119 acpi_status
120 acpi_os_delete_semaphore (
121 	acpi_handle                     handle);
122 
123 acpi_status
124 acpi_os_wait_semaphore (
125 	acpi_handle                     handle,
126 	u32                             units,
127 	u16                             timeout);
128 
129 acpi_status
130 acpi_os_signal_semaphore (
131 	acpi_handle                     handle,
132 	u32                             units);
133 
134 acpi_status
135 acpi_os_create_lock (
136 	acpi_handle                     *out_handle);
137 
138 void
139 acpi_os_delete_lock (
140 	acpi_handle                     handle);
141 
142 void
143 acpi_os_acquire_lock (
144 	acpi_handle                     handle,
145 	u32                             flags);
146 
147 void
148 acpi_os_release_lock (
149 	acpi_handle                     handle,
150 	u32                             flags);
151 
152 
153 /*
154  * Memory allocation and mapping
155  */
156 void *
157 acpi_os_allocate (
158 	acpi_size                       size);
159 
160 void
161 acpi_os_free (
162 	void *                          memory);
163 
164 acpi_status
165 acpi_os_map_memory (
166 	acpi_physical_address           physical_address,
167 	acpi_size                       size,
168 	void __iomem                  **logical_address);
169 
170 void
171 acpi_os_unmap_memory (
172 	void __iomem                  *logical_address,
173 	acpi_size                       size);
174 
175 #ifdef ACPI_FUTURE_USAGE
176 acpi_status
177 acpi_os_get_physical_address (
178 	void                            *logical_address,
179 	acpi_physical_address           *physical_address);
180 #endif
181 
182 
183 /*
184  * Interrupt handlers
185  */
186 acpi_status
187 acpi_os_install_interrupt_handler (
188 	u32                             gsi,
189 	acpi_osd_handler                service_routine,
190 	void                            *context);
191 
192 acpi_status
193 acpi_os_remove_interrupt_handler (
194 	u32                             gsi,
195 	acpi_osd_handler                service_routine);
196 
197 
198 /*
199  * Threads and Scheduling
200  */
201 u32
202 acpi_os_get_thread_id (
203 	void);
204 
205 acpi_status
206 acpi_os_queue_for_execution (
207 	u32                             priority,
208 	acpi_osd_exec_callback          function,
209 	void                            *context);
210 
211 void
212 acpi_os_wait_events_complete(
213 	void * context);
214 
215 void
216 acpi_os_wait_events_complete (
217 	void                            *context);
218 
219 void
220 acpi_os_sleep (
221 	acpi_integer                    milliseconds);
222 
223 void
224 acpi_os_stall (
225 	u32                             microseconds);
226 
227 
228 /*
229  * Platform and hardware-independent I/O interfaces
230  */
231 acpi_status
232 acpi_os_read_port (
233 	acpi_io_address                 address,
234 	u32                             *value,
235 	u32                             width);
236 
237 acpi_status
238 acpi_os_write_port (
239 	acpi_io_address                 address,
240 	u32                             value,
241 	u32                             width);
242 
243 
244 /*
245  * Platform and hardware-independent physical memory interfaces
246  */
247 acpi_status
248 acpi_os_read_memory (
249 	acpi_physical_address           address,
250 	u32                             *value,
251 	u32                             width);
252 
253 acpi_status
254 acpi_os_write_memory (
255 	acpi_physical_address           address,
256 	u32                             value,
257 	u32                             width);
258 
259 
260 /*
261  * Platform and hardware-independent PCI configuration space access
262  * Note: Can't use "Register" as a parameter, changed to "Reg" --
263  * certain compilers complain.
264  */
265 acpi_status
266 acpi_os_read_pci_configuration (
267 	struct acpi_pci_id              *pci_id,
268 	u32                             reg,
269 	void                            *value,
270 	u32                             width);
271 
272 acpi_status
273 acpi_os_write_pci_configuration (
274 	struct acpi_pci_id              *pci_id,
275 	u32                             reg,
276 	acpi_integer                    value,
277 	u32                             width);
278 
279 /*
280  * Interim function needed for PCI IRQ routing
281  */
282 void
283 acpi_os_derive_pci_id(
284 	acpi_handle                     rhandle,
285 	acpi_handle                     chandle,
286 	struct acpi_pci_id              **pci_id);
287 
288 /*
289  * Miscellaneous
290  */
291 u8
292 acpi_os_readable (
293 	void                            *pointer,
294 	acpi_size                       length);
295 
296 #ifdef ACPI_FUTURE_USAGE
297 u8
298 acpi_os_writable (
299 	void                            *pointer,
300 	acpi_size                       length);
301 #endif
302 
303 u64
304 acpi_os_get_timer (
305 	void);
306 
307 acpi_status
308 acpi_os_signal (
309 	u32                             function,
310 	void                            *info);
311 
312 /*
313  * Debug print routines
314  */
315 void ACPI_INTERNAL_VAR_XFACE
316 acpi_os_printf (
317 	const char                      *format,
318 	...);
319 
320 void
321 acpi_os_vprintf (
322 	const char                      *format,
323 	va_list                 args);
324 
325 void
326 acpi_os_redirect_output (
327 	void                            *destination);
328 
329 
330 #ifdef ACPI_FUTURE_USAGE
331 /*
332  * Debug input
333  */
334 u32
335 acpi_os_get_line (
336 	char                            *buffer);
337 #endif
338 
339 
340 /*
341  * Directory manipulation
342  */
343 void *
344 acpi_os_open_directory (
345 	char                            *pathname,
346 	char                            *wildcard_spec,
347 	char                            requested_file_type);
348 
349 /* requeste_file_type values */
350 
351 #define REQUEST_FILE_ONLY                   0
352 #define REQUEST_DIR_ONLY                    1
353 
354 
355 char *
356 acpi_os_get_next_filename (
357 	void                            *dir_handle);
358 
359 void
360 acpi_os_close_directory (
361 	void                            *dir_handle);
362 
363 /*
364  * Debug
365  */
366 void
367 acpi_os_dbg_assert(
368 	void                            *failed_assertion,
369 	void                            *file_name,
370 	u32                             line_number,
371 	char                            *message);
372 
373 #endif /* __ACPIOSXF_H__ */
374