acpiosxf.h revision 217365
167754Smsmith 267754Smsmith/****************************************************************************** 367754Smsmith * 477424Smsmith * Name: acpiosxf.h - All interfaces to the OS Services Layer (OSL). These 577424Smsmith * interfaces must be implemented by OSL to interface the 677424Smsmith * ACPI components to the host operating system. 767754Smsmith * 867754Smsmith *****************************************************************************/ 967754Smsmith 1067754Smsmith 11217365Sjkim/* 12217365Sjkim * Copyright (C) 2000 - 2011, Intel Corp. 1370243Smsmith * All rights reserved. 1467754Smsmith * 15217365Sjkim * Redistribution and use in source and binary forms, with or without 16217365Sjkim * modification, are permitted provided that the following conditions 17217365Sjkim * are met: 18217365Sjkim * 1. Redistributions of source code must retain the above copyright 19217365Sjkim * notice, this list of conditions, and the following disclaimer, 20217365Sjkim * without modification. 21217365Sjkim * 2. Redistributions in binary form must reproduce at minimum a disclaimer 22217365Sjkim * substantially similar to the "NO WARRANTY" disclaimer below 23217365Sjkim * ("Disclaimer") and any redistribution must be conditioned upon 24217365Sjkim * including a substantially similar Disclaimer requirement for further 25217365Sjkim * binary redistribution. 26217365Sjkim * 3. Neither the names of the above-listed copyright holders nor the names 27217365Sjkim * of any contributors may be used to endorse or promote products derived 28217365Sjkim * from this software without specific prior written permission. 2967754Smsmith * 30217365Sjkim * Alternatively, this software may be distributed under the terms of the 31217365Sjkim * GNU General Public License ("GPL") version 2 as published by the Free 32217365Sjkim * Software Foundation. 3367754Smsmith * 34217365Sjkim * NO WARRANTY 35217365Sjkim * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 36217365Sjkim * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 37217365Sjkim * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 38217365Sjkim * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 39217365Sjkim * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 40217365Sjkim * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 41217365Sjkim * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 42217365Sjkim * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 43217365Sjkim * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 44217365Sjkim * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 45217365Sjkim * POSSIBILITY OF SUCH DAMAGES. 46217365Sjkim */ 4767754Smsmith 4877424Smsmith#ifndef __ACPIOSXF_H__ 4977424Smsmith#define __ACPIOSXF_H__ 5067754Smsmith 51193341Sjkim#include <contrib/dev/acpica/include/platform/acenv.h> 52193341Sjkim#include <contrib/dev/acpica/include/actypes.h> 5367754Smsmith 5467754Smsmith 55167802Sjkim/* Types for AcpiOsExecute */ 5667754Smsmith 57167802Sjkimtypedef enum 58167802Sjkim{ 59167802Sjkim OSL_GLOBAL_LOCK_HANDLER, 60167802Sjkim OSL_NOTIFY_HANDLER, 61167802Sjkim OSL_GPE_HANDLER, 62167802Sjkim OSL_DEBUGGER_THREAD, 63167802Sjkim OSL_EC_POLL_HANDLER, 64167802Sjkim OSL_EC_BURST_HANDLER 6567754Smsmith 66167802Sjkim} ACPI_EXECUTE_TYPE; 67167802Sjkim 6877424Smsmith#define ACPI_NO_UNIT_LIMIT ((UINT32) -1) 6977424Smsmith#define ACPI_MUTEX_SEM 1 7067754Smsmith 7167754Smsmith 7280062Smsmith/* Functions for AcpiOsSignal */ 7380062Smsmith 7480062Smsmith#define ACPI_SIGNAL_FATAL 0 7580062Smsmith#define ACPI_SIGNAL_BREAKPOINT 1 7680062Smsmith 77114237Snjltypedef struct acpi_signal_fatal_info 7880062Smsmith{ 7980062Smsmith UINT32 Type; 8080062Smsmith UINT32 Code; 8180062Smsmith UINT32 Argument; 8280062Smsmith 8380062Smsmith} ACPI_SIGNAL_FATAL_INFO; 8480062Smsmith 8580062Smsmith 8667754Smsmith/* 8777424Smsmith * OSL Initialization and shutdown primitives 8867754Smsmith */ 8967754SmsmithACPI_STATUS 9067754SmsmithAcpiOsInitialize ( 9167754Smsmith void); 9267754Smsmith 9367754SmsmithACPI_STATUS 9467754SmsmithAcpiOsTerminate ( 9567754Smsmith void); 9667754Smsmith 9799146Siwasaki 9899146Siwasaki/* 9999146Siwasaki * ACPI Table interfaces 10099146Siwasaki */ 101167802SjkimACPI_PHYSICAL_ADDRESS 10280062SmsmithAcpiOsGetRootPointer ( 103167802Sjkim void); 10477424Smsmith 10599146SiwasakiACPI_STATUS 106114237SnjlAcpiOsPredefinedOverride ( 107114237Snjl const ACPI_PREDEFINED_NAMES *InitVal, 108114237Snjl ACPI_STRING *NewVal); 109114237Snjl 110114237SnjlACPI_STATUS 11199146SiwasakiAcpiOsTableOverride ( 11299146Siwasaki ACPI_TABLE_HEADER *ExistingTable, 11399146Siwasaki ACPI_TABLE_HEADER **NewTable); 11480062Smsmith 11599146Siwasaki 11667754Smsmith/* 117167802Sjkim * Spinlock primitives 11867754Smsmith */ 11967754SmsmithACPI_STATUS 120167802SjkimAcpiOsCreateLock ( 121167802Sjkim ACPI_SPINLOCK *OutHandle); 122167802Sjkim 123167802Sjkimvoid 124167802SjkimAcpiOsDeleteLock ( 125167802Sjkim ACPI_SPINLOCK Handle); 126167802Sjkim 127167802SjkimACPI_CPU_FLAGS 128167802SjkimAcpiOsAcquireLock ( 129167802Sjkim ACPI_SPINLOCK Handle); 130167802Sjkim 131167802Sjkimvoid 132167802SjkimAcpiOsReleaseLock ( 133167802Sjkim ACPI_SPINLOCK Handle, 134167802Sjkim ACPI_CPU_FLAGS Flags); 135167802Sjkim 136167802Sjkim 137167802Sjkim/* 138167802Sjkim * Semaphore primitives 139167802Sjkim */ 140167802SjkimACPI_STATUS 14167754SmsmithAcpiOsCreateSemaphore ( 14267754Smsmith UINT32 MaxUnits, 14367754Smsmith UINT32 InitialUnits, 144167802Sjkim ACPI_SEMAPHORE *OutHandle); 14567754Smsmith 14667754SmsmithACPI_STATUS 14767754SmsmithAcpiOsDeleteSemaphore ( 148167802Sjkim ACPI_SEMAPHORE Handle); 14967754Smsmith 15067754SmsmithACPI_STATUS 15167754SmsmithAcpiOsWaitSemaphore ( 152167802Sjkim ACPI_SEMAPHORE Handle, 15367754Smsmith UINT32 Units, 154107325Siwasaki UINT16 Timeout); 15567754Smsmith 15667754SmsmithACPI_STATUS 15767754SmsmithAcpiOsSignalSemaphore ( 158167802Sjkim ACPI_SEMAPHORE Handle, 15967754Smsmith UINT32 Units); 16067754Smsmith 161167802Sjkim 162167802Sjkim/* 163193267Sjkim * Mutex primitives. May be configured to use semaphores instead via 164193267Sjkim * ACPI_MUTEX_TYPE (see platform/acenv.h) 165167802Sjkim */ 166193267Sjkim#if (ACPI_MUTEX_TYPE != ACPI_BINARY_SEMAPHORE) 167193267Sjkim 168117521SnjlACPI_STATUS 169167802SjkimAcpiOsCreateMutex ( 170167802Sjkim ACPI_MUTEX *OutHandle); 17177424Smsmith 172117521Snjlvoid 173167802SjkimAcpiOsDeleteMutex ( 174167802Sjkim ACPI_MUTEX Handle); 175117521Snjl 176167802SjkimACPI_STATUS 177167802SjkimAcpiOsAcquireMutex ( 178167802Sjkim ACPI_MUTEX Handle, 179167802Sjkim UINT16 Timeout); 180117521Snjl 181117521Snjlvoid 182167802SjkimAcpiOsReleaseMutex ( 183167802Sjkim ACPI_MUTEX Handle); 184193267Sjkim#endif 185117521Snjl 186117521Snjl 18767754Smsmith/* 18867754Smsmith * Memory allocation and mapping 18967754Smsmith */ 19067754Smsmithvoid * 19167754SmsmithAcpiOsAllocate ( 19291116Smsmith ACPI_SIZE Size); 19367754Smsmith 19467754Smsmithvoid 19567754SmsmithAcpiOsFree ( 19667754Smsmith void * Memory); 19767754Smsmith 198167802Sjkimvoid * 19967754SmsmithAcpiOsMapMemory ( 200167802Sjkim ACPI_PHYSICAL_ADDRESS Where, 201193267Sjkim ACPI_SIZE Length); 20267754Smsmith 20367754Smsmithvoid 20467754SmsmithAcpiOsUnmapMemory ( 20567754Smsmith void *LogicalAddress, 20691116Smsmith ACPI_SIZE Size); 20767754Smsmith 20871867SmsmithACPI_STATUS 20971867SmsmithAcpiOsGetPhysicalAddress ( 21071867Smsmith void *LogicalAddress, 21171867Smsmith ACPI_PHYSICAL_ADDRESS *PhysicalAddress); 21267754Smsmith 21377424Smsmith 21467754Smsmith/* 215151937Sjkim * Memory/Object Cache 21667754Smsmith */ 217151937SjkimACPI_STATUS 218151937SjkimAcpiOsCreateCache ( 219151937Sjkim char *CacheName, 220151937Sjkim UINT16 ObjectSize, 221151937Sjkim UINT16 MaxDepth, 222151937Sjkim ACPI_CACHE_T **ReturnCache); 22367754Smsmith 22467754SmsmithACPI_STATUS 225151937SjkimAcpiOsDeleteCache ( 226151937Sjkim ACPI_CACHE_T *Cache); 227151937Sjkim 228151937SjkimACPI_STATUS 229151937SjkimAcpiOsPurgeCache ( 230151937Sjkim ACPI_CACHE_T *Cache); 231151937Sjkim 232151937Sjkimvoid * 233151937SjkimAcpiOsAcquireObject ( 234151937Sjkim ACPI_CACHE_T *Cache); 235151937Sjkim 236151937SjkimACPI_STATUS 237151937SjkimAcpiOsReleaseObject ( 238151937Sjkim ACPI_CACHE_T *Cache, 239151937Sjkim void *Object); 240151937Sjkim 241151937Sjkim 242151937Sjkim/* 243151937Sjkim * Interrupt handlers 244151937Sjkim */ 245151937SjkimACPI_STATUS 24667754SmsmithAcpiOsInstallInterruptHandler ( 24767754Smsmith UINT32 InterruptNumber, 248138287Smarks ACPI_OSD_HANDLER ServiceRoutine, 24967754Smsmith void *Context); 25067754Smsmith 25167754SmsmithACPI_STATUS 25267754SmsmithAcpiOsRemoveInterruptHandler ( 25367754Smsmith UINT32 InterruptNumber, 254138287Smarks ACPI_OSD_HANDLER ServiceRoutine); 25567754Smsmith 25667754Smsmith 25767754Smsmith/* 25877424Smsmith * Threads and Scheduling 25967754Smsmith */ 260167802SjkimACPI_THREAD_ID 26177424SmsmithAcpiOsGetThreadId ( 26277424Smsmith void); 26377424Smsmith 26467754SmsmithACPI_STATUS 265167802SjkimAcpiOsExecute ( 266167802Sjkim ACPI_EXECUTE_TYPE Type, 267138287Smarks ACPI_OSD_EXEC_CALLBACK Function, 26867754Smsmith void *Context); 26967754Smsmith 27067754Smsmithvoid 271138287SmarksAcpiOsWaitEventsComplete ( 272138287Smarks void *Context); 273138287Smarks 274138287Smarksvoid 27567754SmsmithAcpiOsSleep ( 276202771Sjkim UINT64 Milliseconds); 27767754Smsmith 27867754Smsmithvoid 27980062SmsmithAcpiOsStall ( 28067754Smsmith UINT32 Microseconds); 28167754Smsmith 28277424Smsmith 28367754Smsmith/* 28480062Smsmith * Platform and hardware-independent I/O interfaces 28567754Smsmith */ 28680062SmsmithACPI_STATUS 28780062SmsmithAcpiOsReadPort ( 28880062Smsmith ACPI_IO_ADDRESS Address, 289117521Snjl UINT32 *Value, 29080062Smsmith UINT32 Width); 29167754Smsmith 29280062SmsmithACPI_STATUS 29380062SmsmithAcpiOsWritePort ( 29480062Smsmith ACPI_IO_ADDRESS Address, 295117521Snjl UINT32 Value, 29680062Smsmith UINT32 Width); 29767754Smsmith 29867754Smsmith 29967754Smsmith/* 30080062Smsmith * Platform and hardware-independent physical memory interfaces 30167754Smsmith */ 30280062SmsmithACPI_STATUS 30380062SmsmithAcpiOsReadMemory ( 30480062Smsmith ACPI_PHYSICAL_ADDRESS Address, 305117521Snjl UINT32 *Value, 30680062Smsmith UINT32 Width); 30767754Smsmith 30880062SmsmithACPI_STATUS 30980062SmsmithAcpiOsWriteMemory ( 31080062Smsmith ACPI_PHYSICAL_ADDRESS Address, 311117521Snjl UINT32 Value, 31280062Smsmith UINT32 Width); 31367754Smsmith 31467754Smsmith 31567754Smsmith/* 31680062Smsmith * Platform and hardware-independent PCI configuration space access 317138287Smarks * Note: Can't use "Register" as a parameter, changed to "Reg" -- 318138287Smarks * certain compilers complain. 31967754Smsmith */ 32067754SmsmithACPI_STATUS 32180062SmsmithAcpiOsReadPciConfiguration ( 32280062Smsmith ACPI_PCI_ID *PciId, 323138287Smarks UINT32 Reg, 324210976Sjkim UINT64 *Value, 32580062Smsmith UINT32 Width); 32667754Smsmith 32767754SmsmithACPI_STATUS 32880062SmsmithAcpiOsWritePciConfiguration ( 32980062Smsmith ACPI_PCI_ID *PciId, 330138287Smarks UINT32 Reg, 331202771Sjkim UINT64 Value, 33280062Smsmith UINT32 Width); 33367754Smsmith 334167802Sjkim 335114237Snjl/* 33667754Smsmith * Miscellaneous 33767754Smsmith */ 33867754SmsmithBOOLEAN 33967754SmsmithAcpiOsReadable ( 34067754Smsmith void *Pointer, 341117521Snjl ACPI_SIZE Length); 34267754Smsmith 34367754SmsmithBOOLEAN 34467754SmsmithAcpiOsWritable ( 34567754Smsmith void *Pointer, 346117521Snjl ACPI_SIZE Length); 34767754Smsmith 348138287SmarksUINT64 34978986SmsmithAcpiOsGetTimer ( 35078986Smsmith void); 35167754Smsmith 35280062SmsmithACPI_STATUS 35380062SmsmithAcpiOsSignal ( 35480062Smsmith UINT32 Function, 35580062Smsmith void *Info); 35678986Smsmith 357167802Sjkim 35867754Smsmith/* 35967754Smsmith * Debug print routines 36067754Smsmith */ 36192388Smsmithvoid ACPI_INTERNAL_VAR_XFACE 36267754SmsmithAcpiOsPrintf ( 363114237Snjl const char *Format, 36467754Smsmith ...); 36567754Smsmith 36691116Smsmithvoid 36767754SmsmithAcpiOsVprintf ( 368114237Snjl const char *Format, 36967754Smsmith va_list Args); 37067754Smsmith 371100966Siwasakivoid 372100966SiwasakiAcpiOsRedirectOutput ( 373100966Siwasaki void *Destination); 37477424Smsmith 375100966Siwasaki 37667754Smsmith/* 37767754Smsmith * Debug input 37867754Smsmith */ 37967754SmsmithUINT32 38067754SmsmithAcpiOsGetLine ( 381114237Snjl char *Buffer); 38267754Smsmith 38367754Smsmith 38467754Smsmith/* 385114237Snjl * Directory manipulation 386114237Snjl */ 387114237Snjlvoid * 388114237SnjlAcpiOsOpenDirectory ( 389114237Snjl char *Pathname, 390114237Snjl char *WildcardSpec, 391114237Snjl char RequestedFileType); 392114237Snjl 393114237Snjl/* RequesteFileType values */ 394114237Snjl 395114237Snjl#define REQUEST_FILE_ONLY 0 396114237Snjl#define REQUEST_DIR_ONLY 1 397114237Snjl 398114237Snjl 399114237Snjlchar * 400114237SnjlAcpiOsGetNextFilename ( 401114237Snjl void *DirHandle); 402114237Snjl 403114237Snjlvoid 404114237SnjlAcpiOsCloseDirectory ( 405114237Snjl void *DirHandle); 406114237Snjl 40767754Smsmith 40877424Smsmith#endif /* __ACPIOSXF_H__ */ 409