1 // SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
2 /******************************************************************************
4 * Module Name: osunixxf - UNIX OSL interfaces
6 * Copyright (C) 2000 - 2023, Intel Corp.
8 *****************************************************************************/
11 * These interfaces are required in order to compile the ASL compiler and the
12 * various ACPICA tools under Linux or other Unix-like system.
14 #include <acpi/acpi.h>
25 #include <semaphore.h>
29 #define _COMPONENT ACPI_OS_SERVICES
30 ACPI_MODULE_NAME("osunixxf")
32 /* Upcalls to acpi_exec */
34 ae_table_override(struct acpi_table_header *existing_table,
35 struct acpi_table_header **new_table);
37 typedef void *(*PTHREAD_CALLBACK) (void *);
39 /* Buffer used by acpi_os_vprintf */
41 #define ACPI_VPRINTF_BUFFER_SIZE 512
42 #define _ASCII_NEWLINE '\n'
44 /* Terminal support for acpi_exec only */
49 struct termios original_term_attributes;
50 int term_attributes_were_set = 0;
52 acpi_status acpi_ut_read_line(char *buffer, u32 buffer_length, u32 *bytes_read);
54 static void os_enter_line_edit_mode(void);
56 static void os_exit_line_edit_mode(void);
58 /******************************************************************************
60 * FUNCTION: os_enter_line_edit_mode, os_exit_line_edit_mode
66 * DESCRIPTION: Enter/Exit the raw character input mode for the terminal.
68 * Interactive line-editing support for the AML debugger. Used with the
69 * common/acgetline module.
71 * readline() is not used because of non-portability. It is not available
72 * on all systems, and if it is, often the package must be manually installed.
74 * Therefore, we use the POSIX tcgetattr/tcsetattr and do the minimal line
75 * editing that we need in acpi_os_get_line.
77 * If the POSIX tcgetattr/tcsetattr interfaces are unavailable, these
78 * calls will also work:
79 * For os_enter_line_edit_mode: system ("stty cbreak -echo")
80 * For os_exit_line_edit_mode: system ("stty cooked echo")
82 *****************************************************************************/
84 static void os_enter_line_edit_mode(void)
86 struct termios local_term_attributes;
88 term_attributes_were_set = 0;
90 /* STDIN must be a terminal */
92 if (!isatty(STDIN_FILENO)) {
96 /* Get and keep the original attributes */
98 if (tcgetattr(STDIN_FILENO, &original_term_attributes)) {
99 fprintf(stderr, "Could not get terminal attributes!\n");
103 /* Set the new attributes to enable raw character input */
105 memcpy(&local_term_attributes, &original_term_attributes,
106 sizeof(struct termios));
108 local_term_attributes.c_lflag &= ~(ICANON | ECHO);
109 local_term_attributes.c_cc[VMIN] = 1;
110 local_term_attributes.c_cc[VTIME] = 0;
112 if (tcsetattr(STDIN_FILENO, TCSANOW, &local_term_attributes)) {
113 fprintf(stderr, "Could not set terminal attributes!\n");
117 term_attributes_were_set = 1;
120 static void os_exit_line_edit_mode(void)
123 if (!term_attributes_were_set) {
127 /* Set terminal attributes back to the original values */
129 if (tcsetattr(STDIN_FILENO, TCSANOW, &original_term_attributes)) {
130 fprintf(stderr, "Could not restore terminal attributes!\n");
136 /* These functions are not needed for other ACPICA utilities */
138 #define os_enter_line_edit_mode()
139 #define os_exit_line_edit_mode()
142 /******************************************************************************
144 * FUNCTION: acpi_os_initialize, acpi_os_terminate
150 * DESCRIPTION: Initialize and terminate this module.
152 *****************************************************************************/
154 acpi_status acpi_os_initialize(void)
158 acpi_gbl_output_file = stdout;
160 os_enter_line_edit_mode();
162 status = acpi_os_create_lock(&acpi_gbl_print_lock);
163 if (ACPI_FAILURE(status)) {
170 acpi_status acpi_os_terminate(void)
173 os_exit_line_edit_mode();
177 #ifndef ACPI_USE_NATIVE_RSDP_POINTER
178 /******************************************************************************
180 * FUNCTION: acpi_os_get_root_pointer
184 * RETURN: RSDP physical address
186 * DESCRIPTION: Gets the ACPI root pointer (RSDP)
188 *****************************************************************************/
190 acpi_physical_address acpi_os_get_root_pointer(void)
197 /******************************************************************************
199 * FUNCTION: acpi_os_predefined_override
201 * PARAMETERS: init_val - Initial value of the predefined object
202 * new_val - The new value for the object
204 * RETURN: Status, pointer to value. Null pointer returned if not
207 * DESCRIPTION: Allow the OS to override predefined names
209 *****************************************************************************/
212 acpi_os_predefined_override(const struct acpi_predefined_names *init_val,
213 acpi_string *new_val)
216 if (!init_val || !new_val) {
217 return (AE_BAD_PARAMETER);
224 /******************************************************************************
226 * FUNCTION: acpi_os_table_override
228 * PARAMETERS: existing_table - Header of current table (probably
230 * new_table - Where an entire new table is returned.
232 * RETURN: Status, pointer to new table. Null pointer returned if no
233 * table is available to override
235 * DESCRIPTION: Return a different version of a table if one is available
237 *****************************************************************************/
240 acpi_os_table_override(struct acpi_table_header *existing_table,
241 struct acpi_table_header **new_table)
244 if (!existing_table || !new_table) {
245 return (AE_BAD_PARAMETER);
252 ae_table_override(existing_table, new_table);
256 return (AE_NO_ACPI_TABLES);
260 /******************************************************************************
262 * FUNCTION: acpi_os_physical_table_override
264 * PARAMETERS: existing_table - Header of current table (probably firmware)
265 * new_address - Where new table address is returned
267 * new_table_length - Where new table length is returned
269 * RETURN: Status, address/length of new table. Null pointer returned
270 * if no table is available to override.
272 * DESCRIPTION: Returns AE_SUPPORT, function not used in user space.
274 *****************************************************************************/
277 acpi_os_physical_table_override(struct acpi_table_header *existing_table,
278 acpi_physical_address *new_address,
279 u32 *new_table_length)
285 /******************************************************************************
287 * FUNCTION: acpi_os_enter_sleep
289 * PARAMETERS: sleep_state - Which sleep state to enter
290 * rega_value - Register A value
291 * regb_value - Register B value
295 * DESCRIPTION: A hook before writing sleep registers to enter the sleep
296 * state. Return AE_CTRL_TERMINATE to skip further sleep register
299 *****************************************************************************/
301 acpi_status acpi_os_enter_sleep(u8 sleep_state, u32 rega_value, u32 regb_value)
307 /******************************************************************************
309 * FUNCTION: acpi_os_redirect_output
311 * PARAMETERS: destination - An open file handle/pointer
315 * DESCRIPTION: Causes redirect of acpi_os_printf and acpi_os_vprintf
317 *****************************************************************************/
319 void acpi_os_redirect_output(void *destination)
322 acpi_gbl_output_file = destination;
325 /******************************************************************************
327 * FUNCTION: acpi_os_printf
329 * PARAMETERS: fmt, ... - Standard printf format
333 * DESCRIPTION: Formatted output. Note: very similar to acpi_os_vprintf
334 * (performance), changes should be tracked in both functions.
336 *****************************************************************************/
338 void ACPI_INTERNAL_VAR_XFACE acpi_os_printf(const char *fmt, ...)
343 flags = acpi_gbl_db_output_flags;
344 if (flags & ACPI_DB_REDIRECTABLE_OUTPUT) {
346 /* Output is directable to either a file (if open) or the console */
348 if (acpi_gbl_debug_file) {
350 /* Output file is open, send the output there */
353 vfprintf(acpi_gbl_debug_file, fmt, args);
356 /* No redirection, send output to console (once only!) */
358 flags |= ACPI_DB_CONSOLE_OUTPUT;
362 if (flags & ACPI_DB_CONSOLE_OUTPUT) {
364 vfprintf(acpi_gbl_output_file, fmt, args);
369 /******************************************************************************
371 * FUNCTION: acpi_os_vprintf
373 * PARAMETERS: fmt - Standard printf format
374 * args - Argument list
378 * DESCRIPTION: Formatted output with argument list pointer. Note: very
379 * similar to acpi_os_printf, changes should be tracked in both
382 *****************************************************************************/
384 void acpi_os_vprintf(const char *fmt, va_list args)
387 char buffer[ACPI_VPRINTF_BUFFER_SIZE];
390 * We build the output string in a local buffer because we may be
391 * outputting the buffer twice. Using vfprintf is problematic because
392 * some implementations modify the args pointer/structure during
393 * execution. Thus, we use the local buffer for portability.
395 * Note: Since this module is intended for use by the various ACPICA
396 * utilities/applications, we can safely declare the buffer on the stack.
397 * Also, This function is used for relatively small error messages only.
399 vsnprintf(buffer, ACPI_VPRINTF_BUFFER_SIZE, fmt, args);
401 flags = acpi_gbl_db_output_flags;
402 if (flags & ACPI_DB_REDIRECTABLE_OUTPUT) {
404 /* Output is directable to either a file (if open) or the console */
406 if (acpi_gbl_debug_file) {
408 /* Output file is open, send the output there */
410 fputs(buffer, acpi_gbl_debug_file);
412 /* No redirection, send output to console (once only!) */
414 flags |= ACPI_DB_CONSOLE_OUTPUT;
418 if (flags & ACPI_DB_CONSOLE_OUTPUT) {
419 fputs(buffer, acpi_gbl_output_file);
423 #ifndef ACPI_EXEC_APP
424 /******************************************************************************
426 * FUNCTION: acpi_os_get_line
428 * PARAMETERS: buffer - Where to return the command line
429 * buffer_length - Maximum length of Buffer
430 * bytes_read - Where the actual byte count is returned
432 * RETURN: Status and actual bytes read
434 * DESCRIPTION: Get the next input line from the terminal. NOTE: For the
435 * acpi_exec utility, we use the acgetline module instead to
436 * provide line-editing and history support.
438 *****************************************************************************/
440 acpi_status acpi_os_get_line(char *buffer, u32 buffer_length, u32 *bytes_read)
445 /* Standard acpi_os_get_line for all utilities except acpi_exec */
447 for (end_of_line = 0;; end_of_line++) {
448 if (end_of_line >= buffer_length) {
449 return (AE_BUFFER_OVERFLOW);
452 if ((input_char = getchar()) == EOF) {
456 if (!input_char || input_char == _ASCII_NEWLINE) {
460 buffer[end_of_line] = (char)input_char;
463 /* Null terminate the buffer */
465 buffer[end_of_line] = 0;
467 /* Return the number of bytes in the string */
470 *bytes_read = end_of_line;
477 #ifndef ACPI_USE_NATIVE_MEMORY_MAPPING
478 /******************************************************************************
480 * FUNCTION: acpi_os_map_memory
482 * PARAMETERS: where - Physical address of memory to be mapped
483 * length - How much memory to map
485 * RETURN: Pointer to mapped memory. Null on error.
487 * DESCRIPTION: Map physical memory into caller's address space
489 *****************************************************************************/
491 void *acpi_os_map_memory(acpi_physical_address where, acpi_size length)
494 return (ACPI_TO_POINTER((acpi_size)where));
497 /******************************************************************************
499 * FUNCTION: acpi_os_unmap_memory
501 * PARAMETERS: where - Logical address of memory to be unmapped
502 * length - How much memory to unmap
506 * DESCRIPTION: Delete a previously created mapping. Where and Length must
507 * correspond to a previous mapping exactly.
509 *****************************************************************************/
511 void acpi_os_unmap_memory(void *where, acpi_size length)
518 /******************************************************************************
520 * FUNCTION: acpi_os_allocate
522 * PARAMETERS: size - Amount to allocate, in bytes
524 * RETURN: Pointer to the new allocation. Null on error.
526 * DESCRIPTION: Allocate memory. Algorithm is dependent on the OS.
528 *****************************************************************************/
530 void *acpi_os_allocate(acpi_size size)
534 mem = (void *)malloc((size_t) size);
538 #ifdef USE_NATIVE_ALLOCATE_ZEROED
539 /******************************************************************************
541 * FUNCTION: acpi_os_allocate_zeroed
543 * PARAMETERS: size - Amount to allocate, in bytes
545 * RETURN: Pointer to the new allocation. Null on error.
547 * DESCRIPTION: Allocate and zero memory. Algorithm is dependent on the OS.
549 *****************************************************************************/
551 void *acpi_os_allocate_zeroed(acpi_size size)
555 mem = (void *)calloc(1, (size_t) size);
560 /******************************************************************************
562 * FUNCTION: acpi_os_free
564 * PARAMETERS: mem - Pointer to previously allocated memory
568 * DESCRIPTION: Free memory allocated via acpi_os_allocate
570 *****************************************************************************/
572 void acpi_os_free(void *mem)
578 #ifdef ACPI_SINGLE_THREADED
579 /******************************************************************************
581 * FUNCTION: Semaphore stub functions
583 * DESCRIPTION: Stub functions used for single-thread applications that do
584 * not require semaphore synchronization. Full implementations
585 * of these functions appear after the stubs.
587 *****************************************************************************/
590 acpi_os_create_semaphore(u32 max_units,
591 u32 initial_units, acpi_handle *out_handle)
593 *out_handle = (acpi_handle)1;
597 acpi_status acpi_os_delete_semaphore(acpi_handle handle)
602 acpi_status acpi_os_wait_semaphore(acpi_handle handle, u32 units, u16 timeout)
607 acpi_status acpi_os_signal_semaphore(acpi_handle handle, u32 units)
613 /******************************************************************************
615 * FUNCTION: acpi_os_create_semaphore
617 * PARAMETERS: initial_units - Units to be assigned to the new semaphore
618 * out_handle - Where a handle will be returned
622 * DESCRIPTION: Create an OS semaphore
624 *****************************************************************************/
627 acpi_os_create_semaphore(u32 max_units,
628 u32 initial_units, acpi_handle *out_handle)
633 return (AE_BAD_PARAMETER);
637 static int semaphore_count = 0;
638 char semaphore_name[32];
640 snprintf(semaphore_name, sizeof(semaphore_name), "acpi_sem_%d",
642 printf("%s\n", semaphore_name);
644 sem_open(semaphore_name, O_EXCL | O_CREAT, 0755,
647 return (AE_NO_MEMORY);
649 sem_unlink(semaphore_name); /* This just deletes the name */
653 sem = acpi_os_allocate(sizeof(sem_t));
655 return (AE_NO_MEMORY);
658 if (sem_init(sem, 0, initial_units) == -1) {
660 return (AE_BAD_PARAMETER);
664 *out_handle = (acpi_handle)sem;
668 /******************************************************************************
670 * FUNCTION: acpi_os_delete_semaphore
672 * PARAMETERS: handle - Handle returned by acpi_os_create_semaphore
676 * DESCRIPTION: Delete an OS semaphore
678 *****************************************************************************/
680 acpi_status acpi_os_delete_semaphore(acpi_handle handle)
682 sem_t *sem = (sem_t *) handle;
685 return (AE_BAD_PARAMETER);
688 if (sem_close(sem) == -1) {
689 return (AE_BAD_PARAMETER);
692 if (sem_destroy(sem) == -1) {
693 return (AE_BAD_PARAMETER);
700 /******************************************************************************
702 * FUNCTION: acpi_os_wait_semaphore
704 * PARAMETERS: handle - Handle returned by acpi_os_create_semaphore
705 * units - How many units to wait for
706 * msec_timeout - How long to wait (milliseconds)
710 * DESCRIPTION: Wait for units
712 *****************************************************************************/
715 acpi_os_wait_semaphore(acpi_handle handle, u32 units, u16 msec_timeout)
717 acpi_status status = AE_OK;
718 sem_t *sem = (sem_t *) handle;
720 #ifndef ACPI_USE_ALTERNATE_TIMEOUT
721 struct timespec time;
725 return (AE_BAD_PARAMETER);
728 switch (msec_timeout) {
732 * A zero timeout value indicates that we shouldn't wait - just
733 * acquire the semaphore if available otherwise return AE_TIME
734 * (a.k.a. 'would block').
738 if (sem_trywait(sem) == -1) {
743 /* Wait Indefinitely */
745 case ACPI_WAIT_FOREVER:
747 while (((ret_val = sem_wait(sem)) == -1) && (errno == EINTR)) {
748 continue; /* Restart if interrupted */
755 /* Wait with msec_timeout */
759 #ifdef ACPI_USE_ALTERNATE_TIMEOUT
761 * Alternate timeout mechanism for environments where
762 * sem_timedwait is not available or does not work properly.
764 while (msec_timeout) {
765 if (sem_trywait(sem) == 0) {
767 /* Got the semaphore */
771 if (msec_timeout >= 10) {
773 usleep(10 * ACPI_USEC_PER_MSEC); /* ten milliseconds */
776 usleep(ACPI_USEC_PER_MSEC); /* one millisecond */
782 * The interface to sem_timedwait is an absolute time, so we need to
783 * get the current time, then add in the millisecond Timeout value.
785 if (clock_gettime(CLOCK_REALTIME, &time) == -1) {
786 perror("clock_gettime");
790 time.tv_sec += (msec_timeout / ACPI_MSEC_PER_SEC);
792 ((msec_timeout % ACPI_MSEC_PER_SEC) * ACPI_NSEC_PER_MSEC);
794 /* Handle nanosecond overflow (field must be less than one second) */
796 if (time.tv_nsec >= ACPI_NSEC_PER_SEC) {
797 time.tv_sec += (time.tv_nsec / ACPI_NSEC_PER_SEC);
798 time.tv_nsec = (time.tv_nsec % ACPI_NSEC_PER_SEC);
801 while (((ret_val = sem_timedwait(sem, &time)) == -1)
802 && (errno == EINTR)) {
803 continue; /* Restart if interrupted */
808 if (errno != ETIMEDOUT) {
809 perror("sem_timedwait");
820 /******************************************************************************
822 * FUNCTION: acpi_os_signal_semaphore
824 * PARAMETERS: handle - Handle returned by acpi_os_create_semaphore
825 * units - Number of units to send
829 * DESCRIPTION: Send units
831 *****************************************************************************/
833 acpi_status acpi_os_signal_semaphore(acpi_handle handle, u32 units)
835 sem_t *sem = (sem_t *) handle;
838 return (AE_BAD_PARAMETER);
841 if (sem_post(sem) == -1) {
848 #endif /* ACPI_SINGLE_THREADED */
850 /******************************************************************************
852 * FUNCTION: Spinlock interfaces
854 * DESCRIPTION: Map these interfaces to semaphore interfaces
856 *****************************************************************************/
858 acpi_status acpi_os_create_lock(acpi_spinlock * out_handle)
861 return (acpi_os_create_semaphore(1, 1, out_handle));
864 void acpi_os_delete_lock(acpi_spinlock handle)
866 acpi_os_delete_semaphore(handle);
869 acpi_cpu_flags acpi_os_acquire_lock(acpi_handle handle)
871 acpi_os_wait_semaphore(handle, 1, 0xFFFF);
875 void acpi_os_release_lock(acpi_spinlock handle, acpi_cpu_flags flags)
877 acpi_os_signal_semaphore(handle, 1);
880 /******************************************************************************
882 * FUNCTION: acpi_os_install_interrupt_handler
884 * PARAMETERS: interrupt_number - Level handler should respond to.
885 * isr - Address of the ACPI interrupt handler
886 * except_ptr - Where status is returned
888 * RETURN: Handle to the newly installed handler.
890 * DESCRIPTION: Install an interrupt handler. Used to install the ACPI
891 * OS-independent handler.
893 *****************************************************************************/
896 acpi_os_install_interrupt_handler(u32 interrupt_number,
897 acpi_osd_handler service_routine,
904 /******************************************************************************
906 * FUNCTION: acpi_os_remove_interrupt_handler
908 * PARAMETERS: handle - Returned when handler was installed
912 * DESCRIPTION: Uninstalls an interrupt handler.
914 *****************************************************************************/
917 acpi_os_remove_interrupt_handler(u32 interrupt_number,
918 acpi_osd_handler service_routine)
924 /******************************************************************************
926 * FUNCTION: acpi_os_stall
928 * PARAMETERS: microseconds - Time to sleep
930 * RETURN: Blocks until sleep is completed.
932 * DESCRIPTION: Sleep at microsecond granularity
934 *****************************************************************************/
936 void acpi_os_stall(u32 microseconds)
940 usleep(microseconds);
944 /******************************************************************************
946 * FUNCTION: acpi_os_sleep
948 * PARAMETERS: milliseconds - Time to sleep
950 * RETURN: Blocks until sleep is completed.
952 * DESCRIPTION: Sleep at millisecond granularity
954 *****************************************************************************/
956 void acpi_os_sleep(u64 milliseconds)
959 /* Sleep for whole seconds */
961 sleep(milliseconds / ACPI_MSEC_PER_SEC);
964 * Sleep for remaining microseconds.
965 * Arg to usleep() is in usecs and must be less than 1,000,000 (1 second).
967 usleep((milliseconds % ACPI_MSEC_PER_SEC) * ACPI_USEC_PER_MSEC);
970 /******************************************************************************
972 * FUNCTION: acpi_os_get_timer
976 * RETURN: Current time in 100 nanosecond units
978 * DESCRIPTION: Get the current system time
980 *****************************************************************************/
982 u64 acpi_os_get_timer(void)
986 /* This timer has sufficient resolution for user-space application code */
988 gettimeofday(&time, NULL);
990 /* (Seconds * 10^7 = 100ns(10^-7)) + (Microseconds(10^-6) * 10^1 = 100ns) */
992 return (((u64)time.tv_sec * ACPI_100NSEC_PER_SEC) +
993 ((u64)time.tv_usec * ACPI_100NSEC_PER_USEC));
996 /******************************************************************************
998 * FUNCTION: acpi_os_read_pci_configuration
1000 * PARAMETERS: pci_id - Seg/Bus/Dev
1001 * pci_register - Device Register
1002 * value - Buffer where value is placed
1003 * width - Number of bits
1007 * DESCRIPTION: Read data from PCI configuration space
1009 *****************************************************************************/
1012 acpi_os_read_pci_configuration(struct acpi_pci_id *pci_id,
1013 u32 pci_register, u64 *value, u32 width)
1020 /******************************************************************************
1022 * FUNCTION: acpi_os_write_pci_configuration
1024 * PARAMETERS: pci_id - Seg/Bus/Dev
1025 * pci_register - Device Register
1026 * value - Value to be written
1027 * width - Number of bits
1031 * DESCRIPTION: Write data to PCI configuration space
1033 *****************************************************************************/
1036 acpi_os_write_pci_configuration(struct acpi_pci_id *pci_id,
1037 u32 pci_register, u64 value, u32 width)
1043 /******************************************************************************
1045 * FUNCTION: acpi_os_read_port
1047 * PARAMETERS: address - Address of I/O port/register to read
1048 * value - Where value is placed
1049 * width - Number of bits
1051 * RETURN: Value read from port
1053 * DESCRIPTION: Read data from an I/O port or register
1055 *****************************************************************************/
1057 acpi_status acpi_os_read_port(acpi_io_address address, u32 *value, u32 width)
1073 *value = 0xFFFFFFFF;
1078 return (AE_BAD_PARAMETER);
1084 /******************************************************************************
1086 * FUNCTION: acpi_os_write_port
1088 * PARAMETERS: address - Address of I/O port/register to write
1089 * value - Value to write
1090 * width - Number of bits
1094 * DESCRIPTION: Write data to an I/O port or register
1096 *****************************************************************************/
1098 acpi_status acpi_os_write_port(acpi_io_address address, u32 value, u32 width)
1104 /******************************************************************************
1106 * FUNCTION: acpi_os_read_memory
1108 * PARAMETERS: address - Physical Memory Address to read
1109 * value - Where value is placed
1110 * width - Number of bits (8,16,32, or 64)
1112 * RETURN: Value read from physical memory address. Always returned
1113 * as a 64-bit integer, regardless of the read width.
1115 * DESCRIPTION: Read data from a physical memory address
1117 *****************************************************************************/
1120 acpi_os_read_memory(acpi_physical_address address, u64 *value, u32 width)
1134 return (AE_BAD_PARAMETER);
1139 /******************************************************************************
1141 * FUNCTION: acpi_os_write_memory
1143 * PARAMETERS: address - Physical Memory Address to write
1144 * value - Value to write
1145 * width - Number of bits (8,16,32, or 64)
1149 * DESCRIPTION: Write data to a physical memory address
1151 *****************************************************************************/
1154 acpi_os_write_memory(acpi_physical_address address, u64 value, u32 width)
1160 /******************************************************************************
1162 * FUNCTION: acpi_os_readable
1164 * PARAMETERS: pointer - Area to be verified
1165 * length - Size of area
1167 * RETURN: TRUE if readable for entire length
1169 * DESCRIPTION: Verify that a pointer is valid for reading
1171 *****************************************************************************/
1173 u8 acpi_os_readable(void *pointer, acpi_size length)
1179 /******************************************************************************
1181 * FUNCTION: acpi_os_writable
1183 * PARAMETERS: pointer - Area to be verified
1184 * length - Size of area
1186 * RETURN: TRUE if writable for entire length
1188 * DESCRIPTION: Verify that a pointer is valid for writing
1190 *****************************************************************************/
1192 u8 acpi_os_writable(void *pointer, acpi_size length)
1198 /******************************************************************************
1200 * FUNCTION: acpi_os_signal
1202 * PARAMETERS: function - ACPI A signal function code
1203 * info - Pointer to function-dependent structure
1207 * DESCRIPTION: Miscellaneous functions. Example implementation only.
1209 *****************************************************************************/
1211 acpi_status acpi_os_signal(u32 function, void *info)
1215 case ACPI_SIGNAL_FATAL:
1219 case ACPI_SIGNAL_BREAKPOINT:
1231 /* Optional multi-thread support */
1233 #ifndef ACPI_SINGLE_THREADED
1234 /******************************************************************************
1236 * FUNCTION: acpi_os_get_thread_id
1240 * RETURN: Id of the running thread
1242 * DESCRIPTION: Get the ID of the current (running) thread
1244 *****************************************************************************/
1246 acpi_thread_id acpi_os_get_thread_id(void)
1250 thread = pthread_self();
1251 return (ACPI_CAST_PTHREAD_T(thread));
1254 /******************************************************************************
1256 * FUNCTION: acpi_os_execute
1258 * PARAMETERS: type - Type of execution
1259 * function - Address of the function to execute
1260 * context - Passed as a parameter to the function
1264 * DESCRIPTION: Execute a new thread
1266 *****************************************************************************/
1269 acpi_os_execute(acpi_execute_type type,
1270 acpi_osd_exec_callback function, void *context)
1276 pthread_create(&thread, NULL, (PTHREAD_CALLBACK) function, context);
1278 acpi_os_printf("Create thread failed");
1283 #else /* ACPI_SINGLE_THREADED */
1284 acpi_thread_id acpi_os_get_thread_id(void)
1290 acpi_os_execute(acpi_execute_type type,
1291 acpi_osd_exec_callback function, void *context)
1299 #endif /* ACPI_SINGLE_THREADED */
1301 /******************************************************************************
1303 * FUNCTION: acpi_os_wait_events_complete
1309 * DESCRIPTION: Wait for all asynchronous events to complete. This
1310 * implementation does nothing.
1312 *****************************************************************************/
1314 void acpi_os_wait_events_complete(void)