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.

251 lines
5.0 KiB

  1. //
  2. // No Check-in Source Code.
  3. //
  4. // Do not make this code available to non-Microsoft personnel
  5. // without Intel's express permission
  6. //
  7. /**
  8. *** Copyright (C) 1996-97 Intel Corporation. All rights reserved.
  9. ***
  10. *** The information and source code contained herein is the exclusive
  11. *** property of Intel Corporation and may not be disclosed, examined
  12. *** or reproduced in whole or in part without explicit written authorization
  13. *** from the company.
  14. **/
  15. /*++
  16. Copyright (c) 1996 Intel Corporation
  17. Copyright (c) 1994 Microsoft Corporation
  18. Module Name:
  19. x86bios.c
  20. Abstract:
  21. This module implements the platform specific interface between a device
  22. driver and the execution of x86 ROM bios code for the device.
  23. Author:
  24. William K. Cheung (wcheung) 20-Mar-1996
  25. based on the version by David N. Cutler (davec) 17-Jun-1994
  26. Environment:
  27. Kernel mode only.
  28. Revision History:
  29. --*/
  30. #include "halp.h"
  31. //
  32. // Define global data.
  33. //
  34. ULONG HalpX86BiosInitialized = FALSE;
  35. ULONG HalpEnableInt10Calls = FALSE;
  36. BOOLEAN
  37. HalCallBios (
  38. IN ULONG BiosCommand,
  39. IN OUT PULONG Eax,
  40. IN OUT PULONG Ebx,
  41. IN OUT PULONG Ecx,
  42. IN OUT PULONG Edx,
  43. IN OUT PULONG Esi,
  44. IN OUT PULONG Edi,
  45. IN OUT PULONG Ebp
  46. )
  47. /*++
  48. Routine Description:
  49. This function provides the platform specific interface between a device
  50. driver and the execution of the x86 ROM bios code for the specified ROM
  51. bios command.
  52. Arguments:
  53. BiosCommand - Supplies the ROM bios command to be emulated.
  54. Eax to Ebp - Supplies the x86 emulation context.
  55. Return Value:
  56. A value of TRUE is returned if the specified function is executed.
  57. Otherwise, a value of FALSE is returned.
  58. --*/
  59. {
  60. CONTEXT86 Context;
  61. //
  62. // If the x86 BIOS Emulator has not been initialized, then return FALSE.
  63. //
  64. if (HalpX86BiosInitialized == FALSE) {
  65. return FALSE;
  66. }
  67. //
  68. // If the Video Adapter initialization failed and an Int10 command is
  69. // specified, then return FALSE.
  70. //
  71. if ((BiosCommand == 0x10) && (HalpEnableInt10Calls == FALSE)) {
  72. return FALSE;
  73. }
  74. //
  75. // Copy the x86 bios context and emulate the specified command.
  76. //
  77. Context.Eax = *Eax;
  78. Context.Ebx = *Ebx;
  79. Context.Ecx = *Ecx;
  80. Context.Edx = *Edx;
  81. Context.Esi = *Esi;
  82. Context.Edi = *Edi;
  83. Context.Ebp = *Ebp;
  84. #if 0
  85. if (x86BiosExecuteInterrupt((UCHAR)BiosCommand,
  86. &Context,
  87. (PVOID)HalpIoControlBase,
  88. (PVOID)HalpIoMemoryBase) != XM_SUCCESS) {
  89. return FALSE;
  90. }
  91. #endif
  92. //
  93. // Copy the x86 bios context and return TRUE.
  94. //
  95. *Eax = Context.Eax;
  96. *Ebx = Context.Ebx;
  97. *Ecx = Context.Ecx;
  98. *Edx = Context.Edx;
  99. *Esi = Context.Esi;
  100. *Edi = Context.Edi;
  101. *Ebp = Context.Ebp;
  102. return TRUE;
  103. }
  104. VOID
  105. HalpInitializeX86DisplayAdapter(
  106. VOID
  107. )
  108. /*++
  109. Routine Description:
  110. This function initializes a display adapter using the x86 bios emulator.
  111. Arguments:
  112. None.
  113. Return Value:
  114. None.
  115. --*/
  116. {
  117. #if 0
  118. //
  119. // If I/O Ports or I/O memory could not be mapped, then don't
  120. // attempt to initialize the display adapter.
  121. //
  122. if (HalpIoControlBase == NULL || HalpIoMemoryBase == NULL) {
  123. return;
  124. }
  125. //
  126. // Initialize the x86 bios emulator.
  127. //
  128. x86BiosInitializeBios(HalpIoControlBase, HalpIoMemoryBase);
  129. HalpX86BiosInitialized = TRUE;
  130. //
  131. // Attempt to initialize the display adapter by executing its ROM bios
  132. // code. The standard ROM bios code address for PC video adapters is
  133. // 0xC000:0000 on the ISA bus.
  134. //
  135. if (x86BiosInitializeAdapter(0xc0000,
  136. NULL,
  137. (PVOID)HalpIoControlBase,
  138. (PVOID)HalpIoMemoryBase) != XM_SUCCESS) {
  139. HalpEnableInt10Calls = FALSE;
  140. return;
  141. }
  142. #endif
  143. HalpEnableInt10Calls = TRUE;
  144. return;
  145. }
  146. VOID
  147. HalpResetX86DisplayAdapter(
  148. VOID
  149. )
  150. /*++
  151. Routine Description:
  152. This function resets a display adapter using the x86 bios emulator.
  153. Arguments:
  154. None.
  155. Return Value:
  156. None.
  157. --*/
  158. {
  159. CONTEXT86 Context;
  160. //
  161. // Initialize the x86 bios context and make the INT 10 call to initialize
  162. // the display adapter to 80x25 color text mode.
  163. //
  164. Context.Eax = 0x0003; // Function 0, Mode 3
  165. Context.Ebx = 0;
  166. Context.Ecx = 0;
  167. Context.Edx = 0;
  168. Context.Esi = 0;
  169. Context.Edi = 0;
  170. Context.Ebp = 0;
  171. HalCallBios(0x10,
  172. &Context.Eax,
  173. &Context.Ebx,
  174. &Context.Ecx,
  175. &Context.Edx,
  176. &Context.Esi,
  177. &Context.Edi,
  178. &Context.Ebp);
  179. }