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.

180 lines
2.4 KiB

  1. ;++
  2. ;
  3. ;Copyright (c) 1998 Microsoft Corporation
  4. ;
  5. ;Module Name:
  6. ;
  7. ; pae.asm
  8. ;
  9. ;Abstract:
  10. ;
  11. ; Contains routines to aid in enabling PAE mode.
  12. ;
  13. ;Author:
  14. ;
  15. ; Forrest Foltz (forrestf) 12-28-98
  16. ;
  17. ;
  18. ;Revision History:
  19. ;
  20. ;--
  21. .586p
  22. .xlist
  23. include ks386.inc
  24. .list
  25. _TEXT SEGMENT PARA PUBLIC 'CODE'
  26. ASSUME DS:FLAT, ES:FLAT, SS:NOTHING, FS:NOTHING, GS:NOTHING
  27. EFLAGS_ID equ 200000h
  28. ;++
  29. ;
  30. ; BOOLEAN
  31. ; BlpPaeSupported (
  32. ; VOID
  33. ; )
  34. ;
  35. ; Routine Description:
  36. ;
  37. ; This routine determines whether the CPU supports PAE mode
  38. ;
  39. ; Arguments:
  40. ;
  41. ; None.
  42. ;
  43. ; Return value:
  44. ;
  45. ; al == 1 if the CPU does support PAE mode.
  46. ; al == 0 if not.
  47. ;
  48. ;--
  49. public _BlpPaeSupported@0
  50. _BlpPaeSupported@0 proc
  51. ;
  52. ; First determine whether the CPUID instruction is supported. If
  53. ; the EFLAGS_ID bit "sticks" when stored in the flags register, then
  54. ; the CPUID instruction is supported.
  55. ;
  56. mov ecx, EFLAGS_ID
  57. pushfd
  58. pop eax ; eax == flags
  59. xor ecx, eax ; ecx == flags ^ EFLAGS_ID
  60. push ecx
  61. popfd ; load new flags
  62. pushfd
  63. pop ecx ; ecx == result of flag load
  64. xor eax, ecx ; Q: did the EFLAGS_ID bit stick?
  65. jz done ; N: CPUID is not available
  66. ;
  67. ; We can use the CPUID instruction.
  68. ;
  69. push ebx ; CPUID steps on eax, ebx, ecx, edx
  70. mov eax, 1
  71. cpuid
  72. pop ebx
  73. ;
  74. ; edx contains the feature bits. Bit 6 is the PAE extensions flag.
  75. ;
  76. sub eax, eax ; assume not set
  77. test dl, 40h ; Q: bit 6 set?
  78. jz done ; N: return with eax == 0
  79. inc eax ; Y: set eax == 1
  80. done: ret
  81. _BlpPaeSupported@0 endp
  82. ;++
  83. ;
  84. ; VOID
  85. ; BlSetPae (
  86. ; IN ULONG IdentityAddress,
  87. ; IN ULONG PaeCr3
  88. ; )
  89. ;
  90. ; Routine Description:
  91. ;
  92. ; Arguments:
  93. ;
  94. ; Return
  95. ;
  96. ;--
  97. public _BlpEnablePAE@4
  98. _BlpEnablePAE@4 proc
  99. ;
  100. ; Load PDPT address
  101. ;
  102. mov edx, [esp]+4
  103. ;
  104. ; Do this to set the state machine in motion
  105. ;
  106. mov ecx, cr3
  107. mov cr3, ecx
  108. ;
  109. ; Disable paging
  110. ;
  111. mov eax, cr0
  112. and eax, NOT CR0_PG
  113. mov cr0, eax
  114. jmp $+2
  115. ;
  116. ; Enable physical address extensions
  117. ;
  118. mov eax, cr4
  119. or eax, CR4_PAE
  120. ;
  121. ; The following instruction was necessary in order to boot some
  122. ; machines. Probably due to an errata.
  123. ;
  124. mov ecx, cr3
  125. mov cr4, eax
  126. ;
  127. ; Point cr3 to the page directory pointer table
  128. ;
  129. mov cr3, edx
  130. ;
  131. ; Enable paging
  132. ;
  133. mov ecx, cr0
  134. or ecx, CR0_PG
  135. mov cr0, ecx
  136. jmp $+2
  137. ;
  138. ; Clean the stack and return
  139. ;
  140. _BlpEnablePAEEnd:
  141. ret 4
  142. _BlpEnablePAE@4 endp
  143. _TEXT ends
  144. end