1 /*******************************************************************************
3 * Module Name: rsaddr - Address resource descriptors (16/32/64)
5 ******************************************************************************/
8 * Copyright (C) 2000 - 2013, 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.
50 #define _COMPONENT ACPI_RESOURCES
51 ACPI_MODULE_NAME ("rsaddr")
54 /*******************************************************************************
56 * AcpiRsConvertAddress16 - All WORD (16-bit) address resources
58 ******************************************************************************/
60 ACPI_RSCONVERT_INFO AcpiRsConvertAddress16
[5] =
62 {ACPI_RSC_INITGET
, ACPI_RESOURCE_TYPE_ADDRESS16
,
63 ACPI_RS_SIZE (ACPI_RESOURCE_ADDRESS16
),
64 ACPI_RSC_TABLE_SIZE (AcpiRsConvertAddress16
)},
66 {ACPI_RSC_INITSET
, ACPI_RESOURCE_NAME_ADDRESS16
,
67 sizeof (AML_RESOURCE_ADDRESS16
),
70 /* Resource Type, General Flags, and Type-Specific Flags */
72 {ACPI_RSC_ADDRESS
, 0, 0, 0},
75 * These fields are contiguous in both the source and destination:
77 * Address Range Minimum
78 * Address Range Maximum
79 * Address Translation Offset
82 {ACPI_RSC_MOVE16
, ACPI_RS_OFFSET (Data
.Address16
.Granularity
),
83 AML_OFFSET (Address16
.Granularity
),
86 /* Optional ResourceSource (Index and String) */
88 {ACPI_RSC_SOURCE
, ACPI_RS_OFFSET (Data
.Address16
.ResourceSource
),
90 sizeof (AML_RESOURCE_ADDRESS16
)}
94 /*******************************************************************************
96 * AcpiRsConvertAddress32 - All DWORD (32-bit) address resources
98 ******************************************************************************/
100 ACPI_RSCONVERT_INFO AcpiRsConvertAddress32
[5] =
102 {ACPI_RSC_INITGET
, ACPI_RESOURCE_TYPE_ADDRESS32
,
103 ACPI_RS_SIZE (ACPI_RESOURCE_ADDRESS32
),
104 ACPI_RSC_TABLE_SIZE (AcpiRsConvertAddress32
)},
106 {ACPI_RSC_INITSET
, ACPI_RESOURCE_NAME_ADDRESS32
,
107 sizeof (AML_RESOURCE_ADDRESS32
),
110 /* Resource Type, General Flags, and Type-Specific Flags */
112 {ACPI_RSC_ADDRESS
, 0, 0, 0},
115 * These fields are contiguous in both the source and destination:
116 * Address Granularity
117 * Address Range Minimum
118 * Address Range Maximum
119 * Address Translation Offset
122 {ACPI_RSC_MOVE32
, ACPI_RS_OFFSET (Data
.Address32
.Granularity
),
123 AML_OFFSET (Address32
.Granularity
),
126 /* Optional ResourceSource (Index and String) */
128 {ACPI_RSC_SOURCE
, ACPI_RS_OFFSET (Data
.Address32
.ResourceSource
),
130 sizeof (AML_RESOURCE_ADDRESS32
)}
134 /*******************************************************************************
136 * AcpiRsConvertAddress64 - All QWORD (64-bit) address resources
138 ******************************************************************************/
140 ACPI_RSCONVERT_INFO AcpiRsConvertAddress64
[5] =
142 {ACPI_RSC_INITGET
, ACPI_RESOURCE_TYPE_ADDRESS64
,
143 ACPI_RS_SIZE (ACPI_RESOURCE_ADDRESS64
),
144 ACPI_RSC_TABLE_SIZE (AcpiRsConvertAddress64
)},
146 {ACPI_RSC_INITSET
, ACPI_RESOURCE_NAME_ADDRESS64
,
147 sizeof (AML_RESOURCE_ADDRESS64
),
150 /* Resource Type, General Flags, and Type-Specific Flags */
152 {ACPI_RSC_ADDRESS
, 0, 0, 0},
155 * These fields are contiguous in both the source and destination:
156 * Address Granularity
157 * Address Range Minimum
158 * Address Range Maximum
159 * Address Translation Offset
162 {ACPI_RSC_MOVE64
, ACPI_RS_OFFSET (Data
.Address64
.Granularity
),
163 AML_OFFSET (Address64
.Granularity
),
166 /* Optional ResourceSource (Index and String) */
168 {ACPI_RSC_SOURCE
, ACPI_RS_OFFSET (Data
.Address64
.ResourceSource
),
170 sizeof (AML_RESOURCE_ADDRESS64
)}
174 /*******************************************************************************
176 * AcpiRsConvertExtAddress64 - All Extended (64-bit) address resources
178 ******************************************************************************/
180 ACPI_RSCONVERT_INFO AcpiRsConvertExtAddress64
[5] =
182 {ACPI_RSC_INITGET
, ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64
,
183 ACPI_RS_SIZE (ACPI_RESOURCE_EXTENDED_ADDRESS64
),
184 ACPI_RSC_TABLE_SIZE (AcpiRsConvertExtAddress64
)},
186 {ACPI_RSC_INITSET
, ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64
,
187 sizeof (AML_RESOURCE_EXTENDED_ADDRESS64
),
190 /* Resource Type, General Flags, and Type-Specific Flags */
192 {ACPI_RSC_ADDRESS
, 0, 0, 0},
196 {ACPI_RSC_MOVE8
, ACPI_RS_OFFSET (Data
.ExtAddress64
.RevisionID
),
197 AML_OFFSET (ExtAddress64
.RevisionID
),
200 * These fields are contiguous in both the source and destination:
201 * Address Granularity
202 * Address Range Minimum
203 * Address Range Maximum
204 * Address Translation Offset
206 * Type-Specific Attribute
208 {ACPI_RSC_MOVE64
, ACPI_RS_OFFSET (Data
.ExtAddress64
.Granularity
),
209 AML_OFFSET (ExtAddress64
.Granularity
),
214 /*******************************************************************************
216 * AcpiRsConvertGeneralFlags - Flags common to all address descriptors
218 ******************************************************************************/
220 static ACPI_RSCONVERT_INFO AcpiRsConvertGeneralFlags
[6] =
222 {ACPI_RSC_FLAGINIT
, 0, AML_OFFSET (Address
.Flags
),
223 ACPI_RSC_TABLE_SIZE (AcpiRsConvertGeneralFlags
)},
225 /* Resource Type (Memory, Io, BusNumber, etc.) */
227 {ACPI_RSC_MOVE8
, ACPI_RS_OFFSET (Data
.Address
.ResourceType
),
228 AML_OFFSET (Address
.ResourceType
),
231 /* General Flags - Consume, Decode, MinFixed, MaxFixed */
233 {ACPI_RSC_1BITFLAG
, ACPI_RS_OFFSET (Data
.Address
.ProducerConsumer
),
234 AML_OFFSET (Address
.Flags
),
237 {ACPI_RSC_1BITFLAG
, ACPI_RS_OFFSET (Data
.Address
.Decode
),
238 AML_OFFSET (Address
.Flags
),
241 {ACPI_RSC_1BITFLAG
, ACPI_RS_OFFSET (Data
.Address
.MinAddressFixed
),
242 AML_OFFSET (Address
.Flags
),
245 {ACPI_RSC_1BITFLAG
, ACPI_RS_OFFSET (Data
.Address
.MaxAddressFixed
),
246 AML_OFFSET (Address
.Flags
),
251 /*******************************************************************************
253 * AcpiRsConvertMemFlags - Flags common to Memory address descriptors
255 ******************************************************************************/
257 static ACPI_RSCONVERT_INFO AcpiRsConvertMemFlags
[5] =
259 {ACPI_RSC_FLAGINIT
, 0, AML_OFFSET (Address
.SpecificFlags
),
260 ACPI_RSC_TABLE_SIZE (AcpiRsConvertMemFlags
)},
262 /* Memory-specific flags */
264 {ACPI_RSC_1BITFLAG
, ACPI_RS_OFFSET (Data
.Address
.Info
.Mem
.WriteProtect
),
265 AML_OFFSET (Address
.SpecificFlags
),
268 {ACPI_RSC_2BITFLAG
, ACPI_RS_OFFSET (Data
.Address
.Info
.Mem
.Caching
),
269 AML_OFFSET (Address
.SpecificFlags
),
272 {ACPI_RSC_2BITFLAG
, ACPI_RS_OFFSET (Data
.Address
.Info
.Mem
.RangeType
),
273 AML_OFFSET (Address
.SpecificFlags
),
276 {ACPI_RSC_1BITFLAG
, ACPI_RS_OFFSET (Data
.Address
.Info
.Mem
.Translation
),
277 AML_OFFSET (Address
.SpecificFlags
),
282 /*******************************************************************************
284 * AcpiRsConvertIoFlags - Flags common to I/O address descriptors
286 ******************************************************************************/
288 static ACPI_RSCONVERT_INFO AcpiRsConvertIoFlags
[4] =
290 {ACPI_RSC_FLAGINIT
, 0, AML_OFFSET (Address
.SpecificFlags
),
291 ACPI_RSC_TABLE_SIZE (AcpiRsConvertIoFlags
)},
293 /* I/O-specific flags */
295 {ACPI_RSC_2BITFLAG
, ACPI_RS_OFFSET (Data
.Address
.Info
.Io
.RangeType
),
296 AML_OFFSET (Address
.SpecificFlags
),
299 {ACPI_RSC_1BITFLAG
, ACPI_RS_OFFSET (Data
.Address
.Info
.Io
.Translation
),
300 AML_OFFSET (Address
.SpecificFlags
),
303 {ACPI_RSC_1BITFLAG
, ACPI_RS_OFFSET (Data
.Address
.Info
.Io
.TranslationType
),
304 AML_OFFSET (Address
.SpecificFlags
),
309 /*******************************************************************************
311 * FUNCTION: AcpiRsGetAddressCommon
313 * PARAMETERS: Resource - Pointer to the internal resource struct
314 * Aml - Pointer to the AML resource descriptor
316 * RETURN: TRUE if the ResourceType field is OK, FALSE otherwise
318 * DESCRIPTION: Convert common flag fields from a raw AML resource descriptor
319 * to an internal resource descriptor
321 ******************************************************************************/
324 AcpiRsGetAddressCommon (
325 ACPI_RESOURCE
*Resource
,
328 ACPI_FUNCTION_ENTRY ();
331 /* Validate the Resource Type */
333 if ((Aml
->Address
.ResourceType
> 2) && (Aml
->Address
.ResourceType
< 0xC0))
338 /* Get the Resource Type and General Flags */
340 (void) AcpiRsConvertAmlToResource (Resource
, Aml
, AcpiRsConvertGeneralFlags
);
342 /* Get the Type-Specific Flags (Memory and I/O descriptors only) */
344 if (Resource
->Data
.Address
.ResourceType
== ACPI_MEMORY_RANGE
)
346 (void) AcpiRsConvertAmlToResource (Resource
, Aml
, AcpiRsConvertMemFlags
);
348 else if (Resource
->Data
.Address
.ResourceType
== ACPI_IO_RANGE
)
350 (void) AcpiRsConvertAmlToResource (Resource
, Aml
, AcpiRsConvertIoFlags
);
354 /* Generic resource type, just grab the TypeSpecific byte */
356 Resource
->Data
.Address
.Info
.TypeSpecific
= Aml
->Address
.SpecificFlags
;
363 /*******************************************************************************
365 * FUNCTION: AcpiRsSetAddressCommon
367 * PARAMETERS: Aml - Pointer to the AML resource descriptor
368 * Resource - Pointer to the internal resource struct
372 * DESCRIPTION: Convert common flag fields from a resource descriptor to an
375 ******************************************************************************/
378 AcpiRsSetAddressCommon (
380 ACPI_RESOURCE
*Resource
)
382 ACPI_FUNCTION_ENTRY ();
385 /* Set the Resource Type and General Flags */
387 (void) AcpiRsConvertResourceToAml (Resource
, Aml
, AcpiRsConvertGeneralFlags
);
389 /* Set the Type-Specific Flags (Memory and I/O descriptors only) */
391 if (Resource
->Data
.Address
.ResourceType
== ACPI_MEMORY_RANGE
)
393 (void) AcpiRsConvertResourceToAml (Resource
, Aml
, AcpiRsConvertMemFlags
);
395 else if (Resource
->Data
.Address
.ResourceType
== ACPI_IO_RANGE
)
397 (void) AcpiRsConvertResourceToAml (Resource
, Aml
, AcpiRsConvertIoFlags
);
401 /* Generic resource type, just copy the TypeSpecific byte */
403 Aml
->Address
.SpecificFlags
= Resource
->Data
.Address
.Info
.TypeSpecific
;