1 /****************************************************************************** 2 * 3 * Name: acresrc.h - Resource Manager function prototypes 4 * 5 *****************************************************************************/ 6 7 /* 8 * Copyright (C) 2000 - 2013, Intel Corp. 9 * All rights reserved. 10 * 11 * Redistribution and use in source and binary forms, with or without 12 * modification, are permitted provided that the following conditions 13 * are met: 14 * 1. Redistributions of source code must retain the above copyright 15 * notice, this list of conditions, and the following disclaimer, 16 * without modification. 17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer 18 * substantially similar to the "NO WARRANTY" disclaimer below 19 * ("Disclaimer") and any redistribution must be conditioned upon 20 * including a substantially similar Disclaimer requirement for further 21 * binary redistribution. 22 * 3. Neither the names of the above-listed copyright holders nor the names 23 * of any contributors may be used to endorse or promote products derived 24 * from this software without specific prior written permission. 25 * 26 * Alternatively, this software may be distributed under the terms of the 27 * GNU General Public License ("GPL") version 2 as published by the Free 28 * Software Foundation. 29 * 30 * NO WARRANTY 31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 41 * POSSIBILITY OF SUCH DAMAGES. 42 */ 43 44 #ifndef __ACRESRC_H__ 45 #define __ACRESRC_H__ 46 47 /* Need the AML resource descriptor structs */ 48 49 #include <contrib/dev/acpica/include/amlresrc.h> 50 51 52 /* 53 * If possible, pack the following structures to byte alignment, since we 54 * don't care about performance for debug output. Two cases where we cannot 55 * pack the structures: 56 * 57 * 1) Hardware does not support misaligned memory transfers 58 * 2) Compiler does not support pointers within packed structures 59 */ 60 #if (!defined(ACPI_MISALIGNMENT_NOT_SUPPORTED) && !defined(ACPI_PACKED_POINTERS_NOT_SUPPORTED)) 61 #pragma pack(1) 62 #endif 63 64 /* 65 * Individual entry for the resource conversion tables 66 */ 67 typedef const struct acpi_rsconvert_info 68 { 69 UINT8 Opcode; 70 UINT8 ResourceOffset; 71 UINT8 AmlOffset; 72 UINT8 Value; 73 74 } ACPI_RSCONVERT_INFO; 75 76 /* Resource conversion opcodes */ 77 78 typedef enum 79 { 80 ACPI_RSC_INITGET = 0, 81 ACPI_RSC_INITSET, 82 ACPI_RSC_FLAGINIT, 83 ACPI_RSC_1BITFLAG, 84 ACPI_RSC_2BITFLAG, 85 ACPI_RSC_3BITFLAG, 86 ACPI_RSC_ADDRESS, 87 ACPI_RSC_BITMASK, 88 ACPI_RSC_BITMASK16, 89 ACPI_RSC_COUNT, 90 ACPI_RSC_COUNT16, 91 ACPI_RSC_COUNT_GPIO_PIN, 92 ACPI_RSC_COUNT_GPIO_RES, 93 ACPI_RSC_COUNT_GPIO_VEN, 94 ACPI_RSC_COUNT_SERIAL_RES, 95 ACPI_RSC_COUNT_SERIAL_VEN, 96 ACPI_RSC_DATA8, 97 ACPI_RSC_EXIT_EQ, 98 ACPI_RSC_EXIT_LE, 99 ACPI_RSC_EXIT_NE, 100 ACPI_RSC_LENGTH, 101 ACPI_RSC_MOVE_GPIO_PIN, 102 ACPI_RSC_MOVE_GPIO_RES, 103 ACPI_RSC_MOVE_SERIAL_RES, 104 ACPI_RSC_MOVE_SERIAL_VEN, 105 ACPI_RSC_MOVE8, 106 ACPI_RSC_MOVE16, 107 ACPI_RSC_MOVE32, 108 ACPI_RSC_MOVE64, 109 ACPI_RSC_SET8, 110 ACPI_RSC_SOURCE, 111 ACPI_RSC_SOURCEX 112 113 } ACPI_RSCONVERT_OPCODES; 114 115 /* Resource Conversion sub-opcodes */ 116 117 #define ACPI_RSC_COMPARE_AML_LENGTH 0 118 #define ACPI_RSC_COMPARE_VALUE 1 119 120 #define ACPI_RSC_TABLE_SIZE(d) (sizeof (d) / sizeof (ACPI_RSCONVERT_INFO)) 121 122 #define ACPI_RS_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_RESOURCE,f) 123 #define AML_OFFSET(f) (UINT8) ACPI_OFFSET (AML_RESOURCE,f) 124 125 126 /* 127 * Individual entry for the resource dump tables 128 */ 129 typedef const struct acpi_rsdump_info 130 { 131 UINT8 Opcode; 132 UINT8 Offset; 133 char *Name; 134 const char **Pointer; 135 136 } ACPI_RSDUMP_INFO; 137 138 /* Values for the Opcode field above */ 139 140 typedef enum 141 { 142 ACPI_RSD_TITLE = 0, 143 ACPI_RSD_1BITFLAG, 144 ACPI_RSD_2BITFLAG, 145 ACPI_RSD_3BITFLAG, 146 ACPI_RSD_ADDRESS, 147 ACPI_RSD_DWORDLIST, 148 ACPI_RSD_LITERAL, 149 ACPI_RSD_LONGLIST, 150 ACPI_RSD_SHORTLIST, 151 ACPI_RSD_SHORTLISTX, 152 ACPI_RSD_SOURCE, 153 ACPI_RSD_STRING, 154 ACPI_RSD_UINT8, 155 ACPI_RSD_UINT16, 156 ACPI_RSD_UINT32, 157 ACPI_RSD_UINT64, 158 ACPI_RSD_WORDLIST 159 160 } ACPI_RSDUMP_OPCODES; 161 162 /* restore default alignment */ 163 164 #pragma pack() 165 166 167 /* Resource tables indexed by internal resource type */ 168 169 extern const UINT8 AcpiGbl_AmlResourceSizes[]; 170 extern const UINT8 AcpiGbl_AmlResourceSerialBusSizes[]; 171 extern ACPI_RSCONVERT_INFO *AcpiGbl_SetResourceDispatch[]; 172 173 /* Resource tables indexed by raw AML resource descriptor type */ 174 175 extern const UINT8 AcpiGbl_ResourceStructSizes[]; 176 extern const UINT8 AcpiGbl_ResourceStructSerialBusSizes[]; 177 extern ACPI_RSCONVERT_INFO *AcpiGbl_GetResourceDispatch[]; 178 179 extern ACPI_RSCONVERT_INFO *AcpiGbl_ConvertResourceSerialBusDispatch[]; 180 181 typedef struct acpi_vendor_walk_info 182 { 183 ACPI_VENDOR_UUID *Uuid; 184 ACPI_BUFFER *Buffer; 185 ACPI_STATUS Status; 186 187 } ACPI_VENDOR_WALK_INFO; 188 189 190 /* 191 * rscreate 192 */ 193 ACPI_STATUS 194 AcpiRsCreateResourceList ( 195 ACPI_OPERAND_OBJECT *AmlBuffer, 196 ACPI_BUFFER *OutputBuffer); 197 198 ACPI_STATUS 199 AcpiRsCreateAmlResources ( 200 ACPI_RESOURCE *LinkedListBuffer, 201 ACPI_BUFFER *OutputBuffer); 202 203 ACPI_STATUS 204 AcpiRsCreatePciRoutingTable ( 205 ACPI_OPERAND_OBJECT *PackageObject, 206 ACPI_BUFFER *OutputBuffer); 207 208 209 /* 210 * rsutils 211 */ 212 ACPI_STATUS 213 AcpiRsGetPrtMethodData ( 214 ACPI_NAMESPACE_NODE *Node, 215 ACPI_BUFFER *RetBuffer); 216 217 ACPI_STATUS 218 AcpiRsGetCrsMethodData ( 219 ACPI_NAMESPACE_NODE *Node, 220 ACPI_BUFFER *RetBuffer); 221 222 ACPI_STATUS 223 AcpiRsGetPrsMethodData ( 224 ACPI_NAMESPACE_NODE *Node, 225 ACPI_BUFFER *RetBuffer); 226 227 ACPI_STATUS 228 AcpiRsGetMethodData ( 229 ACPI_HANDLE Handle, 230 char *Path, 231 ACPI_BUFFER *RetBuffer); 232 233 ACPI_STATUS 234 AcpiRsSetSrsMethodData ( 235 ACPI_NAMESPACE_NODE *Node, 236 ACPI_BUFFER *RetBuffer); 237 238 ACPI_STATUS 239 AcpiRsGetAeiMethodData ( 240 ACPI_NAMESPACE_NODE *Node, 241 ACPI_BUFFER *RetBuffer); 242 243 /* 244 * rscalc 245 */ 246 ACPI_STATUS 247 AcpiRsGetListLength ( 248 UINT8 *AmlBuffer, 249 UINT32 AmlBufferLength, 250 ACPI_SIZE *SizeNeeded); 251 252 ACPI_STATUS 253 AcpiRsGetAmlLength ( 254 ACPI_RESOURCE *LinkedListBuffer, 255 ACPI_SIZE *SizeNeeded); 256 257 ACPI_STATUS 258 AcpiRsGetPciRoutingTableLength ( 259 ACPI_OPERAND_OBJECT *PackageObject, 260 ACPI_SIZE *BufferSizeNeeded); 261 262 ACPI_STATUS 263 AcpiRsConvertAmlToResources ( 264 UINT8 *Aml, 265 UINT32 Length, 266 UINT32 Offset, 267 UINT8 ResourceIndex, 268 void **Context); 269 270 ACPI_STATUS 271 AcpiRsConvertResourcesToAml ( 272 ACPI_RESOURCE *Resource, 273 ACPI_SIZE AmlSizeNeeded, 274 UINT8 *OutputBuffer); 275 276 277 /* 278 * rsaddr 279 */ 280 void 281 AcpiRsSetAddressCommon ( 282 AML_RESOURCE *Aml, 283 ACPI_RESOURCE *Resource); 284 285 BOOLEAN 286 AcpiRsGetAddressCommon ( 287 ACPI_RESOURCE *Resource, 288 AML_RESOURCE *Aml); 289 290 291 /* 292 * rsmisc 293 */ 294 ACPI_STATUS 295 AcpiRsConvertAmlToResource ( 296 ACPI_RESOURCE *Resource, 297 AML_RESOURCE *Aml, 298 ACPI_RSCONVERT_INFO *Info); 299 300 ACPI_STATUS 301 AcpiRsConvertResourceToAml ( 302 ACPI_RESOURCE *Resource, 303 AML_RESOURCE *Aml, 304 ACPI_RSCONVERT_INFO *Info); 305 306 307 /* 308 * rsutils 309 */ 310 void 311 AcpiRsMoveData ( 312 void *Destination, 313 void *Source, 314 UINT16 ItemCount, 315 UINT8 MoveType); 316 317 UINT8 318 AcpiRsDecodeBitmask ( 319 UINT16 Mask, 320 UINT8 *List); 321 322 UINT16 323 AcpiRsEncodeBitmask ( 324 UINT8 *List, 325 UINT8 Count); 326 327 ACPI_RS_LENGTH 328 AcpiRsGetResourceSource ( 329 ACPI_RS_LENGTH ResourceLength, 330 ACPI_RS_LENGTH MinimumLength, 331 ACPI_RESOURCE_SOURCE *ResourceSource, 332 AML_RESOURCE *Aml, 333 char *StringPtr); 334 335 ACPI_RSDESC_SIZE 336 AcpiRsSetResourceSource ( 337 AML_RESOURCE *Aml, 338 ACPI_RS_LENGTH MinimumLength, 339 ACPI_RESOURCE_SOURCE *ResourceSource); 340 341 void 342 AcpiRsSetResourceHeader ( 343 UINT8 DescriptorType, 344 ACPI_RSDESC_SIZE TotalLength, 345 AML_RESOURCE *Aml); 346 347 void 348 AcpiRsSetResourceLength ( 349 ACPI_RSDESC_SIZE TotalLength, 350 AML_RESOURCE *Aml); 351 352 353 /* 354 * rsdump 355 */ 356 void 357 AcpiRsDumpResourceList ( 358 ACPI_RESOURCE *Resource); 359 360 void 361 AcpiRsDumpIrqList ( 362 UINT8 *RouteTable); 363 364 365 /* 366 * Resource conversion tables 367 */ 368 extern ACPI_RSCONVERT_INFO AcpiRsConvertDma[]; 369 extern ACPI_RSCONVERT_INFO AcpiRsConvertEndDpf[]; 370 extern ACPI_RSCONVERT_INFO AcpiRsConvertIo[]; 371 extern ACPI_RSCONVERT_INFO AcpiRsConvertFixedIo[]; 372 extern ACPI_RSCONVERT_INFO AcpiRsConvertEndTag[]; 373 extern ACPI_RSCONVERT_INFO AcpiRsConvertMemory24[]; 374 extern ACPI_RSCONVERT_INFO AcpiRsConvertGenericReg[]; 375 extern ACPI_RSCONVERT_INFO AcpiRsConvertMemory32[]; 376 extern ACPI_RSCONVERT_INFO AcpiRsConvertFixedMemory32[]; 377 extern ACPI_RSCONVERT_INFO AcpiRsConvertAddress32[]; 378 extern ACPI_RSCONVERT_INFO AcpiRsConvertAddress16[]; 379 extern ACPI_RSCONVERT_INFO AcpiRsConvertExtIrq[]; 380 extern ACPI_RSCONVERT_INFO AcpiRsConvertAddress64[]; 381 extern ACPI_RSCONVERT_INFO AcpiRsConvertExtAddress64[]; 382 extern ACPI_RSCONVERT_INFO AcpiRsConvertGpio[]; 383 extern ACPI_RSCONVERT_INFO AcpiRsConvertFixedDma[]; 384 extern ACPI_RSCONVERT_INFO AcpiRsConvertI2cSerialBus[]; 385 extern ACPI_RSCONVERT_INFO AcpiRsConvertSpiSerialBus[]; 386 extern ACPI_RSCONVERT_INFO AcpiRsConvertUartSerialBus[]; 387 388 /* These resources require separate get/set tables */ 389 390 extern ACPI_RSCONVERT_INFO AcpiRsGetIrq[]; 391 extern ACPI_RSCONVERT_INFO AcpiRsGetStartDpf[]; 392 extern ACPI_RSCONVERT_INFO AcpiRsGetVendorSmall[]; 393 extern ACPI_RSCONVERT_INFO AcpiRsGetVendorLarge[]; 394 395 extern ACPI_RSCONVERT_INFO AcpiRsSetIrq[]; 396 extern ACPI_RSCONVERT_INFO AcpiRsSetStartDpf[]; 397 extern ACPI_RSCONVERT_INFO AcpiRsSetVendor[]; 398 399 400 #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) 401 /* 402 * rsinfo 403 */ 404 extern ACPI_RSDUMP_INFO *AcpiGbl_DumpResourceDispatch[]; 405 extern ACPI_RSDUMP_INFO *AcpiGbl_DumpSerialBusDispatch[]; 406 407 /* 408 * rsdumpinfo 409 */ 410 extern ACPI_RSDUMP_INFO AcpiRsDumpIrq[]; 411 extern ACPI_RSDUMP_INFO AcpiRsDumpPrt[]; 412 extern ACPI_RSDUMP_INFO AcpiRsDumpDma[]; 413 extern ACPI_RSDUMP_INFO AcpiRsDumpStartDpf[]; 414 extern ACPI_RSDUMP_INFO AcpiRsDumpEndDpf[]; 415 extern ACPI_RSDUMP_INFO AcpiRsDumpIo[]; 416 extern ACPI_RSDUMP_INFO AcpiRsDumpIoFlags[]; 417 extern ACPI_RSDUMP_INFO AcpiRsDumpFixedIo[]; 418 extern ACPI_RSDUMP_INFO AcpiRsDumpVendor[]; 419 extern ACPI_RSDUMP_INFO AcpiRsDumpEndTag[]; 420 extern ACPI_RSDUMP_INFO AcpiRsDumpMemory24[]; 421 extern ACPI_RSDUMP_INFO AcpiRsDumpMemory32[]; 422 extern ACPI_RSDUMP_INFO AcpiRsDumpMemoryFlags[]; 423 extern ACPI_RSDUMP_INFO AcpiRsDumpFixedMemory32[]; 424 extern ACPI_RSDUMP_INFO AcpiRsDumpAddress16[]; 425 extern ACPI_RSDUMP_INFO AcpiRsDumpAddress32[]; 426 extern ACPI_RSDUMP_INFO AcpiRsDumpAddress64[]; 427 extern ACPI_RSDUMP_INFO AcpiRsDumpExtAddress64[]; 428 extern ACPI_RSDUMP_INFO AcpiRsDumpExtIrq[]; 429 extern ACPI_RSDUMP_INFO AcpiRsDumpGenericReg[]; 430 extern ACPI_RSDUMP_INFO AcpiRsDumpGpio[]; 431 extern ACPI_RSDUMP_INFO AcpiRsDumpFixedDma[]; 432 extern ACPI_RSDUMP_INFO AcpiRsDumpCommonSerialBus[]; 433 extern ACPI_RSDUMP_INFO AcpiRsDumpI2cSerialBus[]; 434 extern ACPI_RSDUMP_INFO AcpiRsDumpSpiSerialBus[]; 435 extern ACPI_RSDUMP_INFO AcpiRsDumpUartSerialBus[]; 436 extern ACPI_RSDUMP_INFO AcpiRsDumpGeneralFlags[]; 437 #endif 438 439 #endif /* __ACRESRC_H__ */ 440