osunixxf.c revision 118812
1132935Simp/******************************************************************************
243045Sdillon *
343045Sdillon * Module Name: osunixxf - UNIX OSL interfaces
4132935Simp *
5132935Simp *****************************************************************************/
6132935Simp
7132935Simp/******************************************************************************
8132935Simp *
9132935Simp * 1. Copyright Notice
10132935Simp *
1143045Sdillon * Some or all of this work - Copyright (c) 1999 - 2003, Intel Corp.
12132935Simp * All rights reserved.
13132935Simp *
14132935Simp * 2. License
15132935Simp *
16132935Simp * 2.1. This is your license from Intel Corp. under its intellectual property
17132935Simp * rights.  You may have additional license terms from the party that provided
18132935Simp * you this software, covering your right to use that party's intellectual
19132935Simp * property rights.
20132935Simp *
21132935Simp * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
22132935Simp * copy of the source code appearing in this file ("Covered Code") an
23132935Simp * irrevocable, perpetual, worldwide license under Intel's copyrights in the
2450476Speter * base code distributed originally by Intel ("Original Intel Code") to copy,
2543045Sdillon * make derivatives, distribute, use and display any portion of the Covered
2643045Sdillon * Code in any form, with the right to sublicense such rights; and
2743045Sdillon *
2843045Sdillon * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
2943045Sdillon * license (with the right to sublicense), under only those claims of Intel
3043051Sdillon * patents that are infringed by the Original Intel Code, to make, use, sell,
3143045Sdillon * offer to sell, and import the Covered Code and derivative works thereof
3259510Sphantom * solely to the minimum extent necessary to exercise the above copyright
3359510Sphantom * license, and in no event shall the patent license extend to any additions
3443045Sdillon * to or modifications of the Original Intel Code.  No other license or right
3584306Sru * is granted directly or by implication, estoppel or otherwise;
3643045Sdillon *
3743051Sdillon * The above copyright and patent license is granted only if the following
3843045Sdillon * conditions are met:
3943045Sdillon *
4043051Sdillon * 3. Conditions
4171895Sru *
4271895Sru * 3.1. Redistribution of Source with Rights to Further Distribute Source.
4371895Sru * Redistribution of source code of any substantial portion of the Covered
4471895Sru * Code or modification with rights to further distribute source must include
4571895Sru * the above Copyright Notice, the above License, this list of Conditions,
4671895Sru * and the following Disclaimer and Export Compliance provision.  In addition,
4771895Sru * Licensee must cause all Covered Code to which Licensee contributes to
4871895Sru * contain a file documenting the changes Licensee made to create that Covered
49131504Sru * Code and the date of any change.  Licensee must include in that file the
50131504Sru * documentation of any changes made by any predecessor Licensee.  Licensee
5171895Sru * must include a prominent statement that the modification is derived,
5271895Sru * directly or indirectly, from Original Intel Code.
53131504Sru *
54131504Sru * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
5571895Sru * Redistribution of source code of any substantial portion of the Covered
5671895Sru * Code or modification without rights to further distribute source must
5771895Sru * include the following Disclaimer and Export Compliance provision in the
5871895Sru * documentation and/or other materials provided with distribution.  In
5971895Sru * addition, Licensee may not authorize further sublicense of source of any
6071895Sru * portion of the Covered Code, and must include terms to the effect that the
6171895Sru * license from Licensee to its licensee is limited to the intellectual
62131504Sru * property embodied in the software Licensee provides to its licensee, and
63131504Sru * not to intellectual property embodied in modifications its licensee may
6479754Sdd * make.
6543045Sdillon *
6681458Sru * 3.3. Redistribution of Executable. Redistribution in executable form of any
6743045Sdillon * substantial portion of the Covered Code or modification must reproduce the
6843045Sdillon * above Copyright Notice, and the following Disclaimer and Export Compliance
6943045Sdillon * provision in the documentation and/or other materials provided with the
7043045Sdillon * distribution.
7143045Sdillon *
7271895Sru * 3.4. Intel retains all right, title, and interest in and to the Original
7371895Sru * Intel Code.
74131504Sru *
75131504Sru * 3.5. Neither the name Intel nor any other trademark owned or controlled by
7671895Sru * Intel shall be used in advertising or otherwise to promote the sale, use or
7771895Sru * other dealings in products derived from or relating to the Covered Code
7871895Sru * without prior written authorization from Intel.
7971895Sru *
8071895Sru * 4. Disclaimer and Export Compliance
8171895Sru *
8271895Sru * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
8371895Sru * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
8471895Sru * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
8571895Sru * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
8643045Sdillon * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
8743045Sdillon * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
8871895Sru * PARTICULAR PURPOSE.
8971895Sru *
9071895Sru * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
9171895Sru * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
9271895Sru * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
9371895Sru * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
9443045Sdillon * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
9543045Sdillon * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
9643045Sdillon * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
9771895Sru * LIMITED REMEDY.
9871895Sru *
9971895Sru * 4.3. Licensee shall not export, either directly or indirectly, any of this
10071895Sru * software or system incorporating such software without first obtaining any
10179754Sdd * required license or other approval from the U. S. Department of Commerce or
10243045Sdillon * any other agency or department of the United States Government.  In the
10343045Sdillon * event Licensee exports any such software from the United States or
10443045Sdillon * re-exports any such software from a foreign destination, Licensee shall
10543045Sdillon * ensure that the distribution and export/re-export of the software is in
10643045Sdillon * compliance with all laws, regulations, orders, or other restrictions of the
10743045Sdillon * U.S. Export Administration Regulations. Licensee agrees that neither it nor
108131504Sru * any of its subsidiaries will export/re-export any technical data, process,
109131504Sru * software, or service, directly or indirectly, to any country for which the
11043045Sdillon * United States government or any agency thereof requires an export license,
11143045Sdillon * 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 "acpi.h"
129#include "amlcode.h"
130#include "acparser.h"
131#include "acdebug.h"
132
133#define _COMPONENT          ACPI_OS_SERVICES
134        ACPI_MODULE_NAME    ("osunixxf")
135
136
137extern FILE                    *AcpiGbl_DebugFile;
138FILE                           *AcpiGbl_OutputFile;
139
140
141/******************************************************************************
142 *
143 * FUNCTION:    AcpiOsInitialize, AcpiOsTerminate
144 *
145 * PARAMETERS:  None
146 *
147 * RETURN:      Status
148 *
149 * DESCRIPTION: Init and terminate.  Nothing to do.
150 *
151 *****************************************************************************/
152
153ACPI_STATUS
154AcpiOsInitialize (void)
155{
156    AcpiGbl_OutputFile = stdout;
157
158    return AE_OK;
159}
160
161
162ACPI_STATUS
163AcpiOsTerminate (void)
164{
165    return AE_OK;
166}
167
168
169/******************************************************************************
170 *
171 * FUNCTION:    AcpiOsGetRootPointer
172 *
173 * PARAMETERS:  Flags   - Logical or physical addressing mode
174 *              Address - Where the address is returned
175 *
176 * RETURN:      Status
177 *
178 * DESCRIPTION: Gets the root pointer (RSDP)
179 *
180 *****************************************************************************/
181
182ACPI_STATUS
183AcpiOsGetRootPointer (
184    UINT32                  Flags,
185    ACPI_POINTER           *Address)
186{
187
188    return (AE_OK);
189}
190
191
192/******************************************************************************
193 *
194 * FUNCTION:    AcpiOsPredefinedOverride
195 *
196 * PARAMETERS:  InitVal     - Initial value of the predefined object
197 *              NewVal      - The new value for the object
198 *
199 * RETURN:      Status, pointer to value.  Null pointer returned if not
200 *              overriding.
201 *
202 * DESCRIPTION: Allow the OS to override predefined names
203 *
204 *****************************************************************************/
205
206ACPI_STATUS
207AcpiOsPredefinedOverride (
208    const ACPI_PREDEFINED_NAMES *InitVal,
209    ACPI_STRING                 *NewVal)
210{
211
212    if (!InitVal || !NewVal)
213    {
214        return (AE_BAD_PARAMETER);
215    }
216
217    *NewVal = NULL;
218    return (AE_OK);
219}
220
221
222/******************************************************************************
223 *
224 * FUNCTION:    AcpiOsTableOverride
225 *
226 * PARAMETERS:  ExistingTable   - Header of current table (probably firmware)
227 *              NewTable        - Where an entire new table is returned.
228 *
229 * RETURN:      Status, pointer to new table.  Null pointer returned if no
230 *              table is available to override
231 *
232 * DESCRIPTION: Return a different version of a table if one is available
233 *
234 *****************************************************************************/
235
236ACPI_STATUS
237AcpiOsTableOverride (
238    ACPI_TABLE_HEADER       *ExistingTable,
239    ACPI_TABLE_HEADER       **NewTable)
240{
241    if (!ExistingTable || !NewTable)
242    {
243        return (AE_BAD_PARAMETER);
244    }
245
246    *NewTable = NULL;
247    return (AE_OK);
248}
249
250
251/******************************************************************************
252 *
253 * FUNCTION:    AcpiOsReadable
254 *
255 * PARAMETERS:  Pointer             - Area to be verified
256 *              Length              - Size of area
257 *
258 * RETURN:      TRUE if readable for entire length
259 *
260 * DESCRIPTION: Verify that a pointer is valid for reading
261 *
262 *****************************************************************************/
263
264BOOLEAN
265AcpiOsReadable (
266    void                    *Pointer,
267    ACPI_SIZE               Length)
268{
269
270    return (TRUE);
271}
272
273
274/******************************************************************************
275 *
276 * FUNCTION:    AcpiOsWritable
277 *
278 * PARAMETERS:  Pointer             - Area to be verified
279 *              Length              - Size of area
280 *
281 * RETURN:      TRUE if writable for entire length
282 *
283 * DESCRIPTION: Verify that a pointer is valid for writing
284 *
285 *****************************************************************************/
286
287BOOLEAN
288AcpiOsWritable (
289    void                    *Pointer,
290    ACPI_SIZE               Length)
291{
292
293    return (TRUE);
294}
295
296
297/******************************************************************************
298 *
299 * FUNCTION:    AcpiOsRedirectOutput
300 *
301 * PARAMETERS:  Destination         - An open file handle/pointer
302 *
303 * RETURN:      None
304 *
305 * DESCRIPTION: Causes redirect of AcpiOsPrintf and AcpiOsVprintf
306 *
307 *****************************************************************************/
308
309void
310AcpiOsRedirectOutput (
311    void                    *Destination)
312{
313
314    AcpiGbl_OutputFile = Destination;
315}
316
317
318/******************************************************************************
319 *
320 * FUNCTION:    AcpiOsPrintf
321 *
322 * PARAMETERS:  fmt, ...            Standard printf format
323 *
324 * RETURN:      None
325 *
326 * DESCRIPTION: Formatted output
327 *
328 *****************************************************************************/
329
330void ACPI_INTERNAL_VAR_XFACE
331AcpiOsPrintf (
332    const char              *Fmt,
333    ...)
334{
335    va_list                 Args;
336
337
338    va_start (Args, Fmt);
339
340    AcpiOsVprintf (Fmt, Args);
341
342    va_end (Args);
343    return;
344}
345
346
347/******************************************************************************
348 *
349 * FUNCTION:    AcpiOsVprintf
350 *
351 * PARAMETERS:  fmt                 Standard printf format
352 *              args                Argument list
353 *
354 * RETURN:      None
355 *
356 * DESCRIPTION: Formatted output with argument list pointer
357 *
358 *****************************************************************************/
359
360void
361AcpiOsVprintf (
362    const char              *Fmt,
363    va_list                 Args)
364{
365    INT32                   Count = 0;
366    UINT8                   Flags;
367
368
369    Flags = AcpiGbl_DbOutputFlags;
370    if (Flags & ACPI_DB_REDIRECTABLE_OUTPUT)
371    {
372        /* Output is directable to either a file (if open) or the console */
373
374        if (AcpiGbl_DebugFile)
375        {
376            /* Output file is open, send the output there */
377
378            Count = vfprintf (AcpiGbl_DebugFile, Fmt, Args);
379        }
380        else
381        {
382            /* No redirection, send output to console (once only!) */
383
384            Flags |= ACPI_DB_CONSOLE_OUTPUT;
385        }
386    }
387
388    if (Flags & ACPI_DB_CONSOLE_OUTPUT)
389    {
390        Count = vfprintf (AcpiGbl_OutputFile, Fmt, Args);
391    }
392
393    return;
394}
395
396
397/******************************************************************************
398 *
399 * FUNCTION:    AcpiOsGetLine
400 *
401 * PARAMETERS:  fmt                 Standard printf format
402 *              args                Argument list
403 *
404 * RETURN:      Actual bytes read
405 *
406 * DESCRIPTION: Formatted input with argument list pointer
407 *
408 *****************************************************************************/
409
410UINT32
411AcpiOsGetLine (
412    char                    *Buffer)
413{
414    UINT8                   Temp;
415    UINT32                  i;
416
417
418    for (i = 0; ; i++)
419    {
420        scanf ("%1c", &Temp);
421        if (!Temp || Temp == '\n')
422        {
423            break;
424        }
425
426        Buffer [i] = Temp;
427    }
428
429    /* Null terminate the buffer */
430
431    Buffer [i] = 0;
432
433    /* Return the number of bytes in the string */
434
435    return (i);
436}
437
438/******************************************************************************
439 *
440 * FUNCTION:    AcpiOsMapMemory
441 *
442 * PARAMETERS:  where               Physical address of memory to be mapped
443 *              length              How much memory to map
444 *              there               Logical address of mapped memory
445 *
446 * RETURN:      Pointer to mapped memory.  Null on error.
447 *
448 * DESCRIPTION: Map physical memory into caller's address space
449 *
450 *****************************************************************************/
451
452ACPI_STATUS
453AcpiOsMapMemory (
454    ACPI_PHYSICAL_ADDRESS   where,
455    ACPI_SIZE               length,
456    void                    **there)
457{
458    *there = (void *) (uintptr_t) where;
459
460    return AE_OK;
461}
462
463
464/******************************************************************************
465 *
466 * FUNCTION:    AcpiOsUnmapMemory
467 *
468 * PARAMETERS:  where               Logical address of memory to be unmapped
469 *              length              How much memory to unmap
470 *
471 * RETURN:      None.
472 *
473 * DESCRIPTION: Delete a previously created mapping.  Where and Length must
474 *              correspond to a previous mapping exactly.
475 *
476 *****************************************************************************/
477
478void
479AcpiOsUnmapMemory (
480    void                    *where,
481    ACPI_SIZE               length)
482{
483
484    return;
485}
486
487
488/******************************************************************************
489 *
490 * FUNCTION:    AcpiOsAllocate
491 *
492 * PARAMETERS:  Size                Amount to allocate, in bytes
493 *
494 * RETURN:      Pointer to the new allocation.  Null on error.
495 *
496 * DESCRIPTION: Allocate memory.  Algorithm is dependent on the OS.
497 *
498 *****************************************************************************/
499
500void *
501AcpiOsAllocate (
502    ACPI_SIZE               size)
503{
504    void                    *Mem;
505
506
507    Mem = (void *) malloc ((size_t) size);
508
509    return Mem;
510}
511
512
513/******************************************************************************
514 *
515 * FUNCTION:    AcpiOsFree
516 *
517 * PARAMETERS:  mem                 Pointer to previously allocated memory
518 *
519 * RETURN:      None.
520 *
521 * DESCRIPTION: Free memory allocated via AcpiOsAllocate
522 *
523 *****************************************************************************/
524
525void
526AcpiOsFree (
527    void                    *mem)
528{
529
530
531    free (mem);
532}
533
534
535/******************************************************************************
536 *
537 * FUNCTION:    AcpiOsCreateSemaphore
538 *
539 * PARAMETERS:  InitialUnits        - Units to be assigned to the new semaphore
540 *              OutHandle           - Where a handle will be returned
541 *
542 * RETURN:      Status
543 *
544 * DESCRIPTION: Create an OS semaphore
545 *
546 *****************************************************************************/
547
548ACPI_STATUS
549AcpiOsCreateSemaphore (
550    UINT32              MaxUnits,
551    UINT32              InitialUnits,
552    ACPI_HANDLE         *OutHandle)
553{
554
555
556    *OutHandle = (ACPI_HANDLE) 1;
557    return AE_OK;
558}
559
560/******************************************************************************
561 *
562 * FUNCTION:    AcpiOsDeleteSemaphore
563 *
564 * PARAMETERS:  Handle              - Handle returned by AcpiOsCreateSemaphore
565 *
566 * RETURN:      Status
567 *
568 * DESCRIPTION: Delete an OS semaphore
569 *
570 *****************************************************************************/
571
572ACPI_STATUS
573AcpiOsDeleteSemaphore (
574    ACPI_HANDLE         Handle)
575{
576
577    if (!Handle)
578    {
579        return AE_BAD_PARAMETER;
580    }
581
582    return AE_OK;
583}
584
585
586/******************************************************************************
587 *
588 * FUNCTION:    AcpiOsWaitSemaphore
589 *
590 * PARAMETERS:  Handle              - Handle returned by AcpiOsCreateSemaphore
591 *              Units               - How many units to wait for
592 *              Timeout             - How long to wait
593 *
594 * RETURN:      Status
595 *
596 * DESCRIPTION: Wait for units
597 *
598 *****************************************************************************/
599
600ACPI_STATUS
601AcpiOsWaitSemaphore (
602    ACPI_HANDLE         Handle,
603    UINT32              Units,
604    UINT16              Timeout)
605{
606
607
608    return AE_OK;
609}
610
611
612/******************************************************************************
613 *
614 * FUNCTION:    AcpiOsSignalSemaphore
615 *
616 * PARAMETERS:  Handle              - Handle returned by AcpiOsCreateSemaphore
617 *              Units               - Number of units to send
618 *
619 * RETURN:      Status
620 *
621 * DESCRIPTION: Send units
622 *
623 *****************************************************************************/
624
625ACPI_STATUS
626AcpiOsSignalSemaphore (
627    ACPI_HANDLE         Handle,
628    UINT32              Units)
629{
630
631
632    return AE_OK;
633}
634
635
636ACPI_STATUS
637AcpiOsCreateLock (
638    ACPI_HANDLE             *OutHandle)
639{
640
641    return (AcpiOsCreateSemaphore (1, 1, OutHandle));
642}
643
644void
645AcpiOsDeleteLock (
646    ACPI_HANDLE             Handle)
647{
648    AcpiOsDeleteSemaphore (Handle);
649}
650
651
652void
653AcpiOsAcquireLock (
654    ACPI_HANDLE             Handle,
655    UINT32                  Flags)
656{
657    AcpiOsWaitSemaphore (Handle, 1, 0xFFFF);
658}
659
660
661void
662AcpiOsReleaseLock (
663    ACPI_HANDLE             Handle,
664    UINT32                  Flags)
665{
666    AcpiOsSignalSemaphore (Handle, 1);
667}
668
669
670/******************************************************************************
671 *
672 * FUNCTION:    AcpiOsInstallInterruptHandler
673 *
674 * PARAMETERS:  InterruptNumber     Level handler should respond to.
675 *              Isr                 Address of the ACPI interrupt handler
676 *              ExceptPtr           Where status is returned
677 *
678 * RETURN:      Handle to the newly installed handler.
679 *
680 * DESCRIPTION: Install an interrupt handler.  Used to install the ACPI
681 *              OS-independent handler.
682 *
683 *****************************************************************************/
684
685UINT32
686AcpiOsInstallInterruptHandler (
687    UINT32                  InterruptNumber,
688    OSD_HANDLER             ServiceRoutine,
689    void                    *Context)
690{
691
692
693    return AE_OK;
694}
695
696
697/******************************************************************************
698 *
699 * FUNCTION:    AcpiOsRemoveInterruptHandler
700 *
701 * PARAMETERS:  Handle              Returned when handler was installed
702 *
703 * RETURN:      Status
704 *
705 * DESCRIPTION: Uninstalls an interrupt handler.
706 *
707 *****************************************************************************/
708
709ACPI_STATUS
710AcpiOsRemoveInterruptHandler (
711    UINT32                  InterruptNumber,
712    OSD_HANDLER             ServiceRoutine)
713{
714
715    return AE_OK;
716}
717
718
719/******************************************************************************
720 *
721 * FUNCTION:    AcpiOsQueueForExecution
722 *
723 * PARAMETERS:  Priority        - Requested execution priority
724 *              Function        - Address of the function to execute
725 *              Context         - Passed as a parameter to the function
726 *
727 * RETURN:      Status.
728 *
729 * DESCRIPTION: Sleep at microsecond granularity
730 *
731 *****************************************************************************/
732
733ACPI_STATUS
734AcpiOsQueueForExecution (
735    UINT32                  Priority,
736    OSD_EXECUTION_CALLBACK  Function,
737    void                    *Context)
738{
739
740//    _beginthread (Function, (unsigned) 0, Context);
741    return 0;
742}
743
744
745/******************************************************************************
746 *
747 * FUNCTION:    AcpiOsBreakpoint
748 *
749 * PARAMETERS:  Msg                 Message to print
750 *
751 * RETURN:      Status
752 *
753 * DESCRIPTION: Print a message and break to the debugger.
754 *
755 *****************************************************************************/
756
757ACPI_STATUS
758AcpiOsBreakpoint (
759    char                    *Msg)
760{
761
762    /* Print the message and do an INT 3 */
763
764    if (Msg)
765    {
766        AcpiOsPrintf ("AcpiOsBreakpoint: %s ****\n", Msg);
767    }
768    else
769    {
770        AcpiOsPrintf ("At AcpiOsBreakpoint ****\n");
771    }
772
773
774    return AE_OK;
775}
776
777
778/******************************************************************************
779 *
780 * FUNCTION:    AcpiOsSleepUsec
781 *
782 * PARAMETERS:  microseconds        To sleep
783 *
784 * RETURN:      Blocks until sleep is completed.
785 *
786 * DESCRIPTION: Sleep at microsecond granularity
787 *
788 *****************************************************************************/
789
790void
791AcpiOsStall (
792    UINT32                  microseconds)
793{
794
795    return;
796}
797
798
799/******************************************************************************
800 *
801 * FUNCTION:    AcpiOsSleep
802 *
803 * PARAMETERS:  seconds             To sleep
804 *              milliseconds        To sleep
805 *
806 * RETURN:      Blocks until sleep is completed.
807 *
808 * DESCRIPTION: Sleep at second/millisecond granularity
809 *
810 *****************************************************************************/
811
812void
813AcpiOsSleep (
814    UINT32                  seconds,
815    UINT32                  milliseconds)
816{
817
818    usleep (((seconds * 1000) + milliseconds) * 1000);
819    return;
820}
821
822/******************************************************************************
823 *
824 * FUNCTION:    AcpiOsGetTimer
825 *
826 * PARAMETERS:  None
827 *
828 * RETURN:      Current time in milliseconds
829 *
830 * DESCRIPTION: Get the current system time (in milliseconds).
831 *
832 *****************************************************************************/
833
834UINT32
835AcpiOsGetTimer (void)
836{
837    struct timeval  time;
838
839    gettimeofday(&time, NULL);
840
841    return ((time.tv_sec/1000) + (time.tv_usec*1000));
842}
843
844
845/******************************************************************************
846 *
847 * FUNCTION:    AcpiOsReadPciConfiguration
848 *
849 * PARAMETERS:  PciId               Seg/Bus/Dev
850 *              Register            Device Register
851 *              Value               Buffer where value is placed
852 *              Width               Number of bits
853 *
854 * RETURN:      Status
855 *
856 * DESCRIPTION: Read data from PCI configuration space
857 *
858 *****************************************************************************/
859
860ACPI_STATUS
861AcpiOsReadPciConfiguration (
862    ACPI_PCI_ID             *PciId,
863    UINT32                  Register,
864    void                    *Value,
865    UINT32                  Width)
866{
867
868    return (AE_OK);
869}
870
871
872/******************************************************************************
873 *
874 * FUNCTION:    AcpiOsWritePciConfiguration
875 *
876 * PARAMETERS:  PciId               Seg/Bus/Dev
877 *              Register            Device Register
878 *              Value               Value to be written
879 *              Width               Number of bits
880 *
881 * RETURN:      Status.
882 *
883 * DESCRIPTION: Write data to PCI configuration space
884 *
885 *****************************************************************************/
886
887ACPI_STATUS
888AcpiOsWritePciConfiguration (
889    ACPI_PCI_ID             *PciId,
890    UINT32                  Register,
891    ACPI_INTEGER            Value,
892    UINT32                  Width)
893{
894
895    return (AE_OK);
896}
897
898/* TEMPORARY STUB FUNCTION */
899void
900AcpiOsDerivePciId(
901    ACPI_HANDLE             rhandle,
902    ACPI_HANDLE             chandle,
903    ACPI_PCI_ID             **PciId)
904{
905
906}
907
908
909/******************************************************************************
910 *
911 * FUNCTION:    AcpiOsReadPort
912 *
913 * PARAMETERS:  Address             Address of I/O port/register to read
914 *              Value               Where value is placed
915 *              Width               Number of bits
916 *
917 * RETURN:      Value read from port
918 *
919 * DESCRIPTION: Read data from an I/O port or register
920 *
921 *****************************************************************************/
922
923ACPI_STATUS
924AcpiOsReadPort (
925    ACPI_IO_ADDRESS         Address,
926    UINT32                  *Value,
927    UINT32                  Width)
928{
929
930    switch (Width)
931    {
932    case 8:
933        *Value = 0xFF;
934        break;
935
936    case 16:
937        *Value = 0xFFFF;
938        break;
939
940    case 32:
941        *Value = 0xFFFFFFFF;
942        break;
943    }
944
945    return (AE_OK);
946}
947
948
949/******************************************************************************
950 *
951 * FUNCTION:    AcpiOsWritePort
952 *
953 * PARAMETERS:  Address             Address of I/O port/register to write
954 *              Value               Value to write
955 *              Width               Number of bits
956 *
957 * RETURN:      None
958 *
959 * DESCRIPTION: Write data to an I/O port or register
960 *
961 *****************************************************************************/
962
963ACPI_STATUS
964AcpiOsWritePort (
965    ACPI_IO_ADDRESS         Address,
966    UINT32                  Value,
967    UINT32                  Width)
968{
969
970    return (AE_OK);
971}
972
973
974/******************************************************************************
975 *
976 * FUNCTION:    AcpiOsReadMemory
977 *
978 * PARAMETERS:  Address             Physical Memory Address to read
979 *              Value               Where value is placed
980 *              Width               Number of bits
981 *
982 * RETURN:      Value read from physical memory address
983 *
984 * DESCRIPTION: Read data from a physical memory address
985 *
986 *****************************************************************************/
987
988ACPI_STATUS
989AcpiOsReadMemory (
990    ACPI_PHYSICAL_ADDRESS   Address,
991    UINT32                  *Value,
992    UINT32                  Width)
993{
994
995    switch (Width)
996    {
997    case 8:
998    case 16:
999    case 32:
1000        *Value = 0;
1001        break;
1002
1003    default:
1004        return (AE_BAD_PARAMETER);
1005        break;
1006    }
1007    return (AE_OK);
1008}
1009
1010
1011/******************************************************************************
1012 *
1013 * FUNCTION:    AcpiOsWriteMemory
1014 *
1015 * PARAMETERS:  Address             Physical Memory Address to write
1016 *              Value               Value to write
1017 *              Width               Number of bits
1018 *
1019 * RETURN:      None
1020 *
1021 * DESCRIPTION: Write data to a physical memory address
1022 *
1023 *****************************************************************************/
1024
1025ACPI_STATUS
1026AcpiOsWriteMemory (
1027    ACPI_PHYSICAL_ADDRESS   Address,
1028    UINT32                  Value,
1029    UINT32                  Width)
1030{
1031
1032    return (AE_OK);
1033}
1034
1035
1036UINT32
1037AcpiOsGetThreadId(void)
1038{
1039    return getpid();
1040}
1041
1042
1043/******************************************************************************
1044 *
1045 * FUNCTION:    AcpiOsSignal
1046 *
1047 * PARAMETERS:  Function            ACPI CA signal function code
1048 *              Info                Pointer to function-dependent structure
1049 *
1050 * RETURN:      Status
1051 *
1052 * DESCRIPTION: Miscellaneous functions
1053 *
1054 *****************************************************************************/
1055
1056ACPI_STATUS
1057AcpiOsSignal (
1058    UINT32                  Function,
1059    void                    *Info)
1060{
1061
1062    switch (Function)
1063    {
1064    case ACPI_SIGNAL_FATAL:
1065        break;
1066
1067    case ACPI_SIGNAL_BREAKPOINT:
1068
1069        if (Info)
1070        {
1071            AcpiOsPrintf ("AcpiOsBreakpoint: %s ****\n", Info);
1072        }
1073        else
1074        {
1075            AcpiOsPrintf ("At AcpiOsBreakpoint ****\n");
1076        }
1077
1078        break;
1079    }
1080
1081
1082    return (AE_OK);
1083}
1084
1085
1086