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.
59 #include <semaphore.h>
63 #define _COMPONENT ACPI_OS_SERVICES
64 ACPI_MODULE_NAME ("osunixxf")
67 /* Upcalls to AcpiExec */
71 ACPI_TABLE_HEADER
*ExistingTable
,
72 ACPI_TABLE_HEADER
**NewTable
);
74 typedef void* (*PTHREAD_CALLBACK
) (void *);
76 /* Buffer used by AcpiOsVprintf */
78 #define ACPI_VPRINTF_BUFFER_SIZE 512
79 #define _ASCII_NEWLINE '\n'
81 /* Terminal support for AcpiExec only */
86 struct termios OriginalTermAttributes
;
87 int TermAttributesWereSet
= 0;
104 /******************************************************************************
106 * FUNCTION: OsEnterLineEditMode, OsExitLineEditMode
112 * DESCRIPTION: Enter/Exit the raw character input mode for the terminal.
114 * Interactive line-editing support for the AML debugger. Used with the
115 * common/acgetline module.
117 * readline() is not used because of non-portability. It is not available
118 * on all systems, and if it is, often the package must be manually installed.
120 * Therefore, we use the POSIX tcgetattr/tcsetattr and do the minimal line
121 * editing that we need in AcpiOsGetLine.
123 * If the POSIX tcgetattr/tcsetattr interfaces are unavailable, these
124 * calls will also work:
125 * For OsEnterLineEditMode: system ("stty cbreak -echo")
126 * For OsExitLineEditMode: system ("stty cooked echo")
128 *****************************************************************************/
131 OsEnterLineEditMode (
134 struct termios LocalTermAttributes
;
137 TermAttributesWereSet
= 0;
139 /* STDIN must be a terminal */
141 if (!isatty (STDIN_FILENO
))
146 /* Get and keep the original attributes */
148 if (tcgetattr (STDIN_FILENO
, &OriginalTermAttributes
))
150 fprintf (stderr
, "Could not get terminal attributes!\n");
154 /* Set the new attributes to enable raw character input */
156 memcpy (&LocalTermAttributes
, &OriginalTermAttributes
,
157 sizeof (struct termios
));
159 LocalTermAttributes
.c_lflag
&= ~(ICANON
| ECHO
);
160 LocalTermAttributes
.c_cc
[VMIN
] = 1;
161 LocalTermAttributes
.c_cc
[VTIME
] = 0;
163 if (tcsetattr (STDIN_FILENO
, TCSANOW
, &LocalTermAttributes
))
165 fprintf (stderr
, "Could not set terminal attributes!\n");
169 TermAttributesWereSet
= 1;
178 if (!TermAttributesWereSet
)
183 /* Set terminal attributes back to the original values */
185 if (tcsetattr (STDIN_FILENO
, TCSANOW
, &OriginalTermAttributes
))
187 fprintf (stderr
, "Could not restore terminal attributes!\n");
194 /* These functions are not needed for other ACPICA utilities */
196 #define OsEnterLineEditMode()
197 #define OsExitLineEditMode()
201 /******************************************************************************
203 * FUNCTION: AcpiOsInitialize, AcpiOsTerminate
209 * DESCRIPTION: Initialize and terminate this module.
211 *****************************************************************************/
220 AcpiGbl_OutputFile
= stdout
;
222 OsEnterLineEditMode ();
224 Status
= AcpiOsCreateLock (&AcpiGbl_PrintLock
);
225 if (ACPI_FAILURE (Status
))
238 OsExitLineEditMode ();
243 #ifndef ACPI_USE_NATIVE_RSDP_POINTER
244 /******************************************************************************
246 * FUNCTION: AcpiOsGetRootPointer
250 * RETURN: RSDP physical address
252 * DESCRIPTION: Gets the ACPI root pointer (RSDP)
254 *****************************************************************************/
256 ACPI_PHYSICAL_ADDRESS
257 AcpiOsGetRootPointer (
266 /******************************************************************************
268 * FUNCTION: AcpiOsPredefinedOverride
270 * PARAMETERS: InitVal - Initial value of the predefined object
271 * NewVal - The new value for the object
273 * RETURN: Status, pointer to value. Null pointer returned if not
276 * DESCRIPTION: Allow the OS to override predefined names
278 *****************************************************************************/
281 AcpiOsPredefinedOverride (
282 const ACPI_PREDEFINED_NAMES
*InitVal
,
286 if (!InitVal
|| !NewVal
)
288 return (AE_BAD_PARAMETER
);
296 /******************************************************************************
298 * FUNCTION: AcpiOsTableOverride
300 * PARAMETERS: ExistingTable - Header of current table (probably
302 * NewTable - Where an entire new table is returned.
304 * RETURN: Status, pointer to new table. Null pointer returned if no
305 * table is available to override
307 * DESCRIPTION: Return a different version of a table if one is available
309 *****************************************************************************/
312 AcpiOsTableOverride (
313 ACPI_TABLE_HEADER
*ExistingTable
,
314 ACPI_TABLE_HEADER
**NewTable
)
317 if (!ExistingTable
|| !NewTable
)
319 return (AE_BAD_PARAMETER
);
326 AeTableOverride (ExistingTable
, NewTable
);
330 return (AE_NO_ACPI_TABLES
);
335 /******************************************************************************
337 * FUNCTION: AcpiOsPhysicalTableOverride
339 * PARAMETERS: ExistingTable - Header of current table (probably firmware)
340 * NewAddress - Where new table address is returned
342 * NewTableLength - Where new table length is returned
344 * RETURN: Status, address/length of new table. Null pointer returned
345 * if no table is available to override.
347 * DESCRIPTION: Returns AE_SUPPORT, function not used in user space.
349 *****************************************************************************/
352 AcpiOsPhysicalTableOverride (
353 ACPI_TABLE_HEADER
*ExistingTable
,
354 ACPI_PHYSICAL_ADDRESS
*NewAddress
,
355 UINT32
*NewTableLength
)
362 /******************************************************************************
364 * FUNCTION: AcpiOsEnterSleep
366 * PARAMETERS: SleepState - Which sleep state to enter
367 * RegaValue - Register A value
368 * RegbValue - Register B value
372 * DESCRIPTION: A hook before writing sleep registers to enter the sleep
373 * state. Return AE_CTRL_SKIP to skip further sleep register
376 *****************************************************************************/
389 /******************************************************************************
391 * FUNCTION: AcpiOsRedirectOutput
393 * PARAMETERS: Destination - An open file handle/pointer
397 * DESCRIPTION: Causes redirect of AcpiOsPrintf and AcpiOsVprintf
399 *****************************************************************************/
402 AcpiOsRedirectOutput (
406 AcpiGbl_OutputFile
= Destination
;
410 /******************************************************************************
412 * FUNCTION: AcpiOsPrintf
414 * PARAMETERS: fmt, ... - Standard printf format
418 * DESCRIPTION: Formatted output. Note: very similar to AcpiOsVprintf
419 * (performance), changes should be tracked in both functions.
421 *****************************************************************************/
423 void ACPI_INTERNAL_VAR_XFACE
432 Flags
= AcpiGbl_DbOutputFlags
;
433 if (Flags
& ACPI_DB_REDIRECTABLE_OUTPUT
)
435 /* Output is directable to either a file (if open) or the console */
437 if (AcpiGbl_DebugFile
)
439 /* Output file is open, send the output there */
441 va_start (Args
, Fmt
);
442 vfprintf (AcpiGbl_DebugFile
, Fmt
, Args
);
447 /* No redirection, send output to console (once only!) */
449 Flags
|= ACPI_DB_CONSOLE_OUTPUT
;
453 if (Flags
& ACPI_DB_CONSOLE_OUTPUT
)
455 va_start (Args
, Fmt
);
456 vfprintf (AcpiGbl_OutputFile
, Fmt
, Args
);
462 /******************************************************************************
464 * FUNCTION: AcpiOsVprintf
466 * PARAMETERS: fmt - Standard printf format
467 * args - Argument list
471 * DESCRIPTION: Formatted output with argument list pointer. Note: very
472 * similar to AcpiOsPrintf, changes should be tracked in both
475 *****************************************************************************/
483 char Buffer
[ACPI_VPRINTF_BUFFER_SIZE
];
487 * We build the output string in a local buffer because we may be
488 * outputting the buffer twice. Using vfprintf is problematic because
489 * some implementations modify the args pointer/structure during
490 * execution. Thus, we use the local buffer for portability.
492 * Note: Since this module is intended for use by the various ACPICA
493 * utilities/applications, we can safely declare the buffer on the stack.
494 * Also, This function is used for relatively small error messages only.
496 vsnprintf (Buffer
, ACPI_VPRINTF_BUFFER_SIZE
, Fmt
, Args
);
498 Flags
= AcpiGbl_DbOutputFlags
;
499 if (Flags
& ACPI_DB_REDIRECTABLE_OUTPUT
)
501 /* Output is directable to either a file (if open) or the console */
503 if (AcpiGbl_DebugFile
)
505 /* Output file is open, send the output there */
507 fputs (Buffer
, AcpiGbl_DebugFile
);
511 /* No redirection, send output to console (once only!) */
513 Flags
|= ACPI_DB_CONSOLE_OUTPUT
;
517 if (Flags
& ACPI_DB_CONSOLE_OUTPUT
)
519 fputs (Buffer
, AcpiGbl_OutputFile
);
524 #ifndef ACPI_EXEC_APP
525 /******************************************************************************
527 * FUNCTION: AcpiOsGetLine
529 * PARAMETERS: Buffer - Where to return the command line
530 * BufferLength - Maximum length of Buffer
531 * BytesRead - Where the actual byte count is returned
533 * RETURN: Status and actual bytes read
535 * DESCRIPTION: Get the next input line from the terminal. NOTE: For the
536 * AcpiExec utility, we use the acgetline module instead to
537 * provide line-editing and history support.
539 *****************************************************************************/
551 /* Standard AcpiOsGetLine for all utilities except AcpiExec */
553 for (EndOfLine
= 0; ; EndOfLine
++)
555 if (EndOfLine
>= BufferLength
)
557 return (AE_BUFFER_OVERFLOW
);
560 if ((InputChar
= getchar ()) == EOF
)
565 if (!InputChar
|| InputChar
== _ASCII_NEWLINE
)
570 Buffer
[EndOfLine
] = (char) InputChar
;
573 /* Null terminate the buffer */
575 Buffer
[EndOfLine
] = 0;
577 /* Return the number of bytes in the string */
581 *BytesRead
= EndOfLine
;
589 #ifndef ACPI_USE_NATIVE_MEMORY_MAPPING
590 /******************************************************************************
592 * FUNCTION: AcpiOsMapMemory
594 * PARAMETERS: where - Physical address of memory to be mapped
595 * length - How much memory to map
597 * RETURN: Pointer to mapped memory. Null on error.
599 * DESCRIPTION: Map physical memory into caller's address space
601 *****************************************************************************/
605 ACPI_PHYSICAL_ADDRESS where
,
609 return (ACPI_TO_POINTER ((ACPI_SIZE
) where
));
613 /******************************************************************************
615 * FUNCTION: AcpiOsUnmapMemory
617 * PARAMETERS: where - Logical address of memory to be unmapped
618 * length - How much memory to unmap
622 * DESCRIPTION: Delete a previously created mapping. Where and Length must
623 * correspond to a previous mapping exactly.
625 *****************************************************************************/
638 /******************************************************************************
640 * FUNCTION: AcpiOsAllocate
642 * PARAMETERS: Size - Amount to allocate, in bytes
644 * RETURN: Pointer to the new allocation. Null on error.
646 * DESCRIPTION: Allocate memory. Algorithm is dependent on the OS.
648 *****************************************************************************/
657 Mem
= (void *) malloc ((size_t) size
);
662 #ifdef USE_NATIVE_ALLOCATE_ZEROED
663 /******************************************************************************
665 * FUNCTION: AcpiOsAllocateZeroed
667 * PARAMETERS: Size - Amount to allocate, in bytes
669 * RETURN: Pointer to the new allocation. Null on error.
671 * DESCRIPTION: Allocate and zero memory. Algorithm is dependent on the OS.
673 *****************************************************************************/
676 AcpiOsAllocateZeroed (
682 Mem
= (void *) calloc (1, (size_t) size
);
688 /******************************************************************************
690 * FUNCTION: AcpiOsFree
692 * PARAMETERS: mem - Pointer to previously allocated memory
696 * DESCRIPTION: Free memory allocated via AcpiOsAllocate
698 *****************************************************************************/
709 #ifdef ACPI_SINGLE_THREADED
710 /******************************************************************************
712 * FUNCTION: Semaphore stub functions
714 * DESCRIPTION: Stub functions used for single-thread applications that do
715 * not require semaphore synchronization. Full implementations
716 * of these functions appear after the stubs.
718 *****************************************************************************/
721 AcpiOsCreateSemaphore (
724 ACPI_HANDLE
*OutHandle
)
726 *OutHandle
= (ACPI_HANDLE
) 1;
731 AcpiOsDeleteSemaphore (
738 AcpiOsWaitSemaphore (
747 AcpiOsSignalSemaphore (
755 /******************************************************************************
757 * FUNCTION: AcpiOsCreateSemaphore
759 * PARAMETERS: InitialUnits - Units to be assigned to the new semaphore
760 * OutHandle - Where a handle will be returned
764 * DESCRIPTION: Create an OS semaphore
766 *****************************************************************************/
769 AcpiOsCreateSemaphore (
772 ACPI_HANDLE
*OutHandle
)
779 return (AE_BAD_PARAMETER
);
784 static int SemaphoreCount
= 0;
785 char SemaphoreName
[32];
787 snprintf (SemaphoreName
, sizeof (SemaphoreName
), "acpi_sem_%d",
789 printf ("%s\n", SemaphoreName
);
790 Sem
= sem_open (SemaphoreName
, O_EXCL
|O_CREAT
, 0755, InitialUnits
);
793 return (AE_NO_MEMORY
);
795 sem_unlink (SemaphoreName
); /* This just deletes the name */
799 Sem
= AcpiOsAllocate (sizeof (sem_t
));
802 return (AE_NO_MEMORY
);
805 if (sem_init (Sem
, 0, InitialUnits
) == -1)
808 return (AE_BAD_PARAMETER
);
812 *OutHandle
= (ACPI_HANDLE
) Sem
;
817 /******************************************************************************
819 * FUNCTION: AcpiOsDeleteSemaphore
821 * PARAMETERS: Handle - Handle returned by AcpiOsCreateSemaphore
825 * DESCRIPTION: Delete an OS semaphore
827 *****************************************************************************/
830 AcpiOsDeleteSemaphore (
833 sem_t
*Sem
= (sem_t
*) Handle
;
838 return (AE_BAD_PARAMETER
);
842 if (sem_close (Sem
) == -1)
844 return (AE_BAD_PARAMETER
);
847 if (sem_destroy (Sem
) == -1)
849 return (AE_BAD_PARAMETER
);
857 /******************************************************************************
859 * FUNCTION: AcpiOsWaitSemaphore
861 * PARAMETERS: Handle - Handle returned by AcpiOsCreateSemaphore
862 * Units - How many units to wait for
863 * MsecTimeout - How long to wait (milliseconds)
867 * DESCRIPTION: Wait for units
869 *****************************************************************************/
872 AcpiOsWaitSemaphore (
877 ACPI_STATUS Status
= AE_OK
;
878 sem_t
*Sem
= (sem_t
*) Handle
;
879 #ifndef ACPI_USE_ALTERNATE_TIMEOUT
880 struct timespec Time
;
887 return (AE_BAD_PARAMETER
);
895 * A zero timeout value indicates that we shouldn't wait - just
896 * acquire the semaphore if available otherwise return AE_TIME
897 * (a.k.a. 'would block').
901 if (sem_trywait(Sem
) == -1)
907 /* Wait Indefinitely */
909 case ACPI_WAIT_FOREVER
:
917 /* Wait with MsecTimeout */
921 #ifdef ACPI_USE_ALTERNATE_TIMEOUT
923 * Alternate timeout mechanism for environments where
924 * sem_timedwait is not available or does not work properly.
928 if (sem_trywait (Sem
) == 0)
930 /* Got the semaphore */
934 if (MsecTimeout
>= 10)
937 usleep (10 * ACPI_USEC_PER_MSEC
); /* ten milliseconds */
942 usleep (ACPI_USEC_PER_MSEC
); /* one millisecond */
948 * The interface to sem_timedwait is an absolute time, so we need to
949 * get the current time, then add in the millisecond Timeout value.
951 if (clock_gettime (CLOCK_REALTIME
, &Time
) == -1)
953 perror ("clock_gettime");
957 Time
.tv_sec
+= (MsecTimeout
/ ACPI_MSEC_PER_SEC
);
958 Time
.tv_nsec
+= ((MsecTimeout
% ACPI_MSEC_PER_SEC
) * ACPI_NSEC_PER_MSEC
);
960 /* Handle nanosecond overflow (field must be less than one second) */
962 if (Time
.tv_nsec
>= ACPI_NSEC_PER_SEC
)
964 Time
.tv_sec
+= (Time
.tv_nsec
/ ACPI_NSEC_PER_SEC
);
965 Time
.tv_nsec
= (Time
.tv_nsec
% ACPI_NSEC_PER_SEC
);
968 while (((RetVal
= sem_timedwait (Sem
, &Time
)) == -1) && (errno
== EINTR
))
975 if (errno
!= ETIMEDOUT
)
977 perror ("sem_timedwait");
989 /******************************************************************************
991 * FUNCTION: AcpiOsSignalSemaphore
993 * PARAMETERS: Handle - Handle returned by AcpiOsCreateSemaphore
994 * Units - Number of units to send
998 * DESCRIPTION: Send units
1000 *****************************************************************************/
1003 AcpiOsSignalSemaphore (
1007 sem_t
*Sem
= (sem_t
*)Handle
;
1012 return (AE_BAD_PARAMETER
);
1015 if (sem_post (Sem
) == -1)
1023 #endif /* ACPI_SINGLE_THREADED */
1026 /******************************************************************************
1028 * FUNCTION: Spinlock interfaces
1030 * DESCRIPTION: Map these interfaces to semaphore interfaces
1032 *****************************************************************************/
1036 ACPI_SPINLOCK
*OutHandle
)
1039 return (AcpiOsCreateSemaphore (1, 1, OutHandle
));
1045 ACPI_SPINLOCK Handle
)
1047 AcpiOsDeleteSemaphore (Handle
);
1055 AcpiOsWaitSemaphore (Handle
, 1, 0xFFFF);
1062 ACPI_SPINLOCK Handle
,
1063 ACPI_CPU_FLAGS Flags
)
1065 AcpiOsSignalSemaphore (Handle
, 1);
1069 /******************************************************************************
1071 * FUNCTION: AcpiOsInstallInterruptHandler
1073 * PARAMETERS: InterruptNumber - Level handler should respond to.
1074 * Isr - Address of the ACPI interrupt handler
1075 * ExceptPtr - Where status is returned
1077 * RETURN: Handle to the newly installed handler.
1079 * DESCRIPTION: Install an interrupt handler. Used to install the ACPI
1080 * OS-independent handler.
1082 *****************************************************************************/
1085 AcpiOsInstallInterruptHandler (
1086 UINT32 InterruptNumber
,
1087 ACPI_OSD_HANDLER ServiceRoutine
,
1095 /******************************************************************************
1097 * FUNCTION: AcpiOsRemoveInterruptHandler
1099 * PARAMETERS: Handle - Returned when handler was installed
1103 * DESCRIPTION: Uninstalls an interrupt handler.
1105 *****************************************************************************/
1108 AcpiOsRemoveInterruptHandler (
1109 UINT32 InterruptNumber
,
1110 ACPI_OSD_HANDLER ServiceRoutine
)
1117 /******************************************************************************
1119 * FUNCTION: AcpiOsStall
1121 * PARAMETERS: microseconds - Time to sleep
1123 * RETURN: Blocks until sleep is completed.
1125 * DESCRIPTION: Sleep at microsecond granularity
1127 *****************************************************************************/
1131 UINT32 microseconds
)
1136 usleep (microseconds
);
1141 /******************************************************************************
1143 * FUNCTION: AcpiOsSleep
1145 * PARAMETERS: milliseconds - Time to sleep
1147 * RETURN: Blocks until sleep is completed.
1149 * DESCRIPTION: Sleep at millisecond granularity
1151 *****************************************************************************/
1155 UINT64 milliseconds
)
1158 /* Sleep for whole seconds */
1160 sleep (milliseconds
/ ACPI_MSEC_PER_SEC
);
1163 * Sleep for remaining microseconds.
1164 * Arg to usleep() is in usecs and must be less than 1,000,000 (1 second).
1166 usleep ((milliseconds
% ACPI_MSEC_PER_SEC
) * ACPI_USEC_PER_MSEC
);
1170 /******************************************************************************
1172 * FUNCTION: AcpiOsGetTimer
1176 * RETURN: Current time in 100 nanosecond units
1178 * DESCRIPTION: Get the current system time
1180 *****************************************************************************/
1186 struct timeval time
;
1189 /* This timer has sufficient resolution for user-space application code */
1191 gettimeofday (&time
, NULL
);
1193 /* (Seconds * 10^7 = 100ns(10^-7)) + (Microseconds(10^-6) * 10^1 = 100ns) */
1195 return (((UINT64
) time
.tv_sec
* ACPI_100NSEC_PER_SEC
) +
1196 ((UINT64
) time
.tv_usec
* ACPI_100NSEC_PER_USEC
));
1200 /******************************************************************************
1202 * FUNCTION: AcpiOsReadPciConfiguration
1204 * PARAMETERS: PciId - Seg/Bus/Dev
1205 * PciRegister - Device Register
1206 * Value - Buffer where value is placed
1207 * Width - Number of bits
1211 * DESCRIPTION: Read data from PCI configuration space
1213 *****************************************************************************/
1216 AcpiOsReadPciConfiguration (
1228 /******************************************************************************
1230 * FUNCTION: AcpiOsWritePciConfiguration
1232 * PARAMETERS: PciId - Seg/Bus/Dev
1233 * PciRegister - Device Register
1234 * Value - Value to be written
1235 * Width - Number of bits
1239 * DESCRIPTION: Write data to PCI configuration space
1241 *****************************************************************************/
1244 AcpiOsWritePciConfiguration (
1255 /******************************************************************************
1257 * FUNCTION: AcpiOsReadPort
1259 * PARAMETERS: Address - Address of I/O port/register to read
1260 * Value - Where value is placed
1261 * Width - Number of bits
1263 * RETURN: Value read from port
1265 * DESCRIPTION: Read data from an I/O port or register
1267 *****************************************************************************/
1271 ACPI_IO_ADDRESS Address
,
1290 *Value
= 0xFFFFFFFF;
1295 return (AE_BAD_PARAMETER
);
1302 /******************************************************************************
1304 * FUNCTION: AcpiOsWritePort
1306 * PARAMETERS: Address - Address of I/O port/register to write
1307 * Value - Value to write
1308 * Width - Number of bits
1312 * DESCRIPTION: Write data to an I/O port or register
1314 *****************************************************************************/
1318 ACPI_IO_ADDRESS Address
,
1327 /******************************************************************************
1329 * FUNCTION: AcpiOsReadMemory
1331 * PARAMETERS: Address - Physical Memory Address to read
1332 * Value - Where value is placed
1333 * Width - Number of bits (8,16,32, or 64)
1335 * RETURN: Value read from physical memory address. Always returned
1336 * as a 64-bit integer, regardless of the read width.
1338 * DESCRIPTION: Read data from a physical memory address
1340 *****************************************************************************/
1344 ACPI_PHYSICAL_ADDRESS Address
,
1361 return (AE_BAD_PARAMETER
);
1367 /******************************************************************************
1369 * FUNCTION: AcpiOsWriteMemory
1371 * PARAMETERS: Address - Physical Memory Address to write
1372 * Value - Value to write
1373 * Width - Number of bits (8,16,32, or 64)
1377 * DESCRIPTION: Write data to a physical memory address
1379 *****************************************************************************/
1383 ACPI_PHYSICAL_ADDRESS Address
,
1392 /******************************************************************************
1394 * FUNCTION: AcpiOsReadable
1396 * PARAMETERS: Pointer - Area to be verified
1397 * Length - Size of area
1399 * RETURN: TRUE if readable for entire length
1401 * DESCRIPTION: Verify that a pointer is valid for reading
1403 *****************************************************************************/
1415 /******************************************************************************
1417 * FUNCTION: AcpiOsWritable
1419 * PARAMETERS: Pointer - Area to be verified
1420 * Length - Size of area
1422 * RETURN: TRUE if writable for entire length
1424 * DESCRIPTION: Verify that a pointer is valid for writing
1426 *****************************************************************************/
1438 /******************************************************************************
1440 * FUNCTION: AcpiOsSignal
1442 * PARAMETERS: Function - ACPI A signal function code
1443 * Info - Pointer to function-dependent structure
1447 * DESCRIPTION: Miscellaneous functions. Example implementation only.
1449 *****************************************************************************/
1459 case ACPI_SIGNAL_FATAL
:
1463 case ACPI_SIGNAL_BREAKPOINT
:
1475 /* Optional multi-thread support */
1477 #ifndef ACPI_SINGLE_THREADED
1478 /******************************************************************************
1480 * FUNCTION: AcpiOsGetThreadId
1484 * RETURN: Id of the running thread
1486 * DESCRIPTION: Get the ID of the current (running) thread
1488 *****************************************************************************/
1497 thread
= pthread_self();
1498 return (ACPI_CAST_PTHREAD_T (thread
));
1502 /******************************************************************************
1504 * FUNCTION: AcpiOsExecute
1506 * PARAMETERS: Type - Type of execution
1507 * Function - Address of the function to execute
1508 * Context - Passed as a parameter to the function
1512 * DESCRIPTION: Execute a new thread
1514 *****************************************************************************/
1518 ACPI_EXECUTE_TYPE Type
,
1519 ACPI_OSD_EXEC_CALLBACK Function
,
1526 ret
= pthread_create (&thread
, NULL
, (PTHREAD_CALLBACK
) Function
, Context
);
1529 AcpiOsPrintf("Create thread failed");
1534 #else /* ACPI_SINGLE_THREADED */
1544 ACPI_EXECUTE_TYPE Type
,
1545 ACPI_OSD_EXEC_CALLBACK Function
,
1554 #endif /* ACPI_SINGLE_THREADED */
1557 /******************************************************************************
1559 * FUNCTION: AcpiOsWaitEventsComplete
1565 * DESCRIPTION: Wait for all asynchronous events to complete. This
1566 * implementation does nothing.
1568 *****************************************************************************/
1571 AcpiOsWaitEventsComplete (