1 /*******************************************************************************
3 * Module Name: rsaddr - Address resource descriptors (16/32/64)
5 ******************************************************************************/
8 * Copyright (C) 2000 - 2015, 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.
48 #define _COMPONENT ACPI_RESOURCES
49 ACPI_MODULE_NAME ("rsaddr")
52 /*******************************************************************************
54 * AcpiRsConvertAddress16 - All WORD (16-bit) address resources
56 ******************************************************************************/
58 ACPI_RSCONVERT_INFO AcpiRsConvertAddress16[5] =
60 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_ADDRESS16,
61 ACPI_RS_SIZE (ACPI_RESOURCE_ADDRESS16),
62 ACPI_RSC_TABLE_SIZE (AcpiRsConvertAddress16)},
64 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_ADDRESS16,
65 sizeof (AML_RESOURCE_ADDRESS16),
68 /* Resource Type, General Flags, and Type-Specific Flags */
70 {ACPI_RSC_ADDRESS, 0, 0, 0},
73 * These fields are contiguous in both the source and destination:
75 * Address Range Minimum
76 * Address Range Maximum
77 * Address Translation Offset
80 {ACPI_RSC_MOVE16, ACPI_RS_OFFSET (Data.Address16.Address.Granularity),
81 AML_OFFSET (Address16.Granularity),
84 /* Optional ResourceSource (Index and String) */
86 {ACPI_RSC_SOURCE, ACPI_RS_OFFSET (Data.Address16.ResourceSource),
88 sizeof (AML_RESOURCE_ADDRESS16)}
92 /*******************************************************************************
94 * AcpiRsConvertAddress32 - All DWORD (32-bit) address resources
96 ******************************************************************************/
98 ACPI_RSCONVERT_INFO AcpiRsConvertAddress32[5] =
100 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_ADDRESS32,
101 ACPI_RS_SIZE (ACPI_RESOURCE_ADDRESS32),
102 ACPI_RSC_TABLE_SIZE (AcpiRsConvertAddress32)},
104 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_ADDRESS32,
105 sizeof (AML_RESOURCE_ADDRESS32),
108 /* Resource Type, General Flags, and Type-Specific Flags */
110 {ACPI_RSC_ADDRESS, 0, 0, 0},
113 * These fields are contiguous in both the source and destination:
114 * Address Granularity
115 * Address Range Minimum
116 * Address Range Maximum
117 * Address Translation Offset
120 {ACPI_RSC_MOVE32, ACPI_RS_OFFSET (Data.Address32.Address.Granularity),
121 AML_OFFSET (Address32.Granularity),
124 /* Optional ResourceSource (Index and String) */
126 {ACPI_RSC_SOURCE, ACPI_RS_OFFSET (Data.Address32.ResourceSource),
128 sizeof (AML_RESOURCE_ADDRESS32)}
132 /*******************************************************************************
134 * AcpiRsConvertAddress64 - All QWORD (64-bit) address resources
136 ******************************************************************************/
138 ACPI_RSCONVERT_INFO AcpiRsConvertAddress64[5] =
140 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_ADDRESS64,
141 ACPI_RS_SIZE (ACPI_RESOURCE_ADDRESS64),
142 ACPI_RSC_TABLE_SIZE (AcpiRsConvertAddress64)},
144 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_ADDRESS64,
145 sizeof (AML_RESOURCE_ADDRESS64),
148 /* Resource Type, General Flags, and Type-Specific Flags */
150 {ACPI_RSC_ADDRESS, 0, 0, 0},
153 * These fields are contiguous in both the source and destination:
154 * Address Granularity
155 * Address Range Minimum
156 * Address Range Maximum
157 * Address Translation Offset
160 {ACPI_RSC_MOVE64, ACPI_RS_OFFSET (Data.Address64.Address.Granularity),
161 AML_OFFSET (Address64.Granularity),
164 /* Optional ResourceSource (Index and String) */
166 {ACPI_RSC_SOURCE, ACPI_RS_OFFSET (Data.Address64.ResourceSource),
168 sizeof (AML_RESOURCE_ADDRESS64)}
172 /*******************************************************************************
174 * AcpiRsConvertExtAddress64 - All Extended (64-bit) address resources
176 ******************************************************************************/
178 ACPI_RSCONVERT_INFO AcpiRsConvertExtAddress64[5] =
180 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64,
181 ACPI_RS_SIZE (ACPI_RESOURCE_EXTENDED_ADDRESS64),
182 ACPI_RSC_TABLE_SIZE (AcpiRsConvertExtAddress64)},
184 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64,
185 sizeof (AML_RESOURCE_EXTENDED_ADDRESS64),
188 /* Resource Type, General Flags, and Type-Specific Flags */
190 {ACPI_RSC_ADDRESS, 0, 0, 0},
194 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.ExtAddress64.RevisionID),
195 AML_OFFSET (ExtAddress64.RevisionID),
198 * These fields are contiguous in both the source and destination:
199 * Address Granularity
200 * Address Range Minimum
201 * Address Range Maximum
202 * Address Translation Offset
204 * Type-Specific Attribute
206 {ACPI_RSC_MOVE64, ACPI_RS_OFFSET (Data.ExtAddress64.Address.Granularity),
207 AML_OFFSET (ExtAddress64.Granularity),
212 /*******************************************************************************
214 * AcpiRsConvertGeneralFlags - Flags common to all address descriptors
216 ******************************************************************************/
218 static ACPI_RSCONVERT_INFO AcpiRsConvertGeneralFlags[6] =
220 {ACPI_RSC_FLAGINIT, 0, AML_OFFSET (Address.Flags),
221 ACPI_RSC_TABLE_SIZE (AcpiRsConvertGeneralFlags)},
223 /* Resource Type (Memory, Io, BusNumber, etc.) */
225 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.Address.ResourceType),
226 AML_OFFSET (Address.ResourceType),
229 /* General Flags - Consume, Decode, MinFixed, MaxFixed */
231 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Address.ProducerConsumer),
232 AML_OFFSET (Address.Flags),
235 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Address.Decode),
236 AML_OFFSET (Address.Flags),
239 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Address.MinAddressFixed),
240 AML_OFFSET (Address.Flags),
243 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Address.MaxAddressFixed),
244 AML_OFFSET (Address.Flags),
249 /*******************************************************************************
251 * AcpiRsConvertMemFlags - Flags common to Memory address descriptors
253 ******************************************************************************/
255 static ACPI_RSCONVERT_INFO AcpiRsConvertMemFlags[5] =
257 {ACPI_RSC_FLAGINIT, 0, AML_OFFSET (Address.SpecificFlags),
258 ACPI_RSC_TABLE_SIZE (AcpiRsConvertMemFlags)},
260 /* Memory-specific flags */
262 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Address.Info.Mem.WriteProtect),
263 AML_OFFSET (Address.SpecificFlags),
266 {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.Address.Info.Mem.Caching),
267 AML_OFFSET (Address.SpecificFlags),
270 {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.Address.Info.Mem.RangeType),
271 AML_OFFSET (Address.SpecificFlags),
274 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Address.Info.Mem.Translation),
275 AML_OFFSET (Address.SpecificFlags),
280 /*******************************************************************************
282 * AcpiRsConvertIoFlags - Flags common to I/O address descriptors
284 ******************************************************************************/
286 static ACPI_RSCONVERT_INFO AcpiRsConvertIoFlags[4] =
288 {ACPI_RSC_FLAGINIT, 0, AML_OFFSET (Address.SpecificFlags),
289 ACPI_RSC_TABLE_SIZE (AcpiRsConvertIoFlags)},
291 /* I/O-specific flags */
293 {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.Address.Info.Io.RangeType),
294 AML_OFFSET (Address.SpecificFlags),
297 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Address.Info.Io.Translation),
298 AML_OFFSET (Address.SpecificFlags),
301 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Address.Info.Io.TranslationType),
302 AML_OFFSET (Address.SpecificFlags),
307 /*******************************************************************************
309 * FUNCTION: AcpiRsGetAddressCommon
311 * PARAMETERS: Resource - Pointer to the internal resource struct
312 * Aml - Pointer to the AML resource descriptor
314 * RETURN: TRUE if the ResourceType field is OK, FALSE otherwise
316 * DESCRIPTION: Convert common flag fields from a raw AML resource descriptor
317 * to an internal resource descriptor
319 ******************************************************************************/
322 AcpiRsGetAddressCommon (
323 ACPI_RESOURCE *Resource,
326 ACPI_FUNCTION_ENTRY ();
329 /* Validate the Resource Type */
331 if ((Aml->Address.ResourceType > 2) && (Aml->Address.ResourceType < 0xC0))
336 /* Get the Resource Type and General Flags */
338 (void) AcpiRsConvertAmlToResource (Resource, Aml, AcpiRsConvertGeneralFlags);
340 /* Get the Type-Specific Flags (Memory and I/O descriptors only) */
342 if (Resource->Data.Address.ResourceType == ACPI_MEMORY_RANGE)
344 (void) AcpiRsConvertAmlToResource (Resource, Aml, AcpiRsConvertMemFlags);
346 else if (Resource->Data.Address.ResourceType == ACPI_IO_RANGE)
348 (void) AcpiRsConvertAmlToResource (Resource, Aml, AcpiRsConvertIoFlags);
352 /* Generic resource type, just grab the TypeSpecific byte */
354 Resource->Data.Address.Info.TypeSpecific = Aml->Address.SpecificFlags;
361 /*******************************************************************************
363 * FUNCTION: AcpiRsSetAddressCommon
365 * PARAMETERS: Aml - Pointer to the AML resource descriptor
366 * Resource - Pointer to the internal resource struct
370 * DESCRIPTION: Convert common flag fields from a resource descriptor to an
373 ******************************************************************************/
376 AcpiRsSetAddressCommon (
378 ACPI_RESOURCE *Resource)
380 ACPI_FUNCTION_ENTRY ();
383 /* Set the Resource Type and General Flags */
385 (void) AcpiRsConvertResourceToAml (Resource, Aml, AcpiRsConvertGeneralFlags);
387 /* Set the Type-Specific Flags (Memory and I/O descriptors only) */
389 if (Resource->Data.Address.ResourceType == ACPI_MEMORY_RANGE)
391 (void) AcpiRsConvertResourceToAml (Resource, Aml, AcpiRsConvertMemFlags);
393 else if (Resource->Data.Address.ResourceType == ACPI_IO_RANGE)
395 (void) AcpiRsConvertResourceToAml (Resource, Aml, AcpiRsConvertIoFlags);
399 /* Generic resource type, just copy the TypeSpecific byte */
401 Aml->Address.SpecificFlags = Resource->Data.Address.Info.TypeSpecific;