Author: hbelusca
Date: Thu Feb 27 03:05:42 2014
New Revision: 62342
URL:
http://svn.reactos.org/svn/reactos?rev=62342&view=rev
Log:
[NTVDM]
- Add BOP 0x12 "BiosGetMemorySize" (same number as the corresponding INTerrupt).
Needed by ntio.sys when initializing (see next commit).
- Use ASCII names for bios image and dos kernel files names.
- Use the file helper functions committed before for implementing ROM image file loading.
Modified:
branches/ntvdm/subsystems/ntvdm/bios/bios.c
branches/ntvdm/subsystems/ntvdm/bios/bios.h
branches/ntvdm/subsystems/ntvdm/bios/bios32/bios32.c
branches/ntvdm/subsystems/ntvdm/bios/rom.c
branches/ntvdm/subsystems/ntvdm/bios/rom.h
Modified: branches/ntvdm/subsystems/ntvdm/bios/bios.c
URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/subsystems/ntvdm/bios/bio…
==============================================================================
--- branches/ntvdm/subsystems/ntvdm/bios/bios.c [iso-8859-1] (original)
+++ branches/ntvdm/subsystems/ntvdm/bios/bios.c [iso-8859-1] Thu Feb 27 03:05:42 2014
@@ -12,10 +12,10 @@
#include "emulator.h"
#include "callback.h"
+#include "bop.h"
#include "bios.h"
-#include "bop.h"
#include "rom.h"
/* PRIVATE VARIABLES **********************************************************/
@@ -34,12 +34,12 @@
static VOID WINAPI BiosInitBop(LPWORD Stack)
{
/* Load the second part of the Windows NTVDM BIOS image */
- LPCWSTR BiosFileName = L"bios1.rom";
+ LPCSTR BiosFileName = "bios1.rom";
PVOID BiosLocation = (PVOID)TO_LINEAR(BIOS_SEGMENT, 0x0000);
DWORD BiosSize = 0;
BOOLEAN Success;
- DPRINT1("You are loading Windows NTVDM BIOS!");
+ DPRINT1("You are loading Windows NTVDM BIOS!\n");
/* Initialize a private callback context */
InitializeContext(&__BiosContext, BIOS_SEGMENT, 0x0000);
@@ -71,13 +71,13 @@
/* Initialize IVT and hardware */
/* Load VGA BIOS */
- // Success = LoadRom(L"v7vga.rom", (PVOID)0xC0000, &BiosSize);
+ // Success = LoadRom("v7vga.rom", (PVOID)0xC0000, &BiosSize);
// DPRINT1("VGA BIOS loading %s ; GetLastError() = %u\n", Success ?
"succeeded" : "failed", GetLastError());
///////////// MUST BE DONE AFTER IVT INITIALIZATION !! /////////////////////
/* Load some ROMs */
- Success = LoadRom(L"boot.bin", (PVOID)0xE0000, &BiosSize);
+ Success = LoadRom("boot.bin", (PVOID)0xE0000, &BiosSize);
DPRINT1("Test ROM loading %s ; GetLastError() = %u\n", Success ?
"succeeded" : "failed", GetLastError());
SearchAndInitRoms(&__BiosContext);
@@ -85,9 +85,10 @@
/* PUBLIC FUNCTIONS ***********************************************************/
-BOOLEAN BiosInitialize(IN LPCWSTR BiosFileName,
- IN HANDLE ConsoleInput,
- IN HANDLE ConsoleOutput)
+BOOLEAN
+BiosInitialize(IN LPCSTR BiosFileName,
+ IN HANDLE ConsoleInput,
+ IN HANDLE ConsoleOutput)
{
/* Register the BIOS support BOPs */
RegisterBop(BOP_BIOSINIT, BiosInitBop);
@@ -148,7 +149,8 @@
}
}
-VOID BiosCleanup(VOID)
+VOID
+BiosCleanup(VOID)
{
if (Bios32Loaded) Bios32Cleanup();
}
Modified: branches/ntvdm/subsystems/ntvdm/bios/bios.h
URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/subsystems/ntvdm/bios/bio…
==============================================================================
--- branches/ntvdm/subsystems/ntvdm/bios/bios.h [iso-8859-1] (original)
+++ branches/ntvdm/subsystems/ntvdm/bios/bios.h [iso-8859-1] Thu Feb 27 03:05:42 2014
@@ -105,10 +105,13 @@
extern PBIOS_DATA_AREA Bda;
-BOOLEAN BiosInitialize(IN LPCWSTR BiosFileName,
- IN HANDLE ConsoleInput,
- IN HANDLE ConsoleOutput);
-VOID BiosCleanup(VOID);
+BOOLEAN
+BiosInitialize(IN LPCSTR BiosFileName,
+ IN HANDLE ConsoleInput,
+ IN HANDLE ConsoleOutput);
+
+VOID
+BiosCleanup(VOID);
#endif // _BIOS_H_
Modified: branches/ntvdm/subsystems/ntvdm/bios/bios32/bios32.c
URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/subsystems/ntvdm/bios/bio…
==============================================================================
--- branches/ntvdm/subsystems/ntvdm/bios/bios32/bios32.c [iso-8859-1] (original)
+++ branches/ntvdm/subsystems/ntvdm/bios/bios32/bios32.c [iso-8859-1] Thu Feb 27 03:05:42
2014
@@ -12,6 +12,7 @@
#include "emulator.h"
#include "callback.h"
+#include "bop.h"
#include "../rom.h"
#include "../bios.h"
@@ -26,6 +27,9 @@
CALLBACK16 BiosContext;
PBIOS_DATA_AREA Bda;
+
+/* BOP Identifiers */
+#define BOP_GETMEMSIZE 0x12
/* PRIVATE FUNCTIONS **********************************************************/
@@ -347,6 +351,9 @@
((PULONG)BaseAddress)[0x46] = (ULONG)NULL;
((PULONG)BaseAddress)[0x48] = (ULONG)NULL;
((PULONG)BaseAddress)[0x49] = (ULONG)NULL;
+
+ /* Register the BIOS support BOPs */
+ RegisterBop(BOP_GETMEMSIZE, BiosGetMemorySize);
}
/* PUBLIC FUNCTIONS ***********************************************************/
@@ -408,7 +415,7 @@
///////////// MUST BE DONE AFTER IVT INITIALIZATION !! /////////////////////
/* Load some ROMs */
- Success = LoadRom(L"boot.bin", (PVOID)0xE0000, NULL);
+ Success = LoadRom("boot.bin", (PVOID)0xE0000, NULL);
DPRINT1("Test ROM loading %s ; GetLastError() = %u\n", Success ?
"succeeded" : "failed", GetLastError());
SearchAndInitRoms(&BiosContext);
Modified: branches/ntvdm/subsystems/ntvdm/bios/rom.c
URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/subsystems/ntvdm/bios/rom…
==============================================================================
--- branches/ntvdm/subsystems/ntvdm/bios/rom.c [iso-8859-1] (original)
+++ branches/ntvdm/subsystems/ntvdm/bios/rom.c [iso-8859-1] Thu Feb 27 03:05:42 2014
@@ -12,65 +12,48 @@
#include "emulator.h"
#include "callback.h"
+#include "utils.h"
#include "rom.h"
/* PRIVATE FUNCTIONS **********************************************************/
static HANDLE
-OpenRomFile(IN LPCWSTR RomFileName,
- OUT PDWORD RomSize OPTIONAL)
+OpenRomFile(IN PCSTR RomFileName,
+ OUT PULONG RomSize OPTIONAL)
{
HANDLE hRomFile;
- DWORD dwRomSize;
+ ULONG ulRomSize = 0;
/* Open the ROM image file */
- SetLastError(0); // For debugging purposes
- hRomFile = CreateFileW(RomFileName,
- GENERIC_READ,
- FILE_SHARE_READ,
- NULL,
- OPEN_EXISTING,
- FILE_ATTRIBUTE_NORMAL,
- NULL);
- DPRINT1("ROM opening %s ; GetLastError() = %u\n", hRomFile !=
INVALID_HANDLE_VALUE ? "succeeded" : "failed", GetLastError());
-
- /* We failed, bail out */
- if (hRomFile == INVALID_HANDLE_VALUE) return NULL;
-
- /* OK, we have a handle to the ROM image file */
+ hRomFile = FileOpen(RomFileName, &ulRomSize);
+
+ /* If we failed, bail out */
+ if (hRomFile == NULL) return NULL;
/*
- * Retrieve the size of the file.
- *
* The size of the ROM image file is at most 256kB. For instance,
* the SeaBIOS image, which includes also expansion ROMs inside it,
* covers the range C000:0000 to F000:FFFF .
- *
- * We therefore can use GetFileSize.
*/
- dwRomSize = GetFileSize(hRomFile, NULL);
- if ( (dwRomSize == INVALID_FILE_SIZE && GetLastError() != ERROR_SUCCESS) ||
- (dwRomSize > 0x40000) )
+ if (ulRomSize > 0x40000)
{
/* We failed, bail out */
- DPRINT1("Error when retrieving ROM size, or size too large (%d)\n",
dwRomSize);
-
- /* Close the ROM image file */
- CloseHandle(hRomFile);
-
+ DPRINT1("ROM image size 0x%lx too large, expected at most 0x40000
(256kB)", ulRomSize);
+ FileClose(hRomFile);
return NULL;
}
/* Success, return file handle and size if needed */
- if (RomSize) *RomSize = dwRomSize;
+ if (RomSize) *RomSize = ulRomSize;
return hRomFile;
}
-static BOOL
-LoadRomFileByHandle(IN HANDLE RomFileHandle,
- IN PVOID RomLocation,
- IN ULONG RomSize)
+static BOOLEAN
+LoadRomFileByHandle(IN HANDLE RomFileHandle,
+ IN PVOID RomLocation,
+ IN ULONG RomSize,
+ OUT PULONG BytesRead)
{
/*
* The size of the ROM image file is at most 256kB. For instance,
@@ -79,17 +62,15 @@
*/
if (RomSize > 0x40000)
{
- DPRINT1("Wrong ROM image size 0x%lx, expected at most 0x40000 (256kB)",
RomSize);
+ DPRINT1("ROM image size 0x%lx too large, expected at most 0x40000
(256kB)", RomSize);
return FALSE;
}
/* Attempt to load the ROM image file into memory */
- SetLastError(0); // For debugging purposes
- return ReadFile(RomFileHandle,
- REAL_TO_PHYS(RomLocation),
- RomSize,
- &RomSize,
- NULL);
+ return FileLoadByHandle(RomFileHandle,
+ REAL_TO_PHYS(RomLocation),
+ RomSize,
+ BytesRead);
}
static UCHAR
@@ -159,73 +140,82 @@
/* PUBLIC FUNCTIONS ***********************************************************/
-BOOLEAN LoadBios(IN LPCWSTR BiosFileName,
- OUT PVOID* BiosLocation OPTIONAL,
- OUT PDWORD BiosSize OPTIONAL)
-{
- BOOL Success;
- HANDLE hBiosFile;
- DWORD dwBiosSize = 0;
- PVOID pBiosLocation;
+BOOLEAN
+LoadBios(IN PCSTR BiosFileName,
+ OUT PVOID* BiosLocation OPTIONAL,
+ OUT PULONG BiosSize OPTIONAL)
+{
+ BOOLEAN Success;
+ HANDLE hBiosFile;
+ ULONG ulBiosSize = 0;
+ PVOID pBiosLocation;
/* Open the BIOS image file */
- hBiosFile = OpenRomFile(BiosFileName, &dwBiosSize);
+ hBiosFile = OpenRomFile(BiosFileName, &ulBiosSize);
/* If we failed, bail out */
if (hBiosFile == NULL) return FALSE;
/* BIOS location needs to be aligned on 32-bit boundary */
- // (PVOID)((ULONG_PTR)BaseAddress + ROM_AREA_END + 1 - dwBiosSize)
- pBiosLocation = MEM_ALIGN_DOWN(TO_LINEAR(0xF000, 0xFFFF) + 1 - dwBiosSize,
sizeof(ULONG));
+ // (PVOID)((ULONG_PTR)BaseAddress + ROM_AREA_END + 1 - ulBiosSize)
+ pBiosLocation = MEM_ALIGN_DOWN(TO_LINEAR(0xF000, 0xFFFF) + 1 - ulBiosSize,
sizeof(ULONG));
/* Attempt to load the BIOS image file into memory */
- Success = LoadRomFileByHandle(hBiosFile, pBiosLocation, dwBiosSize);
+ Success = LoadRomFileByHandle(hBiosFile,
+ pBiosLocation,
+ ulBiosSize,
+ &ulBiosSize);
DPRINT1("BIOS loading %s ; GetLastError() = %u\n", Success ?
"succeeded" : "failed", GetLastError());
/* Close the BIOS image file */
- CloseHandle(hBiosFile);
+ FileClose(hBiosFile);
/* In case of success, return BIOS location and size if needed */
if (Success)
{
if (BiosLocation) *BiosLocation = pBiosLocation;
- if (BiosSize) *BiosSize = dwBiosSize;
- }
-
- return (BOOLEAN)Success;
-}
-
-BOOLEAN LoadRom(IN LPCWSTR RomFileName,
- IN PVOID RomLocation,
- OUT PDWORD RomSize OPTIONAL)
-{
- BOOL Success;
- HANDLE hRomFile;
- DWORD dwRomSize = 0;
+ if (BiosSize) *BiosSize = ulBiosSize;
+ }
+
+ return Success;
+}
+
+BOOLEAN
+LoadRom(IN PCSTR RomFileName,
+ IN PVOID RomLocation,
+ OUT PULONG RomSize OPTIONAL)
+{
+ BOOLEAN Success;
+ HANDLE hRomFile;
+ ULONG ulRomSize = 0;
/* Open the ROM image file */
- hRomFile = OpenRomFile(RomFileName, &dwRomSize);
+ hRomFile = OpenRomFile(RomFileName, &ulRomSize);
/* If we failed, bail out */
if (hRomFile == NULL) return FALSE;
/* Attempt to load the ROM image file into memory */
- Success = LoadRomFileByHandle(hRomFile, RomLocation, dwRomSize);
+ Success = LoadRomFileByHandle(hRomFile,
+ RomLocation,
+ ulRomSize,
+ &ulRomSize);
DPRINT1("ROM loading %s ; GetLastError() = %u\n", Success ?
"succeeded" : "failed", GetLastError());
/* Close the ROM image file and return */
- CloseHandle(hRomFile);
+ FileClose(hRomFile);
/* In case of success, return ROM size if needed */
if (Success)
{
- if (RomSize) *RomSize = dwRomSize;
- }
-
- return (BOOLEAN)Success;
-}
-
-VOID SearchAndInitRoms(IN PCALLBACK16 Context)
+ if (RomSize) *RomSize = ulRomSize;
+ }
+
+ return Success;
+}
+
+VOID
+SearchAndInitRoms(IN PCALLBACK16 Context)
{
/* Adapters ROMs -- Start: C8000, End: E0000, 2kB blocks */
InitRomRange(Context, 0xC8000, 0xE0000, 0x0800);
Modified: branches/ntvdm/subsystems/ntvdm/bios/rom.h
URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/subsystems/ntvdm/bios/rom…
==============================================================================
--- branches/ntvdm/subsystems/ntvdm/bios/rom.h [iso-8859-1] (original)
+++ branches/ntvdm/subsystems/ntvdm/bios/rom.h [iso-8859-1] Thu Feb 27 03:05:42 2014
@@ -22,15 +22,18 @@
/* FUNCTIONS ******************************************************************/
-BOOLEAN LoadBios(IN LPCWSTR BiosFileName,
- OUT PVOID* BiosLocation OPTIONAL,
- OUT PDWORD BiosSize OPTIONAL);
+BOOLEAN
+LoadBios(IN PCSTR BiosFileName,
+ OUT PVOID* BiosLocation OPTIONAL,
+ OUT PULONG BiosSize OPTIONAL);
-BOOLEAN LoadRom(IN LPCWSTR RomFileName,
- IN PVOID RomLocation,
- OUT PDWORD RomSize OPTIONAL);
+BOOLEAN
+LoadRom(IN PCSTR RomFileName,
+ IN PVOID RomLocation,
+ OUT PULONG RomSize OPTIONAL);
-VOID SearchAndInitRoms(IN PCALLBACK16 Context);
+VOID
+SearchAndInitRoms(IN PCALLBACK16 Context);
#endif // _ROM_H_