Deleted Added
full compact
acpi_resource.c (80078) acpi_resource.c (82372)
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 80078 2001-07-21 10:24:37Z msmith $
27 * $FreeBSD: head/sys/dev/acpica/acpi_resource.c 82372 2001-08-26 22:50:15Z msmith $
28 */
29
30#include "opt_acpi.h"
31#include <sys/param.h>
32#include <sys/kernel.h>
33#include <sys/bus.h>
34#include <machine/bus.h>
35#include <machine/resource.h>

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

65 /*
66 * Fetch the device resources
67 */
68 if (((status = acpi_GetIntoBuffer(handle, AcpiGetPossibleResources, &buf)) != AE_OK) &&
69 ((status = acpi_GetIntoBuffer(handle, AcpiGetCurrentResources, &buf)) != AE_OK)) {
70 device_printf(dev, "can't fetch ACPI resources - %s\n", AcpiFormatException(status));
71 return_ACPI_STATUS(status);
72 }
28 */
29
30#include "opt_acpi.h"
31#include <sys/param.h>
32#include <sys/kernel.h>
33#include <sys/bus.h>
34#include <machine/bus.h>
35#include <machine/resource.h>

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

65 /*
66 * Fetch the device resources
67 */
68 if (((status = acpi_GetIntoBuffer(handle, AcpiGetPossibleResources, &buf)) != AE_OK) &&
69 ((status = acpi_GetIntoBuffer(handle, AcpiGetCurrentResources, &buf)) != AE_OK)) {
70 device_printf(dev, "can't fetch ACPI resources - %s\n", AcpiFormatException(status));
71 return_ACPI_STATUS(status);
72 }
73 DEBUG_PRINT(TRACE_RESOURCES, ("got %d bytes of resources\n", buf.Length));
73 ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "got %d bytes of resources\n", buf.Length));
74 set->set_init(dev, &context);
75
76 /*
77 * Iterate through the resources
78 */
79 curr = buf.Pointer;
80 last = (char *)buf.Pointer + buf.Length;
81 while (curr < last) {
82 res = (ACPI_RESOURCE *)curr;
83 curr += res->Length;
84
85 /*
86 * Handle the individual resource types
87 */
88 switch(res->Id) {
89 case ACPI_RSTYPE_END_TAG:
74 set->set_init(dev, &context);
75
76 /*
77 * Iterate through the resources
78 */
79 curr = buf.Pointer;
80 last = (char *)buf.Pointer + buf.Length;
81 while (curr < last) {
82 res = (ACPI_RESOURCE *)curr;
83 curr += res->Length;
84
85 /*
86 * Handle the individual resource types
87 */
88 switch(res->Id) {
89 case ACPI_RSTYPE_END_TAG:
90 DEBUG_PRINT(TRACE_RESOURCES, ("EndTag\n"));
90 ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "EndTag\n"));
91 curr = last;
92 break;
93
94 case ACPI_RSTYPE_FIXED_IO:
91 curr = last;
92 break;
93
94 case ACPI_RSTYPE_FIXED_IO:
95 DEBUG_PRINT(TRACE_RESOURCES, ("FixedIo 0x%x/%d\n", res->Data.FixedIo.BaseAddress, res->Data.FixedIo.RangeLength));
95 ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "FixedIo 0x%x/%d\n", res->Data.FixedIo.BaseAddress, res->Data.FixedIo.RangeLength));
96 set->set_ioport(dev, context, res->Data.FixedIo.BaseAddress, res->Data.FixedIo.RangeLength);
97 break;
98
99 case ACPI_RSTYPE_IO:
100 if (res->Data.Io.MinBaseAddress == res->Data.Io.MaxBaseAddress) {
96 set->set_ioport(dev, context, res->Data.FixedIo.BaseAddress, res->Data.FixedIo.RangeLength);
97 break;
98
99 case ACPI_RSTYPE_IO:
100 if (res->Data.Io.MinBaseAddress == res->Data.Io.MaxBaseAddress) {
101 DEBUG_PRINT(TRACE_RESOURCES, ("Io 0x%x/%d\n", res->Data.Io.MinBaseAddress, res->Data.Io.RangeLength));
101 ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "Io 0x%x/%d\n", res->Data.Io.MinBaseAddress, res->Data.Io.RangeLength));
102 set->set_ioport(dev, context, res->Data.Io.MinBaseAddress, res->Data.Io.RangeLength);
103 } else {
102 set->set_ioport(dev, context, res->Data.Io.MinBaseAddress, res->Data.Io.RangeLength);
103 } else {
104 DEBUG_PRINT(TRACE_RESOURCES, ("Io 0x%x-0x%x/%d\n", res->Data.Io.MinBaseAddress, res->Data.Io.MaxBaseAddress,
105 res->Data.Io.RangeLength));
104 ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "Io 0x%x-0x%x/%d\n", res->Data.Io.MinBaseAddress, res->Data.Io.MaxBaseAddress,
105 res->Data.Io.RangeLength));
106 set->set_iorange(dev, context, res->Data.Io.MinBaseAddress, res->Data.Io.MaxBaseAddress,
107 res->Data.Io.RangeLength, res->Data.Io.Alignment);
108 }
109 break;
110
111 case ACPI_RSTYPE_FIXED_MEM32:
106 set->set_iorange(dev, context, res->Data.Io.MinBaseAddress, res->Data.Io.MaxBaseAddress,
107 res->Data.Io.RangeLength, res->Data.Io.Alignment);
108 }
109 break;
110
111 case ACPI_RSTYPE_FIXED_MEM32:
112 DEBUG_PRINT(TRACE_RESOURCES, ("FixedMemory32 0x%x/%d\n", res->Data.FixedMemory32.RangeBaseAddress,
113 res->Data.FixedMemory32.RangeLength));
112 ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "FixedMemory32 0x%x/%d\n", res->Data.FixedMemory32.RangeBaseAddress,
113 res->Data.FixedMemory32.RangeLength));
114 set->set_memory(dev, context, res->Data.FixedMemory32.RangeBaseAddress,
115 res->Data.FixedMemory32.RangeLength);
116 break;
117
118 case ACPI_RSTYPE_MEM32:
119 if (res->Data.Memory32.MinBaseAddress == res->Data.Memory32.MaxBaseAddress) {
114 set->set_memory(dev, context, res->Data.FixedMemory32.RangeBaseAddress,
115 res->Data.FixedMemory32.RangeLength);
116 break;
117
118 case ACPI_RSTYPE_MEM32:
119 if (res->Data.Memory32.MinBaseAddress == res->Data.Memory32.MaxBaseAddress) {
120 DEBUG_PRINT(TRACE_RESOURCES, ("Memory32 0x%x/%d\n", res->Data.Memory32.MinBaseAddress,
121 res->Data.Memory32.RangeLength));
120 ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "Memory32 0x%x/%d\n", res->Data.Memory32.MinBaseAddress,
121 res->Data.Memory32.RangeLength));
122 set->set_memory(dev, context, res->Data.Memory32.MinBaseAddress, res->Data.Memory32.RangeLength);
123 } else {
122 set->set_memory(dev, context, res->Data.Memory32.MinBaseAddress, res->Data.Memory32.RangeLength);
123 } else {
124 DEBUG_PRINT(TRACE_RESOURCES, ("Memory32 0x%x-0x%x/%d\n", res->Data.Memory32.MinBaseAddress,
125 res->Data.Memory32.MaxBaseAddress, res->Data.Memory32.RangeLength));
124 ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "Memory32 0x%x-0x%x/%d\n", res->Data.Memory32.MinBaseAddress,
125 res->Data.Memory32.MaxBaseAddress, res->Data.Memory32.RangeLength));
126 set->set_memoryrange(dev, context, res->Data.Memory32.MinBaseAddress, res->Data.Memory32.MaxBaseAddress,
127 res->Data.Memory32.RangeLength, res->Data.Memory32.Alignment);
128 }
129 break;
130
131 case ACPI_RSTYPE_MEM24:
132 if (res->Data.Memory24.MinBaseAddress == res->Data.Memory24.MaxBaseAddress) {
126 set->set_memoryrange(dev, context, res->Data.Memory32.MinBaseAddress, res->Data.Memory32.MaxBaseAddress,
127 res->Data.Memory32.RangeLength, res->Data.Memory32.Alignment);
128 }
129 break;
130
131 case ACPI_RSTYPE_MEM24:
132 if (res->Data.Memory24.MinBaseAddress == res->Data.Memory24.MaxBaseAddress) {
133 DEBUG_PRINT(TRACE_RESOURCES, ("Memory24 0x%x/%d\n", res->Data.Memory24.MinBaseAddress,
134 res->Data.Memory24.RangeLength));
133 ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "Memory24 0x%x/%d\n", res->Data.Memory24.MinBaseAddress,
134 res->Data.Memory24.RangeLength));
135 set->set_memory(dev, context, res->Data.Memory24.MinBaseAddress, res->Data.Memory24.RangeLength);
136 } else {
135 set->set_memory(dev, context, res->Data.Memory24.MinBaseAddress, res->Data.Memory24.RangeLength);
136 } else {
137 DEBUG_PRINT(TRACE_RESOURCES, ("Memory24 0x%x-0x%x/%d\n", res->Data.Memory24.MinBaseAddress,
138 res->Data.Memory24.MaxBaseAddress, res->Data.Memory24.RangeLength));
137 ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "Memory24 0x%x-0x%x/%d\n", res->Data.Memory24.MinBaseAddress,
138 res->Data.Memory24.MaxBaseAddress, res->Data.Memory24.RangeLength));
139 set->set_memoryrange(dev, context, res->Data.Memory24.MinBaseAddress, res->Data.Memory24.MaxBaseAddress,
140 res->Data.Memory24.RangeLength, res->Data.Memory24.Alignment);
141 }
142 break;
143
144 case ACPI_RSTYPE_IRQ:
145 for (i = 0; i < res->Data.Irq.NumberOfInterrupts; i++) {
139 set->set_memoryrange(dev, context, res->Data.Memory24.MinBaseAddress, res->Data.Memory24.MaxBaseAddress,
140 res->Data.Memory24.RangeLength, res->Data.Memory24.Alignment);
141 }
142 break;
143
144 case ACPI_RSTYPE_IRQ:
145 for (i = 0; i < res->Data.Irq.NumberOfInterrupts; i++) {
146 DEBUG_PRINT(TRACE_RESOURCES, ("Irq %d\n", res->Data.Irq.Interrupts[i]));
146 ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "Irq %d\n", res->Data.Irq.Interrupts[i]));
147 set->set_irq(dev, context, res->Data.Irq.Interrupts[i]);
148 }
149 break;
150
151 case ACPI_RSTYPE_DMA:
152 for (i = 0; i < res->Data.Dma.NumberOfChannels; i++) {
147 set->set_irq(dev, context, res->Data.Irq.Interrupts[i]);
148 }
149 break;
150
151 case ACPI_RSTYPE_DMA:
152 for (i = 0; i < res->Data.Dma.NumberOfChannels; i++) {
153 DEBUG_PRINT(TRACE_RESOURCES, ("Drq %d\n", res->Data.Dma.Channels[i]));
153 ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "Drq %d\n", res->Data.Dma.Channels[i]));
154 set->set_drq(dev, context, res->Data.Dma.Channels[i]);
155 }
156 break;
157
158 case ACPI_RSTYPE_START_DPF:
154 set->set_drq(dev, context, res->Data.Dma.Channels[i]);
155 }
156 break;
157
158 case ACPI_RSTYPE_START_DPF:
159 DEBUG_PRINT(TRACE_RESOURCES, ("start dependant functions"));
159 ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "start dependant functions"));
160 set->set_start_dependant(dev, context, res->Data.StartDpf.CompatibilityPriority);
161 break;
162
163 case ACPI_RSTYPE_END_DPF:
160 set->set_start_dependant(dev, context, res->Data.StartDpf.CompatibilityPriority);
161 break;
162
163 case ACPI_RSTYPE_END_DPF:
164 DEBUG_PRINT(TRACE_RESOURCES, ("end dependant functions"));
164 ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "end dependant functions"));
165 set->set_end_dependant(dev, context);
166 break;
167
168 case ACPI_RSTYPE_ADDRESS32:
165 set->set_end_dependant(dev, context);
166 break;
167
168 case ACPI_RSTYPE_ADDRESS32:
169 DEBUG_PRINT(TRACE_RESOURCES, ("unimplemented Address32 resource\n"));
169 ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "unimplemented Address32 resource\n"));
170 break;
171
172 case ACPI_RSTYPE_ADDRESS16:
170 break;
171
172 case ACPI_RSTYPE_ADDRESS16:
173 DEBUG_PRINT(TRACE_RESOURCES, ("unimplemented Address16 resource\n"));
173 ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "unimplemented Address16 resource\n"));
174 break;
175
176 case ACPI_RSTYPE_EXT_IRQ:
174 break;
175
176 case ACPI_RSTYPE_EXT_IRQ:
177 DEBUG_PRINT(TRACE_RESOURCES, ("unimplemented ExtendedIrq resource\n"));
177 ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "unimplemented ExtendedIrq resource\n"));
178 break;
179
180 case ACPI_RSTYPE_VENDOR:
178 break;
179
180 case ACPI_RSTYPE_VENDOR:
181 DEBUG_PRINT(TRACE_RESOURCES, ("unimplemented VendorSpecific resource\n"));
181 ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "unimplemented VendorSpecific resource\n"));
182 break;
183 default:
184 break;
185 }
186 }
187 AcpiOsFree(buf.Pointer);
188 set->set_done(dev, context);
189 return_ACPI_STATUS(AE_OK);

--- 133 unchanged lines hidden ---
182 break;
183 default:
184 break;
185 }
186 }
187 AcpiOsFree(buf.Pointer);
188 set->set_done(dev, context);
189 return_ACPI_STATUS(AE_OK);

--- 133 unchanged lines hidden ---