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.

181 lines
2.6 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. public _BlpEnablePAEStart
  100. _BlpEnablePAEStart label dword
  101. ;
  102. ; Load PDPT address
  103. ;
  104. mov edx, [esp]+4
  105. ;
  106. ; Do this to set the state machine in motion
  107. ;
  108. mov ecx, cr3
  109. mov cr3, ecx
  110. ;
  111. ; Disable paging
  112. ;
  113. mov eax, cr0
  114. and eax, NOT CR0_PG
  115. mov cr0, eax
  116. jmp $+2
  117. ;
  118. ; Enable physical address extensions
  119. ;
  120. mov eax, cr4
  121. or eax, CR4_PAE
  122. ;
  123. ; The following instruction was necessary in order to boot some
  124. ; machines. Probably due to an errata.
  125. ;
  126. mov ecx, cr3
  127. mov cr4, eax
  128. ;
  129. ; Point cr3 to the page directory pointer table
  130. ;
  131. mov cr3, edx
  132. ;
  133. ; Enable paging
  134. ;
  135. mov ecx, cr0
  136. or ecx, CR0_PG
  137. mov cr0, ecx
  138. jmp $+2
  139. ;
  140. ; Clean the stack and return
  141. ;
  142. ret 4
  143. public _BlpEnablePAEEnd
  144. _BlpEnablePAEEnd label dword
  145. _BlpEnablePAE@4 endp
  146. _TEXT ends
  147. end