Deleted Added
full compact
acpi_resource.c (90014) acpi_resource.c (91125)
1/*-
2 * Copyright (c) 2000 Michael Smith
3 * Copyright (c) 2000 BSDi
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 10 unchanged lines hidden (view full) ---

19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 *
1/*-
2 * Copyright (c) 2000 Michael Smith
3 * Copyright (c) 2000 BSDi
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 10 unchanged lines hidden (view full) ---

19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 *
27 * $FreeBSD: head/sys/dev/acpica/acpi_resource.c 90014 2002-01-31 09:18:27Z takawata $
27 * $FreeBSD: head/sys/dev/acpica/acpi_resource.c 91125 2002-02-23 05:28:22Z msmith $
28 */
29
30#include "opt_acpi.h"
31#include <sys/param.h>
32#include <sys/kernel.h>
33#include <sys/bus.h>
34
35#include <machine/bus.h>
36#include <machine/resource.h>
37#include <sys/rman.h>
38
39#include "acpi.h"
40
41#include <dev/acpica/acpivar.h>
42
43/*
44 * Hooks for the ACPI CA debugging infrastructure
45 */
46#define _COMPONENT ACPI_BUS
28 */
29
30#include "opt_acpi.h"
31#include <sys/param.h>
32#include <sys/kernel.h>
33#include <sys/bus.h>
34
35#include <machine/bus.h>
36#include <machine/resource.h>
37#include <sys/rman.h>
38
39#include "acpi.h"
40
41#include <dev/acpica/acpivar.h>
42
43/*
44 * Hooks for the ACPI CA debugging infrastructure
45 */
46#define _COMPONENT ACPI_BUS
47MODULE_NAME("RESOURCE")
47ACPI_MODULE_NAME("RESOURCE")
48
49/*
50 * Fetch a device's resources and associate them with the device.
51 *
52 * Note that it might be nice to also locate ACPI-specific resource items, such
53 * as GPE bits.
54 *
55 * We really need to split the resource-fetching code out from the

--- 4 unchanged lines hidden (view full) ---

60acpi_parse_resources(device_t dev, ACPI_HANDLE handle, struct acpi_parse_resource_set *set)
61{
62 ACPI_BUFFER buf;
63 ACPI_RESOURCE *res;
64 char *curr, *last;
65 ACPI_STATUS status;
66 void *context;
67
48
49/*
50 * Fetch a device's resources and associate them with the device.
51 *
52 * Note that it might be nice to also locate ACPI-specific resource items, such
53 * as GPE bits.
54 *
55 * We really need to split the resource-fetching code out from the

--- 4 unchanged lines hidden (view full) ---

60acpi_parse_resources(device_t dev, ACPI_HANDLE handle, struct acpi_parse_resource_set *set)
61{
62 ACPI_BUFFER buf;
63 ACPI_RESOURCE *res;
64 char *curr, *last;
65 ACPI_STATUS status;
66 void *context;
67
68 FUNCTION_TRACE(__func__);
68 ACPI_FUNCTION_TRACE(__func__);
69
70 /*
71 * Special-case some devices that abuse _PRS/_CRS to mean
72 * something other than "I consume this resource".
73 *
74 * XXX do we really need this? It's only relevant once
75 * we start always-allocating these resources, and even
76 * then, the only special-cased device is likely to be
77 * the PCI interrupt link.
78 */
79
80 /*
81 * Fetch the device's current resources.
82 */
69
70 /*
71 * Special-case some devices that abuse _PRS/_CRS to mean
72 * something other than "I consume this resource".
73 *
74 * XXX do we really need this? It's only relevant once
75 * we start always-allocating these resources, and even
76 * then, the only special-cased device is likely to be
77 * the PCI interrupt link.
78 */
79
80 /*
81 * Fetch the device's current resources.
82 */
83 if (((status = acpi_GetIntoBuffer(handle, AcpiGetCurrentResources, &buf)) != AE_OK)) {
83 buf.Length = ACPI_ALLOCATE_BUFFER;
84 if (ACPI_FAILURE((status = AcpiGetCurrentResources(handle, &buf)))) {
84 if (status != AE_NOT_FOUND)
85 printf("can't fetch resources for %s - %s\n",
86 acpi_name(handle), AcpiFormatException(status));
87 return_ACPI_STATUS(status);
88 }
89 ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "%s - got %d bytes of resources\n",
90 acpi_name(handle), buf.Length));
91 set->set_init(dev, &context);

--- 134 unchanged lines hidden (view full) ---

