1 /****************************************************************************** 2 * 3 * Name: acresrc.h - Resource Manager function prototypes 4 * 5 *****************************************************************************/ 6 7 /* 8 * Copyright (C) 2000 - 2022, 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 MERCHANTABILITY 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_6BITFLAG, 87 ACPI_RSC_ADDRESS, 88 ACPI_RSC_BITMASK, 89 ACPI_RSC_BITMASK16, 90 ACPI_RSC_COUNT, 91 ACPI_RSC_COUNT16, 92 ACPI_RSC_COUNT_GPIO_PIN, 93 ACPI_RSC_COUNT_GPIO_RES, 94 ACPI_RSC_COUNT_GPIO_VEN, 95 ACPI_RSC_COUNT_SERIAL_RES, 96 ACPI_RSC_COUNT_SERIAL_VEN, 97 ACPI_RSC_DATA8, 98 ACPI_RSC_EXIT_EQ, 99 ACPI_RSC_EXIT_LE, 100 ACPI_RSC_EXIT_NE, 101 ACPI_RSC_LENGTH, 102 ACPI_RSC_MOVE_GPIO_PIN, 103 ACPI_RSC_MOVE_GPIO_RES, 104 ACPI_RSC_MOVE_SERIAL_RES, 105 ACPI_RSC_MOVE_SERIAL_VEN, 106 ACPI_RSC_MOVE8, 107 ACPI_RSC_MOVE16, 108 ACPI_RSC_MOVE32, 109 ACPI_RSC_MOVE64, 110 ACPI_RSC_SET8, 111 ACPI_RSC_SOURCE, 112 ACPI_RSC_SOURCEX 113 114 } ACPI_RSCONVERT_OPCODES; 115 116 /* Resource Conversion sub-opcodes */ 117 118 #define ACPI_RSC_COMPARE_AML_LENGTH 0 119 #define ACPI_RSC_COMPARE_VALUE 1 120 121 #define ACPI_RSC_TABLE_SIZE(d) (sizeof (d) / sizeof (ACPI_RSCONVERT_INFO)) 122 123 #define ACPI_RS_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_RESOURCE,f) 124 #define AML_OFFSET(f) (UINT8) ACPI_OFFSET (AML_RESOURCE,f) 125 126 127 /* 128 * Individual entry for the resource dump tables 129 */ 130 typedef const struct acpi_rsdump_info 131 { 132 UINT8 Opcode; 133 UINT8 Offset; 134 const char *Name; 135 const char **Pointer; 136 137 } ACPI_RSDUMP_INFO; 138 139 /* Values for the Opcode field above */ 140 141 typedef enum 142 { 143 ACPI_RSD_TITLE = 0, 144 ACPI_RSD_1BITFLAG, 145 ACPI_RSD_2BITFLAG, 146 ACPI_RSD_3BITFLAG, 147 ACPI_RSD_6BITFLAG, 148 ACPI_RSD_ADDRESS, 149 ACPI_RSD_DWORDLIST, 150 ACPI_RSD_LITERAL, 151 ACPI_RSD_LONGLIST, 152 ACPI_RSD_SHORTLIST, 153 ACPI_RSD_SHORTLISTX, 154 ACPI_RSD_SOURCE, 155 ACPI_RSD_STRING, 156 ACPI_RSD_UINT8, 157 ACPI_RSD_UINT16, 158 ACPI_RSD_UINT32, 159 ACPI_RSD_UINT64, 160 ACPI_RSD_WORDLIST, 161 ACPI_RSD_LABEL, 162 ACPI_RSD_SOURCE_LABEL, 163 164 } ACPI_RSDUMP_OPCODES; 165 166 /* restore default alignment */ 167 168 #pragma pack() 169 170 171 /* Resource tables indexed by internal resource type */ 172 173 extern const UINT8 AcpiGbl_AmlResourceSizes[]; 174 extern const UINT8 AcpiGbl_AmlResourceSerialBusSizes[]; 175 extern ACPI_RSCONVERT_INFO *AcpiGbl_SetResourceDispatch[]; 176 177 /* Resource tables indexed by raw AML resource descriptor type */ 178 179 extern const UINT8 AcpiGbl_ResourceStructSizes[]; 180 extern const UINT8 AcpiGbl_ResourceStructSerialBusSizes[]; 181 extern ACPI_RSCONVERT_INFO *AcpiGbl_GetResourceDispatch[]; 182 183 extern ACPI_RSCONVERT_INFO *AcpiGbl_ConvertResourceSerialBusDispatch[]; 184 185 typedef struct acpi_vendor_walk_info 186 { 187 ACPI_VENDOR_UUID *Uuid; 188 ACPI_BUFFER *Buffer; 189 ACPI_STATUS Status; 190 191 } ACPI_VENDOR_WALK_INFO; 192 193 194 /* 195 * rscreate 196 */ 197 ACPI_STATUS 198 AcpiRsCreateResourceList ( 199 ACPI_OPERAND_OBJECT *AmlBuffer, 200 ACPI_BUFFER *OutputBuffer); 201 202 ACPI_STATUS 203 AcpiRsCreateAmlResources ( 204 ACPI_BUFFER *ResourceList, 205 ACPI_BUFFER *OutputBuffer); 206 207 ACPI_STATUS 208 AcpiRsCreatePciRoutingTable ( 209 ACPI_OPERAND_OBJECT *PackageObject, 210 ACPI_BUFFER *OutputBuffer); 211 212 213 /* 214 * rsutils 215 */ 216 ACPI_STATUS 217 AcpiRsGetPrtMethodData ( 218 ACPI_NAMESPACE_NODE *Node, 219 ACPI_BUFFER *RetBuffer); 220 221 ACPI_STATUS 222 AcpiRsGetCrsMethodData ( 223 ACPI_NAMESPACE_NODE *Node, 224 ACPI_BUFFER *RetBuffer); 225 226 ACPI_STATUS 227 AcpiRsGetPrsMethodData ( 228 ACPI_NAMESPACE_NODE *Node, 229 ACPI_BUFFER *RetBuffer); 230 231 ACPI_STATUS 232 AcpiRsGetMethodData ( 233 ACPI_HANDLE Handle, 234 const char *Path, 235 ACPI_BUFFER *RetBuffer); 236 237 ACPI_STATUS 238 AcpiRsSetSrsMethodData ( 239 ACPI_NAMESPACE_NODE *Node, 240 ACPI_BUFFER *RetBuffer); 241 242 ACPI_STATUS 243 AcpiRsGetAeiMethodData ( 244 ACPI_NAMESPACE_NODE *Node, 245 ACPI_BUFFER *RetBuffer); 246 247 /* 248 * rscalc 249 */ 250 ACPI_STATUS 251 AcpiRsGetListLength ( 252 UINT8 *AmlBuffer, 253 UINT32 AmlBufferLength, 254 ACPI_SIZE *SizeNeeded); 255 256 ACPI_STATUS 257 AcpiRsGetAmlLength ( 258 ACPI_RESOURCE *ResourceList, 259 ACPI_SIZE ResourceListSize, 260 ACPI_SIZE *SizeNeeded); 261 262 ACPI_STATUS 263 AcpiRsGetPciRoutingTableLength ( 264 ACPI_OPERAND_OBJECT *PackageObject, 265 ACPI_SIZE *BufferSizeNeeded); 266 267 ACPI_STATUS 268 AcpiRsConvertAmlToResources ( 269 UINT8 *Aml, 270 UINT32 Length, 271 UINT32 Offset, 272 UINT8 ResourceIndex, 273 void **Context); 274 275 ACPI_STATUS 276 AcpiRsConvertResourcesToAml ( 277 ACPI_RESOURCE *Resource, 278 ACPI_SIZE AmlSizeNeeded, 279 UINT8 *OutputBuffer); 280 281 282 /* 283 * rsaddr 284 */ 285 void 286 AcpiRsSetAddressCommon ( 287 AML_RESOURCE *Aml, 288 ACPI_RESOURCE *Resource); 289 290 BOOLEAN 291 AcpiRsGetAddressCommon ( 292 ACPI_RESOURCE *Resource, 293 AML_RESOURCE *Aml); 294 295 296 /* 297 * rsmisc 298 */ 299 ACPI_STATUS 300 AcpiRsConvertAmlToResource ( 301 ACPI_RESOURCE *Resource, 302 AML_RESOURCE *Aml, 303 ACPI_RSCONVERT_INFO *Info); 304 305 ACPI_STATUS 306 AcpiRsConvertResourceToAml ( 307 ACPI_RESOURCE *Resource, 308 AML_RESOURCE *Aml, 309 ACPI_RSCONVERT_INFO *Info); 310 311 312 /* 313 * rsutils 314 */ 315 void 316 AcpiRsMoveData ( 317 void *Destination, 318 void *Source, 319 UINT16 ItemCount, 320 UINT8 MoveType); 321 322 UINT8 323 AcpiRsDecodeBitmask ( 324 UINT16 Mask, 325 UINT8 *List); 326 327 UINT16 328 AcpiRsEncodeBitmask ( 329 UINT8 *List, 330 UINT8 Count); 331 332 ACPI_RS_LENGTH 333 AcpiRsGetResourceSource ( 334 ACPI_RS_LENGTH ResourceLength, 335 ACPI_RS_LENGTH MinimumLength, 336 ACPI_RESOURCE_SOURCE *ResourceSource, 337 AML_RESOURCE *Aml, 338 char *StringPtr); 339 340 ACPI_RSDESC_SIZE 341 AcpiRsSetResourceSource ( 342 AML_RESOURCE *Aml, 343 ACPI_RS_LENGTH MinimumLength, 344 ACPI_RESOURCE_SOURCE *ResourceSource); 345 346 void 347 AcpiRsSetResourceHeader ( 348 UINT8 DescriptorType, 349 ACPI_RSDESC_SIZE TotalLength, 350 AML_RESOURCE *Aml); 351 352 void 353 AcpiRsSetResourceLength ( 354 ACPI_RSDESC_SIZE TotalLength, 355 AML_RESOURCE *Aml); 356 357 358 /* 359 * rsdump - Debugger support 360 */ 361 #ifdef ACPI_DEBUGGER 362 void 363 AcpiRsDumpResourceList ( 364 ACPI_RESOURCE *Resource); 365 366 void 367 AcpiRsDumpIrqList ( 368 UINT8 *RouteTable); 369 #endif 370 371 372 /* 373 * Resource conversion tables 374 */ 375 extern ACPI_RSCONVERT_INFO AcpiRsConvertDma[]; 376 extern ACPI_RSCONVERT_INFO AcpiRsConvertEndDpf[]; 377 extern ACPI_RSCONVERT_INFO AcpiRsConvertIo[]; 378 extern ACPI_RSCONVERT_INFO AcpiRsConvertFixedIo[]; 379 extern ACPI_RSCONVERT_INFO AcpiRsConvertEndTag[]; 380 extern ACPI_RSCONVERT_INFO AcpiRsConvertMemory24[]; 381 extern ACPI_RSCONVERT_INFO AcpiRsConvertGenericReg[]; 382 extern ACPI_RSCONVERT_INFO AcpiRsConvertMemory32[]; 383 extern ACPI_RSCONVERT_INFO AcpiRsConvertFixedMemory32[]; 384 extern ACPI_RSCONVERT_INFO AcpiRsConvertAddress32[]; 385 extern ACPI_RSCONVERT_INFO AcpiRsConvertAddress16[]; 386 extern ACPI_RSCONVERT_INFO AcpiRsConvertExtIrq[]; 387 extern ACPI_RSCONVERT_INFO AcpiRsConvertAddress64[]; 388 extern ACPI_RSCONVERT_INFO AcpiRsConvertExtAddress64[]; 389 extern ACPI_RSCONVERT_INFO AcpiRsConvertGpio[]; 390 extern ACPI_RSCONVERT_INFO AcpiRsConvertFixedDma[]; 391 extern ACPI_RSCONVERT_INFO AcpiRsConvertCsi2SerialBus[]; 392 extern ACPI_RSCONVERT_INFO AcpiRsConvertI2cSerialBus[]; 393 extern ACPI_RSCONVERT_INFO AcpiRsConvertSpiSerialBus[]; 394 extern ACPI_RSCONVERT_INFO AcpiRsConvertUartSerialBus[]; 395 extern ACPI_RSCONVERT_INFO AcpiRsConvertPinFunction[]; 396 extern ACPI_RSCONVERT_INFO AcpiRsConvertPinConfig[]; 397 extern ACPI_RSCONVERT_INFO AcpiRsConvertPinGroup[]; 398 extern ACPI_RSCONVERT_INFO AcpiRsConvertPinGroupFunction[]; 399 extern ACPI_RSCONVERT_INFO AcpiRsConvertPinGroupConfig[]; 400 401 /* These resources require separate get/set tables */ 402 403 extern ACPI_RSCONVERT_INFO AcpiRsGetIrq[]; 404 extern ACPI_RSCONVERT_INFO AcpiRsGetStartDpf[]; 405 extern ACPI_RSCONVERT_INFO AcpiRsGetVendorSmall[]; 406 extern ACPI_RSCONVERT_INFO AcpiRsGetVendorLarge[]; 407 408 extern ACPI_RSCONVERT_INFO AcpiRsSetIrq[]; 409 extern ACPI_RSCONVERT_INFO AcpiRsSetStartDpf[]; 410 extern ACPI_RSCONVERT_INFO AcpiRsSetVendor[]; 411 412 413 #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) 414 /* 415 * rsinfo 416 */ 417 extern ACPI_RSDUMP_INFO *AcpiGbl_DumpResourceDispatch[]; 418 extern ACPI_RSDUMP_INFO *AcpiGbl_DumpSerialBusDispatch[]; 419 420 /* 421 * rsdumpinfo 422 */ 423 extern ACPI_RSDUMP_INFO AcpiRsDumpIrq[]; 424 extern ACPI_RSDUMP_INFO AcpiRsDumpPrt[]; 425 extern ACPI_RSDUMP_INFO AcpiRsDumpDma[]; 426 extern ACPI_RSDUMP_INFO AcpiRsDumpStartDpf[]; 427 extern ACPI_RSDUMP_INFO AcpiRsDumpEndDpf[]; 428 extern ACPI_RSDUMP_INFO AcpiRsDumpIo[]; 429 extern ACPI_RSDUMP_INFO AcpiRsDumpIoFlags[]; 430 extern ACPI_RSDUMP_INFO AcpiRsDumpFixedIo[]; 431 extern ACPI_RSDUMP_INFO AcpiRsDumpVendor[]; 432 extern ACPI_RSDUMP_INFO AcpiRsDumpEndTag[]; 433 extern ACPI_RSDUMP_INFO AcpiRsDumpMemory24[]; 434 extern ACPI_RSDUMP_INFO AcpiRsDumpMemory32[]; 435 extern ACPI_RSDUMP_INFO AcpiRsDumpMemoryFlags[]; 436 extern ACPI_RSDUMP_INFO AcpiRsDumpFixedMemory32[]; 437 extern ACPI_RSDUMP_INFO AcpiRsDumpAddress16[]; 438 extern ACPI_RSDUMP_INFO AcpiRsDumpAddress32[]; 439 extern ACPI_RSDUMP_INFO AcpiRsDumpAddress64[]; 440 extern ACPI_RSDUMP_INFO AcpiRsDumpExtAddress64[]; 441 extern ACPI_RSDUMP_INFO AcpiRsDumpExtIrq[]; 442 extern ACPI_RSDUMP_INFO AcpiRsDumpGenericReg[]; 443 extern ACPI_RSDUMP_INFO AcpiRsDumpGpio[]; 444 extern ACPI_RSDUMP_INFO AcpiRsDumpPinFunction[]; 445 extern ACPI_RSDUMP_INFO AcpiRsDumpFixedDma[]; 446 extern ACPI_RSDUMP_INFO AcpiRsDumpCommonSerialBus[]; 447 extern ACPI_RSDUMP_INFO AcpiRsDumpCsi2SerialBus[]; 448 extern ACPI_RSDUMP_INFO AcpiRsDumpI2cSerialBus[]; 449 extern ACPI_RSDUMP_INFO AcpiRsDumpSpiSerialBus[]; 450 extern ACPI_RSDUMP_INFO AcpiRsDumpUartSerialBus[]; 451 extern ACPI_RSDUMP_INFO AcpiRsDumpGeneralFlags[]; 452 extern ACPI_RSDUMP_INFO AcpiRsDumpPinConfig[]; 453 extern ACPI_RSDUMP_INFO AcpiRsDumpPinGroup[]; 454 extern ACPI_RSDUMP_INFO AcpiRsDumpPinGroupFunction[]; 455 extern ACPI_RSDUMP_INFO AcpiRsDumpPinGroupConfig[]; 456 #endif 457 458 #endif /* __ACRESRC_H__ */ 459