1 /******************************************************************************
3 * Module Name: osunixxf - UNIX OSL interfaces
5 *****************************************************************************/
8 * Copyright (C) 2000 - 2016, Intel Corp.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
45 * These interfaces are required in order to compile the ASL compiler and the
46 * various ACPICA tools under Linux or other Unix-like system.
48 #include <acpi/acpi.h>
59 #include <semaphore.h>
63 #define _COMPONENT ACPI_OS_SERVICES
64 ACPI_MODULE_NAME("osunixxf")
66 /* Upcalls to acpi_exec */
68 ae_table_override(struct acpi_table_header *existing_table,
69 struct acpi_table_header **new_table);
71 typedef void *(*PTHREAD_CALLBACK) (void *);
73 /* Buffer used by acpi_os_vprintf */
75 #define ACPI_VPRINTF_BUFFER_SIZE 512
76 #define _ASCII_NEWLINE '\n'
78 /* Terminal support for acpi_exec only */
83 struct termios original_term_attributes;
84 int term_attributes_were_set = 0;
86 acpi_status acpi_ut_read_line(char *buffer, u32 buffer_length, u32 *bytes_read);
88 static void os_enter_line_edit_mode(void);
90 static void os_exit_line_edit_mode(void);
92 /******************************************************************************
94 * FUNCTION: os_enter_line_edit_mode, os_exit_line_edit_mode
100 * DESCRIPTION: Enter/Exit the raw character input mode for the terminal.
102 * Interactive line-editing support for the AML debugger. Used with the
103 * common/acgetline module.
105 * readline() is not used because of non-portability. It is not available
106 * on all systems, and if it is, often the package must be manually installed.
108 * Therefore, we use the POSIX tcgetattr/tcsetattr and do the minimal line
109 * editing that we need in acpi_os_get_line.
111 * If the POSIX tcgetattr/tcsetattr interfaces are unavailable, these
112 * calls will also work:
113 * For os_enter_line_edit_mode: system ("stty cbreak -echo")
114 * For os_exit_line_edit_mode: system ("stty cooked echo")
116 *****************************************************************************/
118 static void os_enter_line_edit_mode(void)
120 struct termios local_term_attributes;
122 term_attributes_were_set = 0;
124 /* STDIN must be a terminal */
126 if (!isatty(STDIN_FILENO)) {
130 /* Get and keep the original attributes */
132 if (tcgetattr(STDIN_FILENO, &original_term_attributes)) {
133 fprintf(stderr, "Could not get terminal attributes!\n");
137 /* Set the new attributes to enable raw character input */
139 memcpy(&local_term_attributes, &original_term_attributes,
140 sizeof(struct termios));
142 local_term_attributes.c_lflag &= ~(ICANON | ECHO);
143 local_term_attributes.c_cc[VMIN] = 1;
144 local_term_attributes.c_cc[VTIME] = 0;
146 if (tcsetattr(STDIN_FILENO, TCSANOW, &local_term_attributes)) {
147 fprintf(stderr, "Could not set terminal attributes!\n");
151 term_attributes_were_set = 1;
154 static void os_exit_line_edit_mode(void)
157 if (!term_attributes_were_set) {
161 /* Set terminal attributes back to the original values */
163 if (tcsetattr(STDIN_FILENO, TCSANOW, &original_term_attributes)) {
164 fprintf(stderr, "Could not restore terminal attributes!\n");
170 /* These functions are not needed for other ACPICA utilities */
172 #define os_enter_line_edit_mode()
173 #define os_exit_line_edit_mode()
176 /******************************************************************************
178 * FUNCTION: acpi_os_initialize, acpi_os_terminate
184 * DESCRIPTION: Initialize and terminate this module.
186 *****************************************************************************/
188 acpi_status acpi_os_initialize(void)
192 acpi_gbl_output_file = stdout;
194 os_enter_line_edit_mode();
196 status = acpi_os_create_lock(&acpi_gbl_print_lock);
197 if (ACPI_FAILURE(status)) {
204 acpi_status acpi_os_terminate(void)
207 os_exit_line_edit_mode();
211 #ifndef ACPI_USE_NATIVE_RSDP_POINTER
212 /******************************************************************************
214 * FUNCTION: acpi_os_get_root_pointer
218 * RETURN: RSDP physical address
220 * DESCRIPTION: Gets the ACPI root pointer (RSDP)
222 *****************************************************************************/
224 acpi_physical_address acpi_os_get_root_pointer(void)
231 /******************************************************************************
233 * FUNCTION: acpi_os_predefined_override
235 * PARAMETERS: init_val - Initial value of the predefined object
236 * new_val - The new value for the object
238 * RETURN: Status, pointer to value. Null pointer returned if not
241 * DESCRIPTION: Allow the OS to override predefined names
243 *****************************************************************************/
246 acpi_os_predefined_override(const struct acpi_predefined_names *init_val,
247 acpi_string *new_val)
250 if (!init_val || !new_val) {
251 return (AE_BAD_PARAMETER);
258 /******************************************************************************
260 * FUNCTION: acpi_os_table_override
262 * PARAMETERS: existing_table - Header of current table (probably
264 * new_table - Where an entire new table is returned.
266 * RETURN: Status, pointer to new table. Null pointer returned if no
267 * table is available to override
269 * DESCRIPTION: Return a different version of a table if one is available
271 *****************************************************************************/
274 acpi_os_table_override(struct acpi_table_header *existing_table,
275 struct acpi_table_header **new_table)
278 if (!existing_table || !new_table) {
279 return (AE_BAD_PARAMETER);
286 ae_table_override(existing_table, new_table);
290 return (AE_NO_ACPI_TABLES);
294 /******************************************************************************
296 * FUNCTION: acpi_os_physical_table_override
298 * PARAMETERS: existing_table - Header of current table (probably firmware)
299 * new_address - Where new table address is returned
301 * new_table_length - Where new table length is returned
303 * RETURN: Status, address/length of new table. Null pointer returned
304 * if no table is available to override.
306 * DESCRIPTION: Returns AE_SUPPORT, function not used in user space.
308 *****************************************************************************/
311 acpi_os_physical_table_override(struct acpi_table_header *existing_table,
312 acpi_physical_address *new_address,
313 u32 *new_table_length)
319 /******************************************************************************
321 * FUNCTION: acpi_os_redirect_output
323 * PARAMETERS: destination - An open file handle/pointer
327 * DESCRIPTION: Causes redirect of acpi_os_printf and acpi_os_vprintf
329 *****************************************************************************/
331 void acpi_os_redirect_output(void *destination)
334 acpi_gbl_output_file = destination;
337 /******************************************************************************
339 * FUNCTION: acpi_os_printf
341 * PARAMETERS: fmt, ... - Standard printf format
345 * DESCRIPTION: Formatted output. Note: very similar to acpi_os_vprintf
346 * (performance), changes should be tracked in both functions.
348 *****************************************************************************/
350 void ACPI_INTERNAL_VAR_XFACE acpi_os_printf(const char *fmt, ...)
355 flags = acpi_gbl_db_output_flags;
356 if (flags & ACPI_DB_REDIRECTABLE_OUTPUT) {
358 /* Output is directable to either a file (if open) or the console */
360 if (acpi_gbl_debug_file) {
362 /* Output file is open, send the output there */
365 vfprintf(acpi_gbl_debug_file, fmt, args);
368 /* No redirection, send output to console (once only!) */
370 flags |= ACPI_DB_CONSOLE_OUTPUT;
374 if (flags & ACPI_DB_CONSOLE_OUTPUT) {
376 vfprintf(acpi_gbl_output_file, fmt, args);
381 /******************************************************************************
383 * FUNCTION: acpi_os_vprintf
385 * PARAMETERS: fmt - Standard printf format
386 * args - Argument list
390 * DESCRIPTION: Formatted output with argument list pointer. Note: very
391 * similar to acpi_os_printf, changes should be tracked in both
394 *****************************************************************************/
396 void acpi_os_vprintf(const char *fmt, va_list args)
399 char buffer[ACPI_VPRINTF_BUFFER_SIZE];
402 * We build the output string in a local buffer because we may be
403 * outputting the buffer twice. Using vfprintf is problematic because
404 * some implementations modify the args pointer/structure during
405 * execution. Thus, we use the local buffer for portability.
407 * Note: Since this module is intended for use by the various ACPICA
408 * utilities/applications, we can safely declare the buffer on the stack.
409 * Also, This function is used for relatively small error messages only.
411 vsnprintf(buffer, ACPI_VPRINTF_BUFFER_SIZE, fmt, args);
413 flags = acpi_gbl_db_output_flags;
414 if (flags & ACPI_DB_REDIRECTABLE_OUTPUT) {
416 /* Output is directable to either a file (if open) or the console */
418 if (acpi_gbl_debug_file) {
420 /* Output file is open, send the output there */
422 fputs(buffer, acpi_gbl_debug_file);
424 /* No redirection, send output to console (once only!) */
426 flags |= ACPI_DB_CONSOLE_OUTPUT;
430 if (flags & ACPI_DB_CONSOLE_OUTPUT) {
431 fputs(buffer, acpi_gbl_output_file);
435 #ifndef ACPI_EXEC_APP
436 /******************************************************************************
438 * FUNCTION: acpi_os_get_line
440 * PARAMETERS: buffer - Where to return the command line
441 * buffer_length - Maximum length of Buffer
442 * bytes_read - Where the actual byte count is returned
444 * RETURN: Status and actual bytes read
446 * DESCRIPTION: Get the next input line from the terminal. NOTE: For the
447 * acpi_exec utility, we use the acgetline module instead to
448 * provide line-editing and history support.
450 *****************************************************************************/
452 acpi_status acpi_os_get_line(char *buffer, u32 buffer_length, u32 *bytes_read)
457 /* Standard acpi_os_get_line for all utilities except acpi_exec */
459 for (end_of_line = 0;; end_of_line++) {
460 if (end_of_line >= buffer_length) {
461 return (AE_BUFFER_OVERFLOW);
464 if ((input_char = getchar()) == EOF) {
468 if (!input_char || input_char == _ASCII_NEWLINE) {
472 buffer[end_of_line] = (char)input_char;
475 /* Null terminate the buffer */
477 buffer[end_of_line] = 0;
479 /* Return the number of bytes in the string */
482 *bytes_read = end_of_line;
489 #ifndef ACPI_USE_NATIVE_MEMORY_MAPPING
490 /******************************************************************************
492 * FUNCTION: acpi_os_map_memory
494 * PARAMETERS: where - Physical address of memory to be mapped
495 * length - How much memory to map
497 * RETURN: Pointer to mapped memory. Null on error.
499 * DESCRIPTION: Map physical memory into caller's address space
501 *****************************************************************************/
503 void *acpi_os_map_memory(acpi_physical_address where, acpi_size length)
506 return (ACPI_TO_POINTER((acpi_size)where));
509 /******************************************************************************
511 * FUNCTION: acpi_os_unmap_memory
513 * PARAMETERS: where - Logical address of memory to be unmapped
514 * length - How much memory to unmap
518 * DESCRIPTION: Delete a previously created mapping. Where and Length must
519 * correspond to a previous mapping exactly.
521 *****************************************************************************/
523 void acpi_os_unmap_memory(void *where, acpi_size length)
530 /******************************************************************************
532 * FUNCTION: acpi_os_allocate
534 * PARAMETERS: size - Amount to allocate, in bytes
536 * RETURN: Pointer to the new allocation. Null on error.
538 * DESCRIPTION: Allocate memory. Algorithm is dependent on the OS.
540 *****************************************************************************/
542 void *acpi_os_allocate(acpi_size size)
546 mem = (void *)malloc((size_t) size);
550 #ifdef USE_NATIVE_ALLOCATE_ZEROED
551 /******************************************************************************
553 * FUNCTION: acpi_os_allocate_zeroed
555 * PARAMETERS: size - Amount to allocate, in bytes
557 * RETURN: Pointer to the new allocation. Null on error.
559 * DESCRIPTION: Allocate and zero memory. Algorithm is dependent on the OS.
561 *****************************************************************************/
563 void *acpi_os_allocate_zeroed(acpi_size size)
567 mem = (void *)calloc(1, (size_t) size);
572 /******************************************************************************
574 * FUNCTION: acpi_os_free
576 * PARAMETERS: mem - Pointer to previously allocated memory
580 * DESCRIPTION: Free memory allocated via acpi_os_allocate
582 *****************************************************************************/
584 void acpi_os_free(void *mem)
590 #ifdef ACPI_SINGLE_THREADED
591 /******************************************************************************
593 * FUNCTION: Semaphore stub functions
595 * DESCRIPTION: Stub functions used for single-thread applications that do
596 * not require semaphore synchronization. Full implementations
597 * of these functions appear after the stubs.
599 *****************************************************************************/
602 acpi_os_create_semaphore(u32 max_units,
603 u32 initial_units, acpi_handle *out_handle)
605 *out_handle = (acpi_handle)1;
609 acpi_status acpi_os_delete_semaphore(acpi_handle handle)
614 acpi_status acpi_os_wait_semaphore(acpi_handle handle, u32 units, u16 timeout)
619 acpi_status acpi_os_signal_semaphore(acpi_handle handle, u32 units)
625 /******************************************************************************
627 * FUNCTION: acpi_os_create_semaphore
629 * PARAMETERS: initial_units - Units to be assigned to the new semaphore
630 * out_handle - Where a handle will be returned
634 * DESCRIPTION: Create an OS semaphore
636 *****************************************************************************/
639 acpi_os_create_semaphore(u32 max_units,
640 u32 initial_units, acpi_handle *out_handle)
645 return (AE_BAD_PARAMETER);
649 char *semaphore_name = tmpnam(NULL);
652 sem_open(semaphore_name, O_EXCL | O_CREAT, 0755,
655 return (AE_NO_MEMORY);
657 sem_unlink(semaphore_name); /* This just deletes the name */
661 sem = acpi_os_allocate(sizeof(sem_t));
663 return (AE_NO_MEMORY);
666 if (sem_init(sem, 0, initial_units) == -1) {
668 return (AE_BAD_PARAMETER);
672 *out_handle = (acpi_handle)sem;
676 /******************************************************************************
678 * FUNCTION: acpi_os_delete_semaphore
680 * PARAMETERS: handle - Handle returned by acpi_os_create_semaphore
684 * DESCRIPTION: Delete an OS semaphore
686 *****************************************************************************/
688 acpi_status acpi_os_delete_semaphore(acpi_handle handle)
690 sem_t *sem = (sem_t *) handle;
693 return (AE_BAD_PARAMETER);
696 if (sem_destroy(sem) == -1) {
697 return (AE_BAD_PARAMETER);
703 /******************************************************************************
705 * FUNCTION: acpi_os_wait_semaphore
707 * PARAMETERS: handle - Handle returned by acpi_os_create_semaphore
708 * units - How many units to wait for
709 * msec_timeout - How long to wait (milliseconds)
713 * DESCRIPTION: Wait for units
715 *****************************************************************************/
718 acpi_os_wait_semaphore(acpi_handle handle, u32 units, u16 msec_timeout)
720 acpi_status status = AE_OK;
721 sem_t *sem = (sem_t *) handle;
722 #ifndef ACPI_USE_ALTERNATE_TIMEOUT
723 struct timespec time;
728 return (AE_BAD_PARAMETER);
731 switch (msec_timeout) {
735 * A zero timeout value indicates that we shouldn't wait - just
736 * acquire the semaphore if available otherwise return AE_TIME
737 * (a.k.a. 'would block').
741 if (sem_trywait(sem) == -1) {
746 /* Wait Indefinitely */
748 case ACPI_WAIT_FOREVER:
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)) {
807 if (errno != ETIMEDOUT) {
808 perror("sem_timedwait");
819 /******************************************************************************
821 * FUNCTION: acpi_os_signal_semaphore
823 * PARAMETERS: handle - Handle returned by acpi_os_create_semaphore
824 * units - Number of units to send
828 * DESCRIPTION: Send units
830 *****************************************************************************/
832 acpi_status acpi_os_signal_semaphore(acpi_handle handle, u32 units)
834 sem_t *sem = (sem_t *) handle;
837 return (AE_BAD_PARAMETER);
840 if (sem_post(sem) == -1) {
847 #endif /* ACPI_SINGLE_THREADED */
849 /******************************************************************************
851 * FUNCTION: Spinlock interfaces
853 * DESCRIPTION: Map these interfaces to semaphore interfaces
855 *****************************************************************************/
857 acpi_status acpi_os_create_lock(acpi_spinlock * out_handle)
860 return (acpi_os_create_semaphore(1, 1, out_handle));
863 void acpi_os_delete_lock(acpi_spinlock handle)
865 acpi_os_delete_semaphore(handle);
868 acpi_cpu_flags acpi_os_acquire_lock(acpi_handle handle)
870 acpi_os_wait_semaphore(handle, 1, 0xFFFF);
874 void acpi_os_release_lock(acpi_spinlock handle, acpi_cpu_flags flags)
876 acpi_os_signal_semaphore(handle, 1);
879 /******************************************************************************
881 * FUNCTION: acpi_os_install_interrupt_handler
883 * PARAMETERS: interrupt_number - Level handler should respond to.
884 * isr - Address of the ACPI interrupt handler
885 * except_ptr - Where status is returned
887 * RETURN: Handle to the newly installed handler.
889 * DESCRIPTION: Install an interrupt handler. Used to install the ACPI
890 * OS-independent handler.
892 *****************************************************************************/
895 acpi_os_install_interrupt_handler(u32 interrupt_number,
896 acpi_osd_handler service_routine,
903 /******************************************************************************
905 * FUNCTION: acpi_os_remove_interrupt_handler
907 * PARAMETERS: handle - Returned when handler was installed
911 * DESCRIPTION: Uninstalls an interrupt handler.
913 *****************************************************************************/
916 acpi_os_remove_interrupt_handler(u32 interrupt_number,
917 acpi_osd_handler service_routine)
923 /******************************************************************************
925 * FUNCTION: acpi_os_stall
927 * PARAMETERS: microseconds - Time to sleep
929 * RETURN: Blocks until sleep is completed.
931 * DESCRIPTION: Sleep at microsecond granularity
933 *****************************************************************************/
935 void acpi_os_stall(u32 microseconds)
939 usleep(microseconds);
943 /******************************************************************************
945 * FUNCTION: acpi_os_sleep
947 * PARAMETERS: milliseconds - Time to sleep
949 * RETURN: Blocks until sleep is completed.
951 * DESCRIPTION: Sleep at millisecond granularity
953 *****************************************************************************/
955 void acpi_os_sleep(u64 milliseconds)
958 /* Sleep for whole seconds */
960 sleep(milliseconds / ACPI_MSEC_PER_SEC);
963 * Sleep for remaining microseconds.
964 * Arg to usleep() is in usecs and must be less than 1,000,000 (1 second).
966 usleep((milliseconds % ACPI_MSEC_PER_SEC) * ACPI_USEC_PER_MSEC);
969 /******************************************************************************
971 * FUNCTION: acpi_os_get_timer
975 * RETURN: Current time in 100 nanosecond units
977 * DESCRIPTION: Get the current system time
979 *****************************************************************************/
981 u64 acpi_os_get_timer(void)
985 /* This timer has sufficient resolution for user-space application code */
987 gettimeofday(&time, NULL);
989 /* (Seconds * 10^7 = 100ns(10^-7)) + (Microseconds(10^-6) * 10^1 = 100ns) */
991 return (((u64)time.tv_sec * ACPI_100NSEC_PER_SEC) +
992 ((u64)time.tv_usec * ACPI_100NSEC_PER_USEC));
995 /******************************************************************************
997 * FUNCTION: acpi_os_read_pci_configuration
999 * PARAMETERS: pci_id - Seg/Bus/Dev
1000 * pci_register - Device Register
1001 * value - Buffer where value is placed
1002 * width - Number of bits
1006 * DESCRIPTION: Read data from PCI configuration space
1008 *****************************************************************************/
1011 acpi_os_read_pci_configuration(struct acpi_pci_id *pci_id,
1012 u32 pci_register, u64 *value, u32 width)
1019 /******************************************************************************
1021 * FUNCTION: acpi_os_write_pci_configuration
1023 * PARAMETERS: pci_id - Seg/Bus/Dev
1024 * pci_register - Device Register
1025 * value - Value to be written
1026 * width - Number of bits
1030 * DESCRIPTION: Write data to PCI configuration space
1032 *****************************************************************************/
1035 acpi_os_write_pci_configuration(struct acpi_pci_id *pci_id,
1036 u32 pci_register, u64 value, u32 width)
1042 /******************************************************************************
1044 * FUNCTION: acpi_os_read_port
1046 * PARAMETERS: address - Address of I/O port/register to read
1047 * value - Where value is placed
1048 * width - Number of bits
1050 * RETURN: Value read from port
1052 * DESCRIPTION: Read data from an I/O port or register
1054 *****************************************************************************/
1056 acpi_status acpi_os_read_port(acpi_io_address address, u32 *value, u32 width)
1072 *value = 0xFFFFFFFF;
1077 return (AE_BAD_PARAMETER);
1083 /******************************************************************************
1085 * FUNCTION: acpi_os_write_port
1087 * PARAMETERS: address - Address of I/O port/register to write
1088 * value - Value to write
1089 * width - Number of bits
1093 * DESCRIPTION: Write data to an I/O port or register
1095 *****************************************************************************/
1097 acpi_status acpi_os_write_port(acpi_io_address address, u32 value, u32 width)
1103 /******************************************************************************
1105 * FUNCTION: acpi_os_read_memory
1107 * PARAMETERS: address - Physical Memory Address to read
1108 * value - Where value is placed
1109 * width - Number of bits (8,16,32, or 64)
1111 * RETURN: Value read from physical memory address. Always returned
1112 * as a 64-bit integer, regardless of the read width.
1114 * DESCRIPTION: Read data from a physical memory address
1116 *****************************************************************************/
1119 acpi_os_read_memory(acpi_physical_address address, u64 *value, u32 width)
1133 return (AE_BAD_PARAMETER);
1138 /******************************************************************************
1140 * FUNCTION: acpi_os_write_memory
1142 * PARAMETERS: address - Physical Memory Address to write
1143 * value - Value to write
1144 * width - Number of bits (8,16,32, or 64)
1148 * DESCRIPTION: Write data to a physical memory address
1150 *****************************************************************************/
1153 acpi_os_write_memory(acpi_physical_address address, u64 value, u32 width)
1159 /******************************************************************************
1161 * FUNCTION: acpi_os_readable
1163 * PARAMETERS: pointer - Area to be verified
1164 * length - Size of area
1166 * RETURN: TRUE if readable for entire length
1168 * DESCRIPTION: Verify that a pointer is valid for reading
1170 *****************************************************************************/
1172 u8 acpi_os_readable(void *pointer, acpi_size length)
1178 /******************************************************************************
1180 * FUNCTION: acpi_os_writable
1182 * PARAMETERS: pointer - Area to be verified
1183 * length - Size of area
1185 * RETURN: TRUE if writable for entire length
1187 * DESCRIPTION: Verify that a pointer is valid for writing
1189 *****************************************************************************/
1191 u8 acpi_os_writable(void *pointer, acpi_size length)
1197 /******************************************************************************
1199 * FUNCTION: acpi_os_signal
1201 * PARAMETERS: function - ACPI A signal function code
1202 * info - Pointer to function-dependent structure
1206 * DESCRIPTION: Miscellaneous functions. Example implementation only.
1208 *****************************************************************************/
1210 acpi_status acpi_os_signal(u32 function, void *info)
1214 case ACPI_SIGNAL_FATAL:
1218 case ACPI_SIGNAL_BREAKPOINT:
1230 /* Optional multi-thread support */
1232 #ifndef ACPI_SINGLE_THREADED
1233 /******************************************************************************
1235 * FUNCTION: acpi_os_get_thread_id
1239 * RETURN: Id of the running thread
1241 * DESCRIPTION: Get the ID of the current (running) thread
1243 *****************************************************************************/
1245 acpi_thread_id acpi_os_get_thread_id(void)
1249 thread = pthread_self();
1250 return (ACPI_CAST_PTHREAD_T(thread));
1253 /******************************************************************************
1255 * FUNCTION: acpi_os_execute
1257 * PARAMETERS: type - Type of execution
1258 * function - Address of the function to execute
1259 * context - Passed as a parameter to the function
1263 * DESCRIPTION: Execute a new thread
1265 *****************************************************************************/
1268 acpi_os_execute(acpi_execute_type type,
1269 acpi_osd_exec_callback function, void *context)
1275 pthread_create(&thread, NULL, (PTHREAD_CALLBACK) function, context);
1277 acpi_os_printf("Create thread failed");
1282 #else /* ACPI_SINGLE_THREADED */
1283 acpi_thread_id acpi_os_get_thread_id(void)
1289 acpi_os_execute(acpi_execute_type type,
1290 acpi_osd_exec_callback function, void *context)
1298 #endif /* ACPI_SINGLE_THREADED */
1300 /******************************************************************************
1302 * FUNCTION: acpi_os_wait_events_complete
1308 * DESCRIPTION: Wait for all asynchronous events to complete. This
1309 * implementation does nothing.
1311 *****************************************************************************/
1313 void acpi_os_wait_events_complete(void)