Mouse:
- Remove now useless code in mouse support in BIOS.
- Implement INT 33h, AH=1Bh "Return mouse sensitivity" (returning hardcoded standard values since we don't support custom sensitivities) (AH=13h and 1Ah are marked as UNSUPPORTED).
- INT 33h, AH=1Fh "Disable mouse driver" returns in ES:BX the old INT 33h vector value: implement that.
- Implement INT 33h, AH=21h "Software reset", AH=24h and 4Dh and 6Dh "Software version and mouse info", "pointer to copyright string" and "version 'string'" functionalities.

DOS:
- Initialize in Win2k3-ntvdm-compatible order the DOS drivers: NUL, then CON, then XMS, and then EMS.
- Fix segment/offset inversion usage in INT 21h, AH=5Ch "Lock/Unlock region of file": when using MAKELONG macro to build a far pointer, the first parameter (loword) is the offset, and the second parameter (hiword) is the segment.

svn path=/trunk/; revision=67518
This commit is contained in:
Hermès Bélusca-Maïto 2015-05-02 20:48:08 +00:00
parent b18c48243f
commit bc3ca7d415
5 changed files with 137 additions and 76 deletions

View file

@ -17,12 +17,8 @@
#include "bios32p.h"
#include "io.h"
#include "hardware/mouse.h"
#include "hardware/ps2.h"
// HACK: For the PS/2 bypass and MOUSE.COM driver direct call
#include "dos/mouse32.h"
/* PRIVATE VARIABLES **********************************************************/
/* PRIVATE FUNCTIONS **********************************************************/

View file

@ -11,63 +11,6 @@
/* DEFINES ********************************************************************/
#if 0 // This code is for the MOUSE.COM driver
enum
{
MOUSE_BUTTON_LEFT,
MOUSE_BUTTON_RIGHT,
MOUSE_BUTTON_MIDDLE,
NUM_MOUSE_BUTTONS
};
typedef struct _MOUSE_USER_HANDLER
{
/*
* CallMask format: see table: http://www.ctyme.com/intr/rb-5968.htm#Table3171
* Alternatively, see table: http://www.ctyme.com/intr/rb-5981.htm#Table3174
*/
USHORT CallMask;
ULONG Callback; // Far pointer to the callback
} MOUSE_USER_HANDLER, *PMOUSE_USER_HANDLER;
typedef struct _MOUSE_DRIVER_STATE
{
SHORT ShowCount;
COORD Position;
WORD Character;
WORD ButtonState;
WORD PressCount[NUM_MOUSE_BUTTONS];
COORD LastPress[NUM_MOUSE_BUTTONS];
WORD ReleaseCount[NUM_MOUSE_BUTTONS];
COORD LastRelease[NUM_MOUSE_BUTTONS];
SHORT HorizCount;
SHORT VertCount;
WORD MickeysPerCellHoriz;
WORD MickeysPerCellVert;
/*
* User Subroutine Handlers called on mouse events
*/
MOUSE_USER_HANDLER Handler0; // Handler compatible MS MOUSE v1.0+
MOUSE_USER_HANDLER Handlers[3]; // Handlers compatible MS MOUSE v6.0+
struct
{
WORD ScreenMask;
WORD CursorMask;
} TextCursor;
struct
{
COORD HotSpot;
WORD ScreenMask[16];
WORD CursorMask[16];
} GraphicsCursor;
} MOUSE_DRIVER_STATE, *PMOUSE_DRIVER_STATE;
#endif
/* FUNCTIONS ******************************************************************/
VOID BiosMousePs2Interface(LPWORD Stack);

View file

@ -768,7 +768,6 @@ VOID WINAPI DosInt21h(LPWORD Stack)
{
setES(HIWORD(INDOS_POINTER));
setBX(LOWORD(INDOS_POINTER));
break;
}
@ -1650,7 +1649,7 @@ VOID WINAPI DosInt21h(LPWORD Stack)
if (getAL() == 0x00)
{
/* Lock region of file */
if (DosLockFile(getBX(), MAKELONG(getCX(), getDX()), MAKELONG(getSI(), getDI())))
if (DosLockFile(getBX(), MAKELONG(getDX(), getCX()), MAKELONG(getDI(), getSI())))
{
Stack[STACK_FLAGS] &= ~EMULATOR_FLAG_CF;
}
@ -1663,7 +1662,7 @@ VOID WINAPI DosInt21h(LPWORD Stack)
else if (getAL() == 0x01)
{
/* Unlock region of file */
if (DosUnlockFile(getBX(), MAKELONG(getCX(), getDX()), MAKELONG(getSI(), getDI())))
if (DosUnlockFile(getBX(), MAKELONG(getDX(), getCX()), MAKELONG(getDI(), getSI())))
{
Stack[STACK_FLAGS] &= ~EMULATOR_FLAG_CF;
}
@ -2015,6 +2014,12 @@ BOOLEAN DosKRNLInitialize(VOID)
RegisterDosInt32(0x29, DosFastConOut ); // DOS 2+ Fast Console Output
RegisterDosInt32(0x2F, DosInt2Fh );
/* Load the CON driver */
ConDrvInitialize();
/* Load the XMS driver (HIMEM) */
XmsInitialize();
/* Load the EMS driver */
if (!EmsDrvInitialize(EMS_TOTAL_PAGES))
{
@ -2022,12 +2027,6 @@ BOOLEAN DosKRNLInitialize(VOID)
"Try reducing the number of EMS pages.\n");
}
/* Load the XMS driver (HIMEM) */
XmsInitialize();
/* Load the CON driver */
ConDrvInitialize();
return TRUE;
}

View file

@ -29,17 +29,26 @@
/* PRIVATE VARIABLES **********************************************************/
#define MICKEYS_PER_CELL_HORIZ 8
#define MICKEYS_PER_CELL_VERT 16
// 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;
#define MICKEYS_PER_CELL_HORIZ 8
#define MICKEYS_PER_CELL_VERT 16
static BOOLEAN DriverEnabled = FALSE;
static MOUSE_DRIVER_STATE DriverState;
static DWORD OldIrqHandler;
static DWORD OldIntHandler;
/* PRIVATE FUNCTIONS **********************************************************/
extern VOID WINAPI BiosMouseIrq(LPWORD Stack);
static VOID PaintMouseCursor(VOID)
{
COORD Position = DriverState.Position;
@ -590,6 +599,13 @@ static VOID WINAPI DosMouseService(LPWORD Stack)
break;
}
/* Define Double-Speed Threshold */
case 0x13:
{
DPRINT1("INT 33h, AH=13h: Mouse double-speed threshold is UNSUPPORTED\n");
break;
}
/* Exchange Interrupt Subroutines, compatible MS MOUSE v3.0+ (see function 0x0C) */
case 0x14:
{
@ -772,11 +788,31 @@ static VOID WINAPI DosMouseService(LPWORD Stack)
break;
}
/* Set Mouse Sensitivity */
case 0x1A:
{
DPRINT1("INT 33h, AH=1Ah: Mouse sensitivity is UNSUPPORTED\n");
break;
}
/* Return Mouse Sensitivity */
case 0x1B:
{
DPRINT1("INT 33h, AH=1Bh: Mouse sensitivity is UNSUPPORTED\n");
/* Return default values */
setBX(50); // Horizontal speed
setCX(50); // Vertical speed
setDX(50); // Double speed threshold
break;
}
/* Disable Mouse Driver */
case 0x1F:
{
setES(0x0000);
setBX(0x0000);
/* INT 33h vector before the mouse driver was first installed */
setES(HIWORD(OldIntHandler));
setBX(LOWORD(OldIntHandler));
DosMouseDisable();
break;
@ -789,6 +825,75 @@ static VOID WINAPI DosMouseService(LPWORD Stack)
break;
}
/* Software Reset */
case 0x21:
{
/*
* See: http://www.htl-steyr.ac.at/~morg/pcinfo/hardware/interrupts/inte3sq8.htm
* for detailed information and differences with respect to subfunction 0x00:
* http://www.htl-steyr.ac.at/~morg/pcinfo/hardware/interrupts/inte3j74.htm
*/
SHORT i;
DriverState.ShowCount = 0;
DriverState.ButtonState = 0;
/* Initialize the default clipping range */
DriverState.MinX = 0;
DriverState.MaxX = MOUSE_MAX_HORIZ - 1;
DriverState.MinY = 0;
DriverState.MaxY = MOUSE_MAX_VERT - 1;
/* Initialize the counters */
DriverState.HorizCount = DriverState.VertCount = 0;
for (i = 0; i < NUM_MOUSE_BUTTONS; i++)
{
DriverState.PressCount[i] = DriverState.ReleaseCount[i] = 0;
}
/* Return mouse information */
setAX(0xFFFF); // Hardware & driver installed
setBX(NUM_MOUSE_BUTTONS);
break;
}
/* Get Software Version, Mouse Type, and IRQ Number, compatible MS MOUSE v6.26+ */
case 0x24:
{
setBX(MOUSE_VERSION); // Version Number
// FIXME: To be determined at runtime!
setCH(0x04); // PS/2 Type
setCL(0x00); // PS/2 Interrupt
break;
}
/* Return Pointer to Copyright String */
case 0x4D:
{
setES(HIWORD(COPYRIGHT_POINTER));
setDI(LOWORD(COPYRIGHT_POINTER));
break;
}
/* Get Version String (pointer) */
case 0x6D:
{
/*
* The format of the version "string" is:
* Offset Size Description
* 00h BYTE major version
* 01h BYTE minor version (BCD)
*/
setES(HIWORD(VERSION_POINTER));
setDI(LOWORD(VERSION_POINTER));
break;
}
default:
{
DPRINT1("BIOS Function INT 33h, AX = 0x%04X NOT IMPLEMENTED\n", getAX());
@ -883,6 +988,16 @@ BOOLEAN DosMouseInitialize(VOID)
/* 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);
/* Get the old mouse service interrupt handler */
OldIntHandler = ((PDWORD)BaseAddress)[DOS_MOUSE_INTERRUPT];
/* Initialize the interrupt handler */
RegisterDosInt32(DOS_MOUSE_INTERRUPT, DosMouseService);
@ -892,6 +1007,9 @@ BOOLEAN DosMouseInitialize(VOID)
VOID DosMouseCleanup(VOID)
{
/* Restore the old mouse service interrupt handler */
((PDWORD)BaseAddress)[DOS_MOUSE_INTERRUPT] = OldIntHandler;
if (DriverState.ShowCount > 0) EraseMouseCursor();
DosMouseDisable();
}

View file

@ -11,6 +11,11 @@
/* DEFINES ********************************************************************/
//
// We are ROS PS/2 Mouse Driver Version 6.26, compatible MS-MOUSE 6.26
//
#define MOUSE_VERSION MAKEWORD(0x26, 0x06)
#define DOS_MOUSE_INTERRUPT 0x33
#define MOUSE_IRQ_INT 0x74
#define MOUSE_MAX_HORIZ 640