Source code of Windows XP (NT5)
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.

176 lines
4.2 KiB

  1. /*++
  2. Copyright (c) 1990, 1991 Microsoft Corporation
  3. Module Name:
  4. hwpmbiosc.c
  5. Abstract:
  6. This modules contains ACPI BIOS C supporting routines
  7. Author:
  8. Jake Oshins (jakeo) 6-Feb-1997
  9. Environment:
  10. Real mode.
  11. Revision History:
  12. --*/
  13. #include "hwdetect.h"
  14. #include <string.h>
  15. #include "acpibios.h"
  16. BOOLEAN
  17. HwGetAcpiBiosData(
  18. IN FPUCHAR *Configuration,
  19. OUT PUSHORT Length
  20. )
  21. /*++
  22. Routine Description:
  23. This routine checks to see if an ACPI BIOS is present. If it is,
  24. then it returns the ACPI Root System Description Pointer.
  25. Arguments:
  26. Configuration - structure that holds ACPI pointer
  27. Length - length of that structure
  28. Return Value:
  29. TRUE if ACPI BIOS is present, FALSE otherwise
  30. --*/
  31. {
  32. ULONG romAddr, romEnd;
  33. FPUCHAR current;
  34. FPULONG EbdaAddr;
  35. FPACPI_BIOS_INSTALLATION_CHECK header;
  36. UCHAR sum, node = 0;
  37. USHORT i, nodeSize;
  38. enum PASS { PASS1 = 0, PASS2, MAX_PASSES } pass;
  39. //
  40. // Search on 16 byte boundaries for the signature of the
  41. // Root System Description Table structure.
  42. //
  43. #if defined(NEC_98)
  44. //
  45. // PC98, we search (physical) memory from 0xE8000
  46. // to 0xFFFFF.
  47. MAKE_FP(current, 0xE8000);
  48. romAddr = 0xE8000;
  49. romEnd = ACPI_BIOS_END;
  50. #else
  51. for (pass = PASS1; pass < MAX_PASSES; pass++) {
  52. if (pass == PASS1) {
  53. //
  54. // On the first pass, we search the first 1K of the
  55. // Extended BIOS data area.
  56. //
  57. //
  58. // Earlier, we stored the address of the EBDA in address
  59. // DOS_BEGIN_SEGMENT << 4 : EBIOS_INFO_OFFSET
  60. //
  61. MAKE_FP(EbdaAddr, ((DOS_BEGIN_SEGMENT << 4) + EBIOS_INFO_OFFSET));
  62. MAKE_FP(current, *EbdaAddr);
  63. if (*EbdaAddr == 0) {
  64. continue;
  65. }
  66. romAddr = *EbdaAddr;
  67. romEnd = romAddr + 1024;
  68. } else {
  69. //
  70. // On the second pass, we search (physical) memory 0xE0000
  71. // to 0xF0000.
  72. MAKE_FP(current, ACPI_BIOS_START);
  73. romAddr = ACPI_BIOS_START;
  74. romEnd = ACPI_BIOS_END;
  75. }
  76. #endif
  77. while (romAddr < romEnd) {
  78. header = (FPACPI_BIOS_INSTALLATION_CHECK)current;
  79. //
  80. // Signature to match is the string "RSD PTR".
  81. //
  82. if (header->Signature[0] == 'R' && header->Signature[1] == 'S' &&
  83. header->Signature[2] == 'D' && header->Signature[3] == ' ' &&
  84. header->Signature[4] == 'P' && header->Signature[5] == 'T' &&
  85. header->Signature[6] == 'R' && header->Signature[7] == ' ' ) {
  86. sum = 0;
  87. for (i = 0; i < sizeof(ACPI_BIOS_INSTALLATION_CHECK); i++) {
  88. sum += current[i];
  89. }
  90. if (sum == 0) {
  91. pass = MAX_PASSES; // leave 'for' loop
  92. break; // leave 'while' loop
  93. }
  94. #if DBG
  95. BlPrint("GetAcpiBiosData: Checksum fails\n");
  96. #endif
  97. }
  98. romAddr += ACPI_BIOS_HEADER_INCREMENT;
  99. MAKE_FP(current, romAddr);
  100. }
  101. #if defined(NEC_98)
  102. #else
  103. }
  104. #endif
  105. if (romAddr >= romEnd) {
  106. #if DBG
  107. BlPrint("GetAcpiBiosData: RSDT pointer not found\n");
  108. #endif
  109. return FALSE;
  110. }
  111. nodeSize = sizeof(ACPI_BIOS_INSTALLATION_CHECK) + DATA_HEADER_SIZE;
  112. current = (FPUCHAR) HwAllocateHeap(nodeSize, FALSE);
  113. if (!current) {
  114. #if DBG
  115. BlPrint("GetAcpiBiosData: Out of heap space.\n");
  116. #endif
  117. return FALSE;
  118. }
  119. //
  120. // Collect ACPI Bios installation check data and device node data.
  121. //
  122. _fmemcpy (current + DATA_HEADER_SIZE,
  123. (FPUCHAR)header,
  124. sizeof(ACPI_BIOS_INSTALLATION_CHECK)
  125. );
  126. *Configuration = current;
  127. *Length = nodeSize;
  128. #if DBG
  129. BlPrint("ACPI BIOS found at 0x%x:%x. RdstAddress is 0x%x:%x\n",
  130. (USHORT)(romAddr >> 16),
  131. (USHORT)(romAddr),
  132. (USHORT)(header->RsdtAddress >> 16),
  133. (USHORT)(header->RsdtAddress)
  134. );
  135. #endif
  136. return TRUE;
  137. }