xref: /linux/include/acpi/acpiosxf.h (revision c537b994505099b7197e7d3125b942ecbcc51eb6)
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  * Copyright (C) 2000 - 2007, R. Byron Moore
12  * All rights reserved.
13  *
14  * Redistribution and use in source and binary forms, with or without
15  * modification, are permitted provided that the following conditions
16  * are met:
17  * 1. Redistributions of source code must retain the above copyright
18  *    notice, this list of conditions, and the following disclaimer,
19  *    without modification.
20  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
21  *    substantially similar to the "NO WARRANTY" disclaimer below
22  *    ("Disclaimer") and any redistribution must be conditioned upon
23  *    including a substantially similar Disclaimer requirement for further
24  *    binary redistribution.
25  * 3. Neither the names of the above-listed copyright holders nor the names
26  *    of any contributors may be used to endorse or promote products derived
27  *    from this software without specific prior written permission.
28  *
29  * Alternatively, this software may be distributed under the terms of the
30  * GNU General Public License ("GPL") version 2 as published by the Free
31  * Software Foundation.
32  *
33  * NO WARRANTY
34  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
35  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
36  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
37  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
38  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
39  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
40  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
41  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
42  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
43  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
44  * POSSIBILITY OF SUCH DAMAGES.
45  */
46 
47 #ifndef __ACPIOSXF_H__
48 #define __ACPIOSXF_H__
49 
50 #include "platform/acenv.h"
51 #include "actypes.h"
52 
53 /* Types for acpi_os_execute */
54 
55 typedef enum {
56 	OSL_GLOBAL_LOCK_HANDLER,
57 	OSL_NOTIFY_HANDLER,
58 	OSL_GPE_HANDLER,
59 	OSL_DEBUGGER_THREAD,
60 	OSL_EC_POLL_HANDLER,
61 	OSL_EC_BURST_HANDLER
62 } acpi_execute_type;
63 
64 #define ACPI_NO_UNIT_LIMIT          ((u32) -1)
65 #define ACPI_MUTEX_SEM              1
66 
67 /* Functions for acpi_os_signal */
68 
69 #define ACPI_SIGNAL_FATAL           0
70 #define ACPI_SIGNAL_BREAKPOINT      1
71 
72 struct acpi_signal_fatal_info {
73 	u32 type;
74 	u32 code;
75 	u32 argument;
76 };
77 
78 /*
79  * OSL Initialization and shutdown primitives
80  */
81 acpi_status acpi_os_initialize(void);
82 
83 acpi_status acpi_os_terminate(void);
84 
85 /*
86  * ACPI Table interfaces
87  */
88 acpi_physical_address acpi_os_get_root_pointer(void);
89 
90 acpi_status
91 acpi_os_predefined_override(const struct acpi_predefined_names *init_val,
92 			    acpi_string * new_val);
93 
94 acpi_status
95 acpi_os_table_override(struct acpi_table_header *existing_table,
96 		       struct acpi_table_header **new_table);
97 
98 /*
99  * Spinlock primitives
100  */
101 acpi_status acpi_os_create_lock(acpi_spinlock * out_handle);
102 
103 void acpi_os_delete_lock(acpi_spinlock handle);
104 
105 acpi_cpu_flags acpi_os_acquire_lock(acpi_spinlock handle);
106 
107 void acpi_os_release_lock(acpi_spinlock handle, acpi_cpu_flags flags);
108 
109 /*
110  * Semaphore primitives
111  */
112 acpi_status
113 acpi_os_create_semaphore(u32 max_units,
114 			 u32 initial_units, acpi_semaphore * out_handle);
115 
116 acpi_status acpi_os_delete_semaphore(acpi_semaphore handle);
117 
118 acpi_status
119 acpi_os_wait_semaphore(acpi_semaphore handle, u32 units, u16 timeout);
120 
121 acpi_status acpi_os_signal_semaphore(acpi_semaphore handle, u32 units);
122 
123 /*
124  * Mutex primitives
125  */
126 acpi_status acpi_os_create_mutex(acpi_mutex * out_handle);
127 
128 void acpi_os_delete_mutex(acpi_mutex handle);
129 
130 acpi_status acpi_os_acquire_mutex(acpi_mutex handle, u16 timeout);
131 
132 void acpi_os_release_mutex(acpi_mutex handle);
133 
134 /* Temporary macros for Mutex* interfaces, map to existing semaphore xfaces */
135 
136 #define acpi_os_create_mutex(out_handle)    acpi_os_create_semaphore (1, 1, out_handle)
137 #define acpi_os_delete_mutex(handle)        (void) acpi_os_delete_semaphore (handle)
138 #define acpi_os_acquire_mutex(handle,time)  acpi_os_wait_semaphore (handle, 1, time)
139 #define acpi_os_release_mutex(handle)       (void) acpi_os_signal_semaphore (handle, 1)
140 
141 /*
142  * Memory allocation and mapping
143  */
144 void *acpi_os_allocate(acpi_size size);
145 
146 void __iomem *acpi_os_map_memory(acpi_physical_address where, acpi_native_uint length);
147 
148 void acpi_os_unmap_memory(void __iomem * logical_address, acpi_size size);
149 
150 #ifdef ACPI_FUTURE_USAGE
151 acpi_status
152 acpi_os_get_physical_address(void *logical_address,
153 			     acpi_physical_address * physical_address);
154 #endif
155 
156 /*
157  * Memory/Object Cache
158  */
159 acpi_status
160 acpi_os_create_cache(char *cache_name,
161 		     u16 object_size,
162 		     u16 max_depth, acpi_cache_t ** return_cache);
163 
164 acpi_status acpi_os_delete_cache(acpi_cache_t * cache);
165 
166 acpi_status acpi_os_purge_cache(acpi_cache_t * cache);
167 
168 void *acpi_os_acquire_object(acpi_cache_t * cache);
169 
170 acpi_status acpi_os_release_object(acpi_cache_t * cache, void *object);
171 
172 /*
173  * Interrupt handlers
174  */
175 acpi_status
176 acpi_os_install_interrupt_handler(u32 gsi,
177 				  acpi_osd_handler service_routine,
178 				  void *context);
179 
180 acpi_status
181 acpi_os_remove_interrupt_handler(u32 gsi, acpi_osd_handler service_routine);
182 
183 /*
184  * Threads and Scheduling
185  */
186 acpi_thread_id acpi_os_get_thread_id(void);
187 
188 acpi_status
189 acpi_os_execute(acpi_execute_type type,
190 		acpi_osd_exec_callback function, void *context);
191 
192 void acpi_os_wait_events_complete(void *context);
193 
194 void acpi_os_sleep(acpi_integer milliseconds);
195 
196 void acpi_os_stall(u32 microseconds);
197 
198 /*
199  * Platform and hardware-independent I/O interfaces
200  */
201 acpi_status acpi_os_read_port(acpi_io_address address, u32 * value, u32 width);
202 
203 acpi_status acpi_os_write_port(acpi_io_address address, u32 value, u32 width);
204 
205 /*
206  * Platform and hardware-independent physical memory interfaces
207  */
208 acpi_status
209 acpi_os_read_memory(acpi_physical_address address, u32 * value, u32 width);
210 
211 acpi_status
212 acpi_os_write_memory(acpi_physical_address address, u32 value, u32 width);
213 
214 /*
215  * Platform and hardware-independent PCI configuration space access
216  * Note: Can't use "Register" as a parameter, changed to "Reg" --
217  * certain compilers complain.
218  */
219 acpi_status
220 acpi_os_read_pci_configuration(struct acpi_pci_id *pci_id,
221 			       u32 reg, void *value, u32 width);
222 
223 acpi_status
224 acpi_os_write_pci_configuration(struct acpi_pci_id *pci_id,
225 				u32 reg, acpi_integer value, u32 width);
226 
227 /*
228  * Interim function needed for PCI IRQ routing
229  */
230 void
231 acpi_os_derive_pci_id(acpi_handle rhandle,
232 		      acpi_handle chandle, struct acpi_pci_id **pci_id);
233 
234 /*
235  * Miscellaneous
236  */
237 acpi_status acpi_os_validate_interface(char *interface);
238 
239 acpi_status
240 acpi_os_validate_address(u8 space_id,
241 			 acpi_physical_address address, acpi_size length);
242 
243 u64 acpi_os_get_timer(void);
244 
245 acpi_status acpi_os_signal(u32 function, void *info);
246 
247 /*
248  * Debug print routines
249  */
250 void ACPI_INTERNAL_VAR_XFACE acpi_os_printf(const char *format, ...);
251 
252 void acpi_os_vprintf(const char *format, va_list args);
253 
254 void acpi_os_redirect_output(void *destination);
255 
256 #ifdef ACPI_FUTURE_USAGE
257 /*
258  * Debug input
259  */
260 u32 acpi_os_get_line(char *buffer);
261 #endif
262 
263 /*
264  * Directory manipulation
265  */
266 void *acpi_os_open_directory(char *pathname,
267 			     char *wildcard_spec, char requested_file_type);
268 
269 /* requeste_file_type values */
270 
271 #define REQUEST_FILE_ONLY                   0
272 #define REQUEST_DIR_ONLY                    1
273 
274 char *acpi_os_get_next_filename(void *dir_handle);
275 
276 void acpi_os_close_directory(void *dir_handle);
277 
278 #endif				/* __ACPIOSXF_H__ */
279