[RESENT 4/4] winedos: implement true CDROM DOS device driver
Petr Tesarik
hat at tesarici.cz
Tue Apr 11 03:37:09 CDT 2006
Hi,
while I was trying to make Kindler Literaturlexikon work in Wine, I
found out that this program uses a DOS program to access the CDROM,
and that it requires a real working MSCDEX device driver (and not only
that, the driver has to reside in a different segment than the DOS
core).
To make the patches as small as possible, I've split the patch into
several parts.
This part adds the actual device driver: the routines and the
initialization code. I also had to patch module initialization, since
device drivers can not be initialized later, i.e. when an MZ program
is loaded (in particular, DPMI_AllocInternalRMCB() fails, so we cannot
set up the thunks correctly).
ChangeLog:
* dlls/winedos/int2f.c:
winedos: add CDROM driver strategy and interrupt routines
* dlls/winedos/module.c, dlls/winedos/dosexe.h:
winedos: initialize MSCDEX after other device drivers
-------------- next part --------------
Index: dosexe.h
===================================================================
RCS file: /home/wine/wine/dlls/winedos/dosexe.h,v
retrieving revision 1.38
diff -u -r1.38 dosexe.h
--- dosexe.h 27 Mar 2006 11:30:41 -0000 1.38
+++ dosexe.h 10 Apr 2006 13:52:12 -0000
@@ -374,6 +475,7 @@
/* int2f.c */
extern void WINAPI DOSVM_Int2fHandler(CONTEXT86*);
+extern void MSCDEX_InstallCDROM(void);
/* int31.c */
extern void WINAPI DOSVM_Int31Handler(CONTEXT86*);
Index: int2f.c
===================================================================
RCS file: /home/wine/wine/dlls/winedos/int2f.c,v
retrieving revision 1.8
diff -u -r1.8 int2f.c
--- int2f.c 28 Nov 2005 20:10:42 -0000 1.8
+++ int2f.c 10 Apr 2006 13:52:13 -0000
@@ -946,3 +1024,58 @@
break;
}
}
+
+/* prototypes */
+static void WINAPI cdrom_strategy(CONTEXT86*ctx);
+static void WINAPI cdrom_interrupt(CONTEXT86*ctx);
+
+/* device info */
+static const WINEDEV cdromdev =
+{
+ "WINE_CD_",
+ ATTR_CHAR|ATTR_REMOVABLE|ATTR_IOCTL,
+ cdrom_strategy, cdrom_interrupt
+};
+
+static REQUEST_HEADER *cdrom_driver_request;
+
+/* Return to caller */
+static void do_lret(CONTEXT86*ctx)
+{
+ WORD *stack = CTX_SEG_OFF_TO_LIN(ctx, ctx->SegSs, ctx->Esp);
+
+ ctx->Eip = *(stack++);
+ ctx->SegCs = *(stack++);
+ ctx->Esp += 2*sizeof(WORD);
+}
+
+static void WINAPI cdrom_strategy(CONTEXT86*ctx)
+{
+ cdrom_driver_request = CTX_SEG_OFF_TO_LIN(ctx, ctx->SegEs, ctx->Ebx);
+ do_lret( ctx );
+}
+
+static void WINAPI cdrom_interrupt(CONTEXT86*ctx)
+{
+ if (cdrom_driver_request->unit > CDROM_GetHeap()->hdr.units)
+ cdrom_driver_request->status = STAT_ERROR | 1; /* unknown unit */
+ else
+ MSCDEX_Request((BYTE*)cdrom_driver_request, ISV86(ctx));
+
+ do_lret( ctx );
+}
+
+/**********************************************************************
+ * MSCDEX_InstallCDROM [internal]
+ *
+ * Install the CDROM driver into the DOS device driver chain.
+ */
+void MSCDEX_InstallCDROM(void)
+{
+ CDROM_HEAP *cdrom_heap = CDROM_GetHeap();
+
+ DOSDEV_SetupDevice( &cdromdev,
+ cdrom_heap->cdrom_segment,
+ FIELD_OFFSET(CDROM_HEAP, hdr),
+ FIELD_OFFSET(CDROM_HEAP, thunk) );
+}
Index: module.c
===================================================================
RCS file: /home/wine/wine/dlls/winedos/module.c,v
retrieving revision 1.52
diff -u -r1.52 module.c
--- module.c 3 Oct 2005 10:15:32 -0000 1.52
+++ module.c 10 Apr 2006 13:52:13 -0000
@@ -197,6 +197,7 @@
TRACE("Initializing DOS memory structures\n");
DOSMEM_MapDosLayout();
DOSDEV_InstallDOSDevices();
+ MSCDEX_InstallCDROM();
return TRUE;
}
More information about the wine-patches
mailing list