1 // SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
2 /*******************************************************************************
4 * Module Name: rsaddr - Address resource descriptors (16/32/64)
6 ******************************************************************************/
12 #define _COMPONENT ACPI_RESOURCES
13 ACPI_MODULE_NAME("rsaddr")
15 /*******************************************************************************
17 * acpi_rs_convert_address16 - All WORD (16-bit) address resources
19 ******************************************************************************/
20 struct acpi_rsconvert_info acpi_rs_convert_address16
[5] = {
21 {ACPI_RSC_INITGET
, ACPI_RESOURCE_TYPE_ADDRESS16
,
22 ACPI_RS_SIZE(struct acpi_resource_address16
),
23 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_address16
)},
25 {ACPI_RSC_INITSET
, ACPI_RESOURCE_NAME_ADDRESS16
,
26 sizeof(struct aml_resource_address16
),
29 /* Resource Type, General Flags, and Type-Specific Flags */
31 {ACPI_RSC_ADDRESS
, 0, 0, 0},
34 * These fields are contiguous in both the source and destination:
36 * Address Range Minimum
37 * Address Range Maximum
38 * Address Translation Offset
41 {ACPI_RSC_MOVE16
, ACPI_RS_OFFSET(data
.address16
.address
.granularity
),
42 AML_OFFSET(address16
.granularity
),
45 /* Optional resource_source (Index and String) */
47 {ACPI_RSC_SOURCE
, ACPI_RS_OFFSET(data
.address16
.resource_source
),
49 sizeof(struct aml_resource_address16
)}
52 /*******************************************************************************
54 * acpi_rs_convert_address32 - All DWORD (32-bit) address resources
56 ******************************************************************************/
58 struct acpi_rsconvert_info acpi_rs_convert_address32
[5] = {
59 {ACPI_RSC_INITGET
, ACPI_RESOURCE_TYPE_ADDRESS32
,
60 ACPI_RS_SIZE(struct acpi_resource_address32
),
61 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_address32
)},
63 {ACPI_RSC_INITSET
, ACPI_RESOURCE_NAME_ADDRESS32
,
64 sizeof(struct aml_resource_address32
),
67 /* Resource Type, General Flags, and Type-Specific Flags */
69 {ACPI_RSC_ADDRESS
, 0, 0, 0},
72 * These fields are contiguous in both the source and destination:
74 * Address Range Minimum
75 * Address Range Maximum
76 * Address Translation Offset
79 {ACPI_RSC_MOVE32
, ACPI_RS_OFFSET(data
.address32
.address
.granularity
),
80 AML_OFFSET(address32
.granularity
),
83 /* Optional resource_source (Index and String) */
85 {ACPI_RSC_SOURCE
, ACPI_RS_OFFSET(data
.address32
.resource_source
),
87 sizeof(struct aml_resource_address32
)}
90 /*******************************************************************************
92 * acpi_rs_convert_address64 - All QWORD (64-bit) address resources
94 ******************************************************************************/
96 struct acpi_rsconvert_info acpi_rs_convert_address64
[5] = {
97 {ACPI_RSC_INITGET
, ACPI_RESOURCE_TYPE_ADDRESS64
,
98 ACPI_RS_SIZE(struct acpi_resource_address64
),
99 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_address64
)},
101 {ACPI_RSC_INITSET
, ACPI_RESOURCE_NAME_ADDRESS64
,
102 sizeof(struct aml_resource_address64
),
105 /* Resource Type, General Flags, and Type-Specific Flags */
107 {ACPI_RSC_ADDRESS
, 0, 0, 0},
110 * These fields are contiguous in both the source and destination:
111 * Address Granularity
112 * Address Range Minimum
113 * Address Range Maximum
114 * Address Translation Offset
117 {ACPI_RSC_MOVE64
, ACPI_RS_OFFSET(data
.address64
.address
.granularity
),
118 AML_OFFSET(address64
.granularity
),
121 /* Optional resource_source (Index and String) */
123 {ACPI_RSC_SOURCE
, ACPI_RS_OFFSET(data
.address64
.resource_source
),
125 sizeof(struct aml_resource_address64
)}
128 /*******************************************************************************
130 * acpi_rs_convert_ext_address64 - All Extended (64-bit) address resources
132 ******************************************************************************/
134 struct acpi_rsconvert_info acpi_rs_convert_ext_address64
[5] = {
135 {ACPI_RSC_INITGET
, ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64
,
136 ACPI_RS_SIZE(struct acpi_resource_extended_address64
),
137 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_ext_address64
)},
139 {ACPI_RSC_INITSET
, ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64
,
140 sizeof(struct aml_resource_extended_address64
),
143 /* Resource Type, General Flags, and Type-Specific Flags */
145 {ACPI_RSC_ADDRESS
, 0, 0, 0},
149 {ACPI_RSC_MOVE8
, ACPI_RS_OFFSET(data
.ext_address64
.revision_ID
),
150 AML_OFFSET(ext_address64
.revision_ID
),
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
159 * Type-Specific Attribute
162 ACPI_RS_OFFSET(data
.ext_address64
.address
.granularity
),
163 AML_OFFSET(ext_address64
.granularity
),
167 /*******************************************************************************
169 * acpi_rs_convert_general_flags - Flags common to all address descriptors
171 ******************************************************************************/
173 static struct acpi_rsconvert_info acpi_rs_convert_general_flags
[6] = {
174 {ACPI_RSC_FLAGINIT
, 0, AML_OFFSET(address
.flags
),
175 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_general_flags
)},
177 /* Resource Type (Memory, Io, bus_number, etc.) */
179 {ACPI_RSC_MOVE8
, ACPI_RS_OFFSET(data
.address
.resource_type
),
180 AML_OFFSET(address
.resource_type
),
183 /* General flags - Consume, Decode, min_fixed, max_fixed */
185 {ACPI_RSC_1BITFLAG
, ACPI_RS_OFFSET(data
.address
.producer_consumer
),
186 AML_OFFSET(address
.flags
),
189 {ACPI_RSC_1BITFLAG
, ACPI_RS_OFFSET(data
.address
.decode
),
190 AML_OFFSET(address
.flags
),
193 {ACPI_RSC_1BITFLAG
, ACPI_RS_OFFSET(data
.address
.min_address_fixed
),
194 AML_OFFSET(address
.flags
),
197 {ACPI_RSC_1BITFLAG
, ACPI_RS_OFFSET(data
.address
.max_address_fixed
),
198 AML_OFFSET(address
.flags
),
202 /*******************************************************************************
204 * acpi_rs_convert_mem_flags - Flags common to Memory address descriptors
206 ******************************************************************************/
208 static struct acpi_rsconvert_info acpi_rs_convert_mem_flags
[5] = {
209 {ACPI_RSC_FLAGINIT
, 0, AML_OFFSET(address
.specific_flags
),
210 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_mem_flags
)},
212 /* Memory-specific flags */
214 {ACPI_RSC_1BITFLAG
, ACPI_RS_OFFSET(data
.address
.info
.mem
.write_protect
),
215 AML_OFFSET(address
.specific_flags
),
218 {ACPI_RSC_2BITFLAG
, ACPI_RS_OFFSET(data
.address
.info
.mem
.caching
),
219 AML_OFFSET(address
.specific_flags
),
222 {ACPI_RSC_2BITFLAG
, ACPI_RS_OFFSET(data
.address
.info
.mem
.range_type
),
223 AML_OFFSET(address
.specific_flags
),
226 {ACPI_RSC_1BITFLAG
, ACPI_RS_OFFSET(data
.address
.info
.mem
.translation
),
227 AML_OFFSET(address
.specific_flags
),
231 /*******************************************************************************
233 * acpi_rs_convert_io_flags - Flags common to I/O address descriptors
235 ******************************************************************************/
237 static struct acpi_rsconvert_info acpi_rs_convert_io_flags
[4] = {
238 {ACPI_RSC_FLAGINIT
, 0, AML_OFFSET(address
.specific_flags
),
239 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_io_flags
)},
241 /* I/O-specific flags */
243 {ACPI_RSC_2BITFLAG
, ACPI_RS_OFFSET(data
.address
.info
.io
.range_type
),
244 AML_OFFSET(address
.specific_flags
),
247 {ACPI_RSC_1BITFLAG
, ACPI_RS_OFFSET(data
.address
.info
.io
.translation
),
248 AML_OFFSET(address
.specific_flags
),
252 ACPI_RS_OFFSET(data
.address
.info
.io
.translation_type
),
253 AML_OFFSET(address
.specific_flags
),
257 /*******************************************************************************
259 * FUNCTION: acpi_rs_get_address_common
261 * PARAMETERS: resource - Pointer to the internal resource struct
262 * aml - Pointer to the AML resource descriptor
264 * RETURN: TRUE if the resource_type field is OK, FALSE otherwise
266 * DESCRIPTION: Convert common flag fields from a raw AML resource descriptor
267 * to an internal resource descriptor
269 ******************************************************************************/
272 acpi_rs_get_address_common(struct acpi_resource
*resource
,
273 union aml_resource
*aml
)
275 ACPI_FUNCTION_ENTRY();
277 /* Validate the Resource Type */
279 if ((aml
->address
.resource_type
> 2) &&
280 (aml
->address
.resource_type
< 0xC0)) {
284 /* Get the Resource Type and General Flags */
286 (void)acpi_rs_convert_aml_to_resource(resource
, aml
,
287 acpi_rs_convert_general_flags
);
289 /* Get the Type-Specific Flags (Memory and I/O descriptors only) */
291 if (resource
->data
.address
.resource_type
== ACPI_MEMORY_RANGE
) {
292 (void)acpi_rs_convert_aml_to_resource(resource
, aml
,
293 acpi_rs_convert_mem_flags
);
294 } else if (resource
->data
.address
.resource_type
== ACPI_IO_RANGE
) {
295 (void)acpi_rs_convert_aml_to_resource(resource
, aml
,
296 acpi_rs_convert_io_flags
);
298 /* Generic resource type, just grab the type_specific byte */
300 resource
->data
.address
.info
.type_specific
=
301 aml
->address
.specific_flags
;
307 /*******************************************************************************
309 * FUNCTION: acpi_rs_set_address_common
311 * PARAMETERS: aml - Pointer to the AML resource descriptor
312 * resource - Pointer to the internal resource struct
316 * DESCRIPTION: Convert common flag fields from a resource descriptor to an
319 ******************************************************************************/
322 acpi_rs_set_address_common(union aml_resource
*aml
,
323 struct acpi_resource
*resource
)
325 ACPI_FUNCTION_ENTRY();
327 /* Set the Resource Type and General Flags */
329 (void)acpi_rs_convert_resource_to_aml(resource
, aml
,
330 acpi_rs_convert_general_flags
);
332 /* Set the Type-Specific Flags (Memory and I/O descriptors only) */
334 if (resource
->data
.address
.resource_type
== ACPI_MEMORY_RANGE
) {
335 (void)acpi_rs_convert_resource_to_aml(resource
, aml
,
336 acpi_rs_convert_mem_flags
);
337 } else if (resource
->data
.address
.resource_type
== ACPI_IO_RANGE
) {
338 (void)acpi_rs_convert_resource_to_aml(resource
, aml
,
339 acpi_rs_convert_io_flags
);
341 /* Generic resource type, just copy the type_specific byte */
343 aml
->address
.specific_flags
=
344 resource
->data
.address
.info
.type_specific
;