1 /******************************************************************************
3 * Module Name: dmrestag - Add tags to resource descriptors (Application-level)
5 *****************************************************************************/
8 * Copyright (C) 2000 - 2011, Intel Corp.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
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.
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.
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.
45 #include <contrib/dev/acpica/include/acpi.h>
46 #include <contrib/dev/acpica/include/accommon.h>
47 #include <contrib/dev/acpica/include/acparser.h>
48 #include <contrib/dev/acpica/include/acdisasm.h>
49 #include <contrib/dev/acpica/include/acnamesp.h>
50 #include <contrib/dev/acpica/include/amlcode.h>
52 /* This module used for application-level code only */
54 #define _COMPONENT ACPI_CA_DISASSEMBLER
55 ACPI_MODULE_NAME ("dmrestag")
57 /* Local prototypes */
60 AcpiDmUpdateResourceName (
61 ACPI_NAMESPACE_NODE *ResourceNode);
66 ACPI_RESOURCE_TAG *TagList);
69 AcpiDmGetResourceTag (
71 AML_RESOURCE *Resource,
76 ACPI_NAMESPACE_NODE *BufferNode,
77 ACPI_NAMESPACE_NODE *ResourceNode,
80 static ACPI_NAMESPACE_NODE *
81 AcpiDmGetResourceNode (
82 ACPI_NAMESPACE_NODE *BufferNode,
86 AcpiDmAddResourceToNamespace (
94 AcpiDmAddResourcesToNamespace (
95 ACPI_NAMESPACE_NODE *BufferNode,
96 ACPI_PARSE_OBJECT *Op);
99 /******************************************************************************
101 * Resource Tag tables
103 * These are the predefined tags that refer to elements of a resource
104 * descriptor. Each name and offset is defined in the ACPI specification.
106 * Each table entry contains the bit offset of the field and the associated
109 ******************************************************************************/
111 static ACPI_RESOURCE_TAG AcpiDmIrqTags[] =
113 {( 1 * 8), ACPI_RESTAG_INTERRUPT},
114 {( 3 * 8) + 0, ACPI_RESTAG_INTERRUPTTYPE},
115 {( 3 * 8) + 3, ACPI_RESTAG_INTERRUPTLEVEL},
116 {( 3 * 8) + 4, ACPI_RESTAG_INTERRUPTSHARE},
120 static ACPI_RESOURCE_TAG AcpiDmDmaTags[] =
122 {( 1 * 8), ACPI_RESTAG_DMA},
123 {( 2 * 8) + 0, ACPI_RESTAG_XFERTYPE},
124 {( 2 * 8) + 2, ACPI_RESTAG_BUSMASTER},
125 {( 2 * 8) + 5, ACPI_RESTAG_DMATYPE},
129 static ACPI_RESOURCE_TAG AcpiDmIoTags[] =
131 {( 1 * 8) + 0, ACPI_RESTAG_DECODE},
132 {( 2 * 8), ACPI_RESTAG_MINADDR},
133 {( 4 * 8), ACPI_RESTAG_MAXADDR},
134 {( 6 * 8), ACPI_RESTAG_ALIGNMENT},
135 {( 7 * 8), ACPI_RESTAG_LENGTH},
139 static ACPI_RESOURCE_TAG AcpiDmFixedIoTags[] =
141 {( 1 * 8), ACPI_RESTAG_BASEADDRESS},
142 {( 3 * 8), ACPI_RESTAG_LENGTH},
146 static ACPI_RESOURCE_TAG AcpiDmMemory24Tags[] =
148 {( 3 * 8) + 0, ACPI_RESTAG_READWRITETYPE},
149 {( 4 * 8), ACPI_RESTAG_MINADDR},
150 {( 6 * 8), ACPI_RESTAG_MAXADDR},
151 {( 8 * 8), ACPI_RESTAG_ALIGNMENT},
152 {(10 * 8), ACPI_RESTAG_LENGTH},
156 static ACPI_RESOURCE_TAG AcpiDmRegisterTags[] =
158 {( 3 * 8), ACPI_RESTAG_ADDRESSSPACE},
159 {( 4 * 8), ACPI_RESTAG_REGISTERBITWIDTH},
160 {( 5 * 8), ACPI_RESTAG_REGISTERBITOFFSET},
161 {( 6 * 8), ACPI_RESTAG_ACCESSSIZE},
162 {( 7 * 8), ACPI_RESTAG_ADDRESS},
166 static ACPI_RESOURCE_TAG AcpiDmMemory32Tags[] =
168 {( 3 * 8) + 0, ACPI_RESTAG_READWRITETYPE},
169 {( 4 * 8), ACPI_RESTAG_MINADDR},
170 {( 8 * 8), ACPI_RESTAG_MAXADDR},
171 {(12 * 8), ACPI_RESTAG_ALIGNMENT},
172 {(16 * 8), ACPI_RESTAG_LENGTH},
176 static ACPI_RESOURCE_TAG AcpiDmFixedMemory32Tags[] =
178 {( 3 * 8) + 0, ACPI_RESTAG_READWRITETYPE},
179 {( 4 * 8), ACPI_RESTAG_BASEADDRESS},
180 {( 8 * 8), ACPI_RESTAG_LENGTH},
184 static ACPI_RESOURCE_TAG AcpiDmInterruptTags[] =
186 {( 3 * 8) + 1, ACPI_RESTAG_INTERRUPTTYPE},
187 {( 3 * 8) + 2, ACPI_RESTAG_INTERRUPTLEVEL},
188 {( 3 * 8) + 3, ACPI_RESTAG_INTERRUPTSHARE},
189 {( 5 * 8), ACPI_RESTAG_INTERRUPT},
193 static ACPI_RESOURCE_TAG AcpiDmAddress16Tags[] =
195 {( 4 * 8) + 1, ACPI_RESTAG_DECODE},
196 {( 4 * 8) + 2, ACPI_RESTAG_MINTYPE},
197 {( 4 * 8) + 3, ACPI_RESTAG_MAXTYPE},
198 {( 6 * 8), ACPI_RESTAG_GRANULARITY},
199 {( 8 * 8), ACPI_RESTAG_MINADDR},
200 {(10 * 8), ACPI_RESTAG_MAXADDR},
201 {(12 * 8), ACPI_RESTAG_TRANSLATION},
202 {(14 * 8), ACPI_RESTAG_LENGTH},
206 static ACPI_RESOURCE_TAG AcpiDmAddress32Tags[] =
208 {( 4 * 8) + 1, ACPI_RESTAG_DECODE},
209 {( 4 * 8) + 2, ACPI_RESTAG_MINTYPE},
210 {( 4 * 8) + 3, ACPI_RESTAG_MAXTYPE},
211 {( 6 * 8), ACPI_RESTAG_GRANULARITY},
212 {(10 * 8), ACPI_RESTAG_MINADDR},
213 {(14 * 8), ACPI_RESTAG_MAXADDR},
214 {(18 * 8), ACPI_RESTAG_TRANSLATION},
215 {(22 * 8), ACPI_RESTAG_LENGTH},
219 static ACPI_RESOURCE_TAG AcpiDmAddress64Tags[] =
221 {( 4 * 8) + 1, ACPI_RESTAG_DECODE},
222 {( 4 * 8) + 2, ACPI_RESTAG_MINTYPE},
223 {( 4 * 8) + 3, ACPI_RESTAG_MAXTYPE},
224 {( 6 * 8), ACPI_RESTAG_GRANULARITY},
225 {(14 * 8), ACPI_RESTAG_MINADDR},
226 {(22 * 8), ACPI_RESTAG_MAXADDR},
227 {(30 * 8), ACPI_RESTAG_TRANSLATION},
228 {(38 * 8), ACPI_RESTAG_LENGTH},
232 static ACPI_RESOURCE_TAG AcpiDmExtendedAddressTags[] =
234 {( 4 * 8) + 1, ACPI_RESTAG_DECODE},
235 {( 4 * 8) + 2, ACPI_RESTAG_MINTYPE},
236 {( 4 * 8) + 3, ACPI_RESTAG_MAXTYPE},
237 {( 8 * 8), ACPI_RESTAG_GRANULARITY},
238 {(16 * 8), ACPI_RESTAG_MINADDR},
239 {(24 * 8), ACPI_RESTAG_MAXADDR},
240 {(32 * 8), ACPI_RESTAG_TRANSLATION},
241 {(40 * 8), ACPI_RESTAG_LENGTH},
242 {(48 * 8), ACPI_RESTAG_TYPESPECIFICATTRIBUTES},
246 /* Special-case tables for the type-specific flags */
248 static ACPI_RESOURCE_TAG AcpiDmMemoryFlagTags[] =
250 {( 5 * 8) + 0, ACPI_RESTAG_READWRITETYPE},
251 {( 5 * 8) + 1, ACPI_RESTAG_MEMTYPE},
252 {( 5 * 8) + 3, ACPI_RESTAG_MEMATTRIBUTES},
253 {( 5 * 8) + 5, ACPI_RESTAG_TYPE},
257 static ACPI_RESOURCE_TAG AcpiDmIoFlagTags[] =
259 {( 5 * 8) + 0, ACPI_RESTAG_RANGETYPE},
260 {( 5 * 8) + 4, ACPI_RESTAG_TYPE},
261 {( 5 * 8) + 5, ACPI_RESTAG_TRANSTYPE},
266 /* Dispatch table used to obtain the correct tag table for a descriptor */
268 static ACPI_RESOURCE_TAG *AcpiGbl_ResourceTags [] =
270 /* Small descriptors */
272 NULL, /* 0x00, Reserved */
273 NULL, /* 0x01, Reserved */
274 NULL, /* 0x02, Reserved */
275 NULL, /* 0x03, Reserved */
276 AcpiDmIrqTags, /* 0x04, ACPI_RESOURCE_NAME_IRQ_FORMAT */
277 AcpiDmDmaTags, /* 0x05, ACPI_RESOURCE_NAME_DMA_FORMAT */
278 NULL, /* 0x06, ACPI_RESOURCE_NAME_START_DEPENDENT */
279 NULL, /* 0x07, ACPI_RESOURCE_NAME_END_DEPENDENT */
280 AcpiDmIoTags, /* 0x08, ACPI_RESOURCE_NAME_IO_PORT */
281 AcpiDmFixedIoTags, /* 0x09, ACPI_RESOURCE_NAME_FIXED_IO_PORT */
282 NULL, /* 0x0A, Reserved */
283 NULL, /* 0x0B, Reserved */
284 NULL, /* 0x0C, Reserved */
285 NULL, /* 0x0D, Reserved */
286 NULL, /* 0x0E, ACPI_RESOURCE_NAME_SMALL_VENDOR */
287 NULL, /* 0x0F, ACPI_RESOURCE_NAME_END_TAG (not used) */
289 /* Large descriptors */
291 NULL, /* 0x00, Reserved */
292 AcpiDmMemory24Tags, /* 0x01, ACPI_RESOURCE_NAME_MEMORY_24 */
293 AcpiDmRegisterTags, /* 0x02, ACPI_RESOURCE_NAME_GENERIC_REGISTER */
294 NULL, /* 0x03, Reserved */
295 NULL, /* 0x04, ACPI_RESOURCE_NAME_LARGE_VENDOR */
296 AcpiDmMemory32Tags, /* 0x05, ACPI_RESOURCE_NAME_MEMORY_32 */
297 AcpiDmFixedMemory32Tags, /* 0x06, ACPI_RESOURCE_NAME_FIXED_MEMORY_32 */
298 AcpiDmAddress32Tags, /* 0x07, ACPI_RESOURCE_NAME_DWORD_ADDRESS_SPACE */
299 AcpiDmAddress16Tags, /* 0x08, ACPI_RESOURCE_NAME_WORD_ADDRESS_SPACE */
300 AcpiDmInterruptTags, /* 0x09, ACPI_RESOURCE_NAME_EXTENDED_XRUPT */
301 AcpiDmAddress64Tags, /* 0x0A, ACPI_RESOURCE_NAME_QWORD_ADDRESS_SPACE */
302 AcpiDmExtendedAddressTags /* 0x0B, ACPI_RESOURCE_NAME_EXTENDED_ADDRESS_SPACE */
307 * Globals used to generate unique resource descriptor names. We use names that
308 * start with underscore and a prefix letter that is not used by other ACPI
309 * reserved names. To this, we append hex 0x00 through 0xFF. These 5 prefixes
310 * allow for 5*256 = 1280 unique names, probably sufficient for any single ASL
311 * file. If this becomes too small, we can use alpha+numerals for a total
314 #define ACPI_NUM_RES_PREFIX 5
316 static UINT32 AcpiGbl_NextResourceId = 0;
317 static UINT8 AcpiGbl_NextPrefix = 0;
318 static char AcpiGbl_Prefix[ACPI_NUM_RES_PREFIX] =
319 {'Y','Z','J','K','X'};
322 /*******************************************************************************
324 * FUNCTION: AcpiDmCheckResourceReference
326 * PARAMETERS: Op - Parse Op for the AML opcode
327 * WalkState - Current walk state (with valid scope)
331 * DESCRIPTION: Convert a reference to a resource descriptor to a symbolic
332 * reference if possible
334 * NOTE: Bit index is used to transparently handle both resource bit
335 * fields and byte fields.
337 ******************************************************************************/
340 AcpiDmCheckResourceReference (
341 ACPI_PARSE_OBJECT *Op,
342 ACPI_WALK_STATE *WalkState)
345 ACPI_PARSE_OBJECT *BufferNameOp;
346 ACPI_PARSE_OBJECT *IndexOp;
347 ACPI_NAMESPACE_NODE *BufferNode;
348 ACPI_NAMESPACE_NODE *ResourceNode;
349 const ACPI_OPCODE_INFO *OpInfo;
354 /* We are only interested in the CreateXxxxField opcodes */
356 OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
357 if (OpInfo->Type != AML_TYPE_CREATE_FIELD)
362 /* Get the buffer term operand */
364 BufferNameOp = AcpiPsGetDepthNext (NULL, Op);
366 /* Must be a named buffer, not an arg or local or method call */
368 if (BufferNameOp->Common.AmlOpcode != AML_INT_NAMEPATH_OP)
373 /* Get the Index term, must be an integer constant to convert */
375 IndexOp = BufferNameOp->Common.Next;
376 OpInfo = AcpiPsGetOpcodeInfo (IndexOp->Common.AmlOpcode);
377 if (OpInfo->ObjectType != ACPI_TYPE_INTEGER)
382 /* Get the bit offset of the descriptor within the buffer */
384 if ((Op->Common.AmlOpcode == AML_CREATE_BIT_FIELD_OP) ||
385 (Op->Common.AmlOpcode == AML_CREATE_FIELD_OP))
387 /* Index operand is a bit offset */
389 BitIndex = (UINT32) IndexOp->Common.Value.Integer;
393 /* Index operand is a byte offset, convert to bits */
395 BitIndex = (UINT32) ACPI_MUL_8 (IndexOp->Common.Value.Integer);
398 /* Lookup the buffer in the namespace */
400 Status = AcpiNsLookup (WalkState->ScopeInfo,
401 BufferNameOp->Common.Value.String, ACPI_TYPE_BUFFER,
402 ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, WalkState,
404 if (ACPI_FAILURE (Status))
409 /* Validate object type, we must have a buffer */
411 if (BufferNode->Type != ACPI_TYPE_BUFFER)
416 /* Find the resource descriptor node corresponding to the index */
418 ResourceNode = AcpiDmGetResourceNode (BufferNode, BitIndex);
424 /* Translate the Index to a resource tag pathname */
426 Pathname = AcpiGetTagPathname (BufferNode, ResourceNode, BitIndex);
429 /* Complete the conversion of the Index to a symbol */
431 IndexOp->Common.AmlOpcode = AML_INT_NAMEPATH_OP;
432 IndexOp->Common.Value.String = Pathname;
437 /*******************************************************************************
439 * FUNCTION: AcpiDmGetResourceNode
441 * PARAMETERS: BufferNode - Node for the parent buffer
442 * BitIndex - Index into the resource descriptor
444 * RETURN: Namespace node for the resource descriptor. NULL if not found
446 * DESCRIPTION: Find a resource descriptor that corresponds to the bit index
448 ******************************************************************************/
450 static ACPI_NAMESPACE_NODE *
451 AcpiDmGetResourceNode (
452 ACPI_NAMESPACE_NODE *BufferNode,
455 ACPI_NAMESPACE_NODE *Node;
456 UINT32 ByteIndex = ACPI_DIV_8 (BitIndex);
460 * Child list contains an entry for each resource descriptor. Find
461 * the descriptor that corresponds to the Index.
463 * If there are no children, this is not a resource template
465 Node = BufferNode->Child;
469 * Check if the Index falls within this resource.
471 * Value contains the resource offset, Object contains the resource
472 * length (both in bytes)
474 if ((ByteIndex >= Node->Value) &&
475 (ByteIndex < (Node->Value + Node->Length)))
487 /*******************************************************************************
489 * FUNCTION: AcpiGetTagPathname
491 * PARAMETERS: BufferNode - Node for the parent buffer
492 * ResourceNode - Node for a resource descriptor
493 * BitIndex - Index into the resource descriptor
495 * RETURN: Full pathname for a resource tag. NULL if no match.
496 * Path is returned in AML (packed) format.
498 * DESCRIPTION: Convert a BitIndex into a symbolic resource tag (full pathname)
500 ******************************************************************************/
504 ACPI_NAMESPACE_NODE *BufferNode,
505 ACPI_NAMESPACE_NODE *ResourceNode,
509 UINT32 ResourceBitIndex;
510 UINT8 ResourceTableIndex;
511 ACPI_SIZE RequiredSize;
514 ACPI_PARSE_OBJECT *Op;
519 /* Get the Op that contains the actual buffer data */
521 Op = BufferNode->Op->Common.Value.Arg;
522 Op = Op->Common.Next;
528 /* Get the individual resource descriptor and validate it */
530 Aml = ACPI_CAST_PTR (AML_RESOURCE,
531 &Op->Named.Data[ResourceNode->Value]);
533 Status = AcpiUtValidateResource (Aml, &ResourceTableIndex);
534 if (ACPI_FAILURE (Status))
539 /* Get offset into this descriptor (from offset into entire buffer) */
541 ResourceBitIndex = BitIndex - ACPI_MUL_8 (ResourceNode->Value);
543 /* Get the tag associated with this resource descriptor and offset */
545 Tag = AcpiDmGetResourceTag (ResourceBitIndex, Aml, ResourceTableIndex);
552 * Now that we know that we have a reference that can be converted to a
553 * symbol, change the name of the resource to a unique name.
555 AcpiDmUpdateResourceName (ResourceNode);
557 /* Get the full pathname to the parent buffer */
559 RequiredSize = AcpiNsGetPathnameLength (BufferNode);
565 Pathname = ACPI_ALLOCATE_ZEROED (RequiredSize + ACPI_PATH_SEGMENT_LENGTH);
571 Status = AcpiNsBuildExternalPath (BufferNode, RequiredSize, Pathname);
572 if (ACPI_FAILURE (Status))
578 * Create the full path to the resource and tag by: remove the buffer name,
579 * append the resource descriptor name, append a dot, append the tag name.
581 * TBD: Always using the full path is a bit brute force, the path can be
582 * often be optimized with carats (if the original buffer namepath is a
583 * single nameseg). This doesn't really matter, because these paths do not
584 * end up in the final compiled AML, it's just an appearance issue for the
587 Pathname[ACPI_STRLEN (Pathname) - ACPI_NAME_SIZE] = 0;
588 ACPI_STRNCAT (Pathname, ResourceNode->Name.Ascii, ACPI_NAME_SIZE);
589 ACPI_STRCAT (Pathname, ".");
590 ACPI_STRNCAT (Pathname, Tag, ACPI_NAME_SIZE);
592 /* Internalize the namepath to AML format */
594 AcpiNsInternalizeName (Pathname, &InternalPath);
595 ACPI_FREE (Pathname);
596 return (InternalPath);
600 /*******************************************************************************
602 * FUNCTION: AcpiDmUpdateResourceName
604 * PARAMETERS: ResourceNode - Node for a resource descriptor
606 * RETURN: Stores new name in the ResourceNode
608 * DESCRIPTION: Create a new, unique name for a resource descriptor. Used by
609 * both the disassembly of the descriptor itself and any symbolic
610 * references to the descriptor. Ignored if a unique name has
611 * already been assigned to the resource.
613 * NOTE: Single threaded, suitable for applications only!
615 ******************************************************************************/
618 AcpiDmUpdateResourceName (
619 ACPI_NAMESPACE_NODE *ResourceNode)
621 char Name[ACPI_NAME_SIZE];
624 /* Ignore if a unique name has already been assigned */
626 if (ResourceNode->Name.Integer != ACPI_DEFAULT_RESNAME)
631 /* Generate a new ACPI name for the descriptor */
634 Name[1] = AcpiGbl_Prefix[AcpiGbl_NextPrefix];
635 Name[2] = AcpiUtHexToAsciiChar ((UINT64) AcpiGbl_NextResourceId, 4);
636 Name[3] = AcpiUtHexToAsciiChar ((UINT64) AcpiGbl_NextResourceId, 0);
638 /* Update globals for next name */
640 AcpiGbl_NextResourceId++;
641 if (AcpiGbl_NextResourceId >= 256)
643 AcpiGbl_NextResourceId = 0;
644 AcpiGbl_NextPrefix++;
645 if (AcpiGbl_NextPrefix > ACPI_NUM_RES_PREFIX)
647 AcpiGbl_NextPrefix = 0;
651 /* Change the resource descriptor name */
653 ResourceNode->Name.Integer = *ACPI_CAST_PTR (UINT32, &Name[0]);
657 /*******************************************************************************
659 * FUNCTION: AcpiDmGetResourceTag
661 * PARAMETERS: BitIndex - Index into the resource descriptor
662 * Resource - Pointer to the raw resource data
663 * ResourceIndex - Index correspoinding to the resource type
665 * RETURN: Pointer to the resource tag (ACPI_NAME). NULL if no match.
667 * DESCRIPTION: Convert a BitIndex into a symbolic resource tag.
669 ******************************************************************************/
672 AcpiDmGetResourceTag (
674 AML_RESOURCE *Resource,
677 ACPI_RESOURCE_TAG *TagList;
681 /* Get the tag list for this resource descriptor type */
683 TagList = AcpiGbl_ResourceTags[ResourceIndex];
686 /* There are no tags for this resource type */
692 * Handle the type-specific flags field for the address descriptors.
693 * Kindof brute force, but just blindly search for an index match.
695 switch (Resource->DescriptorType)
697 case ACPI_RESOURCE_NAME_ADDRESS16:
698 case ACPI_RESOURCE_NAME_ADDRESS32:
699 case ACPI_RESOURCE_NAME_ADDRESS64:
700 case ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64:
702 if (Resource->Address.ResourceType == ACPI_ADDRESS_TYPE_MEMORY_RANGE)
704 Tag = AcpiDmSearchTagList (BitIndex, AcpiDmMemoryFlagTags);
706 else if (Resource->Address.ResourceType == ACPI_ADDRESS_TYPE_IO_RANGE)
708 Tag = AcpiDmSearchTagList (BitIndex, AcpiDmIoFlagTags);
711 /* If we found a match, all done. Else, drop to normal search below */
723 /* Search the tag list for this descriptor type */
725 Tag = AcpiDmSearchTagList (BitIndex, TagList);
730 /*******************************************************************************
732 * FUNCTION: AcpiDmSearchTagList
734 * PARAMETERS: BitIndex - Index into the resource descriptor
735 * TagList - List to search
737 * RETURN: Pointer to a tag (ACPI_NAME). NULL if no match found.
739 * DESCRIPTION: Search a tag list for a match to the input BitIndex. Matches
740 * a fixed offset to a symbolic resource tag name.
742 ******************************************************************************/
745 AcpiDmSearchTagList (
747 ACPI_RESOURCE_TAG *TagList)
751 * Walk the null-terminated tag list to find a matching bit offset.
752 * We are looking for an exact match.
754 for ( ; TagList->Tag; TagList++)
756 if (BitIndex == TagList->BitIndex)
758 return (TagList->Tag);
762 /* A matching offset was not found */
768 /*******************************************************************************
770 * FUNCTION: AcpiDmFindResources
772 * PARAMETERS: Root - Root of the parse tree
776 * DESCRIPTION: Add all ResourceTemplate declarations to the namespace. Each
777 * resource descriptor in each template is given a node -- used
778 * for later conversion of resource references to symbolic refs.
780 ******************************************************************************/
783 AcpiDmFindResources (
784 ACPI_PARSE_OBJECT *Root)
786 ACPI_PARSE_OBJECT *Op = Root;
787 ACPI_PARSE_OBJECT *Parent;
790 /* Walk the entire parse tree */
794 /* We are interested in Buffer() declarations */
796 if (Op->Common.AmlOpcode == AML_BUFFER_OP)
798 /* And only declarations of the form Name (XXXX, Buffer()... ) */
800 Parent = Op->Common.Parent;
801 if (Parent->Common.AmlOpcode == AML_NAME_OP)
804 * If the buffer is a resource template, add the individual
805 * resource descriptors to the namespace, as children of the
808 if (ACPI_SUCCESS (AcpiDmIsResourceTemplate (Op)))
810 Op->Common.DisasmOpcode = ACPI_DASM_RESOURCE;
811 AcpiDmAddResourcesToNamespace (Parent->Common.Node, Op);
816 Op = AcpiPsGetDepthNext (Root, Op);
821 /*******************************************************************************
823 * FUNCTION: AcpiDmAddResourcesToNamespace
825 * PARAMETERS: BufferNode - Node for the parent buffer
826 * Op - Parse op for the buffer
830 * DESCRIPTION: Add an entire resource template to the namespace. Each
831 * resource descriptor is added as a namespace node.
833 ******************************************************************************/
836 AcpiDmAddResourcesToNamespace (
837 ACPI_NAMESPACE_NODE *BufferNode,
838 ACPI_PARSE_OBJECT *Op)
840 ACPI_PARSE_OBJECT *NextOp;
843 /* Get to the ByteData list */
845 NextOp = Op->Common.Value.Arg;
846 NextOp = NextOp->Common.Next;
852 /* Set Node and Op to point to each other */
855 Op->Common.Node = BufferNode;
858 * Insert each resource into the namespace
859 * NextOp contains the Aml pointer and the Aml length
861 AcpiUtWalkAmlResources ((UINT8 *) NextOp->Named.Data,
862 (ACPI_SIZE) NextOp->Common.Value.Integer,
863 AcpiDmAddResourceToNamespace, BufferNode);
867 /*******************************************************************************
869 * FUNCTION: AcpiDmAddResourceToNamespace
871 * PARAMETERS: ACPI_WALK_AML_CALLBACK
872 * BufferNode - Node for the parent buffer
876 * DESCRIPTION: Add one resource descriptor to the namespace as a child of the
877 * parent buffer. The same name is used for each descriptor. This
878 * is changed later to a unique name if the resource is actually
879 * referenced by an AML operator.
881 ******************************************************************************/
884 AcpiDmAddResourceToNamespace (
892 ACPI_GENERIC_STATE ScopeInfo;
893 ACPI_NAMESPACE_NODE *Node;
896 /* TBD: Don't need to add descriptors that have no tags defined? */
898 /* Add the resource to the namespace, as child of the buffer */
900 ScopeInfo.Scope.Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Context);
901 Status = AcpiNsLookup (&ScopeInfo, "_TMP", ACPI_TYPE_LOCAL_RESOURCE,
902 ACPI_IMODE_LOAD_PASS2,
903 ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE | ACPI_NS_PREFIX_IS_SCOPE,
905 if (ACPI_FAILURE (Status))
910 /* Set the name to the default, changed later if resource is referenced */
912 Node->Name.Integer = ACPI_DEFAULT_RESNAME;
914 /* Save the offset of the descriptor (within the original buffer) */
916 Node->Value = Offset;
917 Node->Length = Length;