Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 */
0002 /******************************************************************************
0003  *
0004  * Name: acpiosxf.h - All interfaces to the OS Services Layer (OSL). These
0005  *                    interfaces must be implemented by OSL to interface the
0006  *                    ACPI components to the host operating system.
0007  *
0008  * Copyright (C) 2000 - 2022, Intel Corp.
0009  *
0010  *****************************************************************************/
0011 
0012 #ifndef __ACPIOSXF_H__
0013 #define __ACPIOSXF_H__
0014 
0015 #include <acpi/platform/acenv.h>
0016 #include <acpi/actypes.h>
0017 
0018 /* Types for acpi_os_execute */
0019 
0020 typedef enum {
0021     OSL_GLOBAL_LOCK_HANDLER,
0022     OSL_NOTIFY_HANDLER,
0023     OSL_GPE_HANDLER,
0024     OSL_DEBUGGER_MAIN_THREAD,
0025     OSL_DEBUGGER_EXEC_THREAD,
0026     OSL_EC_POLL_HANDLER,
0027     OSL_EC_BURST_HANDLER
0028 } acpi_execute_type;
0029 
0030 #define ACPI_NO_UNIT_LIMIT          ((u32) -1)
0031 #define ACPI_MUTEX_SEM              1
0032 
0033 /* Functions for acpi_os_signal */
0034 
0035 #define ACPI_SIGNAL_FATAL           0
0036 #define ACPI_SIGNAL_BREAKPOINT      1
0037 
0038 struct acpi_signal_fatal_info {
0039     u32 type;
0040     u32 code;
0041     u32 argument;
0042 };
0043 
0044 /*
0045  * OSL Initialization and shutdown primitives
0046  */
0047 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_initialize
0048 acpi_status acpi_os_initialize(void);
0049 #endif
0050 
0051 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_terminate
0052 acpi_status acpi_os_terminate(void);
0053 #endif
0054 
0055 /*
0056  * ACPI Table interfaces
0057  */
0058 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_root_pointer
0059 acpi_physical_address acpi_os_get_root_pointer(void);
0060 #endif
0061 
0062 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_predefined_override
0063 acpi_status
0064 acpi_os_predefined_override(const struct acpi_predefined_names *init_val,
0065                 acpi_string *new_val);
0066 #endif
0067 
0068 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_table_override
0069 acpi_status
0070 acpi_os_table_override(struct acpi_table_header *existing_table,
0071                struct acpi_table_header **new_table);
0072 #endif
0073 
0074 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_physical_table_override
0075 acpi_status
0076 acpi_os_physical_table_override(struct acpi_table_header *existing_table,
0077                 acpi_physical_address *new_address,
0078                 u32 *new_table_length);
0079 #endif
0080 
0081 /*
0082  * Spinlock primitives
0083  */
0084 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_create_lock
0085 acpi_status acpi_os_create_lock(acpi_spinlock * out_handle);
0086 #endif
0087 
0088 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_delete_lock
0089 void acpi_os_delete_lock(acpi_spinlock handle);
0090 #endif
0091 
0092 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_acquire_lock
0093 acpi_cpu_flags acpi_os_acquire_lock(acpi_spinlock handle);
0094 #endif
0095 
0096 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_release_lock
0097 void acpi_os_release_lock(acpi_spinlock handle, acpi_cpu_flags flags);
0098 #endif
0099 
0100 /*
0101  * RAW spinlock primitives. If the OS does not provide them, fallback to
0102  * spinlock primitives
0103  */
0104 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_create_raw_lock
0105 # define acpi_os_create_raw_lock(out_handle)    acpi_os_create_lock(out_handle)
0106 #endif
0107 
0108 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_delete_raw_lock
0109 # define acpi_os_delete_raw_lock(handle)    acpi_os_delete_lock(handle)
0110 #endif
0111 
0112 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_acquire_raw_lock
0113 # define acpi_os_acquire_raw_lock(handle)   acpi_os_acquire_lock(handle)
0114 #endif
0115 
0116 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_release_raw_lock
0117 # define acpi_os_release_raw_lock(handle, flags)    \
0118     acpi_os_release_lock(handle, flags)
0119 #endif
0120 
0121 /*
0122  * Semaphore primitives
0123  */
0124 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_create_semaphore
0125 acpi_status
0126 acpi_os_create_semaphore(u32 max_units,
0127              u32 initial_units, acpi_semaphore * out_handle);
0128 #endif
0129 
0130 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_delete_semaphore
0131 acpi_status acpi_os_delete_semaphore(acpi_semaphore handle);
0132 #endif
0133 
0134 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_wait_semaphore
0135 acpi_status
0136 acpi_os_wait_semaphore(acpi_semaphore handle, u32 units, u16 timeout);
0137 #endif
0138 
0139 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_signal_semaphore
0140 acpi_status acpi_os_signal_semaphore(acpi_semaphore handle, u32 units);
0141 #endif
0142 
0143 /*
0144  * Mutex primitives. May be configured to use semaphores instead via
0145  * ACPI_MUTEX_TYPE (see platform/acenv.h)
0146  */
0147 #if (ACPI_MUTEX_TYPE != ACPI_BINARY_SEMAPHORE)
0148 
0149 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_create_mutex
0150 acpi_status acpi_os_create_mutex(acpi_mutex * out_handle);
0151 #endif
0152 
0153 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_delete_mutex
0154 void acpi_os_delete_mutex(acpi_mutex handle);
0155 #endif
0156 
0157 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_acquire_mutex
0158 acpi_status acpi_os_acquire_mutex(acpi_mutex handle, u16 timeout);
0159 #endif
0160 
0161 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_release_mutex
0162 void acpi_os_release_mutex(acpi_mutex handle);
0163 #endif
0164 
0165 #endif
0166 
0167 /*
0168  * Memory allocation and mapping
0169  */
0170 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_allocate
0171 void *acpi_os_allocate(acpi_size size);
0172 #endif
0173 
0174 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_allocate_zeroed
0175 void *acpi_os_allocate_zeroed(acpi_size size);
0176 #endif
0177 
0178 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_free
0179 void acpi_os_free(void *memory);
0180 #endif
0181 
0182 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_map_memory
0183 void *acpi_os_map_memory(acpi_physical_address where, acpi_size length);
0184 #endif
0185 
0186 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_unmap_memory
0187 void acpi_os_unmap_memory(void *logical_address, acpi_size size);
0188 #endif
0189 
0190 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_physical_address
0191 acpi_status
0192 acpi_os_get_physical_address(void *logical_address,
0193                  acpi_physical_address *physical_address);
0194 #endif
0195 
0196 /*
0197  * Memory/Object Cache
0198  */
0199 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_create_cache
0200 acpi_status
0201 acpi_os_create_cache(char *cache_name,
0202              u16 object_size,
0203              u16 max_depth, acpi_cache_t ** return_cache);
0204 #endif
0205 
0206 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_delete_cache
0207 acpi_status acpi_os_delete_cache(acpi_cache_t * cache);
0208 #endif
0209 
0210 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_purge_cache
0211 acpi_status acpi_os_purge_cache(acpi_cache_t * cache);
0212 #endif
0213 
0214 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_acquire_object
0215 void *acpi_os_acquire_object(acpi_cache_t * cache);
0216 #endif
0217 
0218 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_release_object
0219 acpi_status acpi_os_release_object(acpi_cache_t * cache, void *object);
0220 #endif
0221 
0222 /*
0223  * Interrupt handlers
0224  */
0225 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_install_interrupt_handler
0226 acpi_status
0227 acpi_os_install_interrupt_handler(u32 interrupt_number,
0228                   acpi_osd_handler service_routine,
0229                   void *context);
0230 #endif
0231 
0232 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_remove_interrupt_handler
0233 acpi_status
0234 acpi_os_remove_interrupt_handler(u32 interrupt_number,
0235                  acpi_osd_handler service_routine);
0236 #endif
0237 
0238 /*
0239  * Threads and Scheduling
0240  */
0241 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_thread_id
0242 acpi_thread_id acpi_os_get_thread_id(void);
0243 #endif
0244 
0245 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_execute
0246 acpi_status
0247 acpi_os_execute(acpi_execute_type type,
0248         acpi_osd_exec_callback function, void *context);
0249 #endif
0250 
0251 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_wait_events_complete
0252 void acpi_os_wait_events_complete(void);
0253 #endif
0254 
0255 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_sleep
0256 void acpi_os_sleep(u64 milliseconds);
0257 #endif
0258 
0259 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_stall
0260 void acpi_os_stall(u32 microseconds);
0261 #endif
0262 
0263 /*
0264  * Platform and hardware-independent I/O interfaces
0265  */
0266 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_read_port
0267 acpi_status acpi_os_read_port(acpi_io_address address, u32 *value, u32 width);
0268 #endif
0269 
0270 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_write_port
0271 acpi_status acpi_os_write_port(acpi_io_address address, u32 value, u32 width);
0272 #endif
0273 
0274 /*
0275  * Platform and hardware-independent physical memory interfaces
0276  */
0277 int acpi_os_read_iomem(void __iomem *virt_addr, u64 *value, u32 width);
0278 
0279 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_read_memory
0280 acpi_status
0281 acpi_os_read_memory(acpi_physical_address address, u64 *value, u32 width);
0282 #endif
0283 
0284 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_write_memory
0285 acpi_status
0286 acpi_os_write_memory(acpi_physical_address address, u64 value, u32 width);
0287 #endif
0288 
0289 /*
0290  * Platform and hardware-independent PCI configuration space access
0291  * Note: Can't use "Register" as a parameter, changed to "Reg" --
0292  * certain compilers complain.
0293  */
0294 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_read_pci_configuration
0295 acpi_status
0296 acpi_os_read_pci_configuration(struct acpi_pci_id *pci_id,
0297                    u32 reg, u64 *value, u32 width);
0298 #endif
0299 
0300 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_write_pci_configuration
0301 acpi_status
0302 acpi_os_write_pci_configuration(struct acpi_pci_id *pci_id,
0303                 u32 reg, u64 value, u32 width);
0304 #endif
0305 
0306 /*
0307  * Miscellaneous
0308  */
0309 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_readable
0310 u8 acpi_os_readable(void *pointer, acpi_size length);
0311 #endif
0312 
0313 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_writable
0314 u8 acpi_os_writable(void *pointer, acpi_size length);
0315 #endif
0316 
0317 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_timer
0318 u64 acpi_os_get_timer(void);
0319 #endif
0320 
0321 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_signal
0322 acpi_status acpi_os_signal(u32 function, void *info);
0323 #endif
0324 
0325 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_enter_sleep
0326 acpi_status acpi_os_enter_sleep(u8 sleep_state, u32 rega_value, u32 regb_value);
0327 #endif
0328 
0329 /*
0330  * Debug print routines
0331  */
0332 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_printf
0333 ACPI_PRINTF_LIKE(1)
0334 void ACPI_INTERNAL_VAR_XFACE acpi_os_printf(const char *format, ...);
0335 #endif
0336 
0337 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_vprintf
0338 void acpi_os_vprintf(const char *format, va_list args);
0339 #endif
0340 
0341 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_redirect_output
0342 void acpi_os_redirect_output(void *destination);
0343 #endif
0344 
0345 /*
0346  * Debug IO
0347  */
0348 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_line
0349 acpi_status acpi_os_get_line(char *buffer, u32 buffer_length, u32 *bytes_read);
0350 #endif
0351 
0352 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_initialize_debugger
0353 acpi_status acpi_os_initialize_debugger(void);
0354 #endif
0355 
0356 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_terminate_debugger
0357 void acpi_os_terminate_debugger(void);
0358 #endif
0359 
0360 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_wait_command_ready
0361 acpi_status acpi_os_wait_command_ready(void);
0362 #endif
0363 
0364 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_notify_command_complete
0365 acpi_status acpi_os_notify_command_complete(void);
0366 #endif
0367 
0368 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_trace_point
0369 void
0370 acpi_os_trace_point(acpi_trace_event_type type,
0371             u8 begin, u8 *aml, char *pathname);
0372 #endif
0373 
0374 /*
0375  * Obtain ACPI table(s)
0376  */
0377 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_table_by_name
0378 acpi_status
0379 acpi_os_get_table_by_name(char *signature,
0380               u32 instance,
0381               struct acpi_table_header **table,
0382               acpi_physical_address *address);
0383 #endif
0384 
0385 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_table_by_index
0386 acpi_status
0387 acpi_os_get_table_by_index(u32 index,
0388                struct acpi_table_header **table,
0389                u32 *instance, acpi_physical_address *address);
0390 #endif
0391 
0392 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_table_by_address
0393 acpi_status
0394 acpi_os_get_table_by_address(acpi_physical_address address,
0395                  struct acpi_table_header **table);
0396 #endif
0397 
0398 /*
0399  * Directory manipulation
0400  */
0401 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_open_directory
0402 void *acpi_os_open_directory(char *pathname,
0403                  char *wildcard_spec, char requested_file_type);
0404 #endif
0405 
0406 /* requeste_file_type values */
0407 
0408 #define REQUEST_FILE_ONLY                   0
0409 #define REQUEST_DIR_ONLY                    1
0410 
0411 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_next_filename
0412 char *acpi_os_get_next_filename(void *dir_handle);
0413 #endif
0414 
0415 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_close_directory
0416 void acpi_os_close_directory(void *dir_handle);
0417 #endif
0418 
0419 #endif              /* __ACPIOSXF_H__ */