2 * COPYRIGHT: GPL - See COPYING in the top level directory
3 * PROJECT: ReactOS Virtual DOS Machine
4 * FILE: subsystems/mvdm/ntvdm/bios/bios.c
5 * PURPOSE: VDM BIOS Support Library
6 * PROGRAMMERS: Hermes Belusca-Maito (hermes.belusca@sfr.fr)
9 /* INCLUDES *******************************************************************/
17 #include "cpu/callback.h"
21 #include "bios32/bios32.h"
26 #include "hardware/cmos.h"
30 /* DEFINES ********************************************************************/
33 #define BOP_RESET 0x00 // Windows NTVDM (SoftPC) BIOS calls BOP 0x00
34 // to let the virtual machine perform the POST.
35 #define BOP_EQUIPLIST 0x11
36 #define BOP_GETMEMSIZE 0x12
38 /* PRIVATE VARIABLES **********************************************************/
40 static BOOLEAN Bios32Loaded
= FALSE
;
43 PBIOS_CONFIG_TABLE Bct
;
45 /* PRIVATE FUNCTIONS **********************************************************/
47 /* PUBLIC FUNCTIONS ***********************************************************/
50 WinNtVdmBiosReset(LPWORD Stack
)
52 DisplayMessage(L
"You are loading Windows NTVDM BIOS!\n");
55 DisplayMessage(L
"ReactOS NTVDM doesn't support Windows NTVDM BIOS at the moment. The VDM will shut down.");
60 BiosInitialize(IN LPCSTR BiosFileName
,
61 IN LPCSTR RomFiles OPTIONAL
)
63 BOOLEAN Success
= FALSE
;
64 BOOLEAN Success2
= FALSE
;
68 CHAR RomFileName
[MAX_PATH
+ 10 + 1];
70 /* Disable interrupts */
73 /* Initialize the BDA and the BCT pointers */
74 Bda
= (PBIOS_DATA_AREA
)SEG_OFF_TO_PTR(BDA_SEGMENT
, 0x0000);
75 // The BCT is found at F000:E6F5 for 100% compatible BIOSes.
76 Bct
= (PBIOS_CONFIG_TABLE
)SEG_OFF_TO_PTR(BIOS_SEGMENT
, 0xE6F5);
78 /* Register the BIOS support BOPs */
79 RegisterBop(BOP_RESET
, WinNtVdmBiosReset
); // Needed for Windows NTVDM (SoftPC) BIOS.
80 RegisterBop(BOP_EQUIPLIST
, BiosEquipmentService
); // Needed by Windows NTVDM (SoftPC) BIOS
81 RegisterBop(BOP_GETMEMSIZE
, BiosGetMemorySize
); // and also NTDOS!!
83 if (BiosFileName
== NULL
)
85 Success
= Bios32Loaded
= Bios32Initialize();
87 else if (BiosFileName
[0] != '\0')
89 PVOID BiosLocation
= NULL
;
91 Success
= LoadBios(BiosFileName
, &BiosLocation
, NULL
);
92 DPRINT1("BIOS file '%s' loading %s at address 0x%08x; GetLastError() = %u\n",
93 BiosFileName
, Success
? "succeeded" : "failed", BiosLocation
, GetLastError());
95 else // if (BiosFileName[0] == '\0')
101 /* Bail out now if we failed to load any BIOS file */
102 if (!Success
) return FALSE
;
104 /* Load optional ROMs */
110 strncpy(RomFileName
, RomFile
, ARRAYSIZE(RomFileName
));
111 RomFileName
[ARRAYSIZE(RomFileName
)-1] = '\0';
113 ptr
= strchr(RomFileName
, '|'); // Since '|' is forbidden as a valid file name, we use it as a separator for the ROM address.
117 RomAddress
= strtoul(ptr
, NULL
, 0); // ROM segment
118 RomAddress
<<= 4; // Convert to real address
119 if (RomAddress
== 0) goto Skip
;
121 Success2
= LoadRom(RomFileName
, (PVOID
)RomAddress
, NULL
);
122 DPRINT1("ROM file '%s' loading %s at address 0x%08x; GetLastError() = %u\n",
123 RomFileName
, Success2
? "succeeded" : "failed", RomAddress
, GetLastError());
126 RomFile
+= strlen(RomFile
) + 1;
132 * The CPU is already in reset-mode so that
133 * CS:IP points to F000:FFF0 as required.
135 // DisplayMessage(L"CS:IP=%04X:%04X", getCS(), getIP());
139 // /* Enable interrupts */
142 /* Initialize the Upper Memory Area Manager */
143 if (!UmaMgrInitialize())
145 wprintf(L
"FATAL: Failed to initialize the UMA manager.\n");
157 if (Bios32Loaded
) Bios32Cleanup();