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 *******************************************************************/
14 #include "cpu/callback.h"
18 #include "bios32/bios32.h"
23 #include "hardware/cmos.h"
25 /* DEFINES ********************************************************************/
28 #define BOP_RESET 0x00 // Windows NTVDM (SoftPC) BIOS calls BOP 0x00
29 // to let the virtual machine initialize itself
30 // the IVT and its hardware.
31 #define BOP_EQUIPLIST 0x11
32 #define BOP_GETMEMSIZE 0x12
34 /* PRIVATE VARIABLES **********************************************************/
36 static BOOLEAN Bios32Loaded
= FALSE
;
39 PBIOS_CONFIG_TABLE Bct
;
41 /* PRIVATE FUNCTIONS **********************************************************/
43 /* PUBLIC FUNCTIONS ***********************************************************/
45 VOID WINAPI
BiosEquipmentService(LPWORD Stack
)
47 /* Return the equipment list */
48 setAX(Bda
->EquipmentList
);
51 VOID WINAPI
BiosGetMemorySize(LPWORD Stack
)
53 /* Return the conventional memory size in kB, typically 640 kB */
54 setAX(Bda
->MemorySize
);
58 BiosInitialize(IN LPCSTR BiosFileName
)
60 BOOLEAN Success
= FALSE
;
62 /* Disable interrupts */
65 /* Initialize the BDA and the BCT pointers */
66 Bda
= (PBIOS_DATA_AREA
)SEG_OFF_TO_PTR(BDA_SEGMENT
, 0x0000);
67 // The BCT is found at F000:E6F5 for 100% compatible BIOSes.
68 Bct
= (PBIOS_CONFIG_TABLE
)SEG_OFF_TO_PTR(BIOS_SEGMENT
, 0xE6F5);
70 /**** HACK! HACK! for Windows NTVDM BIOS ****/
71 // WinNtVdmBiosSupportInitialize();
73 // /* Register the BIOS support BOPs */
74 // RegisterBop(BOP_EQUIPLIST , BiosEquipmentService);
75 // RegisterBop(BOP_GETMEMSIZE, BiosGetMemorySize);
77 if (BiosFileName
&& BiosFileName
[0] != '\0')
79 PVOID BiosLocation
= NULL
;
82 Success
= LoadBios(BiosFileName
, &BiosLocation
, &BiosSize
);
83 DPRINT1("BIOS loading %s ; GetLastError() = %u\n", Success
? "succeeded" : "failed", GetLastError());
85 if (!Success
) return FALSE
;
87 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"
88 L
"3 last bytes at 0x%p: 0x%02x 0x%02x 0x%02x",
90 *(PCHAR
)((ULONG_PTR
)REAL_TO_PHYS(BiosLocation
) + 0),
91 *(PCHAR
)((ULONG_PTR
)REAL_TO_PHYS(BiosLocation
) + 1),
92 *(PCHAR
)((ULONG_PTR
)REAL_TO_PHYS(BiosLocation
) + 2),
93 *(PCHAR
)((ULONG_PTR
)REAL_TO_PHYS(BiosLocation
) + 3),
94 *(PCHAR
)((ULONG_PTR
)REAL_TO_PHYS(BiosLocation
) + 4),
95 *(PCHAR
)((ULONG_PTR
)REAL_TO_PHYS(BiosLocation
) + 5),
96 *(PCHAR
)((ULONG_PTR
)REAL_TO_PHYS(BiosLocation
) + 6),
97 *(PCHAR
)((ULONG_PTR
)REAL_TO_PHYS(BiosLocation
) + 7),
98 *(PCHAR
)((ULONG_PTR
)REAL_TO_PHYS(BiosLocation
) + 8),
99 *(PCHAR
)((ULONG_PTR
)REAL_TO_PHYS(BiosLocation
) + 9),
101 (PVOID
)((ULONG_PTR
)BiosLocation
+ BiosSize
- 2),
102 *(PCHAR
)((ULONG_PTR
)REAL_TO_PHYS(BiosLocation
) + BiosSize
- 2),
103 *(PCHAR
)((ULONG_PTR
)REAL_TO_PHYS(BiosLocation
) + BiosSize
- 1),
104 *(PCHAR
)((ULONG_PTR
)REAL_TO_PHYS(BiosLocation
) + BiosSize
- 0));
106 DisplayMessage(L
"POST at 0x%p: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x",
107 TO_LINEAR(getCS(), getIP()),
108 *(PCHAR
)((ULONG_PTR
)SEG_OFF_TO_PTR(getCS(), getIP()) + 0),
109 *(PCHAR
)((ULONG_PTR
)SEG_OFF_TO_PTR(getCS(), getIP()) + 1),
110 *(PCHAR
)((ULONG_PTR
)SEG_OFF_TO_PTR(getCS(), getIP()) + 2),
111 *(PCHAR
)((ULONG_PTR
)SEG_OFF_TO_PTR(getCS(), getIP()) + 3),
112 *(PCHAR
)((ULONG_PTR
)SEG_OFF_TO_PTR(getCS(), getIP()) + 4));
117 * The CPU is already in reset-mode so that
118 * CS:IP points to F000:FFF0 as required.
120 DisplayMessage(L
"CS=0x%p ; IP=0x%p", getCS(), getIP());
128 Success
= Bios32Loaded
= Bios32Initialize();
131 // /* Enable interrupts */
140 if (Bios32Loaded
) Bios32Cleanup();