1 /* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 */
2 /******************************************************************************
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.
8 * Copyright (C) 2000 - 2018, Intel Corp.
10 *****************************************************************************/
12 #ifndef __ACPIOSXF_H__
13 #define __ACPIOSXF_H__
15 #include <acpi/platform/acenv.h>
16 #include <acpi/actypes.h>
18 /* Types for acpi_os_execute */
21 OSL_GLOBAL_LOCK_HANDLER
,
24 OSL_DEBUGGER_MAIN_THREAD
,
25 OSL_DEBUGGER_EXEC_THREAD
,
30 #define ACPI_NO_UNIT_LIMIT ((u32) -1)
31 #define ACPI_MUTEX_SEM 1
33 /* Functions for acpi_os_signal */
35 #define ACPI_SIGNAL_FATAL 0
36 #define ACPI_SIGNAL_BREAKPOINT 1
38 struct acpi_signal_fatal_info
{
45 * OSL Initialization and shutdown primitives
47 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_initialize
48 acpi_status
acpi_os_initialize(void);
51 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_terminate
52 acpi_status
acpi_os_terminate(void);
56 * ACPI Table interfaces
58 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_root_pointer
59 acpi_physical_address
acpi_os_get_root_pointer(void);
62 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_predefined_override
64 acpi_os_predefined_override(const struct acpi_predefined_names
*init_val
,
65 acpi_string
*new_val
);
68 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_table_override
70 acpi_os_table_override(struct acpi_table_header
*existing_table
,
71 struct acpi_table_header
**new_table
);
74 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_physical_table_override
76 acpi_os_physical_table_override(struct acpi_table_header
*existing_table
,
77 acpi_physical_address
*new_address
,
78 u32
*new_table_length
);
84 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_create_lock
85 acpi_status
acpi_os_create_lock(acpi_spinlock
* out_handle
);
88 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_delete_lock
89 void acpi_os_delete_lock(acpi_spinlock handle
);
92 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_acquire_lock
93 acpi_cpu_flags
acpi_os_acquire_lock(acpi_spinlock handle
);
96 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_release_lock
97 void acpi_os_release_lock(acpi_spinlock handle
, acpi_cpu_flags flags
);
101 * Semaphore primitives
103 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_create_semaphore
105 acpi_os_create_semaphore(u32 max_units
,
106 u32 initial_units
, acpi_semaphore
* out_handle
);
109 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_delete_semaphore
110 acpi_status
acpi_os_delete_semaphore(acpi_semaphore handle
);
113 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_wait_semaphore
115 acpi_os_wait_semaphore(acpi_semaphore handle
, u32 units
, u16 timeout
);
118 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_signal_semaphore
119 acpi_status
acpi_os_signal_semaphore(acpi_semaphore handle
, u32 units
);
123 * Mutex primitives. May be configured to use semaphores instead via
124 * ACPI_MUTEX_TYPE (see platform/acenv.h)
126 #if (ACPI_MUTEX_TYPE != ACPI_BINARY_SEMAPHORE)
128 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_create_mutex
129 acpi_status
acpi_os_create_mutex(acpi_mutex
* out_handle
);
132 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_delete_mutex
133 void acpi_os_delete_mutex(acpi_mutex handle
);
136 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_acquire_mutex
137 acpi_status
acpi_os_acquire_mutex(acpi_mutex handle
, u16 timeout
);
140 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_release_mutex
141 void acpi_os_release_mutex(acpi_mutex handle
);
147 * Memory allocation and mapping
149 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_allocate
150 void *acpi_os_allocate(acpi_size size
);
153 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_allocate_zeroed
154 void *acpi_os_allocate_zeroed(acpi_size size
);
157 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_free
158 void acpi_os_free(void *memory
);
161 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_map_memory
162 void *acpi_os_map_memory(acpi_physical_address where
, acpi_size length
);
165 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_unmap_memory
166 void acpi_os_unmap_memory(void *logical_address
, acpi_size size
);
169 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_physical_address
171 acpi_os_get_physical_address(void *logical_address
,
172 acpi_physical_address
*physical_address
);
176 * Memory/Object Cache
178 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_create_cache
180 acpi_os_create_cache(char *cache_name
,
182 u16 max_depth
, acpi_cache_t
** return_cache
);
185 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_delete_cache
186 acpi_status
acpi_os_delete_cache(acpi_cache_t
* cache
);
189 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_purge_cache
190 acpi_status
acpi_os_purge_cache(acpi_cache_t
* cache
);
193 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_acquire_object
194 void *acpi_os_acquire_object(acpi_cache_t
* cache
);
197 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_release_object
198 acpi_status
acpi_os_release_object(acpi_cache_t
* cache
, void *object
);
204 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_install_interrupt_handler
206 acpi_os_install_interrupt_handler(u32 interrupt_number
,
207 acpi_osd_handler service_routine
,
211 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_remove_interrupt_handler
213 acpi_os_remove_interrupt_handler(u32 interrupt_number
,
214 acpi_osd_handler service_routine
);
218 * Threads and Scheduling
220 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_thread_id
221 acpi_thread_id
acpi_os_get_thread_id(void);
224 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_execute
226 acpi_os_execute(acpi_execute_type type
,
227 acpi_osd_exec_callback function
, void *context
);
230 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_wait_events_complete
231 void acpi_os_wait_events_complete(void);
234 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_sleep
235 void acpi_os_sleep(u64 milliseconds
);
238 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_stall
239 void acpi_os_stall(u32 microseconds
);
243 * Platform and hardware-independent I/O interfaces
245 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_read_port
246 acpi_status
acpi_os_read_port(acpi_io_address address
, u32
*value
, u32 width
);
249 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_write_port
250 acpi_status
acpi_os_write_port(acpi_io_address address
, u32 value
, u32 width
);
254 * Platform and hardware-independent physical memory interfaces
256 int acpi_os_read_iomem(void __iomem
*virt_addr
, u64
*value
, u32 width
);
258 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_read_memory
260 acpi_os_read_memory(acpi_physical_address address
, u64
*value
, u32 width
);
263 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_write_memory
265 acpi_os_write_memory(acpi_physical_address address
, u64 value
, u32 width
);
269 * Platform and hardware-independent PCI configuration space access
270 * Note: Can't use "Register" as a parameter, changed to "Reg" --
271 * certain compilers complain.
273 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_read_pci_configuration
275 acpi_os_read_pci_configuration(struct acpi_pci_id
*pci_id
,
276 u32 reg
, u64
*value
, u32 width
);
279 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_write_pci_configuration
281 acpi_os_write_pci_configuration(struct acpi_pci_id
*pci_id
,
282 u32 reg
, u64 value
, u32 width
);
288 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_readable
289 u8
acpi_os_readable(void *pointer
, acpi_size length
);
292 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_writable
293 u8
acpi_os_writable(void *pointer
, acpi_size length
);
296 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_timer
297 u64
acpi_os_get_timer(void);
300 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_signal
301 acpi_status
acpi_os_signal(u32 function
, void *info
);
304 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_enter_sleep
305 acpi_status
acpi_os_enter_sleep(u8 sleep_state
, u32 rega_value
, u32 regb_value
);
309 * Debug print routines
311 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_printf
312 void ACPI_INTERNAL_VAR_XFACE
acpi_os_printf(const char *format
, ...);
315 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_vprintf
316 void acpi_os_vprintf(const char *format
, va_list args
);
319 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_redirect_output
320 void acpi_os_redirect_output(void *destination
);
326 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_line
327 acpi_status
acpi_os_get_line(char *buffer
, u32 buffer_length
, u32
*bytes_read
);
330 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_initialize_debugger
331 acpi_status
acpi_os_initialize_debugger(void);
334 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_terminate_debugger
335 void acpi_os_terminate_debugger(void);
338 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_wait_command_ready
339 acpi_status
acpi_os_wait_command_ready(void);
342 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_notify_command_complete
343 acpi_status
acpi_os_notify_command_complete(void);
346 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_trace_point
348 acpi_os_trace_point(acpi_trace_event_type type
,
349 u8 begin
, u8
*aml
, char *pathname
);
353 * Obtain ACPI table(s)
355 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_table_by_name
357 acpi_os_get_table_by_name(char *signature
,
359 struct acpi_table_header
**table
,
360 acpi_physical_address
*address
);
363 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_table_by_index
365 acpi_os_get_table_by_index(u32 index
,
366 struct acpi_table_header
**table
,
367 u32
*instance
, acpi_physical_address
*address
);
370 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_table_by_address
372 acpi_os_get_table_by_address(acpi_physical_address address
,
373 struct acpi_table_header
**table
);
377 * Directory manipulation
379 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_open_directory
380 void *acpi_os_open_directory(char *pathname
,
381 char *wildcard_spec
, char requested_file_type
);
384 /* requeste_file_type values */
386 #define REQUEST_FILE_ONLY 0
387 #define REQUEST_DIR_ONLY 1
389 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_next_filename
390 char *acpi_os_get_next_filename(void *dir_handle
);
393 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_close_directory
394 void acpi_os_close_directory(void *dir_handle
);
397 #endif /* __ACPIOSXF_H__ */