226 case ACPI_RSTYPE_END_DPF:
227 ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "end dependant functions\n"));
228 set->set_end_dependant(dev, context);
229 break;
230
231 case ACPI_RSTYPE_ADDRESS32:
232 if (res->Data.Address32.AddressLength <= 0)
233 break;
85 if (status != AE_NOT_FOUND)
86 printf("can't fetch resources for %s - %s\n",
87 acpi_name(handle), AcpiFormatException(status));
88 return_ACPI_STATUS(status);
89 }
90 ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "%s - got %d bytes of resources\n",
91 acpi_name(handle), buf.Length));
92 set->set_init(dev, &context);

--- 134 unchanged lines hidden (view full) ---

227 case ACPI_RSTYPE_END_DPF:
228 ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "end dependant functions\n"));
229 set->set_end_dependant(dev, context);
230 break;
231
232 case ACPI_RSTYPE_ADDRESS32:
233 if (res->Data.Address32.AddressLength <= 0)
234 break;
234 if (res->Data.Address32.ProducerConsumer != CONSUMER) {
235 if (res->Data.Address32.ProducerConsumer != ACPI_CONSUMER) {
235 ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "ignored Address32 %s producer\n",
236 ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "ignored Address32 %s producer\n",
236 (res->Data.Address32.ResourceType == IO_RANGE) ?
237 (res->Data.Address32.ResourceType == ACPI_IO_RANGE) ?
237 "IO" : "Memory"));
238 break;
239 }
238 "IO" : "Memory"));
239 break;
240 }
240 if ((res->Data.Address32.ResourceType != MEMORY_RANGE) ||
241 (res->Data.Address32.ResourceType != IO_RANGE)) {
241 if ((res->Data.Address32.ResourceType != ACPI_MEMORY_RANGE) ||
242 (res->Data.Address32.ResourceType != ACPI_IO_RANGE)) {
242 ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
243 "ignored Address32 for non-memory, non-I/O\n"));
244 break;
245 }
246
243 ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
244 "ignored Address32 for non-memory, non-I/O\n"));
245 break;
246 }
247
247 if ((res->Data.Address32.MinAddressFixed == ADDRESS_FIXED) &&
248 (res->Data.Address32.MaxAddressFixed == ADDRESS_FIXED)) {
249 if (res->Data.Address32.ResourceType == MEMORY_RANGE) {
248 if ((res->Data.Address32.MinAddressFixed == ACPI_ADDRESS_FIXED) &&
249 (res->Data.Address32.MaxAddressFixed == ACPI_ADDRESS_FIXED)) {
250 if (res->Data.Address32.ResourceType == ACPI_MEMORY_RANGE) {
250 ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "Address32/Memory 0x%x/%d\n",
251 res->Data.Address32.MinAddressRange,
252 res->Data.Address32.AddressLength));
253 set->set_memory(dev, context,
254 res->Data.Address32.MinAddressRange,
255 res->Data.Address32.AddressLength);
256 } else {
257 ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "Address32/IO 0x%x/%d\n",
258 res->Data.Address32.MinAddressRange,
259 res->Data.Address32.AddressLength));
260 set->set_ioport(dev, context,
261 res->Data.Address32.MinAddressRange,
262 res->Data.Address32.AddressLength);
263 }
264 } else {
251 ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "Address32/Memory 0x%x/%d\n",
252 res->Data.Address32.MinAddressRange,
253 res->Data.Address32.AddressLength));
254 set->set_memory(dev, context,
255 res->Data.Address32.MinAddressRange,
256 res->Data.Address32.AddressLength);
257 } else {
258 ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "Address32/IO 0x%x/%d\n",
259 res->Data.Address32.MinAddressRange,
260 res->Data.Address32.AddressLength));
261 set->set_ioport(dev, context,
262 res->Data.Address32.MinAddressRange,
263 res->Data.Address32.AddressLength);
264 }
265 } else {
265 if (res->Data.Address32.ResourceType == MEMORY_RANGE) {
266 if (res->Data.Address32.ResourceType == ACPI_MEMORY_RANGE) {
266 ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "Address32/Memory 0x%x-0x%x/%d\n",
267 res->Data.Address32.MinAddressRange,
268 res->Data.Address32.MaxAddressRange,
269 res->Data.Address32.AddressLength));
270 set->set_memoryrange(dev, context,
271 res->Data.Address32.MinAddressRange,
272 res->Data.Address32.MaxAddressRange,
273 res->Data.Address32.AddressLength,

--- 10 unchanged lines hidden (view full) ---

284 res->Data.Address32.Granularity);
285 }
286 }
287 break;
288
289 case ACPI_RSTYPE_ADDRESS16:
290 if (res->Data.Address16.AddressLength <= 0)
291 break;
267 ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "Address32/Memory 0x%x-0x%x/%d\n",
268 res->Data.Address32.MinAddressRange,
269 res->Data.Address32.MaxAddressRange,
270 res->Data.Address32.AddressLength));
271 set->set_memoryrange(dev, context,
272 res->Data.Address32.MinAddressRange,
273 res->Data.Address32.MaxAddressRange,
274 res->Data.Address32.AddressLength,

--- 10 unchanged lines hidden (view full) ---

285 res->Data.Address32.Granularity);
286 }
287 }
288 break;
289
290 case ACPI_RSTYPE_ADDRESS16:
291 if (res->Data.Address16.AddressLength <= 0)
292 break;
292 if (res->Data.Address16.ProducerConsumer != CONSUMER) {
293 if (res->Data.Address16.ProducerConsumer != ACPI_CONSUMER) {
293 ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "ignored Address16 %s producer\n",
294 ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "ignored Address16 %s producer\n",
294 (res->Data.Address16.ResourceType == IO_RANGE) ?
295 (res->Data.Address16.ResourceType == ACPI_IO_RANGE) ?
295 "IO" : "Memory"));
296 break;
297 }
296 "IO" : "Memory"));
297 break;
298 }
298 if ((res->Data.Address16.ResourceType != MEMORY_RANGE) ||
299 (res->Data.Address16.ResourceType != IO_RANGE)) {
299 if ((res->Data.Address16.ResourceType != ACPI_MEMORY_RANGE) ||
300 (res->Data.Address16.ResourceType != ACPI_IO_RANGE)) {
300 ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
301 "ignored Address16 for non-memory, non-I/O\n"));
302 break;
303 }
304
301 ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
302 "ignored Address16 for non-memory, non-I/O\n"));
303 break;
304 }
305
305 if ((res->Data.Address16.MinAddressFixed == ADDRESS_FIXED) &&
306 (res->Data.Address16.MaxAddressFixed == ADDRESS_FIXED)) {
307 if (res->Data.Address16.ResourceType == MEMORY_RANGE) {
306 if ((res->Data.Address16.MinAddressFixed == ACPI_ADDRESS_FIXED) &&
307 (res->Data.Address16.MaxAddressFixed == ACPI_ADDRESS_FIXED)) {
308 if (res->Data.Address16.ResourceType == ACPI_MEMORY_RANGE) {
308 ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "Address16/Memory 0x%x/%d\n",
309 res->Data.Address16.MinAddressRange,
310 res->Data.Address16.AddressLength));
311 set->set_memory(dev, context,
312 res->Data.Address16.MinAddressRange,
313 res->Data.Address16.AddressLength);
314 } else {
315 ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "Address16/IO 0x%x/%d\n",
316 res->Data.Address16.MinAddressRange,
317 res->Data.Address16.AddressLength));
318 set->set_ioport(dev, context,
319 res->Data.Address16.MinAddressRange,
320 res->Data.Address16.AddressLength);
321 }
322 } else {
309 ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "Address16/Memory 0x%x/%d\n",
310 res->Data.Address16.MinAddressRange,
311 res->Data.Address16.AddressLength));
312 set->set_memory(dev, context,
313 res->Data.Address16.MinAddressRange,
314 res->Data.Address16.AddressLength);
315 } else {
316 ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "Address16/IO 0x%x/%d\n",
317 res->Data.Address16.MinAddressRange,
318 res->Data.Address16.AddressLength));
319 set->set_ioport(dev, context,
320 res->Data.Address16.MinAddressRange,
321 res->Data.Address16.AddressLength);
322 }
323 } else {
323 if (res->Data.Address16.ResourceType == MEMORY_RANGE) {
324 if (res->Data.Address16.ResourceType == ACPI_MEMORY_RANGE) {
324 ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "Address16/Memory 0x%x-0x%x/%d\n",
325 res->Data.Address16.MinAddressRange,
326 res->Data.Address16.MaxAddressRange,
327 res->Data.Address16.AddressLength));
328 set->set_memoryrange(dev, context,
329 res->Data.Address16.MinAddressRange,
330 res->Data.Address16.MaxAddressRange,
331 res->Data.Address16.AddressLength,

--- 260 unchanged lines hidden ---
325 ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "Address16/Memory 0x%x-0x%x/%d\n",
326 res->Data.Address16.MinAddressRange,
327 res->Data.Address16.MaxAddressRange,
328 res->Data.Address16.AddressLength));
329 set->set_memoryrange(dev, context,
330 res->Data.Address16.MinAddressRange,
331 res->Data.Address16.MaxAddressRange,
332 res->Data.Address16.AddressLength,

--- 260 unchanged lines hidden ---