Author: aandrejevic
Date: Thu Aug 15 01:40:50 2013
New Revision: 59741
URL:
http://svn.reactos.org/svn/reactos?rev=59741&view=rev
Log:
[NTVDM]
Make the BIOS Data Area accessible to other parts of ntvdm.
Properly redirect read/write access to the console to the keyboard and VGA systems,
respectively.
Modified:
branches/ntvdm/subsystems/ntvdm/bios.c
branches/ntvdm/subsystems/ntvdm/bios.h
branches/ntvdm/subsystems/ntvdm/dos.c
branches/ntvdm/subsystems/ntvdm/dos.h
branches/ntvdm/subsystems/ntvdm/ntvdm.h
Modified: branches/ntvdm/subsystems/ntvdm/bios.c
URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/subsystems/ntvdm/bios.c?r…
==============================================================================
--- branches/ntvdm/subsystems/ntvdm/bios.c [iso-8859-1] (original)
+++ branches/ntvdm/subsystems/ntvdm/bios.c [iso-8859-1] Thu Aug 15 01:40:50 2013
@@ -19,7 +19,7 @@
/* PRIVATE VARIABLES **********************************************************/
-static PBIOS_DATA_AREA Bda;
+PBIOS_DATA_AREA Bda;
static BYTE BiosKeyboardMap[256];
static HANDLE BiosConsoleInput = INVALID_HANDLE_VALUE;
static HANDLE BiosConsoleOutput = INVALID_HANDLE_VALUE;
Modified: branches/ntvdm/subsystems/ntvdm/bios.h
URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/subsystems/ntvdm/bios.h?r…
==============================================================================
--- branches/ntvdm/subsystems/ntvdm/bios.h [iso-8859-1] (original)
+++ branches/ntvdm/subsystems/ntvdm/bios.h [iso-8859-1] Thu Aug 15 01:40:50 2013
@@ -99,6 +99,8 @@
/* FUNCTIONS ******************************************************************/
+extern PBIOS_DATA_AREA Bda;
+
BOOLEAN BiosInitialize(VOID);
VOID BiosCleanup(VOID);
BYTE BiosGetVideoMode(VOID);
@@ -112,6 +114,7 @@
VOID BiosTimeService(LPWORD Stack);
VOID BiosHandleIrq(BYTE IrqNumber, LPWORD Stack);
VOID BiosSystemTimerInterrupt(LPWORD Stack);
+VOID BiosPrintCharacter(CHAR Character, BYTE Attribute, BYTE Page);
BOOLEAN BiosScrollWindow(
INT Direction,
DWORD Amount,
Modified: branches/ntvdm/subsystems/ntvdm/dos.c
URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/subsystems/ntvdm/dos.c?re…
==============================================================================
--- branches/ntvdm/subsystems/ntvdm/dos.c [iso-8859-1] (original)
+++ branches/ntvdm/subsystems/ntvdm/dos.c [iso-8859-1] Thu Aug 15 01:40:50 2013
@@ -660,17 +660,30 @@
WORD Result = ERROR_SUCCESS;
DWORD BytesRead32 = 0;
HANDLE Handle = DosGetRealHandle(FileHandle);
+ WORD i;
DPRINT("DosReadFile: FileHandle 0x%04X, Count 0x%04X\n", FileHandle,
Count);
/* Make sure the handle is valid */
if (Handle == INVALID_HANDLE_VALUE) return ERROR_INVALID_HANDLE;
- /* Read the file */
- if (!ReadFile(Handle, Buffer, Count, &BytesRead32, NULL))
- {
- /* Store the error code */
- Result = (WORD)GetLastError();
+ if (IsConsoleHandle(Handle))
+ {
+ for (i = 0; i < Count; i++)
+ {
+ /* Call the BIOS function to read the character */
+ ((LPBYTE)Buffer)[i] = LOBYTE(BiosGetCharacter());
+ BytesRead32++;
+ }
+ }
+ else
+ {
+ /* Read the file */
+ if (!ReadFile(Handle, Buffer, Count, &BytesRead32, NULL))
+ {
+ /* Store the error code */
+ Result = (WORD)GetLastError();
+ }
}
/* The number of bytes read is always 16-bit */
@@ -685,6 +698,7 @@
WORD Result = ERROR_SUCCESS;
DWORD BytesWritten32 = 0;
HANDLE Handle = DosGetRealHandle(FileHandle);
+ WORD i;
DPRINT("DosWriteFile: FileHandle 0x%04X, Count 0x%04X\n",
FileHandle,
@@ -693,11 +707,23 @@
/* Make sure the handle is valid */
if (Handle == INVALID_HANDLE_VALUE) return ERROR_INVALID_HANDLE;
- /* Write the file */
- if (!WriteFile(Handle, Buffer, Count, &BytesWritten32, NULL))
- {
- /* Store the error code */
- Result = (WORD)GetLastError();
+ if (IsConsoleHandle(Handle))
+ {
+ for (i = 0; i < Count; i++)
+ {
+ /* Call the BIOS to print the character */
+ BiosPrintCharacter(((LPBYTE)Buffer)[i], DOS_CHAR_ATTRIBUTE,
Bda->VideoPage);
+ BytesWritten32++;
+ }
+ }
+ else
+ {
+ /* Write the file */
+ if (!WriteFile(Handle, Buffer, Count, &BytesWritten32, NULL))
+ {
+ /* Store the error code */
+ Result = (WORD)GetLastError();
+ }
}
/* The number of bytes written is always 16-bit */
Modified: branches/ntvdm/subsystems/ntvdm/dos.h
URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/subsystems/ntvdm/dos.h?re…
==============================================================================
--- branches/ntvdm/subsystems/ntvdm/dos.h [iso-8859-1] (original)
+++ branches/ntvdm/subsystems/ntvdm/dos.h [iso-8859-1] Thu Aug 15 01:40:50 2013
@@ -36,6 +36,7 @@
#define DOS_CMDLINE_LENGTH 127
#define DOS_DIR_LENGTH 64
#define NUM_DRIVES ('Z' - 'A' + 1)
+#define DOS_CHAR_ATTRIBUTE 0x07
enum DOS_ALLOC_STRATEGY
{
Modified: branches/ntvdm/subsystems/ntvdm/ntvdm.h
URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/subsystems/ntvdm/ntvdm.h?…
==============================================================================
--- branches/ntvdm/subsystems/ntvdm/ntvdm.h [iso-8859-1] (original)
+++ branches/ntvdm/subsystems/ntvdm/ntvdm.h [iso-8859-1] Thu Aug 15 01:40:50 2013
@@ -26,6 +26,7 @@
#define MAX_ADDRESS TO_LINEAR(MAX_SEGMENT, MAX_OFFSET)
#define FAR_POINTER(x) ((ULONG_PTR)BaseAddress + TO_LINEAR(HIWORD(x), LOWORD(x)))
#define STEPS_PER_CYCLE 256
+#define IsConsoleHandle(h) (((((ULONG_PTR)h) & 0x10000003) == 3) ? TRUE : FALSE)
/* FUNCTIONS ******************************************************************/