:pserver:cvsanon@mok.lvcm.com:/CVS/ReactOS reactos
[reactos.git] / drivers / bus / acpi / include / acpiosxf.h
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, 2001 R. Byron Moore
13  *
14  *  This program is free software; you can redistribute it and/or modify
15  *  it under the terms of the GNU General Public License as published by
16  *  the Free Software Foundation; either version 2 of the License, or
17  *  (at your option) any later version.
18  *
19  *  This program is distributed in the hope that it will be useful,
20  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
21  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22  *  GNU General Public License for more details.
23  *
24  *  You should have received a copy of the GNU General Public License
25  *  along with this program; if not, write to the Free Software
26  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
27  */
28
29 #ifndef __ACPIOSXF_H__
30 #define __ACPIOSXF_H__
31
32 #include "platform/acenv.h"
33 #include "actypes.h"
34
35
36 /* Priorities for Acpi_os_queue_for_execution */
37
38 #define OSD_PRIORITY_GPE            1
39 #define OSD_PRIORITY_HIGH           2
40 #define OSD_PRIORITY_MED            3
41 #define OSD_PRIORITY_LO             4
42
43 #define ACPI_NO_UNIT_LIMIT          ((u32) -1)
44 #define ACPI_MUTEX_SEM              1
45
46
47 /*
48  * Types specific to the OS service interfaces
49  */
50
51 typedef
52 u32 (*OSD_HANDLER) (
53         void                    *context);
54
55 typedef
56 void (*OSD_EXECUTION_CALLBACK) (
57         void                    *context);
58
59
60 /*
61  * OSL Initialization and shutdown primitives
62  */
63
64 ACPI_STATUS
65 acpi_os_initialize (
66         void);
67
68 ACPI_STATUS
69 acpi_os_terminate (
70         void);
71
72
73 /*
74  * Synchronization primitives
75  */
76
77 ACPI_STATUS
78 acpi_os_create_semaphore (
79         u32                     max_units,
80         u32                     initial_units,
81         ACPI_HANDLE             *out_handle);
82
83 ACPI_STATUS
84 acpi_os_delete_semaphore (
85         ACPI_HANDLE             handle);
86
87 ACPI_STATUS
88 acpi_os_wait_semaphore (
89         ACPI_HANDLE             handle,
90         u32                     units,
91         u32                     timeout);
92
93 ACPI_STATUS
94 acpi_os_signal_semaphore (
95         ACPI_HANDLE             handle,
96         u32                     units);
97
98
99 /*
100  * Memory allocation and mapping
101  */
102
103 void *
104 acpi_os_allocate (
105         u32                     size);
106
107 void *
108 acpi_os_callocate (
109         u32                     size);
110
111 void
112 acpi_os_free (
113         void *                  memory);
114
115 ACPI_STATUS
116 acpi_os_map_memory (
117         ACPI_PHYSICAL_ADDRESS   physical_address,
118         u32                     length,
119         void                    **logical_address);
120
121 void
122 acpi_os_unmap_memory (
123         void                    *logical_address,
124         u32                     length);
125
126 ACPI_STATUS
127 acpi_os_get_physical_address (
128         void                    *logical_address,
129         ACPI_PHYSICAL_ADDRESS   *physical_address);
130
131
132 /*
133  * Interrupt handlers
134  */
135
136 ACPI_STATUS
137 acpi_os_install_interrupt_handler (
138         u32                     interrupt_number,
139         OSD_HANDLER             service_routine,
140         void                    *context);
141
142 ACPI_STATUS
143 acpi_os_remove_interrupt_handler (
144         u32                     interrupt_number,
145         OSD_HANDLER             service_routine);
146
147
148 /*
149  * Threads and Scheduling
150  */
151
152 u32
153 acpi_os_get_thread_id (
154         void);
155
156 ACPI_STATUS
157 acpi_os_queue_for_execution (
158         u32                     priority,
159         OSD_EXECUTION_CALLBACK  function,
160         void                    *context);
161
162 void
163 acpi_os_sleep (
164         u32                     seconds,
165         u32                     milliseconds);
166
167 void
168 acpi_os_sleep_usec (
169         u32                     microseconds);
170
171
172 /*
173  * Platform/Hardware independent I/O interfaces
174  */
175
176 u8
177 acpi_os_in8 (
178         ACPI_IO_ADDRESS         in_port);
179
180
181 u16
182 acpi_os_in16 (
183         ACPI_IO_ADDRESS         in_port);
184
185 u32
186 acpi_os_in32 (
187         ACPI_IO_ADDRESS         in_port);
188
189 void
190 acpi_os_out8 (
191         ACPI_IO_ADDRESS         out_port,
192         u8                      value);
193
194 void
195 acpi_os_out16 (
196         ACPI_IO_ADDRESS         out_port,
197         u16                     value);
198
199 void
200 acpi_os_out32 (
201         ACPI_IO_ADDRESS         out_port,
202         u32                     value);
203
204
205 /*
206  * Platform/Hardware independent physical memory interfaces
207  */
208
209 u8
210 acpi_os_mem_in8 (
211         ACPI_PHYSICAL_ADDRESS   in_addr);
212
213 u16
214 acpi_os_mem_in16 (
215         ACPI_PHYSICAL_ADDRESS   in_addr);
216
217 u32
218 acpi_os_mem_in32 (
219         ACPI_PHYSICAL_ADDRESS   in_addr);
220
221 void
222 acpi_os_mem_out8 (
223         ACPI_PHYSICAL_ADDRESS   out_addr,
224         u8                      value);
225
226 void
227 acpi_os_mem_out16 (
228         ACPI_PHYSICAL_ADDRESS   out_addr,
229         u16                     value);
230
231 void
232 acpi_os_mem_out32 (
233         ACPI_PHYSICAL_ADDRESS   out_addr,
234         u32                     value);
235
236
237 /*
238  * Standard access to PCI configuration space
239  */
240
241 ACPI_STATUS
242 acpi_os_read_pci_cfg_byte (
243         u32                     bus,
244         u32                     device_function,
245         u32                     register,
246         u8                      *value);
247
248 ACPI_STATUS
249 acpi_os_read_pci_cfg_word (
250         u32                     bus,
251         u32                     device_function,
252         u32                     register,
253         u16                     *value);
254
255 ACPI_STATUS
256 acpi_os_read_pci_cfg_dword (
257         u32                     bus,
258         u32                     device_function,
259         u32                     register,
260         u32                     *value);
261
262 ACPI_STATUS
263 acpi_os_write_pci_cfg_byte (
264         u32                     bus,
265         u32                     device_function,
266         u32                     register,
267         u8                      value);
268
269 ACPI_STATUS
270 acpi_os_write_pci_cfg_word (
271         u32                     bus,
272         u32                     device_function,
273         u32                     register,
274         u16                     value);
275
276
277 ACPI_STATUS
278 acpi_os_write_pci_cfg_dword (
279         u32                     bus,
280         u32                     device_function,
281         u32                     register,
282         u32                     value);
283
284
285 /*
286  * Miscellaneous
287  */
288
289 ACPI_STATUS
290 acpi_os_breakpoint (
291         NATIVE_CHAR             *message);
292
293 u8
294 acpi_os_readable (
295         void                    *pointer,
296         u32                     length);
297
298
299 u8
300 acpi_os_writable (
301         void                    *pointer,
302         u32                     length);
303
304
305 /*
306  * Debug print routines
307  */
308
309 s32
310 acpi_os_printf (
311         const NATIVE_CHAR       *format,
312         ...);
313
314 s32
315 acpi_os_vprintf (
316         const NATIVE_CHAR       *format,
317         va_list                 args);
318
319
320 /*
321  * Debug input
322  */
323
324 u32
325 acpi_os_get_line (
326         NATIVE_CHAR             *buffer);
327
328
329 /*
330  * Debug
331  */
332
333 void
334 acpi_os_dbg_assert(
335         void                    *failed_assertion,
336         void                    *file_name,
337         u32                     line_number,
338         NATIVE_CHAR             *message);
339
340
341 #endif /* __ACPIOSXF_H__ */