osunixxf.c revision 222538
1/******************************************************************************
2 *
3 * Module Name: osunixxf - UNIX OSL interfaces
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 *    notice, this list of conditions, and the following disclaimer,
16 *    without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 *    substantially similar to the "NO WARRANTY" disclaimer below
19 *    ("Disclaimer") and any redistribution must be conditioned upon
20 *    including a substantially similar Disclaimer requirement for further
21 *    binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 *    of any contributors may be used to endorse or promote products derived
24 *    from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44
45/*
46 * These interfaces are required in order to compile the ASL compiler and the
47 * various ACPICA tools under Linux or other Unix-like system.
48 *
49 * Note: Use #define __APPLE__ for OS X generation.
50 */
51#include <stdio.h>
52#include <stdlib.h>
53#include <stdarg.h>
54#include <unistd.h>
55#include <sys/time.h>
56#include <semaphore.h>
57#include <pthread.h>
58#include <errno.h>
59
60#include "acpi.h"
61#include "accommon.h"
62#include "amlcode.h"
63#include "acparser.h"
64#include "acdebug.h"
65
66#define _COMPONENT          ACPI_OS_SERVICES
67        ACPI_MODULE_NAME    ("osunixxf")
68
69
70extern FILE                    *AcpiGbl_DebugFile;
71FILE                           *AcpiGbl_OutputFile;
72
73
74/* Upcalls to AcpiExec */
75
76ACPI_PHYSICAL_ADDRESS
77AeLocalGetRootPointer (
78    void);
79
80void
81AeTableOverride (
82    ACPI_TABLE_HEADER       *ExistingTable,
83    ACPI_TABLE_HEADER       **NewTable);
84
85typedef void* (*PTHREAD_CALLBACK) (void *);
86
87/* Apple-specific */
88
89#ifdef __APPLE__
90#define sem_destroy         sem_close
91#endif
92
93
94/******************************************************************************
95 *
96 * FUNCTION:    AcpiOsInitialize, AcpiOsTerminate
97 *
98 * PARAMETERS:  None
99 *
100 * RETURN:      Status
101 *
102 * DESCRIPTION: Init and terminate. Nothing to do.
103 *
104 *****************************************************************************/
105
106ACPI_STATUS
107AcpiOsInitialize (
108    void)
109{
110
111    AcpiGbl_OutputFile = stdout;
112    return (AE_OK);
113}
114
115
116ACPI_STATUS
117AcpiOsTerminate (
118    void)
119{
120
121    return (AE_OK);
122}
123
124
125/******************************************************************************
126 *
127 * FUNCTION:    AcpiOsGetRootPointer
128 *
129 * PARAMETERS:  None
130 *
131 * RETURN:      RSDP physical address
132 *
133 * DESCRIPTION: Gets the ACPI root pointer (RSDP)
134 *
135 *****************************************************************************/
136
137ACPI_PHYSICAL_ADDRESS
138AcpiOsGetRootPointer (
139    void)
140{
141
142    return (AeLocalGetRootPointer ());
143}
144
145
146/******************************************************************************
147 *
148 * FUNCTION:    AcpiOsPredefinedOverride
149 *
150 * PARAMETERS:  InitVal             - Initial value of the predefined object
151 *              NewVal              - The new value for the object
152 *
153 * RETURN:      Status, pointer to value. Null pointer returned if not
154 *              overriding.
155 *
156 * DESCRIPTION: Allow the OS to override predefined names
157 *
158 *****************************************************************************/
159
160ACPI_STATUS
161AcpiOsPredefinedOverride (
162    const ACPI_PREDEFINED_NAMES *InitVal,
163    ACPI_STRING                 *NewVal)
164{
165
166    if (!InitVal || !NewVal)
167    {
168        return (AE_BAD_PARAMETER);
169    }
170
171    *NewVal = NULL;
172    return (AE_OK);
173}
174
175
176/******************************************************************************
177 *
178 * FUNCTION:    AcpiOsTableOverride
179 *
180 * PARAMETERS:  ExistingTable       - Header of current table (probably
181 *                                    firmware)
182 *              NewTable            - Where an entire new table is returned.
183 *
184 * RETURN:      Status, pointer to new table. Null pointer returned if no
185 *              table is available to override
186 *
187 * DESCRIPTION: Return a different version of a table if one is available
188 *
189 *****************************************************************************/
190
191ACPI_STATUS
192AcpiOsTableOverride (
193    ACPI_TABLE_HEADER       *ExistingTable,
194    ACPI_TABLE_HEADER       **NewTable)
195{
196
197    if (!ExistingTable || !NewTable)
198    {
199        return (AE_BAD_PARAMETER);
200    }
201
202    *NewTable = NULL;
203
204#ifdef ACPI_EXEC_APP
205
206    AeTableOverride (ExistingTable, NewTable);
207    return (AE_OK);
208#else
209
210    return (AE_NO_ACPI_TABLES);
211#endif
212}
213
214
215/******************************************************************************
216 *
217 * FUNCTION:    AcpiOsRedirectOutput
218 *
219 * PARAMETERS:  Destination         - An open file handle/pointer
220 *
221 * RETURN:      None
222 *
223 * DESCRIPTION: Causes redirect of AcpiOsPrintf and AcpiOsVprintf
224 *
225 *****************************************************************************/
226
227void
228AcpiOsRedirectOutput (
229    void                    *Destination)
230{
231
232    AcpiGbl_OutputFile = Destination;
233}
234
235
236/******************************************************************************
237 *
238 * FUNCTION:    AcpiOsPrintf
239 *
240 * PARAMETERS:  fmt, ...            - Standard printf format
241 *
242 * RETURN:      None
243 *
244 * DESCRIPTION: Formatted output
245 *
246 *****************************************************************************/
247
248void ACPI_INTERNAL_VAR_XFACE
249AcpiOsPrintf (
250    const char              *Fmt,
251    ...)
252{
253    va_list                 Args;
254
255
256    va_start (Args, Fmt);
257    AcpiOsVprintf (Fmt, Args);
258    va_end (Args);
259}
260
261
262/******************************************************************************
263 *
264 * FUNCTION:    AcpiOsVprintf
265 *
266 * PARAMETERS:  fmt                 - Standard printf format
267 *              args                - Argument list
268 *
269 * RETURN:      None
270 *
271 * DESCRIPTION: Formatted output with argument list pointer
272 *
273 *****************************************************************************/
274
275void
276AcpiOsVprintf (
277    const char              *Fmt,
278    va_list                 Args)
279{
280    INT32                   Count = 0;
281    UINT8                   Flags;
282
283
284    Flags = AcpiGbl_DbOutputFlags;
285    if (Flags & ACPI_DB_REDIRECTABLE_OUTPUT)
286    {
287        /* Output is directable to either a file (if open) or the console */
288
289        if (AcpiGbl_DebugFile)
290        {
291            /* Output file is open, send the output there */
292
293            Count = vfprintf (AcpiGbl_DebugFile, Fmt, Args);
294        }
295        else
296        {
297            /* No redirection, send output to console (once only!) */
298
299            Flags |= ACPI_DB_CONSOLE_OUTPUT;
300        }
301    }
302
303    if (Flags & ACPI_DB_CONSOLE_OUTPUT)
304    {
305        Count = vfprintf (AcpiGbl_OutputFile, Fmt, Args);
306    }
307}
308
309
310/******************************************************************************
311 *
312 * FUNCTION:    AcpiOsGetLine
313 *
314 * PARAMETERS:  Buffer              - Where to return the command line
315 *              BufferLength        - Maximum length of Buffer
316 *              BytesRead           - Where the actual byte count is returned
317 *
318 * RETURN:      Status and actual bytes read
319 *
320 * DESCRIPTION: Formatted input with argument list pointer
321 *
322 *****************************************************************************/
323
324ACPI_STATUS
325AcpiOsGetLine (
326    char                    *Buffer,
327    UINT32                  BufferLength,
328    UINT32                  *BytesRead)
329{
330    UINT8                   Temp;
331    UINT32                  i;
332
333
334    for (i = 0; ; i++)
335    {
336        if (i >= BufferLength)
337        {
338            return (AE_BUFFER_OVERFLOW);
339        }
340
341        scanf ("%1c", &Temp);
342        if (!Temp || Temp == '\n')
343        {
344            break;
345        }
346
347        Buffer [i] = Temp;
348    }
349
350    /* Null terminate the buffer */
351
352    Buffer [i] = 0;
353
354    /* Return the number of bytes in the string */
355
356    if (BytesRead)
357    {
358        *BytesRead = i;
359    }
360    return (AE_OK);
361}
362
363
364/******************************************************************************
365 *
366 * FUNCTION:    AcpiOsMapMemory
367 *
368 * PARAMETERS:  where               - Physical address of memory to be mapped
369 *              length              - How much memory to map
370 *
371 * RETURN:      Pointer to mapped memory. Null on error.
372 *
373 * DESCRIPTION: Map physical memory into caller's address space
374 *
375 *****************************************************************************/
376
377void *
378AcpiOsMapMemory (
379    ACPI_PHYSICAL_ADDRESS   where,
380    ACPI_SIZE               length)
381{
382
383    return (ACPI_TO_POINTER ((ACPI_SIZE) where));
384}
385
386
387/******************************************************************************
388 *
389 * FUNCTION:    AcpiOsUnmapMemory
390 *
391 * PARAMETERS:  where               - Logical address of memory to be unmapped
392 *              length              - How much memory to unmap
393 *
394 * RETURN:      None.
395 *
396 * DESCRIPTION: Delete a previously created mapping. Where and Length must
397 *              correspond to a previous mapping exactly.
398 *
399 *****************************************************************************/
400
401void
402AcpiOsUnmapMemory (
403    void                    *where,
404    ACPI_SIZE               length)
405{
406
407    return;
408}
409
410
411/******************************************************************************
412 *
413 * FUNCTION:    AcpiOsAllocate
414 *
415 * PARAMETERS:  Size                - Amount to allocate, in bytes
416 *
417 * RETURN:      Pointer to the new allocation. Null on error.
418 *
419 * DESCRIPTION: Allocate memory. Algorithm is dependent on the OS.
420 *
421 *****************************************************************************/
422
423void *
424AcpiOsAllocate (
425    ACPI_SIZE               size)
426{
427    void                    *Mem;
428
429
430    Mem = (void *) malloc ((size_t) size);
431    return (Mem);
432}
433
434
435/******************************************************************************
436 *
437 * FUNCTION:    AcpiOsFree
438 *
439 * PARAMETERS:  mem                 - Pointer to previously allocated memory
440 *
441 * RETURN:      None.
442 *
443 * DESCRIPTION: Free memory allocated via AcpiOsAllocate
444 *
445 *****************************************************************************/
446
447void
448AcpiOsFree (
449    void                    *mem)
450{
451
452    free (mem);
453}
454
455
456#ifdef ACPI_SINGLE_THREADED
457/******************************************************************************
458 *
459 * FUNCTION:    Semaphore stub functions
460 *
461 * DESCRIPTION: Stub functions used for single-thread applications that do
462 *              not require semaphore synchronization. Full implementations
463 *              of these functions appear after the stubs.
464 *
465 *****************************************************************************/
466
467ACPI_STATUS
468AcpiOsCreateSemaphore (
469    UINT32              MaxUnits,
470    UINT32              InitialUnits,
471    ACPI_HANDLE         *OutHandle)
472{
473    *OutHandle = (ACPI_HANDLE) 1;
474    return (AE_OK);
475}
476
477ACPI_STATUS
478AcpiOsDeleteSemaphore (
479    ACPI_HANDLE         Handle)
480{
481    return (AE_OK);
482}
483
484ACPI_STATUS
485AcpiOsWaitSemaphore (
486    ACPI_HANDLE         Handle,
487    UINT32              Units,
488    UINT16              Timeout)
489{
490    return (AE_OK);
491}
492
493ACPI_STATUS
494AcpiOsSignalSemaphore (
495    ACPI_HANDLE         Handle,
496    UINT32              Units)
497{
498    return (AE_OK);
499}
500
501#else
502/******************************************************************************
503 *
504 * FUNCTION:    AcpiOsCreateSemaphore
505 *
506 * PARAMETERS:  InitialUnits        - Units to be assigned to the new semaphore
507 *              OutHandle           - Where a handle will be returned
508 *
509 * RETURN:      Status
510 *
511 * DESCRIPTION: Create an OS semaphore
512 *
513 *****************************************************************************/
514
515ACPI_STATUS
516AcpiOsCreateSemaphore (
517    UINT32              MaxUnits,
518    UINT32              InitialUnits,
519    ACPI_HANDLE         *OutHandle)
520{
521    sem_t               *Sem;
522
523
524    if (!OutHandle)
525    {
526        return (AE_BAD_PARAMETER);
527    }
528
529#ifdef __APPLE__
530    {
531        char            *SemaphoreName = tmpnam (NULL);
532
533        Sem = sem_open (SemaphoreName, O_EXCL|O_CREAT, 0755, InitialUnits);
534        if (!Sem)
535        {
536            return (AE_NO_MEMORY);
537        }
538        sem_unlink (SemaphoreName); /* This just deletes the name */
539    }
540
541#else
542    Sem = AcpiOsAllocate (sizeof (sem_t));
543    if (!Sem)
544    {
545        return (AE_NO_MEMORY);
546    }
547
548    if (sem_init (Sem, 0, InitialUnits) == -1)
549    {
550        AcpiOsFree (Sem);
551        return (AE_BAD_PARAMETER);
552    }
553#endif
554
555    *OutHandle = (ACPI_HANDLE) Sem;
556    return (AE_OK);
557}
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    sem_t               *Sem = (sem_t *) Handle;
577
578
579    if (!Sem)
580    {
581        return (AE_BAD_PARAMETER);
582    }
583
584    if (sem_destroy (Sem) == -1)
585    {
586        return (AE_BAD_PARAMETER);
587    }
588
589    return (AE_OK);
590}
591
592
593/******************************************************************************
594 *
595 * FUNCTION:    AcpiOsWaitSemaphore
596 *
597 * PARAMETERS:  Handle              - Handle returned by AcpiOsCreateSemaphore
598 *              Units               - How many units to wait for
599 *              Timeout             - How long to wait
600 *
601 * RETURN:      Status
602 *
603 * DESCRIPTION: Wait for units
604 *
605 *****************************************************************************/
606
607ACPI_STATUS
608AcpiOsWaitSemaphore (
609    ACPI_HANDLE         Handle,
610    UINT32              Units,
611    UINT16              Timeout)
612{
613    ACPI_STATUS         Status = AE_OK;
614    sem_t               *Sem = (sem_t *) Handle;
615    struct timespec     T;
616
617
618    if (!Sem)
619    {
620        return (AE_BAD_PARAMETER);
621    }
622
623    switch (Timeout)
624    {
625    /*
626     * No Wait:
627     * --------
628     * A zero timeout value indicates that we shouldn't wait - just
629     * acquire the semaphore if available otherwise return AE_TIME
630     * (a.k.a. 'would block').
631     */
632    case 0:
633
634        if (sem_trywait(Sem) == -1)
635        {
636            Status = (AE_TIME);
637        }
638        break;
639
640    /* Wait Indefinitely */
641
642    case ACPI_WAIT_FOREVER:
643
644        if (sem_wait (Sem))
645        {
646            Status = (AE_TIME);
647        }
648        break;
649
650    /* Wait with Timeout */
651
652    default:
653
654        T.tv_sec = Timeout / 1000;
655        T.tv_nsec = (Timeout - (T.tv_sec * 1000)) * 1000000;
656
657#ifdef ACPI_USE_ALTERNATE_TIMEOUT
658        /*
659         * Alternate timeout mechanism for environments where
660         * sem_timedwait is not available or does not work properly.
661         */
662        while (Timeout)
663        {
664            if (sem_trywait (Sem) == 0)
665            {
666                /* Got the semaphore */
667                return (AE_OK);
668            }
669            usleep (1000);  /* one millisecond */
670            Timeout--;
671        }
672        Status = (AE_TIME);
673#else
674
675        if (sem_timedwait (Sem, &T))
676        {
677            Status = (AE_TIME);
678        }
679#endif
680
681        break;
682    }
683
684    return (Status);
685}
686
687
688/******************************************************************************
689 *
690 * FUNCTION:    AcpiOsSignalSemaphore
691 *
692 * PARAMETERS:  Handle              - Handle returned by AcpiOsCreateSemaphore
693 *              Units               - Number of units to send
694 *
695 * RETURN:      Status
696 *
697 * DESCRIPTION: Send units
698 *
699 *****************************************************************************/
700
701ACPI_STATUS
702AcpiOsSignalSemaphore (
703    ACPI_HANDLE         Handle,
704    UINT32              Units)
705{
706    sem_t               *Sem = (sem_t *)Handle;
707
708
709    if (!Sem)
710    {
711        return (AE_BAD_PARAMETER);
712    }
713
714    if (sem_post (Sem) == -1)
715    {
716        return (AE_LIMIT);
717    }
718
719    return (AE_OK);
720}
721
722#endif /* ACPI_SINGLE_THREADED */
723
724
725/******************************************************************************
726 *
727 * FUNCTION:    Spinlock interfaces
728 *
729 * DESCRIPTION: Map these interfaces to semaphore interfaces
730 *
731 *****************************************************************************/
732
733ACPI_STATUS
734AcpiOsCreateLock (
735    ACPI_SPINLOCK           *OutHandle)
736{
737
738    return (AcpiOsCreateSemaphore (1, 1, OutHandle));
739}
740
741
742void
743AcpiOsDeleteLock (
744    ACPI_SPINLOCK           Handle)
745{
746    AcpiOsDeleteSemaphore (Handle);
747}
748
749
750ACPI_CPU_FLAGS
751AcpiOsAcquireLock (
752    ACPI_HANDLE             Handle)
753{
754    AcpiOsWaitSemaphore (Handle, 1, 0xFFFF);
755    return (0);
756}
757
758
759void
760AcpiOsReleaseLock (
761    ACPI_SPINLOCK           Handle,
762    ACPI_CPU_FLAGS          Flags)
763{
764    AcpiOsSignalSemaphore (Handle, 1);
765}
766
767
768/******************************************************************************
769 *
770 * FUNCTION:    AcpiOsInstallInterruptHandler
771 *
772 * PARAMETERS:  InterruptNumber     - Level handler should respond to.
773 *              Isr                 - Address of the ACPI interrupt handler
774 *              ExceptPtr           - Where status is returned
775 *
776 * RETURN:      Handle to the newly installed handler.
777 *
778 * DESCRIPTION: Install an interrupt handler. Used to install the ACPI
779 *              OS-independent handler.
780 *
781 *****************************************************************************/
782
783UINT32
784AcpiOsInstallInterruptHandler (
785    UINT32                  InterruptNumber,
786    ACPI_OSD_HANDLER        ServiceRoutine,
787    void                    *Context)
788{
789
790    return (AE_OK);
791}
792
793
794/******************************************************************************
795 *
796 * FUNCTION:    AcpiOsRemoveInterruptHandler
797 *
798 * PARAMETERS:  Handle              - Returned when handler was installed
799 *
800 * RETURN:      Status
801 *
802 * DESCRIPTION: Uninstalls an interrupt handler.
803 *
804 *****************************************************************************/
805
806ACPI_STATUS
807AcpiOsRemoveInterruptHandler (
808    UINT32                  InterruptNumber,
809    ACPI_OSD_HANDLER        ServiceRoutine)
810{
811
812    return (AE_OK);
813}
814
815
816/******************************************************************************
817 *
818 * FUNCTION:    AcpiOsExecute
819 *
820 * PARAMETERS:  Type                - Type of execution
821 *              Function            - Address of the function to execute
822 *              Context             - Passed as a parameter to the function
823 *
824 * RETURN:      Status.
825 *
826 * DESCRIPTION: Execute a new thread
827 *
828 *****************************************************************************/
829
830ACPI_STATUS
831AcpiOsExecute (
832    ACPI_EXECUTE_TYPE       Type,
833    ACPI_OSD_EXEC_CALLBACK  Function,
834    void                    *Context)
835{
836    pthread_t               thread;
837    int                     ret;
838
839
840    ret = pthread_create (&thread, NULL, (PTHREAD_CALLBACK) Function, Context);
841    if (ret)
842    {
843        AcpiOsPrintf("Create thread failed");
844    }
845    return (0);
846}
847
848
849/******************************************************************************
850 *
851 * FUNCTION:    AcpiOsStall
852 *
853 * PARAMETERS:  microseconds        - Time to sleep
854 *
855 * RETURN:      Blocks until sleep is completed.
856 *
857 * DESCRIPTION: Sleep at microsecond granularity
858 *
859 *****************************************************************************/
860
861void
862AcpiOsStall (
863    UINT32                  microseconds)
864{
865
866    if (microseconds)
867    {
868        usleep (microseconds);
869    }
870}
871
872
873/******************************************************************************
874 *
875 * FUNCTION:    AcpiOsSleep
876 *
877 * PARAMETERS:  milliseconds        - Time to sleep
878 *
879 * RETURN:      Blocks until sleep is completed.
880 *
881 * DESCRIPTION: Sleep at millisecond granularity
882 *
883 *****************************************************************************/
884
885void
886AcpiOsSleep (
887    UINT64                  milliseconds)
888{
889
890    sleep (milliseconds / 1000);    /* Sleep for whole seconds */
891
892    /*
893     * Arg to usleep() must be less than 1,000,000 (1 second)
894     */
895    usleep ((milliseconds % 1000) * 1000);      /* Sleep for remaining usecs */
896}
897
898
899/******************************************************************************
900 *
901 * FUNCTION:    AcpiOsGetTimer
902 *
903 * PARAMETERS:  None
904 *
905 * RETURN:      Current time in 100 nanosecond units
906 *
907 * DESCRIPTION: Get the current system time
908 *
909 *****************************************************************************/
910
911UINT64
912AcpiOsGetTimer (
913    void)
914{
915    struct timeval          time;
916
917
918    gettimeofday (&time, NULL);
919
920    /* Seconds * 10^7 = 100ns(10^-7), Microseconds(10^-6) * 10^1 = 100ns */
921
922    return (((UINT64) time.tv_sec * 10000000) + ((UINT64) time.tv_usec * 10));
923}
924
925
926/******************************************************************************
927 *
928 * FUNCTION:    AcpiOsReadPciConfiguration
929 *
930 * PARAMETERS:  PciId               - Seg/Bus/Dev
931 *              Register            - Device Register
932 *              Value               - Buffer where value is placed
933 *              Width               - Number of bits
934 *
935 * RETURN:      Status
936 *
937 * DESCRIPTION: Read data from PCI configuration space
938 *
939 *****************************************************************************/
940
941ACPI_STATUS
942AcpiOsReadPciConfiguration (
943    ACPI_PCI_ID             *PciId,
944    UINT32                  Register,
945    UINT64                  *Value,
946    UINT32                  Width)
947{
948
949    return (AE_OK);
950}
951
952
953/******************************************************************************
954 *
955 * FUNCTION:    AcpiOsWritePciConfiguration
956 *
957 * PARAMETERS:  PciId               - Seg/Bus/Dev
958 *              Register            - Device Register
959 *              Value               - Value to be written
960 *              Width               - Number of bits
961 *
962 * RETURN:      Status.
963 *
964 * DESCRIPTION: Write data to PCI configuration space
965 *
966 *****************************************************************************/
967
968ACPI_STATUS
969AcpiOsWritePciConfiguration (
970    ACPI_PCI_ID             *PciId,
971    UINT32                  Register,
972    UINT64                  Value,
973    UINT32                  Width)
974{
975
976    return (AE_OK);
977}
978
979
980/******************************************************************************
981 *
982 * FUNCTION:    AcpiOsReadPort
983 *
984 * PARAMETERS:  Address             - Address of I/O port/register to read
985 *              Value               - Where value is placed
986 *              Width               - Number of bits
987 *
988 * RETURN:      Value read from port
989 *
990 * DESCRIPTION: Read data from an I/O port or register
991 *
992 *****************************************************************************/
993
994ACPI_STATUS
995AcpiOsReadPort (
996    ACPI_IO_ADDRESS         Address,
997    UINT32                  *Value,
998    UINT32                  Width)
999{
1000
1001    switch (Width)
1002    {
1003    case 8:
1004        *Value = 0xFF;
1005        break;
1006
1007    case 16:
1008        *Value = 0xFFFF;
1009        break;
1010
1011    case 32:
1012        *Value = 0xFFFFFFFF;
1013        break;
1014
1015    default:
1016        return (AE_BAD_PARAMETER);
1017    }
1018
1019    return (AE_OK);
1020}
1021
1022
1023/******************************************************************************
1024 *
1025 * FUNCTION:    AcpiOsWritePort
1026 *
1027 * PARAMETERS:  Address             - Address of I/O port/register to write
1028 *              Value               - Value to write
1029 *              Width               - Number of bits
1030 *
1031 * RETURN:      None
1032 *
1033 * DESCRIPTION: Write data to an I/O port or register
1034 *
1035 *****************************************************************************/
1036
1037ACPI_STATUS
1038AcpiOsWritePort (
1039    ACPI_IO_ADDRESS         Address,
1040    UINT32                  Value,
1041    UINT32                  Width)
1042{
1043
1044    return (AE_OK);
1045}
1046
1047
1048/******************************************************************************
1049 *
1050 * FUNCTION:    AcpiOsReadMemory
1051 *
1052 * PARAMETERS:  Address             - Physical Memory Address to read
1053 *              Value               - Where value is placed
1054 *              Width               - Number of bits
1055 *
1056 * RETURN:      Value read from physical memory address
1057 *
1058 * DESCRIPTION: Read data from a physical memory address
1059 *
1060 *****************************************************************************/
1061
1062ACPI_STATUS
1063AcpiOsReadMemory (
1064    ACPI_PHYSICAL_ADDRESS   Address,
1065    UINT32                  *Value,
1066    UINT32                  Width)
1067{
1068
1069    switch (Width)
1070    {
1071    case 8:
1072    case 16:
1073    case 32:
1074        *Value = 0;
1075        break;
1076
1077    default:
1078        return (AE_BAD_PARAMETER);
1079    }
1080    return (AE_OK);
1081}
1082
1083
1084/******************************************************************************
1085 *
1086 * FUNCTION:    AcpiOsWriteMemory
1087 *
1088 * PARAMETERS:  Address             - Physical Memory Address to write
1089 *              Value               - Value to write
1090 *              Width               - Number of bits
1091 *
1092 * RETURN:      None
1093 *
1094 * DESCRIPTION: Write data to a physical memory address
1095 *
1096 *****************************************************************************/
1097
1098ACPI_STATUS
1099AcpiOsWriteMemory (
1100    ACPI_PHYSICAL_ADDRESS   Address,
1101    UINT32                  Value,
1102    UINT32                  Width)
1103{
1104
1105    return (AE_OK);
1106}
1107
1108
1109/******************************************************************************
1110 *
1111 * FUNCTION:    AcpiOsReadable
1112 *
1113 * PARAMETERS:  Pointer             - Area to be verified
1114 *              Length              - Size of area
1115 *
1116 * RETURN:      TRUE if readable for entire length
1117 *
1118 * DESCRIPTION: Verify that a pointer is valid for reading
1119 *
1120 *****************************************************************************/
1121
1122BOOLEAN
1123AcpiOsReadable (
1124    void                    *Pointer,
1125    ACPI_SIZE               Length)
1126{
1127
1128    return (TRUE);
1129}
1130
1131
1132/******************************************************************************
1133 *
1134 * FUNCTION:    AcpiOsWritable
1135 *
1136 * PARAMETERS:  Pointer             - Area to be verified
1137 *              Length              - Size of area
1138 *
1139 * RETURN:      TRUE if writable for entire length
1140 *
1141 * DESCRIPTION: Verify that a pointer is valid for writing
1142 *
1143 *****************************************************************************/
1144
1145BOOLEAN
1146AcpiOsWritable (
1147    void                    *Pointer,
1148    ACPI_SIZE               Length)
1149{
1150
1151    return (TRUE);
1152}
1153
1154
1155/******************************************************************************
1156 *
1157 * FUNCTION:    AcpiOsGetThreadId
1158 *
1159 * PARAMETERS:  None
1160 *
1161 * RETURN:      Id of the running thread
1162 *
1163 * DESCRIPTION: Get the ID of the current (running) thread
1164 *
1165 *****************************************************************************/
1166
1167ACPI_THREAD_ID
1168AcpiOsGetThreadId (
1169    void)
1170{
1171
1172    return (ACPI_CAST_PTHREAD_T (pthread_self()));
1173}
1174
1175
1176/******************************************************************************
1177 *
1178 * FUNCTION:    AcpiOsSignal
1179 *
1180 * PARAMETERS:  Function            - ACPI CA signal function code
1181 *              Info                - Pointer to function-dependent structure
1182 *
1183 * RETURN:      Status
1184 *
1185 * DESCRIPTION: Miscellaneous functions. Example implementation only.
1186 *
1187 *****************************************************************************/
1188
1189ACPI_STATUS
1190AcpiOsSignal (
1191    UINT32                  Function,
1192    void                    *Info)
1193{
1194
1195    switch (Function)
1196    {
1197    case ACPI_SIGNAL_FATAL:
1198        break;
1199
1200    case ACPI_SIGNAL_BREAKPOINT:
1201        break;
1202
1203    default:
1204        break;
1205    }
1206
1207    return (AE_OK);
1208}
1209