1 /* 2 * acpi_utils.c - ACPI Utility Functions ($Revision: 10 $) 3 * 4 * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com> 5 * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com> 6 * 7 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 8 * 9 * This program is free software; you can redistribute it and/or modify 10 * it under the terms of the GNU General Public License as published by 11 * the Free Software Foundation; either version 2 of the License, or (at 12 * your option) any later version. 13 * 14 * This program is distributed in the hope that it will be useful, but 15 * WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 * General Public License for more details. 18 * 19 * You should have received a copy of the GNU General Public License along 20 * with this program; if not, write to the Free Software Foundation, Inc., 21 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. 22 * 23 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 24 */ 25 26 #include <precomp.h> 27 #include <ntstrsafe.h> 28 29 #define NDEBUG 30 #include <debug.h> 31 32 /* Modified for ReactOS and latest ACPICA 33 * Copyright (C)2009 Samuel Serapion 34 */ 35 36 #define _COMPONENT ACPI_BUS_COMPONENT 37 ACPI_MODULE_NAME ("acpi_utils") 38 39 static void 40 acpi_util_eval_error(ACPI_HANDLE h, ACPI_STRING p, ACPI_STATUS s) 41 { 42 #ifdef ACPI_DEBUG_OUTPUT 43 char prefix[80] = {'\0'}; 44 ACPI_BUFFER buffer = {sizeof(prefix), prefix}; 45 AcpiGetName(h, ACPI_FULL_PATHNAME, &buffer); 46 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Evaluate [%s.%s]: %s\n", 47 (char *) prefix, p, AcpiFormatException(s))); 48 #else 49 return; 50 #endif 51 } 52 53 54 /* -------------------------------------------------------------------------- 55 Object Evaluation Helpers 56 -------------------------------------------------------------------------- */ 57 58 59 ACPI_STATUS 60 acpi_extract_package ( 61 ACPI_OBJECT *package, 62 ACPI_BUFFER *format, 63 ACPI_BUFFER *buffer) 64 { 65 UINT32 size_required = 0; 66 UINT32 tail_offset = 0; 67 char *format_string = NULL; 68 UINT32 format_count = 0; 69 UINT32 i = 0; 70 UINT8 *head = NULL; 71 UINT8 *tail = NULL; 72 73 if (!package || (package->Type != ACPI_TYPE_PACKAGE) || (package->Package.Count < 1)) { 74 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Invalid 'package' argument\n")); 75 return_ACPI_STATUS(AE_BAD_PARAMETER); 76 } 77 78 if (!format || !format->Pointer || (format->Length < 1)) { 79 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Invalid 'format' argument\n")); 80 return_ACPI_STATUS(AE_BAD_PARAMETER); 81 } 82 83 if (!buffer) { 84 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Invalid 'buffer' argument\n")); 85 return_ACPI_STATUS(AE_BAD_PARAMETER); 86 } 87 88 format_count = (format->Length/sizeof(char)) - 1; 89 if (format_count > package->Package.Count) { 90 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Format specifies more objects [%d] than exist in package [%d].", format_count, package->package.count)); 91 return_ACPI_STATUS(AE_BAD_DATA); 92 } 93 94 format_string = format->Pointer; 95 96 /* 97 * Calculate size_required. 98 */ 99 for (i=0; i<format_count; i++) { 100 101 ACPI_OBJECT *element = &(package->Package.Elements[i]); 102 103 if (!element) { 104 return_ACPI_STATUS(AE_BAD_DATA); 105 } 106 107 switch (element->Type) { 108 109 case ACPI_TYPE_INTEGER: 110 switch (format_string[i]) { 111 case 'N': 112 size_required += sizeof(ACPI_INTEGER); 113 tail_offset += sizeof(ACPI_INTEGER); 114 break; 115 case 'S': 116 size_required += sizeof(char*) + sizeof(ACPI_INTEGER) + sizeof(char); 117 tail_offset += sizeof(char*); 118 break; 119 default: 120 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Invalid package element [%d]: got number, expecting [%c].\n", i, format_string[i])); 121 return_ACPI_STATUS(AE_BAD_DATA); 122 break; 123 } 124 break; 125 126 case ACPI_TYPE_STRING: 127 case ACPI_TYPE_BUFFER: 128 switch (format_string[i]) { 129 case 'S': 130 size_required += sizeof(char*) + (element->String.Length * sizeof(char)) + sizeof(char); 131 tail_offset += sizeof(char*); 132 break; 133 case 'B': 134 size_required += sizeof(UINT8*) + (element->Buffer.Length * sizeof(UINT8)); 135 tail_offset += sizeof(UINT8*); 136 break; 137 default: 138 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Invalid package element [%d] got string/buffer, expecting [%c].\n", i, format_string[i])); 139 return_ACPI_STATUS(AE_BAD_DATA); 140 break; 141 } 142 break; 143 144 case ACPI_TYPE_PACKAGE: 145 default: 146 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found unsupported element at index=%d\n", i)); 147 /* TBD: handle nested packages... */ 148 return_ACPI_STATUS(AE_SUPPORT); 149 break; 150 } 151 } 152 153 /* 154 * Validate output buffer. 155 */ 156 if (buffer->Length < size_required) { 157 buffer->Length = size_required; 158 return_ACPI_STATUS(AE_BUFFER_OVERFLOW); 159 } 160 else if (buffer->Length != size_required || !buffer->Pointer) { 161 return_ACPI_STATUS(AE_BAD_PARAMETER); 162 } 163 164 head = buffer->Pointer; 165 tail = ((PUCHAR)buffer->Pointer) + tail_offset; 166 167 /* 168 * Extract package data. 169 */ 170 for (i=0; i<format_count; i++) { 171 172 UINT8 **pointer = NULL; 173 ACPI_OBJECT *element = &(package->Package.Elements[i]); 174 175 if (!element) { 176 return_ACPI_STATUS(AE_BAD_DATA); 177 } 178 179 switch (element->Type) { 180 181 case ACPI_TYPE_INTEGER: 182 switch (format_string[i]) { 183 case 'N': 184 *((ACPI_INTEGER*)head) = element->Integer.Value; 185 head += sizeof(ACPI_INTEGER); 186 break; 187 case 'S': 188 pointer = (UINT8**)head; 189 *pointer = tail; 190 *((ACPI_INTEGER*)tail) = element->Integer.Value; 191 head += sizeof(ACPI_INTEGER*); 192 tail += sizeof(ACPI_INTEGER); 193 /* NULL terminate string */ 194 *tail = (char)0; 195 tail += sizeof(char); 196 break; 197 default: 198 /* Should never get here */ 199 break; 200 } 201 break; 202 203 case ACPI_TYPE_STRING: 204 case ACPI_TYPE_BUFFER: 205 switch (format_string[i]) { 206 case 'S': 207 pointer = (UINT8**)head; 208 *pointer = tail; 209 memcpy(tail, element->String.Pointer, element->String.Length); 210 head += sizeof(char*); 211 tail += element->String.Length * sizeof(char); 212 /* NULL terminate string */ 213 *tail = (char)0; 214 tail += sizeof(char); 215 break; 216 case 'B': 217 pointer = (UINT8**)head; 218 *pointer = tail; 219 memcpy(tail, element->Buffer.Pointer, element->Buffer.Length); 220 head += sizeof(UINT8*); 221 tail += element->Buffer.Length * sizeof(UINT8); 222 break; 223 default: 224 /* Should never get here */ 225 break; 226 } 227 break; 228 229 case ACPI_TYPE_PACKAGE: 230 /* TBD: handle nested packages... */ 231 default: 232 /* Should never get here */ 233 break; 234 } 235 } 236 237 return_ACPI_STATUS(AE_OK); 238 } 239 240 241 ACPI_STATUS 242 acpi_evaluate_integer ( 243 ACPI_HANDLE handle, 244 ACPI_STRING pathname, 245 ACPI_OBJECT_LIST *arguments, 246 unsigned long long *data) 247 { 248 ACPI_STATUS status = AE_OK; 249 ACPI_OBJECT element; 250 ACPI_BUFFER buffer = {sizeof(ACPI_OBJECT), &element}; 251 252 ACPI_FUNCTION_TRACE("acpi_evaluate_integer"); 253 254 if (!data) 255 return_ACPI_STATUS(AE_BAD_PARAMETER); 256 257 status = AcpiEvaluateObject(handle, pathname, arguments, &buffer); 258 if (ACPI_FAILURE(status)) { 259 acpi_util_eval_error(handle, pathname, status); 260 return_ACPI_STATUS(status); 261 } 262 263 if (element.Type != ACPI_TYPE_INTEGER) { 264 acpi_util_eval_error(handle, pathname, AE_BAD_DATA); 265 return_ACPI_STATUS(AE_BAD_DATA); 266 } 267 268 *data = element.Integer.Value; 269 270 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Return value [%lu]\n", *data)); 271 272 return_ACPI_STATUS(AE_OK); 273 } 274 275 276 ACPI_STATUS 277 acpi_evaluate_reference ( 278 ACPI_HANDLE handle, 279 ACPI_STRING pathname, 280 ACPI_OBJECT_LIST *arguments, 281 struct acpi_handle_list *list) 282 { 283 ACPI_STATUS status = AE_OK; 284 ACPI_OBJECT *package = NULL; 285 ACPI_OBJECT *element = NULL; 286 ACPI_BUFFER buffer = {ACPI_ALLOCATE_BUFFER, NULL}; 287 UINT32 i = 0; 288 289 ACPI_FUNCTION_TRACE("acpi_evaluate_reference"); 290 291 if (!list) { 292 return_ACPI_STATUS(AE_BAD_PARAMETER); 293 } 294 295 /* Evaluate object. */ 296 297 status = AcpiEvaluateObject(handle, pathname, arguments, &buffer); 298 if (ACPI_FAILURE(status)) 299 goto end; 300 301 package = (ACPI_OBJECT *) buffer.Pointer; 302 303 if ((buffer.Length == 0) || !package) { 304 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 305 "No return object (len %X ptr %p)\n", 306 buffer.Length, package)); 307 status = AE_BAD_DATA; 308 acpi_util_eval_error(handle, pathname, status); 309 goto end; 310 } 311 if (package->Type != ACPI_TYPE_PACKAGE) { 312 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 313 "Expecting a [Package], found type %X\n", 314 package->Type)); 315 status = AE_BAD_DATA; 316 acpi_util_eval_error(handle, pathname, status); 317 goto end; 318 } 319 if (!package->Package.Count) { 320 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 321 "[Package] has zero elements (%p)\n", 322 package)); 323 status = AE_BAD_DATA; 324 acpi_util_eval_error(handle, pathname, status); 325 goto end; 326 } 327 328 if (package->Package.Count > ACPI_MAX_HANDLES) { 329 return AE_NO_MEMORY; 330 } 331 list->count = package->Package.Count; 332 333 /* Extract package data. */ 334 335 for (i = 0; i < list->count; i++) { 336 337 element = &(package->Package.Elements[i]); 338 339 if (element->Type != ACPI_TYPE_LOCAL_REFERENCE) { 340 status = AE_BAD_DATA; 341 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 342 "Expecting a [Reference] package element, found type %X\n", 343 element->type)); 344 acpi_util_eval_error(handle, pathname, status); 345 break; 346 } 347 348 if (!element->Reference.Handle) { 349 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid reference in" 350 " package %s\n", pathname)); 351 status = AE_NULL_ENTRY; 352 break; 353 } 354 /* Get the ACPI_HANDLE. */ 355 356 list->handles[i] = element->Reference.Handle; 357 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found reference [%p]\n", 358 list->handles[i])); 359 } 360 361 end: 362 if (ACPI_FAILURE(status)) { 363 list->count = 0; 364 //ExFreePool(list->handles); 365 } 366 367 if (buffer.Pointer) 368 AcpiOsFree(buffer.Pointer); 369 370 return_ACPI_STATUS(status); 371 } 372 373 NTSTATUS 374 acpi_create_registry_table(HANDLE ParentKeyHandle, ACPI_TABLE_HEADER *OutTable, PCWSTR KeyName) 375 { 376 OBJECT_ATTRIBUTES ObjectAttributes; 377 UNICODE_STRING HardwareKeyName, ValueName; 378 ANSI_STRING HardwareKeyNameA; 379 HANDLE KeyHandle = NULL, SubKeyHandle = NULL; 380 NTSTATUS Status; 381 char OemId[7] = { 0 }; /* exactly one byte more than ACPI_TABLE_HEADER->OemId */ 382 char OemTableId[9] = { 0 }; /* exactly one byte more than ACPI_TABLE_HEADER->OemTableId */ 383 WCHAR OemRevision[9] = { 0 }; /* enough to accept hex DWORD */ 384 385 C_ASSERT(sizeof(OemId) == RTL_FIELD_SIZE(ACPI_TABLE_HEADER, OemId) + 1); 386 C_ASSERT(sizeof(OemTableId) == RTL_FIELD_SIZE(ACPI_TABLE_HEADER, OemTableId) + 1); 387 /* Copy OEM data from the table */ 388 RtlCopyMemory(OemId, OutTable->OemId, sizeof(OutTable->OemId)); 389 RtlCopyMemory(OemTableId, OutTable->OemTableId, sizeof(OutTable->OemTableId)); 390 /* Create table subkey */ 391 RtlInitUnicodeString(&HardwareKeyName, KeyName); 392 InitializeObjectAttributes(&ObjectAttributes, 393 &HardwareKeyName, 394 OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE, 395 ParentKeyHandle, 396 NULL); 397 Status = ZwCreateKey(&KeyHandle, 398 KEY_WRITE, 399 &ObjectAttributes, 400 0, 401 NULL, 402 REG_OPTION_VOLATILE, 403 NULL); 404 if (!NT_SUCCESS(Status)) 405 { 406 DPRINT1("ZwCreateKey() for %ws failed (Status 0x%08lx)\n", KeyName, Status); 407 return Status; 408 } 409 410 if (OutTable->OemRevision != 0) 411 { 412 /* We have OEM info in table, so create other OEM subkeys */ 413 RtlInitAnsiString(&HardwareKeyNameA, OemId); 414 Status = RtlAnsiStringToUnicodeString(&HardwareKeyName, &HardwareKeyNameA, TRUE); 415 if (!NT_SUCCESS(Status)) 416 { 417 DPRINT1("RtlAnsiStringToUnicodeString() for %s failed (Status 0x%08lx)\n", HardwareKeyNameA, Status); 418 ZwClose(KeyHandle); 419 return Status; 420 } 421 422 InitializeObjectAttributes(&ObjectAttributes, 423 &HardwareKeyName, 424 OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE, 425 KeyHandle, 426 NULL); 427 Status = ZwCreateKey(&SubKeyHandle, 428 KEY_WRITE, 429 &ObjectAttributes, 430 0, 431 NULL, 432 REG_OPTION_VOLATILE, 433 NULL); 434 RtlFreeUnicodeString(&HardwareKeyName); 435 ZwClose(KeyHandle); 436 if (!NT_SUCCESS(Status)) 437 { 438 DPRINT1("ZwCreateKey() for %s failed (Status 0x%08lx)\n", HardwareKeyNameA, Status); 439 return Status; 440 } 441 KeyHandle = SubKeyHandle; 442 443 RtlInitAnsiString(&HardwareKeyNameA, OemTableId); 444 Status = RtlAnsiStringToUnicodeString(&HardwareKeyName, &HardwareKeyNameA, TRUE); 445 if (!NT_SUCCESS(Status)) 446 { 447 DPRINT1("RtlAnsiStringToUnicodeString() for %s failed (Status 0x%08lx)\n", HardwareKeyNameA, Status); 448 ZwClose(KeyHandle); 449 return Status; 450 } 451 452 InitializeObjectAttributes(&ObjectAttributes, 453 &HardwareKeyName, 454 OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE, 455 KeyHandle, 456 NULL); 457 Status = ZwCreateKey(&SubKeyHandle, 458 KEY_WRITE, 459 &ObjectAttributes, 460 0, 461 NULL, 462 REG_OPTION_VOLATILE, 463 NULL); 464 RtlFreeUnicodeString(&HardwareKeyName); 465 ZwClose(KeyHandle); 466 if (!NT_SUCCESS(Status)) 467 { 468 DPRINT1("ZwCreateKey() for %s failed (Status 0x%08lx)\n", HardwareKeyNameA, Status); 469 return Status; 470 } 471 KeyHandle = SubKeyHandle; 472 473 Status = RtlStringCbPrintfW(OemRevision, 474 sizeof(OemRevision), 475 L"%08X", 476 OutTable->OemRevision); 477 if (!NT_SUCCESS(Status)) 478 { 479 DPRINT1("RtlStringCbPrintfW() for 0x%08lx failed (Status 0x%08lx)\n", OutTable->OemRevision, Status); 480 ZwClose(KeyHandle); 481 return Status; 482 } 483 RtlInitUnicodeString(&HardwareKeyName, OemRevision); 484 485 InitializeObjectAttributes(&ObjectAttributes, 486 &HardwareKeyName, 487 OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE, 488 KeyHandle, 489 NULL); 490 Status = ZwCreateKey(&SubKeyHandle, 491 KEY_WRITE, 492 &ObjectAttributes, 493 0, 494 NULL, 495 REG_OPTION_VOLATILE, 496 NULL); 497 ZwClose(KeyHandle); 498 if (!NT_SUCCESS(Status)) 499 { 500 DPRINT1("ZwCreateKey() for %ws failed (Status 0x%08lx)\n", KeyName, Status); 501 return Status; 502 } 503 KeyHandle = SubKeyHandle; 504 } 505 /* Table reg value name is always '00000000' */ 506 RtlInitUnicodeString(&ValueName, 507 L"00000000"); 508 Status = ZwSetValueKey(KeyHandle, 509 &ValueName, 510 0, 511 REG_BINARY, 512 OutTable, 513 OutTable->Length); 514 ZwClose(KeyHandle); 515 if (!NT_SUCCESS(Status)) 516 { 517 DPRINT1("ZwSetValueKey() failed (Status 0x%08lx)\n", Status); 518 return Status; 519 } 520 521 return STATUS_SUCCESS; 522 } 523 524 NTSTATUS 525 acpi_create_volatile_registry_tables(void) 526 { 527 OBJECT_ATTRIBUTES ObjectAttributes; 528 UNICODE_STRING HardwareKeyName = RTL_CONSTANT_STRING(L"\\Registry\\Machine\\HARDWARE\\ACPI"); 529 HANDLE KeyHandle = NULL; 530 NTSTATUS Status; 531 ACPI_STATUS AcpiStatus; 532 ACPI_TABLE_HEADER *OutTable; 533 ACPI_PHYSICAL_ADDRESS RsdpAddress; 534 ACPI_TABLE_RSDP *Rsdp; 535 ACPI_PHYSICAL_ADDRESS Address; 536 UINT32 TableEntrySize; 537 538 /* Create Main Hardware ACPI key*/ 539 InitializeObjectAttributes(&ObjectAttributes, 540 &HardwareKeyName, 541 OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE, 542 NULL, 543 NULL); 544 Status = ZwCreateKey(&KeyHandle, 545 KEY_WRITE, 546 &ObjectAttributes, 547 0, 548 NULL, 549 REG_OPTION_VOLATILE, 550 NULL); 551 if (!NT_SUCCESS(Status)) 552 { 553 DPRINT1("ZwCreateKey() for ACPI failed (Status 0x%08lx)\n", Status); 554 return Status; 555 } 556 /* Read DSDT table */ 557 AcpiStatus = AcpiGetTable(ACPI_SIG_DSDT, 0, &OutTable); 558 if (ACPI_FAILURE(AcpiStatus)) 559 { 560 DPRINT1("AcpiGetTable() for DSDT failed (Status 0x%08lx)\n", AcpiStatus); 561 Status = STATUS_UNSUCCESSFUL; 562 goto done; 563 } 564 /* Dump DSDT table */ 565 Status = acpi_create_registry_table(KeyHandle, OutTable, L"DSDT"); 566 if (!NT_SUCCESS(Status)) 567 { 568 DPRINT1("acpi_dump_table_to_registry() for DSDT failed (Status 0x%08lx)\n", Status); 569 goto done; 570 } 571 /* Read FACS table */ 572 AcpiStatus = AcpiGetTable(ACPI_SIG_FACS, 0, &OutTable); 573 if (ACPI_FAILURE(AcpiStatus)) 574 { 575 DPRINT1("AcpiGetTable() for FACS failed (Status 0x%08lx)\n", AcpiStatus); 576 Status = STATUS_UNSUCCESSFUL; 577 goto done; 578 } 579 /* Dump FACS table */ 580 Status = acpi_create_registry_table(KeyHandle, OutTable, L"FACS"); 581 if (!NT_SUCCESS(Status)) 582 { 583 DPRINT1("acpi_dump_table_to_registry() for FACS failed (Status 0x%08lx)\n", Status); 584 goto done; 585 } 586 /* Read FACS table */ 587 AcpiStatus = AcpiGetTable(ACPI_SIG_FADT, 0, &OutTable); 588 if (ACPI_FAILURE(AcpiStatus)) 589 { 590 DPRINT1("AcpiGetTable() for FADT failed (Status 0x%08lx)\n", AcpiStatus); 591 Status = STATUS_UNSUCCESSFUL; 592 goto done; 593 } 594 /* Dump FADT table */ 595 Status = acpi_create_registry_table(KeyHandle, OutTable, L"FADT"); 596 if (!NT_SUCCESS(Status)) 597 { 598 DPRINT1("acpi_dump_table_to_registry() for FADT failed (Status 0x%08lx)\n", Status); 599 goto done; 600 } 601 /* This is a rough copy from ACPICA reading of RSDT/XSDT and added to avoid patching acpica */ 602 RsdpAddress = AcpiOsGetRootPointer(); 603 /* Map the entire RSDP and extract the address of the RSDT or XSDT */ 604 Rsdp = AcpiOsMapMemory(RsdpAddress, sizeof(ACPI_TABLE_RSDP)); 605 if (!Rsdp) 606 { 607 DPRINT1("AcpiOsMapMemory() failed\n"); 608 Status = STATUS_NO_MEMORY; 609 goto done; 610 } 611 /* Use XSDT if present and not overridden. Otherwise, use RSDT */ 612 if ((Rsdp->Revision > 1) && 613 Rsdp->XsdtPhysicalAddress && 614 !AcpiGbl_DoNotUseXsdt) 615 { 616 /* 617 * RSDP contains an XSDT (64-bit physical addresses). We must use 618 * the XSDT if the revision is > 1 and the XSDT pointer is present, 619 * as per the ACPI specification. 620 */ 621 Address = (ACPI_PHYSICAL_ADDRESS)Rsdp->XsdtPhysicalAddress; 622 TableEntrySize = ACPI_XSDT_ENTRY_SIZE; 623 } 624 else 625 { 626 /* Root table is an RSDT (32-bit physical addresses) */ 627 Address = (ACPI_PHYSICAL_ADDRESS)Rsdp->RsdtPhysicalAddress; 628 TableEntrySize = ACPI_RSDT_ENTRY_SIZE; 629 } 630 /* 631 * It is not possible to map more than one entry in some environments, 632 * so unmap the RSDP here before mapping other tables 633 */ 634 AcpiOsUnmapMemory(Rsdp, sizeof(ACPI_TABLE_RSDP)); 635 OutTable = AcpiOsMapMemory(Address, TableEntrySize); 636 if (!OutTable) 637 { 638 DPRINT1("AcpiOsMapMemory() failed\n"); 639 Status = STATUS_NO_MEMORY; 640 goto done; 641 } 642 /* Dump RSDT table */ 643 Status = acpi_create_registry_table(KeyHandle, OutTable, L"RSDT"); 644 AcpiOsUnmapMemory(OutTable, TableEntrySize); 645 if (!NT_SUCCESS(Status)) 646 { 647 DPRINT1("acpi_dump_table_to_registry() for RSDT failed (Status 0x%08lx)\n", Status); 648 } 649 650 done: 651 ZwClose(KeyHandle); 652 return Status; 653 } 654