Commit 770eb51e authored by Alexandre Julliard's avatar Alexandre Julliard

Moved most global data out of the LPDOSTASK structure.

Allocate DPMI real-mode segments globally at startup. Try to allocate DOS memory at address 0.
parent 0ff083ba
...@@ -11,38 +11,13 @@ ...@@ -11,38 +11,13 @@
#include "winbase.h" /* for LPSTARTUPINFO32A */ #include "winbase.h" /* for LPSTARTUPINFO32A */
#include "winnt.h" /* for PCONTEXT */ #include "winnt.h" /* for PCONTEXT */
typedef struct _DOSSYSTEM {
int id;
void *data;
struct _DOSSYSTEM *next;
} DOSSYSTEM;
struct _DOSEVENT; struct _DOSEVENT;
typedef struct _DOSTASK { typedef struct _DOSTASK {
LPVOID img; WORD psp_seg;
unsigned img_ofs; WORD dpmi_flag;
WORD psp_seg,load_seg;
WORD init_cs,init_ip,init_ss,init_sp;
WORD xms_seg;
WORD dpmi_seg,dpmi_sel,dpmi_flag;
char mm_name[128];
int mm_fd;
HANDLE hReadPipe,hXPipe,hConInput,hConOutput;
int read_pipe,write_pipe;
pid_t task;
int sig_sent,entered,idling;
struct _DOSEVENT *pending,*current;
DOSSYSTEM *sys;
} DOSTASK, *LPDOSTASK; } DOSTASK, *LPDOSTASK;
typedef struct _DOSEVENT {
int irq,priority;
void (*relay)(LPDOSTASK,CONTEXT86*,void*);
void *data;
struct _DOSEVENT *next;
} DOSEVENT, *LPDOSEVENT;
#define DOS_PRIORITY_REALTIME 0 /* IRQ0 */ #define DOS_PRIORITY_REALTIME 0 /* IRQ0 */
#define DOS_PRIORITY_KEYBOARD 1 /* IRQ1 */ #define DOS_PRIORITY_KEYBOARD 1 /* IRQ1 */
#define DOS_PRIORITY_VGA 2 /* IRQ9 */ #define DOS_PRIORITY_VGA 2 /* IRQ9 */
...@@ -50,26 +25,19 @@ typedef struct _DOSEVENT { ...@@ -50,26 +25,19 @@ typedef struct _DOSEVENT {
#define DOS_PRIORITY_SERIAL 10 /* IRQ4 */ #define DOS_PRIORITY_SERIAL 10 /* IRQ4 */
#if defined(linux) && defined(__i386__) #if defined(linux) && defined(__i386__)
#define MZ_SUPPORTED #define MZ_SUPPORTED
extern BOOL MZ_InitTask( LPDOSTASK lpDosTask );
extern void MZ_KillTask( LPDOSTASK lpDosTask );
extern LPDOSTASK MZ_AllocDPMITask( void );
#endif /* linux-i386 */ #endif /* linux-i386 */
#define V86_FLAG 0x00020000 #define V86_FLAG 0x00020000
extern BOOL MZ_LoadImage( HMODULE module, HANDLE hFile, LPCSTR filename ); extern BOOL MZ_LoadImage( HMODULE module, HANDLE hFile, LPCSTR filename );
extern LPDOSTASK MZ_Current( void ); extern LPDOSTASK MZ_Current( void );
extern LPDOSTASK MZ_AllocDPMITask( void );
extern int DOSVM_Enter( CONTEXT86 *context ); extern int DOSVM_Enter( CONTEXT86 *context );
extern void DOSVM_Wait( int read_pipe, HANDLE hObject ); extern void DOSVM_Wait( int read_pipe, HANDLE hObject );
extern void DOSVM_QueueEvent( int irq, int priority, void (*relay)(LPDOSTASK,CONTEXT86*,void*), void *data ); extern void DOSVM_QueueEvent( int irq, int priority, void (*relay)(CONTEXT86*,void*), void *data );
extern void DOSVM_PIC_ioport_out( WORD port, BYTE val ); extern void DOSVM_PIC_ioport_out( WORD port, BYTE val );
extern void DOSVM_SetTimer( unsigned ticks ); extern void DOSVM_SetTimer( unsigned ticks );
extern unsigned DOSVM_GetTimer( void ); extern unsigned DOSVM_GetTimer( void );
extern void DOSVM_SetSystemData( int id, void *data );
extern void* DOSVM_GetSystemData( int id );
#endif /* __WINE_DOSEXE_H */ #endif /* __WINE_DOSEXE_H */
...@@ -60,6 +60,8 @@ extern ldt_copy_entry ldt_copy[LDT_SIZE]; ...@@ -60,6 +60,8 @@ extern ldt_copy_entry ldt_copy[LDT_SIZE];
#define PTR_SEG_OFF_TO_LIN(seg,off) \ #define PTR_SEG_OFF_TO_LIN(seg,off) \
((void*)(GET_SEL_BASE(seg) + (unsigned int)(off))) ((void*)(GET_SEL_BASE(seg) + (unsigned int)(off)))
#define PTR_REAL_TO_LIN(seg,off) \
((void*)(((unsigned int)(seg) << 4) + LOWORD(off)))
#define PTR_SEG_TO_LIN(ptr) \ #define PTR_SEG_TO_LIN(ptr) \
PTR_SEG_OFF_TO_LIN(SELECTOROF(ptr),OFFSETOF(ptr)) PTR_SEG_OFF_TO_LIN(SELECTOROF(ptr),OFFSETOF(ptr))
#define PTR_SEG_OFF_TO_SEGPTR(seg,off) \ #define PTR_SEG_OFF_TO_SEGPTR(seg,off) \
......
...@@ -128,8 +128,11 @@ extern BYTE * DOSMEM_BiosSys(); ...@@ -128,8 +128,11 @@ extern BYTE * DOSMEM_BiosSys();
extern DWORD DOSMEM_CollateTable; extern DWORD DOSMEM_CollateTable;
extern DWORD DOSMEM_ErrorCall; /* various real-mode code stubs */
extern DWORD DOSMEM_ErrorBuffer; extern WORD DOSMEM_wrap_seg;
extern WORD DOSMEM_xms_seg;
extern WORD DOSMEM_dpmi_seg;
extern WORD DOSMEM_dpmi_sel;
extern DWORD DOS_LOLSeg; extern DWORD DOS_LOLSeg;
extern struct _DOS_LISTOFLISTS * DOSMEM_LOL(); extern struct _DOS_LISTOFLISTS * DOSMEM_LOL();
...@@ -249,7 +252,7 @@ extern void ASPI_DOS_HandleInt(CONTEXT86 *context); ...@@ -249,7 +252,7 @@ extern void ASPI_DOS_HandleInt(CONTEXT86 *context);
* a *32-bit* general register as third parameter, e.g. * a *32-bit* general register as third parameter, e.g.
* CTX_SEG_OFF_TO_LIN( context, DS_reg(context), EDX_reg(context) ) * CTX_SEG_OFF_TO_LIN( context, DS_reg(context), EDX_reg(context) )
* This will generate a linear pointer in all three cases: * This will generate a linear pointer in all three cases:
* Real-Mode: Seg*16 + LOWORD(Offset) + V86BASE * Real-Mode: Seg*16 + LOWORD(Offset)
* 16-bit: convert (Seg, LOWORD(Offset)) to linear * 16-bit: convert (Seg, LOWORD(Offset)) to linear
* 32-bit: use Offset as linear address (DeviceIoControl!) * 32-bit: use Offset as linear address (DeviceIoControl!)
* *
...@@ -258,8 +261,8 @@ extern void ASPI_DOS_HandleInt(CONTEXT86 *context); ...@@ -258,8 +261,8 @@ extern void ASPI_DOS_HandleInt(CONTEXT86 *context);
* (0 counts also as 32-bit segment). * (0 counts also as 32-bit segment).
*/ */
#define CTX_SEG_OFF_TO_LIN(context,seg,off) \ #define CTX_SEG_OFF_TO_LIN(context,seg,off) \
(ISV86(context) ? (void*)(V86BASE(context)+((seg)<<4)+(off&0xffff)) : \ (ISV86(context) ? PTR_REAL_TO_LIN((seg),(off)) : \
(!seg || IS_SELECTOR_SYSTEM(seg))? (void *)off : PTR_SEG_OFF_TO_LIN(seg,off&0xffff)) (!seg || IS_SELECTOR_SYSTEM(seg))? (void *)(off) : PTR_SEG_OFF_TO_LIN((seg),LOWORD(off)))
#define INT_BARF(context,num) \ #define INT_BARF(context,num) \
ERR( "int%x: unknown/not implemented parameters:\n" \ ERR( "int%x: unknown/not implemented parameters:\n" \
......
...@@ -730,7 +730,6 @@ typedef HANDLE *PHANDLE; ...@@ -730,7 +730,6 @@ typedef HANDLE *PHANDLE;
#define RESET_ZFLAG(context) (EFL_reg(context) &= ~0x0040) #define RESET_ZFLAG(context) (EFL_reg(context) &= ~0x0040)
#define ISV86(context) (EFL_reg(context) & 0x00020000) #define ISV86(context) (EFL_reg(context) & 0x00020000)
#define V86BASE(context) DOSMEM_MemoryBase()
/* Macros to retrieve the current context */ /* Macros to retrieve the current context */
......
...@@ -29,13 +29,13 @@ ...@@ -29,13 +29,13 @@
#include "winsock.h" #include "winsock.h"
#include "syslevel.h" #include "syslevel.h"
#include "debugtools.h" #include "debugtools.h"
#include "dosexe.h"
#include "services.h" #include "services.h"
#include "server.h" #include "server.h"
DEFAULT_DEBUG_CHANNEL(task)
DECLARE_DEBUG_CHANNEL(relay) DEFAULT_DEBUG_CHANNEL(task);
DECLARE_DEBUG_CHANNEL(toolhelp) DECLARE_DEBUG_CHANNEL(relay);
DECLARE_DEBUG_CHANNEL(toolhelp);
/* Min. number of thunks allocated when creating a new segment */ /* Min. number of thunks allocated when creating a new segment */
#define MIN_THUNKS 32 #define MIN_THUNKS 32
...@@ -243,7 +243,6 @@ BOOL TASK_Create( NE_MODULE *pModule, UINT16 cmdShow, TEB *teb, LPCSTR cmdline, ...@@ -243,7 +243,6 @@ BOOL TASK_Create( NE_MODULE *pModule, UINT16 cmdShow, TEB *teb, LPCSTR cmdline,
/* NOTE: for 16-bit tasks, the instance handles are updated later on /* NOTE: for 16-bit tasks, the instance handles are updated later on
in NE_InitProcess */ in NE_InitProcess */
} }
if (MZ_Current() && MZ_Current()->load_seg) pTask->flags |= TDBF_WINOLDAP;
pTask->version = pModule->expected_version; pTask->version = pModule->expected_version;
pTask->hModule = pModule->self; pTask->hModule = pModule->self;
......
...@@ -29,7 +29,7 @@ inline static void add_stack( CONTEXT86 *context, int offset ) ...@@ -29,7 +29,7 @@ inline static void add_stack( CONTEXT86 *context, int offset )
inline static void *make_ptr( CONTEXT86 *context, DWORD seg, DWORD off, int long_addr ) inline static void *make_ptr( CONTEXT86 *context, DWORD seg, DWORD off, int long_addr )
{ {
if (ISV86(context)) return DOSMEM_MemoryBase() + (seg << 4) + LOWORD(off); if (ISV86(context)) return PTR_REAL_TO_LIN( seg, off );
if (IS_SELECTOR_SYSTEM(seg)) return (void *)off; if (IS_SELECTOR_SYSTEM(seg)) return (void *)off;
if (!long_addr) off = LOWORD(off); if (!long_addr) off = LOWORD(off);
return PTR_SEG_OFF_TO_LIN( seg, off ); return PTR_SEG_OFF_TO_LIN( seg, off );
...@@ -38,7 +38,7 @@ inline static void *make_ptr( CONTEXT86 *context, DWORD seg, DWORD off, int long ...@@ -38,7 +38,7 @@ inline static void *make_ptr( CONTEXT86 *context, DWORD seg, DWORD off, int long
inline static void *get_stack( CONTEXT86 *context ) inline static void *get_stack( CONTEXT86 *context )
{ {
if (ISV86(context)) if (ISV86(context))
return DOSMEM_MemoryBase() + (context->SegSs << 4) + LOWORD(context->Esp); return PTR_REAL_TO_LIN( context->SegSs, context->Esp );
if (IS_SELECTOR_SYSTEM(context->SegSs)) if (IS_SELECTOR_SYSTEM(context->SegSs))
return (void *)context->Esp; return (void *)context->Esp;
if (IS_SELECTOR_32BIT(context->SegSs)) if (IS_SELECTOR_32BIT(context->SegSs))
......
...@@ -47,8 +47,9 @@ typedef struct { ...@@ -47,8 +47,9 @@ typedef struct {
#define CON_BUFFER 128 #define CON_BUFFER 128
#define SYSTEM_STRATEGY_NUL 0x0100 enum strategy { SYSTEM_STRATEGY_NUL, SYSTEM_STRATEGY_CON, NB_SYSTEM_STRATEGIES };
#define SYSTEM_STRATEGY_CON 0x0101
static void *strategy_data[NB_SYSTEM_STRATEGIES];
#define NONEXT ((DWORD)-1) #define NONEXT ((DWORD)-1)
...@@ -150,20 +151,19 @@ static void do_lret(CONTEXT86*ctx) ...@@ -150,20 +151,19 @@ static void do_lret(CONTEXT86*ctx)
static void do_strategy(CONTEXT86*ctx, int id, int extra) static void do_strategy(CONTEXT86*ctx, int id, int extra)
{ {
REQUEST_HEADER *hdr = CTX_SEG_OFF_TO_LIN(ctx, ES_reg(ctx), EBX_reg(ctx)); REQUEST_HEADER *hdr = CTX_SEG_OFF_TO_LIN(ctx, ES_reg(ctx), EBX_reg(ctx));
void **hdr_ptr = DOSVM_GetSystemData(id); void **hdr_ptr = strategy_data[id];
if (!hdr_ptr) { if (!hdr_ptr) {
hdr_ptr = calloc(1,sizeof(void *)+extra); hdr_ptr = calloc(1,sizeof(void *)+extra);
DOSVM_SetSystemData(id, hdr_ptr); strategy_data[id] = hdr_ptr;
} }
*hdr_ptr = hdr; *hdr_ptr = hdr;
do_lret(ctx); do_lret(ctx);
} }
static REQUEST_HEADER * get_hdr(int id, void**extra) static REQUEST_HEADER * get_hdr(int id, void**extra)
{ {
void **hdr_ptr = DOSVM_GetSystemData(id); void **hdr_ptr = strategy_data[id];
if (extra) if (extra)
*extra = hdr_ptr ? (void*)(hdr_ptr+1) : (void *)NULL; *extra = hdr_ptr ? (void*)(hdr_ptr+1) : (void *)NULL;
return hdr_ptr ? *hdr_ptr : (void *)NULL; return hdr_ptr ? *hdr_ptr : (void *)NULL;
...@@ -209,7 +209,6 @@ static void WINAPI con_interrupt(CONTEXT86*ctx) ...@@ -209,7 +209,6 @@ static void WINAPI con_interrupt(CONTEXT86*ctx)
BYTE *curbuffer = (lol->offs_unread_CON) ? BYTE *curbuffer = (lol->offs_unread_CON) ?
(((BYTE*)dataseg) + lol->offs_unread_CON) : (BYTE*)NULL; (((BYTE*)dataseg) + lol->offs_unread_CON) : (BYTE*)NULL;
DOS_DEVICE_HEADER *con = dataseg->dev; DOS_DEVICE_HEADER *con = dataseg->dev;
LPDOSTASK lpDosTask = MZ_Current();
switch (hdr->command) { switch (hdr->command) {
case CMD_INPUT: case CMD_INPUT:
...@@ -301,7 +300,7 @@ static void WINAPI con_interrupt(CONTEXT86*ctx) ...@@ -301,7 +300,7 @@ static void WINAPI con_interrupt(CONTEXT86*ctx)
/* a character */ /* a character */
if ((len+1)<CON_BUFFER) { if ((len+1)<CON_BUFFER) {
linebuffer[len] = LOBYTE(data); linebuffer[len] = LOBYTE(data);
WriteFile(lpDosTask->hConOutput, &linebuffer[len++], 1, NULL, NULL); WriteFile(GetStdHandle(STD_OUTPUT_HANDLE), &linebuffer[len++], 1, NULL, NULL);
} }
/* else beep, but I don't like noise */ /* else beep, but I don't like noise */
} }
...@@ -309,7 +308,7 @@ static void WINAPI con_interrupt(CONTEXT86*ctx) ...@@ -309,7 +308,7 @@ static void WINAPI con_interrupt(CONTEXT86*ctx)
case '\b': case '\b':
if (len>0) { if (len>0) {
len--; len--;
WriteFile(lpDosTask->hConOutput, "\b \b", 3, NULL, NULL); WriteFile(GetStdHandle(STD_OUTPUT_HANDLE), "\b \b", 3, NULL, NULL);
} }
break; break;
} }
...@@ -377,7 +376,7 @@ static void WINAPI con_interrupt(CONTEXT86*ctx) ...@@ -377,7 +376,7 @@ static void WINAPI con_interrupt(CONTEXT86*ctx)
SELECTOROF(io->buffer), SELECTOROF(io->buffer),
(DWORD)OFFSETOF(io->buffer)); (DWORD)OFFSETOF(io->buffer));
DWORD result = 0; DWORD result = 0;
WriteFile(lpDosTask->hConOutput, buffer, io->count, &result, NULL); WriteFile(GetStdHandle(STD_OUTPUT_HANDLE), buffer, io->count, &result, NULL);
io->count = result; io->count = result;
hdr->status = STAT_DONE; hdr->status = STAT_DONE;
} }
......
...@@ -15,9 +15,11 @@ DEFAULT_DEBUG_CHANNEL(int); ...@@ -15,9 +15,11 @@ DEFAULT_DEBUG_CHANNEL(int);
#define QUEUELEN 31 #define QUEUELEN 31
typedef struct { static struct
{
BYTE queuelen,queue[QUEUELEN],ascii[QUEUELEN]; BYTE queuelen,queue[QUEUELEN],ascii[QUEUELEN];
} KBDSYSTEM; } kbdinfo;
/********************************************************************** /**********************************************************************
* INT_Int09Handler * INT_Int09Handler
...@@ -58,48 +60,35 @@ void WINAPI INT_Int09Handler( CONTEXT86 *context ) ...@@ -58,48 +60,35 @@ void WINAPI INT_Int09Handler( CONTEXT86 *context )
DOSVM_PIC_ioport_out(0x20, 0x20); /* send EOI */ DOSVM_PIC_ioport_out(0x20, 0x20); /* send EOI */
} }
static void KbdRelay( LPDOSTASK lpDosTask, CONTEXT86 *context, void *data ) static void KbdRelay( CONTEXT86 *context, void *data )
{ {
KBDSYSTEM *sys = (KBDSYSTEM *)DOSVM_GetSystemData(0x09); if (kbdinfo.queuelen) {
if (sys && sys->queuelen) {
/* cleanup operation, called from DOSVM_PIC_ioport_out: /* cleanup operation, called from DOSVM_PIC_ioport_out:
* we'll remove current scancode from keyboard buffer here, * we'll remove current scancode from keyboard buffer here,
* rather than in ReadScan, because some DOS apps depend on * rather than in ReadScan, because some DOS apps depend on
* the scancode being available for reading multiple times... */ * the scancode being available for reading multiple times... */
if (--sys->queuelen) { if (--kbdinfo.queuelen) {
memmove(sys->queue,sys->queue+1,sys->queuelen); memmove(kbdinfo.queue,kbdinfo.queue+1,kbdinfo.queuelen);
memmove(sys->ascii,sys->ascii+1,sys->queuelen); memmove(kbdinfo.ascii,kbdinfo.ascii+1,kbdinfo.queuelen);
} }
} }
} }
void WINAPI INT_Int09SendScan( BYTE scan, BYTE ascii ) void WINAPI INT_Int09SendScan( BYTE scan, BYTE ascii )
{ {
KBDSYSTEM *sys = (KBDSYSTEM *)DOSVM_GetSystemData(0x09); if (kbdinfo.queuelen == QUEUELEN) {
if (!sys) {
sys = calloc(1,sizeof(KBDSYSTEM));
DOSVM_SetSystemData(0x09,sys);
}
if (sys->queuelen == QUEUELEN) {
ERR("keyboard queue overflow\n"); ERR("keyboard queue overflow\n");
return; return;
} }
/* add scancode to queue */ /* add scancode to queue */
sys->queue[sys->queuelen] = scan; kbdinfo.queue[kbdinfo.queuelen] = scan;
sys->ascii[sys->queuelen++] = ascii; kbdinfo.ascii[kbdinfo.queuelen++] = ascii;
/* tell app to read it by triggering IRQ 1 (int 09) */ /* tell app to read it by triggering IRQ 1 (int 09) */
DOSVM_QueueEvent(1,DOS_PRIORITY_KEYBOARD,KbdRelay,NULL); DOSVM_QueueEvent(1,DOS_PRIORITY_KEYBOARD,KbdRelay,NULL);
} }
BYTE WINAPI INT_Int09ReadScan( BYTE*ascii ) BYTE WINAPI INT_Int09ReadScan( BYTE*ascii )
{ {
KBDSYSTEM *sys = (KBDSYSTEM *)DOSVM_GetSystemData(0x09); if (ascii) *ascii = kbdinfo.ascii[0];
if (sys) { return kbdinfo.queue[0];
if (ascii) *ascii = sys->ascii[0];
return sys->queue[0];
} else {
if (ascii) *ascii = 0;
return 0;
}
} }
...@@ -115,9 +115,7 @@ void WINAPI INT_Int2fHandler( CONTEXT86 *context ) ...@@ -115,9 +115,7 @@ void WINAPI INT_Int2fHandler( CONTEXT86 *context )
break; break;
case 0x10: /* XMS v2+ get driver address */ case 0x10: /* XMS v2+ get driver address */
{ {
LPDOSTASK lpDosTask = MZ_Current(); ES_reg(context) = DOSMEM_xms_seg;
ES_reg(context) = lpDosTask ? lpDosTask->xms_seg : 0;
BX_reg(context) = 0; BX_reg(context) = 0;
break; break;
} }
...@@ -349,15 +347,13 @@ static void do_int2f_16( CONTEXT86 *context ) ...@@ -349,15 +347,13 @@ static void do_int2f_16( CONTEXT86 *context )
#endif #endif
{ {
SYSTEM_INFO si; SYSTEM_INFO si;
LPDOSTASK lpDosTask = MZ_Current();
GetSystemInfo(&si); GetSystemInfo(&si);
AX_reg(context) = 0x0000; /* DPMI Installed */ AX_reg(context) = 0x0000; /* DPMI Installed */
BX_reg(context) = 0x0001; /* 32bits available */ BX_reg(context) = 0x0001; /* 32bits available */
CL_reg(context) = si.wProcessorLevel; CL_reg(context) = si.wProcessorLevel;
DX_reg(context) = 0x005a; /* DPMI major/minor 0.90 */ DX_reg(context) = 0x005a; /* DPMI major/minor 0.90 */
SI_reg(context) = 0; /* # of para. of DOS extended private data */ SI_reg(context) = 0; /* # of para. of DOS extended private data */
ES_reg(context) = lpDosTask ? lpDosTask->dpmi_seg : 0; ES_reg(context) = DOSMEM_dpmi_seg;
DI_reg(context) = 0; /* ES:DI is DPMI switch entry point */ DI_reg(context) = 0; /* ES:DI is DPMI switch entry point */
break; break;
} }
...@@ -402,9 +398,8 @@ static void MSCDEX_Dump(char* pfx, BYTE* req, int dorealmode) ...@@ -402,9 +398,8 @@ static void MSCDEX_Dump(char* pfx, BYTE* req, int dorealmode)
case 3: case 3:
case 12: case 12:
ptr += sprintf(ptr, "\n\t\t\t\tIO_struct => "); ptr += sprintf(ptr, "\n\t\t\t\tIO_struct => ");
ios = (dorealmode) ? ios = (dorealmode) ? PTR_REAL_TO_LIN( PTR_AT(req, 16, WORD), PTR_AT(req, 14, WORD)) :
DOSMEM_MapRealToLinear(MAKELONG(PTR_AT(req, 14, WORD), PTR_AT(req, 16, WORD))) : PTR_SEG_OFF_TO_LIN(PTR_AT(req, 16, WORD), PTR_AT(req, 14, WORD));
PTR_SEG_OFF_TO_LIN(PTR_AT(req, 16, WORD), PTR_AT(req, 14, WORD));
for (i = 0; i < PTR_AT(req, 18, WORD); i++) { for (i = 0; i < PTR_AT(req, 18, WORD); i++) {
ptr += sprintf(ptr, "%02x ", ios[i]); ptr += sprintf(ptr, "%02x ", ios[i]);
...@@ -476,9 +471,7 @@ static void MSCDEX_Handler(CONTEXT86* context) ...@@ -476,9 +471,7 @@ static void MSCDEX_Handler(CONTEXT86* context)
BYTE Error = 255; /* No Error */ BYTE Error = 255; /* No Error */
int dorealmode = ISV86(context); int dorealmode = ISV86(context);
driver_request = (dorealmode) ? driver_request = CTX_SEG_OFF_TO_LIN(context, context->SegEs, context->Ebx);
DOSMEM_MapRealToLinear(MAKELONG(BX_reg(context), ES_reg(context))) :
PTR_SEG_OFF_TO_LIN(ES_reg(context), BX_reg(context));
if (!driver_request) { if (!driver_request) {
/* FIXME - to be deleted ?? */ /* FIXME - to be deleted ?? */
...@@ -517,7 +510,7 @@ static void MSCDEX_Handler(CONTEXT86* context) ...@@ -517,7 +510,7 @@ static void MSCDEX_Handler(CONTEXT86* context)
switch (driver_request[2]) { switch (driver_request[2]) {
case 3: case 3:
io_stru = (dorealmode) ? io_stru = (dorealmode) ?
DOSMEM_MapRealToLinear(MAKELONG(PTR_AT(driver_request, 14, WORD), PTR_AT(driver_request, 16, WORD))) : PTR_REAL_TO_LIN( PTR_AT(driver_request, 16, WORD), PTR_AT(driver_request, 14, WORD) ) :
PTR_SEG_OFF_TO_LIN(PTR_AT(driver_request, 16, WORD), PTR_AT(driver_request, 14, WORD)); PTR_SEG_OFF_TO_LIN(PTR_AT(driver_request, 16, WORD), PTR_AT(driver_request, 14, WORD));
TRACE(" --> IOCTL INPUT <%d>\n", io_stru[0]); TRACE(" --> IOCTL INPUT <%d>\n", io_stru[0]);
...@@ -682,7 +675,7 @@ static void MSCDEX_Handler(CONTEXT86* context) ...@@ -682,7 +675,7 @@ static void MSCDEX_Handler(CONTEXT86* context)
case 12: case 12:
io_stru = (dorealmode) ? io_stru = (dorealmode) ?
DOSMEM_MapRealToLinear(MAKELONG(PTR_AT(driver_request, 14, WORD), PTR_AT(driver_request, 16, WORD))) : PTR_REAL_TO_LIN( PTR_AT(driver_request, 16, WORD), PTR_AT(driver_request, 14, WORD)) :
PTR_SEG_OFF_TO_LIN(PTR_AT(driver_request, 16, WORD), PTR_AT(driver_request, 14, WORD)); PTR_SEG_OFF_TO_LIN(PTR_AT(driver_request, 16, WORD), PTR_AT(driver_request, 14, WORD));
TRACE(" --> IOCTL OUTPUT <%d>\n", io_stru[0]); TRACE(" --> IOCTL OUTPUT <%d>\n", io_stru[0]);
......
...@@ -13,11 +13,12 @@ ...@@ -13,11 +13,12 @@
DEFAULT_DEBUG_CHANNEL(int) DEFAULT_DEBUG_CHANNEL(int)
typedef struct { static struct
{
DWORD x, y, but; DWORD x, y, but;
FARPROC16 callback; FARPROC16 callback;
WORD callmask; WORD callmask;
} MOUSESYSTEM; } mouse_info;
/********************************************************************** /**********************************************************************
* INT_Int33Handler * INT_Int33Handler
...@@ -26,15 +27,12 @@ typedef struct { ...@@ -26,15 +27,12 @@ typedef struct {
*/ */
void WINAPI INT_Int33Handler( CONTEXT86 *context ) void WINAPI INT_Int33Handler( CONTEXT86 *context )
{ {
MOUSESYSTEM *sys = (MOUSESYSTEM *)DOSVM_GetSystemData(0x33);
switch (AX_reg(context)) { switch (AX_reg(context)) {
case 0x00: case 0x00:
TRACE("Reset mouse driver and request status\n"); TRACE("Reset mouse driver and request status\n");
AX_reg(context) = 0xFFFF; /* installed */ AX_reg(context) = 0xFFFF; /* installed */
BX_reg(context) = 3; /* # of buttons */ BX_reg(context) = 3; /* # of buttons */
sys = calloc(1,sizeof(MOUSESYSTEM)); memset( &mouse_info, 0, sizeof(mouse_info) );
DOSVM_SetSystemData(0x33, sys);
break; break;
case 0x01: case 0x01:
FIXME("Show mouse cursor\n"); FIXME("Show mouse cursor\n");
...@@ -44,9 +42,9 @@ void WINAPI INT_Int33Handler( CONTEXT86 *context ) ...@@ -44,9 +42,9 @@ void WINAPI INT_Int33Handler( CONTEXT86 *context )
break; break;
case 0x03: case 0x03:
TRACE("Return mouse position and button status\n"); TRACE("Return mouse position and button status\n");
BX_reg(context) = sys->but; BX_reg(context) = mouse_info.but;
CX_reg(context) = sys->x; CX_reg(context) = mouse_info.x;
DX_reg(context) = sys->y; DX_reg(context) = mouse_info.y;
break; break;
case 0x04: case 0x04:
FIXME("Position mouse cursor\n"); FIXME("Position mouse cursor\n");
...@@ -65,8 +63,8 @@ void WINAPI INT_Int33Handler( CONTEXT86 *context ) ...@@ -65,8 +63,8 @@ void WINAPI INT_Int33Handler( CONTEXT86 *context )
break; break;
case 0x0C: case 0x0C:
TRACE("Define mouse interrupt subroutine\n"); TRACE("Define mouse interrupt subroutine\n");
sys->callmask = CX_reg(context); mouse_info.callmask = CX_reg(context);
sys->callback = (FARPROC16)PTR_SEG_OFF_TO_SEGPTR(ES_reg(context), DX_reg(context)); mouse_info.callback = (FARPROC16)PTR_SEG_OFF_TO_SEGPTR(ES_reg(context), DX_reg(context));
break; break;
case 0x10: case 0x10:
FIXME("Define screen region for update\n"); FIXME("Define screen region for update\n");
...@@ -81,7 +79,7 @@ typedef struct { ...@@ -81,7 +79,7 @@ typedef struct {
WORD mask,but,x,y,mx,my; WORD mask,but,x,y,mx,my;
} MCALLDATA; } MCALLDATA;
static void MouseRelay(LPDOSTASK lpDosTask,CONTEXT86 *context,void *mdata) static void MouseRelay(CONTEXT86 *context,void *mdata)
{ {
MCALLDATA *data = (MCALLDATA *)mdata; MCALLDATA *data = (MCALLDATA *)mdata;
CONTEXT86 ctx = *context; CONTEXT86 ctx = *context;
...@@ -100,58 +98,56 @@ static void MouseRelay(LPDOSTASK lpDosTask,CONTEXT86 *context,void *mdata) ...@@ -100,58 +98,56 @@ static void MouseRelay(LPDOSTASK lpDosTask,CONTEXT86 *context,void *mdata)
void WINAPI INT_Int33Message(UINT message,WPARAM wParam,LPARAM lParam) void WINAPI INT_Int33Message(UINT message,WPARAM wParam,LPARAM lParam)
{ {
MOUSESYSTEM *sys = (MOUSESYSTEM *)DOSVM_GetSystemData(0x33);
WORD mask = 0; WORD mask = 0;
unsigned Height, Width, SX=1, SY=1; unsigned Height, Width, SX=1, SY=1;
if (!sys) return;
if (!VGA_GetMode(&Height,&Width,NULL)) { if (!VGA_GetMode(&Height,&Width,NULL)) {
/* may need to do some coordinate scaling */ /* may need to do some coordinate scaling */
SX = 640/Width; SX = 640/Width;
if (!SX) SX=1; if (!SX) SX=1;
} }
sys->x = LOWORD(lParam) * SX; mouse_info.x = LOWORD(lParam) * SX;
sys->y = HIWORD(lParam) * SY; mouse_info.y = HIWORD(lParam) * SY;
switch (message) { switch (message) {
case WM_MOUSEMOVE: case WM_MOUSEMOVE:
mask |= 0x01; mask |= 0x01;
break; break;
case WM_LBUTTONDOWN: case WM_LBUTTONDOWN:
case WM_LBUTTONDBLCLK: case WM_LBUTTONDBLCLK:
sys->but |= 0x01; mouse_info.but |= 0x01;
mask |= 0x02; mask |= 0x02;
break; break;
case WM_LBUTTONUP: case WM_LBUTTONUP:
sys->but &= ~0x01; mouse_info.but &= ~0x01;
mask |= 0x04; mask |= 0x04;
break; break;
case WM_RBUTTONDOWN: case WM_RBUTTONDOWN:
case WM_RBUTTONDBLCLK: case WM_RBUTTONDBLCLK:
sys->but |= 0x02; mouse_info.but |= 0x02;
mask |= 0x08; mask |= 0x08;
break; break;
case WM_RBUTTONUP: case WM_RBUTTONUP:
sys->but &= ~0x02; mouse_info.but &= ~0x02;
mask |= 0x10; mask |= 0x10;
break; break;
case WM_MBUTTONDOWN: case WM_MBUTTONDOWN:
case WM_MBUTTONDBLCLK: case WM_MBUTTONDBLCLK:
sys->but |= 0x04; mouse_info.but |= 0x04;
mask |= 0x20; mask |= 0x20;
break; break;
case WM_MBUTTONUP: case WM_MBUTTONUP:
sys->but &= ~0x04; mouse_info.but &= ~0x04;
mask |= 0x40; mask |= 0x40;
break; break;
} }
if ((mask & sys->callmask) && sys->callback) { if ((mask & mouse_info.callmask) && mouse_info.callback) {
MCALLDATA *data = calloc(1,sizeof(MCALLDATA)); MCALLDATA *data = calloc(1,sizeof(MCALLDATA));
data->proc = sys->callback; data->proc = mouse_info.callback;
data->mask = mask & sys->callmask; data->mask = mask & mouse_info.callmask;
data->but = sys->but; data->but = mouse_info.but;
data->x = sys->x; data->x = mouse_info.x;
data->y = sys->y; data->y = mouse_info.y;
DOSVM_QueueEvent(-1, DOS_PRIORITY_MOUSE, MouseRelay, data); DOSVM_QueueEvent(-1, DOS_PRIORITY_MOUSE, MouseRelay, data);
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment