aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/tables/tbxface.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/tables/tbxface.c')
-rw-r--r--drivers/acpi/tables/tbxface.c253
1 files changed, 117 insertions, 136 deletions
diff --git a/drivers/acpi/tables/tbxface.c b/drivers/acpi/tables/tbxface.c
index 0c0b9085dbeb..3f96a4909aad 100644
--- a/drivers/acpi/tables/tbxface.c
+++ b/drivers/acpi/tables/tbxface.c
@@ -48,10 +48,8 @@
48#include <acpi/acnamesp.h> 48#include <acpi/acnamesp.h>
49#include <acpi/actables.h> 49#include <acpi/actables.h>
50 50
51
52#define _COMPONENT ACPI_TABLES 51#define _COMPONENT ACPI_TABLES
53 ACPI_MODULE_NAME ("tbxface") 52ACPI_MODULE_NAME("tbxface")
54
55 53
56/******************************************************************************* 54/*******************************************************************************
57 * 55 *
@@ -65,25 +63,20 @@
65 * provided RSDT 63 * provided RSDT
66 * 64 *
67 ******************************************************************************/ 65 ******************************************************************************/
68 66acpi_status acpi_load_tables(void)
69acpi_status
70acpi_load_tables (
71 void)
72{ 67{
73 struct acpi_pointer rsdp_address; 68 struct acpi_pointer rsdp_address;
74 acpi_status status; 69 acpi_status status;
75
76
77 ACPI_FUNCTION_TRACE ("acpi_load_tables");
78 70
71 ACPI_FUNCTION_TRACE("acpi_load_tables");
79 72
80 /* Get the RSDP */ 73 /* Get the RSDP */
81 74
82 status = acpi_os_get_root_pointer (ACPI_LOGICAL_ADDRESSING, 75 status = acpi_os_get_root_pointer(ACPI_LOGICAL_ADDRESSING,
83 &rsdp_address); 76 &rsdp_address);
84 if (ACPI_FAILURE (status)) { 77 if (ACPI_FAILURE(status)) {
85 ACPI_REPORT_ERROR (("acpi_load_tables: Could not get RSDP, %s\n", 78 ACPI_REPORT_ERROR(("acpi_load_tables: Could not get RSDP, %s\n",
86 acpi_format_exception (status))); 79 acpi_format_exception(status)));
87 goto error_exit; 80 goto error_exit;
88 } 81 }
89 82
@@ -91,54 +84,47 @@ acpi_load_tables (
91 84
92 acpi_gbl_table_flags = rsdp_address.pointer_type; 85 acpi_gbl_table_flags = rsdp_address.pointer_type;
93 86
94 status = acpi_tb_verify_rsdp (&rsdp_address); 87 status = acpi_tb_verify_rsdp(&rsdp_address);
95 if (ACPI_FAILURE (status)) { 88 if (ACPI_FAILURE(status)) {
96 ACPI_REPORT_ERROR (("acpi_load_tables: RSDP Failed validation: %s\n", 89 ACPI_REPORT_ERROR(("acpi_load_tables: RSDP Failed validation: %s\n", acpi_format_exception(status)));
97 acpi_format_exception (status)));
98 goto error_exit; 90 goto error_exit;
99 } 91 }
100 92
101 /* Get the RSDT via the RSDP */ 93 /* Get the RSDT via the RSDP */
102 94
103 status = acpi_tb_get_table_rsdt (); 95 status = acpi_tb_get_table_rsdt();
104 if (ACPI_FAILURE (status)) { 96 if (ACPI_FAILURE(status)) {
105 ACPI_REPORT_ERROR (("acpi_load_tables: Could not load RSDT: %s\n", 97 ACPI_REPORT_ERROR(("acpi_load_tables: Could not load RSDT: %s\n", acpi_format_exception(status)));
106 acpi_format_exception (status)));
107 goto error_exit; 98 goto error_exit;
108 } 99 }
109 100
110 /* Now get the tables needed by this subsystem (FADT, DSDT, etc.) */ 101 /* Now get the tables needed by this subsystem (FADT, DSDT, etc.) */
111 102
112 status = acpi_tb_get_required_tables (); 103 status = acpi_tb_get_required_tables();
113 if (ACPI_FAILURE (status)) { 104 if (ACPI_FAILURE(status)) {
114 ACPI_REPORT_ERROR (( 105 ACPI_REPORT_ERROR(("acpi_load_tables: Error getting required tables (DSDT/FADT/FACS): %s\n", acpi_format_exception(status)));
115 "acpi_load_tables: Error getting required tables (DSDT/FADT/FACS): %s\n",
116 acpi_format_exception (status)));
117 goto error_exit; 106 goto error_exit;
118 } 107 }
119 108
120 ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "ACPI Tables successfully acquired\n")); 109 ACPI_DEBUG_PRINT((ACPI_DB_INIT, "ACPI Tables successfully acquired\n"));
121 110
122 /* Load the namespace from the tables */ 111 /* Load the namespace from the tables */
123 112
124 status = acpi_ns_load_namespace (); 113 status = acpi_ns_load_namespace();
125 if (ACPI_FAILURE (status)) { 114 if (ACPI_FAILURE(status)) {
126 ACPI_REPORT_ERROR (("acpi_load_tables: Could not load namespace: %s\n", 115 ACPI_REPORT_ERROR(("acpi_load_tables: Could not load namespace: %s\n", acpi_format_exception(status)));
127 acpi_format_exception (status)));
128 goto error_exit; 116 goto error_exit;
129 } 117 }
130 118
131 return_ACPI_STATUS (AE_OK); 119 return_ACPI_STATUS(AE_OK);
132 120
121 error_exit:
122 ACPI_REPORT_ERROR(("acpi_load_tables: Could not load tables: %s\n",
123 acpi_format_exception(status)));
133 124
134error_exit: 125 return_ACPI_STATUS(status);
135 ACPI_REPORT_ERROR (("acpi_load_tables: Could not load tables: %s\n",
136 acpi_format_exception (status)));
137
138 return_ACPI_STATUS (status);
139} 126}
140 127
141
142#ifdef ACPI_FUTURE_USAGE 128#ifdef ACPI_FUTURE_USAGE
143/******************************************************************************* 129/*******************************************************************************
144 * 130 *
@@ -156,40 +142,49 @@ error_exit:
156 * 142 *
157 ******************************************************************************/ 143 ******************************************************************************/
158 144
159acpi_status 145acpi_status acpi_load_table(struct acpi_table_header *table_ptr)
160acpi_load_table (
161 struct acpi_table_header *table_ptr)
162{ 146{
163 acpi_status status; 147 acpi_status status;
164 struct acpi_table_desc table_info; 148 struct acpi_table_desc table_info;
165 struct acpi_pointer address; 149 struct acpi_pointer address;
166
167
168 ACPI_FUNCTION_TRACE ("acpi_load_table");
169 150
151 ACPI_FUNCTION_TRACE("acpi_load_table");
170 152
171 if (!table_ptr) { 153 if (!table_ptr) {
172 return_ACPI_STATUS (AE_BAD_PARAMETER); 154 return_ACPI_STATUS(AE_BAD_PARAMETER);
173 } 155 }
174 156
175 /* Copy the table to a local buffer */ 157 /* Copy the table to a local buffer */
176 158
177 address.pointer_type = ACPI_LOGICAL_POINTER | ACPI_LOGICAL_ADDRESSING; 159 address.pointer_type = ACPI_LOGICAL_POINTER | ACPI_LOGICAL_ADDRESSING;
178 address.pointer.logical = table_ptr; 160 address.pointer.logical = table_ptr;
179 161
180 status = acpi_tb_get_table_body (&address, table_ptr, &table_info); 162 status = acpi_tb_get_table_body(&address, table_ptr, &table_info);
181 if (ACPI_FAILURE (status)) { 163 if (ACPI_FAILURE(status)) {
182 return_ACPI_STATUS (status); 164 return_ACPI_STATUS(status);
165 }
166
167 /* Check signature for a valid table type */
168
169 status = acpi_tb_recognize_table(&table_info, ACPI_TABLE_ALL);
170 if (ACPI_FAILURE(status)) {
171 return_ACPI_STATUS(status);
183 } 172 }
184 173
185 /* Install the new table into the local data structures */ 174 /* Install the new table into the local data structures */
186 175
187 status = acpi_tb_install_table (&table_info); 176 status = acpi_tb_install_table(&table_info);
188 if (ACPI_FAILURE (status)) { 177 if (ACPI_FAILURE(status)) {
178 if (status == AE_ALREADY_EXISTS) {
179 /* Table already exists, no error */
180
181 status = AE_OK;
182 }
183
189 /* Free table allocated by acpi_tb_get_table_body */ 184 /* Free table allocated by acpi_tb_get_table_body */
190 185
191 acpi_tb_delete_single_table (&table_info); 186 acpi_tb_delete_single_table(&table_info);
192 return_ACPI_STATUS (status); 187 return_ACPI_STATUS(status);
193 } 188 }
194 189
195 /* Convert the table to common format if necessary */ 190 /* Convert the table to common format if necessary */
@@ -197,31 +192,32 @@ acpi_load_table (
197 switch (table_info.type) { 192 switch (table_info.type) {
198 case ACPI_TABLE_FADT: 193 case ACPI_TABLE_FADT:
199 194
200 status = acpi_tb_convert_table_fadt (); 195 status = acpi_tb_convert_table_fadt();
201 break; 196 break;
202 197
203 case ACPI_TABLE_FACS: 198 case ACPI_TABLE_FACS:
204 199
205 status = acpi_tb_build_common_facs (&table_info); 200 status = acpi_tb_build_common_facs(&table_info);
206 break; 201 break;
207 202
208 default: 203 default:
209 /* Load table into namespace if it contains executable AML */ 204 /* Load table into namespace if it contains executable AML */
210 205
211 status = acpi_ns_load_table (table_info.installed_desc, acpi_gbl_root_node); 206 status =
207 acpi_ns_load_table(table_info.installed_desc,
208 acpi_gbl_root_node);
212 break; 209 break;
213 } 210 }
214 211
215 if (ACPI_FAILURE (status)) { 212 if (ACPI_FAILURE(status)) {
216 /* Uninstall table and free the buffer */ 213 /* Uninstall table and free the buffer */
217 214
218 (void) acpi_tb_uninstall_table (table_info.installed_desc); 215 (void)acpi_tb_uninstall_table(table_info.installed_desc);
219 } 216 }
220 217
221 return_ACPI_STATUS (status); 218 return_ACPI_STATUS(status);
222} 219}
223 220
224
225/******************************************************************************* 221/*******************************************************************************
226 * 222 *
227 * FUNCTION: acpi_unload_table 223 * FUNCTION: acpi_unload_table
@@ -234,20 +230,16 @@ acpi_load_table (
234 * 230 *
235 ******************************************************************************/ 231 ******************************************************************************/
236 232
237acpi_status 233acpi_status acpi_unload_table(acpi_table_type table_type)
238acpi_unload_table (
239 acpi_table_type table_type)
240{ 234{
241 struct acpi_table_desc *table_desc; 235 struct acpi_table_desc *table_desc;
242
243
244 ACPI_FUNCTION_TRACE ("acpi_unload_table");
245 236
237 ACPI_FUNCTION_TRACE("acpi_unload_table");
246 238
247 /* Parameter validation */ 239 /* Parameter validation */
248 240
249 if (table_type > ACPI_TABLE_MAX) { 241 if (table_type > ACPI_TABLE_MAX) {
250 return_ACPI_STATUS (AE_BAD_PARAMETER); 242 return_ACPI_STATUS(AE_BAD_PARAMETER);
251 } 243 }
252 244
253 /* Find all tables of the requested type */ 245 /* Find all tables of the requested type */
@@ -260,18 +252,17 @@ acpi_unload_table (
260 * "Scope" operator. Thus, we need to track ownership by an ID, not 252 * "Scope" operator. Thus, we need to track ownership by an ID, not
261 * simply a position within the hierarchy 253 * simply a position within the hierarchy
262 */ 254 */
263 acpi_ns_delete_namespace_by_owner (table_desc->table_id); 255 acpi_ns_delete_namespace_by_owner(table_desc->owner_id);
264 256 acpi_ut_release_owner_id(&table_desc->owner_id);
265 table_desc = table_desc->next; 257 table_desc = table_desc->next;
266 } 258 }
267 259
268 /* Delete (or unmap) all tables of this type */ 260 /* Delete (or unmap) all tables of this type */
269 261
270 acpi_tb_delete_tables_by_type (table_type); 262 acpi_tb_delete_tables_by_type(table_type);
271 return_ACPI_STATUS (AE_OK); 263 return_ACPI_STATUS(AE_OK);
272} 264}
273 265
274
275/******************************************************************************* 266/*******************************************************************************
276 * 267 *
277 * FUNCTION: acpi_get_table_header 268 * FUNCTION: acpi_get_table_header
@@ -294,54 +285,49 @@ acpi_unload_table (
294 ******************************************************************************/ 285 ******************************************************************************/
295 286
296acpi_status 287acpi_status
297acpi_get_table_header ( 288acpi_get_table_header(acpi_table_type table_type,
298 acpi_table_type table_type, 289 u32 instance, struct acpi_table_header *out_table_header)
299 u32 instance,
300 struct acpi_table_header *out_table_header)
301{ 290{
302 struct acpi_table_header *tbl_ptr; 291 struct acpi_table_header *tbl_ptr;
303 acpi_status status; 292 acpi_status status;
304 293
294 ACPI_FUNCTION_TRACE("acpi_get_table_header");
305 295
306 ACPI_FUNCTION_TRACE ("acpi_get_table_header"); 296 if ((instance == 0) ||
307 297 (table_type == ACPI_TABLE_RSDP) || (!out_table_header)) {
308 298 return_ACPI_STATUS(AE_BAD_PARAMETER);
309 if ((instance == 0) ||
310 (table_type == ACPI_TABLE_RSDP) ||
311 (!out_table_header)) {
312 return_ACPI_STATUS (AE_BAD_PARAMETER);
313 } 299 }
314 300
315 /* Check the table type and instance */ 301 /* Check the table type and instance */
316 302
317 if ((table_type > ACPI_TABLE_MAX) || 303 if ((table_type > ACPI_TABLE_MAX) ||
318 (ACPI_IS_SINGLE_TABLE (acpi_gbl_table_data[table_type].flags) && 304 (ACPI_IS_SINGLE_TABLE(acpi_gbl_table_data[table_type].flags) &&
319 instance > 1)) { 305 instance > 1)) {
320 return_ACPI_STATUS (AE_BAD_PARAMETER); 306 return_ACPI_STATUS(AE_BAD_PARAMETER);
321 } 307 }
322 308
323 /* Get a pointer to the entire table */ 309 /* Get a pointer to the entire table */
324 310
325 status = acpi_tb_get_table_ptr (table_type, instance, &tbl_ptr); 311 status = acpi_tb_get_table_ptr(table_type, instance, &tbl_ptr);
326 if (ACPI_FAILURE (status)) { 312 if (ACPI_FAILURE(status)) {
327 return_ACPI_STATUS (status); 313 return_ACPI_STATUS(status);
328 } 314 }
329 315
330 /* The function will return a NULL pointer if the table is not loaded */ 316 /* The function will return a NULL pointer if the table is not loaded */
331 317
332 if (tbl_ptr == NULL) { 318 if (tbl_ptr == NULL) {
333 return_ACPI_STATUS (AE_NOT_EXIST); 319 return_ACPI_STATUS(AE_NOT_EXIST);
334 } 320 }
335 321
336 /* Copy the header to the caller's buffer */ 322 /* Copy the header to the caller's buffer */
337 323
338 ACPI_MEMCPY ((void *) out_table_header, (void *) tbl_ptr, 324 ACPI_MEMCPY((void *)out_table_header, (void *)tbl_ptr,
339 sizeof (struct acpi_table_header)); 325 sizeof(struct acpi_table_header));
340 326
341 return_ACPI_STATUS (status); 327 return_ACPI_STATUS(status);
342} 328}
343 329
344#endif /* ACPI_FUTURE_USAGE */ 330#endif /* ACPI_FUTURE_USAGE */
345 331
346/******************************************************************************* 332/*******************************************************************************
347 * 333 *
@@ -367,43 +353,39 @@ acpi_get_table_header (
367 ******************************************************************************/ 353 ******************************************************************************/
368 354
369acpi_status 355acpi_status
370acpi_get_table ( 356acpi_get_table(acpi_table_type table_type,
371 acpi_table_type table_type, 357 u32 instance, struct acpi_buffer *ret_buffer)
372 u32 instance,
373 struct acpi_buffer *ret_buffer)
374{ 358{
375 struct acpi_table_header *tbl_ptr; 359 struct acpi_table_header *tbl_ptr;
376 acpi_status status; 360 acpi_status status;
377 acpi_size table_length; 361 acpi_size table_length;
378
379
380 ACPI_FUNCTION_TRACE ("acpi_get_table");
381 362
363 ACPI_FUNCTION_TRACE("acpi_get_table");
382 364
383 /* Parameter validation */ 365 /* Parameter validation */
384 366
385 if (instance == 0) { 367 if (instance == 0) {
386 return_ACPI_STATUS (AE_BAD_PARAMETER); 368 return_ACPI_STATUS(AE_BAD_PARAMETER);
387 } 369 }
388 370
389 status = acpi_ut_validate_buffer (ret_buffer); 371 status = acpi_ut_validate_buffer(ret_buffer);
390 if (ACPI_FAILURE (status)) { 372 if (ACPI_FAILURE(status)) {
391 return_ACPI_STATUS (status); 373 return_ACPI_STATUS(status);
392 } 374 }
393 375
394 /* Check the table type and instance */ 376 /* Check the table type and instance */
395 377
396 if ((table_type > ACPI_TABLE_MAX) || 378 if ((table_type > ACPI_TABLE_MAX) ||
397 (ACPI_IS_SINGLE_TABLE (acpi_gbl_table_data[table_type].flags) && 379 (ACPI_IS_SINGLE_TABLE(acpi_gbl_table_data[table_type].flags) &&
398 instance > 1)) { 380 instance > 1)) {
399 return_ACPI_STATUS (AE_BAD_PARAMETER); 381 return_ACPI_STATUS(AE_BAD_PARAMETER);
400 } 382 }
401 383
402 /* Get a pointer to the entire table */ 384 /* Get a pointer to the entire table */
403 385
404 status = acpi_tb_get_table_ptr (table_type, instance, &tbl_ptr); 386 status = acpi_tb_get_table_ptr(table_type, instance, &tbl_ptr);
405 if (ACPI_FAILURE (status)) { 387 if (ACPI_FAILURE(status)) {
406 return_ACPI_STATUS (status); 388 return_ACPI_STATUS(status);
407 } 389 }
408 390
409 /* 391 /*
@@ -411,7 +393,7 @@ acpi_get_table (
411 * table is not loaded. 393 * table is not loaded.
412 */ 394 */
413 if (tbl_ptr == NULL) { 395 if (tbl_ptr == NULL) {
414 return_ACPI_STATUS (AE_NOT_EXIST); 396 return_ACPI_STATUS(AE_NOT_EXIST);
415 } 397 }
416 398
417 /* Get the table length */ 399 /* Get the table length */
@@ -419,23 +401,22 @@ acpi_get_table (
419 if (table_type == ACPI_TABLE_RSDP) { 401 if (table_type == ACPI_TABLE_RSDP) {
420 /* RSD PTR is the only "table" without a header */ 402 /* RSD PTR is the only "table" without a header */
421 403
422 table_length = sizeof (struct rsdp_descriptor); 404 table_length = sizeof(struct rsdp_descriptor);
423 } 405 } else {
424 else {
425 table_length = (acpi_size) tbl_ptr->length; 406 table_length = (acpi_size) tbl_ptr->length;
426 } 407 }
427 408
428 /* Validate/Allocate/Clear caller buffer */ 409 /* Validate/Allocate/Clear caller buffer */
429 410
430 status = acpi_ut_initialize_buffer (ret_buffer, table_length); 411 status = acpi_ut_initialize_buffer(ret_buffer, table_length);
431 if (ACPI_FAILURE (status)) { 412 if (ACPI_FAILURE(status)) {
432 return_ACPI_STATUS (status); 413 return_ACPI_STATUS(status);
433 } 414 }
434 415
435 /* Copy the table to the buffer */ 416 /* Copy the table to the buffer */
436 417
437 ACPI_MEMCPY ((void *) ret_buffer->pointer, (void *) tbl_ptr, table_length); 418 ACPI_MEMCPY((void *)ret_buffer->pointer, (void *)tbl_ptr, table_length);
438 return_ACPI_STATUS (AE_OK); 419 return_ACPI_STATUS(AE_OK);
439} 420}
440EXPORT_SYMBOL(acpi_get_table);
441 421
422EXPORT_SYMBOL(acpi_get_table);