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