]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blame - include/acpi/acpiosxf.h
Merge tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi
[mirror_ubuntu-jammy-kernel.git] / include / acpi / acpiosxf.h
CommitLineData
95857638 1/* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 */
1da177e4
LT
2/******************************************************************************
3 *
abf95c36 4 * Name: acpiosxf.h - All interfaces to the OS Services Layer (OSL). These
1da177e4
LT
5 * interfaces must be implemented by OSL to interface the
6 * ACPI components to the host operating system.
7 *
4441e55d 8 * Copyright (C) 2000 - 2021, Intel Corp.
1da177e4 9 *
95857638 10 *****************************************************************************/
1da177e4
LT
11
12#ifndef __ACPIOSXF_H__
13#define __ACPIOSXF_H__
14
a1ce3928
DH
15#include <acpi/platform/acenv.h>
16#include <acpi/actypes.h>
1da177e4 17
958dd242 18/* Types for acpi_os_execute */
1da177e4 19
958dd242
BM
20typedef enum {
21 OSL_GLOBAL_LOCK_HANDLER,
22 OSL_NOTIFY_HANDLER,
23 OSL_GPE_HANDLER,
f988f24e
LZ
24 OSL_DEBUGGER_MAIN_THREAD,
25 OSL_DEBUGGER_EXEC_THREAD,
958dd242 26 OSL_EC_POLL_HANDLER,
4119532c 27 OSL_EC_BURST_HANDLER
958dd242 28} acpi_execute_type;
1da177e4
LT
29
30#define ACPI_NO_UNIT_LIMIT ((u32) -1)
31#define ACPI_MUTEX_SEM 1
32
1da177e4
LT
33/* Functions for acpi_os_signal */
34
35#define ACPI_SIGNAL_FATAL 0
36#define ACPI_SIGNAL_BREAKPOINT 1
37
4be44fcd
LB
38struct acpi_signal_fatal_info {
39 u32 type;
40 u32 code;
41 u32 argument;
1da177e4
LT
42};
43
1da177e4
LT
44/*
45 * OSL Initialization and shutdown primitives
46 */
7e94632f 47#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_initialize
93220587 48acpi_status acpi_os_initialize(void);
7e94632f 49#endif
1da177e4 50
7e94632f 51#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_terminate
4be44fcd 52acpi_status acpi_os_terminate(void);
7e94632f 53#endif
1da177e4
LT
54
55/*
56 * ACPI Table interfaces
57 */
7e94632f 58#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_root_pointer
f3d2e786 59acpi_physical_address acpi_os_get_root_pointer(void);
7e94632f 60#endif
1da177e4 61
7e94632f 62#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_predefined_override
1da177e4 63acpi_status
4be44fcd 64acpi_os_predefined_override(const struct acpi_predefined_names *init_val,
80b28810 65 acpi_string *new_val);
7e94632f 66#endif
1da177e4 67
7e94632f 68#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_table_override
1da177e4 69acpi_status
4be44fcd
LB
70acpi_os_table_override(struct acpi_table_header *existing_table,
71 struct acpi_table_header **new_table);
7e94632f 72#endif
1da177e4 73
7e94632f 74#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_physical_table_override
f7b004a1
BM
75acpi_status
76acpi_os_physical_table_override(struct acpi_table_header *existing_table,
f5c1e1c5 77 acpi_physical_address *new_address,
f7b004a1 78 u32 *new_table_length);
7e94632f 79#endif
f7b004a1 80
1da177e4 81/*
967440e3
BM
82 * Spinlock primitives
83 */
7e94632f 84#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_create_lock
3e8214e5 85acpi_status acpi_os_create_lock(acpi_spinlock * out_handle);
07e49a7a 86#endif
9f63b88b 87
7e94632f 88#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_delete_lock
967440e3 89void acpi_os_delete_lock(acpi_spinlock handle);
7e94632f 90#endif
967440e3 91
7e94632f 92#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_acquire_lock
967440e3 93acpi_cpu_flags acpi_os_acquire_lock(acpi_spinlock handle);
7e94632f 94#endif
967440e3 95
7e94632f 96#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_release_lock
967440e3 97void acpi_os_release_lock(acpi_spinlock handle, acpi_cpu_flags flags);
7e94632f 98#endif
967440e3 99
c3052594
SAS
100/*
101 * RAW spinlock primitives. If the OS does not provide them, fallback to
102 * spinlock primitives
103 */
104#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_create_raw_lock
105# define acpi_os_create_raw_lock(out_handle) acpi_os_create_lock(out_handle)
106#endif
107
108#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_delete_raw_lock
109# define acpi_os_delete_raw_lock(handle) acpi_os_delete_lock(handle)
110#endif
111
112#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_acquire_raw_lock
113# define acpi_os_acquire_raw_lock(handle) acpi_os_acquire_lock(handle)
114#endif
115
116#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_release_raw_lock
117# define acpi_os_release_raw_lock(handle, flags) \
118 acpi_os_release_lock(handle, flags)
119#endif
120
967440e3
BM
121/*
122 * Semaphore primitives
1da177e4 123 */
7e94632f 124#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_create_semaphore
1da177e4 125acpi_status
4be44fcd 126acpi_os_create_semaphore(u32 max_units,
967440e3 127 u32 initial_units, acpi_semaphore * out_handle);
7e94632f 128#endif
1da177e4 129
7e94632f 130#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_delete_semaphore
967440e3 131acpi_status acpi_os_delete_semaphore(acpi_semaphore handle);
7e94632f 132#endif
1da177e4 133
7e94632f 134#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_wait_semaphore
967440e3
BM
135acpi_status
136acpi_os_wait_semaphore(acpi_semaphore handle, u32 units, u16 timeout);
7e94632f 137#endif
967440e3 138
7e94632f 139#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_signal_semaphore
967440e3 140acpi_status acpi_os_signal_semaphore(acpi_semaphore handle, u32 units);
7e94632f 141#endif
967440e3
BM
142
143/*
1685bd40
BM
144 * Mutex primitives. May be configured to use semaphores instead via
145 * ACPI_MUTEX_TYPE (see platform/acenv.h)
967440e3 146 */
1685bd40
BM
147#if (ACPI_MUTEX_TYPE != ACPI_BINARY_SEMAPHORE)
148
7e94632f 149#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_create_mutex
967440e3 150acpi_status acpi_os_create_mutex(acpi_mutex * out_handle);
7e94632f 151#endif
1da177e4 152
7e94632f 153#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_delete_mutex
967440e3 154void acpi_os_delete_mutex(acpi_mutex handle);
7e94632f 155#endif
1da177e4 156
7e94632f 157#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_acquire_mutex
967440e3 158acpi_status acpi_os_acquire_mutex(acpi_mutex handle, u16 timeout);
7e94632f 159#endif
1da177e4 160
7e94632f 161#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_release_mutex
967440e3 162void acpi_os_release_mutex(acpi_mutex handle);
1685bd40 163#endif
1da177e4 164
7e94632f
LZ
165#endif
166
1da177e4
LT
167/*
168 * Memory allocation and mapping
169 */
7e94632f 170#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_allocate
4be44fcd 171void *acpi_os_allocate(acpi_size size);
7e94632f 172#endif
1da177e4 173
7e94632f 174#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_allocate_zeroed
b3c86c30 175void *acpi_os_allocate_zeroed(acpi_size size);
7e94632f 176#endif
b3c86c30 177
7e94632f 178#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_free
739dcbb9 179void acpi_os_free(void *memory);
7e94632f 180#endif
739dcbb9 181
7e94632f 182#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_map_memory
93220587 183void *acpi_os_map_memory(acpi_physical_address where, acpi_size length);
7e94632f 184#endif
1da177e4 185
7e94632f 186#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_unmap_memory
93220587 187void acpi_os_unmap_memory(void *logical_address, acpi_size size);
7e94632f 188#endif
1da177e4 189
7e94632f 190#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_physical_address
1da177e4 191acpi_status
4be44fcd 192acpi_os_get_physical_address(void *logical_address,
f5c1e1c5 193 acpi_physical_address *physical_address);
1da177e4
LT
194#endif
195
73459f73
RM
196/*
197 * Memory/Object Cache
198 */
7e94632f 199#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_create_cache
73459f73 200acpi_status
4be44fcd
LB
201acpi_os_create_cache(char *cache_name,
202 u16 object_size,
203 u16 max_depth, acpi_cache_t ** return_cache);
7e94632f 204#endif
73459f73 205
7e94632f 206#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_delete_cache
4be44fcd 207acpi_status acpi_os_delete_cache(acpi_cache_t * cache);
7e94632f 208#endif
73459f73 209
7e94632f 210#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_purge_cache
4be44fcd 211acpi_status acpi_os_purge_cache(acpi_cache_t * cache);
7e94632f 212#endif
73459f73 213
7e94632f 214#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_acquire_object
4be44fcd 215void *acpi_os_acquire_object(acpi_cache_t * cache);
7e94632f 216#endif
73459f73 217
7e94632f 218#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_release_object
4be44fcd 219acpi_status acpi_os_release_object(acpi_cache_t * cache, void *object);
7e94632f 220#endif
73459f73 221
1da177e4
LT
222/*
223 * Interrupt handlers
224 */
7e94632f 225#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_install_interrupt_handler
1da177e4 226acpi_status
739dcbb9 227acpi_os_install_interrupt_handler(u32 interrupt_number,
4be44fcd
LB
228 acpi_osd_handler service_routine,
229 void *context);
7e94632f 230#endif
1da177e4 231
7e94632f 232#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_remove_interrupt_handler
1da177e4 233acpi_status
739dcbb9
LZ
234acpi_os_remove_interrupt_handler(u32 interrupt_number,
235 acpi_osd_handler service_routine);
7e94632f 236#endif
1da177e4
LT
237
238/*
239 * Threads and Scheduling
240 */
7e94632f 241#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_thread_id
8313524a 242acpi_thread_id acpi_os_get_thread_id(void);
7e94632f 243#endif
1da177e4 244
7e94632f 245#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_execute
1da177e4 246acpi_status
958dd242
BM
247acpi_os_execute(acpi_execute_type type,
248 acpi_osd_exec_callback function, void *context);
7e94632f 249#endif
1da177e4 250
7e94632f 251#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_wait_events_complete
bd6f10a5 252void acpi_os_wait_events_complete(void);
7e94632f 253#endif
1da177e4 254
7e94632f 255#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_sleep
5df7e6cb 256void acpi_os_sleep(u64 milliseconds);
7e94632f 257#endif
1da177e4 258
7e94632f 259#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_stall
4be44fcd 260void acpi_os_stall(u32 microseconds);
7e94632f 261#endif
1da177e4
LT
262
263/*
264 * Platform and hardware-independent I/O interfaces
265 */
7e94632f
LZ
266#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_read_port
267acpi_status acpi_os_read_port(acpi_io_address address, u32 *value, u32 width);
268#endif
1da177e4 269
7e94632f 270#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_write_port
4be44fcd 271acpi_status acpi_os_write_port(acpi_io_address address, u32 value, u32 width);
7e94632f 272#endif
1da177e4
LT
273
274/*
275 * Platform and hardware-independent physical memory interfaces
276 */
eeb2d80d
SP
277int acpi_os_read_iomem(void __iomem *virt_addr, u64 *value, u32 width);
278
7e94632f 279#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_read_memory
1da177e4 280acpi_status
653f4b53 281acpi_os_read_memory(acpi_physical_address address, u64 *value, u32 width);
7e94632f 282#endif
1da177e4 283
7e94632f 284#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_write_memory
1da177e4 285acpi_status
653f4b53 286acpi_os_write_memory(acpi_physical_address address, u64 value, u32 width);
7e94632f 287#endif
1da177e4
LT
288
289/*
290 * Platform and hardware-independent PCI configuration space access
291 * Note: Can't use "Register" as a parameter, changed to "Reg" --
292 * certain compilers complain.
293 */
7e94632f 294#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_read_pci_configuration
1da177e4 295acpi_status
4be44fcd 296acpi_os_read_pci_configuration(struct acpi_pci_id *pci_id,
c5f0231e 297 u32 reg, u64 *value, u32 width);
7e94632f 298#endif
1da177e4 299
7e94632f 300#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_write_pci_configuration
1da177e4 301acpi_status
4be44fcd 302acpi_os_write_pci_configuration(struct acpi_pci_id *pci_id,
5df7e6cb 303 u32 reg, u64 value, u32 width);
7e94632f 304#endif
1da177e4 305
1da177e4
LT
306/*
307 * Miscellaneous
308 */
7e94632f
LZ
309#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_readable
310u8 acpi_os_readable(void *pointer, acpi_size length);
311#endif
312
313#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_writable
314u8 acpi_os_writable(void *pointer, acpi_size length);
315#endif
316
317#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_timer
4be44fcd 318u64 acpi_os_get_timer(void);
7e94632f 319#endif
1da177e4 320
7e94632f 321#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_signal
4be44fcd 322acpi_status acpi_os_signal(u32 function, void *info);
7e94632f 323#endif
1da177e4 324
0fc5e8f4
LZ
325#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_enter_sleep
326acpi_status acpi_os_enter_sleep(u8 sleep_state, u32 rega_value, u32 regb_value);
327#endif
328
1da177e4
LT
329/*
330 * Debug print routines
331 */
7e94632f 332#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_printf
36056d0c 333ACPI_PRINTF_LIKE(1)
4be44fcd 334void ACPI_INTERNAL_VAR_XFACE acpi_os_printf(const char *format, ...);
7e94632f 335#endif
1da177e4 336
7e94632f 337#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_vprintf
4be44fcd 338void acpi_os_vprintf(const char *format, va_list args);
7e94632f 339#endif
1da177e4 340
7e94632f 341#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_redirect_output
4be44fcd 342void acpi_os_redirect_output(void *destination);
7e94632f 343#endif
1da177e4
LT
344
345/*
f8d31489 346 * Debug IO
1da177e4 347 */
7e94632f
LZ
348#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_line
349acpi_status acpi_os_get_line(char *buffer, u32 buffer_length, u32 *bytes_read);
350#endif
7e94632f 351
703ecd22
LZ
352#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_initialize_debugger
353acpi_status acpi_os_initialize_debugger(void);
f8d31489
LZ
354#endif
355
703ecd22
LZ
356#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_terminate_debugger
357void acpi_os_terminate_debugger(void);
f8d31489
LZ
358#endif
359
360#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_wait_command_ready
361acpi_status acpi_os_wait_command_ready(void);
362#endif
363
364#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_notify_command_complete
365acpi_status acpi_os_notify_command_complete(void);
366#endif
367
dd99cbcc
LZ
368#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_trace_point
369void
370acpi_os_trace_point(acpi_trace_event_type type,
371 u8 begin, u8 *aml, char *pathname);
372#endif
373
7e94632f
LZ
374/*
375 * Obtain ACPI table(s)
376 */
377#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_table_by_name
378acpi_status
379acpi_os_get_table_by_name(char *signature,
380 u32 instance,
381 struct acpi_table_header **table,
f5c1e1c5 382 acpi_physical_address *address);
7e94632f
LZ
383#endif
384
385#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_table_by_index
386acpi_status
387acpi_os_get_table_by_index(u32 index,
388 struct acpi_table_header **table,
f5c1e1c5 389 u32 *instance, acpi_physical_address *address);
7e94632f
LZ
390#endif
391
392#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_table_by_address
393acpi_status
394acpi_os_get_table_by_address(acpi_physical_address address,
395 struct acpi_table_header **table);
1da177e4
LT
396#endif
397
1da177e4
LT
398/*
399 * Directory manipulation
400 */
7e94632f 401#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_open_directory
4be44fcd
LB
402void *acpi_os_open_directory(char *pathname,
403 char *wildcard_spec, char requested_file_type);
7e94632f 404#endif
1da177e4
LT
405
406/* requeste_file_type values */
407
408#define REQUEST_FILE_ONLY 0
409#define REQUEST_DIR_ONLY 1
410
7e94632f 411#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_next_filename
4be44fcd 412char *acpi_os_get_next_filename(void *dir_handle);
7e94632f 413#endif
1da177e4 414
7e94632f 415#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_close_directory
4be44fcd 416void acpi_os_close_directory(void *dir_handle);
7e94632f 417#endif
1da177e4 418
4be44fcd 419#endif /* __ACPIOSXF_H__ */