License added.

This commit is contained in:
Scott Duensing 2026-10-13 13:58:31 -05:00
parent 9265a76b65
commit 08876e2a90
5 changed files with 158 additions and 8 deletions

21
drv/LICENSE.md Normal file
View file

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2026 Scott Duensing
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View file

@ -11,9 +11,12 @@ Windows 3.1 Device Driver Adaptation Guide (DDAG). Where the DDAG is silent,
behavior follows the Windows 3.1 SDK, Wine's Win16 comm code, or the stock behavior follows the Windows 3.1 SDK, Wine's Win16 comm code, or the stock
driver as far as it is known; those cases are called out below. driver as far as it is known; those cases are called out below.
> Status: the driver was rewritten to the DDAG on 2026-10-12. The rewrite > Status: the driver was rewritten to the DDAG on 2026-10-12. Built with
> compiles and links under Open Watcom with the Win16 headers but has not yet > Open Watcom (`watcom.mk`), it runs: JoeyLib's Win16 port installs it as
> been built with MSVC 1.52 or run on hardware. See > `comm.drv` on Windows for Workgroups 3.11 under DOSBox Staging, where COM1
> opens and echoes, and 16 KB go out and come back in order at the full line
> rate at 57600 and at 115200 (`KPCBR_115200`). It has not yet been built
> with MSVC 1.52 or run on hardware. See
> [Verification checklist](#verification-checklist). > [Verification checklist](#verification-checklist).
@ -36,6 +39,7 @@ driver as far as it is known; those cases are called out below.
- [Verification checklist](#verification-checklist) - [Verification checklist](#verification-checklist)
- [Future work](#future-work) - [Future work](#future-work)
- [References](#references) - [References](#references)
- [License](#license)
## Files ## Files
@ -48,7 +52,10 @@ driver as far as it is known; those cases are called out below.
| `lpt.c` | LPT1-LPT3 support (polled output through BIOS INT 17h) | | `lpt.c` | LPT1-LPT3 support (polled output through BIOS INT 17h) |
| `commdrv.def` | Module definition: module name `COMM`, export ordinals, FIXED segments | | `commdrv.def` | Module definition: module name `COMM`, export ordinals, FIXED segments |
| `makefile` | NMAKE build for MSVC 1.52 | | `makefile` | NMAKE build for MSVC 1.52 |
| `watcom.mk` | GNU make build with Open Watcom v2 (on Linux) |
| `kpcomm.lnk` | wlink directives for the Open Watcom build: what `commdrv.def` gives MSVC's linker |
| `ring0.md` | Notes for moving interrupt handling to ring 0, if it is ever needed | | `ring0.md` | Notes for moving interrupt handling to ring 0, if it is ever needed |
| `LICENSE.md` | The MIT License |
## Building ## Building
@ -79,15 +86,30 @@ Two rules matter for anyone changing the code:
DS-relative, so any out-parameter that can point at a stack variable is DS-relative, so any out-parameter that can point at a stack variable is
declared `FAR`. declared `FAR`.
A compile check without MSVC is possible with Open Watcom 2.0 (Win16 target, ### With Open Watcom
small model, SS != DS):
`watcom.mk` builds the same driver with Open Watcom v2's 16-bit Windows
target, with GNU make on Linux. It uses the Open Watcom JoeyLib's installer
sets up (`../../joeylib/toolchains/opt/openWatcom`) unless `WATCOM` names
another; it needs the 16-bit Windows libraries (`lib286/win`).
``` ```
wcc -q -bt=windows -ms -zu -zw -bd -zp2 -2 -w4 commdrv.c cd drv
make -f watcom.mk builds bin/kpcomm.drv
make -f watcom.mk clean removes obj/ and bin/
make -f watcom.mk OBJ=DIR BIN=DIR builds somewhere else
``` ```
Expect W200 "referenced but never assigned" warnings for variables set The flags match the MSVC build's (see `watcom.mk`), with no stack probes
inside `_asm` blocks; Watcom does not see those assignments. (`-s`: Watcom adds them by default). `kpcomm.lnk` carries `commdrv.def`'s
module name, description, fixed segments and export ordinals; the sources'
`_export` exports the entry points too, which wlink's warning W1121 reports
and the link file turns off. The W200 "referenced but never assigned"
warnings for variables set inside `_asm` blocks are turned off as well
(`-wcd=200`): Watcom does not see those assignments, and the code it
generates for them is right (they are memory operands). JoeyLib's installer
builds the driver this way (its `kpcomm` component), into its own build
tree.
## Installing ## Installing
@ -576,6 +598,13 @@ disabled.
## Verification checklist ## Verification checklist
Confirmed in emulation (2026-10-12): an Open Watcom build on Windows for
Workgroups 3.11 under DOSBox Staging, through JoeyLib's Win16 port and its
gates. COM1 opens and closes (item 4, COM1 only), and 16 KB go out and come
back in order at the full line rate at 57600 and at 115200 through
`KPCBR_115200` (items 3 and 6, without flow control and without other load);
Windows' own COMM.DRV refuses `KPCBR_115200`, as it should.
Not yet confirmed on hardware with an MSVC 1.52 build: Not yet confirmed on hardware with an MSVC 1.52 build:
1. **Build.** It compiles and links cleanly under MSVC 1.52, including 1. **Build.** It compiles and links cleanly under MSVC 1.52, including
@ -629,3 +658,26 @@ Not yet confirmed on hardware with an MSVC 1.52 build:
`COMMDRV30`): https://jeffpar.github.io/kbarchive/kb/080/Q80901/ `COMMDRV30`): https://jeffpar.github.io/kbarchive/kb/080/Q80901/
- KB Q83449, Windows 3.1 serial communications Q&A - KB Q83449, Windows 3.1 serial communications Q&A
- KB Q101417, the MSR shadow at offset 35 of the ComDEB - KB Q101417, the MSR shadow at offset 35 of the ComDEB
## License
KPCOMM is distributed under the MIT License (`LICENSE.md`): it may be used,
changed and shipped, alone or with a program, as source or as the built
driver, as long as the copyright and permission notice go with it. The
license covers this folder; the rest of the repository is not under it.
Built with Open Watcom (`watcom.mk`), the driver also carries Open Watcom
code (its DLL start-up and C library helpers), and Open Watcom's license
(the Sybase Open Watcom Public License, section 2.2(d)) asks for a notice,
in the driver and in its documentation, that the source of that code is
available and where. The built `kpcomm.drv` carries the notice (never
shown); a program that ships it puts this line in its documentation:
```
This software contains code from Open Watcom. Its source code is available
under the terms of the Sybase Open Watcom Public License version 1.0 from
https://github.com/open-watcom/open-watcom-v2
```
The MSVC build carries none of Open Watcom's code.

View file

@ -139,6 +139,21 @@ PortStateT ports[MAX_PORTS]; // One per COM port, indexed by cid; s
volatile bool portsSuspended = false; // Set while a DOS application owns the hardware volatile bool portsSuspended = false; // Set while a DOS application owns the hardware
static uint16_t biosSelector = 0; // DPMI selector for segment 0040h (0 = not created yet) static uint16_t biosSelector = 0; // DPMI selector for segment 0040h (0 = not created yet)
#ifdef __WATCOMC__
// -----------------------------------------------------------------------
// Open Watcom's notice
//
// Open Watcom's license (the Sybase Open Watcom Public License, section
// 2.2(d)) asks for a notice, in the driver and in its documentation, that
// the source of the Open Watcom code it carries (its DLL start-up and C
// library helpers) is available, and where. This is the driver's copy,
// never shown; it is not static, so the compiler keeps it although nothing
// reads it. README.md gives the same text for the documentation. The
// MSVC build carries none of Open Watcom's code.
// -----------------------------------------------------------------------
const char owplNotice[] = "This software contains code from Open Watcom. Its source code is available under the terms of the Sybase Open Watcom Public License version 1.0 from https://github.com/open-watcom/open-watcom-v2";
#endif
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// addErrors - Record CE_* bits from application context // addErrors - Record CE_* bits from application context

18
drv/kpcomm.lnk Normal file
View file

@ -0,0 +1,18 @@
# kpcomm.lnk -- wlink directives for KPCOMM.DRV built with Open Watcom
# (watcom.mk): what commdrv.def gives MSVC's linker. The module name stays
# COMM, as USER.EXE imports the driver by that name, and the entry points
# keep the stock driver's ordinals. Code and data are fixed and preloaded.
# The sources' _export exports the entry points too (W1121, off): the
# ordinals come from here.
system windows_dll
disable 1121
option modname=COMM
option description 'KPCOMM -- High-Speed Serial Communications Driver'
option heapsize=1024
segment type code preload fixed
segment type data preload fixed
export INICOM.1, SETCOM.2, SETQUE.3, RECCOM.4, SNDCOM.5, CTX.6, TRMCOM.7, STACOM.8
export CEXTFCN.9, CFLUSH.10, CEVT.11, CEVTGET.12, CSETBRK.13, CCLRBRK.14, GETDCB.15
export WEP.16 resident
export SUSPENDOPENCOMMPORTS.17, REACTIVATEOPENCOMMPORTS.18, COMMWRITESTRING.19, READCOMMSTRING.20
export ENABLENOTIFICATION.100, COMMNOTIFYWNDPROC.101

44
drv/watcom.mk Normal file
View file

@ -0,0 +1,44 @@
# watcom.mk -- KPCOMM.DRV built on Linux with Open Watcom v2's 16-bit
# Windows target, for hosts without MSVC 1.52 (the makefile, for NMAKE, is
# the MSVC build). Uses the Open Watcom JoeyLib's installer sets up, unless
# WATCOM names another.
#
# make -f watcom.mk bin/kpcomm.drv
# make -f watcom.mk clean remove obj/ and bin/
# make -f watcom.mk OBJ=DIR BIN=DIR build somewhere else
#
# Compiler flags, as the MSVC build's: Windows target (-bt=windows) DLL
# (-bd), small model with SS != DS (-ms -zu), Windows prolog for exported
# functions (-zw), no stack probes (-s), 286 code (-2), structures packed
# on 2 bytes (-zp2), all warnings (-w4). The _asm blocks set variables
# Watcom cannot see set (W200), so those warnings are off (-wcd=200);
# kpcomm.lnk is commdrv.def for wlink.
WATCOM ?= $(abspath $(CURDIR)/../../joeylib/toolchains/opt/openWatcom)
export WATCOM
export PATH := $(WATCOM)/binl64:$(PATH)
CC := wcc
LINK := wlink
CFLAGS := -q -bt=windows -bd -ms -zu -zw -s -2 -zp2 -os -w4 -wcd=200 -we -i=$(WATCOM)/h -i=$(WATCOM)/h/win
OBJ ?= obj
BIN ?= bin
TARGET := $(BIN)/kpcomm.drv
OBJS := $(OBJ)/commdrv.obj $(OBJ)/isr.obj $(OBJ)/lpt.obj
all: $(TARGET)
$(OBJ)/%.obj: %.c commdrv.h watcom.mk | $(OBJ)
$(CC) $(CFLAGS) -fo=$@ $<
$(TARGET): $(OBJS) kpcomm.lnk | $(BIN)
$(LINK) option quiet @kpcomm.lnk name $@ $(foreach o,$(OBJS),file $(o)) option map=$(OBJ)/kpcomm.map
$(OBJ) $(BIN):
mkdir -p $@
clean:
rm -rf $(OBJ) $(BIN)
.PHONY: all clean