No empty .Rs/.Re
[netbsd-mini2440.git] / sys / external / intel-public / acpica / dist / osunixxf.c
blobb430e83f1600bbc5689404a5846fb3a8870d4b48
1 /******************************************************************************
3 * Module Name: osunixxf - UNIX OSL interfaces
5 *****************************************************************************/
7 /******************************************************************************
9 * 1. Copyright Notice
11 * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp.
12 * All rights reserved.
14 * 2. License
16 * 2.1. This is your license from Intel Corp. under its intellectual property
17 * rights. You may have additional license terms from the party that provided
18 * you this software, covering your right to use that party's intellectual
19 * property rights.
21 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
22 * copy of the source code appearing in this file ("Covered Code") an
23 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
24 * base code distributed originally by Intel ("Original Intel Code") to copy,
25 * make derivatives, distribute, use and display any portion of the Covered
26 * Code in any form, with the right to sublicense such rights; and
28 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
29 * license (with the right to sublicense), under only those claims of Intel
30 * patents that are infringed by the Original Intel Code, to make, use, sell,
31 * offer to sell, and import the Covered Code and derivative works thereof
32 * solely to the minimum extent necessary to exercise the above copyright
33 * license, and in no event shall the patent license extend to any additions
34 * to or modifications of the Original Intel Code. No other license or right
35 * is granted directly or by implication, estoppel or otherwise;
37 * The above copyright and patent license is granted only if the following
38 * conditions are met:
40 * 3. Conditions
42 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
43 * Redistribution of source code of any substantial portion of the Covered
44 * Code or modification with rights to further distribute source must include
45 * the above Copyright Notice, the above License, this list of Conditions,
46 * and the following Disclaimer and Export Compliance provision. In addition,
47 * Licensee must cause all Covered Code to which Licensee contributes to
48 * contain a file documenting the changes Licensee made to create that Covered
49 * Code and the date of any change. Licensee must include in that file the
50 * documentation of any changes made by any predecessor Licensee. Licensee
51 * must include a prominent statement that the modification is derived,
52 * directly or indirectly, from Original Intel Code.
54 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
55 * Redistribution of source code of any substantial portion of the Covered
56 * Code or modification without rights to further distribute source must
57 * include the following Disclaimer and Export Compliance provision in the
58 * documentation and/or other materials provided with distribution. In
59 * addition, Licensee may not authorize further sublicense of source of any
60 * portion of the Covered Code, and must include terms to the effect that the
61 * license from Licensee to its licensee is limited to the intellectual
62 * property embodied in the software Licensee provides to its licensee, and
63 * not to intellectual property embodied in modifications its licensee may
64 * make.
66 * 3.3. Redistribution of Executable. Redistribution in executable form of any
67 * substantial portion of the Covered Code or modification must reproduce the
68 * above Copyright Notice, and the following Disclaimer and Export Compliance
69 * provision in the documentation and/or other materials provided with the
70 * distribution.
72 * 3.4. Intel retains all right, title, and interest in and to the Original
73 * Intel Code.
75 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
76 * Intel shall be used in advertising or otherwise to promote the sale, use or
77 * other dealings in products derived from or relating to the Covered Code
78 * without prior written authorization from Intel.
80 * 4. Disclaimer and Export Compliance
82 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
83 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
84 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
85 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
86 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
87 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
88 * PARTICULAR PURPOSE.
90 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
91 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
92 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
93 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
94 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
95 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
96 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
97 * LIMITED REMEDY.
99 * 4.3. Licensee shall not export, either directly or indirectly, any of this
100 * software or system incorporating such software without first obtaining any
101 * required license or other approval from the U. S. Department of Commerce or
102 * any other agency or department of the United States Government. In the
103 * event Licensee exports any such software from the United States or
104 * re-exports any such software from a foreign destination, Licensee shall
105 * ensure that the distribution and export/re-export of the software is in
106 * compliance with all laws, regulations, orders, or other restrictions of the
107 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
108 * any of its subsidiaries will export/re-export any technical data, process,
109 * software, or service, directly or indirectly, to any country for which the
110 * United States government or any agency thereof requires an export license,
111 * other governmental approval, or letter of assurance, without first obtaining
112 * such license, approval or letter.
114 *****************************************************************************/
118 * These interfaces are required in order to compile the ASL compiler under
119 * Linux or other Unix-like system.
122 #include <stdio.h>
123 #include <stdlib.h>
124 #include <stdarg.h>
125 #include <unistd.h>
126 #include <sys/time.h>
127 #include <semaphore.h>
128 #include <pthread.h>
130 #include "acpi.h"
131 #include "accommon.h"
132 #include "amlcode.h"
133 #include "acparser.h"
134 #include "acdebug.h"
136 #define _COMPONENT ACPI_OS_SERVICES
137 ACPI_MODULE_NAME ("osunixxf")
140 extern FILE *AcpiGbl_DebugFile;
141 FILE *AcpiGbl_OutputFile;
144 /* Upcalls to AcpiExec */
146 ACPI_PHYSICAL_ADDRESS
147 AeLocalGetRootPointer (
148 void);
150 void
151 AeTableOverride (
152 ACPI_TABLE_HEADER *ExistingTable,
153 ACPI_TABLE_HEADER **NewTable);
155 typedef void* (*PTHREAD_CALLBACK) (void *);
158 /******************************************************************************
160 * FUNCTION: AcpiOsInitialize, AcpiOsTerminate
162 * PARAMETERS: None
164 * RETURN: Status
166 * DESCRIPTION: Init and terminate. Nothing to do.
168 *****************************************************************************/
170 ACPI_STATUS
171 AcpiOsInitialize (void)
174 AcpiGbl_OutputFile = stdout;
175 return (AE_OK);
179 ACPI_STATUS
180 AcpiOsTerminate (void)
183 return (AE_OK);
187 /******************************************************************************
189 * FUNCTION: AcpiOsGetRootPointer
191 * PARAMETERS: None
193 * RETURN: RSDP physical address
195 * DESCRIPTION: Gets the root pointer (RSDP)
197 *****************************************************************************/
199 ACPI_PHYSICAL_ADDRESS
200 AcpiOsGetRootPointer (
201 void)
204 return (AeLocalGetRootPointer ());
208 /******************************************************************************
210 * FUNCTION: AcpiOsPredefinedOverride
212 * PARAMETERS: InitVal - Initial value of the predefined object
213 * NewVal - The new value for the object
215 * RETURN: Status, pointer to value. Null pointer returned if not
216 * overriding.
218 * DESCRIPTION: Allow the OS to override predefined names
220 *****************************************************************************/
222 ACPI_STATUS
223 AcpiOsPredefinedOverride (
224 const ACPI_PREDEFINED_NAMES *InitVal,
225 ACPI_STRING *NewVal)
228 if (!InitVal || !NewVal)
230 return (AE_BAD_PARAMETER);
233 *NewVal = NULL;
234 return (AE_OK);
238 /******************************************************************************
240 * FUNCTION: AcpiOsTableOverride
242 * PARAMETERS: ExistingTable - Header of current table (probably firmware)
243 * NewTable - Where an entire new table is returned.
245 * RETURN: Status, pointer to new table. Null pointer returned if no
246 * table is available to override
248 * DESCRIPTION: Return a different version of a table if one is available
250 *****************************************************************************/
252 ACPI_STATUS
253 AcpiOsTableOverride (
254 ACPI_TABLE_HEADER *ExistingTable,
255 ACPI_TABLE_HEADER **NewTable)
258 if (!ExistingTable || !NewTable)
260 return (AE_BAD_PARAMETER);
263 *NewTable = NULL;
265 #ifdef ACPI_EXEC_APP
267 AeTableOverride (ExistingTable, NewTable);
268 return (AE_OK);
269 #else
271 return (AE_NO_ACPI_TABLES);
272 #endif
276 /******************************************************************************
278 * FUNCTION: AcpiOsRedirectOutput
280 * PARAMETERS: Destination - An open file handle/pointer
282 * RETURN: None
284 * DESCRIPTION: Causes redirect of AcpiOsPrintf and AcpiOsVprintf
286 *****************************************************************************/
288 void
289 AcpiOsRedirectOutput (
290 void *Destination)
293 AcpiGbl_OutputFile = Destination;
297 /******************************************************************************
299 * FUNCTION: AcpiOsPrintf
301 * PARAMETERS: fmt, ... Standard printf format
303 * RETURN: None
305 * DESCRIPTION: Formatted output
307 *****************************************************************************/
309 void ACPI_INTERNAL_VAR_XFACE
310 AcpiOsPrintf (
311 const char *Fmt,
312 ...)
314 va_list Args;
317 va_start (Args, Fmt);
318 AcpiOsVprintf (Fmt, Args);
319 va_end (Args);
323 /******************************************************************************
325 * FUNCTION: AcpiOsVprintf
327 * PARAMETERS: fmt Standard printf format
328 * args Argument list
330 * RETURN: None
332 * DESCRIPTION: Formatted output with argument list pointer
334 *****************************************************************************/
336 void
337 AcpiOsVprintf (
338 const char *Fmt,
339 va_list Args)
341 INT32 Count = 0;
342 UINT8 Flags;
345 Flags = AcpiGbl_DbOutputFlags;
346 if (Flags & ACPI_DB_REDIRECTABLE_OUTPUT)
348 /* Output is directable to either a file (if open) or the console */
350 if (AcpiGbl_DebugFile)
352 /* Output file is open, send the output there */
354 Count = vfprintf (AcpiGbl_DebugFile, Fmt, Args);
356 else
358 /* No redirection, send output to console (once only!) */
360 Flags |= ACPI_DB_CONSOLE_OUTPUT;
364 if (Flags & ACPI_DB_CONSOLE_OUTPUT)
366 Count = vfprintf (AcpiGbl_OutputFile, Fmt, Args);
371 /******************************************************************************
373 * FUNCTION: AcpiOsGetLine
375 * PARAMETERS: fmt Standard printf format
376 * args Argument list
378 * RETURN: Actual bytes read
380 * DESCRIPTION: Formatted input with argument list pointer
382 *****************************************************************************/
384 UINT32
385 AcpiOsGetLine (
386 char *Buffer)
388 UINT8 Temp;
389 UINT32 i;
392 for (i = 0; ; i++)
394 scanf ("%1c", &Temp);
395 if (!Temp || Temp == '\n')
397 break;
400 Buffer [i] = Temp;
403 /* Null terminate the buffer */
405 Buffer [i] = 0;
407 /* Return the number of bytes in the string */
409 return (i);
412 /******************************************************************************
414 * FUNCTION: AcpiOsMapMemory
416 * PARAMETERS: where Physical address of memory to be mapped
417 * length How much memory to map
419 * RETURN: Pointer to mapped memory. Null on error.
421 * DESCRIPTION: Map physical memory into caller's address space
423 *****************************************************************************/
425 void *
426 AcpiOsMapMemory (
427 ACPI_PHYSICAL_ADDRESS where,
428 ACPI_SIZE length)
431 return (ACPI_TO_POINTER ((ACPI_SIZE) where));
435 /******************************************************************************
437 * FUNCTION: AcpiOsUnmapMemory
439 * PARAMETERS: where Logical address of memory to be unmapped
440 * length How much memory to unmap
442 * RETURN: None.
444 * DESCRIPTION: Delete a previously created mapping. Where and Length must
445 * correspond to a previous mapping exactly.
447 *****************************************************************************/
449 void
450 AcpiOsUnmapMemory (
451 void *where,
452 ACPI_SIZE length)
455 return;
459 /******************************************************************************
461 * FUNCTION: AcpiOsAllocate
463 * PARAMETERS: Size Amount to allocate, in bytes
465 * RETURN: Pointer to the new allocation. Null on error.
467 * DESCRIPTION: Allocate memory. Algorithm is dependent on the OS.
469 *****************************************************************************/
471 void *
472 AcpiOsAllocate (
473 ACPI_SIZE size)
475 void *Mem;
478 Mem = (void *) malloc ((size_t) size);
479 return (Mem);
483 /******************************************************************************
485 * FUNCTION: AcpiOsFree
487 * PARAMETERS: mem Pointer to previously allocated memory
489 * RETURN: None.
491 * DESCRIPTION: Free memory allocated via AcpiOsAllocate
493 *****************************************************************************/
495 void
496 AcpiOsFree (
497 void *mem)
500 free (mem);
504 /******************************************************************************
506 * FUNCTION: AcpiOsCreateSemaphore
508 * PARAMETERS: InitialUnits - Units to be assigned to the new semaphore
509 * OutHandle - Where a handle will be returned
511 * RETURN: Status
513 * DESCRIPTION: Create an OS semaphore
515 *****************************************************************************/
517 ACPI_STATUS
518 AcpiOsCreateSemaphore (
519 UINT32 MaxUnits,
520 UINT32 InitialUnits,
521 ACPI_HANDLE *OutHandle)
523 sem_t *Sem;
526 if (!OutHandle)
528 return (AE_BAD_PARAMETER);
531 Sem = AcpiOsAllocate (sizeof (sem_t));
533 if (!Sem)
535 return (AE_NO_MEMORY);
538 if (sem_init (Sem, 0, InitialUnits) == -1)
540 AcpiOsFree (Sem);
541 return (AE_BAD_PARAMETER);
544 *OutHandle = (ACPI_HANDLE) Sem;
545 return (AE_OK);
549 /******************************************************************************
551 * FUNCTION: AcpiOsDeleteSemaphore
553 * PARAMETERS: Handle - Handle returned by AcpiOsCreateSemaphore
555 * RETURN: Status
557 * DESCRIPTION: Delete an OS semaphore
559 *****************************************************************************/
561 ACPI_STATUS
562 AcpiOsDeleteSemaphore (
563 ACPI_HANDLE Handle)
565 sem_t *Sem = (sem_t *) Handle;
568 if (!Sem)
570 return (AE_BAD_PARAMETER);
573 if (sem_destroy (Sem) == -1)
575 return (AE_BAD_PARAMETER);
578 return (AE_OK);
582 /******************************************************************************
584 * FUNCTION: AcpiOsWaitSemaphore
586 * PARAMETERS: Handle - Handle returned by AcpiOsCreateSemaphore
587 * Units - How many units to wait for
588 * Timeout - How long to wait
590 * RETURN: Status
592 * DESCRIPTION: Wait for units
594 *****************************************************************************/
596 ACPI_STATUS
597 AcpiOsWaitSemaphore (
598 ACPI_HANDLE Handle,
599 UINT32 Units,
600 UINT16 Timeout)
602 ACPI_STATUS Status = AE_OK;
603 sem_t *Sem = (sem_t *) Handle;
604 struct timespec T;
607 if (!Sem)
609 return (AE_BAD_PARAMETER);
612 switch (Timeout)
615 * No Wait:
616 * --------
617 * A zero timeout value indicates that we shouldn't wait - just
618 * acquire the semaphore if available otherwise return AE_TIME
619 * (a.k.a. 'would block').
621 case 0:
623 if (sem_trywait(Sem) == -1)
625 Status = (AE_TIME);
627 break;
629 /* Wait Indefinitely */
631 case ACPI_WAIT_FOREVER:
633 if (sem_wait (Sem))
635 Status = (AE_TIME);
637 break;
639 /* Wait with Timeout */
641 default:
643 T.tv_sec = Timeout / 1000;
644 T.tv_nsec = (Timeout - (T.tv_sec * 1000)) * 1000000;
646 #ifdef ACPI_USE_ALTERNATE_TIMEOUT
648 * Alternate timeout mechanism for environments where
649 * sem_timedwait is not available or does not work properly.
651 while (Timeout)
653 if (sem_trywait (Sem) == 0)
655 /* Got the semaphore */
656 return (AE_OK);
658 usleep (1000); /* one millisecond */
659 Timeout--;
661 Status = (AE_TIME);
662 #else
664 if (sem_timedwait (Sem, &T))
666 Status = (AE_TIME);
668 #endif
670 break;
673 return (Status);
677 /******************************************************************************
679 * FUNCTION: AcpiOsSignalSemaphore
681 * PARAMETERS: Handle - Handle returned by AcpiOsCreateSemaphore
682 * Units - Number of units to send
684 * RETURN: Status
686 * DESCRIPTION: Send units
688 *****************************************************************************/
690 ACPI_STATUS
691 AcpiOsSignalSemaphore (
692 ACPI_HANDLE Handle,
693 UINT32 Units)
695 sem_t *Sem = (sem_t *)Handle;
698 if (!Sem)
700 return (AE_BAD_PARAMETER);
703 if (sem_post (Sem) == -1)
705 return (AE_LIMIT);
708 return (AE_OK);
712 /******************************************************************************
714 * FUNCTION: Spinlock interfaces
716 * DESCRIPTION: Map these interfaces to semaphore interfaces
718 *****************************************************************************/
720 ACPI_STATUS
721 AcpiOsCreateLock (
722 ACPI_SPINLOCK *OutHandle)
725 return (AcpiOsCreateSemaphore (1, 1, OutHandle));
729 void
730 AcpiOsDeleteLock (
731 ACPI_SPINLOCK Handle)
733 AcpiOsDeleteSemaphore (Handle);
737 ACPI_CPU_FLAGS
738 AcpiOsAcquireLock (
739 ACPI_HANDLE Handle)
741 AcpiOsWaitSemaphore (Handle, 1, 0xFFFF);
742 return (0);
746 void
747 AcpiOsReleaseLock (
748 ACPI_SPINLOCK Handle,
749 ACPI_CPU_FLAGS Flags)
751 AcpiOsSignalSemaphore (Handle, 1);
755 /******************************************************************************
757 * FUNCTION: AcpiOsInstallInterruptHandler
759 * PARAMETERS: InterruptNumber Level handler should respond to.
760 * Isr Address of the ACPI interrupt handler
761 * ExceptPtr Where status is returned
763 * RETURN: Handle to the newly installed handler.
765 * DESCRIPTION: Install an interrupt handler. Used to install the ACPI
766 * OS-independent handler.
768 *****************************************************************************/
770 UINT32
771 AcpiOsInstallInterruptHandler (
772 UINT32 InterruptNumber,
773 ACPI_OSD_HANDLER ServiceRoutine,
774 void *Context)
777 return (AE_OK);
781 /******************************************************************************
783 * FUNCTION: AcpiOsRemoveInterruptHandler
785 * PARAMETERS: Handle Returned when handler was installed
787 * RETURN: Status
789 * DESCRIPTION: Uninstalls an interrupt handler.
791 *****************************************************************************/
793 ACPI_STATUS
794 AcpiOsRemoveInterruptHandler (
795 UINT32 InterruptNumber,
796 ACPI_OSD_HANDLER ServiceRoutine)
799 return (AE_OK);
803 /******************************************************************************
805 * FUNCTION: AcpiOsExecute
807 * PARAMETERS: Type - Type of execution
808 * Function - Address of the function to execute
809 * Context - Passed as a parameter to the function
811 * RETURN: Status.
813 * DESCRIPTION: Execute a new thread
815 *****************************************************************************/
817 ACPI_STATUS
818 AcpiOsExecute (
819 ACPI_EXECUTE_TYPE Type,
820 ACPI_OSD_EXEC_CALLBACK Function,
821 void *Context)
823 pthread_t thread;
824 int ret;
827 ret = pthread_create (&thread, NULL, (PTHREAD_CALLBACK) Function, Context);
828 if (ret)
830 AcpiOsPrintf("Create thread failed");
832 return (0);
836 /******************************************************************************
838 * FUNCTION: AcpiOsStall
840 * PARAMETERS: microseconds To sleep
842 * RETURN: Blocks until sleep is completed.
844 * DESCRIPTION: Sleep at microsecond granularity
846 *****************************************************************************/
848 void
849 AcpiOsStall (
850 UINT32 microseconds)
853 if (microseconds)
855 usleep (microseconds);
860 /******************************************************************************
862 * FUNCTION: AcpiOsSleep
864 * PARAMETERS: milliseconds To sleep
866 * RETURN: Blocks until sleep is completed.
868 * DESCRIPTION: Sleep at millisecond granularity
870 *****************************************************************************/
872 void
873 AcpiOsSleep (
874 ACPI_INTEGER milliseconds)
877 sleep (milliseconds / 1000); /* Sleep for whole seconds */
880 * Arg to usleep() must be less than 1,000,000 (1 second)
882 usleep ((milliseconds % 1000) * 1000); /* Sleep for remaining usecs */
885 /******************************************************************************
887 * FUNCTION: AcpiOsGetTimer
889 * PARAMETERS: None
891 * RETURN: Current time in 100 nanosecond units
893 * DESCRIPTION: Get the current system time
895 *****************************************************************************/
897 UINT64
898 AcpiOsGetTimer (void)
900 struct timeval time;
903 gettimeofday (&time, NULL);
905 /* Seconds * 10^7 = 100ns(10^-7), Microseconds(10^-6) * 10^1 = 100ns */
907 return (((UINT64) time.tv_sec * 10000000) + ((UINT64) time.tv_usec * 10));
911 /******************************************************************************
913 * FUNCTION: AcpiOsValidateInterface
915 * PARAMETERS: Interface - Requested interface to be validated
917 * RETURN: AE_OK if interface is supported, AE_SUPPORT otherwise
919 * DESCRIPTION: Match an interface string to the interfaces supported by the
920 * host. Strings originate from an AML call to the _OSI method.
922 *****************************************************************************/
924 ACPI_STATUS
925 AcpiOsValidateInterface (
926 char *Interface)
929 return (AE_SUPPORT);
933 /******************************************************************************
935 * FUNCTION: AcpiOsReadPciConfiguration
937 * PARAMETERS: PciId Seg/Bus/Dev
938 * Register Device Register
939 * Value Buffer where value is placed
940 * Width Number of bits
942 * RETURN: Status
944 * DESCRIPTION: Read data from PCI configuration space
946 *****************************************************************************/
948 ACPI_STATUS
949 AcpiOsReadPciConfiguration (
950 ACPI_PCI_ID *PciId,
951 UINT32 Register,
952 void *Value,
953 UINT32 Width)
956 return (AE_OK);
960 /******************************************************************************
962 * FUNCTION: AcpiOsWritePciConfiguration
964 * PARAMETERS: PciId Seg/Bus/Dev
965 * Register Device Register
966 * Value Value to be written
967 * Width Number of bits
969 * RETURN: Status.
971 * DESCRIPTION: Write data to PCI configuration space
973 *****************************************************************************/
975 ACPI_STATUS
976 AcpiOsWritePciConfiguration (
977 ACPI_PCI_ID *PciId,
978 UINT32 Register,
979 ACPI_INTEGER Value,
980 UINT32 Width)
983 return (AE_OK);
986 /* TEMPORARY STUB FUNCTION */
987 void
988 AcpiOsDerivePciId(
989 ACPI_HANDLE rhandle,
990 ACPI_HANDLE chandle,
991 ACPI_PCI_ID **PciId)
997 /******************************************************************************
999 * FUNCTION: AcpiOsReadPort
1001 * PARAMETERS: Address Address of I/O port/register to read
1002 * Value Where value is placed
1003 * Width Number of bits
1005 * RETURN: Value read from port
1007 * DESCRIPTION: Read data from an I/O port or register
1009 *****************************************************************************/
1011 ACPI_STATUS
1012 AcpiOsReadPort (
1013 ACPI_IO_ADDRESS Address,
1014 UINT32 *Value,
1015 UINT32 Width)
1018 switch (Width)
1020 case 8:
1021 *Value = 0xFF;
1022 break;
1024 case 16:
1025 *Value = 0xFFFF;
1026 break;
1028 case 32:
1029 *Value = 0xFFFFFFFF;
1030 break;
1032 default:
1033 return (AE_BAD_PARAMETER);
1036 return (AE_OK);
1040 /******************************************************************************
1042 * FUNCTION: AcpiOsWritePort
1044 * PARAMETERS: Address Address of I/O port/register to write
1045 * Value Value to write
1046 * Width Number of bits
1048 * RETURN: None
1050 * DESCRIPTION: Write data to an I/O port or register
1052 *****************************************************************************/
1054 ACPI_STATUS
1055 AcpiOsWritePort (
1056 ACPI_IO_ADDRESS Address,
1057 UINT32 Value,
1058 UINT32 Width)
1061 return (AE_OK);
1065 /******************************************************************************
1067 * FUNCTION: AcpiOsReadMemory
1069 * PARAMETERS: Address Physical Memory Address to read
1070 * Value Where value is placed
1071 * Width Number of bits
1073 * RETURN: Value read from physical memory address
1075 * DESCRIPTION: Read data from a physical memory address
1077 *****************************************************************************/
1079 ACPI_STATUS
1080 AcpiOsReadMemory (
1081 ACPI_PHYSICAL_ADDRESS Address,
1082 UINT32 *Value,
1083 UINT32 Width)
1086 switch (Width)
1088 case 8:
1089 case 16:
1090 case 32:
1091 *Value = 0;
1092 break;
1094 default:
1095 return (AE_BAD_PARAMETER);
1097 return (AE_OK);
1101 /******************************************************************************
1103 * FUNCTION: AcpiOsWriteMemory
1105 * PARAMETERS: Address Physical Memory Address to write
1106 * Value Value to write
1107 * Width Number of bits
1109 * RETURN: None
1111 * DESCRIPTION: Write data to a physical memory address
1113 *****************************************************************************/
1115 ACPI_STATUS
1116 AcpiOsWriteMemory (
1117 ACPI_PHYSICAL_ADDRESS Address,
1118 UINT32 Value,
1119 UINT32 Width)
1122 return (AE_OK);
1126 /******************************************************************************
1128 * FUNCTION: AcpiOsReadable
1130 * PARAMETERS: Pointer - Area to be verified
1131 * Length - Size of area
1133 * RETURN: TRUE if readable for entire length
1135 * DESCRIPTION: Verify that a pointer is valid for reading
1137 *****************************************************************************/
1139 BOOLEAN
1140 AcpiOsReadable (
1141 void *Pointer,
1142 ACPI_SIZE Length)
1145 return (TRUE);
1149 /******************************************************************************
1151 * FUNCTION: AcpiOsWritable
1153 * PARAMETERS: Pointer - Area to be verified
1154 * Length - Size of area
1156 * RETURN: TRUE if writable for entire length
1158 * DESCRIPTION: Verify that a pointer is valid for writing
1160 *****************************************************************************/
1162 BOOLEAN
1163 AcpiOsWritable (
1164 void *Pointer,
1165 ACPI_SIZE Length)
1168 return (TRUE);
1172 /******************************************************************************
1174 * FUNCTION: AcpiOsGetThreadId
1176 * PARAMETERS: None
1178 * RETURN: Id of the running thread
1180 * DESCRIPTION: Get the Id of the current (running) thread
1182 * NOTE: The environment header should contain this line:
1183 * #define ACPI_THREAD_ID pthread_t
1185 *****************************************************************************/
1187 ACPI_THREAD_ID
1188 AcpiOsGetThreadId (void)
1191 return (pthread_self ());
1195 /******************************************************************************
1197 * FUNCTION: AcpiOsSignal
1199 * PARAMETERS: Function ACPI CA signal function code
1200 * Info Pointer to function-dependent structure
1202 * RETURN: Status
1204 * DESCRIPTION: Miscellaneous functions. Example implementation only.
1206 *****************************************************************************/
1208 ACPI_STATUS
1209 AcpiOsSignal (
1210 UINT32 Function,
1211 void *Info)
1214 switch (Function)
1216 case ACPI_SIGNAL_FATAL:
1217 break;
1219 case ACPI_SIGNAL_BREAKPOINT:
1220 break;
1222 default:
1223 break;
1226 return (AE_OK);