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 /* Types for AcpiOsExecute */ 54 55 typedef enum 56 { 57 OSL_GLOBAL_LOCK_HANDLER, 58 OSL_NOTIFY_HANDLER, 59 OSL_GPE_HANDLER, 60 OSL_DEBUGGER_THREAD, 61 OSL_EC_POLL_HANDLER, 62 OSL_EC_BURST_HANDLER 63 64 } ACPI_EXECUTE_TYPE; 65 66 #define ACPI_NO_UNIT_LIMIT ((UINT32) -1) 67 #define ACPI_MUTEX_SEM 1 68 69 70 /* Functions for AcpiOsSignal */ 71 72 #define ACPI_SIGNAL_FATAL 0 73 #define ACPI_SIGNAL_BREAKPOINT 1 74 75 typedef struct acpi_signal_fatal_info 76 { 77 UINT32 Type; 78 UINT32 Code; 79 UINT32 Argument; 80 81 } ACPI_SIGNAL_FATAL_INFO; 82 83 84 /* 85 * OSL Initialization and shutdown primitives 86 */ 87 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsInitialize 88 ACPI_STATUS 89 AcpiOsInitialize ( 90 void); 91 #endif 92 93 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsTerminate 94 ACPI_STATUS 95 AcpiOsTerminate ( 96 void); 97 #endif 98 99 100 /* 101 * ACPI Table interfaces 102 */ 103 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsGetRootPointer 104 ACPI_PHYSICAL_ADDRESS 105 AcpiOsGetRootPointer ( 106 void); 107 #endif 108 109 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsPredefinedOverride 110 ACPI_STATUS 111 AcpiOsPredefinedOverride ( 112 const ACPI_PREDEFINED_NAMES *InitVal, 113 ACPI_STRING *NewVal); 114 #endif 115 116 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsTableOverride 117 ACPI_STATUS 118 AcpiOsTableOverride ( 119 ACPI_TABLE_HEADER *ExistingTable, 120 ACPI_TABLE_HEADER **NewTable); 121 #endif 122 123 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsPhysicalTableOverride 124 ACPI_STATUS 125 AcpiOsPhysicalTableOverride ( 126 ACPI_TABLE_HEADER *ExistingTable, 127 ACPI_PHYSICAL_ADDRESS *NewAddress, 128 UINT32 *NewTableLength); 129 #endif 130 131 132 /* 133 * Spinlock primitives 134 */ 135 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsCreateLock 136 ACPI_STATUS 137 AcpiOsCreateLock ( 138 ACPI_SPINLOCK *OutHandle); 139 #endif 140 141 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsDeleteLock 142 void 143 AcpiOsDeleteLock ( 144 ACPI_SPINLOCK Handle); 145 #endif 146 147 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsAcquireLock 148 ACPI_CPU_FLAGS 149 AcpiOsAcquireLock ( 150 ACPI_SPINLOCK Handle); 151 #endif 152 153 #ifdef ACPI_DEBUG_LOCKS 154 ACPI_CPU_FLAGS 155 _AcpiOsAcquireLock ( 156 ACPI_SPINLOCK Handle, 157 const char *func, 158 int line); 159 #endif 160 161 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsReleaseLock 162 void 163 AcpiOsReleaseLock ( 164 ACPI_SPINLOCK Handle, 165 ACPI_CPU_FLAGS Flags); 166 #endif 167 168 169 /* 170 * Semaphore primitives 171 */ 172 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsCreateSemaphore 173 ACPI_STATUS 174 AcpiOsCreateSemaphore ( 175 UINT32 MaxUnits, 176 UINT32 InitialUnits, 177 ACPI_SEMAPHORE *OutHandle); 178 #endif 179 180 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsDeleteSemaphore 181 ACPI_STATUS 182 AcpiOsDeleteSemaphore ( 183 ACPI_SEMAPHORE Handle); 184 #endif 185 186 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsWaitSemaphore 187 ACPI_STATUS 188 AcpiOsWaitSemaphore ( 189 ACPI_SEMAPHORE Handle, 190 UINT32 Units, 191 UINT16 Timeout); 192 #endif 193 194 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsSignalSemaphore 195 ACPI_STATUS 196 AcpiOsSignalSemaphore ( 197 ACPI_SEMAPHORE Handle, 198 UINT32 Units); 199 #endif 200 201 202 /* 203 * Mutex primitives. May be configured to use semaphores instead via 204 * ACPI_MUTEX_TYPE (see platform/acenv.h) 205 */ 206 #if (ACPI_MUTEX_TYPE != ACPI_BINARY_SEMAPHORE) 207 208 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsCreateMutex 209 ACPI_STATUS 210 AcpiOsCreateMutex ( 211 ACPI_MUTEX *OutHandle); 212 #endif 213 214 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsDeleteMutex 215 void 216 AcpiOsDeleteMutex ( 217 ACPI_MUTEX Handle); 218 #endif 219 220 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsAcquireMutex 221 ACPI_STATUS 222 AcpiOsAcquireMutex ( 223 ACPI_MUTEX Handle, 224 UINT16 Timeout); 225 #endif 226 227 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsReleaseMutex 228 void 229 AcpiOsReleaseMutex ( 230 ACPI_MUTEX Handle); 231 #endif 232 233 #endif 234 235 236 /* 237 * Memory allocation and mapping 238 */ 239 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsAllocate 240 void * 241 AcpiOsAllocate ( 242 ACPI_SIZE Size); 243 #endif 244 245 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsAllocateZeroed 246 void * 247 AcpiOsAllocateZeroed ( 248 ACPI_SIZE Size); 249 #endif 250 251 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsFree 252 void 253 AcpiOsFree ( 254 void * Memory); 255 #endif 256 257 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsMapMemory 258 void * 259 AcpiOsMapMemory ( 260 ACPI_PHYSICAL_ADDRESS Where, 261 ACPI_SIZE Length); 262 #endif 263 264 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsUnmapMemory 265 void 266 AcpiOsUnmapMemory ( 267 void *LogicalAddress, 268 ACPI_SIZE Size); 269 #endif 270 271 #ifdef ACPI_DEBUG_MEMMAP 272 void * 273 _AcpiOsMapMemory ( 274 ACPI_PHYSICAL_ADDRESS Where, 275 ACPI_SIZE Length, 276 const char *caller, 277 int line); 278 void 279 _AcpiOsUnmapMemory ( 280 void *LogicalAddress, 281 ACPI_SIZE Length, 282 const char *caller, 283 int line); 284 #endif 285 286 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsGetPhysicalAddress 287 ACPI_STATUS 288 AcpiOsGetPhysicalAddress ( 289 void *LogicalAddress, 290 ACPI_PHYSICAL_ADDRESS *PhysicalAddress); 291 #endif 292 293 294 /* 295 * Memory/Object Cache 296 */ 297 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsCreateCache 298 ACPI_STATUS 299 AcpiOsCreateCache ( 300 char *CacheName, 301 UINT16 ObjectSize, 302 UINT16 MaxDepth, 303 ACPI_CACHE_T **ReturnCache); 304 #endif 305 306 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsDeleteCache 307 ACPI_STATUS 308 AcpiOsDeleteCache ( 309 ACPI_CACHE_T *Cache); 310 #endif 311 312 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsPurgeCache 313 ACPI_STATUS 314 AcpiOsPurgeCache ( 315 ACPI_CACHE_T *Cache); 316 #endif 317 318 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsAcquireObject 319 void * 320 AcpiOsAcquireObject ( 321 ACPI_CACHE_T *Cache); 322 #endif 323 324 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsReleaseObject 325 ACPI_STATUS 326 AcpiOsReleaseObject ( 327 ACPI_CACHE_T *Cache, 328 void *Object); 329 #endif 330 331 #ifdef ACPI_DEBUG_CACHE 332 ACPI_STATUS 333 _AcpiOsReleaseObject ( 334 ACPI_CACHE_T *Cache, 335 void *Object, 336 const char *func, 337 int line); 338 #endif 339 340 /* 341 * Interrupt handlers 342 */ 343 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsInstallInterruptHandler 344 ACPI_STATUS 345 AcpiOsInstallInterruptHandler ( 346 UINT32 InterruptNumber, 347 ACPI_OSD_HANDLER ServiceRoutine, 348 void *Context); 349 #endif 350 351 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsRemoveInterruptHandler 352 ACPI_STATUS 353 AcpiOsRemoveInterruptHandler ( 354 UINT32 InterruptNumber, 355 ACPI_OSD_HANDLER ServiceRoutine); 356 #endif 357 358 359 /* 360 * Threads and Scheduling 361 */ 362 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsGetThreadId 363 ACPI_THREAD_ID 364 AcpiOsGetThreadId ( 365 void); 366 #endif 367 368 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsExecute 369 ACPI_STATUS 370 AcpiOsExecute ( 371 ACPI_EXECUTE_TYPE Type, 372 ACPI_OSD_EXEC_CALLBACK Function, 373 void *Context); 374 #endif 375 376 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsWaitEventsComplete 377 void 378 AcpiOsWaitEventsComplete ( 379 void); 380 #endif 381 382 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsSleep 383 void 384 AcpiOsSleep ( 385 UINT64 Milliseconds); 386 #endif 387 388 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsStall 389 void 390 AcpiOsStall ( 391 UINT32 Microseconds); 392 #endif 393 394 395 /* 396 * Platform and hardware-independent I/O interfaces 397 */ 398 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsReadPort 399 ACPI_STATUS 400 AcpiOsReadPort ( 401 ACPI_IO_ADDRESS Address, 402 UINT32 *Value, 403 UINT32 Width); 404 #endif 405 406 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsWritePort 407 ACPI_STATUS 408 AcpiOsWritePort ( 409 ACPI_IO_ADDRESS Address, 410 UINT32 Value, 411 UINT32 Width); 412 #endif 413 414 415 /* 416 * Platform and hardware-independent physical memory interfaces 417 */ 418 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsReadMemory 419 ACPI_STATUS 420 AcpiOsReadMemory ( 421 ACPI_PHYSICAL_ADDRESS Address, 422 UINT64 *Value, 423 UINT32 Width); 424 #endif 425 426 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsWriteMemory 427 ACPI_STATUS 428 AcpiOsWriteMemory ( 429 ACPI_PHYSICAL_ADDRESS Address, 430 UINT64 Value, 431 UINT32 Width); 432 #endif 433 434 435 /* 436 * Platform and hardware-independent PCI configuration space access 437 * Note: Can't use "Register" as a parameter, changed to "Reg" -- 438 * certain compilers complain. 439 */ 440 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsReadPciConfiguration 441 ACPI_STATUS 442 AcpiOsReadPciConfiguration ( 443 ACPI_PCI_ID *PciId, 444 UINT32 Reg, 445 UINT64 *Value, 446 UINT32 Width); 447 #endif 448 449 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsWritePciConfiguration 450 ACPI_STATUS 451 AcpiOsWritePciConfiguration ( 452 ACPI_PCI_ID *PciId, 453 UINT32 Reg, 454 UINT64 Value, 455 UINT32 Width); 456 #endif 457 458 459 /* 460 * Miscellaneous 461 */ 462 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsReadable 463 BOOLEAN 464 AcpiOsReadable ( 465 void *Pointer, 466 ACPI_SIZE Length); 467 #endif 468 469 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsWritable 470 BOOLEAN 471 AcpiOsWritable ( 472 void *Pointer, 473 ACPI_SIZE Length); 474 #endif 475 476 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsGetTimer 477 UINT64 478 AcpiOsGetTimer ( 479 void); 480 #endif 481 482 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsSignal 483 ACPI_STATUS 484 AcpiOsSignal ( 485 UINT32 Function, 486 void *Info); 487 #endif 488 489 490 /* 491 * Debug print routines 492 */ 493 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsPrintf 494 void ACPI_INTERNAL_VAR_XFACE 495 AcpiOsPrintf ( 496 const char *Format, 497 ...); 498 #endif 499 500 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsVprintf 501 void 502 AcpiOsVprintf ( 503 const char *Format, 504 va_list Args); 505 #endif 506 507 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsRedirectOutput 508 void 509 AcpiOsRedirectOutput ( 510 void *Destination); 511 #endif 512 513 514 /* 515 * Debug input 516 */ 517 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsGetLine 518 ACPI_STATUS 519 AcpiOsGetLine ( 520 char *Buffer, 521 UINT32 BufferLength, 522 UINT32 *BytesRead); 523 #endif 524 525 526 /* 527 * Obtain ACPI table(s) 528 */ 529 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsGetTableByName 530 ACPI_STATUS 531 AcpiOsGetTableByName ( 532 char *Signature, 533 UINT32 Instance, 534 ACPI_TABLE_HEADER **Table, 535 ACPI_PHYSICAL_ADDRESS *Address); 536 #endif 537 538 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsGetTableByIndex 539 ACPI_STATUS 540 AcpiOsGetTableByIndex ( 541 UINT32 Index, 542 ACPI_TABLE_HEADER **Table, 543 UINT32 *Instance, 544 ACPI_PHYSICAL_ADDRESS *Address); 545 #endif 546 547 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsGetTableByAddress 548 ACPI_STATUS 549 AcpiOsGetTableByAddress ( 550 ACPI_PHYSICAL_ADDRESS Address, 551 ACPI_TABLE_HEADER **Table); 552 #endif 553 554 555 /* 556 * Directory manipulation 557 */ 558 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsOpenDirectory 559 void * 560 AcpiOsOpenDirectory ( 561 char *Pathname, 562 char *WildcardSpec, 563 char RequestedFileType); 564 #endif 565 566 /* RequesteFileType values */ 567 568 #define REQUEST_FILE_ONLY 0 569 #define REQUEST_DIR_ONLY 1 570 571 572 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsGetNextFilename 573 char * 574 AcpiOsGetNextFilename ( 575 void *DirHandle); 576 #endif 577 578 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsCloseDirectory 579 void 580 AcpiOsCloseDirectory ( 581 void *DirHandle); 582 #endif 583 584 585 #endif /* __ACPIOSXF_H__ */ 586