This source file includes following definitions.
- ACPI_MODULE_NAME
- acpi_ex_system_io_space_handler
- acpi_ex_pci_config_space_handler
- acpi_ex_cmos_space_handler
- acpi_ex_pci_bar_space_handler
- acpi_ex_data_table_space_handler
1
2
3
4
5
6
7
8
9
10 #include <acpi/acpi.h>
11 #include "accommon.h"
12 #include "acinterp.h"
13
14 #define _COMPONENT ACPI_EXECUTER
15 ACPI_MODULE_NAME("exregion")
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 acpi_status
35 acpi_ex_system_memory_space_handler(u32 function,
36 acpi_physical_address address,
37 u32 bit_width,
38 u64 *value,
39 void *handler_context, void *region_context)
40 {
41 acpi_status status = AE_OK;
42 void *logical_addr_ptr = NULL;
43 struct acpi_mem_space_context *mem_info = region_context;
44 u32 length;
45 acpi_size map_length;
46 acpi_size page_boundary_map_length;
47 #ifdef ACPI_MISALIGNMENT_NOT_SUPPORTED
48 u32 remainder;
49 #endif
50
51 ACPI_FUNCTION_TRACE(ex_system_memory_space_handler);
52
53
54
55 switch (bit_width) {
56 case 8:
57
58 length = 1;
59 break;
60
61 case 16:
62
63 length = 2;
64 break;
65
66 case 32:
67
68 length = 4;
69 break;
70
71 case 64:
72
73 length = 8;
74 break;
75
76 default:
77
78 ACPI_ERROR((AE_INFO, "Invalid SystemMemory width %u",
79 bit_width));
80 return_ACPI_STATUS(AE_AML_OPERAND_VALUE);
81 }
82
83 #ifdef ACPI_MISALIGNMENT_NOT_SUPPORTED
84
85
86
87
88 (void)acpi_ut_short_divide((u64) address, length, NULL, &remainder);
89 if (remainder != 0) {
90 return_ACPI_STATUS(AE_AML_ALIGNMENT);
91 }
92 #endif
93
94
95
96
97
98
99 if ((address < mem_info->mapped_physical_address) ||
100 (((u64) address + length) > ((u64)
101 mem_info->mapped_physical_address +
102 mem_info->mapped_length))) {
103
104
105
106
107 if (mem_info->mapped_length) {
108
109
110
111 acpi_os_unmap_memory(mem_info->mapped_logical_address,
112 mem_info->mapped_length);
113 }
114
115
116
117
118
119
120 map_length = (acpi_size)
121 ((mem_info->address + mem_info->length) - address);
122
123
124
125
126
127
128
129
130
131
132
133
134 page_boundary_map_length = (acpi_size)
135 (ACPI_ROUND_UP(address, ACPI_DEFAULT_PAGE_SIZE) - address);
136 if (page_boundary_map_length == 0) {
137 page_boundary_map_length = ACPI_DEFAULT_PAGE_SIZE;
138 }
139
140 if (map_length > page_boundary_map_length) {
141 map_length = page_boundary_map_length;
142 }
143
144
145
146 mem_info->mapped_logical_address =
147 acpi_os_map_memory(address, map_length);
148 if (!mem_info->mapped_logical_address) {
149 ACPI_ERROR((AE_INFO,
150 "Could not map memory at 0x%8.8X%8.8X, size %u",
151 ACPI_FORMAT_UINT64(address),
152 (u32)map_length));
153 mem_info->mapped_length = 0;
154 return_ACPI_STATUS(AE_NO_MEMORY);
155 }
156
157
158
159 mem_info->mapped_physical_address = address;
160 mem_info->mapped_length = map_length;
161 }
162
163
164
165
166
167 logical_addr_ptr = mem_info->mapped_logical_address +
168 ((u64) address - (u64) mem_info->mapped_physical_address);
169
170 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
171 "System-Memory (width %u) R/W %u Address=%8.8X%8.8X\n",
172 bit_width, function, ACPI_FORMAT_UINT64(address)));
173
174
175
176
177
178
179
180
181
182 switch (function) {
183 case ACPI_READ:
184
185 *value = 0;
186 switch (bit_width) {
187 case 8:
188
189 *value = (u64)ACPI_GET8(logical_addr_ptr);
190 break;
191
192 case 16:
193
194 *value = (u64)ACPI_GET16(logical_addr_ptr);
195 break;
196
197 case 32:
198
199 *value = (u64)ACPI_GET32(logical_addr_ptr);
200 break;
201
202 case 64:
203
204 *value = (u64)ACPI_GET64(logical_addr_ptr);
205 break;
206
207 default:
208
209
210
211 break;
212 }
213 break;
214
215 case ACPI_WRITE:
216
217 switch (bit_width) {
218 case 8:
219
220 ACPI_SET8(logical_addr_ptr, *value);
221 break;
222
223 case 16:
224
225 ACPI_SET16(logical_addr_ptr, *value);
226 break;
227
228 case 32:
229
230 ACPI_SET32(logical_addr_ptr, *value);
231 break;
232
233 case 64:
234
235 ACPI_SET64(logical_addr_ptr, *value);
236 break;
237
238 default:
239
240
241
242 break;
243 }
244 break;
245
246 default:
247
248 status = AE_BAD_PARAMETER;
249 break;
250 }
251
252 return_ACPI_STATUS(status);
253 }
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273 acpi_status
274 acpi_ex_system_io_space_handler(u32 function,
275 acpi_physical_address address,
276 u32 bit_width,
277 u64 *value,
278 void *handler_context, void *region_context)
279 {
280 acpi_status status = AE_OK;
281 u32 value32;
282
283 ACPI_FUNCTION_TRACE(ex_system_io_space_handler);
284
285 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
286 "System-IO (width %u) R/W %u Address=%8.8X%8.8X\n",
287 bit_width, function, ACPI_FORMAT_UINT64(address)));
288
289
290
291 switch (function) {
292 case ACPI_READ:
293
294 status = acpi_hw_read_port((acpi_io_address)address,
295 &value32, bit_width);
296 *value = value32;
297 break;
298
299 case ACPI_WRITE:
300
301 status = acpi_hw_write_port((acpi_io_address)address,
302 (u32)*value, bit_width);
303 break;
304
305 default:
306
307 status = AE_BAD_PARAMETER;
308 break;
309 }
310
311 return_ACPI_STATUS(status);
312 }
313
314 #ifdef ACPI_PCI_CONFIGURED
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333 acpi_status
334 acpi_ex_pci_config_space_handler(u32 function,
335 acpi_physical_address address,
336 u32 bit_width,
337 u64 *value,
338 void *handler_context, void *region_context)
339 {
340 acpi_status status = AE_OK;
341 struct acpi_pci_id *pci_id;
342 u16 pci_register;
343
344 ACPI_FUNCTION_TRACE(ex_pci_config_space_handler);
345
346
347
348
349
350
351
352
353
354
355
356
357
358 pci_id = (struct acpi_pci_id *)region_context;
359 pci_register = (u16) (u32) address;
360
361 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
362 "Pci-Config %u (%u) Seg(%04x) Bus(%04x) "
363 "Dev(%04x) Func(%04x) Reg(%04x)\n",
364 function, bit_width, pci_id->segment, pci_id->bus,
365 pci_id->device, pci_id->function, pci_register));
366
367 switch (function) {
368 case ACPI_READ:
369
370 *value = 0;
371 status =
372 acpi_os_read_pci_configuration(pci_id, pci_register, value,
373 bit_width);
374 break;
375
376 case ACPI_WRITE:
377
378 status =
379 acpi_os_write_pci_configuration(pci_id, pci_register,
380 *value, bit_width);
381 break;
382
383 default:
384
385 status = AE_BAD_PARAMETER;
386 break;
387 }
388
389 return_ACPI_STATUS(status);
390 }
391 #endif
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411 acpi_status
412 acpi_ex_cmos_space_handler(u32 function,
413 acpi_physical_address address,
414 u32 bit_width,
415 u64 *value,
416 void *handler_context, void *region_context)
417 {
418 acpi_status status = AE_OK;
419
420 ACPI_FUNCTION_TRACE(ex_cmos_space_handler);
421
422 return_ACPI_STATUS(status);
423 }
424
425 #ifdef ACPI_PCI_CONFIGURED
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444 acpi_status
445 acpi_ex_pci_bar_space_handler(u32 function,
446 acpi_physical_address address,
447 u32 bit_width,
448 u64 *value,
449 void *handler_context, void *region_context)
450 {
451 acpi_status status = AE_OK;
452
453 ACPI_FUNCTION_TRACE(ex_pci_bar_space_handler);
454
455 return_ACPI_STATUS(status);
456 }
457 #endif
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477 acpi_status
478 acpi_ex_data_table_space_handler(u32 function,
479 acpi_physical_address address,
480 u32 bit_width,
481 u64 *value,
482 void *handler_context, void *region_context)
483 {
484 ACPI_FUNCTION_TRACE(ex_data_table_space_handler);
485
486
487
488
489
490 switch (function) {
491 case ACPI_READ:
492
493 memcpy(ACPI_CAST_PTR(char, value),
494 ACPI_PHYSADDR_TO_PTR(address), ACPI_DIV_8(bit_width));
495 break;
496
497 case ACPI_WRITE:
498
499 memcpy(ACPI_PHYSADDR_TO_PTR(address),
500 ACPI_CAST_PTR(char, value), ACPI_DIV_8(bit_width));
501 break;
502
503 default:
504
505 return_ACPI_STATUS(AE_BAD_PARAMETER);
506 }
507
508 return_ACPI_STATUS(AE_OK);
509 }