acpiosxf.h revision 212761
15455Sdg
21541Srgrimes/******************************************************************************
31541Srgrimes *
41541Srgrimes * Name: acpiosxf.h - All interfaces to the OS Services Layer (OSL).  These
51541Srgrimes *                    interfaces must be implemented by OSL to interface the
61541Srgrimes *                    ACPI components to the host operating system.
71541Srgrimes *
81541Srgrimes *****************************************************************************/
91541Srgrimes
101541Srgrimes
111541Srgrimes/******************************************************************************
121541Srgrimes *
131541Srgrimes * 1. Copyright Notice
141541Srgrimes *
151541Srgrimes * Some or all of this work - Copyright (c) 1999 - 2010, Intel Corp.
161541Srgrimes * All rights reserved.
171541Srgrimes *
181541Srgrimes * 2. License
191541Srgrimes *
201541Srgrimes * 2.1. This is your license from Intel Corp. under its intellectual property
211541Srgrimes * rights.  You may have additional license terms from the party that provided
221541Srgrimes * you this software, covering your right to use that party's intellectual
231541Srgrimes * property rights.
241541Srgrimes *
251541Srgrimes * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
261541Srgrimes * copy of the source code appearing in this file ("Covered Code") an
271541Srgrimes * irrevocable, perpetual, worldwide license under Intel's copyrights in the
281541Srgrimes * base code distributed originally by Intel ("Original Intel Code") to copy,
291541Srgrimes * make derivatives, distribute, use and display any portion of the Covered
301541Srgrimes * Code in any form, with the right to sublicense such rights; and
311541Srgrimes *
321541Srgrimes * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
331541Srgrimes * license (with the right to sublicense), under only those claims of Intel
341541Srgrimes * patents that are infringed by the Original Intel Code, to make, use, sell,
351541Srgrimes * offer to sell, and import the Covered Code and derivative works thereof
361817Sdg * solely to the minimum extent necessary to exer
371541Srgrimes se the above copyright
381541Srgrimes * license, and in no event shall the patent license extend to any additions
391541Srgrimes * to or modifications of the Original Intel Code.  No other license or right
401541Srgrimes * is granted directly or by implication, estoppel or otherwise;
411541Srgrimes *
421541Srgrimes * The above copyright and patent license is granted only if the following
435455Sdg * conditions are met:
441541Srgrimes *
451541Srgrimes * 3. Conditions
461541Srgrimes *
471541Srgrimes * 3.1. Redistribution of Source with Rights to Further Distribute Source.
481541Srgrimes * Redistribution of source code of any substantial portion of the Covered
495455Sdg * Code or modification with rights to further distribute source must include
505455Sdg * the above Copyright Notice, the above License, this list of Conditions,
515455Sdg * and the following Disclaimer and Export Compliance provision.  In addition,
521541Srgrimes * Licensee must cause all Covered Code to which Licensee contributes to
535455Sdg * contain a file documenting the changes Licensee made to create that Covered
541541Srgrimes * Code and the date of any change.  Licensee must include in that file the
551541Srgrimes * documentation of any changes made by any predecessor Licensee.  Licensee
561541Srgrimes * must include a prominent statement that the modification is derived,
571541Srgrimes * directly or indirectly, from Original Intel Code.
581541Srgrimes *
591541Srgrimes * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
601541Srgrimes * Redistribution of source code of any substantial portion of the Covered
611541Srgrimes * Code or modification without rights to further distribute source must
621541Srgrimes * include the following Disclaimer and Export Compliance provision in the
631817Sdg * documentation and/or other materials provided with distribution.  In
6449720Salc * addition, Licensee may not authorize further sublicense of source of any
651541Srgrimes * portion of the Covered Code, and must include terms to the effect that the
661541Srgrimes * license from Licensee to its licensee is limited to the intellectual
671541Srgrimes * property embodied in the software Licensee provides to its licensee, and
681541Srgrimes * not to intellectual property embodied in modifications its licensee may
691541Srgrimes * make.
701541Srgrimes *
711541Srgrimes * 3.3. Redistribution of Executable. Redistribution in executable form of any
721541Srgrimes * substantial portion of the Covered Code or modification must reproduce the
731541Srgrimes * above Copyright Notice, and the following Disclaimer and Export Compliance
7444754Sjulian * provision in the documentation and/or other materials provided with the
7537282Sjmg * distribution.
7644754Sjulian *
7737282Sjmg * 3.4. Intel retains all right, title, and interest in and to the Original
786816Sdg * Intel Code.
7938517Sdfr *
8038517Sdfr * 3.5. Neither the name Intel nor any other trademark owned or controlled by
811541Srgrimes * Intel shall be used in advertising or otherwise to promote the sale, use or
821541Srgrimes * other dealings in products derived from or relating to the Covered Code
831541Srgrimes * without prior written authorization from Intel.
841541Srgrimes *
851541Srgrimes * 4. Disclaimer and Export Compliance
861541Srgrimes *
871541Srgrimes * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
881541Srgrimes * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
891541Srgrimes * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
901541Srgrimes * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
911541Srgrimes * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
921541Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
931541Srgrimes * PARTICULAR PURPOSE.
941541Srgrimes *
951541Srgrimes * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
961541Srgrimes * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
971541Srgrimes * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
981541Srgrimes * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
991541Srgrimes * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
1001541Srgrimes * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
1011541Srgrimes * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
1021541Srgrimes * LIMITED REMEDY.
1031541Srgrimes *
10446349Salc * 4.3. Licensee shall not export, either directly or indirectly, any of this
10546349Salc * software or system incorporating such software without first obtaining any
10646349Salc * required license or other approval from the U. S. Department of Commerce or
10746349Salc * any other agency or department of the United States Government.  In the
1081541Srgrimes * event Licensee exports any such software from the United States or
1091541Srgrimes * re-exports any such software from a foreign destination, Licensee shall
1101541Srgrimes * ensure that the distribution and export/re-export of the software is in
1111541Srgrimes * compliance with all laws, regulations, orders, or other restrictions of the
1121541Srgrimes * U.S. Export Administration Regulations. Licensee agrees that neither it nor
1135455Sdg * any of its subsidiaries will export/re-export any technical data, process,
11442957Sdillon * software, or service, directly or indirectly, to any country for which the
11542957Sdillon * United States government or any agency thereof requires an export license,
1161541Srgrimes * other governmental approval, or letter of assurance, without first obtaining
11742957Sdillon * such license, approval or letter.
11812767Sdyson *
1195455Sdg *****************************************************************************/
12018169Sdyson
12118169Sdyson#ifndef __ACPIOSXF_H__
12218169Sdyson#define __ACPIOSXF_H__
1235455Sdg
1245455Sdg#include <contrib/dev/acpica/include/platform/acenv.h>
12513490Sdyson#include <contrib/dev/acpica/include/actypes.h>
12613490Sdyson
12713490Sdyson
12813490Sdyson/* Types for AcpiOsExecute */
12936735Sdfr
13013490Sdysontypedef enum
13113490Sdyson{
13236735Sdfr    OSL_GLOBAL_LOCK_HANDLER,
13336735Sdfr    OSL_NOTIFY_HANDLER,
13436735Sdfr    OSL_GPE_HANDLER,
13536735Sdfr    OSL_DEBUGGER_THREAD,
1361541Srgrimes    OSL_EC_POLL_HANDLER,
1371541Srgrimes    OSL_EC_BURST_HANDLER
13818169Sdyson
13942957Sdillon} ACPI_EXECUTE_TYPE;
14042957Sdillon
14142957Sdillon#define ACPI_NO_UNIT_LIMIT          ((UINT32) -1)
14242957Sdillon#define ACPI_MUTEX_SEM              1
14342957Sdillon
14442957Sdillon
14544754Sjulian/* Functions for AcpiOsSignal */
14644754Sjulian
14742957Sdillon#define ACPI_SIGNAL_FATAL           0
14818169Sdyson#define ACPI_SIGNAL_BREAKPOINT      1
14918169Sdyson
15043752Sdillontypedef struct acpi_signal_fatal_info
15118169Sdyson{
15218169Sdyson    UINT32                  Type;
15336326Sdyson    UINT32                  Code;
15436326Sdyson    UINT32                  Argument;
15536326Sdyson
15636326Sdyson} ACPI_SIGNAL_FATAL_INFO;
15736326Sdyson
15836326Sdyson
15936326Sdyson/*
16018169Sdyson * OSL Initialization and shutdown primitives
16118169Sdyson */
16218169SdysonACPI_STATUS
16318169SdysonAcpiOsInitialize (
16418169Sdyson    void);
16518169Sdyson
16618169SdysonACPI_STATUS
16718169SdysonAcpiOsTerminate (
16818169Sdyson    void);
16918169Sdyson
17018169Sdyson
17118169Sdyson/*
17218169Sdyson * ACPI Table interfaces
17318169Sdyson */
17418169SdysonACPI_PHYSICAL_ADDRESS
17518169SdysonAcpiOsGetRootPointer (
17618779Sdyson    void);
17718169Sdyson
17818169SdysonACPI_STATUS
17918169SdysonAcpiOsPredefinedOverride (
18018169Sdyson    const ACPI_PREDEFINED_NAMES *InitVal,
18118169Sdyson    ACPI_STRING                 *NewVal);
18249666Salc
18318779SdysonACPI_STATUS
18418779SdysonAcpiOsTableOverride (
18518779Sdyson    ACPI_TABLE_HEADER       *ExistingTable,
18618779Sdyson    ACPI_TABLE_HEADER       **NewTable);
18718779Sdyson
18849666Salc
18949666Salc/*
19049666Salc * Spinlock primitives
19149666Salc */
19249666SalcACPI_STATUS
19349666SalcAcpiOsCreateLock (
19418169Sdyson    ACPI_SPINLOCK           *OutHandle);
19518169Sdyson
19649720Salcvoid
19749720SalcAcpiOsDeleteLock (
19849720Salc    ACPI_SPINLOCK           Handle);
19949720Salc
20049720SalcACPI_CPU_FLAGS
20149720SalcAcpiOsAcquireLock (
20213490Sdyson    ACPI_SPINLOCK           Handle);
20318169Sdyson
20418169Sdysonvoid
20518169SdysonAcpiOsReleaseLock (
20649326Salc    ACPI_SPINLOCK           Handle,
20718169Sdyson    ACPI_CPU_FLAGS          Flags);
20818169Sdyson
20944754Sjulian
21044754Sjulian/*
2111541Srgrimes * Semaphore primitives
2121541Srgrimes */
2131541SrgrimesACPI_STATUS
2141541SrgrimesAcpiOsCreateSemaphore (
2151541Srgrimes    UINT32                  MaxUnits,
21642957Sdillon    UINT32                  InitialUnits,
21742957Sdillon    ACPI_SEMAPHORE          *OutHandle);
21842957Sdillon
21942957SdillonACPI_STATUS
22042957SdillonAcpiOsDeleteSemaphore (
22142957Sdillon    ACPI_SEMAPHORE          Handle);
22242957Sdillon
22342957SdillonACPI_STATUS
22442957SdillonAcpiOsWaitSemaphore (
2251541Srgrimes    ACPI_SEMAPHORE          Handle,
2269507Sdg    UINT32                  Units,
2279507Sdg    UINT16                  Timeout);
2289507Sdg
2291541SrgrimesACPI_STATUS
2309507SdgAcpiOsSignalSemaphore (
2319507Sdg    ACPI_SEMAPHORE          Handle,
23216750Sdyson    UINT32                  Units);
23318169Sdyson
2349507Sdg
2359507Sdg/*
2369507Sdg * Mutex primitives. May be configured to use semaphores instead via
2371541Srgrimes * ACPI_MUTEX_TYPE (see platform/acenv.h)
2381541Srgrimes */
2399507Sdg#if (ACPI_MUTEX_TYPE != ACPI_BINARY_SEMAPHORE)
2401541Srgrimes
2415455SdgACPI_STATUS
2421541SrgrimesAcpiOsCreateMutex (
2439507Sdg    ACPI_MUTEX              *OutHandle);
2449507Sdg
2459507Sdgvoid
2469507SdgAcpiOsDeleteMutex (
2479507Sdg    ACPI_MUTEX              Handle);
2489507Sdg
2499507SdgACPI_STATUS
2509507SdgAcpiOsAcquireMutex (
2511541Srgrimes    ACPI_MUTEX              Handle,
25213765Smpp    UINT16                  Timeout);
2531541Srgrimes
2541541Srgrimesvoid
2559507SdgAcpiOsReleaseMutex (
2561541Srgrimes    ACPI_MUTEX              Handle);
2579507Sdg#endif
2589507Sdg
25910544Sdyson
26010544Sdyson/*
26110544Sdyson * Memory allocation and mapping
26210544Sdyson */
2631541Srgrimesvoid *
2641541SrgrimesAcpiOsAllocate (
26544754Sjulian    ACPI_SIZE               Size);
26644754Sjulian
26718169Sdysonvoid
2685455SdgAcpiOsFree (
2695455Sdg    void *                  Memory);
27018169Sdyson
2711541Srgrimesvoid *
27244754SjulianAcpiOsMapMemory (
27344754Sjulian    ACPI_PHYSICAL_ADDRESS   Where,
27412767Sdyson    ACPI_SIZE               Length);
27512767Sdyson
2765455Sdgvoid
2775455SdgAcpiOsUnmapMemory (
2781541Srgrimes    void                    *LogicalAddress,
2791541Srgrimes    ACPI_SIZE               Size);
2801541Srgrimes
2811541SrgrimesACPI_STATUS
2821541SrgrimesAcpiOsGetPhysicalAddress (
2831541Srgrimes    void                    *LogicalAddress,
2841541Srgrimes    ACPI_PHYSICAL_ADDRESS   *PhysicalAddress);
2851541Srgrimes
2861541Srgrimes
2871541Srgrimes/*
28838799Sdfr * Memory/Object Cache
28938799Sdfr */
29038799SdfrACPI_STATUS
29138799SdfrAcpiOsCreateCache (
29238799Sdfr    char                    *CacheName,
29338517Sdfr    UINT16                  ObjectSize,
29438799Sdfr    UINT16                  MaxDepth,
29538799Sdfr    ACPI_CACHE_T            **ReturnCache);
29638799Sdfr
29738799SdfrACPI_STATUS
29838799SdfrAcpiOsDeleteCache (
29938517Sdfr    ACPI_CACHE_T            *Cache);
30038799Sdfr
30138799SdfrACPI_STATUS
30238799SdfrAcpiOsPurgeCache (
30338799Sdfr    ACPI_CACHE_T            *Cache);
30438799Sdfr
30538799Sdfrvoid *
30633936SdysonAcpiOsAcquireObject (
30738799Sdfr    ACPI_CACHE_T            *Cache);
3081541Srgrimes
30938799SdfrACPI_STATUS
31038799SdfrAcpiOsReleaseObject (
31138799Sdfr    ACPI_CACHE_T            *Cache,
31243122Sdillon    void                    *Object);
31338799Sdfr
31433936Sdyson
3151541Srgrimes/*
31642957Sdillon * Interrupt handlers
31742957Sdillon */
31842957SdillonACPI_STATUS
31942957SdillonAcpiOsInstallInterruptHandler (
32042957Sdillon    UINT32                  InterruptNumber,
32142957Sdillon    ACPI_OSD_HANDLER        ServiceRoutine,
32238799Sdfr    void                    *Context);
32342957Sdillon
32438799SdfrACPI_STATUS
32538799SdfrAcpiOsRemoveInterruptHandler (
32638799Sdfr    UINT32                  InterruptNumber,
32738799Sdfr    ACPI_OSD_HANDLER        ServiceRoutine);
32838799Sdfr
32938799Sdfr
33038517Sdfr/*
33142957Sdillon * Threads and Scheduling
33242957Sdillon */
33342957SdillonACPI_THREAD_ID
33442957SdillonAcpiOsGetThreadId (
33542957Sdillon    void);
33642957Sdillon
33742957SdillonACPI_STATUS
33842957SdillonAcpiOsExecute (
33938799Sdfr    ACPI_EXECUTE_TYPE       Type,
34042957Sdillon    ACPI_OSD_EXEC_CALLBACK  Function,
34142957Sdillon    void                    *Context);
34243122Sdillon
34342957Sdillonvoid
34442957SdillonAcpiOsWaitEventsComplete (
34542957Sdillon    void                    *Context);
34642957Sdillon
34743134Sdillonvoid
34843134SdillonAcpiOsSleep (
34943134Sdillon    UINT64                  Milliseconds);
35043134Sdillon
35143134Sdillonvoid
35242957SdillonAcpiOsStall (
35338799Sdfr    UINT32                  Microseconds);
35438799Sdfr
35538799Sdfr
35634206Sdyson/*
35734206Sdyson * Platform and hardware-independent I/O interfaces
35838799Sdfr */
35938799SdfrACPI_STATUS
36038799SdfrAcpiOsReadPort (
36138799Sdfr    ACPI_IO_ADDRESS         Address,
36242957Sdillon    UINT32                  *Value,
36342957Sdillon    UINT32                  Width);
36438799Sdfr
36534206SdysonACPI_STATUS
36638799SdfrAcpiOsWritePort (
3675455Sdg    ACPI_IO_ADDRESS         Address,
3685455Sdg    UINT32                  Value,
3695455Sdg    UINT32                  Width);
3701541Srgrimes
3715455Sdg
3725455Sdg/*
3735455Sdg * Platform and hardware-independent physical memory interfaces
3741549Srgrimes */
37533109SdysonACPI_STATUS
37633109SdysonAcpiOsReadMemory (
37733109Sdyson    ACPI_PHYSICAL_ADDRESS   Address,
37833109Sdyson    UINT32                  *Value,
37933109Sdyson    UINT32                  Width);
3805455Sdg
3815455SdgACPI_STATUS
38212767SdysonAcpiOsWriteMemory (
38333109Sdyson    ACPI_PHYSICAL_ADDRESS   Address,
3846357Sphk    UINT32                  Value,
38515811Sdyson    UINT32                  Width);
38642957Sdillon
38742957Sdillon
3885455Sdg/*
38912767Sdyson * Platform and hardware-independent PCI configuration space access
39012767Sdyson * Note: Can't use "Register" as a parameter, changed to "Reg" --
39144051Sdillon * certain compilers complain.
39212767Sdyson */
3935455SdgACPI_STATUS
39440700SdgAcpiOsReadPciConfiguration (
3955455Sdg    ACPI_PCI_ID             *PciId,
39617334Sdyson    UINT32                  Reg,
39717334Sdyson    UINT64                  *Value,
39810544Sdyson    UINT32                  Width);
39946349Salc
40046349SalcACPI_STATUS
4015455SdgAcpiOsWritePciConfiguration (
40215811Sdyson    ACPI_PCI_ID             *PciId,
4035455Sdg    UINT32                  Reg,
4045455Sdg    UINT64                  Value,
4056357Sphk    UINT32                  Width);
40643747Sdillon
40742957Sdillon
40833936Sdyson/*
40942957Sdillon * Miscellaneous
41042957Sdillon */
41145347SjulianBOOLEAN
41243752SdillonAcpiOsReadable (
4135455Sdg    void                    *Pointer,
4141549Srgrimes    ACPI_SIZE               Length);
4151549Srgrimes
4161549SrgrimesBOOLEAN
4171549SrgrimesAcpiOsWritable (
4181549Srgrimes    void                    *Pointer,
4191549Srgrimes    ACPI_SIZE               Length);
4208010Sbde
4214461SbdeUINT64
4221549SrgrimesAcpiOsGetTimer (
4231549Srgrimes    void);
4241549Srgrimes
4251549SrgrimesACPI_STATUS
4268010SbdeAcpiOsSignal (
4274461Sbde    UINT32                  Function,
4281549Srgrimes    void                    *Info);
4293660Sdg
43042408Seivind
4311549Srgrimes/*
4321549Srgrimes * Debug print routines
43343122Sdillon */
43443122Sdillonvoid ACPI_INTERNAL_VAR_XFACE
43543122SdillonAcpiOsPrintf (
43643122Sdillon    const char              *Format,
43743122Sdillon    ...);
43843122Sdillon
43943122Sdillonvoid
44043122SdillonAcpiOsVprintf (
44143122Sdillon    const char              *Format,
4428010Sbde    va_list                 Args);
4436816Sdg
4446816Sdgvoid
4456816SdgAcpiOsRedirectOutput (
4466816Sdg    void                    *Destination);
44734206Sdyson
44838799Sdfr
4496816Sdg/*
4506816Sdg * Debug input
45134206Sdyson */
45238799SdfrUINT32
4536816SdgAcpiOsGetLine (
4546816Sdg    char                    *Buffer);
4556816Sdg
45615811Sdyson
45715811Sdyson/*
45815811Sdyson * Directory manipulation
45915811Sdyson */
46015811Sdysonvoid *
46115811SdysonAcpiOsOpenDirectory (
46215811Sdyson    char                    *Pathname,
46315811Sdyson    char                    *WildcardSpec,
46415811Sdyson    char                    RequestedFileType);
46515811Sdyson
46615811Sdyson/* RequesteFileType values */
46715811Sdyson
46815811Sdyson#define REQUEST_FILE_ONLY                   0
46915811Sdyson#define REQUEST_DIR_ONLY                    1
4706816Sdg
47115811Sdyson
47215811Sdysonchar *
47315811SdysonAcpiOsGetNextFilename (
47415811Sdyson    void                    *DirHandle);
47515811Sdyson
47615811Sdysonvoid
47715811SdysonAcpiOsCloseDirectory (
47815811Sdyson    void                    *DirHandle);
47915811Sdyson
48015811Sdyson
48115811Sdyson#endif /* __ACPIOSXF_H__ */
48215811Sdyson