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.

521 lines
7.1 KiB

  1. /*++
  2. Copyright (c) 1996 Intel Corporation
  3. Copyright (c) 1994 Microsoft Corporation
  4. Module Name:
  5. i64bios.c copied from hali64\x86bios.c
  6. Abstract:
  7. This module implements the platform specific interface between a device
  8. driver and the execution of x86 ROM bios code for the device.
  9. Author:
  10. William K. Cheung (wcheung) 20-Mar-1996
  11. based on the version by David N. Cutler (davec) 17-Jun-1994
  12. Environment:
  13. Kernel mode only.
  14. Revision History:
  15. Bernard Lint, M.Jayakumar November 1998
  16. --*/
  17. #include "halp.h"
  18. #include "emulate.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. extern XM_STATUS x86BiosExecuteInterrupt (
  24. IN UCHAR Number,
  25. IN OUT PXM86_CONTEXT Context,
  26. IN PVOID BiosIoSpace OPTIONAL,
  27. IN PVOID BiosIoMemory OPTIONAL
  28. );
  29. extern PVOID x86BiosTranslateAddress (
  30. IN USHORT Segment,
  31. IN USHORT Offset
  32. );
  33. //
  34. // Initialize Default X86 bios spaces
  35. //
  36. #define NUMBER_X86_PAGES (0x100000 / PAGE_SIZE) // map through 0xfffff
  37. PVOID HalpIoControlBase = NULL;
  38. PVOID HalpIoMemoryBase = NULL;
  39. //
  40. // Define global data.
  41. //
  42. ULONG HalpX86BiosInitialized = FALSE;
  43. ULONG HalpEnableInt10Calls = FALSE;
  44. VOID
  45. HalpInitIoMemoryBase(
  46. VOID
  47. )
  48. /*++
  49. Routine Description:
  50. Arguements:
  51. Return Value:
  52. --*/
  53. {
  54. PHYSICAL_ADDRESS COMPATIBLE_PCI_PHYSICAL_BASE_ADDRESS = { 0x0};
  55. HalpIoMemoryBase = (PUCHAR)HalpMapPhysicalMemory (
  56. COMPATIBLE_PCI_PHYSICAL_BASE_ADDRESS,
  57. (ULONG) NUMBER_X86_PAGES,
  58. (MEMORY_CACHING_TYPE)MmNonCached
  59. );
  60. ASSERT(HalpIoMemoryBase);
  61. }
  62. ULONG
  63. HalpSetCmosData (
  64. IN PVOID BusHandler,
  65. IN PVOID RootHandler,
  66. IN ULONG SlotNumber,
  67. IN PVOID Buffer,
  68. IN ULONG Offset,
  69. IN ULONG Length
  70. )
  71. /*++
  72. Routine Description:
  73. Arguements:
  74. Return Value:
  75. --*/
  76. {
  77. return 0;
  78. }
  79. ULONG
  80. HalpGetCmosData (
  81. IN ULONG BusNumber,
  82. IN ULONG SlotNumber,
  83. IN PVOID Buffer,
  84. IN ULONG Length
  85. )
  86. /*++
  87. Routine Description:
  88. Arguements:
  89. Return Value:
  90. --*/
  91. {
  92. return 0;
  93. }
  94. VOID
  95. HalpAcquireCmosSpinLock (
  96. VOID
  97. )
  98. /*++
  99. Routine Description:
  100. Arguements:
  101. Return Value:
  102. --*/
  103. {
  104. return;
  105. }
  106. VOID
  107. HalpReleaseCmosSpinLock (
  108. VOID
  109. )
  110. /*++
  111. Routine Description:
  112. Arguements:
  113. Return Value:
  114. --*/
  115. {
  116. return ;
  117. }
  118. HAL_DISPLAY_BIOS_INFORMATION
  119. HalpGetDisplayBiosInformation (
  120. VOID
  121. )
  122. /*++
  123. Routine Description:
  124. Arguements:
  125. Return Value:
  126. --*/
  127. {
  128. return 8;
  129. }
  130. VOID
  131. HalpInitializeCmos (
  132. VOID
  133. )
  134. /*++
  135. Routine Description:
  136. Arguements:
  137. Return Value:
  138. --*/
  139. {
  140. return ;
  141. }
  142. VOID
  143. HalpReadCmosTime (
  144. PTIME_FIELDS TimeFields
  145. )
  146. /*++
  147. Routine Description:
  148. Arguements:
  149. Return Value:
  150. --*/
  151. {
  152. return ;
  153. }
  154. VOID
  155. HalpWriteCmosTime (
  156. PTIME_FIELDS TimeFields
  157. )
  158. /*++
  159. Routine Description:
  160. Arguements:
  161. Return Value:
  162. --*/
  163. {
  164. return;
  165. }
  166. VOID
  167. HalpBiosDisplayReset (
  168. VOID
  169. )
  170. /*++
  171. Routine Description:
  172. Arguements:
  173. Return Value:
  174. --*/
  175. {
  176. //
  177. // Make an int10 call to set the display into 640x480 16 color mode
  178. //
  179. // mov ax, 12h
  180. // int 10h
  181. //
  182. ULONG Eax = 0x12;
  183. ULONG Exx = 0x00;
  184. HalCallBios(0x10,
  185. &Eax,
  186. &Exx,
  187. &Exx,
  188. &Exx,
  189. &Exx,
  190. &Exx,
  191. &Exx);
  192. return;
  193. }
  194. BOOLEAN
  195. HalCallBios (
  196. IN ULONG BiosCommand,
  197. IN OUT PULONG Eax,
  198. IN OUT PULONG Ebx,
  199. IN OUT PULONG Ecx,
  200. IN OUT PULONG Edx,
  201. IN OUT PULONG Esi,
  202. IN OUT PULONG Edi,
  203. IN OUT PULONG Ebp
  204. )
  205. /*++
  206. Routine Description:
  207. This function provides the platform specific interface between a device
  208. driver and the execution of the x86 ROM bios code for the specified ROM
  209. bios command.
  210. Arguments:
  211. BiosCommand - Supplies the ROM bios command to be emulated.
  212. Eax to Ebp - Supplies the x86 emulation context.
  213. Return Value:
  214. A value of TRUE is returned if the specified function is executed.
  215. Otherwise, a value of FALSE is returned.
  216. --*/
  217. {
  218. XM86_CONTEXT Context;
  219. HalDebugPrint(( HAL_INFO, "HAL: HalCallBios - Cmd = 0x%x, eax = 0x%p\n", BiosCommand, Eax ));
  220. //
  221. // If the x86 BIOS Emulator has not been initialized, then return FALSE.
  222. //
  223. if (HalpX86BiosInitialized == FALSE) {
  224. return FALSE;
  225. }
  226. //
  227. // If the Adapter BIOS initialization failed and an Int10 command is
  228. // specified, then return FALSE.
  229. //
  230. if ((BiosCommand == 0x10) && (HalpEnableInt10Calls == FALSE)) {
  231. return FALSE;
  232. }
  233. //
  234. // Copy the x86 bios context and emulate the specified command.
  235. //
  236. Context.Eax = *Eax;
  237. Context.Ebx = *Ebx;
  238. Context.Ecx = *Ecx;
  239. Context.Edx = *Edx;
  240. Context.Esi = *Esi;
  241. Context.Edi = *Edi;
  242. Context.Ebp = *Ebp;
  243. if (x86BiosExecuteInterrupt((UCHAR)BiosCommand,
  244. &Context,
  245. (PVOID)HalpIoControlBase,
  246. (PVOID)HalpIoMemoryBase) != XM_SUCCESS) {
  247. HalDebugPrint(( HAL_ERROR, "HAL: HalCallBios - ERROR in Cmd = 0x%x\n", BiosCommand ));
  248. return FALSE;
  249. }
  250. //
  251. // Copy the x86 bios context and return TRUE.
  252. //
  253. *Eax = Context.Eax;
  254. *Ebx = Context.Ebx;
  255. *Ecx = Context.Ecx;
  256. *Edx = Context.Edx;
  257. *Esi = Context.Esi;
  258. *Edi = Context.Edi;
  259. *Ebp = Context.Ebp;
  260. return TRUE;
  261. }
  262. VOID
  263. HalpInitializeX86Int10Call(
  264. VOID
  265. )
  266. /*++
  267. Routine Description:
  268. This function initializes x86 bios emulator, display data area and
  269. interrupt vector area.
  270. Arguments:
  271. None.
  272. Return Value:
  273. None.
  274. --*/
  275. {
  276. XM86_CONTEXT State;
  277. PXM86_CONTEXT Context;
  278. PULONG x86BiosLowMemoryPtr, PhysicalMemoryPtr;
  279. //
  280. // Initialize the x86 bios emulator.
  281. //
  282. x86BiosInitializeBios(HalpIoControlBase, HalpIoMemoryBase);
  283. x86BiosLowMemoryPtr = (PULONG)(x86BiosTranslateAddress(LOW_MEM_SEGMET, LOW_MEM_OFFSET));
  284. PhysicalMemoryPtr = (PULONG) HalpIoMemoryBase;
  285. //
  286. // Copy the VECTOR TABLE from 0 to 2k. This is because we are not executing
  287. // the initialization of Adapter since SAL takes care of it. However, the
  288. // emulation memory needs to be updated from the interrupt vector and BIOS
  289. // data area.
  290. //
  291. RtlCopyMemory(x86BiosLowMemoryPtr,
  292. PhysicalMemoryPtr,
  293. (SIZE_OF_VECTOR_TABLE+SIZE_OF_BIOS_DATA_AREA)
  294. );
  295. HalpX86BiosInitialized = TRUE;
  296. HalpEnableInt10Calls = TRUE;
  297. return;
  298. }
  299. VOID
  300. HalpResetX86DisplayAdapter(
  301. VOID
  302. )
  303. /*++
  304. Routine Description:
  305. This function resets a display adapter using the x86 bios emulator.
  306. Arguments:
  307. None.
  308. Return Value:
  309. None.
  310. --*/
  311. {
  312. ULONG Eax;
  313. ULONG Ebx;
  314. ULONG Ecx;
  315. ULONG Edx;
  316. ULONG Esi;
  317. ULONG Edi;
  318. ULONG Ebp;
  319. //
  320. // Initialize the x86 bios context and make the INT 10 call to initialize
  321. // the display adapter to 80x25 color text mode.
  322. //
  323. Eax = 0x0003; // Function 0, Mode 3
  324. Ebx = 0;
  325. Ecx = 0;
  326. Edx = 0;
  327. Esi = 0;
  328. Edi = 0;
  329. Ebp = 0;
  330. HalCallBios(0x10,
  331. &Eax,
  332. &Ebx,
  333. &Ecx,
  334. &Edx,
  335. &Esi,
  336. &Edi,
  337. &Ebp);
  338. }