78f78c14d9115a7775642c27e7b0a17f69379b17
2 * COPYRIGHT: GPL - See COPYING in the top level directory
3 * PROJECT: ReactOS Virtual DOS Machine
5 * PURPOSE: VDM BIOS Support Library
6 * PROGRAMMERS: Hermes Belusca-Maito (hermes.belusca@sfr.fr)
9 /* INCLUDES *******************************************************************/
15 #include "cpu/callback.h"
19 #include "bios32/bios32.h"
24 #include "hardware/cmos.h"
26 /* DEFINES ********************************************************************/
29 #define BOP_RESET 0x00 // Windows NTVDM (SoftPC) BIOS calls BOP 0x00
30 // to let the virtual machine initialize itself
31 // the IVT and its hardware.
32 #define BOP_EQUIPLIST 0x11
33 #define BOP_GETMEMSIZE 0x12
35 /* PRIVATE VARIABLES **********************************************************/
37 static BOOLEAN Bios32Loaded
= FALSE
;
40 PBIOS_CONFIG_TABLE Bct
;
42 /* PRIVATE FUNCTIONS **********************************************************/
44 static BOOLEAN NTAPI
BiosRomWrite(ULONG Address
, PVOID Buffer
, ULONG Size
)
46 /* Prevent writing to ROM */
50 /* PUBLIC FUNCTIONS ***********************************************************/
52 VOID WINAPI
BiosEquipmentService(LPWORD Stack
)
54 /* Return the equipment list */
55 setAX(Bda
->EquipmentList
);
58 VOID WINAPI
BiosGetMemorySize(LPWORD Stack
)
60 /* Return the conventional memory size in kB, typically 640 kB */
61 setAX(Bda
->MemorySize
);
65 BiosInitialize(IN LPCSTR BiosFileName
)
67 BOOLEAN Success
= FALSE
;
69 /* Disable interrupts */
72 /* Initialize the BDA and the BCT pointers */
73 Bda
= (PBIOS_DATA_AREA
)SEG_OFF_TO_PTR(BDA_SEGMENT
, 0x0000);
74 // The BCT is found at F000:E6F5 for 100% compatible BIOSes.
75 Bct
= (PBIOS_CONFIG_TABLE
)SEG_OFF_TO_PTR(BIOS_SEGMENT
, 0xE6F5);
77 /**** HACK! HACK! for Windows NTVDM BIOS ****/
78 // WinNtVdmBiosSupportInitialize();
80 // /* Register the BIOS support BOPs */
81 // RegisterBop(BOP_EQUIPLIST , BiosEquipmentService);
82 // RegisterBop(BOP_GETMEMSIZE, BiosGetMemorySize);
84 MemInstallFastMemoryHook((PVOID
)ROM_AREA_START
,
85 ROM_AREA_END
- ROM_AREA_START
+ 1,
89 if (BiosFileName
&& BiosFileName
[0] != '\0')
91 PVOID BiosLocation
= NULL
;
94 Success
= LoadBios(BiosFileName
, &BiosLocation
, &BiosSize
);
95 DPRINT1("BIOS loading %s ; GetLastError() = %u\n", Success
? "succeeded" : "failed", GetLastError());
97 if (!Success
) return FALSE
;
99 DisplayMessage(L
"First bytes at 0x%p: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n"
100 L
"3 last bytes at 0x%p: 0x%02x 0x%02x 0x%02x",
102 *(PCHAR
)((ULONG_PTR
)REAL_TO_PHYS(BiosLocation
) + 0),
103 *(PCHAR
)((ULONG_PTR
)REAL_TO_PHYS(BiosLocation
) + 1),
104 *(PCHAR
)((ULONG_PTR
)REAL_TO_PHYS(BiosLocation
) + 2),
105 *(PCHAR
)((ULONG_PTR
)REAL_TO_PHYS(BiosLocation
) + 3),
106 *(PCHAR
)((ULONG_PTR
)REAL_TO_PHYS(BiosLocation
) + 4),
107 *(PCHAR
)((ULONG_PTR
)REAL_TO_PHYS(BiosLocation
) + 5),
108 *(PCHAR
)((ULONG_PTR
)REAL_TO_PHYS(BiosLocation
) + 6),
109 *(PCHAR
)((ULONG_PTR
)REAL_TO_PHYS(BiosLocation
) + 7),
110 *(PCHAR
)((ULONG_PTR
)REAL_TO_PHYS(BiosLocation
) + 8),
111 *(PCHAR
)((ULONG_PTR
)REAL_TO_PHYS(BiosLocation
) + 9),
113 (PVOID
)((ULONG_PTR
)BiosLocation
+ BiosSize
- 2),
114 *(PCHAR
)((ULONG_PTR
)REAL_TO_PHYS(BiosLocation
) + BiosSize
- 2),
115 *(PCHAR
)((ULONG_PTR
)REAL_TO_PHYS(BiosLocation
) + BiosSize
- 1),
116 *(PCHAR
)((ULONG_PTR
)REAL_TO_PHYS(BiosLocation
) + BiosSize
- 0));
118 DisplayMessage(L
"POST at 0x%p: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x",
119 TO_LINEAR(getCS(), getIP()),
120 *(PCHAR
)((ULONG_PTR
)SEG_OFF_TO_PTR(getCS(), getIP()) + 0),
121 *(PCHAR
)((ULONG_PTR
)SEG_OFF_TO_PTR(getCS(), getIP()) + 1),
122 *(PCHAR
)((ULONG_PTR
)SEG_OFF_TO_PTR(getCS(), getIP()) + 2),
123 *(PCHAR
)((ULONG_PTR
)SEG_OFF_TO_PTR(getCS(), getIP()) + 3),
124 *(PCHAR
)((ULONG_PTR
)SEG_OFF_TO_PTR(getCS(), getIP()) + 4));
129 * The CPU is already in reset-mode so that
130 * CS:IP points to F000:FFF0 as required.
132 DisplayMessage(L
"CS=0x%p ; IP=0x%p", getCS(), getIP());
140 Success
= Bios32Loaded
= Bios32Initialize();
143 // /* Enable interrupts */
152 if (Bios32Loaded
) Bios32Cleanup();