167754Smsmith/****************************************************************************** 267754Smsmith * 3241973Sjkim * Name: acpiosxf.h - All interfaces to the OS Services Layer (OSL). These 477424Smsmith * interfaces must be implemented by OSL to interface the 577424Smsmith * ACPI components to the host operating system. 667754Smsmith * 767754Smsmith *****************************************************************************/ 867754Smsmith 967754Smsmith 10217365Sjkim/* 11245582Sjkim * Copyright (C) 2000 - 2013, Intel Corp. 1270243Smsmith * All rights reserved. 1367754Smsmith * 14217365Sjkim * Redistribution and use in source and binary forms, with or without 15217365Sjkim * modification, are permitted provided that the following conditions 16217365Sjkim * are met: 17217365Sjkim * 1. Redistributions of source code must retain the above copyright 18217365Sjkim * notice, this list of conditions, and the following disclaimer, 19217365Sjkim * without modification. 20217365Sjkim * 2. Redistributions in binary form must reproduce at minimum a disclaimer 21217365Sjkim * substantially similar to the "NO WARRANTY" disclaimer below 22217365Sjkim * ("Disclaimer") and any redistribution must be conditioned upon 23217365Sjkim * including a substantially similar Disclaimer requirement for further 24217365Sjkim * binary redistribution. 25217365Sjkim * 3. Neither the names of the above-listed copyright holders nor the names 26217365Sjkim * of any contributors may be used to endorse or promote products derived 27217365Sjkim * from this software without specific prior written permission. 2867754Smsmith * 29217365Sjkim * Alternatively, this software may be distributed under the terms of the 30217365Sjkim * GNU General Public License ("GPL") version 2 as published by the Free 31217365Sjkim * Software Foundation. 3267754Smsmith * 33217365Sjkim * NO WARRANTY 34217365Sjkim * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 35217365Sjkim * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 36217365Sjkim * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 37217365Sjkim * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 38217365Sjkim * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 39217365Sjkim * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 40217365Sjkim * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 41217365Sjkim * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 42217365Sjkim * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 43217365Sjkim * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 44217365Sjkim * POSSIBILITY OF SUCH DAMAGES. 45217365Sjkim */ 4667754Smsmith 4777424Smsmith#ifndef __ACPIOSXF_H__ 4877424Smsmith#define __ACPIOSXF_H__ 4967754Smsmith 50193341Sjkim#include <contrib/dev/acpica/include/platform/acenv.h> 51193341Sjkim#include <contrib/dev/acpica/include/actypes.h> 5267754Smsmith 5367754Smsmith 54167802Sjkim/* Types for AcpiOsExecute */ 5567754Smsmith 56167802Sjkimtypedef enum 57167802Sjkim{ 58167802Sjkim OSL_GLOBAL_LOCK_HANDLER, 59167802Sjkim OSL_NOTIFY_HANDLER, 60167802Sjkim OSL_GPE_HANDLER, 61167802Sjkim OSL_DEBUGGER_THREAD, 62167802Sjkim OSL_EC_POLL_HANDLER, 63167802Sjkim OSL_EC_BURST_HANDLER 6467754Smsmith 65167802Sjkim} ACPI_EXECUTE_TYPE; 66167802Sjkim 6777424Smsmith#define ACPI_NO_UNIT_LIMIT ((UINT32) -1) 6877424Smsmith#define ACPI_MUTEX_SEM 1 6967754Smsmith 7067754Smsmith 7180062Smsmith/* Functions for AcpiOsSignal */ 7280062Smsmith 7380062Smsmith#define ACPI_SIGNAL_FATAL 0 7480062Smsmith#define ACPI_SIGNAL_BREAKPOINT 1 7580062Smsmith 76114237Snjltypedef struct acpi_signal_fatal_info 7780062Smsmith{ 7880062Smsmith UINT32 Type; 7980062Smsmith UINT32 Code; 8080062Smsmith UINT32 Argument; 8180062Smsmith 8280062Smsmith} ACPI_SIGNAL_FATAL_INFO; 8380062Smsmith 8480062Smsmith 8567754Smsmith/* 8677424Smsmith * OSL Initialization and shutdown primitives 8767754Smsmith */ 8867754SmsmithACPI_STATUS 8967754SmsmithAcpiOsInitialize ( 9067754Smsmith void); 9167754Smsmith 9267754SmsmithACPI_STATUS 9367754SmsmithAcpiOsTerminate ( 9467754Smsmith void); 9567754Smsmith 9699146Siwasaki 9799146Siwasaki/* 9899146Siwasaki * ACPI Table interfaces 9999146Siwasaki */ 100167802SjkimACPI_PHYSICAL_ADDRESS 10180062SmsmithAcpiOsGetRootPointer ( 102167802Sjkim void); 10377424Smsmith 10499146SiwasakiACPI_STATUS 105114237SnjlAcpiOsPredefinedOverride ( 106114237Snjl const ACPI_PREDEFINED_NAMES *InitVal, 107114237Snjl ACPI_STRING *NewVal); 108114237Snjl 109114237SnjlACPI_STATUS 11099146SiwasakiAcpiOsTableOverride ( 11199146Siwasaki ACPI_TABLE_HEADER *ExistingTable, 11299146Siwasaki ACPI_TABLE_HEADER **NewTable); 11380062Smsmith 114231844SjkimACPI_STATUS 115231844SjkimAcpiOsPhysicalTableOverride ( 116231844Sjkim ACPI_TABLE_HEADER *ExistingTable, 117231844Sjkim ACPI_PHYSICAL_ADDRESS *NewAddress, 118231844Sjkim UINT32 *NewTableLength); 11999146Siwasaki 120231844Sjkim 12167754Smsmith/* 122167802Sjkim * Spinlock primitives 12367754Smsmith */ 124241973Sjkim#ifndef AcpiOsCreateLock 12567754SmsmithACPI_STATUS 126167802SjkimAcpiOsCreateLock ( 127167802Sjkim ACPI_SPINLOCK *OutHandle); 128241973Sjkim#endif 129167802Sjkim 130167802Sjkimvoid 131167802SjkimAcpiOsDeleteLock ( 132167802Sjkim ACPI_SPINLOCK Handle); 133167802Sjkim 134167802SjkimACPI_CPU_FLAGS 135167802SjkimAcpiOsAcquireLock ( 136167802Sjkim ACPI_SPINLOCK Handle); 137167802Sjkim 138167802Sjkimvoid 139167802SjkimAcpiOsReleaseLock ( 140167802Sjkim ACPI_SPINLOCK Handle, 141167802Sjkim ACPI_CPU_FLAGS Flags); 142167802Sjkim 143167802Sjkim 144167802Sjkim/* 145167802Sjkim * Semaphore primitives 146167802Sjkim */ 147167802SjkimACPI_STATUS 14867754SmsmithAcpiOsCreateSemaphore ( 14967754Smsmith UINT32 MaxUnits, 15067754Smsmith UINT32 InitialUnits, 151167802Sjkim ACPI_SEMAPHORE *OutHandle); 15267754Smsmith 15367754SmsmithACPI_STATUS 15467754SmsmithAcpiOsDeleteSemaphore ( 155167802Sjkim ACPI_SEMAPHORE Handle); 15667754Smsmith 15767754SmsmithACPI_STATUS 15867754SmsmithAcpiOsWaitSemaphore ( 159167802Sjkim ACPI_SEMAPHORE Handle, 16067754Smsmith UINT32 Units, 161107325Siwasaki UINT16 Timeout); 16267754Smsmith 16367754SmsmithACPI_STATUS 16467754SmsmithAcpiOsSignalSemaphore ( 165167802Sjkim ACPI_SEMAPHORE Handle, 16667754Smsmith UINT32 Units); 16767754Smsmith 168167802Sjkim 169167802Sjkim/* 170193267Sjkim * Mutex primitives. May be configured to use semaphores instead via 171193267Sjkim * ACPI_MUTEX_TYPE (see platform/acenv.h) 172167802Sjkim */ 173193267Sjkim#if (ACPI_MUTEX_TYPE != ACPI_BINARY_SEMAPHORE) 174193267Sjkim 175117521SnjlACPI_STATUS 176167802SjkimAcpiOsCreateMutex ( 177167802Sjkim ACPI_MUTEX *OutHandle); 17877424Smsmith 179117521Snjlvoid 180167802SjkimAcpiOsDeleteMutex ( 181167802Sjkim ACPI_MUTEX Handle); 182117521Snjl 183167802SjkimACPI_STATUS 184167802SjkimAcpiOsAcquireMutex ( 185167802Sjkim ACPI_MUTEX Handle, 186167802Sjkim UINT16 Timeout); 187117521Snjl 188117521Snjlvoid 189167802SjkimAcpiOsReleaseMutex ( 190167802Sjkim ACPI_MUTEX Handle); 191193267Sjkim#endif 192117521Snjl 193117521Snjl 19467754Smsmith/* 19567754Smsmith * Memory allocation and mapping 19667754Smsmith */ 19767754Smsmithvoid * 19867754SmsmithAcpiOsAllocate ( 19991116Smsmith ACPI_SIZE Size); 20067754Smsmith 20167754Smsmithvoid 20267754SmsmithAcpiOsFree ( 20367754Smsmith void * Memory); 20467754Smsmith 205167802Sjkimvoid * 20667754SmsmithAcpiOsMapMemory ( 207167802Sjkim ACPI_PHYSICAL_ADDRESS Where, 208193267Sjkim ACPI_SIZE Length); 20967754Smsmith 21067754Smsmithvoid 21167754SmsmithAcpiOsUnmapMemory ( 21267754Smsmith void *LogicalAddress, 21391116Smsmith ACPI_SIZE Size); 21467754Smsmith 21571867SmsmithACPI_STATUS 21671867SmsmithAcpiOsGetPhysicalAddress ( 21771867Smsmith void *LogicalAddress, 21871867Smsmith ACPI_PHYSICAL_ADDRESS *PhysicalAddress); 21967754Smsmith 22077424Smsmith 22167754Smsmith/* 222151937Sjkim * Memory/Object Cache 22367754Smsmith */ 224151937SjkimACPI_STATUS 225151937SjkimAcpiOsCreateCache ( 226151937Sjkim char *CacheName, 227151937Sjkim UINT16 ObjectSize, 228151937Sjkim UINT16 MaxDepth, 229151937Sjkim ACPI_CACHE_T **ReturnCache); 23067754Smsmith 23167754SmsmithACPI_STATUS 232151937SjkimAcpiOsDeleteCache ( 233151937Sjkim ACPI_CACHE_T *Cache); 234151937Sjkim 235151937SjkimACPI_STATUS 236151937SjkimAcpiOsPurgeCache ( 237151937Sjkim ACPI_CACHE_T *Cache); 238151937Sjkim 239151937Sjkimvoid * 240151937SjkimAcpiOsAcquireObject ( 241151937Sjkim ACPI_CACHE_T *Cache); 242151937Sjkim 243151937SjkimACPI_STATUS 244151937SjkimAcpiOsReleaseObject ( 245151937Sjkim ACPI_CACHE_T *Cache, 246151937Sjkim void *Object); 247151937Sjkim 248151937Sjkim 249151937Sjkim/* 250151937Sjkim * Interrupt handlers 251151937Sjkim */ 252151937SjkimACPI_STATUS 25367754SmsmithAcpiOsInstallInterruptHandler ( 25467754Smsmith UINT32 InterruptNumber, 255138287Smarks ACPI_OSD_HANDLER ServiceRoutine, 25667754Smsmith void *Context); 25767754Smsmith 25867754SmsmithACPI_STATUS 25967754SmsmithAcpiOsRemoveInterruptHandler ( 26067754Smsmith UINT32 InterruptNumber, 261138287Smarks ACPI_OSD_HANDLER ServiceRoutine); 26267754Smsmith 26367754Smsmith 26467754Smsmith/* 26577424Smsmith * Threads and Scheduling 26667754Smsmith */ 267167802SjkimACPI_THREAD_ID 26877424SmsmithAcpiOsGetThreadId ( 26977424Smsmith void); 27077424Smsmith 27167754SmsmithACPI_STATUS 272167802SjkimAcpiOsExecute ( 273167802Sjkim ACPI_EXECUTE_TYPE Type, 274138287Smarks ACPI_OSD_EXEC_CALLBACK Function, 27567754Smsmith void *Context); 27667754Smsmith 27767754Smsmithvoid 278138287SmarksAcpiOsWaitEventsComplete ( 279235945Sjkim void); 280138287Smarks 281138287Smarksvoid 28267754SmsmithAcpiOsSleep ( 283202771Sjkim UINT64 Milliseconds); 28467754Smsmith 28567754Smsmithvoid 28680062SmsmithAcpiOsStall ( 28767754Smsmith UINT32 Microseconds); 28867754Smsmith 28977424Smsmith 29067754Smsmith/* 29180062Smsmith * Platform and hardware-independent I/O interfaces 29267754Smsmith */ 29380062SmsmithACPI_STATUS 29480062SmsmithAcpiOsReadPort ( 29580062Smsmith ACPI_IO_ADDRESS Address, 296117521Snjl UINT32 *Value, 29780062Smsmith UINT32 Width); 29867754Smsmith 29980062SmsmithACPI_STATUS 30080062SmsmithAcpiOsWritePort ( 30180062Smsmith ACPI_IO_ADDRESS Address, 302117521Snjl UINT32 Value, 30380062Smsmith UINT32 Width); 30467754Smsmith 30567754Smsmith 30667754Smsmith/* 30780062Smsmith * Platform and hardware-independent physical memory interfaces 30867754Smsmith */ 30980062SmsmithACPI_STATUS 31080062SmsmithAcpiOsReadMemory ( 31180062Smsmith ACPI_PHYSICAL_ADDRESS Address, 312231844Sjkim UINT64 *Value, 31380062Smsmith UINT32 Width); 31467754Smsmith 31580062SmsmithACPI_STATUS 31680062SmsmithAcpiOsWriteMemory ( 31780062Smsmith ACPI_PHYSICAL_ADDRESS Address, 318231844Sjkim UINT64 Value, 31980062Smsmith UINT32 Width); 32067754Smsmith 32167754Smsmith 32267754Smsmith/* 32380062Smsmith * Platform and hardware-independent PCI configuration space access 324138287Smarks * Note: Can't use "Register" as a parameter, changed to "Reg" -- 325138287Smarks * certain compilers complain. 32667754Smsmith */ 32767754SmsmithACPI_STATUS 32880062SmsmithAcpiOsReadPciConfiguration ( 32980062Smsmith ACPI_PCI_ID *PciId, 330138287Smarks UINT32 Reg, 331210976Sjkim UINT64 *Value, 33280062Smsmith UINT32 Width); 33367754Smsmith 33467754SmsmithACPI_STATUS 33580062SmsmithAcpiOsWritePciConfiguration ( 33680062Smsmith ACPI_PCI_ID *PciId, 337138287Smarks UINT32 Reg, 338202771Sjkim UINT64 Value, 33980062Smsmith UINT32 Width); 34067754Smsmith 341167802Sjkim 342114237Snjl/* 34367754Smsmith * Miscellaneous 34467754Smsmith */ 34567754SmsmithBOOLEAN 34667754SmsmithAcpiOsReadable ( 34767754Smsmith void *Pointer, 348117521Snjl ACPI_SIZE Length); 34967754Smsmith 35067754SmsmithBOOLEAN 35167754SmsmithAcpiOsWritable ( 35267754Smsmith void *Pointer, 353117521Snjl ACPI_SIZE Length); 35467754Smsmith 355138287SmarksUINT64 35678986SmsmithAcpiOsGetTimer ( 35778986Smsmith void); 35867754Smsmith 35980062SmsmithACPI_STATUS 36080062SmsmithAcpiOsSignal ( 36180062Smsmith UINT32 Function, 36280062Smsmith void *Info); 36378986Smsmith 364167802Sjkim 36567754Smsmith/* 36667754Smsmith * Debug print routines 36767754Smsmith */ 36892388Smsmithvoid ACPI_INTERNAL_VAR_XFACE 36967754SmsmithAcpiOsPrintf ( 370114237Snjl const char *Format, 37167754Smsmith ...); 37267754Smsmith 37391116Smsmithvoid 37467754SmsmithAcpiOsVprintf ( 375114237Snjl const char *Format, 37667754Smsmith va_list Args); 37767754Smsmith 378100966Siwasakivoid 379100966SiwasakiAcpiOsRedirectOutput ( 380100966Siwasaki void *Destination); 38177424Smsmith 382100966Siwasaki 38367754Smsmith/* 38467754Smsmith * Debug input 38567754Smsmith */ 386222544SjkimACPI_STATUS 38767754SmsmithAcpiOsGetLine ( 388222544Sjkim char *Buffer, 389222544Sjkim UINT32 BufferLength, 390222544Sjkim UINT32 *BytesRead); 39167754Smsmith 39267754Smsmith 39367754Smsmith/* 394250838Sjkim * Obtain ACPI table(s) 395250838Sjkim */ 396250838SjkimACPI_STATUS 397250838SjkimAcpiOsGetTableByName ( 398250838Sjkim char *Signature, 399250838Sjkim UINT32 Instance, 400250838Sjkim ACPI_TABLE_HEADER **Table, 401250838Sjkim ACPI_PHYSICAL_ADDRESS *Address); 402250838Sjkim 403250838SjkimACPI_STATUS 404250838SjkimAcpiOsGetTableByIndex ( 405250838Sjkim UINT32 Index, 406250838Sjkim ACPI_TABLE_HEADER **Table, 407254745Sjkim UINT32 *Instance, 408250838Sjkim ACPI_PHYSICAL_ADDRESS *Address); 409250838Sjkim 410250838SjkimACPI_STATUS 411250838SjkimAcpiOsGetTableByAddress ( 412250838Sjkim ACPI_PHYSICAL_ADDRESS Address, 413250838Sjkim ACPI_TABLE_HEADER **Table); 414250838Sjkim 415250838Sjkim 416250838Sjkim/* 417114237Snjl * Directory manipulation 418114237Snjl */ 419114237Snjlvoid * 420114237SnjlAcpiOsOpenDirectory ( 421114237Snjl char *Pathname, 422114237Snjl char *WildcardSpec, 423114237Snjl char RequestedFileType); 424114237Snjl 425114237Snjl/* RequesteFileType values */ 426114237Snjl 427114237Snjl#define REQUEST_FILE_ONLY 0 428114237Snjl#define REQUEST_DIR_ONLY 1 429114237Snjl 430114237Snjl 431114237Snjlchar * 432114237SnjlAcpiOsGetNextFilename ( 433114237Snjl void *DirHandle); 434114237Snjl 435114237Snjlvoid 436114237SnjlAcpiOsCloseDirectory ( 437114237Snjl void *DirHandle); 438114237Snjl 43967754Smsmith 44077424Smsmith#endif /* __ACPIOSXF_H__ */ 441