#include "ntvdm.h"
#include <debug.h>
#include "emulator.h"
#include "memory.h"
#include "cpu/callback.h"
#include "rom.h"
#include "utils.h"
Go to the source code of this file.
|
static BOOLEAN FASTCALL | ShadowRomWrite (ULONG Address, PVOID Buffer, ULONG Size) |
|
static HANDLE | OpenRomFile (IN PCSTR RomFileName, OUT PULONG RomSize OPTIONAL) |
|
static BOOLEAN | LoadRomFileByHandle (IN HANDLE RomFileHandle, IN PVOID RomLocation, IN ULONG RomSize, OUT PULONG BytesRead) |
|
static VOID | InitRomRange (IN PCALLBACK16 Context, IN ULONG Start, IN ULONG End, IN ULONG Increment) |
|
BOOLEAN | WriteProtectRom (IN PVOID RomLocation, IN ULONG RomSize) |
|
BOOLEAN | WriteUnProtectRom (IN PVOID RomLocation, IN ULONG RomSize) |
|
UCHAR | CalcRomChecksum (IN ULONG RomLocation, IN ULONG RomSize) |
|
BOOLEAN | LoadBios (IN PCSTR BiosFileName, OUT PVOID *BiosLocation OPTIONAL, OUT PULONG BiosSize OPTIONAL) |
|
BOOLEAN | LoadRom (IN PCSTR RomFileName, IN PVOID RomLocation, OUT PULONG RomSize OPTIONAL) |
|
VOID | SearchAndInitRoms (IN PCALLBACK16 Context) |
|
◆ NDEBUG
Definition at line 13 of file rom.c.
◆ CalcRomChecksum()
Definition at line 153 of file rom.c.
155{
156 ULONG RomLastAddress = RomLocation + RomSize;
158
159 while (RomLocation < RomLastAddress)
160 {
162 ++RomLocation;
163 }
164
165 return Sum;
166}
#define REAL_TO_PHYS(ptr)
Referenced by InitRomRange(), and VidBiosInitialize().
◆ InitRomRange()
Definition at line 87 of file rom.c.
91{
95
97 {
98
100 {
101
102
103
104
105
106
107
108
109
111 if (
Address >= 0xE0000) RomSize = 0x10000;
112
114 if (Checksum == 0x00)
115 {
117 DPRINT1(
"Going to run @ address 0x%p\n", EntryPoint);
118
119 EntryPoint =
MAKELONG((EntryPoint & 0xFFFF), (EntryPoint & 0xF0000) >> 4);
120
123
124
126 }
127 else
128 {
129 DPRINT1(
"ROM @ address 0x%p has invalid checksum of 0x%02x\n",
Address, Checksum);
130 }
131 }
132 }
133}
IN OUT PLONG IN OUT PLONG Addend IN OUT PLONG IN LONG Increment
UCHAR CalcRomChecksum(IN ULONG RomLocation, IN ULONG RomSize)
#define OPTION_ROM_SIGNATURE
VOID RunCallback16(IN PCALLBACK16 Context, IN ULONG FarPtr)
VOID WINAPI setDS(USHORT)
Referenced by SearchAndInitRoms().
◆ LoadBios()
Definition at line 169 of file rom.c.
172{
175 ULONG ulBiosSize = 0;
177
178
179 hBiosFile =
OpenRomFile(BiosFileName, &ulBiosSize);
180
181
183
184
185
187
188
190 pBiosLocation,
191 ulBiosSize,
192 &ulBiosSize);
194
195
197
198
199
200
201
203 {
205
206 if (BiosLocation) *BiosLocation = pBiosLocation;
207 if (BiosSize) *BiosSize = ulBiosSize;
208 }
209
211}
#define TO_LINEAR(seg, off)
#define MEM_ALIGN_DOWN(ptr, align)
static HANDLE OpenRomFile(IN PCSTR RomFileName, OUT PULONG RomSize OPTIONAL)
BOOLEAN WriteProtectRom(IN PVOID RomLocation, IN ULONG RomSize)
static BOOLEAN LoadRomFileByHandle(IN HANDLE RomFileHandle, IN PVOID RomLocation, IN ULONG RomSize, OUT PULONG BytesRead)
VOID FileClose(IN HANDLE FileHandle)
DWORD WINAPI GetLastError(void)
Referenced by BiosInitialize().
◆ LoadRom()
Definition at line 214 of file rom.c.
217{
221
222
224
225
227
228
230 RomLocation,
231 ulRomSize,
232 &ulRomSize);
234
235
237
238
239
240
241
243 {
245 if (RomSize) *RomSize = ulRomSize;
246 }
247
249}
Referenced by BiosInitialize().
◆ LoadRomFileByHandle()
Definition at line 63 of file rom.c.
67{
68
69
70
71
72
73 if (RomSize > 0x40000)
74 {
75 DPRINT1(
"ROM image size 0x%lx too large, expected at most 0x40000 (256kB)\n", RomSize);
77 }
78
79
82 RomSize,
84}
BOOLEAN FileLoadByHandle(IN HANDLE FileHandle, IN PVOID Location, IN ULONG FileSize, OUT PULONG BytesRead)
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR _In_opt_ PLONGLONG _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_opt_ PULONG_PTR BytesRead
Referenced by LoadBios(), and LoadRom().
◆ OpenRomFile()
Definition at line 32 of file rom.c.
34{
37
38
39 hRomFile =
FileOpen(RomFileName, &ulRomSize);
40
41
43
44
45
46
47
48
49 if (ulRomSize > 0x40000)
50 {
51
52 DPRINT1(
"ROM image size 0x%lx too large, expected at most 0x40000 (256kB)\n", ulRomSize);
55 }
56
57
58 if (RomSize) *RomSize = ulRomSize;
59 return hRomFile;
60}
HANDLE FileOpen(IN PCSTR FileName, OUT PULONG FileSize OPTIONAL)
Referenced by LoadBios(), and LoadRom().
◆ SearchAndInitRoms()
Definition at line 252 of file rom.c.
253{
254
256
257
259
260
262}
static VOID InitRomRange(IN PCALLBACK16 Context, IN ULONG Start, IN ULONG End, IN ULONG Increment)
Referenced by Bios32Post().
◆ ShadowRomWrite()
◆ WriteProtectRom()
Definition at line 138 of file rom.c.
140{
143}
static BOOLEAN FASTCALL ShadowRomWrite(ULONG Address, PVOID Buffer, ULONG Size)
BOOL MemInstallFastMemoryHook(PVOID Address, ULONG Size, PMEMORY_READ_HANDLER ReadHandler, PMEMORY_WRITE_HANDLER WriteHandler)
Referenced by Bios32Initialize(), LoadBios(), LoadRom(), and VidBiosInitialize().
◆ WriteUnProtectRom()
Definition at line 146 of file rom.c.
148{
150}
BOOL MemRemoveFastMemoryHook(PVOID Address, ULONG Size)