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 * Copyright (C) 2000 - 2014, Intel Corp. 11 * All rights reserved. 12 * 13 * Redistribution and use in source and binary forms, with or without 14 * modification, are permitted provided that the following conditions 15 * are met: 16 * 1. Redistributions of source code must retain the above copyright 17 * notice, this list of conditions, and the following disclaimer, 18 * without modification. 19 * 2. Redistributions in binary form must reproduce at minimum a disclaimer 20 * substantially similar to the "NO WARRANTY" disclaimer below 21 * ("Disclaimer") and any redistribution must be conditioned upon 22 * including a substantially similar Disclaimer requirement for further 23 * binary redistribution. 24 * 3. Neither the names of the above-listed copyright holders nor the names 25 * of any contributors may be used to endorse or promote products derived 26 * from this software without specific prior written permission. 27 * 28 * Alternatively, this software may be distributed under the terms of the 29 * GNU General Public License ("GPL") version 2 as published by the Free 30 * Software Foundation. 31 * 32 * NO WARRANTY 33 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 34 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 35 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 36 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 37 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 38 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 39 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 40 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 41 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 42 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 43 * POSSIBILITY OF SUCH DAMAGES. 44 */ 45 46 #ifndef __ACPIOSXF_H__ 47 #define __ACPIOSXF_H__ 48 49 #include "platform/acenv.h" 50 #include "actypes.h" 51 52 53 #pragma pack(push) /* Set default struct packing */ 54 55 /* Types for AcpiOsExecute */ 56 57 typedef enum 58 { 59 OSL_GLOBAL_LOCK_HANDLER, 60 OSL_NOTIFY_HANDLER, 61 OSL_GPE_HANDLER, 62 OSL_DEBUGGER_THREAD, 63 OSL_EC_POLL_HANDLER, 64 OSL_EC_BURST_HANDLER 65 66 } ACPI_EXECUTE_TYPE; 67 68 #define ACPI_NO_UNIT_LIMIT ((UINT32) -1) 69 #define ACPI_MUTEX_SEM 1 70 71 72 /* Functions for AcpiOsSignal */ 73 74 #define ACPI_SIGNAL_FATAL 0 75 #define ACPI_SIGNAL_BREAKPOINT 1 76 77 typedef struct acpi_signal_fatal_info 78 { 79 UINT32 Type; 80 UINT32 Code; 81 UINT32 Argument; 82 83 } ACPI_SIGNAL_FATAL_INFO; 84 85 86 /* 87 * OSL Initialization and shutdown primitives 88 */ 89 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsInitialize 90 ACPI_STATUS 91 AcpiOsInitialize ( 92 void); 93 #endif 94 95 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsTerminate 96 ACPI_STATUS 97 AcpiOsTerminate ( 98 void); 99 #endif 100 101 102 /* 103 * ACPI Table interfaces 104 */ 105 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsGetRootPointer 106 ACPI_PHYSICAL_ADDRESS 107 AcpiOsGetRootPointer ( 108 void); 109 #endif 110 111 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsPredefinedOverride 112 ACPI_STATUS 113 AcpiOsPredefinedOverride ( 114 const ACPI_PREDEFINED_NAMES *InitVal, 115 ACPI_STRING *NewVal); 116 #endif 117 118 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsTableOverride 119 ACPI_STATUS 120 AcpiOsTableOverride ( 121 ACPI_TABLE_HEADER *ExistingTable, 122 ACPI_TABLE_HEADER **NewTable); 123 #endif 124 125 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsPhysicalTableOverride 126 ACPI_STATUS 127 AcpiOsPhysicalTableOverride ( 128 ACPI_TABLE_HEADER *ExistingTable, 129 ACPI_PHYSICAL_ADDRESS *NewAddress, 130 UINT32 *NewTableLength); 131 #endif 132 133 134 /* 135 * Spinlock primitives 136 */ 137 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsCreateLock 138 ACPI_STATUS 139 AcpiOsCreateLock ( 140 ACPI_SPINLOCK *OutHandle); 141 #endif 142 143 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsDeleteLock 144 void 145 AcpiOsDeleteLock ( 146 ACPI_SPINLOCK Handle); 147 #endif 148 149 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsAcquireLock 150 ACPI_CPU_FLAGS 151 AcpiOsAcquireLock ( 152 ACPI_SPINLOCK Handle); 153 #endif 154 155 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsReleaseLock 156 void 157 AcpiOsReleaseLock ( 158 ACPI_SPINLOCK Handle, 159 ACPI_CPU_FLAGS Flags); 160 #endif 161 162 163 /* 164 * Semaphore primitives 165 */ 166 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsCreateSemaphore 167 ACPI_STATUS 168 AcpiOsCreateSemaphore ( 169 UINT32 MaxUnits, 170 UINT32 InitialUnits, 171 ACPI_SEMAPHORE *OutHandle); 172 #endif 173 174 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsDeleteSemaphore 175 ACPI_STATUS 176 AcpiOsDeleteSemaphore ( 177 ACPI_SEMAPHORE Handle); 178 #endif 179 180 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsWaitSemaphore 181 ACPI_STATUS 182 AcpiOsWaitSemaphore ( 183 ACPI_SEMAPHORE Handle, 184 UINT32 Units, 185 UINT16 Timeout); 186 #endif 187 188 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsSignalSemaphore 189 ACPI_STATUS 190 AcpiOsSignalSemaphore ( 191 ACPI_SEMAPHORE Handle, 192 UINT32 Units); 193 #endif 194 195 196 /* 197 * Mutex primitives. May be configured to use semaphores instead via 198 * ACPI_MUTEX_TYPE (see platform/acenv.h) 199 */ 200 #if (ACPI_MUTEX_TYPE != ACPI_BINARY_SEMAPHORE) 201 202 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsCreateMutex 203 ACPI_STATUS 204 AcpiOsCreateMutex ( 205 ACPI_MUTEX *OutHandle); 206 #endif 207 208 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsDeleteMutex 209 void 210 AcpiOsDeleteMutex ( 211 ACPI_MUTEX Handle); 212 #endif 213 214 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsAcquireMutex 215 ACPI_STATUS 216 AcpiOsAcquireMutex ( 217 ACPI_MUTEX Handle, 218 UINT16 Timeout); 219 #endif 220 221 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsReleaseMutex 222 void 223 AcpiOsReleaseMutex ( 224 ACPI_MUTEX Handle); 225 #endif 226 227 #endif 228 229 230 /* 231 * Memory allocation and mapping 232 */ 233 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsAllocate 234 void * 235 AcpiOsAllocate ( 236 ACPI_SIZE Size); 237 #endif 238 239 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsAllocateZeroed 240 void * 241 AcpiOsAllocateZeroed ( 242 ACPI_SIZE Size); 243 #endif 244 245 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsFree 246 void 247 AcpiOsFree ( 248 void * Memory); 249 #endif 250 251 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsMapMemory 252 void * 253 AcpiOsMapMemory ( 254 ACPI_PHYSICAL_ADDRESS Where, 255 ACPI_SIZE Length); 256 #endif 257 258 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsUnmapMemory 259 void 260 AcpiOsUnmapMemory ( 261 void *LogicalAddress, 262 ACPI_SIZE Size); 263 #endif 264 265 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsGetPhysicalAddress 266 ACPI_STATUS 267 AcpiOsGetPhysicalAddress ( 268 void *LogicalAddress, 269 ACPI_PHYSICAL_ADDRESS *PhysicalAddress); 270 #endif 271 272 273 /* 274 * Memory/Object Cache 275 */ 276 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsCreateCache 277 ACPI_STATUS 278 AcpiOsCreateCache ( 279 char *CacheName, 280 UINT16 ObjectSize, 281 UINT16 MaxDepth, 282 ACPI_CACHE_T **ReturnCache); 283 #endif 284 285 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsDeleteCache 286 ACPI_STATUS 287 AcpiOsDeleteCache ( 288 ACPI_CACHE_T *Cache); 289 #endif 290 291 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsPurgeCache 292 ACPI_STATUS 293 AcpiOsPurgeCache ( 294 ACPI_CACHE_T *Cache); 295 #endif 296 297 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsAcquireObject 298 void * 299 AcpiOsAcquireObject ( 300 ACPI_CACHE_T *Cache); 301 #endif 302 303 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsReleaseObject 304 ACPI_STATUS 305 AcpiOsReleaseObject ( 306 ACPI_CACHE_T *Cache, 307 void *Object); 308 #endif 309 310 311 /* 312 * Interrupt handlers 313 */ 314 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsInstallInterruptHandler 315 ACPI_STATUS 316 AcpiOsInstallInterruptHandler ( 317 UINT32 InterruptNumber, 318 ACPI_OSD_HANDLER ServiceRoutine, 319 void *Context); 320 #endif 321 322 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsRemoveInterruptHandler 323 ACPI_STATUS 324 AcpiOsRemoveInterruptHandler ( 325 UINT32 InterruptNumber, 326 ACPI_OSD_HANDLER ServiceRoutine); 327 #endif 328 329 330 /* 331 * Threads and Scheduling 332 */ 333 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsGetThreadId 334 ACPI_THREAD_ID 335 AcpiOsGetThreadId ( 336 void); 337 #endif 338 339 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsExecute 340 ACPI_STATUS 341 AcpiOsExecute ( 342 ACPI_EXECUTE_TYPE Type, 343 ACPI_OSD_EXEC_CALLBACK Function, 344 void *Context); 345 #endif 346 347 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsWaitEventsComplete 348 void 349 AcpiOsWaitEventsComplete ( 350 void); 351 #endif 352 353 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsSleep 354 void 355 AcpiOsSleep ( 356 UINT64 Milliseconds); 357 #endif 358 359 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsStall 360 void 361 AcpiOsStall ( 362 UINT32 Microseconds); 363 #endif 364 365 366 /* 367 * Platform and hardware-independent I/O interfaces 368 */ 369 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsReadPort 370 ACPI_STATUS 371 AcpiOsReadPort ( 372 ACPI_IO_ADDRESS Address, 373 UINT32 *Value, 374 UINT32 Width); 375 #endif 376 377 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsWritePort 378 ACPI_STATUS 379 AcpiOsWritePort ( 380 ACPI_IO_ADDRESS Address, 381 UINT32 Value, 382 UINT32 Width); 383 #endif 384 385 386 /* 387 * Platform and hardware-independent physical memory interfaces 388 */ 389 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsReadMemory 390 ACPI_STATUS 391 AcpiOsReadMemory ( 392 ACPI_PHYSICAL_ADDRESS Address, 393 UINT64 *Value, 394 UINT32 Width); 395 #endif 396 397 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsWriteMemory 398 ACPI_STATUS 399 AcpiOsWriteMemory ( 400 ACPI_PHYSICAL_ADDRESS Address, 401 UINT64 Value, 402 UINT32 Width); 403 #endif 404 405 406 /* 407 * Platform and hardware-independent PCI configuration space access 408 * Note: Can't use "Register" as a parameter, changed to "Reg" -- 409 * certain compilers complain. 410 */ 411 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsReadPciConfiguration 412 ACPI_STATUS 413 AcpiOsReadPciConfiguration ( 414 ACPI_PCI_ID *PciId, 415 UINT32 Reg, 416 UINT64 *Value, 417 UINT32 Width); 418 #endif 419 420 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsWritePciConfiguration 421 ACPI_STATUS 422 AcpiOsWritePciConfiguration ( 423 ACPI_PCI_ID *PciId, 424 UINT32 Reg, 425 UINT64 Value, 426 UINT32 Width); 427 #endif 428 429 430 /* 431 * Miscellaneous 432 */ 433 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsReadable 434 BOOLEAN 435 AcpiOsReadable ( 436 void *Pointer, 437 ACPI_SIZE Length); 438 #endif 439 440 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsWritable 441 BOOLEAN 442 AcpiOsWritable ( 443 void *Pointer, 444 ACPI_SIZE Length); 445 #endif 446 447 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsGetTimer 448 UINT64 449 AcpiOsGetTimer ( 450 void); 451 #endif 452 453 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsSignal 454 ACPI_STATUS 455 AcpiOsSignal ( 456 UINT32 Function, 457 void *Info); 458 #endif 459 460 461 /* 462 * Debug print routines 463 */ 464 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsPrintf 465 void ACPI_INTERNAL_VAR_XFACE 466 AcpiOsPrintf ( 467 const char *Format, 468 ...); 469 #endif 470 471 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsVprintf 472 void 473 AcpiOsVprintf ( 474 const char *Format, 475 va_list Args); 476 #endif 477 478 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsRedirectOutput 479 void 480 AcpiOsRedirectOutput ( 481 void *Destination); 482 #endif 483 484 485 /* 486 * Debug input 487 */ 488 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsGetLine 489 ACPI_STATUS 490 AcpiOsGetLine ( 491 char *Buffer, 492 UINT32 BufferLength, 493 UINT32 *BytesRead); 494 #endif 495 496 497 /* 498 * Obtain ACPI table(s) 499 */ 500 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsGetTableByName 501 ACPI_STATUS 502 AcpiOsGetTableByName ( 503 char *Signature, 504 UINT32 Instance, 505 ACPI_TABLE_HEADER **Table, 506 ACPI_PHYSICAL_ADDRESS *Address); 507 #endif 508 509 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsGetTableByIndex 510 ACPI_STATUS 511 AcpiOsGetTableByIndex ( 512 UINT32 Index, 513 ACPI_TABLE_HEADER **Table, 514 UINT32 *Instance, 515 ACPI_PHYSICAL_ADDRESS *Address); 516 #endif 517 518 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsGetTableByAddress 519 ACPI_STATUS 520 AcpiOsGetTableByAddress ( 521 ACPI_PHYSICAL_ADDRESS Address, 522 ACPI_TABLE_HEADER **Table); 523 #endif 524 525 526 /* 527 * Directory manipulation 528 */ 529 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsOpenDirectory 530 void * 531 AcpiOsOpenDirectory ( 532 char *Pathname, 533 char *WildcardSpec, 534 char RequestedFileType); 535 #endif 536 537 /* RequesteFileType values */ 538 539 #define REQUEST_FILE_ONLY 0 540 #define REQUEST_DIR_ONLY 1 541 542 543 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsGetNextFilename 544 char * 545 AcpiOsGetNextFilename ( 546 void *DirHandle); 547 #endif 548 549 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsCloseDirectory 550 void 551 AcpiOsCloseDirectory ( 552 void *DirHandle); 553 #endif 554 555 556 #pragma pack(pop) /* Restore original struct packing */ 557 558 #endif /* __ACPIOSXF_H__ */ 559