]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/contrib/dev/acpica/osunixxf.c
This commit was generated by cvs2svn to compensate for changes in r159825,
[FreeBSD/FreeBSD.git] / sys / contrib / dev / acpica / osunixxf.c
1 /******************************************************************************
2  *
3  * Module Name: osunixxf - UNIX OSL interfaces
4  *
5  *****************************************************************************/
6
7 /******************************************************************************
8  *
9  * 1. Copyright Notice
10  *
11  * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp.
12  * All rights reserved.
13  *
14  * 2. License
15  *
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.
20  *
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
27  *
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;
36  *
37  * The above copyright and patent license is granted only if the following
38  * conditions are met:
39  *
40  * 3. Conditions
41  *
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.
53  *
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.
65  *
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.
71  *
72  * 3.4. Intel retains all right, title, and interest in and to the Original
73  * Intel Code.
74  *
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.
79  *
80  * 4. Disclaimer and Export Compliance
81  *
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.
89  *
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.
98  *
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.
113  *
114  *****************************************************************************/
115
116
117 /*
118  * These interfaces are required in order to compile the ASL compiler under
119  * Linux.
120  */
121
122 #include <stdio.h>
123 #include <stdlib.h>
124 #include <stdarg.h>
125 #include <unistd.h>
126 #include <sys/time.h>
127
128 #include <contrib/dev/acpica/acpi.h>
129 #include <contrib/dev/acpica/amlcode.h>
130 #include <contrib/dev/acpica/acparser.h>
131 #include <contrib/dev/acpica/acdebug.h>
132
133 #include <contrib/dev/acpica/compiler/aslcompiler.h>
134
135 #define _COMPONENT          ACPI_OS_SERVICES
136         ACPI_MODULE_NAME    ("osunixxf")
137
138
139 extern FILE                    *AcpiGbl_DebugFile;
140 FILE                           *AcpiGbl_OutputFile;
141
142
143 /******************************************************************************
144  *
145  * FUNCTION:    AcpiOsInitialize, AcpiOsTerminate
146  *
147  * PARAMETERS:  None
148  *
149  * RETURN:      Status
150  *
151  * DESCRIPTION: Init and terminate.  Nothing to do.
152  *
153  *****************************************************************************/
154
155 ACPI_STATUS
156 AcpiOsInitialize (void)
157 {
158     AcpiGbl_OutputFile = stdout;
159
160     return AE_OK;
161 }
162
163
164 ACPI_STATUS
165 AcpiOsTerminate (void)
166 {
167     return AE_OK;
168 }
169
170
171 /******************************************************************************
172  *
173  * FUNCTION:    AcpiOsGetRootPointer
174  *
175  * PARAMETERS:  Flags   - Logical or physical addressing mode
176  *              Address - Where the address is returned
177  *
178  * RETURN:      Status
179  *
180  * DESCRIPTION: Gets the root pointer (RSDP)
181  *
182  *****************************************************************************/
183
184 ACPI_STATUS
185 AcpiOsGetRootPointer (
186     UINT32                  Flags,
187     ACPI_POINTER           *Address)
188 {
189
190     return (AeLocalGetRootPointer(Flags, (ACPI_PHYSICAL_ADDRESS *) Address));
191 }
192
193
194 /******************************************************************************
195  *
196  * FUNCTION:    AcpiOsPredefinedOverride
197  *
198  * PARAMETERS:  InitVal     - Initial value of the predefined object
199  *              NewVal      - The new value for the object
200  *
201  * RETURN:      Status, pointer to value.  Null pointer returned if not
202  *              overriding.
203  *
204  * DESCRIPTION: Allow the OS to override predefined names
205  *
206  *****************************************************************************/
207
208 ACPI_STATUS
209 AcpiOsPredefinedOverride (
210     const ACPI_PREDEFINED_NAMES *InitVal,
211     ACPI_STRING                 *NewVal)
212 {
213
214     if (!InitVal || !NewVal)
215     {
216         return (AE_BAD_PARAMETER);
217     }
218
219     *NewVal = NULL;
220     return (AE_OK);
221 }
222
223
224 /******************************************************************************
225  *
226  * FUNCTION:    AcpiOsTableOverride
227  *
228  * PARAMETERS:  ExistingTable   - Header of current table (probably firmware)
229  *              NewTable        - Where an entire new table is returned.
230  *
231  * RETURN:      Status, pointer to new table.  Null pointer returned if no
232  *              table is available to override
233  *
234  * DESCRIPTION: Return a different version of a table if one is available
235  *
236  *****************************************************************************/
237
238 ACPI_STATUS
239 AcpiOsTableOverride (
240     ACPI_TABLE_HEADER       *ExistingTable,
241     ACPI_TABLE_HEADER       **NewTable)
242 {
243
244     if (!ExistingTable || !NewTable)
245     {
246         return (AE_BAD_PARAMETER);
247     }
248
249     *NewTable = NULL;
250
251 #ifdef ACPI_EXEC_APP
252
253     /* This code exercises the table override mechanism in the core */
254
255     if (!ACPI_STRNCMP (ExistingTable->Signature, DSDT_SIG, ACPI_NAME_SIZE))
256     {
257         /* override DSDT with itself */
258
259         *NewTable = AcpiGbl_DbTablePtr;
260     }
261     return (AE_OK);
262 #else
263     return AE_NO_ACPI_TABLES;
264 #endif
265 }
266
267
268 /******************************************************************************
269  *
270  * FUNCTION:    AcpiOsReadable
271  *
272  * PARAMETERS:  Pointer             - Area to be verified
273  *              Length              - Size of area
274  *
275  * RETURN:      TRUE if readable for entire length
276  *
277  * DESCRIPTION: Verify that a pointer is valid for reading
278  *
279  *****************************************************************************/
280
281 BOOLEAN
282 AcpiOsReadable (
283     void                    *Pointer,
284     ACPI_SIZE               Length)
285 {
286
287     return (TRUE);
288 }
289
290
291 /******************************************************************************
292  *
293  * FUNCTION:    AcpiOsWritable
294  *
295  * PARAMETERS:  Pointer             - Area to be verified
296  *              Length              - Size of area
297  *
298  * RETURN:      TRUE if writable for entire length
299  *
300  * DESCRIPTION: Verify that a pointer is valid for writing
301  *
302  *****************************************************************************/
303
304 BOOLEAN
305 AcpiOsWritable (
306     void                    *Pointer,
307     ACPI_SIZE               Length)
308 {
309
310     return (TRUE);
311 }
312
313
314 /******************************************************************************
315  *
316  * FUNCTION:    AcpiOsRedirectOutput
317  *
318  * PARAMETERS:  Destination         - An open file handle/pointer
319  *
320  * RETURN:      None
321  *
322  * DESCRIPTION: Causes redirect of AcpiOsPrintf and AcpiOsVprintf
323  *
324  *****************************************************************************/
325
326 void
327 AcpiOsRedirectOutput (
328     void                    *Destination)
329 {
330
331     AcpiGbl_OutputFile = Destination;
332 }
333
334
335 /******************************************************************************
336  *
337  * FUNCTION:    AcpiOsPrintf
338  *
339  * PARAMETERS:  fmt, ...            Standard printf format
340  *
341  * RETURN:      None
342  *
343  * DESCRIPTION: Formatted output
344  *
345  *****************************************************************************/
346
347 void ACPI_INTERNAL_VAR_XFACE
348 AcpiOsPrintf (
349     const char              *Fmt,
350     ...)
351 {
352     va_list                 Args;
353
354
355     va_start (Args, Fmt);
356
357     AcpiOsVprintf (Fmt, Args);
358
359     va_end (Args);
360     return;
361 }
362
363
364 /******************************************************************************
365  *
366  * FUNCTION:    AcpiOsVprintf
367  *
368  * PARAMETERS:  fmt                 Standard printf format
369  *              args                Argument list
370  *
371  * RETURN:      None
372  *
373  * DESCRIPTION: Formatted output with argument list pointer
374  *
375  *****************************************************************************/
376
377 void
378 AcpiOsVprintf (
379     const char              *Fmt,
380     va_list                 Args)
381 {
382     INT32                   Count = 0;
383     UINT8                   Flags;
384
385
386     Flags = AcpiGbl_DbOutputFlags;
387     if (Flags & ACPI_DB_REDIRECTABLE_OUTPUT)
388     {
389         /* Output is directable to either a file (if open) or the console */
390
391         if (AcpiGbl_DebugFile)
392         {
393             /* Output file is open, send the output there */
394
395             Count = vfprintf (AcpiGbl_DebugFile, Fmt, Args);
396         }
397         else
398         {
399             /* No redirection, send output to console (once only!) */
400
401             Flags |= ACPI_DB_CONSOLE_OUTPUT;
402         }
403     }
404
405     if (Flags & ACPI_DB_CONSOLE_OUTPUT)
406     {
407         Count = vfprintf (AcpiGbl_OutputFile, Fmt, Args);
408     }
409
410     return;
411 }
412
413
414 /******************************************************************************
415  *
416  * FUNCTION:    AcpiOsGetLine
417  *
418  * PARAMETERS:  fmt                 Standard printf format
419  *              args                Argument list
420  *
421  * RETURN:      Actual bytes read
422  *
423  * DESCRIPTION: Formatted input with argument list pointer
424  *
425  *****************************************************************************/
426
427 UINT32
428 AcpiOsGetLine (
429     char                    *Buffer)
430 {
431     UINT8                   Temp;
432     UINT32                  i;
433
434
435     for (i = 0; ; i++)
436     {
437         scanf ("%1c", &Temp);
438         if (!Temp || Temp == '\n')
439         {
440             break;
441         }
442
443         Buffer [i] = Temp;
444     }
445
446     /* Null terminate the buffer */
447
448     Buffer [i] = 0;
449
450     /* Return the number of bytes in the string */
451
452     return (i);
453 }
454
455 /******************************************************************************
456  *
457  * FUNCTION:    AcpiOsMapMemory
458  *
459  * PARAMETERS:  where               Physical address of memory to be mapped
460  *              length              How much memory to map
461  *              there               Logical address of mapped memory
462  *
463  * RETURN:      Pointer to mapped memory.  Null on error.
464  *
465  * DESCRIPTION: Map physical memory into caller's address space
466  *
467  *****************************************************************************/
468
469 ACPI_STATUS
470 AcpiOsMapMemory (
471     ACPI_PHYSICAL_ADDRESS   where,
472     ACPI_SIZE               length,
473     void                    **there)
474 {
475     *there = ACPI_TO_POINTER (where);
476
477     return AE_OK;
478 }
479
480
481 /******************************************************************************
482  *
483  * FUNCTION:    AcpiOsUnmapMemory
484  *
485  * PARAMETERS:  where               Logical address of memory to be unmapped
486  *              length              How much memory to unmap
487  *
488  * RETURN:      None.
489  *
490  * DESCRIPTION: Delete a previously created mapping.  Where and Length must
491  *              correspond to a previous mapping exactly.
492  *
493  *****************************************************************************/
494
495 void
496 AcpiOsUnmapMemory (
497     void                    *where,
498     ACPI_SIZE               length)
499 {
500
501     return;
502 }
503
504
505 /******************************************************************************
506  *
507  * FUNCTION:    AcpiOsAllocate
508  *
509  * PARAMETERS:  Size                Amount to allocate, in bytes
510  *
511  * RETURN:      Pointer to the new allocation.  Null on error.
512  *
513  * DESCRIPTION: Allocate memory.  Algorithm is dependent on the OS.
514  *
515  *****************************************************************************/
516
517 void *
518 AcpiOsAllocate (
519     ACPI_SIZE               size)
520 {
521     void                    *Mem;
522
523
524     Mem = (void *) malloc ((size_t) size);
525
526     return Mem;
527 }
528
529
530 /******************************************************************************
531  *
532  * FUNCTION:    AcpiOsFree
533  *
534  * PARAMETERS:  mem                 Pointer to previously allocated memory
535  *
536  * RETURN:      None.
537  *
538  * DESCRIPTION: Free memory allocated via AcpiOsAllocate
539  *
540  *****************************************************************************/
541
542 void
543 AcpiOsFree (
544     void                    *mem)
545 {
546
547
548     free (mem);
549 }
550
551
552 /******************************************************************************
553  *
554  * FUNCTION:    AcpiOsCreateSemaphore
555  *
556  * PARAMETERS:  InitialUnits        - Units to be assigned to the new semaphore
557  *              OutHandle           - Where a handle will be returned
558  *
559  * RETURN:      Status
560  *
561  * DESCRIPTION: Create an OS semaphore
562  *
563  *****************************************************************************/
564
565 ACPI_STATUS
566 AcpiOsCreateSemaphore (
567     UINT32              MaxUnits,
568     UINT32              InitialUnits,
569     ACPI_HANDLE         *OutHandle)
570 {
571
572
573     *OutHandle = (ACPI_HANDLE) 1;
574     return AE_OK;
575 }
576
577 /******************************************************************************
578  *
579  * FUNCTION:    AcpiOsDeleteSemaphore
580  *
581  * PARAMETERS:  Handle              - Handle returned by AcpiOsCreateSemaphore
582  *
583  * RETURN:      Status
584  *
585  * DESCRIPTION: Delete an OS semaphore
586  *
587  *****************************************************************************/
588
589 ACPI_STATUS
590 AcpiOsDeleteSemaphore (
591     ACPI_HANDLE         Handle)
592 {
593
594     if (!Handle)
595     {
596         return AE_BAD_PARAMETER;
597     }
598
599     return AE_OK;
600 }
601
602
603 /******************************************************************************
604  *
605  * FUNCTION:    AcpiOsWaitSemaphore
606  *
607  * PARAMETERS:  Handle              - Handle returned by AcpiOsCreateSemaphore
608  *              Units               - How many units to wait for
609  *              Timeout             - How long to wait
610  *
611  * RETURN:      Status
612  *
613  * DESCRIPTION: Wait for units
614  *
615  *****************************************************************************/
616
617 ACPI_STATUS
618 AcpiOsWaitSemaphore (
619     ACPI_HANDLE         Handle,
620     UINT32              Units,
621     UINT16              Timeout)
622 {
623
624
625     return AE_OK;
626 }
627
628
629 /******************************************************************************
630  *
631  * FUNCTION:    AcpiOsSignalSemaphore
632  *
633  * PARAMETERS:  Handle              - Handle returned by AcpiOsCreateSemaphore
634  *              Units               - Number of units to send
635  *
636  * RETURN:      Status
637  *
638  * DESCRIPTION: Send units
639  *
640  *****************************************************************************/
641
642 ACPI_STATUS
643 AcpiOsSignalSemaphore (
644     ACPI_HANDLE         Handle,
645     UINT32              Units)
646 {
647
648
649     return AE_OK;
650 }
651
652
653 ACPI_STATUS
654 AcpiOsCreateLock (
655     ACPI_HANDLE             *OutHandle)
656 {
657
658     return (AcpiOsCreateSemaphore (1, 1, OutHandle));
659 }
660
661 void
662 AcpiOsDeleteLock (
663     ACPI_HANDLE             Handle)
664 {
665     AcpiOsDeleteSemaphore (Handle);
666 }
667
668
669 ACPI_NATIVE_UINT
670 AcpiOsAcquireLock (
671     ACPI_HANDLE             Handle)
672 {
673     AcpiOsWaitSemaphore (Handle, 1, 0xFFFF);
674     return (0);
675 }
676
677
678 void
679 AcpiOsReleaseLock (
680     ACPI_HANDLE             Handle,
681     ACPI_NATIVE_UINT        Flags)
682 {
683     AcpiOsSignalSemaphore (Handle, 1);
684 }
685
686
687 /******************************************************************************
688  *
689  * FUNCTION:    AcpiOsInstallInterruptHandler
690  *
691  * PARAMETERS:  InterruptNumber     Level handler should respond to.
692  *              Isr                 Address of the ACPI interrupt handler
693  *              ExceptPtr           Where status is returned
694  *
695  * RETURN:      Handle to the newly installed handler.
696  *
697  * DESCRIPTION: Install an interrupt handler.  Used to install the ACPI
698  *              OS-independent handler.
699  *
700  *****************************************************************************/
701
702 UINT32
703 AcpiOsInstallInterruptHandler (
704     UINT32                  InterruptNumber,
705     ACPI_OSD_HANDLER        ServiceRoutine,
706     void                    *Context)
707 {
708
709
710     return AE_OK;
711 }
712
713
714 /******************************************************************************
715  *
716  * FUNCTION:    AcpiOsRemoveInterruptHandler
717  *
718  * PARAMETERS:  Handle              Returned when handler was installed
719  *
720  * RETURN:      Status
721  *
722  * DESCRIPTION: Uninstalls an interrupt handler.
723  *
724  *****************************************************************************/
725
726 ACPI_STATUS
727 AcpiOsRemoveInterruptHandler (
728     UINT32                  InterruptNumber,
729     ACPI_OSD_HANDLER        ServiceRoutine)
730 {
731
732     return AE_OK;
733 }
734
735
736 /******************************************************************************
737  *
738  * FUNCTION:    AcpiOsQueueForExecution
739  *
740  * PARAMETERS:  Priority        - Requested execution priority
741  *              Function        - Address of the function to execute
742  *              Context         - Passed as a parameter to the function
743  *
744  * RETURN:      Status.
745  *
746  * DESCRIPTION: Sleep at microsecond granularity
747  *
748  *****************************************************************************/
749
750 ACPI_STATUS
751 AcpiOsQueueForExecution (
752     UINT32                  Priority,
753     ACPI_OSD_EXEC_CALLBACK  Function,
754     void                    *Context)
755 {
756
757 //    _beginthread (Function, (unsigned) 0, Context);
758     return 0;
759 }
760
761
762 /******************************************************************************
763  *
764  * FUNCTION:    AcpiOsBreakpoint
765  *
766  * PARAMETERS:  Msg                 Message to print
767  *
768  * RETURN:      Status
769  *
770  * DESCRIPTION: Print a message and break to the debugger.
771  *
772  *****************************************************************************/
773
774 ACPI_STATUS
775 AcpiOsBreakpoint (
776     char                    *Msg)
777 {
778
779     /* Print the message and do an INT 3 */
780
781     if (Msg)
782     {
783         AcpiOsPrintf ("AcpiOsBreakpoint: %s ****\n", Msg);
784     }
785     else
786     {
787         AcpiOsPrintf ("At AcpiOsBreakpoint ****\n");
788     }
789
790
791     return AE_OK;
792 }
793
794
795 /******************************************************************************
796  *
797  * FUNCTION:    AcpiOsStall
798  *
799  * PARAMETERS:  microseconds        To sleep
800  *
801  * RETURN:      Blocks until sleep is completed.
802  *
803  * DESCRIPTION: Sleep at microsecond granularity
804  *
805  *****************************************************************************/
806
807 void
808 AcpiOsStall (
809     UINT32                  microseconds)
810 {
811
812     if (microseconds)
813     {
814         usleep (microseconds);
815     }
816     return;
817 }
818
819
820 /******************************************************************************
821  *
822  * FUNCTION:    AcpiOsSleep
823  *
824  * PARAMETERS:  milliseconds        To sleep
825  *
826  * RETURN:      Blocks until sleep is completed.
827  *
828  * DESCRIPTION: Sleep at millisecond granularity
829  *
830  *****************************************************************************/
831
832 void
833 AcpiOsSleep (
834     ACPI_INTEGER            milliseconds)
835 {
836
837     sleep (milliseconds / 1000);    /* Sleep for whole seconds */
838
839     /*
840      * Arg to usleep() must be less than 1,000,000 (1 second)
841      */
842     usleep ((milliseconds % 1000) * 1000);      /* Sleep for remaining usecs */
843
844     return;
845 }
846
847 /******************************************************************************
848  *
849  * FUNCTION:    AcpiOsGetTimer
850  *
851  * PARAMETERS:  None
852  *
853  * RETURN:      Current time in 100 nanosecond units
854  *
855  * DESCRIPTION: Get the current system time
856  *
857  *****************************************************************************/
858
859 UINT64
860 AcpiOsGetTimer (void)
861 {
862     struct timeval  time;
863
864     gettimeofday(&time, NULL);
865
866     /* Seconds * 10^7 = 100ns(10^-7), Microseconds(10^-6) * 10^1 = 100ns */
867
868     return (((UINT64) time.tv_sec * 10000000) + ((UINT64) time.tv_usec * 10));
869 }
870
871
872 /******************************************************************************
873  *
874  * FUNCTION:    AcpiOsReadPciConfiguration
875  *
876  * PARAMETERS:  PciId               Seg/Bus/Dev
877  *              Register            Device Register
878  *              Value               Buffer where value is placed
879  *              Width               Number of bits
880  *
881  * RETURN:      Status
882  *
883  * DESCRIPTION: Read data from PCI configuration space
884  *
885  *****************************************************************************/
886
887 ACPI_STATUS
888 AcpiOsReadPciConfiguration (
889     ACPI_PCI_ID             *PciId,
890     UINT32                  Register,
891     void                    *Value,
892     UINT32                  Width)
893 {
894
895     return (AE_OK);
896 }
897
898
899 /******************************************************************************
900  *
901  * FUNCTION:    AcpiOsWritePciConfiguration
902  *
903  * PARAMETERS:  PciId               Seg/Bus/Dev
904  *              Register            Device Register
905  *              Value               Value to be written
906  *              Width               Number of bits
907  *
908  * RETURN:      Status.
909  *
910  * DESCRIPTION: Write data to PCI configuration space
911  *
912  *****************************************************************************/
913
914 ACPI_STATUS
915 AcpiOsWritePciConfiguration (
916     ACPI_PCI_ID             *PciId,
917     UINT32                  Register,
918     ACPI_INTEGER            Value,
919     UINT32                  Width)
920 {
921
922     return (AE_OK);
923 }
924
925 /* TEMPORARY STUB FUNCTION */
926 void
927 AcpiOsDerivePciId(
928     ACPI_HANDLE             rhandle,
929     ACPI_HANDLE             chandle,
930     ACPI_PCI_ID             **PciId)
931 {
932
933 }
934
935
936 /******************************************************************************
937  *
938  * FUNCTION:    AcpiOsReadPort
939  *
940  * PARAMETERS:  Address             Address of I/O port/register to read
941  *              Value               Where value is placed
942  *              Width               Number of bits
943  *
944  * RETURN:      Value read from port
945  *
946  * DESCRIPTION: Read data from an I/O port or register
947  *
948  *****************************************************************************/
949
950 ACPI_STATUS
951 AcpiOsReadPort (
952     ACPI_IO_ADDRESS         Address,
953     UINT32                  *Value,
954     UINT32                  Width)
955 {
956
957     switch (Width)
958     {
959     case 8:
960         *Value = 0xFF;
961         break;
962
963     case 16:
964         *Value = 0xFFFF;
965         break;
966
967     case 32:
968         *Value = 0xFFFFFFFF;
969         break;
970     }
971
972     return (AE_OK);
973 }
974
975
976 /******************************************************************************
977  *
978  * FUNCTION:    AcpiOsWritePort
979  *
980  * PARAMETERS:  Address             Address of I/O port/register to write
981  *              Value               Value to write
982  *              Width               Number of bits
983  *
984  * RETURN:      None
985  *
986  * DESCRIPTION: Write data to an I/O port or register
987  *
988  *****************************************************************************/
989
990 ACPI_STATUS
991 AcpiOsWritePort (
992     ACPI_IO_ADDRESS         Address,
993     UINT32                  Value,
994     UINT32                  Width)
995 {
996
997     return (AE_OK);
998 }
999
1000
1001 /******************************************************************************
1002  *
1003  * FUNCTION:    AcpiOsReadMemory
1004  *
1005  * PARAMETERS:  Address             Physical Memory Address to read
1006  *              Value               Where value is placed
1007  *              Width               Number of bits
1008  *
1009  * RETURN:      Value read from physical memory address
1010  *
1011  * DESCRIPTION: Read data from a physical memory address
1012  *
1013  *****************************************************************************/
1014
1015 ACPI_STATUS
1016 AcpiOsReadMemory (
1017     ACPI_PHYSICAL_ADDRESS   Address,
1018     UINT32                  *Value,
1019     UINT32                  Width)
1020 {
1021
1022     switch (Width)
1023     {
1024     case 8:
1025     case 16:
1026     case 32:
1027         *Value = 0;
1028         break;
1029
1030     default:
1031         return (AE_BAD_PARAMETER);
1032         break;
1033     }
1034     return (AE_OK);
1035 }
1036
1037
1038 /******************************************************************************
1039  *
1040  * FUNCTION:    AcpiOsWriteMemory
1041  *
1042  * PARAMETERS:  Address             Physical Memory Address to write
1043  *              Value               Value to write
1044  *              Width               Number of bits
1045  *
1046  * RETURN:      None
1047  *
1048  * DESCRIPTION: Write data to a physical memory address
1049  *
1050  *****************************************************************************/
1051
1052 ACPI_STATUS
1053 AcpiOsWriteMemory (
1054     ACPI_PHYSICAL_ADDRESS   Address,
1055     UINT32                  Value,
1056     UINT32                  Width)
1057 {
1058
1059     return (AE_OK);
1060 }
1061
1062
1063 UINT32
1064 AcpiOsGetThreadId(void)
1065 {
1066     return getpid();
1067 }
1068
1069
1070 /******************************************************************************
1071  *
1072  * FUNCTION:    AcpiOsSignal
1073  *
1074  * PARAMETERS:  Function            ACPI CA signal function code
1075  *              Info                Pointer to function-dependent structure
1076  *
1077  * RETURN:      Status
1078  *
1079  * DESCRIPTION: Miscellaneous functions
1080  *
1081  *****************************************************************************/
1082
1083 ACPI_STATUS
1084 AcpiOsSignal (
1085     UINT32                  Function,
1086     void                    *Info)
1087 {
1088
1089     switch (Function)
1090     {
1091     case ACPI_SIGNAL_FATAL:
1092         break;
1093
1094     case ACPI_SIGNAL_BREAKPOINT:
1095
1096         if (Info)
1097         {
1098             AcpiOsPrintf ("AcpiOsBreakpoint: %s ****\n", Info);
1099         }
1100         else
1101         {
1102             AcpiOsPrintf ("At AcpiOsBreakpoint ****\n");
1103         }
1104
1105         break;
1106     }
1107
1108
1109     return (AE_OK);
1110 }
1111
1112