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.

194 lines
3.1 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. PVOID HalpIoControlBase = NULL;
  20. PVOID HalpIoMemoryBase = (PVOID)KSEG0_BASE;
  21. BOOLEAN HalpX86BiosInitialized = FALSE;
  22. VOID
  23. HalpBiosDisplayReset (
  24. VOID
  25. )
  26. /*++
  27. Routine Description:
  28. This function places the VGA display into 640 x 480 16 color mode
  29. by calling the BIOS.
  30. Arguments:
  31. None.
  32. Return Value:
  33. None.
  34. --*/
  35. {
  36. ULONG eax;
  37. ULONG exx;
  38. //
  39. // ah = function 0: reset display
  40. // al = mode 0x12: 640x480 16 color
  41. //
  42. eax = 0x0012;
  43. exx = 0;
  44. //
  45. // Simulate:
  46. //
  47. // mov ax, 0012h
  48. // int 10h
  49. //
  50. HalCallBios(0x10,&eax,&exx,&exx,&exx,&exx,&exx,&exx);
  51. }
  52. BOOLEAN
  53. HalCallBios (
  54. IN ULONG BiosCommand,
  55. IN OUT PULONG Eax,
  56. IN OUT PULONG Ebx,
  57. IN OUT PULONG Ecx,
  58. IN OUT PULONG Edx,
  59. IN OUT PULONG Esi,
  60. IN OUT PULONG Edi,
  61. IN OUT PULONG Ebp
  62. )
  63. /*++
  64. Routine Description:
  65. This function provides the platform specific interface between a device
  66. driver and the execution of the x86 ROM bios code for the specified ROM
  67. bios command.
  68. Arguments:
  69. BiosCommand - Supplies the ROM bios command to be emulated.
  70. Eax to Ebp - Supplies the x86 emulation context.
  71. Return Value:
  72. A value of TRUE is returned if the specified function is executed.
  73. Otherwise, a value of FALSE is returned.
  74. --*/
  75. {
  76. XM86_CONTEXT context;
  77. XM_STATUS status;
  78. if (HalpX86BiosInitialized == FALSE) {
  79. return FALSE;
  80. }
  81. // s
  82. // Copy the x86 bios context and emulate the specified command.
  83. //
  84. context.Eax = *Eax;
  85. context.Ebx = *Ebx;
  86. context.Ecx = *Ecx;
  87. context.Edx = *Edx;
  88. context.Esi = *Esi;
  89. context.Edi = *Edi;
  90. context.Ebp = *Ebp;
  91. status = x86BiosExecuteInterrupt((UCHAR)BiosCommand,
  92. &context,
  93. (PVOID)HalpIoControlBase,
  94. (PVOID)HalpIoMemoryBase);
  95. if (status != XM_SUCCESS) {
  96. return FALSE;
  97. }
  98. //
  99. // Copy the x86 bios context and return TRUE.
  100. //
  101. *Eax = context.Eax;
  102. *Ebx = context.Ebx;
  103. *Ecx = context.Ecx;
  104. *Edx = context.Edx;
  105. *Esi = context.Esi;
  106. *Edi = context.Edi;
  107. *Ebp = context.Ebp;
  108. return TRUE;
  109. }
  110. VOID
  111. HalpInitializeBios (
  112. VOID
  113. )
  114. /*++
  115. Routine Description:
  116. This routine initializes the X86 emulation module and an attached VGA
  117. adapter.
  118. Arguments:
  119. None.
  120. Return Value:
  121. None.
  122. --*/
  123. {
  124. XM_STATUS status;
  125. x86BiosInitializeBios(NULL, (PVOID)KSEG0_BASE);
  126. status = x86BiosInitializeAdapter(0xc0000,NULL,NULL,NULL);
  127. if (status != XM_SUCCESS) {
  128. return;
  129. }
  130. HalpX86BiosInitialized = TRUE;
  131. }