blob: 1033748e73ec8c4669224d6b84b3db15c09facc7 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/******************************************************************************
2 *
Bob Mooref3d2e782007-02-02 19:48:18 +03003 * Module Name: tbutils - table utilities
Linus Torvalds1da177e2005-04-16 15:20:36 -07004 *
5 *****************************************************************************/
6
7/*
Bob Moore4a90c7e2006-01-13 16:22:00 -05008 * Copyright (C) 2000 - 2006, R. Byron Moore
Linus Torvalds1da177e2005-04-16 15:20:36 -07009 * 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/actables.h>
46
Linus Torvalds1da177e2005-04-16 15:20:36 -070047#define _COMPONENT ACPI_TABLES
Len Brown4be44fc2005-08-05 00:44:28 -040048ACPI_MODULE_NAME("tbutils")
Linus Torvalds1da177e2005-04-16 15:20:36 -070049
Robert Moore44f6c012005-04-18 22:49:35 -040050/* Local prototypes */
Bob Moorea4bbb812007-02-02 19:48:19 +030051static acpi_physical_address
52acpi_tb_get_root_table_entry(u8 * table_entry,
53 acpi_native_uint table_entry_size);
54
Linus Torvalds1da177e2005-04-16 15:20:36 -070055/*******************************************************************************
56 *
Bob Mooref3d2e782007-02-02 19:48:18 +030057 * FUNCTION: acpi_tb_print_table_header
Robert Moore0c9938c2005-07-29 15:15:00 -070058 *
Bob Mooref3d2e782007-02-02 19:48:18 +030059 * PARAMETERS: Address - Table physical address
60 * Header - Table header
Robert Moore0c9938c2005-07-29 15:15:00 -070061 *
Bob Mooref3d2e782007-02-02 19:48:18 +030062 * RETURN: None
Robert Moore0c9938c2005-07-29 15:15:00 -070063 *
Bob Moorec5fc42a2007-02-02 19:48:19 +030064 * DESCRIPTION: Print an ACPI table header. Special cases for FACS and RSDP.
Robert Moore0c9938c2005-07-29 15:15:00 -070065 *
66 ******************************************************************************/
67
Bob Mooref3d2e782007-02-02 19:48:18 +030068void
69acpi_tb_print_table_header(acpi_physical_address address,
70 struct acpi_table_header *header)
Robert Moore0c9938c2005-07-29 15:15:00 -070071{
Robert Moore0c9938c2005-07-29 15:15:00 -070072
Bob Moorec5fc42a2007-02-02 19:48:19 +030073 if (ACPI_COMPARE_NAME(header->signature, ACPI_SIG_FACS)) {
74
75 /* FACS only has signature and length fields of common table header */
76
77 ACPI_INFO((AE_INFO, "%4.4s @ 0x%p/0x%04X",
78 header->signature, ACPI_CAST_PTR(void, address),
79 header->length));
80 } else if (ACPI_COMPARE_NAME(header->signature, ACPI_SIG_RSDP)) {
81
82 /* RSDP has no common fields */
83
84 ACPI_INFO((AE_INFO, "RSDP @ 0x%p/0x%04X (v%3.3d %6.6s)",
85 ACPI_CAST_PTR(void, address),
Bob Moorea4bbb812007-02-02 19:48:19 +030086 (ACPI_CAST_PTR(struct acpi_table_rsdp, header)->
87 revision >
88 0) ? ACPI_CAST_PTR(struct acpi_table_rsdp,
89 header)->length : 20,
90 ACPI_CAST_PTR(struct acpi_table_rsdp,
91 header)->revision,
92 ACPI_CAST_PTR(struct acpi_table_rsdp,
93 header)->oem_id));
Bob Moorec5fc42a2007-02-02 19:48:19 +030094 } else {
Bob Moore4bf27392007-02-02 19:48:19 +030095 /* Standard ACPI table with full common header */
96
Bob Moorec5fc42a2007-02-02 19:48:19 +030097 ACPI_INFO((AE_INFO,
98 "%4.4s @ 0x%p/0x%04X (v%3.3d %6.6s %8.8s 0x%08X %4.4s 0x%08X)",
99 header->signature, ACPI_CAST_PTR(void, address),
100 header->length, header->revision, header->oem_id,
101 header->oem_table_id, header->oem_revision,
102 header->asl_compiler_id,
103 header->asl_compiler_revision));
104 }
Bob Mooref3d2e782007-02-02 19:48:18 +0300105}
Robert Moore0c9938c2005-07-29 15:15:00 -0700106
Bob Mooref3d2e782007-02-02 19:48:18 +0300107/*******************************************************************************
108 *
Bob Moorec5fc42a2007-02-02 19:48:19 +0300109 * FUNCTION: acpi_tb_validate_checksum
110 *
111 * PARAMETERS: Table - ACPI table to verify
112 * Length - Length of entire table
113 *
114 * RETURN: Status
115 *
116 * DESCRIPTION: Verifies that the table checksums to zero. Optionally returns
117 * exception on bad checksum.
118 *
119 ******************************************************************************/
120
121acpi_status acpi_tb_verify_checksum(struct acpi_table_header *table, u32 length)
122{
123 u8 checksum;
124
125 /* Compute the checksum on the table */
126
127 checksum = acpi_tb_checksum(ACPI_CAST_PTR(u8, table), length);
128
129 /* Checksum ok? (should be zero) */
130
131 if (checksum) {
132 ACPI_WARNING((AE_INFO,
133 "Incorrect checksum in table [%4.4s] - %2.2X, should be %2.2X",
134 table->signature, table->checksum,
135 (u8) (table->checksum - checksum)));
136
137#if (ACPI_CHECKSUM_ABORT)
138
139 return (AE_BAD_CHECKSUM);
140#endif
141 }
142
143 return (AE_OK);
144}
145
146/*******************************************************************************
147 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300148 * FUNCTION: acpi_tb_checksum
149 *
150 * PARAMETERS: Buffer - Pointer to memory region to be checked
151 * Length - Length of this memory region
152 *
153 * RETURN: Checksum (u8)
154 *
155 * DESCRIPTION: Calculates circular checksum of memory region.
156 *
157 ******************************************************************************/
158
159u8 acpi_tb_checksum(u8 * buffer, acpi_native_uint length)
160{
161 u8 sum = 0;
162 u8 *end = buffer + length;
163
164 while (buffer < end) {
165 sum = (u8) (sum + *(buffer++));
166 }
167
168 return sum;
169}
170
171/*******************************************************************************
172 *
Bob Moorec5fc42a2007-02-02 19:48:19 +0300173 * FUNCTION: acpi_tb_install_table
Bob Mooref3d2e782007-02-02 19:48:18 +0300174 *
Bob Moorec5fc42a2007-02-02 19:48:19 +0300175 * PARAMETERS: Address - Physical address of DSDT or FACS
176 * Flags - Flags
177 * Signature - Table signature, NULL if no need to
178 * match
179 * table_index - Index into root table array
Bob Mooref3d2e782007-02-02 19:48:18 +0300180 *
Bob Moorec5fc42a2007-02-02 19:48:19 +0300181 * RETURN: None
Bob Mooref3d2e782007-02-02 19:48:18 +0300182 *
Bob Moorec5fc42a2007-02-02 19:48:19 +0300183 * DESCRIPTION: Install an ACPI table into the global data structure.
Bob Mooref3d2e782007-02-02 19:48:18 +0300184 *
185 ******************************************************************************/
186
Bob Moore765ec202007-02-02 19:48:20 +0300187void
Bob Moorec5fc42a2007-02-02 19:48:19 +0300188acpi_tb_install_table(acpi_physical_address address,
189 u8 flags, char *signature, acpi_native_uint table_index)
Bob Mooref3d2e782007-02-02 19:48:18 +0300190{
Bob Mooref3d2e782007-02-02 19:48:18 +0300191 struct acpi_table_header *table;
192
Bob Moorec5fc42a2007-02-02 19:48:19 +0300193 if (!address) {
194 ACPI_ERROR((AE_INFO,
195 "Null physical address for ACPI table [%s]",
196 signature));
Bob Mooref3d2e782007-02-02 19:48:18 +0300197 return;
198 }
199
Bob Moorec5fc42a2007-02-02 19:48:19 +0300200 /* Map just the table header */
201
202 table = acpi_os_map_memory(address, sizeof(struct acpi_table_header));
Bob Mooref3d2e782007-02-02 19:48:18 +0300203 if (!table) {
204 return;
205 }
206
Bob Moorec5fc42a2007-02-02 19:48:19 +0300207 /* If a particular signature is expected, signature must match */
208
209 if (signature && !ACPI_COMPARE_NAME(table->signature, signature)) {
210 ACPI_ERROR((AE_INFO,
211 "Invalid signature 0x%X for ACPI table [%s]",
212 *ACPI_CAST_PTR(u32, table->signature), signature));
213 goto unmap_and_exit;
214 }
215
216 /* Initialize the table entry */
217
218 acpi_gbl_root_table_list.tables[table_index].address = address;
219 acpi_gbl_root_table_list.tables[table_index].length = table->length;
220 acpi_gbl_root_table_list.tables[table_index].flags = flags;
Bob Mooref3d2e782007-02-02 19:48:18 +0300221
222 ACPI_MOVE_32_TO_32(&
Bob Moorec5fc42a2007-02-02 19:48:19 +0300223 (acpi_gbl_root_table_list.tables[table_index].
224 signature), table->signature);
Bob Mooref3d2e782007-02-02 19:48:18 +0300225
Bob Moorec5fc42a2007-02-02 19:48:19 +0300226 acpi_tb_print_table_header(address, table);
Bob Mooref3d2e782007-02-02 19:48:18 +0300227
Bob Moorec5fc42a2007-02-02 19:48:19 +0300228 if (table_index == ACPI_TABLE_INDEX_DSDT) {
Bob Mooref3d2e782007-02-02 19:48:18 +0300229
Bob Moorec5fc42a2007-02-02 19:48:19 +0300230 /* Global integer width is based upon revision of the DSDT */
231
232 acpi_ut_set_integer_width(table->revision);
233 }
234
235 unmap_and_exit:
Bob Mooref3d2e782007-02-02 19:48:18 +0300236 acpi_os_unmap_memory(table, sizeof(struct acpi_table_header));
237}
238
239/*******************************************************************************
240 *
Bob Moorea4bbb812007-02-02 19:48:19 +0300241 * FUNCTION: acpi_tb_get_root_table_entry
242 *
243 * PARAMETERS: table_entry - Pointer to the RSDT/XSDT table entry
244 * table_entry_size - sizeof 32 or 64 (RSDT or XSDT)
245 *
246 * RETURN: Physical address extracted from the root table
247 *
248 * DESCRIPTION: Get one root table entry. Handles 32-bit and 64-bit cases on
249 * both 32-bit and 64-bit platforms
250 *
251 * NOTE: acpi_physical_address is 32-bit on 32-bit platforms, 64-bit on
252 * 64-bit platforms.
253 *
254 ******************************************************************************/
255
256static acpi_physical_address
257acpi_tb_get_root_table_entry(u8 * table_entry,
258 acpi_native_uint table_entry_size)
259{
260 u64 address64;
261
262 /*
263 * Get the table physical address (32-bit for RSDT, 64-bit for XSDT):
264 * Note: Addresses are 32-bit aligned (not 64) in both RSDT and XSDT
265 */
266 if (table_entry_size == sizeof(u32)) {
267 /*
268 * 32-bit platform, RSDT: Return 32-bit table entry
269 * 64-bit platform, RSDT: Expand 32-bit to 64-bit and return
270 */
271 return ((acpi_physical_address)
272 (*ACPI_CAST_PTR(u32, table_entry)));
273 } else {
274 /*
275 * 32-bit platform, XSDT: Truncate 64-bit to 32-bit and return
276 * 64-bit platform, XSDT: Move (unaligned) 64-bit to local, return 64-bit
277 */
278 ACPI_MOVE_64_TO_64(&address64, table_entry);
279
280#if ACPI_MACHINE_WIDTH == 32
281 if (address64 > ACPI_UINT32_MAX) {
282
Bob Mooreea5d8eb2007-02-02 19:48:20 +0300283 /* Will truncate 64-bit address to 32 bits, issue warning */
Bob Moorea4bbb812007-02-02 19:48:19 +0300284
285 ACPI_WARNING((AE_INFO,
286 "64-bit Physical Address in XSDT is too large (%8.8X%8.8X), truncating",
287 ACPI_FORMAT_UINT64(address64)));
288 }
289#endif
290 return ((acpi_physical_address) (address64));
291 }
292}
293
294/*******************************************************************************
295 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300296 * FUNCTION: acpi_tb_parse_root_table
297 *
298 * PARAMETERS: Rsdp - Pointer to the RSDP
299 * Flags - Flags
300 *
301 * RETURN: Status
302 *
303 * DESCRIPTION: This function is called to parse the Root System Description
304 * Table (RSDT or XSDT)
305 *
306 * NOTE: Tables are mapped (not copied) for efficiency. The FACS must
307 * be mapped and cannot be copied because it contains the actual
308 * memory location of the ACPI Global Lock.
309 *
310 ******************************************************************************/
311
Alexey Starikovskiyad718602007-02-02 19:48:19 +0300312acpi_status __init
Bob Moorec5fc42a2007-02-02 19:48:19 +0300313acpi_tb_parse_root_table(acpi_physical_address rsdp_address, u8 flags)
Bob Mooref3d2e782007-02-02 19:48:18 +0300314{
Bob Moorec5fc42a2007-02-02 19:48:19 +0300315 struct acpi_table_rsdp *rsdp;
316 acpi_native_uint table_entry_size;
317 acpi_native_uint i;
318 u32 table_count;
Bob Mooref3d2e782007-02-02 19:48:18 +0300319 struct acpi_table_header *table;
320 acpi_physical_address address;
321 u32 length;
322 u8 *table_entry;
Bob Mooref3d2e782007-02-02 19:48:18 +0300323 acpi_status status;
324
325 ACPI_FUNCTION_TRACE(tb_parse_root_table);
326
Bob Moorec5fc42a2007-02-02 19:48:19 +0300327 /*
328 * Map the entire RSDP and extract the address of the RSDT or XSDT
329 */
330 rsdp = acpi_os_map_memory(rsdp_address, sizeof(struct acpi_table_rsdp));
331 if (!rsdp) {
332 return_ACPI_STATUS(AE_NO_MEMORY);
333 }
334
335 acpi_tb_print_table_header(rsdp_address,
336 ACPI_CAST_PTR(struct acpi_table_header,
337 rsdp));
338
Bob Mooref3d2e782007-02-02 19:48:18 +0300339 /* Differentiate between RSDT and XSDT root tables */
340
341 if (rsdp->revision > 1 && rsdp->xsdt_physical_address) {
Bob Moorea18ecf42005-08-15 03:42:00 -0800342 /*
Bob Mooref3d2e782007-02-02 19:48:18 +0300343 * Root table is an XSDT (64-bit physical addresses). We must use the
344 * XSDT if the revision is > 1 and the XSDT pointer is present, as per
345 * the ACPI specification.
Bob Moorea18ecf42005-08-15 03:42:00 -0800346 */
Bob Moorec5fc42a2007-02-02 19:48:19 +0300347 address = (acpi_physical_address) rsdp->xsdt_physical_address;
348 table_entry_size = sizeof(u64);
Bob Mooref3d2e782007-02-02 19:48:18 +0300349 } else {
350 /* Root table is an RSDT (32-bit physical addresses) */
Bob Moore52fc0b02006-10-02 00:00:00 -0400351
Bob Moorec5fc42a2007-02-02 19:48:19 +0300352 address = (acpi_physical_address) rsdp->rsdt_physical_address;
353 table_entry_size = sizeof(u32);
Bob Mooref3d2e782007-02-02 19:48:18 +0300354 }
Robert Moore0c9938c2005-07-29 15:15:00 -0700355
Bob Moorec5fc42a2007-02-02 19:48:19 +0300356 /*
357 * It is not possible to map more than one entry in some environments,
358 * so unmap the RSDP here before mapping other tables
359 */
360 acpi_os_unmap_memory(rsdp, sizeof(struct acpi_table_rsdp));
361
362 /* Map the RSDT/XSDT table header to get the full table length */
Robert Moore0c9938c2005-07-29 15:15:00 -0700363
Bob Mooref3d2e782007-02-02 19:48:18 +0300364 table = acpi_os_map_memory(address, sizeof(struct acpi_table_header));
365 if (!table) {
Bob Moorec5fc42a2007-02-02 19:48:19 +0300366 return_ACPI_STATUS(AE_NO_MEMORY);
Bob Mooref3d2e782007-02-02 19:48:18 +0300367 }
Robert Moore0c9938c2005-07-29 15:15:00 -0700368
Bob Moorec5fc42a2007-02-02 19:48:19 +0300369 acpi_tb_print_table_header(address, table);
370
Bob Mooref3d2e782007-02-02 19:48:18 +0300371 /* Get the length of the full table, verify length and map entire table */
372
373 length = table->length;
374 acpi_os_unmap_memory(table, sizeof(struct acpi_table_header));
375
376 if (length < sizeof(struct acpi_table_header)) {
377 ACPI_ERROR((AE_INFO, "Invalid length 0x%X in RSDT/XSDT",
378 length));
Bob Moorec5fc42a2007-02-02 19:48:19 +0300379 return_ACPI_STATUS(AE_INVALID_TABLE_LENGTH);
Bob Mooref3d2e782007-02-02 19:48:18 +0300380 }
381
382 table = acpi_os_map_memory(address, length);
383 if (!table) {
Bob Moorec5fc42a2007-02-02 19:48:19 +0300384 return_ACPI_STATUS(AE_NO_MEMORY);
Bob Mooref3d2e782007-02-02 19:48:18 +0300385 }
386
387 /* Validate the root table checksum */
388
Bob Moorec5fc42a2007-02-02 19:48:19 +0300389 status = acpi_tb_verify_checksum(table, length);
390 if (ACPI_FAILURE(status)) {
Bob Mooref3d2e782007-02-02 19:48:18 +0300391 acpi_os_unmap_memory(table, length);
Bob Moorec5fc42a2007-02-02 19:48:19 +0300392 return_ACPI_STATUS(status);
Bob Mooref3d2e782007-02-02 19:48:18 +0300393 }
Bob Mooref3d2e782007-02-02 19:48:18 +0300394
395 /* Calculate the number of tables described in the root table */
396
397 table_count =
Bob Moorea4bbb812007-02-02 19:48:19 +0300398 (u32) ((table->length -
399 sizeof(struct acpi_table_header)) / table_entry_size);
Bob Mooref3d2e782007-02-02 19:48:18 +0300400
Bob Moorec5fc42a2007-02-02 19:48:19 +0300401 /*
402 * First two entries in the table array are reserved for the DSDT and FACS,
403 * which are not actually present in the RSDT/XSDT - they come from the FADT
404 */
Bob Mooref3d2e782007-02-02 19:48:18 +0300405 table_entry =
406 ACPI_CAST_PTR(u8, table) + sizeof(struct acpi_table_header);
407 acpi_gbl_root_table_list.count = 2;
408
409 /*
Bob Moorec5fc42a2007-02-02 19:48:19 +0300410 * Initialize the root table array from the RSDT/XSDT
Bob Mooref3d2e782007-02-02 19:48:18 +0300411 */
Bob Moorec5fc42a2007-02-02 19:48:19 +0300412 for (i = 0; i < table_count; i++) {
Bob Mooref3d2e782007-02-02 19:48:18 +0300413 if (acpi_gbl_root_table_list.count >=
414 acpi_gbl_root_table_list.size) {
Bob Moorec5fc42a2007-02-02 19:48:19 +0300415
416 /* There is no more room in the root table array, attempt resize */
417
Bob Mooref3d2e782007-02-02 19:48:18 +0300418 status = acpi_tb_resize_root_table_list();
419 if (ACPI_FAILURE(status)) {
420 ACPI_WARNING((AE_INFO,
421 "Truncating %u table entries!",
422 (unsigned)
423 (acpi_gbl_root_table_list.size -
424 acpi_gbl_root_table_list.
425 count)));
426 break;
427 }
Robert Moore0c9938c2005-07-29 15:15:00 -0700428 }
429
Bob Moorea4bbb812007-02-02 19:48:19 +0300430 /* Get the table physical address (32-bit for RSDT, 64-bit for XSDT) */
431
432 acpi_gbl_root_table_list.tables[acpi_gbl_root_table_list.count].
433 address =
434 acpi_tb_get_root_table_entry(table_entry, table_entry_size);
Bob Mooref3d2e782007-02-02 19:48:18 +0300435
Bob Moorec5fc42a2007-02-02 19:48:19 +0300436 table_entry += table_entry_size;
Bob Mooref3d2e782007-02-02 19:48:18 +0300437 acpi_gbl_root_table_list.count++;
438 }
439
440 /*
441 * It is not possible to map more than one entry in some environments,
442 * so unmap the root table here before mapping other tables
443 */
444 acpi_os_unmap_memory(table, length);
445
Bob Moorec5fc42a2007-02-02 19:48:19 +0300446 /*
447 * Complete the initialization of the root table array by examining
448 * the header of each table
449 */
Bob Mooref3d2e782007-02-02 19:48:18 +0300450 for (i = 2; i < acpi_gbl_root_table_list.count; i++) {
Bob Moorec5fc42a2007-02-02 19:48:19 +0300451 acpi_tb_install_table(acpi_gbl_root_table_list.tables[i].
452 address, flags, NULL, i);
Bob Mooref3d2e782007-02-02 19:48:18 +0300453
Bob Moorec5fc42a2007-02-02 19:48:19 +0300454 /* Special case for FADT - get the DSDT and FACS */
Bob Mooref3d2e782007-02-02 19:48:18 +0300455
Bob Moorec5fc42a2007-02-02 19:48:19 +0300456 if (ACPI_COMPARE_NAME
457 (&acpi_gbl_root_table_list.tables[i].signature,
458 ACPI_SIG_FADT)) {
459 acpi_tb_parse_fadt(i, flags);
Bob Mooref3d2e782007-02-02 19:48:18 +0300460 }
Robert Moore0c9938c2005-07-29 15:15:00 -0700461 }
462
Len Brown4be44fc2005-08-05 00:44:28 -0400463 return_ACPI_STATUS(AE_OK);
Robert Moore0c9938c2005-07-29 15:15:00 -0700464}
465
Bob Mooref3d2e782007-02-02 19:48:18 +0300466/******************************************************************************
Robert Moore0c9938c2005-07-29 15:15:00 -0700467 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300468 * FUNCTION: acpi_tb_map
Linus Torvalds1da177e2005-04-16 15:20:36 -0700469 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300470 * PARAMETERS: Address - Address to be mapped
471 * Length - Length to be mapped
472 * Flags - Logical or physical addressing mode
Linus Torvalds1da177e2005-04-16 15:20:36 -0700473 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300474 * RETURN: Pointer to mapped region
Linus Torvalds1da177e2005-04-16 15:20:36 -0700475 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300476 * DESCRIPTION: Maps memory according to flag
Linus Torvalds1da177e2005-04-16 15:20:36 -0700477 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300478 *****************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700479
Bob Mooref3d2e782007-02-02 19:48:18 +0300480void *acpi_tb_map(acpi_physical_address address, u32 length, u32 flags)
Bob Moore793c2382006-03-31 00:00:00 -0500481{
482
Bob Mooref3d2e782007-02-02 19:48:18 +0300483 if (flags == ACPI_TABLE_ORIGIN_MAPPED) {
484 return (acpi_os_map_memory(address, length));
485 } else {
486 return (ACPI_CAST_PTR(void, address));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700487 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700488}
489
Bob Mooref3d2e782007-02-02 19:48:18 +0300490/******************************************************************************
Robert Moore44f6c012005-04-18 22:49:35 -0400491 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300492 * FUNCTION: acpi_tb_unmap
Robert Moore44f6c012005-04-18 22:49:35 -0400493 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300494 * PARAMETERS: Pointer - To mapped region
495 * Length - Length to be unmapped
496 * Flags - Logical or physical addressing mode
Robert Moore44f6c012005-04-18 22:49:35 -0400497 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300498 * RETURN: None
Robert Moore44f6c012005-04-18 22:49:35 -0400499 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300500 * DESCRIPTION: Unmaps memory according to flag
501 *
502 *****************************************************************************/
Robert Moore44f6c012005-04-18 22:49:35 -0400503
Bob Mooref3d2e782007-02-02 19:48:18 +0300504void acpi_tb_unmap(void *pointer, u32 length, u32 flags)
Robert Moore44f6c012005-04-18 22:49:35 -0400505{
Robert Moore44f6c012005-04-18 22:49:35 -0400506
Bob Mooref3d2e782007-02-02 19:48:18 +0300507 if (flags == ACPI_TABLE_ORIGIN_MAPPED) {
508 acpi_os_unmap_memory(pointer, length);
Robert Moore44f6c012005-04-18 22:49:35 -0400509 }
Robert Moore44f6c012005-04-18 22:49:35 -0400510}