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 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 |
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 |
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 */ |
83 buf.Length = ACPI_ALLOCATE_BUFFER; 84 if (ACPI_FAILURE((status = AcpiGetCurrentResources(handle, &buf)))) { |
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; |
235 if (res->Data.Address32.ProducerConsumer != ACPI_CONSUMER) { |
236 ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "ignored Address32 %s producer\n", |
237 (res->Data.Address32.ResourceType == ACPI_IO_RANGE) ? |
238 "IO" : "Memory")); 239 break; 240 } |
241 if ((res->Data.Address32.ResourceType != ACPI_MEMORY_RANGE) || 242 (res->Data.Address32.ResourceType != ACPI_IO_RANGE)) { |
243 ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, 244 "ignored Address32 for non-memory, non-I/O\n")); 245 break; 246 } 247 |
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) { |
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 { |
266 if (res->Data.Address32.ResourceType == ACPI_MEMORY_RANGE) { |
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; |
293 if (res->Data.Address16.ProducerConsumer != ACPI_CONSUMER) { |
294 ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "ignored Address16 %s producer\n", |
295 (res->Data.Address16.ResourceType == ACPI_IO_RANGE) ? |
296 "IO" : "Memory")); 297 break; 298 } |
299 if ((res->Data.Address16.ResourceType != ACPI_MEMORY_RANGE) || 300 (res->Data.Address16.ResourceType != ACPI_IO_RANGE)) { |
301 ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, 302 "ignored Address16 for non-memory, non-I/O\n")); 303 break; 304 } 305 |
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) { |
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 { |
324 if (res->Data.Address16.ResourceType == ACPI_MEMORY_RANGE) { |
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 --- |