blob: 47e979e7ba3591a5deeb50ccf79e17695cfe73d2 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*******************************************************************************
2 *
3 * Module Name: rsmem24 - Memory resource descriptors
4 *
5 ******************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
Linus Torvalds1da177e2005-04-16 15:20:36 -070044#include <acpi/acpi.h>
45#include <acpi/acresrc.h>
46
47#define _COMPONENT ACPI_RESOURCES
Len Brown4be44fc2005-08-05 00:44:28 -040048ACPI_MODULE_NAME("rsmemory")
Linus Torvalds1da177e2005-04-16 15:20:36 -070049
50/*******************************************************************************
51 *
Bob Moore50eca3e2005-09-30 19:03:00 -040052 * FUNCTION: acpi_rs_get_memory24
Linus Torvalds1da177e2005-04-16 15:20:36 -070053 *
Bob Moore50eca3e2005-09-30 19:03:00 -040054 * PARAMETERS: Aml - Pointer to the AML resource descriptor
55 * aml_resource_length - Length of the resource from the AML header
56 * Resource - Where the internal resource is returned
Linus Torvalds1da177e2005-04-16 15:20:36 -070057 *
58 * RETURN: Status
59 *
Bob Moore50eca3e2005-09-30 19:03:00 -040060 * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding
61 * internal resource descriptor, simplifying bitflags and handling
62 * alignment and endian issues if necessary.
Linus Torvalds1da177e2005-04-16 15:20:36 -070063 *
64 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -070065acpi_status
Bob Moore50eca3e2005-09-30 19:03:00 -040066acpi_rs_get_memory24(union aml_resource * aml,
67 u16 aml_resource_length, struct acpi_resource * resource)
Linus Torvalds1da177e2005-04-16 15:20:36 -070068{
Bob Moore50eca3e2005-09-30 19:03:00 -040069 ACPI_FUNCTION_TRACE("rs_get_memory24");
Linus Torvalds1da177e2005-04-16 15:20:36 -070070
Bob Moore50eca3e2005-09-30 19:03:00 -040071 /* Get the Read/Write bit */
Linus Torvalds1da177e2005-04-16 15:20:36 -070072
Bob Moore50eca3e2005-09-30 19:03:00 -040073 resource->data.memory24.read_write_attribute =
74 (aml->memory24.information & 0x01);
Linus Torvalds1da177e2005-04-16 15:20:36 -070075
76 /*
Bob Moore50eca3e2005-09-30 19:03:00 -040077 * Get the following contiguous fields from the AML descriptor:
78 * Minimum Base Address
79 * Maximum Base Address
80 * Address Base Alignment
81 * Range Length
Linus Torvalds1da177e2005-04-16 15:20:36 -070082 */
Bob Moore50eca3e2005-09-30 19:03:00 -040083 acpi_rs_move_data(&resource->data.memory24.minimum,
84 &aml->memory24.minimum, 4, ACPI_MOVE_TYPE_16_TO_32);
Linus Torvalds1da177e2005-04-16 15:20:36 -070085
Bob Moore50eca3e2005-09-30 19:03:00 -040086 /* Complete the resource header */
Robert Moore44f6c012005-04-18 22:49:35 -040087
Bob Moore50eca3e2005-09-30 19:03:00 -040088 resource->type = ACPI_RESOURCE_TYPE_MEMORY24;
89 resource->length = ACPI_SIZEOF_RESOURCE(struct acpi_resource_memory24);
Len Brown4be44fc2005-08-05 00:44:28 -040090 return_ACPI_STATUS(AE_OK);
Linus Torvalds1da177e2005-04-16 15:20:36 -070091}
92
Linus Torvalds1da177e2005-04-16 15:20:36 -070093/*******************************************************************************
94 *
Bob Moore50eca3e2005-09-30 19:03:00 -040095 * FUNCTION: acpi_rs_set_memory24
Linus Torvalds1da177e2005-04-16 15:20:36 -070096 *
Bob Moore50eca3e2005-09-30 19:03:00 -040097 * PARAMETERS: Resource - Pointer to the resource descriptor
98 * Aml - Where the AML descriptor is returned
Linus Torvalds1da177e2005-04-16 15:20:36 -070099 *
100 * RETURN: Status
101 *
Bob Moore50eca3e2005-09-30 19:03:00 -0400102 * DESCRIPTION: Convert an internal resource descriptor to the corresponding
103 * external AML resource descriptor.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104 *
105 ******************************************************************************/
106
107acpi_status
Bob Moore50eca3e2005-09-30 19:03:00 -0400108acpi_rs_set_memory24(struct acpi_resource *resource, union aml_resource *aml)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109{
Bob Moore50eca3e2005-09-30 19:03:00 -0400110 ACPI_FUNCTION_TRACE("rs_set_memory24");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700111
Robert Moore44f6c012005-04-18 22:49:35 -0400112 /* Set the Information Byte */
113
Bob Moore50eca3e2005-09-30 19:03:00 -0400114 aml->memory24.information = (u8)
115 (resource->data.memory24.read_write_attribute & 0x01);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116
Bob Moore50eca3e2005-09-30 19:03:00 -0400117 /*
118 * Set the following contiguous fields in the AML descriptor:
119 * Minimum Base Address
120 * Maximum Base Address
121 * Address Base Alignment
122 * Range Length
123 */
124 acpi_rs_move_data(&aml->memory24.minimum,
125 &resource->data.memory24.minimum, 4,
126 ACPI_MOVE_TYPE_32_TO_16);
Robert Moore44f6c012005-04-18 22:49:35 -0400127
Bob Moore50eca3e2005-09-30 19:03:00 -0400128 /* Complete the AML descriptor header */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700129
Bob Moore50eca3e2005-09-30 19:03:00 -0400130 acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_MEMORY24,
131 sizeof(struct aml_resource_memory24), aml);
Len Brown4be44fc2005-08-05 00:44:28 -0400132 return_ACPI_STATUS(AE_OK);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700133}
134
Linus Torvalds1da177e2005-04-16 15:20:36 -0700135/*******************************************************************************
136 *
Bob Moore50eca3e2005-09-30 19:03:00 -0400137 * FUNCTION: acpi_rs_get_memory32
Linus Torvalds1da177e2005-04-16 15:20:36 -0700138 *
Bob Moore50eca3e2005-09-30 19:03:00 -0400139 * PARAMETERS: Aml - Pointer to the AML resource descriptor
140 * aml_resource_length - Length of the resource from the AML header
141 * Resource - Where the internal resource is returned
Linus Torvalds1da177e2005-04-16 15:20:36 -0700142 *
143 * RETURN: Status
144 *
Bob Moore50eca3e2005-09-30 19:03:00 -0400145 * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding
146 * internal resource descriptor, simplifying bitflags and handling
147 * alignment and endian issues if necessary.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700148 *
149 ******************************************************************************/
150
151acpi_status
Bob Moore50eca3e2005-09-30 19:03:00 -0400152acpi_rs_get_memory32(union aml_resource *aml,
153 u16 aml_resource_length, struct acpi_resource *resource)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700154{
Bob Moore50eca3e2005-09-30 19:03:00 -0400155 ACPI_FUNCTION_TRACE("rs_get_memory32");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700156
Bob Moore50eca3e2005-09-30 19:03:00 -0400157 /* Get the Read/Write bit */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700158
Bob Moore50eca3e2005-09-30 19:03:00 -0400159 resource->data.memory32.read_write_attribute =
160 (aml->memory32.information & 0x01);
Robert Moore44f6c012005-04-18 22:49:35 -0400161
Bob Moore50eca3e2005-09-30 19:03:00 -0400162 /*
163 * Get the following contiguous fields from the AML descriptor:
164 * Minimum Base Address
165 * Maximum Base Address
166 * Address Base Alignment
167 * Range Length
168 */
169 acpi_rs_move_data(&resource->data.memory32.minimum,
170 &aml->memory32.minimum, 4, ACPI_MOVE_TYPE_32_TO_32);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700171
Bob Moore50eca3e2005-09-30 19:03:00 -0400172 /* Complete the resource header */
Robert Moore44f6c012005-04-18 22:49:35 -0400173
Bob Moore50eca3e2005-09-30 19:03:00 -0400174 resource->type = ACPI_RESOURCE_TYPE_MEMORY32;
175 resource->length = ACPI_SIZEOF_RESOURCE(struct acpi_resource_memory32);
176 return_ACPI_STATUS(AE_OK);
177}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700178
Bob Moore50eca3e2005-09-30 19:03:00 -0400179/*******************************************************************************
180 *
181 * FUNCTION: acpi_rs_set_memory32
182 *
183 * PARAMETERS: Resource - Pointer to the resource descriptor
184 * Aml - Where the AML descriptor is returned
185 *
186 * RETURN: Status
187 *
188 * DESCRIPTION: Convert an internal resource descriptor to the corresponding
189 * external AML resource descriptor.
190 *
191 ******************************************************************************/
192
193acpi_status
194acpi_rs_set_memory32(struct acpi_resource *resource, union aml_resource *aml)
195{
196 ACPI_FUNCTION_TRACE("rs_set_memory32");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700197
Robert Moore44f6c012005-04-18 22:49:35 -0400198 /* Set the Information Byte */
199
Bob Moore50eca3e2005-09-30 19:03:00 -0400200 aml->memory32.information = (u8)
201 (resource->data.memory32.read_write_attribute & 0x01);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700202
Bob Moore50eca3e2005-09-30 19:03:00 -0400203 /*
204 * Set the following contiguous fields in the AML descriptor:
205 * Minimum Base Address
206 * Maximum Base Address
207 * Address Base Alignment
208 * Range Length
209 */
210 acpi_rs_move_data(&aml->memory32.minimum,
211 &resource->data.memory32.minimum, 4,
212 ACPI_MOVE_TYPE_32_TO_32);
Robert Moore44f6c012005-04-18 22:49:35 -0400213
Bob Moore50eca3e2005-09-30 19:03:00 -0400214 /* Complete the AML descriptor header */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700215
Bob Moore50eca3e2005-09-30 19:03:00 -0400216 acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_MEMORY32,
217 sizeof(struct aml_resource_memory32), aml);
218 return_ACPI_STATUS(AE_OK);
219}
Robert Moore44f6c012005-04-18 22:49:35 -0400220
Bob Moore50eca3e2005-09-30 19:03:00 -0400221/*******************************************************************************
222 *
223 * FUNCTION: acpi_rs_get_fixed_memory32
224 *
225 * PARAMETERS: Aml - Pointer to the AML resource descriptor
226 * aml_resource_length - Length of the resource from the AML header
227 * Resource - Where the internal resource is returned
228 *
229 * RETURN: Status
230 *
231 * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding
232 * internal resource descriptor, simplifying bitflags and handling
233 * alignment and endian issues if necessary.
234 *
235 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700236
Bob Moore50eca3e2005-09-30 19:03:00 -0400237acpi_status
238acpi_rs_get_fixed_memory32(union aml_resource *aml,
239 u16 aml_resource_length,
240 struct acpi_resource *resource)
241{
242 ACPI_FUNCTION_TRACE("rs_get_fixed_memory32");
Robert Moore44f6c012005-04-18 22:49:35 -0400243
Bob Moore50eca3e2005-09-30 19:03:00 -0400244 /* Get the Read/Write bit */
245
246 resource->data.fixed_memory32.read_write_attribute =
247 (aml->fixed_memory32.information & 0x01);
248
249 /*
250 * Get the following contiguous fields from the AML descriptor:
251 * Base Address
252 * Range Length
253 */
254 ACPI_MOVE_32_TO_32(&resource->data.fixed_memory32.address,
255 &aml->fixed_memory32.address);
256 ACPI_MOVE_32_TO_32(&resource->data.fixed_memory32.address_length,
257 &aml->fixed_memory32.address_length);
258
259 /* Complete the resource header */
260
261 resource->type = ACPI_RESOURCE_TYPE_FIXED_MEMORY32;
262 resource->length =
263 ACPI_SIZEOF_RESOURCE(struct acpi_resource_fixed_memory32);
264 return_ACPI_STATUS(AE_OK);
265}
266
267/*******************************************************************************
268 *
269 * FUNCTION: acpi_rs_set_fixed_memory32
270 *
271 * PARAMETERS: Resource - Pointer to the resource descriptor
272 * Aml - Where the AML descriptor is returned
273 *
274 * RETURN: Status
275 *
276 * DESCRIPTION: Convert an internal resource descriptor to the corresponding
277 * external AML resource descriptor.
278 *
279 ******************************************************************************/
280
281acpi_status
282acpi_rs_set_fixed_memory32(struct acpi_resource *resource,
283 union aml_resource *aml)
284{
285 ACPI_FUNCTION_TRACE("rs_set_fixed_memory32");
286
287 /* Set the Information Byte */
288
289 aml->fixed_memory32.information = (u8)
290 (resource->data.fixed_memory32.read_write_attribute & 0x01);
291
292 /*
293 * Set the following contiguous fields in the AML descriptor:
294 * Base Address
295 * Range Length
296 */
297 ACPI_MOVE_32_TO_32(&aml->fixed_memory32.address,
298 &resource->data.fixed_memory32.address);
299 ACPI_MOVE_32_TO_32(&aml->fixed_memory32.address_length,
300 &resource->data.fixed_memory32.address_length);
301
302 /* Complete the AML descriptor header */
303
304 acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_FIXED_MEMORY32,
305 sizeof(struct aml_resource_fixed_memory32),
306 aml);
Len Brown4be44fc2005-08-05 00:44:28 -0400307 return_ACPI_STATUS(AE_OK);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700308}