Author: hbelusca
Date: Sun Jun 14 16:40:45 2015
New Revision: 68138
URL:
http://svn.reactos.org/svn/reactos?rev=68138&view=rev
Log:
[NTVDM]: Allocate a dedicated block of memory for the mouse driver, in which we write all
the needed info (instead of putting them in the BIOS space). The INT32 stubs go in this
region, too.
Modified:
trunk/reactos/subsystems/mvdm/ntvdm/dos/mouse32.c
trunk/reactos/subsystems/mvdm/ntvdm/int32.c
trunk/reactos/subsystems/mvdm/ntvdm/int32.h
Modified: trunk/reactos/subsystems/mvdm/ntvdm/dos/mouse32.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/dos/…
==============================================================================
--- trunk/reactos/subsystems/mvdm/ntvdm/dos/mouse32.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/mvdm/ntvdm/dos/mouse32.c [iso-8859-1] Sun Jun 14 16:40:45
2015
@@ -27,18 +27,27 @@
#include "memory.h"
#include "io.h"
#include "dos32krnl/dos.h"
+#include "dos32krnl/memory.h"
/* PRIVATE VARIABLES **********************************************************/
-// FIXME: Because I don't know a better place to store the string
-// I temporarily put it in BIOS space. This need to be moved to a
-// proper place when this driver is interfaced correctly with DOS.
-#define COPYRIGHT_POINTER MAKELONG(0xE100, 0xF000)
-static const CHAR MouseCopyright[] = "ROS PS/2 16/32-bit Mouse Driver Compatible
MS-MOUSE 6.26 Copyright (C) ReactOS Team 1996-2015";
-
-// See FIXME from above.
-#define VERSION_POINTER MAKELONG(0xE160, 0xF000)
-static PWORD Version;
+static const CHAR MouseCopyright[] = "ROS PS/2 16/32-bit Mouse Driver Compatible
MS-MOUSE 6.26 Copyright (C) ReactOS Team 1996-2015\0";
+
+#pragma pack(push, 1)
+
+typedef struct _MOUSE_DRIVER
+{
+ CHAR Copyright[sizeof(MouseCopyright)];
+ WORD Version;
+ BYTE MouseDosInt16Stub[Int16To32StubSize];
+ BYTE MouseIrqInt16Stub[Int16To32StubSize];
+} MOUSE_DRIVER, *PMOUSE_DRIVER;
+
+#pragma pack(pop)
+
+/* Global data contained in guest memory */
+WORD MouseDataSegment;
+PMOUSE_DRIVER MouseData;
#define MICKEYS_PER_CELL_HORIZ 8
#define MICKEYS_PER_CELL_VERT 16
@@ -876,8 +885,8 @@
/* Return Pointer to Copyright String */
case 0x4D:
{
- setES(HIWORD(COPYRIGHT_POINTER));
- setDI(LOWORD(COPYRIGHT_POINTER));
+ setES(MouseDataSegment);
+ setDI(FIELD_OFFSET(MOUSE_DRIVER, Copyright));
break;
}
@@ -890,8 +899,8 @@
* 00h BYTE major version
* 01h BYTE minor version (BCD)
*/
- setES(HIWORD(VERSION_POINTER));
- setDI(LOWORD(VERSION_POINTER));
+ setES(MouseDataSegment);
+ setDI(FIELD_OFFSET(MOUSE_DRIVER, Version));
break;
}
@@ -914,7 +923,8 @@
OldIrqHandler = ((PDWORD)BaseAddress)[MOUSE_IRQ_INT];
/* Set the IRQ handler */
- RegisterDosInt32(MOUSE_IRQ_INT, DosMouseIrq);
+ RegisterInt32(MAKELONG(FIELD_OFFSET(MOUSE_DRIVER, MouseIrqInt16Stub),
MouseDataSegment),
+ MOUSE_IRQ_INT, DosMouseIrq, NULL);
}
}
@@ -986,21 +996,26 @@
BOOLEAN DosMouseInitialize(VOID)
{
+ /* Initialize some memory for storing our data that should be available to DOS */
+ MouseDataSegment = DosAllocateMemory(sizeof(MOUSE_DRIVER), NULL);
+ if (MouseDataSegment == 0) return FALSE;
+ MouseData = (PMOUSE_DRIVER)SEG_OFF_TO_PTR(MouseDataSegment, 0x0000);
+
/* Clear the state */
RtlZeroMemory(&DriverState, sizeof(DriverState));
- /* Setup the version variable in BCD format, compatible MS-MOUSE */
- Version = (PWORD)FAR_POINTER(VERSION_POINTER);
- *Version = MAKEWORD(MOUSE_VERSION/0x0100, MOUSE_VERSION%0x0100);
-
/* Mouse Driver Copyright */
- RtlCopyMemory(FAR_POINTER(COPYRIGHT_POINTER), MouseCopyright,
sizeof(MouseCopyright)-1);
+ RtlCopyMemory(MouseData->Copyright, MouseCopyright, sizeof(MouseCopyright)-1);
+
+ /* Mouse Driver Version in BCD format, compatible MS-MOUSE */
+ MouseData->Version = MAKEWORD(MOUSE_VERSION/0x0100, MOUSE_VERSION%0x0100);
/* Get the old mouse service interrupt handler */
OldIntHandler = ((PDWORD)BaseAddress)[DOS_MOUSE_INTERRUPT];
/* Initialize the interrupt handler */
- RegisterDosInt32(DOS_MOUSE_INTERRUPT, DosMouseService);
+ RegisterInt32(MAKELONG(FIELD_OFFSET(MOUSE_DRIVER, MouseDosInt16Stub),
MouseDataSegment),
+ DOS_MOUSE_INTERRUPT, DosMouseService, NULL);
DosMouseEnable();
return TRUE;
@@ -1014,3 +1029,5 @@
if (DriverState.ShowCount > 0) EraseMouseCursor();
DosMouseDisable();
}
+
+/* EOF */
Modified: trunk/reactos/subsystems/mvdm/ntvdm/int32.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/int3…
==============================================================================
--- trunk/reactos/subsystems/mvdm/ntvdm/int32.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/mvdm/ntvdm/int32.c [iso-8859-1] Sun Jun 14 16:40:45 2015
@@ -59,7 +59,7 @@
0x44, 0x44, // inc sp, inc sp
0xCF, // iret
};
-const ULONG Int16To32StubSize = sizeof(Int16To32);
+C_ASSERT(sizeof(Int16To32) == Int16To32StubSize);
/* PUBLIC FUNCTIONS ***********************************************************/
Modified: trunk/reactos/subsystems/mvdm/ntvdm/int32.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/int3…
==============================================================================
--- trunk/reactos/subsystems/mvdm/ntvdm/int32.h [iso-8859-1] (original)
+++ trunk/reactos/subsystems/mvdm/ntvdm/int32.h [iso-8859-1] Sun Jun 14 16:40:45 2015
@@ -34,7 +34,8 @@
#define STACK_CS 2
#define STACK_FLAGS 3
-extern const ULONG Int16To32StubSize;
+// To be adjusted with the Int16To32 handler code in int32.c
+#define Int16To32StubSize 17
/* FUNCTIONS ******************************************************************/