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 - 2013, 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 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsReleaseLock 154 void 155 AcpiOsReleaseLock ( 156 ACPI_SPINLOCK Handle, 157 ACPI_CPU_FLAGS Flags); 158 #endif 159 160 161 /* 162 * Semaphore primitives 163 */ 164 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsCreateSemaphore 165 ACPI_STATUS 166 AcpiOsCreateSemaphore ( 167 UINT32 MaxUnits, 168 UINT32 InitialUnits, 169 ACPI_SEMAPHORE *OutHandle); 170 #endif 171 172 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsDeleteSemaphore 173 ACPI_STATUS 174 AcpiOsDeleteSemaphore ( 175 ACPI_SEMAPHORE Handle); 176 #endif 177 178 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsWaitSemaphore 179 ACPI_STATUS 180 AcpiOsWaitSemaphore ( 181 ACPI_SEMAPHORE Handle, 182 UINT32 Units, 183 UINT16 Timeout); 184 #endif 185 186 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsSignalSemaphore 187 ACPI_STATUS 188 AcpiOsSignalSemaphore ( 189 ACPI_SEMAPHORE Handle, 190 UINT32 Units); 191 #endif 192 193 194 /* 195 * Mutex primitives. May be configured to use semaphores instead via 196 * ACPI_MUTEX_TYPE (see platform/acenv.h) 197 */ 198 #if (ACPI_MUTEX_TYPE != ACPI_BINARY_SEMAPHORE) 199 200 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsCreateMutex 201 ACPI_STATUS 202 AcpiOsCreateMutex ( 203 ACPI_MUTEX *OutHandle); 204 #endif 205 206 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsDeleteMutex 207 void 208 AcpiOsDeleteMutex ( 209 ACPI_MUTEX Handle); 210 #endif 211 212 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsAcquireMutex 213 ACPI_STATUS 214 AcpiOsAcquireMutex ( 215 ACPI_MUTEX Handle, 216 UINT16 Timeout); 217 #endif 218 219 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsReleaseMutex 220 void 221 AcpiOsReleaseMutex ( 222 ACPI_MUTEX Handle); 223 #endif 224 225 #endif 226 227 228 /* 229 * Memory allocation and mapping 230 */ 231 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsAllocate 232 void * 233 AcpiOsAllocate ( 234 ACPI_SIZE Size); 235 #endif 236 237 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsAllocateZeroed 238 void * 239 AcpiOsAllocateZeroed ( 240 ACPI_SIZE Size); 241 #endif 242 243 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsFree 244 void 245 AcpiOsFree ( 246 void * Memory); 247 #endif 248 249 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsMapMemory 250 void * 251 AcpiOsMapMemory ( 252 ACPI_PHYSICAL_ADDRESS Where, 253 ACPI_SIZE Length); 254 #endif 255 256 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsUnmapMemory 257 void 258 AcpiOsUnmapMemory ( 259 void *LogicalAddress, 260 ACPI_SIZE Size); 261 #endif 262 263 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsGetPhysicalAddress 264 ACPI_STATUS 265 AcpiOsGetPhysicalAddress ( 266 void *LogicalAddress, 267 ACPI_PHYSICAL_ADDRESS *PhysicalAddress); 268 #endif 269 270 271 /* 272 * Memory/Object Cache 273 */ 274 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsCreateCache 275 ACPI_STATUS 276 AcpiOsCreateCache ( 277 char *CacheName, 278 UINT16 ObjectSize, 279 UINT16 MaxDepth, 280 ACPI_CACHE_T **ReturnCache); 281 #endif 282 283 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsDeleteCache 284 ACPI_STATUS 285 AcpiOsDeleteCache ( 286 ACPI_CACHE_T *Cache); 287 #endif 288 289 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsPurgeCache 290 ACPI_STATUS 291 AcpiOsPurgeCache ( 292 ACPI_CACHE_T *Cache); 293 #endif 294 295 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsAcquireObject 296 void * 297 AcpiOsAcquireObject ( 298 ACPI_CACHE_T *Cache); 299 #endif 300 301 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsReleaseObject 302 ACPI_STATUS 303 AcpiOsReleaseObject ( 304 ACPI_CACHE_T *Cache, 305 void *Object); 306 #endif 307 308 309 /* 310 * Interrupt handlers 311 */ 312 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsInstallInterruptHandler 313 ACPI_STATUS 314 AcpiOsInstallInterruptHandler ( 315 UINT32 InterruptNumber, 316 ACPI_OSD_HANDLER ServiceRoutine, 317 void *Context); 318 #endif 319 320 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsRemoveInterruptHandler 321 ACPI_STATUS 322 AcpiOsRemoveInterruptHandler ( 323 UINT32 InterruptNumber, 324 ACPI_OSD_HANDLER ServiceRoutine); 325 #endif 326 327 328 /* 329 * Threads and Scheduling 330 */ 331 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsGetThreadId 332 ACPI_THREAD_ID 333 AcpiOsGetThreadId ( 334 void); 335 #endif 336 337 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsExecute 338 ACPI_STATUS 339 AcpiOsExecute ( 340 ACPI_EXECUTE_TYPE Type, 341 ACPI_OSD_EXEC_CALLBACK Function, 342 void *Context); 343 #endif 344 345 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsWaitEventsComplete 346 void 347 AcpiOsWaitEventsComplete ( 348 void); 349 #endif 350 351 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsSleep 352 void 353 AcpiOsSleep ( 354 UINT64 Milliseconds); 355 #endif 356 357 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsStall 358 void 359 AcpiOsStall ( 360 UINT32 Microseconds); 361 #endif 362 363 364 /* 365 * Platform and hardware-independent I/O interfaces 366 */ 367 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsReadPort 368 ACPI_STATUS 369 AcpiOsReadPort ( 370 ACPI_IO_ADDRESS Address, 371 UINT32 *Value, 372 UINT32 Width); 373 #endif 374 375 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsWritePort 376 ACPI_STATUS 377 AcpiOsWritePort ( 378 ACPI_IO_ADDRESS Address, 379 UINT32 Value, 380 UINT32 Width); 381 #endif 382 383 384 /* 385 * Platform and hardware-independent physical memory interfaces 386 */ 387 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsReadMemory 388 ACPI_STATUS 389 AcpiOsReadMemory ( 390 ACPI_PHYSICAL_ADDRESS Address, 391 UINT64 *Value, 392 UINT32 Width); 393 #endif 394 395 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsWriteMemory 396 ACPI_STATUS 397 AcpiOsWriteMemory ( 398 ACPI_PHYSICAL_ADDRESS Address, 399 UINT64 Value, 400 UINT32 Width); 401 #endif 402 403 404 /* 405 * Platform and hardware-independent PCI configuration space access 406 * Note: Can't use "Register" as a parameter, changed to "Reg" -- 407 * certain compilers complain. 408 */ 409 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsReadPciConfiguration 410 ACPI_STATUS 411 AcpiOsReadPciConfiguration ( 412 ACPI_PCI_ID *PciId, 413 UINT32 Reg, 414 UINT64 *Value, 415 UINT32 Width); 416 #endif 417 418 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsWritePciConfiguration 419 ACPI_STATUS 420 AcpiOsWritePciConfiguration ( 421 ACPI_PCI_ID *PciId, 422 UINT32 Reg, 423 UINT64 Value, 424 UINT32 Width); 425 #endif 426 427 428 /* 429 * Miscellaneous 430 */ 431 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsReadable 432 BOOLEAN 433 AcpiOsReadable ( 434 void *Pointer, 435 ACPI_SIZE Length); 436 #endif 437 438 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsWritable 439 BOOLEAN 440 AcpiOsWritable ( 441 void *Pointer, 442 ACPI_SIZE Length); 443 #endif 444 445 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsGetTimer 446 UINT64 447 AcpiOsGetTimer ( 448 void); 449 #endif 450 451 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsSignal 452 ACPI_STATUS 453 AcpiOsSignal ( 454 UINT32 Function, 455 void *Info); 456 #endif 457 458 459 /* 460 * Debug print routines 461 */ 462 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsPrintf 463 void ACPI_INTERNAL_VAR_XFACE 464 AcpiOsPrintf ( 465 const char *Format, 466 ...); 467 #endif 468 469 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsVprintf 470 void 471 AcpiOsVprintf ( 472 const char *Format, 473 va_list Args); 474 #endif 475 476 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsRedirectOutput 477 void 478 AcpiOsRedirectOutput ( 479 void *Destination); 480 #endif 481 482 483 /* 484 * Debug input 485 */ 486 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsGetLine 487 ACPI_STATUS 488 AcpiOsGetLine ( 489 char *Buffer, 490 UINT32 BufferLength, 491 UINT32 *BytesRead); 492 #endif 493 494 495 /* 496 * Obtain ACPI table(s) 497 */ 498 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsGetTableByName 499 ACPI_STATUS 500 AcpiOsGetTableByName ( 501 char *Signature, 502 UINT32 Instance, 503 ACPI_TABLE_HEADER **Table, 504 ACPI_PHYSICAL_ADDRESS *Address); 505 #endif 506 507 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsGetTableByIndex 508 ACPI_STATUS 509 AcpiOsGetTableByIndex ( 510 UINT32 Index, 511 ACPI_TABLE_HEADER **Table, 512 UINT32 *Instance, 513 ACPI_PHYSICAL_ADDRESS *Address); 514 #endif 515 516 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsGetTableByAddress 517 ACPI_STATUS 518 AcpiOsGetTableByAddress ( 519 ACPI_PHYSICAL_ADDRESS Address, 520 ACPI_TABLE_HEADER **Table); 521 #endif 522 523 524 /* 525 * Directory manipulation 526 */ 527 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsOpenDirectory 528 void * 529 AcpiOsOpenDirectory ( 530 char *Pathname, 531 char *WildcardSpec, 532 char RequestedFileType); 533 #endif 534 535 /* RequesteFileType values */ 536 537 #define REQUEST_FILE_ONLY 0 538 #define REQUEST_DIR_ONLY 1 539 540 541 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsGetNextFilename 542 char * 543 AcpiOsGetNextFilename ( 544 void *DirHandle); 545 #endif 546 547 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsCloseDirectory 548 void 549 AcpiOsCloseDirectory ( 550 void *DirHandle); 551 #endif 552 553 554 #endif /* __ACPIOSXF_H__ */