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.

173 lines
3.7 KiB

  1. /*++
  2. Copyright (c) 1992 Microsoft Corporation
  3. Module Name:
  4. detsup.c
  5. Abstract:
  6. Various detection code is included from the HALs and this module
  7. includes compatible functions for setup
  8. Revision History:
  9. --*/
  10. #include "haldtect.h"
  11. #define _NTHAL_
  12. #define _HALI_
  13. //
  14. // Include NCR detection code
  15. //
  16. #define SETUP
  17. //
  18. // Include ACPI detection code
  19. //
  20. #include "halacpi\acpisetd.c"
  21. //
  22. // Include MPS 1.1 detection code
  23. //
  24. #include "halmps\i386\mpdetect.c"
  25. //
  26. // Thunk functions.
  27. // Equivalent Hal functions which various detection code may use
  28. //
  29. PVOID
  30. HalpMapPhysicalMemory64(
  31. IN PHYSICAL_ADDRESS PhysicalAddress,
  32. IN ULONG NumberPages
  33. )
  34. /*++
  35. Routine Description:
  36. This routine maps physical memory into the area of virtual memory.
  37. Arguments:
  38. PhysicalAddress - Supplies the physical address of the start of the
  39. area of physical memory to be mapped.
  40. NumberPages - Supplies the number of pages contained in the area of
  41. physical memory to be mapped.
  42. Return Value:
  43. PVOID - Virtual address at which the requested block of physical memory
  44. was mapped
  45. --*/
  46. {
  47. extern PHARDWARE_PTE HalPT;
  48. ULONG PageFrame;
  49. ULONG i, j;
  50. PageFrame = (PhysicalAddress.LowPart) >> PAGE_SHIFT;
  51. if (PageFrame >= 1 && PageFrame+NumberPages < 0x1000) {
  52. //
  53. // The lower 16M is 'identity' mapped with the physical addresses.
  54. //
  55. return (PVOID)PhysicalAddress.LowPart;
  56. }
  57. //
  58. // Map a pointer to the address requested
  59. //
  60. for (i=0; i <= 1024-NumberPages; i++) {
  61. for (j=0; j < NumberPages; j++) {
  62. if ( ((PULONG)HalPT)[i+j] ) {
  63. break;
  64. }
  65. }
  66. if (j == NumberPages) {
  67. for (j=0; j<NumberPages; j++) {
  68. HalPT[i+j].PageFrameNumber = PageFrame+j;
  69. HalPT[i+j].Valid = 1;
  70. HalPT[i+j].Write = 1;
  71. }
  72. j = 0xffc00000 | (i<<12) | ((PhysicalAddress.LowPart) & 0xfff);
  73. return (PVOID) j;
  74. }
  75. }
  76. SlFatalError(PhysicalAddress.LowPart);
  77. return NULL;
  78. }
  79. PVOID
  80. HalpMapPhysicalMemoryWriteThrough64(
  81. IN PHYSICAL_ADDRESS PhysicalAddress,
  82. IN ULONG NumberPages
  83. )
  84. /*++
  85. Routine Description:
  86. This routine maps physical memory into the area of virtual memory.
  87. Arguments:
  88. PhysicalAddress - Supplies the physical address of the start of the
  89. area of physical memory to be mapped.
  90. NumberPages - Supplies the number of pages contained in the area of
  91. physical memory to be mapped.
  92. Return Value:
  93. PVOID - Virtual address at which the requested block of physical memory
  94. was mapped
  95. --*/
  96. {
  97. extern PHARDWARE_PTE HalPT;
  98. ULONG PageFrame;
  99. ULONG i, j;
  100. PageFrame = (PhysicalAddress.LowPart) >> PAGE_SHIFT;
  101. //
  102. // Map a pointer to the address requested
  103. //
  104. for (i=0; i <= 1024-NumberPages; i++) {
  105. for (j=0; j < NumberPages; j++) {
  106. if ( ((PULONG)HalPT)[i+j] ) {
  107. break;
  108. }
  109. }
  110. if (j == NumberPages) {
  111. for (j=0; j<NumberPages; j++) {
  112. HalPT[i+j].PageFrameNumber = PageFrame+j;
  113. HalPT[i+j].Valid = 1;
  114. HalPT[i+j].Write = 1;
  115. HalPT[i+j].WriteThrough = 1;
  116. HalPT[i+j].CacheDisable = 1;
  117. }
  118. j = 0xffc00000 | (i<<12) | ((PhysicalAddress.LowPart) & 0xfff);
  119. return (PVOID) j;
  120. }
  121. }
  122. SlFatalError(PhysicalAddress.LowPart);
  123. return NULL;
  124. }