Skip to content

Commit

Permalink
Add a mini-VDD VxD; revise the INF file and docs
Browse files Browse the repository at this point in the history
  • Loading branch information
phkelley committed Jan 25, 2023
1 parent 3804560 commit 3f330ec
Show file tree
Hide file tree
Showing 8 changed files with 207 additions and 11 deletions.
16 changes: 8 additions & 8 deletions boxv9x.inf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
;
; INF file for VirtualBox Win9x display driver
; INF file for QEMU Win9x display driver
; Copyright 2012-2022, The OS/2 Museum

[version]
Expand All @@ -13,17 +13,17 @@ BoxV.Copy = 11

[SourceDisksNames]
; BOXV9X is the driver disk volume label
1="VirtualBox Win9x Display Driver Disk",BOXV9X,1
1="QEMU Win9x Display Driver Disk",BOXV9X,1

[SourceDisksFiles]
boxvmini.drv=1
;boxvmini.vxd=1
boxvmini.vxd=1

[Manufacturer]
%Mfg%=Mfg.BoxV

[Mfg.BoxV]
%PCI\VEN_80EE&DEV_BEEF.DeviceDesc%=BoxV,PCI\VEN_80EE&DEV_BEEF
%PCI\VEN_1234&DEV_1111.DeviceDesc%=BoxV,PCI\VEN_1234&DEV_1111

[BoxV]
CopyFiles=BoxV.Copy
Expand All @@ -32,7 +32,7 @@ AddReg=BoxV_AddReg

[BoxV.Copy]
boxvmini.drv
;boxvmini.vxd
boxvmini.vxd

[Prev.DelReg]
HKR,,Ver
Expand All @@ -47,7 +47,7 @@ HKR,,DevLoader,,*vdd
HKR,DEFAULT,Mode,,"8,640,480"
HKR,DEFAULT,drv,,boxvmini.drv
HKR,DEFAULT,vdd,,"*vdd,*vflatd"
;HKR,DEFAULT,minivdd,,boxvmini.vxd
HKR,DEFAULT,minivdd,,boxvmini.vxd
;HKR,DEFAULT,carddvdd,,cardsamp.vxd
HKR,DEFAULT,RefreshRate,,-1
HKR,DEFAULT,DDC,,1
Expand Down Expand Up @@ -114,5 +114,5 @@ HKR,"MODES\32\1920,1080"
HKR,"MODES\32\1920,1200"

[Strings]
Mfg="VirtualBox"
PCI\VEN_80EE&DEV_BEEF.DeviceDesc="VirtualBox SVGA PCI"
Mfg="QEMU"
PCI\VEN_1234&DEV_1111.DeviceDesc="QEMU SVGA PCI"
4 changes: 2 additions & 2 deletions readdev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ with the overhead of a higher level language.

When built with DBGPRINT (e.g. wmake clean && wmake DBGPRINT=1), the driver
includes debug logging implemented as dbg_printf() function. This is a small
printf() subset with output directed to the VirtualBox debug port, such that
the output appears in the VBox.log file.
printf() subset with output directed to the QEMU debug port, such that
the output appears on the debug console (supply "-debugcon stdio" to QEMU).

It would be much nicer to use the C runtime printf(), but that is not at all
possible because the small model library printf() cannot operate with SS != DS
Expand Down
2 changes: 1 addition & 1 deletion readme.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
This is a display minidriver for the Windows 9x family of operating systems,
designed to run on the virtual hardware provided by VirtualBox.
designed to run on the virtual hardware provided by QEMU ("-device VGA").

The driver can be installed through the Display Settings dialog or through
the Device Manager.
Expand Down
8 changes: 8 additions & 0 deletions vxd/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
*.exe
*.dll
*.inc
*.exp
*.lib
*.map
*.obj
*.vxd
13 changes: 13 additions & 0 deletions vxd/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
To build this VxD, I used the following toolchain, which I can't redistribute:

* ML.EXE (Microsoft Macro Assembler Version 6.11d)
* LINK.EXE (Microsoft Incremental Linker Version 5.12.8181)
* MSPDB50.DLL (Needed by the linker; version 6.00.7156)

All three of these binaries came from the Windows 98 DDK, which is available
on archive.org as a RAR file. The binaries are in BINS_DDK.CAB.

The following header files are also required, also from the Windows 98 DDK:

* VMM.INC (timestamp August 3rd, 1998)
* MINIVDD.INC (timestamp August 3rd, 1998)
158 changes: 158 additions & 0 deletions vxd/boxvmini.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
;
; Mini-VDD VxD for the BOXV9X display driver on QEMU
;
; Having this mini-VDD present fixes a couple of problems with the BOXV9X
; driver. First, it virtualizes accesses to the Bochs VGA registers on I/O
; ports 1CEh and 1CFh (VBE_DISPI_IOPORT_INDEX and VBE_DISPI_IOPORT_DATA).
; This means that when you start an MS-DOS Prompt, the screen doesn't go
; wonky when the DOS VM, calling into the VGA ROM BIOS, ends up trying to
; perform I/O to those ports.
;
; Second, it fixes a problem at Windows shutdown (under KVM and WHPX accel)
; where the machine hangs instead of showing the "Windows is shutting down"
; graphic momentarily, and then actually shutting down.
;
.386p

.xlist
include VMM.INC
include MINIVDD.INC
.list

Declare_Virtual_Device \
BOXVMINI, 4, 0, \
MiniVDD_Control, \
Undefined_Device_ID, \
VDD_Init_Order,,,,

; Data segment
VxD_DATA_SEG

WindowsVMHandle dd ?

VxD_DATA_ENDS

; Init segment (discardable)
VxD_ICODE_SEG

