aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJaroslav Hensl <jara@hensl.cz>2024-04-24 22:35:44 +0200
committerJaroslav Hensl <jara@hensl.cz>2024-04-24 22:35:44 +0200
commit484d69bd1cc2104525707f870ae5ca1b2a97bdf3 (patch)
treede258f5d11403b8586ddf428dcfbf258a3edcf34
parent15354cd08b184ebc79c55a0858e7772648c69608 (diff)
downloadvmdisp9x-484d69bd1cc2104525707f870ae5ca1b2a97bdf3.tar.gz
System version 0x400, use REGISTER_DISPLAY_DRIVER, alloc. segment desc. in VXD, font fix (need DDK98)
-rw-r--r--enable.c50
-rw-r--r--init.c12
-rw-r--r--makefile34
-rw-r--r--modes.c2
-rw-r--r--pm16_calls.c39
-rw-r--r--res/vmws_vxd.rc12
-rw-r--r--version.h2
-rw-r--r--vmdisp9x.inf1
-rw-r--r--vmm.h4
-rw-r--r--vxd_lib.c77
-rw-r--r--vxd_lib.h4
-rw-r--r--vxd_main.c35
-rw-r--r--vxd_strings.h8
-rw-r--r--vxd_vdd.c133
-rw-r--r--vxd_vdd.h2
-rw-r--r--vxd_vdd_list.h20
16 files changed, 370 insertions, 65 deletions
diff --git a/enable.c b/enable.c
index 544bc11..9ae2bf4 100644
--- a/enable.c
+++ b/enable.c
@@ -184,7 +184,6 @@ UINT WINAPI __loadds Enable( LPVOID lpDevice, UINT style, LPSTR lpDeviceType,
LPDIBENGINE lpEng = lpDevice;
LPBITMAPINFO lpInfo;
WORD wFlags;
- DWORD dwRet;
/* Initialize the PDEVICE. */
lpDriverPDevice = lpDevice;
@@ -255,20 +254,43 @@ UINT WINAPI __loadds Enable( LPVOID lpDevice, UINT style, LPSTR lpDeviceType,
wFlags = wPDeviceFlags;
if( wPalettized )
wFlags |= PALETTIZED;
-
+#if 1
+ /* JH: It looks like CreateDIBPDevice is not needed and you have to only
+ * fill the LPDIBENGINE structure.
+ */
+ lpEng->deType = TYPE_DIBENG;
+ lpEng->deFlags = wFlags;
+ lpEng->deWidth = wScreenX;
+ lpEng->deHeight = wScreenY;
+ lpEng->deWidthBytes = hda->pitch;
+ lpEng->deDeltaScan = hda->pitch;
+ lpEng->dePlanes = 1;
+ lpEng->deBitsPixel = wBpp;
+ lpEng->deReserved1 = 0;
+ lpEng->delpPDevice = 0;
+ lpEng->deBitsOffset = 0;
+ lpEng->deBitsSelector = ScreenSelector;
+ lpEng->deBitmapInfo = lpInfo;
+ lpEng->deVersion = 0x400;
+ lpEng->deBeginAccess = BeginAccess_VXD;
+ lpEng->deEndAccess = EndAccess_VXD;
+#else
/* Call the DIB Engine to set up the PDevice. */
dbg_printf( "lpInfo=%WP lpDevice=%WP lpColorTable=%WP wFlags=%X ScreenSelector=%X\n", lpInfo, lpDevice, lpColorTable, wFlags, ScreenSelector );
- dwRet = CreateDIBPDeviceX( lpInfo, lpDevice, ScreenSelector :> 0, wFlags );
- if( !dwRet ) {
- dbg_printf( "Enable: CreateDIBPDevice failed!\n" );
- return( 0 );
+ {
+ DWORD dwRet;
+ dwRet = CreateDIBPDeviceX( lpInfo, lpDevice, ScreenSelector :> 0, wFlags );
+ if( !dwRet ) {
+ dbg_printf( "Enable: CreateDIBPDevice failed!\n" );
+ return( 0 );
+ }
+ dbg_printf( "Enable: CreateDIBPDevice returned %lX\n", dwRet );
}
- dbg_printf( "Enable: CreateDIBPDevice returned %lX\n", dwRet );
/* Now fill out the begin/end access callbacks. */
lpEng->deBeginAccess = BeginAccess_VXD;
lpEng->deEndAccess = EndAccess_VXD;
-
+#endif
/* Program the DAC in non-direct color modes. */
if( wBpp <= 8 ) {
switch( wBpp ) {
@@ -289,6 +311,7 @@ UINT WINAPI __loadds Enable( LPVOID lpDevice, UINT style, LPSTR lpDeviceType,
if( !bReEnabling ) {
HookInt2Fh();
}
+
DDCreateDriverObject(1);
wEnabled = 1;
@@ -310,7 +333,7 @@ UINT WINAPI __loadds Enable( LPVOID lpDevice, UINT style, LPSTR lpDeviceType,
lpInfo->dpHorzSize = DISPLAY_HORZ_MM;
lpInfo->dpVertSize = DISPLAY_VERT_MM;
lpInfo->dpPlanes = 1;
- lpInfo->dpCapsFE = 0;
+ //lpInfo->dpCapsFE = 0;
lpInfo->dpNumFonts = 0;
/* Now set the fields that depend on current mode. */
@@ -330,17 +353,17 @@ UINT WINAPI __loadds Enable( LPVOID lpDevice, UINT style, LPSTR lpDeviceType,
/* These calculations are a wild guess and probably don't matter. */
lpInfo->dpELoWin.xcoord = DISPLAY_SIZE_EN;
lpInfo->dpELoWin.ycoord = DISPLAY_SIZE_EN;
- lpInfo->dpELoVpt.xcoord = wScrX / 5;
+ lpInfo->dpELoVpt.xcoord = wScrX;
lpInfo->dpELoVpt.ycoord = -lpInfo->dpELoVpt.xcoord;
lpInfo->dpELoWin.xcoord = DISPLAY_SIZE_EN * 5;
lpInfo->dpELoWin.ycoord = DISPLAY_SIZE_EN * 5;
- lpInfo->dpEHiVpt.xcoord = wScrX / 10;
+ lpInfo->dpEHiVpt.xcoord = -wScrX / 2;
lpInfo->dpEHiVpt.ycoord = -lpInfo->dpEHiVpt.xcoord;
lpInfo->dpTwpWin.xcoord = DISPLAY_SIZE_TWP;
lpInfo->dpTwpWin.ycoord = DISPLAY_SIZE_TWP;
- lpInfo->dpTwpVpt.xcoord = wScrX / 10;
+ lpInfo->dpTwpVpt.xcoord = -wScrX / 2;
lpInfo->dpTwpVpt.ycoord = -lpInfo->dpTwpVpt.xcoord;
/* Update more GDIINFO bits. */
@@ -353,7 +376,7 @@ UINT WINAPI __loadds Enable( LPVOID lpDevice, UINT style, LPSTR lpDeviceType,
* Realistically, software rendering in a VM on a modern system is going to be a lot
* faster than most mid-1990s graphics cards.
*/
- lpInfo->dpCaps1 |= C1_COLORCURSOR | C1_REINIT_ABLE; /* | C1_SLOW_CARD */;
+ lpInfo->dpCaps1 |= C1_COLORCURSOR | C1_REINIT_ABLE | C1_BYTE_PACKED | C1_GLYPH_INDEX; /* | C1_SLOW_CARD */;
//lpInfo->dpCaps1 &= ~C1_GLYPH_INDEX;
lpInfo->dpText |= TC_CP_STROKE | TC_RA_ABLE;
@@ -409,6 +432,7 @@ UINT WINAPI __loadds Enable( LPVOID lpDevice, UINT style, LPSTR lpDeviceType,
//DIB_Enable( lpInfo, 1, NULL, NULL, NULL );
dbg_printf( "sizeof(GDIINFO)=%d (%X), dpDEVICEsize=%X\n", sizeof( GDIINFO ), sizeof( GDIINFO ), lpInfo->dpDEVICEsize );
+
return( sizeof( GDIINFO ) );
}
}
diff --git a/init.c b/init.c
index 3c3a6ca..976f15f 100644
--- a/init.c
+++ b/init.c
@@ -192,6 +192,12 @@ UINT FAR DriverInit( UINT cbHeap, UINT hModule, LPSTR lpCmdLine )
dbg_printf("VXD connect success!\n");
FBHDA_setup(&hda, &hda_linear);
+ if(hda == NULL)
+ {
+ dbg_printf("DriverInit: failed to get FBHDA!\n");
+ return 0;
+ }
+
mouse_buffer(&mouse_buf, &mouse_buf_lin);
if(mouse_buf != NULL)
{
@@ -199,11 +205,5 @@ UINT FAR DriverInit( UINT cbHeap, UINT hModule, LPSTR lpCmdLine )
mouse_vxd = TRUE;
}
- if(hda == NULL)
- {
- dbg_printf("DriverInit: failed to get FBHDA!\n");
- return 0;
- }
-
return( 1 ); /* Success. */
}
diff --git a/makefile b/makefile
index 657ddfe..7766b21 100644
--- a/makefile
+++ b/makefile
@@ -11,10 +11,16 @@ OBJS += &
INCS = -I$(%WATCOM)\h\win -Iddk -Ivmware
-VER_BUILD = 45
+VER_BUILD = 47
FLAGS = -DDRV_VER_BUILD=$(VER_BUILD)
+# Watcom resource compiler haven't -40 option, but without it DIB engine displays
+# wrong some national fonts and denies to use font smooth edge.
+# This option allow to use MS 16-bit RC.EXE from DDK98 but you need
+# 32 bit Windows to run this (and DDK98 installed of course).
+#DDK98_PATH = C:\98DDK
+
# Define HWBLT if BitBlt can be accelerated.
#FLAGS += -DHWBLT
@@ -43,7 +49,20 @@ CFLAGS32 += -DCOM2
CFLAGS32 += -d0
!endif
-#all : boxvmini.drv vmwsmini.drv qemumini.drv vmwsmini.vxd qemumini.vxd
+# 16bit RC.EXE from DDK98
+!ifdef DDK98_PATH
+RC16 = $(DDK98_PATH)\bin\win98\bin16\RC.EXE
+RC16_FLAGS = -40 -i $(DDK98_PATH)\inc\win98\inc16 -i res -d DRV_VER_BUILD=$(VER_BUILD)
+
+BOXVMINI_DRV_RC = $(RC16) $(RC16_FLAGS) res\boxvmini.rc $@
+VMWSMINI_DRV_RC = $(RC16) $(RC16_FLAGS) res\vmwsmini.rc $@
+QEMUMINI_DRV_RC = $(RC16) $(RC16_FLAGS) res\qemumini.rc $@
+!else
+BOXVMINI_DRV_RC = wrc -q boxvmini.res $@
+VMWSMINI_DRV_RC = wrc -q vmwsmini.res $@
+QEMUMINI_DRV_RC = wrc -q qemumini.res $@
+!endif
+
all : vmwsmini.drv vmwsmini.vxd qemumini.drv qemumini.vxd boxvmini.drv boxvmini.vxd
# Object files: PM16 RING-3
@@ -155,9 +174,6 @@ vmwsmini.res : res/vmwsmini.rc res/colortab.bin res/config.bin res/fonts.bin res
qemumini.res : res/qemumini.rc res/colortab.bin res/config.bin res/fonts.bin res/fonts120.bin .autodepend
wrc -q -r -ad -bt=windows -fo=$@ -Ires -I$(%WATCOM)/h/win $(FLAGS) res/qemumini.rc
-vmws_vxd.res : res/vmws_vxd.rc .autodepend
- wrc -q -r -ad -bt=nt -fo=$@ -Ires -I$(%WATCOM)/h/win $(FLAGS) res/vmws_vxd.rc
-
res/colortab.bin : res/colortab.c
wcc -q $(INCS) $<
wlink op quiet disable 1014, 1023 name $@ sys dos output raw file colortab.obj
@@ -243,7 +259,7 @@ export UserRepaintDisable.500
export ValidateMode.700
import GlobalSmartPageLock KERNEL.230
<<
- wrc -q boxvmini.res $@
+ $(BOXVMINI_DRV_RC)
vmwsmini.drv : $(OBJS) vmwsmini.res dibeng.lib
wlink op quiet, start=DriverInit_ disable 2055 $(DBGFILE) @<<vmwsmini.lnk
@@ -310,7 +326,7 @@ export UserRepaintDisable.500
export ValidateMode.700
import GlobalSmartPageLock KERNEL.230
<<
- wrc -q vmwsmini.res $@
+ $(VMWSMINI_DRV_RC)
qemumini.drv : $(OBJS) qemumini.res dibeng.lib
wlink op quiet, start=DriverInit_ disable 2055 $(DBGFILE) @<<qemumini.lnk
@@ -377,9 +393,9 @@ export UserRepaintDisable.500
export ValidateMode.700
import GlobalSmartPageLock KERNEL.230
<<
- wrc -q qemumini.res $@
+ $(QEMUMINI_DRV_RC)
-vmwsmini.vxd : $(OBJS) vmws_vxd.res
+vmwsmini.vxd : $(OBJS)
wlink op quiet $(DBGFILE32) @<<vmwsmini.lnk
system win_vxd dynamic
option map=vmwsvxd.map
diff --git a/modes.c b/modes.c
index fd8faac..33f4ad3 100644
--- a/modes.c
+++ b/modes.c
@@ -254,6 +254,7 @@ int PhysicalEnable( void )
/* Allocate an LDT selector for the screen. */
if( !ScreenSelector ) {
ScreenSelector = ((DWORD)hda->vram_pm16) >> 16;
+#if 0
if(ScreenSelector == 0)
{
ScreenSelector = DPMI_AllocLDTDesc(1);
@@ -268,6 +269,7 @@ int PhysicalEnable( void )
dbg_printf( "PhysicalEnable: Invalid VRAM selector failed!\n" );
return( 0 );
}
+#endif
}
/* NB: Currently not used. DirectDraw would need the segment base. */
diff --git a/pm16_calls.c b/pm16_calls.c
index 7b42184..eb36c57 100644
--- a/pm16_calls.c
+++ b/pm16_calls.c
@@ -30,6 +30,12 @@ THE SOFTWARE.
#include "dpmi.h"
+#include <gdidefs.h>
+#include <dibeng.h>
+#include <valmode.h>
+#include <minivdd.h>
+#include "minidrv.h"
+
#include "pm16_calls.h"
#include "vxd.h"
#include "3d_accel.h"
@@ -47,6 +53,8 @@ extern void dbg_printf( const char *s, ... );
#endif
static DWORD VXD_VM = 0;
+static DWORD vxd_fbhda16 = 0;
+static DWORD vxd_mouse16 = 0;
#pragma code_seg( _INIT )
@@ -57,6 +65,7 @@ BOOL VXD_VM_connect()
return TRUE;
}
+ /* read service vector */
_asm{
push es
push ax
@@ -79,11 +88,36 @@ BOOL VXD_VM_connect()
pop es
};
+ dbg_printf("VDD_REGISTER_DISPLAY_DRIVER_INFO for VM: %d\n", OurVMHandle);
+
+ _asm{
+ .386
+ push eax
+ push ebx
+ push ecx
+ push edx
+
+ mov eax, VDD_REGISTER_DISPLAY_DRIVER_INFO
+ movzx ebx, word ptr [OurVMHandle]
+ call dword ptr [VDDEntryPoint]
+
+ mov [vxd_fbhda16], edx
+ mov [vxd_mouse16], ecx
+
+ pop edx
+ pop ecx
+ pop ebx
+ pop eax
+ }
+
+ dbg_printf("VDD_REGISTER_DISPLAY_DRIVER_INFO: eax=%lX, edx=%lX, ecx=%lX\n", VXD_VM, vxd_fbhda16, vxd_mouse16);
+
return VXD_VM != 0;
}
void FBHDA_setup(FBHDA_t __far* __far* FBHDA, DWORD __far* FBHDA_linear)
{
+#if 0
static DWORD linear;
linear = 0;
@@ -115,6 +149,8 @@ void FBHDA_setup(FBHDA_t __far* __far* FBHDA, DWORD __far* FBHDA_linear)
*FBHDA = (FBHDA_t __far*)longptr;
*FBHDA_linear = linear;
}
+#endif
+ *FBHDA = (FBHDA_t __far*)vxd_fbhda16;
}
void FBHDA_access_begin(DWORD flags)
@@ -287,6 +323,7 @@ BOOL mouse_load()
void mouse_buffer(void __far* __far* pBuf, DWORD __far* pLinear)
{
+#if 0
static DWORD buffer;
_asm
@@ -317,6 +354,8 @@ void mouse_buffer(void __far* __far* pBuf, DWORD __far* pLinear)
*pBuf = longptr;
*pLinear = buffer;
}
+#endif
+ *pBuf = (void __far*)vxd_mouse16;
}
void mouse_move(int x, int y)
diff --git a/res/vmws_vxd.rc b/res/vmws_vxd.rc
deleted file mode 100644
index 0ad9778..0000000
--- a/res/vmws_vxd.rc
+++ /dev/null
@@ -1,12 +0,0 @@
-/*
- * Windows 9x minidriver resource file.
- * Most of the contents is defined by backward compatibility
- * requirements. Much of the detail is explained in the Windows 3.x
- * and 2.x DDKs.
- */
-
-#include "windows.h"
-
-#define VER_ORIGINALFILENAME_STR "vmsvmini.vxd"
-
-#include "display.rcv"
diff --git a/version.h b/version.h
index 89987ae..28c9c38 100644
--- a/version.h
+++ b/version.h
@@ -5,7 +5,7 @@
#define DRV_STR(x) DRV_STR_(x)
/* on binaries equals 1 and for INF is 1 = separate driver, 2 = softgpu pack */
-#define DRV_VER_MAJOR 1
+#define DRV_VER_MAJOR 4
/* the YEAR */
#define DRV_VER_MINOR 2024
diff --git a/vmdisp9x.inf b/vmdisp9x.inf
index 856403a..111b0e5 100644
--- a/vmdisp9x.inf
+++ b/vmdisp9x.inf
@@ -162,6 +162,7 @@ HKLM,Software\Microsoft\Windows\CurrentVersion\OpenGLdrivers,VMWSVGA
HKR,,Ver,,4.0
HKR,,DevLoader,,*vdd
HKR,DEFAULT,vdd,,"*vdd"
+HKR,DEFAULT,carddvdd,,cardsamp.vxd
HKR,DEFAULT,RefreshRate,,-1
HKR,DEFAULT,DDC,,1
HKR,DEFAULT,ExtModeSwitch,,0
diff --git a/vmm.h b/vmm.h
index 9a7b812..87d7e67 100644
--- a/vmm.h
+++ b/vmm.h
@@ -67,8 +67,8 @@ typedef struct tagVxD_Desc_Block
} DDB ;
#pragma pack(pop)
-#define DDK_VERSION 0x30A
-//#define DDK_VERSION 0x400
+//#define DDK_VERSION 0x30A
+#define DDK_VERSION 0x400
//#define DDK_VERSION 0x40A
// version 3.10 is required or Windows 95 can't load VXD
diff --git a/vxd_lib.c b/vxd_lib.c
index b1c4c72..9fa83db 100644
--- a/vxd_lib.c
+++ b/vxd_lib.c
@@ -309,6 +309,83 @@ DWORD __cdecl _GetFreePageCount(DWORD *pLockablePages)
return sFreePages;
}
+static void __declspec(naked) __cdecl _BuildDescriptorDWORDs_(ULONG DESCBase, ULONG DESCLimit, ULONG DESCType, ULONG DESCSize, ULONG flags)
+{
+ VMMJmp(_BuildDescriptorDWORDs);
+}
+
+void __cdecl _BuildDescriptorDWORDs(ULONG DESCBase, ULONG DESCLimit, ULONG DESCType, ULONG DESCSize, ULONG flags, DWORD *outDescHigh, DWORD *outDescLow)
+{
+ static DWORD sHigh;
+ static DWORD sLow;
+
+ _BuildDescriptorDWORDs_(DESCBase, DESCLimit, DESCType, DESCSize, flags);
+ _asm
+ {
+ mov [sHigh], edx
+ mov [sLow], eax
+ }
+
+ *outDescHigh = sHigh;
+ *outDescLow = sLow;
+}
+
+static void __declspec(naked) __cdecl _Allocate_LDT_Selector_(ULONG vm, ULONG DescHigh, ULONG DescLow, ULONG Count, ULONG flags)
+{
+ VMMJmp(_Allocate_LDT_Selector);
+}
+
+void __cdecl _Allocate_LDT_Selector(ULONG vm, ULONG DescHigh, ULONG DescLow, ULONG Count, ULONG flags, DWORD *outFirstSelector, DWORD *outSelectorTable)
+{
+ static DWORD firstSelector;
+ static DWORD selectorTable;
+
+ _Allocate_LDT_Selector_(vm, DescHigh, DescLow, Count, flags);
+ _asm
+ {
+ mov [firstSelector], eax
+ mov [selectorTable], edx
+ }
+
+ if(outFirstSelector != NULL)
+ {
+ *outFirstSelector = firstSelector;
+ }
+
+ if(outSelectorTable != NULL)
+ {
+ *outSelectorTable = selectorTable;
+ }
+}
+
+static void __declspec(naked) __cdecl _Allocate_GDT_Selector_(ULONG DescHigh, ULONG DescLow, ULONG flags)
+{
+ VMMJmp(_Allocate_GDT_Selector);
+}
+
+void __cdecl _Allocate_GDT_Selector(ULONG DescHigh, ULONG DescLow, ULONG flags, DWORD *outFirstSelector, DWORD *outSelectorTable)
+{
+ static DWORD firstSelector;
+ static DWORD selectorTable;
+
+ _Allocate_GDT_Selector_(DescHigh, DescLow, flags);
+ _asm
+ {
+ mov [firstSelector], eax
+ mov [selectorTable], edx
+ }
+
+ if(outFirstSelector != NULL)
+ {
+ *outFirstSelector = firstSelector;
+ }
+
+ if(outSelectorTable != NULL)
+ {
+ *outSelectorTable = selectorTable;
+ }
+}
+
ULONG __declspec(naked) __cdecl _PageAllocate(ULONG nPages, ULONG pType, ULONG VM, ULONG AlignMask, ULONG minPhys, ULONG maxPhys, ULONG *PhysAddr, ULONG flags)
{
VMMJmp(_PageAllocate);
diff --git a/vxd_lib.h b/vxd_lib.h
index 674ed65..9bf406e 100644
--- a/vxd_lib.h
+++ b/vxd_lib.h
@@ -51,6 +51,10 @@ void __cdecl *Map_Flat(BYTE SegOffset, BYTE OffOfset);
void __cdecl Install_IO_Handler(DWORD port, DWORD callback);
DWORD __cdecl _GetFreePageCount(DWORD *pLockablePages);
+void __cdecl _BuildDescriptorDWORDs(ULONG DESCBase, ULONG DESCLimit, ULONG DESCType, ULONG DESCSize, ULONG flags, DWORD *outDescHigh, DWORD *outDescLow);
+void __cdecl _Allocate_LDT_Selector(ULONG vm, ULONG DescHigh, ULONG DescLow, ULONG Count, ULONG flags, DWORD *outFirstSelector, DWORD *outSelectorTable);
+void __cdecl _Allocate_GDT_Selector(ULONG DescHigh, ULONG DescLow, ULONG flags, DWORD *outFirstSelector, DWORD *outSelectorTable);
+
/**
* round size in bytes to number of pages
**/
diff --git a/vxd_main.c b/vxd_main.c
index c9d3b01..5be084a 100644
--- a/vxd_main.c
+++ b/vxd_main.c
@@ -74,18 +74,21 @@ DDB VXD_DDB = {
VXD_MINOR_VER, // Minor Version
NULL,
VXD_DEVICE_NAME,
- VDD_Init_Order, //Undefined_Init_Order,
+ VDD_Init_Order,
(DWORD)VXD_control,
(DWORD)VXD_API_entry,
(DWORD)VXD_API_entry,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
+ NULL,// CS:IP of API entry point
+ NULL,// CS:IP of API entry point
+ NULL,// Reference data from real mode
+ NULL,// Pointer to service table
+ NULL,// Number of services
NULL, // DDB_Win32_Service_Table
- NULL, // prev
- sizeof(DDB)
+ 'Prev', //NULL, // prev
+ sizeof(DDB),
+ 'Rsv1',
+ 'Rsv2',
+ 'Rsv3',
};
#include "vxd_strings.h"
@@ -426,17 +429,30 @@ static void configure_FBHDA()
_asm { call _procname ## _proc }; \
_asm { retn }; \
}
+
+#define VDDNAKED(_fnname, _procname) void __declspec(naked) _procname ## _entry() { \
+ _asm { pushad }; \
+ _asm { mov eax, esp }; \
+ _asm { add eax, 32 }; \
+ _asm { push eax }; \
+ _asm { call _procname ## _proc }; \
+ _asm { popad }; \
+ _asm { retn }; \
+ }
+
#include "vxd_vdd_list.h"
#undef VDDFUNC
+#undef VDDNAKED
#define VDDFUNC(id, procname) DispatchTable[id] = (DWORD)(procname ## _entry);
+#define VDDNAKED VDDFUNC
/* init device and fill dispatch table */
void Device_Dynamic_Init_proc(DWORD VM)
{
dbg_printf(dbg_Device_Init_proc);
- // VMMCall _Allocate_Device_CB_Area
+ VMMCall(_Allocate_Device_CB_Area);
ThisVM = VM;
#ifdef SVGA
@@ -464,6 +480,7 @@ void Device_Dynamic_Init_proc(DWORD VM)
configure_FBHDA();
}
#undef VDDFUNC
+#undef VDDNAKED
/* process user space (PM32, RING-3) call */
DWORD __stdcall Device_IO_Control_proc(DWORD vmhandle, struct DIOCParams *params)
diff --git a/vxd_strings.h b/vxd_strings.h
index f8b3569..64bc36b 100644
--- a/vxd_strings.h
+++ b/vxd_strings.h
@@ -117,6 +117,14 @@ DSTR(dbg_cache, "Cache enabled: %d\n");
DSTR(dbg_mob_size, "sizeof(SVGA3dCmdDefineGBMob) = %d\n");
+DSTR(dbg_map_pm16, "map_pm16: vm = %ld, linear = %lX, size = %ld\n");
+
+DSTR(dbg_map_pm16_sel, "map_pm16: selector %lX\n");
+
+DSTR(dbg_register, "register: ebx = %ld, ecx = %ld, VM = %lX\n");
+
+DSTR(dbg_map_pm16_qw, "map_pm16: high=%lX, low=%lX\n");
+
#undef DSTR
#endif
diff --git a/vxd_vdd.c b/vxd_vdd.c
index e82a091..8f15f11 100644
--- a/vxd_vdd.c
+++ b/vxd_vdd.c
@@ -35,6 +35,8 @@ THE SOFTWARE.
#include "vxd_vdd.h"
#include "3d_accel.h"
+#include "vxd_lib.h"
+
#ifdef SVGA
#include "svga_all.h"
#endif
@@ -44,12 +46,55 @@ THE SOFTWARE.
/* code and data is same segment */
#include "code32.h"
+#include "vxd_strings.h"
+
extern FBHDA_t *hda;
+extern DWORD ThisVM;
+
+static DWORD hda_pm16 = 0;
+static DWORD mouse_pm16 = 0;
#ifdef VBE
extern WORD vbe_chip_id;
#endif
+static BOOL mode_changing = FALSE;
+
+static void VDD_Register_Extra_Screen_Selector(DWORD selector)
+{
+ static DWORD sSelector;
+ sSelector = selector;
+
+ _asm mov eax, [sSelector]
+ _asm push eax
+ VxDCall(VDD, Register_Extra_Screen_Selector);
+ _asm pop eax
+}
+
+static DWORD map_pm16(DWORD vm, DWORD linear, DWORD size)
+{
+ DWORD hi = 0;
+ DWORD low = 0;
+ DWORD selector;
+
+ dbg_printf(dbg_map_pm16, vm, linear, size);
+
+ _BuildDescriptorDWORDs(linear, RoundToPages(size), 0x92, 0x80, 0, &hi, &low);
+
+ dbg_printf(dbg_map_pm16_qw, hi, low);
+
+ //_Allocate_LDT_Selector(vm, hi, low, 1, 0, &selector, NULL);
+ _Allocate_GDT_Selector(hi, low, 0, &selector, NULL);
+
+ dbg_printf(dbg_test, 2);
+
+ VDD_Register_Extra_Screen_Selector(selector);
+
+ dbg_printf(dbg_map_pm16_sel, selector);
+
+ return selector << 16;
+}
+
/*
You can implement all the VESA support entirely in your mini-VDD. Doing so will
cause VESA applications to run more efficiently since all of the VESA support is
@@ -86,7 +131,33 @@ See also VDD_REGISTER_DISPLAY_DRIVER_INFO.
**/
VDDPROC(REGISTER_DISPLAY_DRIVER, register_display_driver)
{
- VDD_NC;
+ dbg_printf(dbg_register, state->Client_EBX, state->Client_ECX, ThisVM);
+
+ if(hda->vram_pm16 == 0)
+ {
+ hda->vram_pm16 = map_pm16(state->Client_EBX, (DWORD)hda->vram_pm32, hda->vram_size);
+ }
+
+ if(hda_pm16 == 0)
+ {
+ hda_pm16 = map_pm16(state->Client_EBX, (DWORD)hda, sizeof(FBHDA_t));
+ }
+
+ if(mouse_pm16 == 0)
+ {
+ mouse_pm16 = map_pm16(state->Client_EBX, (DWORD)mouse_buffer(), MOUSE_BUFFER_SIZE);
+ }
+
+ /* RETURN:
+ EAX -> VXD_VM (thisVM)
+ EDX -> fbhda
+ ECX -> mouse_buffer
+ */
+ state->Client_EAX = ThisVM;
+ state->Client_EDX = hda_pm16;
+ state->Client_ECX = mouse_pm16;
+
+ VDD_CY;
}
/**
@@ -191,6 +262,24 @@ This routine is called during the save process of a VESA hi-res screen. It tells
**/
VDDPROC(GET_BANK_SIZE, get_bank_size)
{
+ state->Client_EAX = 0;
+ state->Client_EDX = 0x4000;
+ VDD_CY;
+}
+
+
+VDDPROC(GET_VDD_BANK, get_vdd_bank)
+{
+ state->Client_EDX = state->Client_ECX;
+}
+
+VDDPROC(SET_VDD_BANK, set_vdd_bank)
+{
+
+}
+
+VDDPROC(RESET_BANK, reset_bank)
+{
}
@@ -371,27 +460,67 @@ void Disable_Global_Trapping(DWORD port)
_asm pop edx
}
-/* for QEMU */
VDDPROC(PRE_HIRES_TO_VGA, pre_hires_to_vga)
{
+ mode_changing = TRUE;
+#ifdef QEMU
Disable_Global_Trapping(0x1CE);
Disable_Global_Trapping(0x1CF);
+#endif
}
VDDPROC(POST_HIRES_TO_VGA, post_hires_to_vga)
{
+ mode_changing = FALSE;
+#ifdef QEMU
Enable_Global_Trapping(0x1CE);
Enable_Global_Trapping(0x1CF);
+#endif
+}
+
+VDDPROC(PRE_VGA_TO_HIRES, pre_vga_to_hires)
+{
+ mode_changing = TRUE;
+}
+
+VDDPROC(POST_VGA_TO_HIRES, post_vga_to_hires)
+{
+ mode_changing = FALSE;
}
VDDPROC(ENABLE_TRAPS, enable_traps)
{
+#ifdef QEMU
Enable_Global_Trapping(0x1CE);
Enable_Global_Trapping(0x1CF);
+#endif
}
VDDPROC(DISPLAY_DRIVER_DISABLING, display_driver_disabling)
{
+#ifdef QEMU
Disable_Global_Trapping(0x1CE);
Disable_Global_Trapping(0x1CF);
+#endif
+}
+
+VDDPROC(SAVE_REGISTERS, save_registers)
+{
+ // NOP
+}
+
+
+VDDPROC(RESTORE_REGISTERS, restore_registers)
+{
+ // NOP
+}
+
+VDDPROC(VIRTUALIZE_CRTC_IN, virtualize_crtc_in)
+{
+ // NOP
+}
+
+VDDPROC(VIRTUALIZE_CRTC_OUT, virtualize_crtc_out)
+{
+ // NOP
}
diff --git a/vxd_vdd.h b/vxd_vdd.h
index 428a5fb..f25e2c1 100644
--- a/vxd_vdd.h
+++ b/vxd_vdd.h
@@ -101,8 +101,10 @@ void dbg_printf( const char *s, ... );
/* generate prototypes */
#define VDDFUNC(_fnname, _procname) void __stdcall _procname ## _proc(PCRS_32 state);
+#define VDDNAKED VDDFUNC
#include "vxd_vdd_list.h"
#undef VDDFUNC
+#undef VDDNAKED
#define VDDPROC(_fnname, _procname) void __stdcall _procname ## _proc(PCRS_32 state)
diff --git a/vxd_vdd_list.h b/vxd_vdd_list.h
index 9155921..4600757 100644
--- a/vxd_vdd_list.h
+++ b/vxd_vdd_list.h
@@ -5,17 +5,15 @@
*/
VDDFUNC(REGISTER_DISPLAY_DRIVER, register_display_driver)
-//VDDFUNC(GET_VDD_BANK, get_vdd_bank)
-//VDDFUNC(SET_VDD_BANK, set_vdd_bank)
-//VDDFUNC(RESET_BANK, reset_bank)
-#ifdef QEMU
+VDDFUNC(GET_VDD_BANK, get_vdd_bank)
+VDDFUNC(SET_VDD_BANK, set_vdd_bank)
+VDDFUNC(RESET_BANK, reset_bank)
VDDFUNC(PRE_HIRES_TO_VGA, pre_hires_to_vga)
VDDFUNC(POST_HIRES_TO_VGA, post_hires_to_vga)
-#endif
-//VDDFUNC(PRE_VGA_TO_HIRES, pre_vga_to_hires)
-//VDDFUNC(POST_VGA_TO_HIRES, post_vga_to_hires)
-//VDDFUNC(SAVE_REGISTERS, save_registers)
-//VDDFUNC(RESTORE_REGISTERS, restore_registers)
+VDDFUNC(PRE_VGA_TO_HIRES, pre_vga_to_hires)
+VDDFUNC(POST_VGA_TO_HIRES, post_vga_to_hires)
+VDDFUNC(SAVE_REGISTERS, save_registers)
+VDDFUNC(RESTORE_REGISTERS, restore_registers)
//VDDFUNC(MODIFY_REGISTER_STATE, modify_register_state)
//VDDFUNC(ACCESS_VGA_MEMORY_MODE, access_vga_memory_mode)
//VDDFUNC(ACCESS_LINEAR_MEMORY_MODE, access_linear_memory_mode)
@@ -24,8 +22,8 @@ VDDFUNC(ENABLE_TRAPS, enable_traps)
#endif
//VDDFUNC(DISABLE_TRAPS, disable_traps)
//VDDFUNC(MAKE_HARDWARE_NOT_BUSY, make_hardware_not_busy)
-//VDDFUNC(VIRTUALIZE_CRTC_IN, virtualize_crtc_in)
-//VDDFUNC(VIRTUALIZE_CRTC_OUT, virtualize_crtc_out)
+VDDFUNC(VIRTUALIZE_CRTC_IN, virtualize_crtc_in)
+VDDFUNC(VIRTUALIZE_CRTC_OUT, virtualize_crtc_out)
//VDDFUNC(VIRTUALIZE_SEQUENCER_IN, virtualize_sequencer_in)
//VDDFUNC(VIRTUALIZE_SEQUENCER_OUT, virtualize_sequencer_out)
//VDDFUNC(VIRTUALIZE_GCR_IN, virtualize_gcr_in)