acpiosxf.h revision 245582
1/****************************************************************************** 2 * 3 * Name: acpiosxf.h - All interfaces to the OS Services Layer (OSL). These 4 * interfaces must be implemented by OSL to interface the 5 * ACPI components to the host operating system. 6 * 7 *****************************************************************************/ 8 9 10/* 11 * Copyright (C) 2000 - 2013, Intel Corp. 12 * All rights reserved. 13 * 14 * Redistribution and use in source and binary forms, with or without 15 * modification, are permitted provided that the following conditions 16 * are met: 17 * 1. Redistributions of source code must retain the above copyright 18 * notice, this list of conditions, and the following disclaimer, 19 * without modification. 20 * 2. Redistributions in binary form must reproduce at minimum a disclaimer 21 * substantially similar to the "NO WARRANTY" disclaimer below 22 * ("Disclaimer") and any redistribution must be conditioned upon 23 * including a substantially similar Disclaimer requirement for further 24 * binary redistribution. 25 * 3. Neither the names of the above-listed copyright holders nor the names 26 * of any contributors may be used to endorse or promote products derived 27 * from this software without specific prior written permission. 28 * 29 * Alternatively, this software may be distributed under the terms of the 30 * GNU General Public License ("GPL") version 2 as published by the Free 31 * Software Foundation. 32 * 33 * NO WARRANTY 34 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 35 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 36 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 37 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 38 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 39 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 40 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 41 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 42 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 43 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 44 * POSSIBILITY OF SUCH DAMAGES. 45 */ 46 47#ifndef __ACPIOSXF_H__ 48#define __ACPIOSXF_H__ 49 50#include <contrib/dev/acpica/include/platform/acenv.h> 51#include <contrib/dev/acpica/include/actypes.h> 52 53 54/* Types for AcpiOsExecute */ 55 56typedef enum 57{ 58 OSL_GLOBAL_LOCK_HANDLER, 59 OSL_NOTIFY_HANDLER, 60 OSL_GPE_HANDLER, 61 OSL_DEBUGGER_THREAD, 62 OSL_EC_POLL_HANDLER, 63 OSL_EC_BURST_HANDLER 64 65} ACPI_EXECUTE_TYPE; 66 67#define ACPI_NO_UNIT_LIMIT ((UINT32) -1) 68#define ACPI_MUTEX_SEM 1 69 70 71/* Functions for AcpiOsSignal */ 72 73#define ACPI_SIGNAL_FATAL 0 74#define ACPI_SIGNAL_BREAKPOINT 1 75 76typedef struct acpi_signal_fatal_info 77{ 78 UINT32 Type; 79 UINT32 Code; 80 UINT32 Argument; 81 82} ACPI_SIGNAL_FATAL_INFO; 83 84 85/* 86 * OSL Initialization and shutdown primitives 87 */ 88ACPI_STATUS 89AcpiOsInitialize ( 90 void); 91 92ACPI_STATUS 93AcpiOsTerminate ( 94 void); 95 96 97/* 98 * ACPI Table interfaces 99 */ 100ACPI_PHYSICAL_ADDRESS 101AcpiOsGetRootPointer ( 102 void); 103 104ACPI_STATUS 105AcpiOsPredefinedOverride ( 106 const ACPI_PREDEFINED_NAMES *InitVal, 107 ACPI_STRING *NewVal); 108 109ACPI_STATUS 110AcpiOsTableOverride ( 111 ACPI_TABLE_HEADER *ExistingTable, 112 ACPI_TABLE_HEADER **NewTable); 113 114ACPI_STATUS 115AcpiOsPhysicalTableOverride ( 116 ACPI_TABLE_HEADER *ExistingTable, 117 ACPI_PHYSICAL_ADDRESS *NewAddress, 118 UINT32 *NewTableLength); 119 120 121/* 122 * Spinlock primitives 123 */ 124#ifndef AcpiOsCreateLock 125ACPI_STATUS 126AcpiOsCreateLock ( 127 ACPI_SPINLOCK *OutHandle); 128#endif 129 130void 131AcpiOsDeleteLock ( 132 ACPI_SPINLOCK Handle); 133 134ACPI_CPU_FLAGS 135AcpiOsAcquireLock ( 136 ACPI_SPINLOCK Handle); 137 138void 139AcpiOsReleaseLock ( 140 ACPI_SPINLOCK Handle, 141 ACPI_CPU_FLAGS Flags); 142 143 144/* 145 * Semaphore primitives 146 */ 147ACPI_STATUS 148AcpiOsCreateSemaphore ( 149 UINT32 MaxUnits, 150 UINT32 InitialUnits, 151 ACPI_SEMAPHORE *OutHandle); 152 153ACPI_STATUS 154AcpiOsDeleteSemaphore ( 155 ACPI_SEMAPHORE Handle); 156 157ACPI_STATUS 158AcpiOsWaitSemaphore ( 159 ACPI_SEMAPHORE Handle, 160 UINT32 Units, 161 UINT16 Timeout); 162 163ACPI_STATUS 164AcpiOsSignalSemaphore ( 165 ACPI_SEMAPHORE Handle, 166 UINT32 Units); 167 168 169/* 170 * Mutex primitives. May be configured to use semaphores instead via 171 * ACPI_MUTEX_TYPE (see platform/acenv.h) 172 */ 173#if (ACPI_MUTEX_TYPE != ACPI_BINARY_SEMAPHORE) 174 175ACPI_STATUS 176AcpiOsCreateMutex ( 177 ACPI_MUTEX *OutHandle); 178 179void 180AcpiOsDeleteMutex ( 181 ACPI_MUTEX Handle); 182 183ACPI_STATUS 184AcpiOsAcquireMutex ( 185 ACPI_MUTEX Handle, 186 UINT16 Timeout); 187 188void 189AcpiOsReleaseMutex ( 190 ACPI_MUTEX Handle); 191#endif 192 193 194/* 195 * Memory allocation and mapping 196 */ 197void * 198AcpiOsAllocate ( 199 ACPI_SIZE Size); 200 201void 202AcpiOsFree ( 203 void * Memory); 204 205void * 206AcpiOsMapMemory ( 207 ACPI_PHYSICAL_ADDRESS Where, 208 ACPI_SIZE Length); 209 210void 211AcpiOsUnmapMemory ( 212 void *LogicalAddress, 213 ACPI_SIZE Size); 214 215ACPI_STATUS 216AcpiOsGetPhysicalAddress ( 217 void *LogicalAddress, 218 ACPI_PHYSICAL_ADDRESS *PhysicalAddress); 219 220 221/* 222 * Memory/Object Cache 223 */ 224ACPI_STATUS 225AcpiOsCreateCache ( 226 char *CacheName, 227 UINT16 ObjectSize, 228 UINT16 MaxDepth, 229 ACPI_CACHE_T **ReturnCache); 230 231ACPI_STATUS 232AcpiOsDeleteCache ( 233 ACPI_CACHE_T *Cache); 234 235ACPI_STATUS 236AcpiOsPurgeCache ( 237 ACPI_CACHE_T *Cache); 238 239void * 240AcpiOsAcquireObject ( 241 ACPI_CACHE_T *Cache); 242 243ACPI_STATUS 244AcpiOsReleaseObject ( 245 ACPI_CACHE_T *Cache, 246 void *Object); 247 248 249/* 250 * Interrupt handlers 251 */ 252ACPI_STATUS 253AcpiOsInstallInterruptHandler ( 254 UINT32 InterruptNumber, 255 ACPI_OSD_HANDLER ServiceRoutine, 256 void *Context); 257 258ACPI_STATUS 259AcpiOsRemoveInterruptHandler ( 260 UINT32 InterruptNumber, 261 ACPI_OSD_HANDLER ServiceRoutine); 262 263 264/* 265 * Threads and Scheduling 266 */ 267ACPI_THREAD_ID 268AcpiOsGetThreadId ( 269 void); 270 271ACPI_STATUS 272AcpiOsExecute ( 273 ACPI_EXECUTE_TYPE Type, 274 ACPI_OSD_EXEC_CALLBACK Function, 275 void *Context); 276 277void 278AcpiOsWaitEventsComplete ( 279 void); 280 281void 282AcpiOsSleep ( 283 UINT64 Milliseconds); 284 285void 286AcpiOsStall ( 287 UINT32 Microseconds); 288 289 290/* 291 * Platform and hardware-independent I/O interfaces 292 */ 293ACPI_STATUS 294AcpiOsReadPort ( 295 ACPI_IO_ADDRESS Address, 296 UINT32 *Value, 297 UINT32 Width); 298 299ACPI_STATUS 300AcpiOsWritePort ( 301 ACPI_IO_ADDRESS Address, 302 UINT32 Value, 303 UINT32 Width); 304 305 306/* 307 * Platform and hardware-independent physical memory interfaces 308 */ 309ACPI_STATUS 310AcpiOsReadMemory ( 311 ACPI_PHYSICAL_ADDRESS Address, 312 UINT64 *Value, 313 UINT32 Width); 314 315ACPI_STATUS 316AcpiOsWriteMemory ( 317 ACPI_PHYSICAL_ADDRESS Address, 318 UINT64 Value, 319 UINT32 Width); 320 321 322/* 323 * Platform and hardware-independent PCI configuration space access 324 * Note: Can't use "Register" as a parameter, changed to "Reg" -- 325 * certain compilers complain. 326 */ 327ACPI_STATUS 328AcpiOsReadPciConfiguration ( 329 ACPI_PCI_ID *PciId, 330 UINT32 Reg, 331 UINT64 *Value, 332 UINT32 Width); 333 334ACPI_STATUS 335AcpiOsWritePciConfiguration ( 336 ACPI_PCI_ID *PciId, 337 UINT32 Reg, 338 UINT64 Value, 339 UINT32 Width); 340 341 342/* 343 * Miscellaneous 344 */ 345BOOLEAN 346AcpiOsReadable ( 347 void *Pointer, 348 ACPI_SIZE Length); 349 350BOOLEAN 351AcpiOsWritable ( 352 void *Pointer, 353 ACPI_SIZE Length); 354 355UINT64 356AcpiOsGetTimer ( 357 void); 358 359ACPI_STATUS 360AcpiOsSignal ( 361 UINT32 Function, 362 void *Info); 363 364 365/* 366 * Debug print routines 367 */ 368void ACPI_INTERNAL_VAR_XFACE 369AcpiOsPrintf ( 370 const char *Format, 371 ...); 372 373void 374AcpiOsVprintf ( 375 const char *Format, 376 va_list Args); 377 378void 379AcpiOsRedirectOutput ( 380 void *Destination); 381 382 383/* 384 * Debug input 385 */ 386ACPI_STATUS 387AcpiOsGetLine ( 388 char *Buffer, 389 UINT32 BufferLength, 390 UINT32 *BytesRead); 391 392 393/* 394 * Directory manipulation 395 */ 396void * 397AcpiOsOpenDirectory ( 398 char *Pathname, 399 char *WildcardSpec, 400 char RequestedFileType); 401 402/* RequesteFileType values */ 403 404#define REQUEST_FILE_ONLY 0 405#define REQUEST_DIR_ONLY 1 406 407 408char * 409AcpiOsGetNextFilename ( 410 void *DirHandle); 411 412void 413AcpiOsCloseDirectory ( 414 void *DirHandle); 415 416 417#endif /* __ACPIOSXF_H__ */ 418