public MiniVDD_Dynamic_Init
BeginProc MiniVDD_Dynamic_Init
;
mov WindowsVMHandle, ebx
;
VxDCall VDD_Get_Mini_Dispatch_Table
MiniVDDDispatch PRE_HIRES_TO_VGA, PreHiResToVGA
MiniVDDDispatch POST_HIRES_TO_VGA, PostHiResToVGA
MiniVDDDispatch ENABLE_TRAPS, EnableTraps
MiniVDDDispatch DISPLAY_DRIVER_DISABLING, DisplayDriverDisabling
;
mov esi, OFFSET32 MiniVDD_Virtual1CE
mov edx, 1ceh
VMMCall Install_IO_Handler
mov edx, 1ceh
VMMCall Disable_Global_Trapping
;
mov esi, OFFSET32 MiniVDD_Virtual1CE
mov edx, 1cfh
VMMCall Install_IO_Handler
mov edx, 1cfh
VMMCall Disable_Global_Trapping
;
clc
ret
EndProc MiniVDD_Dynamic_Init

public MiniVDD_Init_Complete
BeginProc MiniVDD_Init_Complete
;
; At Windows shutdown time, the display driver calls VDD_DRIVER_UNREGISTER,
; which calls our DisplayDriverDisabling callback, and soon thereafter
; does an INT 10h (AH=0) to mode 3 (and then 13) in V86 mode. However, the
; memory ranges for display memory are not always mapped!
;
; If the VGA ROM BIOS, during execution of such a set video mode call, tries to
; clear the screen, and the appropriate memory range isn't mapped, then we end
; up in a page fault handler, which I guess maps the memory and then resumes
; execution in V86 mode. But strangely, in QEMU, this fault & resume mechanism
; does not work with KVM or WHPX assist, at least on Intel. The machine hangs
; instead (I have not root caused why).
;
; We can dodge this problem by setting up real mappings up front.
;
; At entry, EBX contains a Windows VM handle.
;
mov edx, 0A0h
VMMCall _PhysIntoV86,<edx,ebx,edx,16,0>
;
mov edx, 0B8h
VMMCall _PhysIntoV86,<edx,ebx,edx,8,0>
;
ret
EndProc MiniVDD_Init_Complete

VxD_ICODE_ENDS

; Fixed segment
VxD_LOCKED_CODE_SEG

Begin_Control_Dispatch MiniVDD
Control_Dispatch Device_Init, MiniVDD_Dynamic_Init
Control_Dispatch Init_Complete, MiniVDD_Init_Complete
Control_Dispatch Sys_Dynamic_Device_Init, MiniVDD_Dynamic_Init
End_Control_Dispatch MiniVDD

public MiniVDD_Virtual1CE
BeginProc MiniVDD_Virtual1CE
; AX/AL contains the value to be read or written on the port.
; EBX contains the handle of the VM accessing the port.
; ECX contains the direction (in/out) and size (byte/word) of the operation.
; EDX contains the port number, which for us will either be 1CEh or 1CFh.
VxDCall VDD_Get_VM_Info
cmp edi, WindowsVMHandle ; Is the CRTC controlled by Windows?
jne _Virtual1CEPhysical ; If not, we should allow the I/O
cmp ebx, edi ; Is the calling VM Windows?
jne _Virtual1CEExit ; If not, we should eat the I/O
_Virtual1CEPhysical:
VxDJmp VDD_Do_Physical_IO
_Virtual1CEExit:
ret
EndProc MiniVDD_Virtual1CE

public MiniVDD_EnableTraps
BeginProc MiniVDD_EnableTraps
mov edx, 1ceh
VMMCall Enable_Global_Trapping
mov edx, 1cfh
VMMCall Enable_Global_Trapping
ret
EndProc MiniVDD_EnableTraps

public MiniVDD_PreHiResToVGA
BeginProc MiniVDD_PreHiResToVGA
mov edx, 1ceh
VMMCall Disable_Global_Trapping
mov edx, 1cfh
VMMCall Disable_Global_Trapping
ret
EndProc MiniVDD_PreHiResToVGA

public MiniVDD_PostHiResToVGA
BeginProc MiniVDD_PostHiResToVGA
mov edx, 1ceh
VMMCall Enable_Global_Trapping
mov edx, 1cfh
VMMCall Enable_Global_Trapping
ret
EndProc MiniVDD_PostHiResToVGA

public MiniVDD_DisplayDriverDisabling
BeginProc MiniVDD_DisplayDriverDisabling
mov edx, 1ceh
VMMCall Disable_Global_Trapping
mov edx, 1cfh
VMMCall Disable_Global_Trapping
ret
EndProc MiniVDD_DisplayDriverDisabling

VxD_LOCKED_CODE_ENDS
end
10 changes: 10 additions & 0 deletions vxd/boxvmini.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
VXD BOXVMINI DYNAMIC
DESCRIPTION 'DOS386 BOXVMINI Device (Version 4.0)'

SEGMENTS
_LTEXT CLASS 'LCODE' PRELOAD NONDISCARDABLE
_LDATA CLASS 'LCODE' PRELOAD NONDISCARDABLE
_ITEXT CLASS 'ICODE' DISCARDABLE

EXPORTS
BOXVMINI_DDB @1
7 changes: 7 additions & 0 deletions vxd/make.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@echo off

REM Assemble
ml -coff -DBLD_COFF -W2 -Zd -c -Cx -DMASM6 -Sg -DVGA -DVGA31 -DMINIVDD=1 -Foboxvmini.obj boxvmini.asm

REM Link
link /VXD /NOD boxvmini.obj /OUT:boxvmini.vxd /MAP:boxvmini.map /DEF:boxvmini.def

0 comments on commit 3f330ec

Please sign in to comment.