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.

256 lines
4.9 KiB

  1. /*--
  2. Copyright (c) 2001 Microsoft Corporation
  3. Module Name:
  4. x86bios.c
  5. Abstract:
  6. This is the AMD64 specific part of the video port driver
  7. Author:
  8. Forrest C. Foltz (forrestf)
  9. Environment:
  10. Kernel mode only
  11. Notes:
  12. This module is a driver which implements OS dependent functions on
  13. behalf of the video drivers
  14. Revision history:
  15. --*/
  16. #include "halcmn.h"
  17. #include <xm86.h>
  18. #include <x86new.h>
  19. #define LOW_MEM_SEGMET 0
  20. #define LOW_MEM_OFFSET 0
  21. #define SIZE_OF_VECTOR_TABLE 0x400
  22. #define SIZE_OF_BIOS_DATA_AREA 0x400
  23. PVOID HalpIoControlBase = NULL;
  24. PVOID HalpIoMemoryBase = (PVOID)KSEG0_BASE;
  25. BOOLEAN HalpX86BiosInitialized = FALSE;
  26. extern PVOID x86BiosTranslateAddress (
  27. IN USHORT Segment,
  28. IN USHORT Offset
  29. );
  30. BOOLEAN
  31. HalpBiosDisplayReset (
  32. VOID
  33. )
  34. /*++
  35. Routine Description:
  36. This function places the VGA display into 640 x 480 16 color mode
  37. by calling the BIOS.
  38. Arguments:
  39. None.
  40. Return Value:
  41. TRUE if reset have been executed successfuly
  42. --*/
  43. {
  44. ULONG eax;
  45. ULONG exx;
  46. //
  47. // ah = function 0: reset display
  48. // al = mode 0x12: 640x480 16 color
  49. //
  50. eax = 0x0012;
  51. exx = 0;
  52. //
  53. // Simulate:
  54. //
  55. // mov ax, 0012h
  56. // int 10h
  57. //
  58. return HalCallBios(0x10,&eax,&exx,&exx,&exx,&exx,&exx,&exx);
  59. }
  60. BOOLEAN
  61. HalCallBios (
  62. IN ULONG BiosCommand,
  63. IN OUT PULONG Eax,
  64. IN OUT PULONG Ebx,
  65. IN OUT PULONG Ecx,
  66. IN OUT PULONG Edx,
  67. IN OUT PULONG Esi,
  68. IN OUT PULONG Edi,
  69. IN OUT PULONG Ebp
  70. )
  71. /*++
  72. Routine Description:
  73. This function provides the platform specific interface between a device
  74. driver and the execution of the x86 ROM bios code for the specified ROM
  75. bios command.
  76. Arguments:
  77. BiosCommand - Supplies the ROM bios command to be emulated.
  78. Eax to Ebp - Supplies the x86 emulation context.
  79. Return Value:
  80. A value of TRUE is returned if the specified function is executed.
  81. Otherwise, a value of FALSE is returned.
  82. --*/
  83. {
  84. XM86_CONTEXT context;
  85. XM_STATUS status;
  86. if (HalpX86BiosInitialized == FALSE) {
  87. return FALSE;
  88. }
  89. // s
  90. // Copy the x86 bios context and emulate the specified command.
  91. //
  92. context.Eax = *Eax;
  93. context.Ebx = *Ebx;
  94. context.Ecx = *Ecx;
  95. context.Edx = *Edx;
  96. context.Esi = *Esi;
  97. context.Edi = *Edi;
  98. context.Ebp = *Ebp;
  99. status = x86BiosExecuteInterrupt((UCHAR)BiosCommand,
  100. &context,
  101. (PVOID)HalpIoControlBase,
  102. (PVOID)HalpIoMemoryBase);
  103. if (status != XM_SUCCESS) {
  104. return FALSE;
  105. }
  106. //
  107. // Copy the x86 bios context and return TRUE.
  108. //
  109. *Eax = context.Eax;
  110. *Ebx = context.Ebx;
  111. *Ecx = context.Ecx;
  112. *Edx = context.Edx;
  113. *Esi = context.Esi;
  114. *Edi = context.Edi;
  115. *Ebp = context.Ebp;
  116. return TRUE;
  117. }
  118. VOID
  119. HalpInitializeBios (
  120. VOID
  121. )
  122. /*++
  123. Routine Description:
  124. This routine initializes the X86 emulation module and an attached VGA
  125. adapter.
  126. Arguments:
  127. None.
  128. Return Value:
  129. None.
  130. --*/
  131. {
  132. PULONG x86BiosLowMemoryPtr, InterruptTablePtr;
  133. PHYSICAL_ADDRESS COMPATIBLE_PCI_PHYSICAL_BASE_ADDRESS = { 0x0};
  134. x86BiosInitializeBios(NULL, (PVOID)KSEG0_BASE);
  135. HalpX86BiosInitialized = TRUE;
  136. //
  137. // Copy the VECTOR TABLE from 0 to 2k. This is because we are not executing
  138. // the initialization of Adapter. The initialization code of the Adapter
  139. // could be discarded after POST. However, the emulation memory needs to be
  140. // updated from the interrupt vector and BIOS data area.
  141. //
  142. InterruptTablePtr =
  143. (PULONG) MmMapIoSpace(COMPATIBLE_PCI_PHYSICAL_BASE_ADDRESS,
  144. SIZE_OF_VECTOR_TABLE + SIZE_OF_BIOS_DATA_AREA,
  145. (MEMORY_CACHING_TYPE)MmNonCached);
  146. if(InterruptTablePtr) {
  147. x86BiosLowMemoryPtr = (PULONG)(x86BiosTranslateAddress(LOW_MEM_SEGMET, LOW_MEM_OFFSET));
  148. RtlCopyMemory(x86BiosLowMemoryPtr,
  149. InterruptTablePtr,
  150. SIZE_OF_VECTOR_TABLE + SIZE_OF_BIOS_DATA_AREA);
  151. MmUnmapIoSpace(InterruptTablePtr,
  152. SIZE_OF_VECTOR_TABLE + SIZE_OF_BIOS_DATA_AREA);
  153. }
  154. }
  155. HAL_DISPLAY_BIOS_INFORMATION
  156. HalpGetDisplayBiosInformation (
  157. VOID
  158. )
  159. /*++
  160. Routine Description:
  161. This routine returns a value indicating how video (int 10) bios calls
  162. are handled.
  163. Arguments:
  164. None.
  165. Return Value:
  166. HalDisplayEmulatedBios
  167. --*/
  168. {
  169. //
  170. // This hal emulates int 10 bios calls
  171. //
  172. return HalDisplayEmulatedBios;
  173. }