1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44#include <acpi/acpi.h>
45#include "accommon.h"
46#include "acresrc.h"
47
48#define _COMPONENT ACPI_RESOURCES
49ACPI_MODULE_NAME("rsaddr")
50
51
52
53
54
55
56struct acpi_rsconvert_info acpi_rs_convert_address16[5] = {
57 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_ADDRESS16,
58 ACPI_RS_SIZE(struct acpi_resource_address16),
59 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_address16)},
60
61 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_ADDRESS16,
62 sizeof(struct aml_resource_address16),
63 0},
64
65
66
67 {ACPI_RSC_ADDRESS, 0, 0, 0},
68
69
70
71
72
73
74
75
76
77 {ACPI_RSC_MOVE16, ACPI_RS_OFFSET(data.address16.granularity),
78 AML_OFFSET(address16.granularity),
79 5},
80
81
82
83 {ACPI_RSC_SOURCE, ACPI_RS_OFFSET(data.address16.resource_source),
84 0,
85 sizeof(struct aml_resource_address16)}
86};
87
88
89
90
91
92
93
94struct acpi_rsconvert_info acpi_rs_convert_address32[5] = {
95 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_ADDRESS32,
96 ACPI_RS_SIZE(struct acpi_resource_address32),
97 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_address32)},
98
99 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_ADDRESS32,
100 sizeof(struct aml_resource_address32),
101 0},
102
103
104
105 {ACPI_RSC_ADDRESS, 0, 0, 0},
106
107
108
109
110
111
112
113
114
115 {ACPI_RSC_MOVE32, ACPI_RS_OFFSET(data.address32.granularity),
116 AML_OFFSET(address32.granularity),
117 5},
118
119
120
121 {ACPI_RSC_SOURCE, ACPI_RS_OFFSET(data.address32.resource_source),
122 0,
123 sizeof(struct aml_resource_address32)}
124};
125
126
127
128
129
130
131
132struct acpi_rsconvert_info acpi_rs_convert_address64[5] = {
133 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_ADDRESS64,
134 ACPI_RS_SIZE(struct acpi_resource_address64),
135 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_address64)},
136
137 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_ADDRESS64,
138 sizeof(struct aml_resource_address64),
139 0},
140
141
142
143 {ACPI_RSC_ADDRESS, 0, 0, 0},
144
145
146
147
148
149
150
151
152
153 {ACPI_RSC_MOVE64, ACPI_RS_OFFSET(data.address64.granularity),
154 AML_OFFSET(address64.granularity),
155 5},
156
157
158
159 {ACPI_RSC_SOURCE, ACPI_RS_OFFSET(data.address64.resource_source),
160 0,
161 sizeof(struct aml_resource_address64)}
162};
163
164
165
166
167
168
169
170struct acpi_rsconvert_info acpi_rs_convert_ext_address64[5] = {
171 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64,
172 ACPI_RS_SIZE(struct acpi_resource_extended_address64),
173 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_ext_address64)},
174
175 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64,
176 sizeof(struct aml_resource_extended_address64),
177 0},
178
179
180
181 {ACPI_RSC_ADDRESS, 0, 0, 0},
182
183
184
185 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.ext_address64.revision_ID),
186 AML_OFFSET(ext_address64.revision_ID),
187 1},
188
189
190
191
192
193
194
195
196
197 {ACPI_RSC_MOVE64, ACPI_RS_OFFSET(data.ext_address64.granularity),
198 AML_OFFSET(ext_address64.granularity),
199 6}
200};
201
202
203
204
205
206
207
208static struct acpi_rsconvert_info acpi_rs_convert_general_flags[6] = {
209 {ACPI_RSC_FLAGINIT, 0, AML_OFFSET(address.flags),
210 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_general_flags)},
211
212
213
214 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.address.resource_type),
215 AML_OFFSET(address.resource_type),
216 1},
217
218
219
220 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.address.producer_consumer),
221 AML_OFFSET(address.flags),
222 0},
223
224 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.address.decode),
225 AML_OFFSET(address.flags),
226 1},
227
228 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.address.min_address_fixed),
229 AML_OFFSET(address.flags),
230 2},
231
232 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.address.max_address_fixed),
233 AML_OFFSET(address.flags),
234 3}
235};
236
237
238
239
240
241
242
243static struct acpi_rsconvert_info acpi_rs_convert_mem_flags[5] = {
244 {ACPI_RSC_FLAGINIT, 0, AML_OFFSET(address.specific_flags),
245 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_mem_flags)},
246
247
248
249 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.address.info.mem.write_protect),
250 AML_OFFSET(address.specific_flags),
251 0},
252
253 {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET(data.address.info.mem.caching),
254 AML_OFFSET(address.specific_flags),
255 1},
256
257 {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET(data.address.info.mem.range_type),
258 AML_OFFSET(address.specific_flags),
259 3},
260
261 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.address.info.mem.translation),
262 AML_OFFSET(address.specific_flags),
263 5}
264};
265
266
267
268
269
270
271
272static struct acpi_rsconvert_info acpi_rs_convert_io_flags[4] = {
273 {ACPI_RSC_FLAGINIT, 0, AML_OFFSET(address.specific_flags),
274 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_io_flags)},
275
276
277
278 {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET(data.address.info.io.range_type),
279 AML_OFFSET(address.specific_flags),
280 0},
281
282 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.address.info.io.translation),
283 AML_OFFSET(address.specific_flags),
284 4},
285
286 {ACPI_RSC_1BITFLAG,
287 ACPI_RS_OFFSET(data.address.info.io.translation_type),
288 AML_OFFSET(address.specific_flags),
289 5}
290};
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306u8
307acpi_rs_get_address_common(struct acpi_resource *resource,
308 union aml_resource *aml)
309{
310 ACPI_FUNCTION_ENTRY();
311
312
313
314 if ((aml->address.resource_type > 2)
315 && (aml->address.resource_type < 0xC0)) {
316 return (FALSE);
317 }
318
319
320
321 (void)acpi_rs_convert_aml_to_resource(resource, aml,
322 acpi_rs_convert_general_flags);
323
324
325
326 if (resource->data.address.resource_type == ACPI_MEMORY_RANGE) {
327 (void)acpi_rs_convert_aml_to_resource(resource, aml,
328 acpi_rs_convert_mem_flags);
329 } else if (resource->data.address.resource_type == ACPI_IO_RANGE) {
330 (void)acpi_rs_convert_aml_to_resource(resource, aml,
331 acpi_rs_convert_io_flags);
332 } else {
333
334
335 resource->data.address.info.type_specific =
336 aml->address.specific_flags;
337 }
338
339 return (TRUE);
340}
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356void
357acpi_rs_set_address_common(union aml_resource *aml,
358 struct acpi_resource *resource)
359{
360 ACPI_FUNCTION_ENTRY();
361
362
363
364 (void)acpi_rs_convert_resource_to_aml(resource, aml,
365 acpi_rs_convert_general_flags);
366
367
368
369 if (resource->data.address.resource_type == ACPI_MEMORY_RANGE) {
370 (void)acpi_rs_convert_resource_to_aml(resource, aml,
371 acpi_rs_convert_mem_flags);
372 } else if (resource->data.address.resource_type == ACPI_IO_RANGE) {
373 (void)acpi_rs_convert_resource_to_aml(resource, aml,
374 acpi_rs_convert_io_flags);
375 } else {
376
377
378 aml->address.specific_flags =
379 resource->data.address.info.type_specific;
380 }
381}
382