1 /****************************************************************************** 2 * 3 * Name: acresrc.h - Resource Manager function prototypes 4 * 5 *****************************************************************************/ 6 7 /* 8 * Copyright (C) 2000 - 2020, 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 "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 const 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 ACPI_RSD_LABEL, 160 ACPI_RSD_SOURCE_LABEL, 161 162 } ACPI_RSDUMP_OPCODES; 163 164 /* restore default alignment */ 165 166 #pragma pack() 167 168 169 /* Resource tables indexed by internal resource type */ 170 171 extern const UINT8 AcpiGbl_AmlResourceSizes[]; 172 extern const UINT8 AcpiGbl_AmlResourceSerialBusSizes[]; 173 extern ACPI_RSCONVERT_INFO *AcpiGbl_SetResourceDispatch[]; 174 175 /* Resource tables indexed by raw AML resource descriptor type */ 176 177 extern const UINT8 AcpiGbl_ResourceStructSizes[]; 178 extern const UINT8 AcpiGbl_ResourceStructSerialBusSizes[]; 179 extern ACPI_RSCONVERT_INFO *AcpiGbl_GetResourceDispatch[]; 180 181 extern ACPI_RSCONVERT_INFO *AcpiGbl_ConvertResourceSerialBusDispatch[]; 182 183 typedef struct acpi_vendor_walk_info 184 { 185 ACPI_VENDOR_UUID *Uuid; 186 ACPI_BUFFER *Buffer; 187 ACPI_STATUS Status; 188 189 } ACPI_VENDOR_WALK_INFO; 190 191 192 /* 193 * rscreate 194 */ 195 ACPI_STATUS 196 AcpiRsCreateResourceList ( 197 ACPI_OPERAND_OBJECT *AmlBuffer, 198 ACPI_BUFFER *OutputBuffer); 199 200 ACPI_STATUS 201 AcpiRsCreateAmlResources ( 202 ACPI_BUFFER *ResourceList, 203 ACPI_BUFFER *OutputBuffer); 204 205 ACPI_STATUS 206 AcpiRsCreatePciRoutingTable ( 207 ACPI_OPERAND_OBJECT *PackageObject, 208 ACPI_BUFFER *OutputBuffer); 209 210 211 /* 212 * rsutils 213 */ 214 ACPI_STATUS 215 AcpiRsGetPrtMethodData ( 216 ACPI_NAMESPACE_NODE *Node, 217 ACPI_BUFFER *RetBuffer); 218 219 ACPI_STATUS 220 AcpiRsGetCrsMethodData ( 221 ACPI_NAMESPACE_NODE *Node, 222 ACPI_BUFFER *RetBuffer); 223 224 ACPI_STATUS 225 AcpiRsGetPrsMethodData ( 226 ACPI_NAMESPACE_NODE *Node, 227 ACPI_BUFFER *RetBuffer); 228 229 ACPI_STATUS 230 AcpiRsGetMethodData ( 231 ACPI_HANDLE Handle, 232 const char *Path, 233 ACPI_BUFFER *RetBuffer); 234 235 ACPI_STATUS 236 AcpiRsSetSrsMethodData ( 237 ACPI_NAMESPACE_NODE *Node, 238 ACPI_BUFFER *RetBuffer); 239 240 ACPI_STATUS 241 AcpiRsGetAeiMethodData ( 242 ACPI_NAMESPACE_NODE *Node, 243 ACPI_BUFFER *RetBuffer); 244 245 /* 246 * rscalc 247 */ 248 ACPI_STATUS 249 AcpiRsGetListLength ( 250 UINT8 *AmlBuffer, 251 UINT32 AmlBufferLength, 252 ACPI_SIZE *SizeNeeded); 253 254 ACPI_STATUS 255 AcpiRsGetAmlLength ( 256 ACPI_RESOURCE *ResourceList, 257 ACPI_SIZE ResourceListSize, 258 ACPI_SIZE *SizeNeeded); 259 260 ACPI_STATUS 261 AcpiRsGetPciRoutingTableLength ( 262 ACPI_OPERAND_OBJECT *PackageObject, 263 ACPI_SIZE *BufferSizeNeeded); 264 265 ACPI_STATUS 266 AcpiRsConvertAmlToResources ( 267 UINT8 *Aml, 268 UINT32 Length, 269 UINT32 Offset, 270 UINT8 ResourceIndex, 271 void **Context); 272 273 ACPI_STATUS 274 AcpiRsConvertResourcesToAml ( 275 ACPI_RESOURCE *Resource, 276 ACPI_SIZE AmlSizeNeeded, 277 UINT8 *OutputBuffer); 278 279 280 /* 281 * rsaddr 282 */ 283 void 284 AcpiRsSetAddressCommon ( 285 AML_RESOURCE *Aml, 286 ACPI_RESOURCE *Resource); 287 288 BOOLEAN 289 AcpiRsGetAddressCommon ( 290 ACPI_RESOURCE *Resource, 291 AML_RESOURCE *Aml); 292 293 294 /* 295 * rsmisc 296 */ 297 ACPI_STATUS 298 AcpiRsConvertAmlToResource ( 299 ACPI_RESOURCE *Resource, 300 AML_RESOURCE *Aml, 301 ACPI_RSCONVERT_INFO *Info); 302 303 ACPI_STATUS 304 AcpiRsConvertResourceToAml ( 305 ACPI_RESOURCE *Resource, 306 AML_RESOURCE *Aml, 307 ACPI_RSCONVERT_INFO *Info); 308 309 310 /* 311 * rsutils 312 */ 313 void 314 AcpiRsMoveData ( 315 void *Destination, 316 void *Source, 317 UINT16 ItemCount, 318 UINT8 MoveType); 319 320 UINT8 321 AcpiRsDecodeBitmask ( 322 UINT16 Mask, 323 UINT8 *List); 324 325 UINT16 326 AcpiRsEncodeBitmask ( 327 UINT8 *List, 328 UINT8 Count); 329 330 ACPI_RS_LENGTH 331 AcpiRsGetResourceSource ( 332 ACPI_RS_LENGTH ResourceLength, 333 ACPI_RS_LENGTH MinimumLength, 334 ACPI_RESOURCE_SOURCE *ResourceSource, 335 AML_RESOURCE *Aml, 336 char *StringPtr); 337 338 ACPI_RSDESC_SIZE 339 AcpiRsSetResourceSource ( 340 AML_RESOURCE *Aml, 341 ACPI_RS_LENGTH MinimumLength, 342 ACPI_RESOURCE_SOURCE *ResourceSource); 343 344 void 345 AcpiRsSetResourceHeader ( 346 UINT8 DescriptorType, 347 ACPI_RSDESC_SIZE TotalLength, 348 AML_RESOURCE *Aml); 349 350 void 351 AcpiRsSetResourceLength ( 352 ACPI_RSDESC_SIZE TotalLength, 353 AML_RESOURCE *Aml); 354 355 356 /* 357 * rsdump - Debugger support 358 */ 359 #ifdef ACPI_DEBUGGER 360 void 361 AcpiRsDumpResourceList ( 362 ACPI_RESOURCE *Resource); 363 364 void 365 AcpiRsDumpIrqList ( 366 UINT8 *RouteTable); 367 #endif 368 369 370 /* 371 * Resource conversion tables 372 */ 373 extern ACPI_RSCONVERT_INFO AcpiRsConvertDma[]; 374 extern ACPI_RSCONVERT_INFO AcpiRsConvertEndDpf[]; 375 extern ACPI_RSCONVERT_INFO AcpiRsConvertIo[]; 376 extern ACPI_RSCONVERT_INFO AcpiRsConvertFixedIo[]; 377 extern ACPI_RSCONVERT_INFO AcpiRsConvertEndTag[]; 378 extern ACPI_RSCONVERT_INFO AcpiRsConvertMemory24[]; 379 extern ACPI_RSCONVERT_INFO AcpiRsConvertGenericReg[]; 380 extern ACPI_RSCONVERT_INFO AcpiRsConvertMemory32[]; 381 extern ACPI_RSCONVERT_INFO AcpiRsConvertFixedMemory32[]; 382 extern ACPI_RSCONVERT_INFO AcpiRsConvertAddress32[]; 383 extern ACPI_RSCONVERT_INFO AcpiRsConvertAddress16[]; 384 extern ACPI_RSCONVERT_INFO AcpiRsConvertExtIrq[]; 385 extern ACPI_RSCONVERT_INFO AcpiRsConvertAddress64[]; 386 extern ACPI_RSCONVERT_INFO AcpiRsConvertExtAddress64[]; 387 extern ACPI_RSCONVERT_INFO AcpiRsConvertGpio[]; 388 extern ACPI_RSCONVERT_INFO AcpiRsConvertFixedDma[]; 389 extern ACPI_RSCONVERT_INFO AcpiRsConvertI2cSerialBus[]; 390 extern ACPI_RSCONVERT_INFO AcpiRsConvertSpiSerialBus[]; 391 extern ACPI_RSCONVERT_INFO AcpiRsConvertUartSerialBus[]; 392 extern ACPI_RSCONVERT_INFO AcpiRsConvertPinFunction[]; 393 extern ACPI_RSCONVERT_INFO AcpiRsConvertPinConfig[]; 394 extern ACPI_RSCONVERT_INFO AcpiRsConvertPinGroup[]; 395 extern ACPI_RSCONVERT_INFO AcpiRsConvertPinGroupFunction[]; 396 extern ACPI_RSCONVERT_INFO AcpiRsConvertPinGroupConfig[]; 397 398 /* These resources require separate get/set tables */ 399 400 extern ACPI_RSCONVERT_INFO AcpiRsGetIrq[]; 401 extern ACPI_RSCONVERT_INFO AcpiRsGetStartDpf[]; 402 extern ACPI_RSCONVERT_INFO AcpiRsGetVendorSmall[]; 403 extern ACPI_RSCONVERT_INFO AcpiRsGetVendorLarge[]; 404 405 extern ACPI_RSCONVERT_INFO AcpiRsSetIrq[]; 406 extern ACPI_RSCONVERT_INFO AcpiRsSetStartDpf[]; 407 extern ACPI_RSCONVERT_INFO AcpiRsSetVendor[]; 408 409 410 #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) 411 /* 412 * rsinfo 413 */ 414 extern ACPI_RSDUMP_INFO *AcpiGbl_DumpResourceDispatch[]; 415 extern ACPI_RSDUMP_INFO *AcpiGbl_DumpSerialBusDispatch[]; 416 417 /* 418 * rsdumpinfo 419 */ 420 extern ACPI_RSDUMP_INFO AcpiRsDumpIrq[]; 421 extern ACPI_RSDUMP_INFO AcpiRsDumpPrt[]; 422 extern ACPI_RSDUMP_INFO AcpiRsDumpDma[]; 423 extern ACPI_RSDUMP_INFO AcpiRsDumpStartDpf[]; 424 extern ACPI_RSDUMP_INFO AcpiRsDumpEndDpf[]; 425 extern ACPI_RSDUMP_INFO AcpiRsDumpIo[]; 426 extern ACPI_RSDUMP_INFO AcpiRsDumpIoFlags[]; 427 extern ACPI_RSDUMP_INFO AcpiRsDumpFixedIo[]; 428 extern ACPI_RSDUMP_INFO AcpiRsDumpVendor[]; 429 extern ACPI_RSDUMP_INFO AcpiRsDumpEndTag[]; 430 extern ACPI_RSDUMP_INFO AcpiRsDumpMemory24[]; 431 extern ACPI_RSDUMP_INFO AcpiRsDumpMemory32[]; 432 extern ACPI_RSDUMP_INFO AcpiRsDumpMemoryFlags[]; 433 extern ACPI_RSDUMP_INFO AcpiRsDumpFixedMemory32[]; 434 extern ACPI_RSDUMP_INFO AcpiRsDumpAddress16[]; 435 extern ACPI_RSDUMP_INFO AcpiRsDumpAddress32[]; 436 extern ACPI_RSDUMP_INFO AcpiRsDumpAddress64[]; 437 extern ACPI_RSDUMP_INFO AcpiRsDumpExtAddress64[]; 438 extern ACPI_RSDUMP_INFO AcpiRsDumpExtIrq[]; 439 extern ACPI_RSDUMP_INFO AcpiRsDumpGenericReg[]; 440 extern ACPI_RSDUMP_INFO AcpiRsDumpGpio[]; 441 extern ACPI_RSDUMP_INFO AcpiRsDumpPinFunction[]; 442 extern ACPI_RSDUMP_INFO AcpiRsDumpFixedDma[]; 443 extern ACPI_RSDUMP_INFO AcpiRsDumpCommonSerialBus[]; 444 extern ACPI_RSDUMP_INFO AcpiRsDumpI2cSerialBus[]; 445 extern ACPI_RSDUMP_INFO AcpiRsDumpSpiSerialBus[]; 446 extern ACPI_RSDUMP_INFO AcpiRsDumpUartSerialBus[]; 447 extern ACPI_RSDUMP_INFO AcpiRsDumpGeneralFlags[]; 448 extern ACPI_RSDUMP_INFO AcpiRsDumpPinConfig[]; 449 extern ACPI_RSDUMP_INFO AcpiRsDumpPinGroup[]; 450 extern ACPI_RSDUMP_INFO AcpiRsDumpPinGroupFunction[]; 451 extern ACPI_RSDUMP_INFO AcpiRsDumpPinGroupConfig[]; 452 #endif 453 454 #endif /* __ACRESRC_H__ */ 455