1 /******************************************************************************
3 * Module Name: osunixxf - UNIX OSL interfaces
5 *****************************************************************************/
8 * Copyright (C) 2000 - 2014, 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.
59 #include <semaphore.h>
63 #define _COMPONENT ACPI_OS_SERVICES
64 ACPI_MODULE_NAME ("osunixxf")
67 BOOLEAN AcpiGbl_DebugTimeout = FALSE;
70 /* Upcalls to AcpiExec */
74 ACPI_TABLE_HEADER *ExistingTable,
75 ACPI_TABLE_HEADER **NewTable);
77 typedef void* (*PTHREAD_CALLBACK) (void *);
79 /* Buffer used by AcpiOsVprintf */
81 #define ACPI_VPRINTF_BUFFER_SIZE 512
82 #define _ASCII_NEWLINE '\n'
84 /* Terminal support for AcpiExec only */
89 struct termios OriginalTermAttributes;
90 int TermAttributesWereSet = 0;
107 /******************************************************************************
109 * FUNCTION: OsEnterLineEditMode, OsExitLineEditMode
115 * DESCRIPTION: Enter/Exit the raw character input mode for the terminal.
117 * Interactive line-editing support for the AML debugger. Used with the
118 * common/acgetline module.
120 * readline() is not used because of non-portability. It is not available
121 * on all systems, and if it is, often the package must be manually installed.
123 * Therefore, we use the POSIX tcgetattr/tcsetattr and do the minimal line
124 * editing that we need in AcpiOsGetLine.
126 * If the POSIX tcgetattr/tcsetattr interfaces are unavailable, these
127 * calls will also work:
128 * For OsEnterLineEditMode: system ("stty cbreak -echo")
129 * For OsExitLineEditMode: system ("stty cooked echo")
131 *****************************************************************************/
134 OsEnterLineEditMode (
137 struct termios LocalTermAttributes;
140 TermAttributesWereSet = 0;
142 /* STDIN must be a terminal */
144 if (!isatty (STDIN_FILENO))
149 /* Get and keep the original attributes */
151 if (tcgetattr (STDIN_FILENO, &OriginalTermAttributes))
153 fprintf (stderr, "Could not get terminal attributes!\n");
157 /* Set the new attributes to enable raw character input */
159 memcpy (&LocalTermAttributes, &OriginalTermAttributes,
160 sizeof (struct termios));
162 LocalTermAttributes.c_lflag &= ~(ICANON | ECHO);
163 LocalTermAttributes.c_cc[VMIN] = 1;
164 LocalTermAttributes.c_cc[VTIME] = 0;
166 if (tcsetattr (STDIN_FILENO, TCSANOW, &LocalTermAttributes))
168 fprintf (stderr, "Could not set terminal attributes!\n");
172 TermAttributesWereSet = 1;
181 if (!TermAttributesWereSet)
186 /* Set terminal attributes back to the original values */
188 if (tcsetattr (STDIN_FILENO, TCSANOW, &OriginalTermAttributes))
190 fprintf (stderr, "Could not restore terminal attributes!\n");
197 /* These functions are not needed for other ACPICA utilities */
199 #define OsEnterLineEditMode()
200 #define OsExitLineEditMode()
204 /******************************************************************************
206 * FUNCTION: AcpiOsInitialize, AcpiOsTerminate
212 * DESCRIPTION: Initialize and terminate this module.
214 *****************************************************************************/
223 AcpiGbl_OutputFile = stdout;
225 OsEnterLineEditMode ();
227 Status = AcpiOsCreateLock (&AcpiGbl_PrintLock);
228 if (ACPI_FAILURE (Status))
241 OsExitLineEditMode ();
246 #ifndef ACPI_USE_NATIVE_RSDP_POINTER
247 /******************************************************************************
249 * FUNCTION: AcpiOsGetRootPointer
253 * RETURN: RSDP physical address
255 * DESCRIPTION: Gets the ACPI root pointer (RSDP)
257 *****************************************************************************/
259 ACPI_PHYSICAL_ADDRESS
260 AcpiOsGetRootPointer (
269 /******************************************************************************
271 * FUNCTION: AcpiOsPredefinedOverride
273 * PARAMETERS: InitVal - Initial value of the predefined object
274 * NewVal - The new value for the object
276 * RETURN: Status, pointer to value. Null pointer returned if not
279 * DESCRIPTION: Allow the OS to override predefined names
281 *****************************************************************************/
284 AcpiOsPredefinedOverride (
285 const ACPI_PREDEFINED_NAMES *InitVal,
289 if (!InitVal || !NewVal)
291 return (AE_BAD_PARAMETER);
299 /******************************************************************************
301 * FUNCTION: AcpiOsTableOverride
303 * PARAMETERS: ExistingTable - Header of current table (probably
305 * NewTable - Where an entire new table is returned.
307 * RETURN: Status, pointer to new table. Null pointer returned if no
308 * table is available to override
310 * DESCRIPTION: Return a different version of a table if one is available
312 *****************************************************************************/
315 AcpiOsTableOverride (
316 ACPI_TABLE_HEADER *ExistingTable,
317 ACPI_TABLE_HEADER **NewTable)
320 if (!ExistingTable || !NewTable)
322 return (AE_BAD_PARAMETER);
329 AeTableOverride (ExistingTable, NewTable);
333 return (AE_NO_ACPI_TABLES);
338 /******************************************************************************
340 * FUNCTION: AcpiOsPhysicalTableOverride
342 * PARAMETERS: ExistingTable - Header of current table (probably firmware)
343 * NewAddress - Where new table address is returned
345 * NewTableLength - Where new table length is returned
347 * RETURN: Status, address/length of new table. Null pointer returned
348 * if no table is available to override.
350 * DESCRIPTION: Returns AE_SUPPORT, function not used in user space.
352 *****************************************************************************/
355 AcpiOsPhysicalTableOverride (
356 ACPI_TABLE_HEADER *ExistingTable,
357 ACPI_PHYSICAL_ADDRESS *NewAddress,
358 UINT32 *NewTableLength)
365 /******************************************************************************
367 * FUNCTION: AcpiOsRedirectOutput
369 * PARAMETERS: Destination - An open file handle/pointer
373 * DESCRIPTION: Causes redirect of AcpiOsPrintf and AcpiOsVprintf
375 *****************************************************************************/
378 AcpiOsRedirectOutput (
382 AcpiGbl_OutputFile = Destination;
386 /******************************************************************************
388 * FUNCTION: AcpiOsPrintf
390 * PARAMETERS: fmt, ... - Standard printf format
394 * DESCRIPTION: Formatted output. Note: very similar to AcpiOsVprintf
395 * (performance), changes should be tracked in both functions.
397 *****************************************************************************/
399 void ACPI_INTERNAL_VAR_XFACE
408 Flags = AcpiGbl_DbOutputFlags;
409 if (Flags & ACPI_DB_REDIRECTABLE_OUTPUT)
411 /* Output is directable to either a file (if open) or the console */
413 if (AcpiGbl_DebugFile)
415 /* Output file is open, send the output there */
417 va_start (Args, Fmt);
418 vfprintf (AcpiGbl_DebugFile, Fmt, Args);
423 /* No redirection, send output to console (once only!) */
425 Flags |= ACPI_DB_CONSOLE_OUTPUT;
429 if (Flags & ACPI_DB_CONSOLE_OUTPUT)
431 va_start (Args, Fmt);
432 vfprintf (AcpiGbl_OutputFile, Fmt, Args);
438 /******************************************************************************
440 * FUNCTION: AcpiOsVprintf
442 * PARAMETERS: fmt - Standard printf format
443 * args - Argument list
447 * DESCRIPTION: Formatted output with argument list pointer. Note: very
448 * similar to AcpiOsPrintf, changes should be tracked in both
451 *****************************************************************************/
459 char Buffer[ACPI_VPRINTF_BUFFER_SIZE];
463 * We build the output string in a local buffer because we may be
464 * outputting the buffer twice. Using vfprintf is problematic because
465 * some implementations modify the args pointer/structure during
466 * execution. Thus, we use the local buffer for portability.
468 * Note: Since this module is intended for use by the various ACPICA
469 * utilities/applications, we can safely declare the buffer on the stack.
470 * Also, This function is used for relatively small error messages only.
472 vsnprintf (Buffer, ACPI_VPRINTF_BUFFER_SIZE, Fmt, Args);
474 Flags = AcpiGbl_DbOutputFlags;
475 if (Flags & ACPI_DB_REDIRECTABLE_OUTPUT)
477 /* Output is directable to either a file (if open) or the console */
479 if (AcpiGbl_DebugFile)
481 /* Output file is open, send the output there */
483 fputs (Buffer, AcpiGbl_DebugFile);
487 /* No redirection, send output to console (once only!) */
489 Flags |= ACPI_DB_CONSOLE_OUTPUT;
493 if (Flags & ACPI_DB_CONSOLE_OUTPUT)
495 fputs (Buffer, AcpiGbl_OutputFile);
500 #ifndef ACPI_EXEC_APP
501 /******************************************************************************
503 * FUNCTION: AcpiOsGetLine
505 * PARAMETERS: Buffer - Where to return the command line
506 * BufferLength - Maximum length of Buffer
507 * BytesRead - Where the actual byte count is returned
509 * RETURN: Status and actual bytes read
511 * DESCRIPTION: Get the next input line from the terminal. NOTE: For the
512 * AcpiExec utility, we use the acgetline module instead to
513 * provide line-editing and history support.
515 *****************************************************************************/
527 /* Standard AcpiOsGetLine for all utilities except AcpiExec */
529 for (EndOfLine = 0; ; EndOfLine++)
531 if (EndOfLine >= BufferLength)
533 return (AE_BUFFER_OVERFLOW);
536 if ((InputChar = getchar ()) == EOF)
541 if (!InputChar || InputChar == _ASCII_NEWLINE)
546 Buffer[EndOfLine] = (char) InputChar;
549 /* Null terminate the buffer */
551 Buffer[EndOfLine] = 0;
553 /* Return the number of bytes in the string */
557 *BytesRead = EndOfLine;
565 #ifndef ACPI_USE_NATIVE_MEMORY_MAPPING
566 /******************************************************************************
568 * FUNCTION: AcpiOsMapMemory
570 * PARAMETERS: where - Physical address of memory to be mapped
571 * length - How much memory to map
573 * RETURN: Pointer to mapped memory. Null on error.
575 * DESCRIPTION: Map physical memory into caller's address space
577 *****************************************************************************/
581 ACPI_PHYSICAL_ADDRESS where,
585 return (ACPI_TO_POINTER ((ACPI_SIZE) where));
589 /******************************************************************************
591 * FUNCTION: AcpiOsUnmapMemory
593 * PARAMETERS: where - Logical address of memory to be unmapped
594 * length - How much memory to unmap
598 * DESCRIPTION: Delete a previously created mapping. Where and Length must
599 * correspond to a previous mapping exactly.
601 *****************************************************************************/
614 /******************************************************************************
616 * FUNCTION: AcpiOsAllocate
618 * PARAMETERS: Size - Amount to allocate, in bytes
620 * RETURN: Pointer to the new allocation. Null on error.
622 * DESCRIPTION: Allocate memory. Algorithm is dependent on the OS.
624 *****************************************************************************/
633 Mem = (void *) malloc ((size_t) size);
638 #ifdef USE_NATIVE_ALLOCATE_ZEROED
639 /******************************************************************************
641 * FUNCTION: AcpiOsAllocateZeroed
643 * PARAMETERS: Size - Amount to allocate, in bytes
645 * RETURN: Pointer to the new allocation. Null on error.
647 * DESCRIPTION: Allocate and zero memory. Algorithm is dependent on the OS.
649 *****************************************************************************/
652 AcpiOsAllocateZeroed (
658 Mem = (void *) calloc (1, (size_t) size);
664 /******************************************************************************
666 * FUNCTION: AcpiOsFree
668 * PARAMETERS: mem - Pointer to previously allocated memory
672 * DESCRIPTION: Free memory allocated via AcpiOsAllocate
674 *****************************************************************************/
685 #ifdef ACPI_SINGLE_THREADED
686 /******************************************************************************
688 * FUNCTION: Semaphore stub functions
690 * DESCRIPTION: Stub functions used for single-thread applications that do
691 * not require semaphore synchronization. Full implementations
692 * of these functions appear after the stubs.
694 *****************************************************************************/
697 AcpiOsCreateSemaphore (
700 ACPI_HANDLE *OutHandle)
702 *OutHandle = (ACPI_HANDLE) 1;
707 AcpiOsDeleteSemaphore (
714 AcpiOsWaitSemaphore (
723 AcpiOsSignalSemaphore (
731 /******************************************************************************
733 * FUNCTION: AcpiOsCreateSemaphore
735 * PARAMETERS: InitialUnits - Units to be assigned to the new semaphore
736 * OutHandle - Where a handle will be returned
740 * DESCRIPTION: Create an OS semaphore
742 *****************************************************************************/
745 AcpiOsCreateSemaphore (
748 ACPI_HANDLE *OutHandle)
755 return (AE_BAD_PARAMETER);
760 char *SemaphoreName = tmpnam (NULL);
762 Sem = sem_open (SemaphoreName, O_EXCL|O_CREAT, 0755, InitialUnits);
765 return (AE_NO_MEMORY);
767 sem_unlink (SemaphoreName); /* This just deletes the name */
771 Sem = AcpiOsAllocate (sizeof (sem_t));
774 return (AE_NO_MEMORY);
777 if (sem_init (Sem, 0, InitialUnits) == -1)
780 return (AE_BAD_PARAMETER);
784 *OutHandle = (ACPI_HANDLE) Sem;
789 /******************************************************************************
791 * FUNCTION: AcpiOsDeleteSemaphore
793 * PARAMETERS: Handle - Handle returned by AcpiOsCreateSemaphore
797 * DESCRIPTION: Delete an OS semaphore
799 *****************************************************************************/
802 AcpiOsDeleteSemaphore (
805 sem_t *Sem = (sem_t *) Handle;
810 return (AE_BAD_PARAMETER);
813 if (sem_destroy (Sem) == -1)
815 return (AE_BAD_PARAMETER);
822 /******************************************************************************
824 * FUNCTION: AcpiOsWaitSemaphore
826 * PARAMETERS: Handle - Handle returned by AcpiOsCreateSemaphore
827 * Units - How many units to wait for
828 * MsecTimeout - How long to wait (milliseconds)
832 * DESCRIPTION: Wait for units
834 *****************************************************************************/
837 AcpiOsWaitSemaphore (
842 ACPI_STATUS Status = AE_OK;
843 sem_t *Sem = (sem_t *) Handle;
844 #ifndef ACPI_USE_ALTERNATE_TIMEOUT
845 struct timespec Time;
852 return (AE_BAD_PARAMETER);
860 * A zero timeout value indicates that we shouldn't wait - just
861 * acquire the semaphore if available otherwise return AE_TIME
862 * (a.k.a. 'would block').
866 if (sem_trywait(Sem) == -1)
872 /* Wait Indefinitely */
874 case ACPI_WAIT_FOREVER:
882 /* Wait with MsecTimeout */
886 #ifdef ACPI_USE_ALTERNATE_TIMEOUT
888 * Alternate timeout mechanism for environments where
889 * sem_timedwait is not available or does not work properly.
893 if (sem_trywait (Sem) == 0)
895 /* Got the semaphore */
899 if (MsecTimeout >= 10)
902 usleep (10 * ACPI_USEC_PER_MSEC); /* ten milliseconds */
907 usleep (ACPI_USEC_PER_MSEC); /* one millisecond */
913 * The interface to sem_timedwait is an absolute time, so we need to
914 * get the current time, then add in the millisecond Timeout value.
916 if (clock_gettime (CLOCK_REALTIME, &Time) == -1)
918 perror ("clock_gettime");
922 Time.tv_sec += (MsecTimeout / ACPI_MSEC_PER_SEC);
923 Time.tv_nsec += ((MsecTimeout % ACPI_MSEC_PER_SEC) * ACPI_NSEC_PER_MSEC);
925 /* Handle nanosecond overflow (field must be less than one second) */
927 if (Time.tv_nsec >= ACPI_NSEC_PER_SEC)
929 Time.tv_sec += (Time.tv_nsec / ACPI_NSEC_PER_SEC);
930 Time.tv_nsec = (Time.tv_nsec % ACPI_NSEC_PER_SEC);
933 while (((RetVal = sem_timedwait (Sem, &Time)) == -1) && (errno == EINTR))
940 if (errno != ETIMEDOUT)
942 perror ("sem_timedwait");
954 /******************************************************************************
956 * FUNCTION: AcpiOsSignalSemaphore
958 * PARAMETERS: Handle - Handle returned by AcpiOsCreateSemaphore
959 * Units - Number of units to send
963 * DESCRIPTION: Send units
965 *****************************************************************************/
968 AcpiOsSignalSemaphore (
972 sem_t *Sem = (sem_t *)Handle;
977 return (AE_BAD_PARAMETER);
980 if (sem_post (Sem) == -1)
988 #endif /* ACPI_SINGLE_THREADED */
991 /******************************************************************************
993 * FUNCTION: Spinlock interfaces
995 * DESCRIPTION: Map these interfaces to semaphore interfaces
997 *****************************************************************************/
1001 ACPI_SPINLOCK *OutHandle)
1004 return (AcpiOsCreateSemaphore (1, 1, OutHandle));
1010 ACPI_SPINLOCK Handle)
1012 AcpiOsDeleteSemaphore (Handle);
1020 AcpiOsWaitSemaphore (Handle, 1, 0xFFFF);
1027 ACPI_SPINLOCK Handle,
1028 ACPI_CPU_FLAGS Flags)
1030 AcpiOsSignalSemaphore (Handle, 1);
1034 /******************************************************************************
1036 * FUNCTION: AcpiOsInstallInterruptHandler
1038 * PARAMETERS: InterruptNumber - Level handler should respond to.
1039 * Isr - Address of the ACPI interrupt handler
1040 * ExceptPtr - Where status is returned
1042 * RETURN: Handle to the newly installed handler.
1044 * DESCRIPTION: Install an interrupt handler. Used to install the ACPI
1045 * OS-independent handler.
1047 *****************************************************************************/
1050 AcpiOsInstallInterruptHandler (
1051 UINT32 InterruptNumber,
1052 ACPI_OSD_HANDLER ServiceRoutine,
1060 /******************************************************************************
1062 * FUNCTION: AcpiOsRemoveInterruptHandler
1064 * PARAMETERS: Handle - Returned when handler was installed
1068 * DESCRIPTION: Uninstalls an interrupt handler.
1070 *****************************************************************************/
1073 AcpiOsRemoveInterruptHandler (
1074 UINT32 InterruptNumber,
1075 ACPI_OSD_HANDLER ServiceRoutine)
1082 /******************************************************************************
1084 * FUNCTION: AcpiOsStall
1086 * PARAMETERS: microseconds - Time to sleep
1088 * RETURN: Blocks until sleep is completed.
1090 * DESCRIPTION: Sleep at microsecond granularity
1092 *****************************************************************************/
1096 UINT32 microseconds)
1101 usleep (microseconds);
1106 /******************************************************************************
1108 * FUNCTION: AcpiOsSleep
1110 * PARAMETERS: milliseconds - Time to sleep
1112 * RETURN: Blocks until sleep is completed.
1114 * DESCRIPTION: Sleep at millisecond granularity
1116 *****************************************************************************/
1120 UINT64 milliseconds)
1123 /* Sleep for whole seconds */
1125 sleep (milliseconds / ACPI_MSEC_PER_SEC);
1128 * Sleep for remaining microseconds.
1129 * Arg to usleep() is in usecs and must be less than 1,000,000 (1 second).
1131 usleep ((milliseconds % ACPI_MSEC_PER_SEC) * ACPI_USEC_PER_MSEC);
1135 /******************************************************************************
1137 * FUNCTION: AcpiOsGetTimer
1141 * RETURN: Current time in 100 nanosecond units
1143 * DESCRIPTION: Get the current system time
1145 *****************************************************************************/
1151 struct timeval time;
1154 /* This timer has sufficient resolution for user-space application code */
1156 gettimeofday (&time, NULL);
1158 /* (Seconds * 10^7 = 100ns(10^-7)) + (Microseconds(10^-6) * 10^1 = 100ns) */
1160 return (((UINT64) time.tv_sec * ACPI_100NSEC_PER_SEC) +
1161 ((UINT64) time.tv_usec * ACPI_100NSEC_PER_USEC));
1165 /******************************************************************************
1167 * FUNCTION: AcpiOsReadPciConfiguration
1169 * PARAMETERS: PciId - Seg/Bus/Dev
1170 * PciRegister - Device Register
1171 * Value - Buffer where value is placed
1172 * Width - Number of bits
1176 * DESCRIPTION: Read data from PCI configuration space
1178 *****************************************************************************/
1181 AcpiOsReadPciConfiguration (
1193 /******************************************************************************
1195 * FUNCTION: AcpiOsWritePciConfiguration
1197 * PARAMETERS: PciId - Seg/Bus/Dev
1198 * PciRegister - Device Register
1199 * Value - Value to be written
1200 * Width - Number of bits
1204 * DESCRIPTION: Write data to PCI configuration space
1206 *****************************************************************************/
1209 AcpiOsWritePciConfiguration (
1220 /******************************************************************************
1222 * FUNCTION: AcpiOsReadPort
1224 * PARAMETERS: Address - Address of I/O port/register to read
1225 * Value - Where value is placed
1226 * Width - Number of bits
1228 * RETURN: Value read from port
1230 * DESCRIPTION: Read data from an I/O port or register
1232 *****************************************************************************/
1236 ACPI_IO_ADDRESS Address,
1255 *Value = 0xFFFFFFFF;
1260 return (AE_BAD_PARAMETER);
1267 /******************************************************************************
1269 * FUNCTION: AcpiOsWritePort
1271 * PARAMETERS: Address - Address of I/O port/register to write
1272 * Value - Value to write
1273 * Width - Number of bits
1277 * DESCRIPTION: Write data to an I/O port or register
1279 *****************************************************************************/
1283 ACPI_IO_ADDRESS Address,
1292 /******************************************************************************
1294 * FUNCTION: AcpiOsReadMemory
1296 * PARAMETERS: Address - Physical Memory Address to read
1297 * Value - Where value is placed
1298 * Width - Number of bits (8,16,32, or 64)
1300 * RETURN: Value read from physical memory address. Always returned
1301 * as a 64-bit integer, regardless of the read width.
1303 * DESCRIPTION: Read data from a physical memory address
1305 *****************************************************************************/
1309 ACPI_PHYSICAL_ADDRESS Address,
1326 return (AE_BAD_PARAMETER);
1332 /******************************************************************************
1334 * FUNCTION: AcpiOsWriteMemory
1336 * PARAMETERS: Address - Physical Memory Address to write
1337 * Value - Value to write
1338 * Width - Number of bits (8,16,32, or 64)
1342 * DESCRIPTION: Write data to a physical memory address
1344 *****************************************************************************/
1348 ACPI_PHYSICAL_ADDRESS Address,
1357 /******************************************************************************
1359 * FUNCTION: AcpiOsReadable
1361 * PARAMETERS: Pointer - Area to be verified
1362 * Length - Size of area
1364 * RETURN: TRUE if readable for entire length
1366 * DESCRIPTION: Verify that a pointer is valid for reading
1368 *****************************************************************************/
1380 /******************************************************************************
1382 * FUNCTION: AcpiOsWritable
1384 * PARAMETERS: Pointer - Area to be verified
1385 * Length - Size of area
1387 * RETURN: TRUE if writable for entire length
1389 * DESCRIPTION: Verify that a pointer is valid for writing
1391 *****************************************************************************/
1403 /******************************************************************************
1405 * FUNCTION: AcpiOsSignal
1407 * PARAMETERS: Function - ACPI A signal function code
1408 * Info - Pointer to function-dependent structure
1412 * DESCRIPTION: Miscellaneous functions. Example implementation only.
1414 *****************************************************************************/
1424 case ACPI_SIGNAL_FATAL:
1428 case ACPI_SIGNAL_BREAKPOINT:
1440 /* Optional multi-thread support */
1442 #ifndef ACPI_SINGLE_THREADED
1443 /******************************************************************************
1445 * FUNCTION: AcpiOsGetThreadId
1449 * RETURN: Id of the running thread
1451 * DESCRIPTION: Get the ID of the current (running) thread
1453 *****************************************************************************/
1462 thread = pthread_self();
1463 return (ACPI_CAST_PTHREAD_T (thread));
1467 /******************************************************************************
1469 * FUNCTION: AcpiOsExecute
1471 * PARAMETERS: Type - Type of execution
1472 * Function - Address of the function to execute
1473 * Context - Passed as a parameter to the function
1477 * DESCRIPTION: Execute a new thread
1479 *****************************************************************************/
1483 ACPI_EXECUTE_TYPE Type,
1484 ACPI_OSD_EXEC_CALLBACK Function,
1491 ret = pthread_create (&thread, NULL, (PTHREAD_CALLBACK) Function, Context);
1494 AcpiOsPrintf("Create thread failed");
1499 #else /* ACPI_SINGLE_THREADED */
1509 ACPI_EXECUTE_TYPE Type,
1510 ACPI_OSD_EXEC_CALLBACK Function,
1519 #endif /* ACPI_SINGLE_THREADED */
1522 /******************************************************************************
1524 * FUNCTION: AcpiOsWaitEventsComplete
1530 * DESCRIPTION: Wait for all asynchronous events to complete. This
1531 * implementation does nothing.
1533 *****************************************************************************/
1536 AcpiOsWaitEventsComplete (