Windows NT 4.0 source code leak
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.

239 lines
4.0 KiB

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