Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

144 lines
2.7 KiB

  1. /*++
  2. Copyright (c) 1997 Microsoft Corporation
  3. All rights reserved
  4. Module Name:
  5. acpidtct.c
  6. Abstract:
  7. This module peruses the ACPI tables looking for specific
  8. entries.
  9. Author:
  10. Matt Holle (matth) (shamefully stolen from jakeo's x86 code)
  11. Environment:
  12. Revision History:
  13. --*/
  14. #include "stdlib.h"
  15. #include "string.h"
  16. #include "bldr.h"
  17. #include "acpitabl.h"
  18. #include "efi.h"
  19. #include "extern.h"
  20. PDESCRIPTION_HEADER
  21. BlFindACPITable(
  22. IN PCHAR TableName,
  23. IN ULONG TableLength
  24. )
  25. /*++
  26. Routine Description:
  27. Given a table name, finds that table in the ACPI BIOS
  28. Arguments:
  29. TableName - Supplies the table name
  30. TableLength - Supplies the length of the table to map
  31. Return Value:
  32. Pointer to the table if found
  33. NULL if the table is not found
  34. Note:
  35. This function is not capable of returning a pointer to
  36. a table with a signature of DSDT. But that's never necessary
  37. in the loader. If the loader ever incorporates an AML
  38. interpreter, this will have to be enhanced.
  39. --*/
  40. {
  41. ULONG Signature;
  42. PDESCRIPTION_HEADER Header;
  43. ULONG TableCount;
  44. ULONG i;
  45. PXSDT xsdt = NULL;
  46. PRSDP rsdp = (PRSDP)AcpiTable;
  47. UNREFERENCED_PARAMETER( TableLength );
  48. //DbgPrint("Hunting for table %s\n", TableName);
  49. //
  50. // Sanity Check.
  51. //
  52. if (rsdp) {
  53. //DbgPrint("Looking through 2.0 RSDP: %p\n", rsdp20);
  54. xsdt = (PVOID)rsdp->XsdtAddress.QuadPart;
  55. if (xsdt->Header.Signature != XSDT_SIGNATURE) {
  56. //
  57. // Found ACPI 2.0 tables, but the signature
  58. // is garbage.
  59. //
  60. return NULL;
  61. }
  62. } else {
  63. //
  64. // Didn't find any tables at all.
  65. //
  66. return NULL;
  67. }
  68. Signature = *((ULONG UNALIGNED *)TableName);
  69. //
  70. // If they want the root table, we've already got that.
  71. //
  72. if (Signature == XSDT_SIGNATURE) {
  73. return(&xsdt->Header);
  74. } else {
  75. TableCount = NumTableEntriesFromXSDTPointer(xsdt);
  76. //DbgPrint("xSDT contains %d tables\n", TableCount);
  77. //
  78. // Sanity check.
  79. //
  80. if( TableCount > 0x100 ) {
  81. return(NULL);
  82. }
  83. //
  84. // Dig.
  85. //
  86. for (i=0;i<TableCount;i++) {
  87. Header = (PDESCRIPTION_HEADER)(xsdt->Tables[i].QuadPart);
  88. if (Header->Signature == Signature) {
  89. //DbgPrint("Table Address: %p\n", Header);
  90. return(Header);
  91. }
  92. }
  93. }
  94. //DbgPrint("Table not found\n");
  95. return(NULL);
  96. }