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.

123 lines
3.7 KiB

  1. //
  2. // Fake Bios support initialization.
  3. //
  4. // This file provides interrim support for rom bios services initialization.
  5. // It is only intended for use until Insignia produces proper rom support
  6. // for NTVDM
  7. //
  8. #include <windows.h>
  9. #include <stdio.h>
  10. #include <conio.h>
  11. #include <string.h>
  12. #include "softpc.h"
  13. #include "bop.h"
  14. #include "xguest.h"
  15. #include "xbios.h"
  16. #include "xbiosdsk.h"
  17. #include "fun.h"
  18. #define SERVICE_LENGTH 4
  19. static BYTE ServiceRoutine[] = { 0xC4 , 0xC4, BOP_UNIMPINT, 0xCF };
  20. #define RESET_LENGTH 16
  21. static BYTE ResetRoutine[] = { 0xEA, 0x00, 0x00, 0x00, 0xE0, // jmpf E000:0
  22. BIOSDATE_MINE,
  23. 0, 0xFE, 0 };
  24. static BYTE WarmBoot[] = {
  25. OPX_MOVAX, BYTESOFFSET(0x30),
  26. OPX_MOV2SEG, MODREGRM(MOD_REGISTER,REG_SS,REG_AX),
  27. OPX_MOVSP, BYTESOFFSET(0x100),
  28. OPX_MOVAX, 0x00, 0x00,
  29. OPX_MOV2SEG, MODREGRM(MOD_REGISTER,REG_DS,REG_AX),
  30. OPX_MOV2SEG, MODREGRM(MOD_REGISTER,REG_ES,REG_AX),
  31. OPX_MOVDX, DRIVE_FD0, 0x00, // WARNING: sync with BIOSBOOT_DRIVE
  32. OPX_MOVCX, 0x01, 0x00,
  33. OPX_MOVBX, BYTESOFFSET(BIOSDATA_BOOT),
  34. OPX_MOVAX, 0x01, DSKFUNC_READSECTORS,
  35. OPX_INT, BIOSINT_DSK,
  36. OPX_JB, -7,
  37. OPX_JMPF, BYTESCOMPOSITE(0, BIOSDATA_BOOT)
  38. };
  39. #define WARMBOOT_LENGTH sizeof(WarmBoot)
  40. static BYTE EquipmentRoutine[] = { // INT 11h code
  41. OPX_PUSHDS,
  42. OPX_MOVAX, 0x00, 0x00,
  43. OPX_MOV2SEG, MODREGRM(MOD_REGISTER,REG_DS,REG_AX),
  44. OPX_MOVAXOFF, BYTESOFFSET(BIOSDATA_EQUIP_FLAG),
  45. OPX_POPDS,
  46. OPX_IRET
  47. };
  48. #define EQUIPMENT_LENGTH sizeof(EquipmentRoutine)
  49. static BYTE MemoryRoutine[] = { // INT 12h code
  50. OPX_PUSHDS,
  51. OPX_MOVAX, 0x00, 0x00,
  52. OPX_MOV2SEG, MODREGRM(MOD_REGISTER,REG_DS,REG_AX),
  53. OPX_MOVAXOFF, BYTESOFFSET(BIOSDATA_MEMORY_SIZE),
  54. OPX_POPDS,
  55. OPX_IRET
  56. };
  57. #define MEMORY_LENGTH sizeof(MemoryRoutine)
  58. VOID BiosInit(int argc, char *argv[]) {
  59. PVOID Address, RomAddress;
  60. // set up IVT with unimplemented interrupt handler
  61. for (Address = NULL; Address < (PVOID)(0x1D * 4); (PCHAR)Address += 4) {
  62. *(PWORD)Address = 0x100;
  63. *(((PWORD)Address) + 1) = 0xF000;
  64. }
  65. RomAddress = (PVOID)(0xE000 << 4);
  66. // set up warm boot handler
  67. memcpy(RomAddress, WarmBoot, WARMBOOT_LENGTH);
  68. Address = RMSEGOFFTOLIN(0, BIOSINT_WBOOT * 4);
  69. *((PWORD)Address) = 0;
  70. *((PWORD)Address + 1) = 0xE000;
  71. (PCHAR)RomAddress += WARMBOOT_LENGTH;
  72. // set up equipment interrupt handler
  73. memcpy(RomAddress, EquipmentRoutine, EQUIPMENT_LENGTH);
  74. Address = RMSEGOFFTOLIN(0, BIOSINT_EQUIP * 4);
  75. *((PWORD)Address) = RMOFF(RomAddress);
  76. *((PWORD)Address + 1) = RMSEG(RomAddress);
  77. (PCHAR)RomAddress += EQUIPMENT_LENGTH;
  78. // set up memory size interrupt handler
  79. memcpy(RomAddress, MemoryRoutine, MEMORY_LENGTH);
  80. Address = RMSEGOFFTOLIN(0, BIOSINT_MEMORY * 4);
  81. *((PWORD)Address) = RMOFF(RomAddress);
  82. *((PWORD)Address + 1) = RMSEG(RomAddress);
  83. RomAddress = (PVOID)((0xF000 << 4) + 0x100);
  84. Address = (PBYTE)RomAddress + 0xFE53;
  85. *(PCHAR)Address = 0xCF; // IRET at f000:ff53
  86. // set up unimplemented interrupt handler
  87. memcpy(RomAddress, ServiceRoutine, SERVICE_LENGTH);
  88. (PCHAR)RomAddress += SERVICE_LENGTH;
  89. // set up reset code
  90. memcpy(RMSEGOFFTOLIN(BIOSROM_SEG, BIOSROM_RESET), ResetRoutine, RESET_LENGTH);
  91. // set up equipment byte and memory size
  92. *(PWORD)RMSEGOFFTOLIN(BIOSDATA_SEG, BIOSDATA_EQUIP_FLAG) =
  93. BIOSEQUIP_32KPLANAR;
  94. *(PWORD)RMSEGOFFTOLIN(BIOSDATA_SEG, BIOSDATA_MEMORY_SIZE) =
  95. 640;
  96. // Initialize individual rom modules
  97. BiosKbdInit(argc, argv, &RomAddress);
  98. BiosVidInit(argc, argv, &RomAddress);
  99. }