├── .gitignore ├── CPNET-registry.md ├── Makefile ├── README.md ├── contrib ├── CpnetSerialServer.jar ├── CpnetSocketServer.jar └── serialserver ├── dist ├── ccp.spr ├── cpnetldr.com ├── cpnetsts.com ├── dskreset.com ├── endlist.com ├── help │ ├── README │ ├── cpm2net.hlp │ ├── cpm3net.hlp │ ├── cpnet12.hlp │ ├── cpnet3.hlp │ └── help.com ├── local.com ├── login.com ├── logoff.com ├── mail.com ├── mpm │ ├── Makefile │ ├── app_note_01.txt │ ├── app_note_02.txt │ ├── app_note_03.txt │ ├── netwrkif.asm │ ├── server.asm │ ├── serverx.asm │ ├── ulcif.asm │ └── ulcnios.asm ├── ndos.spr ├── network.com ├── pipnet.com ├── src │ ├── Makefile │ ├── ccp.asm │ ├── cpbdos.asm │ ├── cpbios.asm │ ├── cpndos.asm │ ├── cpnetldr.asm │ ├── cpnios.asm │ ├── cpnos.asm │ └── ndos.asm ├── vcpm │ ├── gencom.com │ ├── hexcom.com │ ├── link.com │ ├── mac.com │ └── rmac.com └── xsubnet.com ├── doc ├── CPNET-WIZ850io.odt ├── CPNET-WIZ850io.pdf ├── CpnetSerialServer.odt ├── CpnetSerialServer.pdf ├── CpnetServers.odg ├── CpnetServers.pdf ├── CpnetSocketServer.odt ├── CpnetSocketServer.pdf ├── dri-cpnet.odt └── dri-cpnet.pdf ├── md ├── BUILD.md ├── CPNET-Z80.md ├── CPNET12.md ├── CPNET3.md ├── DEVEL.md ├── DUO.md ├── FT245R.md ├── H8XSPI.md ├── INS8250.md ├── KAYPRO.md ├── MINZ.md ├── MPMserver.md ├── MT011.md ├── RC-SIOB.md ├── RUN-RC2014.md ├── SER-DRI.md ├── SERIAL.md ├── USB1232H.md ├── VCPNET.md ├── W5500.md └── Z180CSIO.md ├── src ├── bnkntsrv.asm ├── cfgnwif.lib ├── config.lib ├── cpnboot.asm ├── cpnldr-w.asm ├── duo │ ├── config.lib │ ├── makevars │ └── platform.asm ├── ft245r │ ├── chrio.asm │ ├── config.lib │ └── platform.asm ├── gm.cpnet.asm ├── h8xspi │ ├── config.lib │ ├── makevars │ └── platform.asm ├── ins8250 │ ├── chrio.asm │ ├── config.lib │ └── platform.asm ├── kaypro │ ├── chrio.asm │ ├── config.lib │ └── platform.asm ├── libcpnet.asm ├── libnvram.asm ├── minz │ ├── chrio.asm │ ├── config.lib │ ├── makevars │ └── platform.asm ├── mt011 │ ├── config.lib │ ├── makevars │ └── platform.asm ├── ndos3.asm ├── ndos3dup.asm ├── ndos3wiz.asm ├── netboot.asm ├── netdown.asm ├── netstat.asm ├── ntpdate.asm ├── ntwrkrcv.asm ├── null │ └── config.lib ├── nvram.asm ├── rc-siob │ ├── chrio.asm │ ├── config.lib │ └── platform.asm ├── rdate.asm ├── resntsrv.asm ├── rsxls.asm ├── rsxrm.asm ├── ser-dri │ ├── config.lib │ ├── makevars │ └── snios.asm ├── serial │ ├── config.lib │ ├── makevars │ └── snios.asm ├── servers.asm ├── snios000.asm ├── snios12.asm ├── srvprot.asm ├── srvstart.asm ├── srvstat.asm ├── srvstop.asm ├── tr.asm ├── usb1232 │ ├── chrio.asm │ ├── config.lib │ └── platform.asm ├── vcpnet │ ├── config.lib │ ├── platform.asm │ └── snios.asm ├── w5500 │ ├── config.lib │ ├── libwiznt.asm │ ├── makevars │ ├── nios.asm │ ├── snios.asm │ ├── wizcfg.asm │ ├── wizdbg.asm │ └── wiztest.asm ├── w5500c │ ├── config.lib │ ├── libwiznt.asm │ ├── makevars │ ├── snios.asm │ ├── wizcfg.asm │ └── wizdbg.asm ├── z180.lib ├── z180csio │ ├── config.lib │ └── platform.asm └── z80.lib ├── tools ├── VirtualCpm.jar ├── vcpm └── vcpmrc └── util ├── nvram.h └── wizcfg.c /.gitignore: -------------------------------------------------------------------------------- 1 | bld/ 2 | dist/src/*.com 3 | dist/src/*.sym 4 | dist/src/*.prn 5 | dist/src/*.rel 6 | dist/src/*.hex 7 | -------------------------------------------------------------------------------- /CPNET-registry.md: -------------------------------------------------------------------------------- 1 | **CP/NET Node ID conventions** 2 | 3 | 1. Node ID 0xFF is designated by CP/NET as the broadcast destination. It is also used internally for an invalid/unconfigured value. It cannot be used as an active node ID. 4 | 1. Node ID 0x00 is reserved for a local CP/NET server. Since this is the default server for CP/NET commands, this provides the maximum convenience for accessing the “primary” local server. This server must not be accessible on the internet (e.g. it’s port must not be exposed, and should not be in the range 0x3100-0x31FF). 5 | 1. Node IDs 0xF0-0xFE are reserved for private networks and should not be used for nodes that interact (are visible) on the internet. They may be used as servers or clients. 6 | 1. Publicly accessible nodes should use TCP/IP port 0x31nn, where ‘nn’ is the hexadecimal node ID. This equates to decimal port numbers 12544-12799. WIZCFG on clients will use this convention for the source port numbers of sockets to servers. 7 | 1. Node IDs 0x01 upward will be registered for servers that are accessible on the internet. These servers will use (listen on) TCP/IP port 0x31nn, where ‘nn’ is the node ID. 8 | 1. Node IDs 0xEF downward will be registered for clients that will access servers on the internet. 9 | 10 | **Registered Node IDs** 11 | 12 | ``` 13 | 00 (private network) Your private primary server 14 | 01 Douglas Miller 96.42.235.153/12545 Serving software updates 15 | C9 Douglas Miller Virtual CP/M 3 Client 16 | EF Norby Test client for WIZ850io bringup 17 | F0-FE (private network) Your private clients and servers 18 | ``` 19 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for cpnet-z80. 2 | # General usage: make NIC=xxx HBA=yyy 3 | # Creates build results in $(BUILD)/$(NIC)/$(HBA) 4 | 5 | # Some default values. 6 | # Use NIC=xxx HBA=yyy on commandline to override. 7 | HBA = h8xspi 8 | NIC = w5500 9 | 10 | # Known NICs: 11 | # w5500 WizNET W5500 via SPI, various modules. 12 | # w5500c WizNET W5500 via z180 CSIO, SC126 13 | # mms77422 Magnolia Microsystems MagNET, ca. 1983, deprecated. 14 | # vcpnet Fictitious device for emulations. 15 | # serial Simple serial protocol for reliable transports. 16 | # ser-dri Original DRI reference serial protocol, error checking/retry. 17 | # W5500 HBAs: 18 | # h8xspi Heathkit SPI to WIZ850io and NVRAM. 19 | # mt011 RC2014 SPI to Featherwing W5500 module. 20 | # z180csio SC126 SPI to W5500 module, NIC=w5500c 21 | # duo Duodyne SPI to WIZ850io and NVRAM. 22 | # Serial protocol HBAs: 23 | # rc-siob RC2014 main serial port 24 | # ins8250 Serial port via INS8250 (or equiv) UART. 25 | # kaypro Kaypro Z80-SIO "serial data" port. 26 | # ft245r FTDI USB fifo adapter. 27 | # Null HBA: 28 | # null Provides no additional dependencies. 29 | 30 | # customize for build host platform 31 | CRLFP = unix2dos 32 | CRLF2 = unix2dos -n 33 | VCPM = vcpm 34 | ZMAC = zmac 35 | 36 | # Output/build directory. 37 | # Override on commandline using BUILD=/some/path. 38 | BUILD = bld 39 | 40 | ############################################################# 41 | # Generally, nothing below here should require customization. 42 | # Furthermore, all the above may be done on the commandline. 43 | ############################################################# 44 | 45 | BLD_TOP = $(BUILD)/$(NIC)/$(HBA) 46 | 47 | BLD_SRC = $(BLD_TOP)/src 48 | BLD_LIB = $(BLD_TOP)/lib 49 | BLD_BIN2 = $(BLD_TOP)/bin/cpnet12 50 | BLD_BIN3 = $(BLD_TOP)/bin/cpnet3 51 | BLD_MPM = $(BLD_TOP)/bin/mpmnet 52 | 53 | # For the 'vcpm' (VirtualCpm.jar) emulation 54 | export CPMDrive_D = $(BLD_SRC) 55 | export CPMDrive_L = $(BLD_LIB) 56 | export CPMDefault = d: 57 | 58 | TARGETS = netstat.com srvstat.com rdate.com tr.com 59 | MPMTARG = 60 | ND3DEP = ndos3dup.com 61 | LIBS = z80.lib config.lib 62 | DIRS = $(BLD_SRC) $(BLD_LIB) $(BLD_BIN2) $(BLD_BIN3) 63 | CPNLDR = dist/cpnetldr.com 64 | SNDEPS = snios.rel 65 | SNLINK = snios 66 | 67 | # Files in dist subdir: 68 | CPNET = cpnetsts.com dskreset.com endlist.com local.com \ 69 | login.com logoff.com mail.com network.com xsubnet.com 70 | CPN2 = ndos.spr ccp.spr cpnetldr.com pipnet.com $(CPNET) 71 | CPN3 = $(CPNET) 72 | XCPN3 = ntpdate.com rsxrm.com rsxls.com netdown.com 73 | XCPN2 = netdown.com 74 | 75 | ALLTARG = cpnet2 cpnet3 76 | 77 | -include src/$(NIC)/makevars 78 | -include src/$(HBA)/makevars 79 | 80 | ifneq ($(MPMTARG),) 81 | DIRS += $(BLD_MPM) 82 | ALLTARG += mpmnet 83 | endif 84 | 85 | .SECONDARY: 86 | 87 | all: $(DIRS) $(addprefix $(BLD_LIB)/,$(LIBS)) $(ALLTARG) 88 | 89 | cpnet2: $(addprefix $(BLD_BIN2)/,$(TARGETS) $(CPN2) snios.spr $(XCPN2)) 90 | 91 | cpnet3: $(addprefix $(BLD_BIN3)/,$(TARGETS) $(CPN3) ndos3.com $(XCPN3)) 92 | 93 | mpmnet: $(addprefix $(BLD_MPM)/,$(MPMTARG) srvstat.com) 94 | 95 | $(BLD_SRC) $(BLD_LIB) $(BLD_BIN2) $(BLD_BIN3) $(BLD_MPM): 96 | @mkdir -p $@ 97 | 98 | $(BLD_LIB)/config.lib: src/config.lib src/$(NIC)/config.lib src/$(HBA)/config.lib 99 | cat $^ | $(CRLFP) >$@ 100 | 101 | $(BLD_LIB)/%: src/% 102 | $(CRLF2) $^ $@ 103 | 104 | $(BLD_BIN3)/%: $(BLD_SRC)/% 105 | cp -v --update $^ $@ 106 | 107 | $(BLD_BIN2)/%: $(BLD_SRC)/% 108 | cp -v --update $^ $@ 109 | 110 | $(BLD_MPM)/%: $(BLD_SRC)/% 111 | cp -v --update $^ $@ 112 | 113 | $(BLD_BIN3)/%: dist/% 114 | cp -v --update $^ $@ 115 | 116 | $(BLD_BIN2)/%: dist/% 117 | cp -v --update $^ $@ 118 | 119 | $(BLD_SRC)/%.asm: src/%.asm 120 | $(CRLF2) $^ $@ 121 | 122 | $(BLD_SRC)/%.asm: src/$(NIC)/%.asm 123 | $(CRLF2) $^ $@ 124 | 125 | $(BLD_SRC)/%.asm: src/$(HBA)/%.asm 126 | $(CRLF2) $^ $@ 127 | 128 | %/wizcfg.com: $(addprefix %/,$(WZCDEPS)) 129 | $(VCPM) link $(WZCLINK)'[oc,nr]' 130 | 131 | %/snios.spr: $(addprefix %/,$(SNDEPS)) %/snios12.rel 132 | $(VCPM) link "snios=snios12,$(SNLINK)[os,nr]" 133 | 134 | %/ndos3wiz.com: %/ndos3wiz.rel %/libwiznt.rel %/libnvram.rel %/libcpnet.rel 135 | $(VCPM) link ndos3wiz,libwiznt,libnvram,libcpnet'[oc,nr]' 136 | 137 | %/ndos3.com: %/ndos3.rel $(addprefix %/,$(SNDEPS)) %/$(ND3DEP) 138 | $(VCPM) link "ndos3.rsx=ndos3,$(SNLINK)[op,nr]" 139 | @cp $*/$(ND3DEP) $*/ndos3.com 140 | $(VCPM) gencom ndos3.com ndos3.rsx 141 | 142 | %/ntpdate.com: %/ntpdate.rel $(addprefix %/,$(SNDEPS)) 143 | $(VCPM) link "ntpdate=ntpdate,$(SNLINK)[oc,nr]" 144 | 145 | %/cpnboot.com: %/cpnboot.rel %/netboot.rel %/platform.rel $(addprefix %/,$(CPBDEPS)) $(addprefix %/,$(SNDEPS)) 146 | $(VCPM) link "cpnboot=cpnboot,netboot,platform$(CPBLINK),$(SNLINK)[oc,nr]" 147 | 148 | $(BLD_BIN2)/cpnetldr.com: $(CPNLDR) 149 | cp -v --update $^ $@ 150 | 151 | %/cpnldr-w.com: %/cpnldr-w.rel %/libwiznt.rel %/libnvram.rel %/libcpnet.rel 152 | $(VCPM) link cpnldr-w,libwiznt,libnvram,libcpnet'[oc,nr]' 153 | 154 | %/netservr.rsp: %/resntsrv.rel 155 | $(VCPM) link netservr.rsp=resntsrv"[os,nr]" 156 | 157 | %/netservr.brs: %/bnkntsrv.rel %/ntwrkrcv.rel %/servers.rel %/nios.rel 158 | $(VCPM) link netservr.brs=bnkntsrv,ntwrkrcv,servers,nios"[os,nr]" 159 | 160 | %/system.dat: %/gm.cpnet.asm 161 | cd $(CPMDrive_D) && \ 162 | $(ZMAC) -o gm.cpnet.cim gm.cpnet.asm && \ 163 | mv gm.cpnet.cim system.dat 164 | 165 | %.com: %.asm 166 | $(VCPM) mac "$(notdir $?)" '$$SZLL' 167 | $(VCPM) hexcom "$(notdir $*)" 168 | 169 | %.rel: %.asm 170 | $(VCPM) rmac "$(notdir $?)" '$$SZLL' 171 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # cpnet-z80 2 | [CPNET-Z80](md/CPNET-Z80.md) is a port/implementation of DRI CP/NET with drivers for the following 3 | environments: 4 | 5 | NIC | HBA | Description 6 | ----|-----|------------ 7 | [w5500](md/W5500.md) | [h8xspi](md/H8XSPI.md) | Heathkit H8/H89 with WIZ850io and NVRAM 8 | [w5500](md/W5500.md) | [mt011](md/MT011.md) | RC2014 with MT011 and Featherwing W5500 9 | [w5500](md/W5500.md) | [duo](md/DUO.md) | Duodyne with Disk-I/O, with WIZ850io and NVRAM 10 | [w5500c](md/W5500.md) | [z180csio](md/Z180CSIO.md) | SC126 Z180 with W5500 breakout board 11 | [serial](md/SERIAL.md) | [ft245r](md/FT245R.md) | Serial over FT245R USB module, simple protocol 12 | [serial](md/SERIAL.md) | [USB1232](md/USB1232H.md) | Serial over USB1232H module, simple protocol 13 | [serial](md/SERIAL.md) | [rc-siob](md/RC-SIOB.md) | Serial support via FTDI cable for SC131 14 | [ser-dri](md/SER-DRI.md) | [minz](md/MINZ.md) | Serial over MinZ-U ASCI1 port, DRI protocol 15 | [ser-dri](md/SER-DRI.md) | [ft245r](md/FT245R.md) | Serial over FT245R USB module, DRI protocol 16 | [ser-dri](md/SER-DRI.md) | [ins8250](md/INS8250.md) | DRI serial protocol over INS8250-like UART 17 | [ser-dri](md/SER-DRI.md) | [kaypro](md/KAYPRO.md) | DRI serial protocol on Kaypro Z80-SIO UART 18 | [vcpnet](md/VCPNET.md) | null | Virtual CP/NET pseudo device 19 | 20 | An [MP/M Server](md/MPMserver.md) implementation is also available. 21 | Currently, only the W5500 NIC builds the MP/M components. 22 | 23 | For the Heathkit H8/H89, the board is the H8xSPI with the 24 | [WIZ850io](https://www.wiznet.io/product-item/wiz850io/) W5500 module 25 | and includes an NVRAM chip as well, 26 | used for storing network configuration. 27 | See [H8_CP_NET_SPI](http://koyado.com/Heathkit/H8_CP_NET_SPI_Wiznet_Network.html). 28 | 29 | The file [doc/dri-cpnet.pdf](/doc/dri-cpnet.pdf) 30 | contains the original Digital Research CP/NET documentation, 31 | modified to add the CP/M 3 extensions. 32 | 33 | The file [doc/CPNET-WIZ850io.pdf](/doc/CPNET-WIZ850io.pdf) 34 | contains specific instructions for the Heathkit H8/H89 35 | CP/NET environment, but it also contains a lot of general information about how 36 | CP/NET is being used on a W5500-based TCP/IP network. 37 | 38 | There are also server implementations in the 'contrib' directory, with 39 | documention in 'doc'. 40 | 41 | To avoid conflicts of CP/NET node IDs on the internet, a registry scheme is 42 | proposed in [CPNET-registry.md](/CPNET-registry.md). 43 | 44 | ## Prebuilt packages 45 | 46 | Prebuilt packages for the Heathkit H8/H89 W5500 are available 47 | [here](http://sebhc.durgadas.com/mms89/wiz850io/). 48 | 49 | Prebuilt packages for the Kaypro (Serial Data port) are available 50 | [here](http://sebhc.durgadas.com/kaypro/). 51 | 52 | Prebuilt packages for other architectures are TBD. 53 | 54 | ## [Running CP/NET3](md/CPNET3.md) 55 | 56 | ## [Running CP/NET 1.2](md/CPNET12.md) 57 | 58 | ## How to [build](md/BUILD.md) your own. 59 | 60 | ## How to [develop](md/DEVEL.md) a new platform. 61 | 62 | ### [Running CP/NET](md/RUN-RC2014.md) on RC2014. 63 | 64 | ## CP/NET on SC131 and friends (serial port) * 65 | 66 | The SC131 and for that matter all Z180 solutions that use the onboard ACSI sio ports will run into trouble with the 67 | missing modem control signals for port b. They are simply not supplied to the out side world, (sort of), the important 68 | one is hijacked by the SD driver (RomWBW) and the way the board is layed out. 69 | 70 | Good news is it works at 57600, so to run cpnet on your SC131, do the following. 71 | Install and build as above. make NIC=serial HBA=rc-siob 72 | 73 | Your next test is to configure the B port as follows. b:mode com1: 57600,n,8,1 74 | 75 | Then set up the ~/cpnet-z80/contrib/CpnetSerialServer config file. 76 | ``` 77 | cpnet_tty=/dev/ttyUSB2 57600 78 | cpnet_proto=BINARY 79 | cpnet_cid=01 80 | cpnet_server03=HostFileBdos 81 | ``` 82 | 83 | Start the server with ./serialserver conf=config 84 | then start the CP/M network with the following. 85 | ``` 86 | b:pip a:=c:ccp.spr 87 | cpnetldr 88 | network k:=c:[3] 89 | ``` 90 | 91 | See server documentation for further details. 92 | 93 | 94 | From here you can copy/run/what ever the files on your pseudo drives. You can also 95 | copy/install from the pseudo drive. In addition any file you copy to the pseudo drive 96 | on your server system will be accessable instantly on your CP/M system. 97 | 98 | -------------------------------------------------------------------------------- /contrib/CpnetSerialServer.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/durgadas311/cpnet-z80/20e06f4badb7dda7af6c7102dab0e91611056da7/contrib/CpnetSerialServer.jar -------------------------------------------------------------------------------- /contrib/CpnetSocketServer.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/durgadas311/cpnet-z80/20e06f4badb7dda7af6c7102dab0e91611056da7/contrib/CpnetSocketServer.jar -------------------------------------------------------------------------------- /contrib/serialserver: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Wrapper script to startup CpnetSerialServer on Linux, possibly MAC 3 | # Note: jSerialComm seems sensitive to versions. 4 | # Try newer versions at your own risk. 5 | 6 | CLASS=CpnetSerialServer 7 | JAR1=${CLASS}.jar # location of the server JAR 8 | JAR2=${HOME}/Downloads/jSerialComm-2.6.2.jar # location of jSerial 9 | 10 | if [[ -L ${JAR2} ]]; then 11 | JAR2=$(readlink -f ${JAR2}) 12 | fi 13 | if [[ ! -f ${JAR1} ]]; then 14 | echo "Missing: ${JAR1}" >&2 15 | exit 1 16 | fi 17 | if [[ ! -f ${JAR2} ]]; then 18 | echo "Missing: ${JAR2}" >&2 19 | exit 1 20 | fi 21 | 22 | java -cp ${JAR1}:${JAR2} ${CLASS} "${@}" 23 | -------------------------------------------------------------------------------- /dist/ccp.spr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/durgadas311/cpnet-z80/20e06f4badb7dda7af6c7102dab0e91611056da7/dist/ccp.spr -------------------------------------------------------------------------------- /dist/cpnetldr.com: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/durgadas311/cpnet-z80/20e06f4badb7dda7af6c7102dab0e91611056da7/dist/cpnetldr.com -------------------------------------------------------------------------------- /dist/cpnetsts.com: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/durgadas311/cpnet-z80/20e06f4badb7dda7af6c7102dab0e91611056da7/dist/cpnetsts.com -------------------------------------------------------------------------------- /dist/dskreset.com: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/durgadas311/cpnet-z80/20e06f4badb7dda7af6c7102dab0e91611056da7/dist/dskreset.com -------------------------------------------------------------------------------- /dist/endlist.com: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/durgadas311/cpnet-z80/20e06f4badb7dda7af6c7102dab0e91611056da7/dist/endlist.com -------------------------------------------------------------------------------- /dist/help/README: -------------------------------------------------------------------------------- 1 | This version of HELP.COM works on any version of CP/M (2.0 and greater). 2 | 3 | Rename the desired topic collection to HELP.HLP on the target system. 4 | 5 | cpm2net.hlp CP/M 2.2 basic system with CP/NET 1.2 6 | cpnet12.hlp CP/NET 1.2 help only 7 | cpm3net.hlp CP/M 3 basic system with CP/NET 3 8 | cpnet3.hlp CP/NET 3 help only 9 | -------------------------------------------------------------------------------- /dist/help/cpm2net.hlp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/durgadas311/cpnet-z80/20e06f4badb7dda7af6c7102dab0e91611056da7/dist/help/cpm2net.hlp -------------------------------------------------------------------------------- /dist/help/cpm3net.hlp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/durgadas311/cpnet-z80/20e06f4badb7dda7af6c7102dab0e91611056da7/dist/help/cpm3net.hlp -------------------------------------------------------------------------------- /dist/help/help.com: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/durgadas311/cpnet-z80/20e06f4badb7dda7af6c7102dab0e91611056da7/dist/help/help.com -------------------------------------------------------------------------------- /dist/local.com: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/durgadas311/cpnet-z80/20e06f4badb7dda7af6c7102dab0e91611056da7/dist/local.com -------------------------------------------------------------------------------- /dist/login.com: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/durgadas311/cpnet-z80/20e06f4badb7dda7af6c7102dab0e91611056da7/dist/login.com -------------------------------------------------------------------------------- /dist/logoff.com: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/durgadas311/cpnet-z80/20e06f4badb7dda7af6c7102dab0e91611056da7/dist/logoff.com -------------------------------------------------------------------------------- /dist/mail.com: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/durgadas311/cpnet-z80/20e06f4badb7dda7af6c7102dab0e91611056da7/dist/mail.com -------------------------------------------------------------------------------- /dist/mpm/Makefile: -------------------------------------------------------------------------------- 1 | # For the 'vcpm' (VirtualCpm.jar) emulation 2 | export CPMDrive_D = $(PWD) 3 | export CPMDrive_E = $(PWD)/tmp 4 | export CPMDefault = d: 5 | 6 | .SECONDARY: 7 | 8 | CRLFP = unix2dos 9 | CRLF2 = unix2dos -n 10 | VCPM = vcpm 11 | 12 | all: server.rsp 13 | 14 | tmp/%.asm: %.asm 15 | @mkdir -p tmp 16 | unix2dos -n $^ $@ 17 | 18 | %.rsp: %.rel 19 | $(VCPM) link $@=$*"[os,nr]" 20 | 21 | %.rel: tmp/%.asm 22 | $(VCPM) rmac e:$* '$$RDPDSZ' 23 | -------------------------------------------------------------------------------- /dist/mpm/app_note_01.txt: -------------------------------------------------------------------------------- 1 | CP/NET V1.2 2 | Application Note 01, 11/11/82 3 | Writing Improved NETWRKIF Modules for CP/NET 4 | 5 | Copyright (C) 1982 by Digital Research 6 | CP/NET is a registered trademark of Digital Research. 7 | MP/M-II is a trademark of Digital Research. 8 | Compiled November 1982 9 | 10 | (Retyped by Emmanuel ROCHE.) 11 | 12 | Applicable Products and Version Numbers: CP/NET V1.2 13 | 14 | Use a small patch to the SERVER.RSP module to write a NETWRKIF module that has 15 | marked space and performance efficiencies. 16 | 17 | The patch causes all of the SERVER processes to write their output to the same 18 | queue, NtwrkQ00: 19 | 20 | 0A>pip server.sav=server.rsp 21 | 0A>ddt server.rsp 22 | [MP/M II] DDT VERS 2.0 23 | NEXT PC 24 | 0D00 0100 25 | -A0543 26 | 0543 mvi a,30 27 | 0545 jmp 34F 28 | 0548 . 29 | -Iserver.rsp 30 | -W18 31 | -G0 32 | 0A> 33 | 34 | The patched SERVER.RSP must now be GENSYSed into MP/M-II. 35 | 36 | With this patch installed, a server architecture is possible that requires 37 | only 2 non-reentrant NETWRKIF processes: one queue to the output NETWRKIF 38 | process, and one input queue for every server process on the host computer. 39 | The relationship between queues and processes is shown in the following 40 | figure. 41 | 42 | ********** +----------+ 43 | +--->* NtwrkQI0 *--->| SERVR0PR |--->+ 44 | | ********** +----------+ | 45 | | | 46 | +----------+ ********** +----------+ | 47 | | NTWRKIN |--->* NtwrkQI1 *--->| SERVR1PR |--->+ 48 | +----------+ ********** +----------+ | 49 | | | 50 | | ********** +----------+ | 51 | +--->* NtwrkQI2 *--->| SERVR2PR |--->+ 52 | ********** +----------+ | 53 | | 54 | +----------+ | 55 | | NTWRKOUT | ... ... | 56 | +----------+ | 57 | ^ | 58 | | | 59 | ********** | 60 | * NtwrkQO0 * ... ... | 61 | ********** | 62 | ^ | 63 | | | 64 | +----------------------<-------------------+ 65 | 66 | Figure 1. Server architecture 67 | 68 | The process NTWRKIN handles all network input and routes messages from the 69 | network interface to the appropriate server process through an input queue. 70 | The process NTWRKOUT reads the single output queue and sends a response 71 | message back out over the network. 72 | 73 | Minimizing the number of Process Descriptors (PD) and queues improves MP/M-II 74 | dispatch time, because the process and queue threads are shorter and take less 75 | time to traverse. Less common memory is required, because fewer Process 76 | Descriptors and Queue Control Block (QCB) are needed. 77 | 78 | Enough buffer space must be allocated to the output queue, so that a pointer 79 | to a message from every server process in the system can be written 80 | simultaneously, or the NETWRKIF module can limit the number of messages being 81 | worked on at any one time, and size the queue buffer accordingly. This process 82 | involves a small amount of buffer management analogous to the MX queue 83 | demonstrated in Appendix E of the "CP/NET Network Operating System Reference 84 | Manual". 85 | 86 | This type of server architecture is demonstrate by the example programs in 87 | Appendices F and G. 88 | -------------------------------------------------------------------------------- /dist/mpm/app_note_03.txt: -------------------------------------------------------------------------------- 1 | CP/NET V1.2 2 | Application Note 03, 11/11/82 3 | Changing the CP/NET and CP/NOS Version Number 4 | 5 | Copyright (C) 1982 by Digital Research 6 | CP/M and CP/NET are registered trademarks of Digital Research. 7 | CB-80, CP/M Plus, CP/NOS, MP/M and MP/M-II 8 | are trademarks of Digital Research. 9 | Compiled November 1982 10 | 11 | (Retyped by Emmanuel ROCHE.) 12 | 13 | Applicable Products and Version Numbers: CP/NET V1.2 14 | 15 | Function 12, Return Version Number, returns a 2-byte value in register HL. The 16 | low-order byte contains the release number. This number is set to 22 17 | hexadecimal if CP/NET is running under CP/M Version 2.2. The high-order byte 18 | specifies the operating system type: 0=CP/M, 1=MP/M-II, and 2=CP/NET or 19 | CP/NOS. 20 | 21 | Many application programs specifically check to ensure that they are running 22 | under either CP/M or MP/M-II. They might fail when run under CP/NET or CP/NOS. 23 | Another problem arises when applications check the release number before 24 | performing certain shared file operations. For example, CB-80 requires a 25 | hexadecimal 30 or greater in the release number before opening a file in 26 | shared mode. 27 | 28 | The following patch causes Function 12 to return any desired version number 29 | when the NDOS has been loaded for CP/NET operations. 30 | 31 | A>ren ndos.sav=ndos.spr 32 | A>ddt ndos.spr 33 | DDT VERS 2.2 34 | NEXT PC 35 | 0F80 0100 36 | -A0AC0 37 | 0AC0 lxi h,(version number) 38 | 0AC3 nop 39 | 0AC4 . 40 | -G0 41 | A>save 15 ndos.spr 42 | 43 | where (version number) is an hexadecimal value, chosen to support a desired 44 | application: 45 | 46 | 0022 makes the system look like unmodified CP/M 2.2 47 | 0130 makes the system look like MP/M-II 48 | 0230 CP/NET, but with a version number that allows 49 | CB-80 to run using shared files. 50 | 51 | This same patch can be applied to CP/NOS. Link CP/NOS as you would to produce 52 | a COM file. The patch is made to the COM file before converting it to ROM, or 53 | to a form that you can download. 54 | 55 | A>ren cpnos.sav=cpnos.com 56 | A>ddt cpnos.com 57 | DDT VERS 2.2 58 | NEXT PC 59 | 0F80 0100 60 | -A082E 61 | 082E lxi h,(version number) 62 | 082F nop 63 | 0830 . 64 | -G0 65 | A>save xx cpnos.com 66 | 67 | The size of the COM file depends on the size of your CPNIOS and CPBIOS 68 | modules. Save the correct number of pages after performing the patch. 69 | 70 | Because this patch makes the CP/NET or CP/NOS system have the same version 71 | number as a CP/M system, applications that specifically check for a CP/NET 72 | system might now function improperly. Applications that require the system to 73 | look like MP/M-II might not work when the system is configured to look like 74 | CP/M. All CP/NET utilities check to make sure that the operating system type 75 | is set to 2, for CP/NET. It might be useful to write a set of programs that 76 | dynamically perform the patching process. This allows a user to invoke the 77 | appropriate version number before running an application. 78 | 79 | When running either CP/NET or CP/NOS with a version number of 30 or greater, 80 | make sure that the application makes no calls to MP/M-II or CP/M Plus 81 | functions not supported by CP/NET. Examples of such functions are queue 82 | handling calls, attach and detach functions, multisector I/O, and memory 83 | management. Invoking such functions results in a program error. 84 | -------------------------------------------------------------------------------- /dist/ndos.spr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/durgadas311/cpnet-z80/20e06f4badb7dda7af6c7102dab0e91611056da7/dist/ndos.spr -------------------------------------------------------------------------------- /dist/network.com: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/durgadas311/cpnet-z80/20e06f4badb7dda7af6c7102dab0e91611056da7/dist/network.com -------------------------------------------------------------------------------- /dist/pipnet.com: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/durgadas311/cpnet-z80/20e06f4badb7dda7af6c7102dab0e91611056da7/dist/pipnet.com -------------------------------------------------------------------------------- /dist/src/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for CP/NET 1.2 dist components 2 | # TODO: create CCP.ASM 3 | # Invoked from dist/src 4 | 5 | BUILD = ../../bld 6 | 7 | 8 | BLD_TOP = $(BUILD)/dist 9 | 10 | BLD_SRC = $(BLD_TOP)/src 11 | BLD_LIB = $(BLD_TOP)/lib 12 | BLD_BIN = $(BLD_TOP)/bin 13 | 14 | # For the 'vcpm' (VirtualCpm.jar) emulation 15 | export CPMDrive_D = $(BLD_SRC) 16 | export CPMDrive_L = $(BLD_LIB) 17 | export CPMDefault = d: 18 | 19 | LIBS = z80.lib config.lib 20 | DIRS = $(BLD_SRC) $(BLD_LIB) $(BLD_BIN) 21 | 22 | TARGETS = cpnetldr.com ndos.spr ccp.spr 23 | 24 | .SECONDARY: 25 | 26 | # customize for build host platform 27 | CRLFP = unix2dos 28 | CRLF2 = unix2dos -n 29 | VCPM = vcpm 30 | 31 | all: $(DIRS) $(addprefix $(BLD_LIB)/,$(LIBS)) \ 32 | $(addprefix $(BLD_SRC)/,$(TARGETS)) 33 | 34 | $(BLD_SRC) $(BLD_LIB) $(BLD_BIN): 35 | @mkdir -p $@ 36 | 37 | $(BLD_LIB)/%: ../../src/% 38 | $(CRLF2) $^ $@ 39 | 40 | $(BLD_SRC)/%.asm: %.asm 41 | $(CRLF2) $^ $@ 42 | 43 | %/ccp.spr: %/ccp.rel 44 | $(VCPM) link "ccp[os,nr]" 45 | 46 | %/ndos.spr: %/ndos.rel 47 | $(VCPM) link "ndos[os,nr]" 48 | 49 | # An example, really. For ROM at F000. 50 | #cpnos.com: cpnos.rel cpndos.rel cpbdos.rel cpbios.rel cpnios.rel 51 | # vcpm link "cpnos,cpndos,cpnios,cpbdos,cpbios[LF000,DEC00]" 52 | 53 | %.com: %.asm 54 | $(VCPM) mac "$(notdir $?)" '$$SZLL' 55 | $(VCPM) hexcom "$(notdir $*)" 56 | 57 | %.rel: %.asm 58 | $(VCPM) rmac "$(notdir $?)" '$$SZLL' 59 | -------------------------------------------------------------------------------- /dist/src/cpbdos.asm: -------------------------------------------------------------------------------- 1 | ; diskless BDOS for CP/NOS - functions 0-12 only. 2 | ; may be ROMable 3 | 4 | extrn ndosrl 5 | public bdos,bdosds 6 | 7 | reboot equ 0000h 8 | ioloc equ 0003h 9 | bdosa equ 0006h 10 | 11 | ; TODO: how do we know BIOS is at ndosrl+0x300? 12 | ; Offsets are for ndosrl 13 | wbootf equ 0303h 14 | constf equ 0306h 15 | coninf equ 0309h 16 | conoutf equ 030ch 17 | listf equ 030fh 18 | 19 | cr equ 13 20 | lf equ 10 21 | tab equ 9 22 | bs equ 8 23 | xoff equ 13h 24 | ctlc equ 3 25 | ctle equ 5 26 | ctlp equ 10h 27 | ctlr equ 12h 28 | ctlu equ 15h 29 | ctlx equ 18h 30 | rubout equ 7fh 31 | 32 | 33 | cseg 34 | db 0,0,0,0,0,0 ; serial number 35 | bdos: jmp bdose 36 | 37 | db 'COPR. ''78-''82 DRI' 38 | 39 | bdose: xchg 40 | shld info 41 | xchg 42 | lxi h,0 43 | shld aret 44 | dad sp 45 | shld entsp 46 | lxi sp,lstack 47 | lxi h,goback 48 | push h 49 | mov a,c 50 | cpi nfuncs 51 | rnc 52 | mov c,e 53 | lxi h,functab 54 | mov e,a 55 | mvi d,0 56 | dad d 57 | dad d 58 | mov e,m 59 | inx h 60 | mov d,m 61 | lhld info 62 | xchg 63 | pchl 64 | 65 | functab: 66 | dw ndosrl+wbootf 67 | dw func1 68 | dw tabout 69 | dw func3 70 | dw ndosrl+conoutf 71 | dw ndosrl+listf 72 | dw func6 73 | dw func7 74 | dw func8 75 | dw func9 76 | dw read 77 | dw func11 78 | dw func12 79 | nfuncs equ ($-functab)/2 80 | 81 | conin: lxi h,kbchar 82 | mov a,m 83 | mvi m,0 84 | ora a 85 | rnz 86 | jmp ndosrl+coninf 87 | 88 | conech: call conin 89 | call echoc 90 | rc 91 | push psw 92 | mov c,a 93 | call tabout 94 | pop psw 95 | ret 96 | 97 | echoc: cpi cr 98 | rz 99 | cpi lf 100 | rz 101 | cpi tab 102 | rz 103 | cpi bs 104 | rz 105 | cpi ' ' 106 | ret 107 | 108 | conbrk: lda kbchar 109 | ora a 110 | jnz conb1 111 | call ndosrl+constf 112 | ani 1 113 | rz 114 | call ndosrl+coninf 115 | cpi xoff 116 | jnz conb0 117 | call ndosrl+coninf 118 | cpi ctlc 119 | jz reboot 120 | xra a 121 | ret 122 | 123 | conb0: sta kbchar 124 | conb1: mvi a,1 125 | ret 126 | 127 | conout: lda compcol 128 | ora a 129 | jnz compout 130 | push b 131 | call conbrk 132 | pop b 133 | push b 134 | call ndosrl+conoutf 135 | pop b 136 | push b 137 | lda listcp 138 | ora a 139 | cnz ndosrl+listf 140 | pop b 141 | compout: 142 | mov a,c 143 | lxi h,column 144 | cpi rubout 145 | rz 146 | inr m 147 | cpi ' ' 148 | rnc 149 | dcr m 150 | mov a,m 151 | ora a 152 | rz 153 | mov a,c 154 | cpi bs 155 | jnz notbacksp 156 | dcr m 157 | ret 158 | notbacksp: 159 | cpi lf 160 | rnz 161 | mvi m,0 162 | ret 163 | 164 | ctlout: 165 | mov a,c 166 | call echoc 167 | jnc tabout 168 | push psw 169 | mvi c,'^' 170 | call conout 171 | pop psw 172 | ori '@' 173 | mov c,a 174 | tabout: 175 | mov a,c 176 | cpi tab 177 | jnz conout 178 | tab0: mvi c,' ' 179 | call conout 180 | lda column 181 | ani 111b 182 | jnz tab0 183 | ret 184 | 185 | backup: call pctlh 186 | mvi c,' ' 187 | call ndosrl+conoutf 188 | pctlh: mvi c,bs 189 | jmp ndosrl+conoutf 190 | 191 | crlfp: mvi c,'#' 192 | call conout 193 | call crlf 194 | crlfp0: lda column 195 | lxi h,strtcol 196 | cmp m 197 | rnc 198 | mvi c,' ' 199 | call conout 200 | jmp crlfp0 201 | 202 | crlf: mvi c,cr 203 | call conout 204 | mvi c,lf 205 | jmp conout 206 | 207 | print: ldax b 208 | cpi '$' 209 | rz 210 | inx b 211 | push b 212 | mov c,a 213 | call tabout 214 | pop b 215 | jmp print 216 | 217 | read: lda column 218 | sta strtcol 219 | lhld info 220 | mov c,m 221 | inx h 222 | push h 223 | mvi b,0 224 | readnx: push b 225 | push h 226 | readn0: call conin 227 | ani 7fh 228 | pop h 229 | pop b 230 | cpi cr 231 | jz readen 232 | cpi lf 233 | jz readen 234 | cpi bs 235 | jnz noth 236 | mov a,b 237 | ora a 238 | jz readnx 239 | dcr b 240 | lda column 241 | sta compcol 242 | jmp linelen 243 | 244 | noth: cpi rubout 245 | jnz notrub 246 | mov a,b 247 | ora a 248 | jz readnx 249 | mov a,m 250 | dcr b 251 | dcx h 252 | jmp rdech1 253 | 254 | notrub: cpi ctle 255 | jnz note 256 | push b 257 | push h 258 | call crlf 259 | xra a 260 | sta strtcol 261 | jmp readn0 262 | note: cpi ctlp 263 | jnz notp 264 | push h 265 | lxi h,listcp 266 | mvi a,1 267 | sub m 268 | mov m,a 269 | pop h 270 | jmp readnx 271 | 272 | notp: cpi ctlx 273 | jnz notx 274 | pop h 275 | backx: lda strtcol 276 | lxi h,column 277 | cmp m 278 | jnc read 279 | dcr m 280 | call backup 281 | jmp backx 282 | notx: cpi ctlu 283 | jnz notu 284 | call crlfp 285 | pop h 286 | jmp read 287 | notu: cpi ctlr 288 | jnz notr 289 | linelen: 290 | push b 291 | call crlfp 292 | pop b 293 | pop h 294 | push h 295 | push b 296 | rep0: mov a,b 297 | ora a 298 | jz rep1 299 | inx h 300 | mov c,m 301 | dcr b 302 | push b 303 | push h 304 | call ctlout 305 | pop h 306 | pop b 307 | jmp rep0 308 | 309 | rep1: push h 310 | lda compcol 311 | ora a 312 | jz readn0 313 | lxi h,column 314 | sub m 315 | sta compcol 316 | backsp: call backup 317 | lxi h,compcol 318 | dcr m 319 | jnz backsp 320 | jmp readn0 321 | 322 | notr: 323 | ;not a ctlr, place into buffer 324 | rdecho: 325 | inx h 326 | mov m,a 327 | inr b 328 | rdech1: push b 329 | push h 330 | mov c,a 331 | call ctlout 332 | pop h 333 | pop b 334 | mov a,m 335 | cpi ctlc 336 | mov a,b 337 | jnz notc 338 | cpi 1 339 | jz reboot 340 | notc: cmp c 341 | jc readnx 342 | readen: pop h 343 | mov m,b 344 | mvi c,cr 345 | jmp conout 346 | 347 | func1: call conech 348 | jmp sta$ret 349 | 350 | func3: call ndosrl+coninf 351 | jmp sta$ret 352 | 353 | func6: mov a,c 354 | inr a 355 | jz dirinp 356 | inr a 357 | jz ndosrl+constf 358 | jmp ndosrl+conoutf 359 | 360 | dirinp: call ndosrl+constf 361 | ora a 362 | jz goback 363 | call ndosrl+coninf 364 | jmp sta$ret 365 | 366 | func7: lda ioloc 367 | jmp sta$ret 368 | 369 | func8: lxi h,ioloc 370 | mov m,c 371 | ret 372 | 373 | func9: xchg 374 | mov c,l 375 | mov b,h 376 | jmp print 377 | 378 | func11: call conbrk 379 | sta$ret: 380 | sta aret 381 | ret 382 | 383 | setlret1: 384 | mvi a,1 385 | jmp sta$ret 386 | 387 | dseg 388 | bdosds: ; area to be zeroed by CPNDOS - must be 61 bytes... 389 | compcol: db 0 390 | strtcol: db 0 391 | column: db 0 392 | listcp: db 0 393 | kbchar: db 0 394 | entsp: ds 2 395 | ds 48 396 | lstack: dw 0 397 | info: ds 2 398 | aret: ds 2 399 | 400 | cseg 401 | func12: mvi a,22h ; CP/M v2.2 402 | jmp sta$ret 403 | 404 | goback: lhld entsp 405 | sphl 406 | lhld aret 407 | mov a,l 408 | mov b,h 409 | ret 410 | 411 | end 412 | -------------------------------------------------------------------------------- /dist/src/cpbios.asm: -------------------------------------------------------------------------------- 1 | title 'BIOS for CP/NOS 1.2' 2 | ; 3 | ; 4 | ; Version 1.1 October, 1981 5 | ; Version 1.2 Beta Test, 08-23-82 6 | ; 7 | vers equ 12 ;version 1.2 8 | ; 9 | ; Copyright (c) 1980, 1981, 1982 10 | ; Digital Research 11 | ; Box 579, Pacific Grove 12 | ; California, 93950 13 | ; 14 | ; 15 | true equ 0ffffh ;value of "true" 16 | false equ not true ;"false" 17 | ; 18 | DSC2 equ false 19 | Altos equ true 20 | ; 21 | ; perform following functions 22 | ; boot cold start 23 | ; wboot (not used under CP/NOS) 24 | ; const console status 25 | ; reg-a = 00 if no character ready 26 | ; reg-a = ff if character ready 27 | ; conin console character in (result in reg-a) 28 | ; conout console character out (char in reg-c) 29 | ; list list out (char in reg-c) 30 | ; 31 | 32 | extrn NDOS ; Network Disk Operating System 33 | extrn BDOS ; Basc Disk Operating System 34 | extrn NDOSRL ; NDOS serial number, BIOS jump table 35 | ; is page aligned at 0300H offset 36 | CSEG 37 | BIOS: 38 | public BIOS 39 | ; jump vector for indiviual routines 40 | jmp boot 41 | wboote: jmp error 42 | jmp const 43 | jmp conin 44 | jmp conout 45 | jmp list 46 | jmp error 47 | jmp error 48 | jmp error 49 | jmp error 50 | jmp error 51 | jmp error 52 | jmp error 53 | jmp error 54 | jmp error 55 | jmp listst ;list status 56 | jmp error 57 | BIOSlen equ $-BIOS 58 | ; 59 | cr equ 0dh ;carriage return 60 | lf equ 0ah ;line feed 61 | ; 62 | buff equ 0080h ;default buffer 63 | ; 64 | signon: ;signon message: xxk cp/m vers y.y 65 | db cr,lf,lf 66 | db '64' ;memory size 67 | db 'k CP/NOS vers ' 68 | db vers/10+'0','.',vers mod 10+'0' 69 | db cr,lf,0 70 | ; 71 | boot: ;print signon message and go to ccp 72 | ; 73 | ; device initialization - as required 74 | ; 75 | lxi sp,buff+0080h 76 | lxi h,signon 77 | call prmsg ;print message 78 | mvi a,jmp 79 | sta 0000h 80 | sta 0005h 81 | lxi h,BDOS 82 | shld 0006h 83 | xra a 84 | sta 0004h 85 | lxi h,NDOSRL+0303h 86 | shld 0001h 87 | dcx h 88 | dcx h 89 | dcx h 90 | lxi d,BIOS 91 | mvi c,BIOSlen 92 | initloop: 93 | ldax d 94 | mov m,a 95 | inx h 96 | inx d 97 | dcr c 98 | jnz initloop 99 | jmp NDOS+03h ;go to NDOS initialization 100 | ; 101 | ; Device equate table 102 | ; 103 | if DSC2 104 | cstati equ 41h 105 | cmski equ 02h 106 | cdprti equ 40h 107 | 108 | cstato equ 41h 109 | cmsko equ 01h 110 | cdprto equ 40h 111 | 112 | lstato equ 49h 113 | lmsko equ 01h 114 | ldprto equ 48h 115 | endif 116 | 117 | if Altos 118 | cstati equ 1Dh 119 | cmski equ 01h 120 | cdprti equ 1Ch 121 | 122 | cstato equ 1Dh 123 | cmsko equ 04h 124 | cdprto equ 1Ch 125 | 126 | lstato equ 1Fh 127 | lmsko equ 0Ch 128 | ldprto equ 1Eh 129 | endif 130 | 131 | ; 132 | ; 133 | const: ;console status to reg-a 134 | if Altos 135 | mvi a,0 136 | out cstati 137 | endif 138 | in cstati 139 | ani cmski 140 | rz 141 | mvi a,0ffh 142 | ret 143 | ; 144 | conin: ;console character to reg-a 145 | call const 146 | jz conin 147 | in cdprti 148 | ani 7fh ;remove parity bit 149 | ret 150 | ; 151 | conout: ;console character from c to console out 152 | if Altos 153 | mvi a,10h 154 | out cstato 155 | endif 156 | in cstato 157 | ani cmsko 158 | jz conout 159 | mov a,c 160 | out cdprto 161 | ret 162 | ; 163 | list: ;list device out 164 | if Altos 165 | mvi a,10h 166 | out lstato 167 | endif 168 | in lstato 169 | ani lmsko 170 | cpi lmsko 171 | jnz list 172 | mov a,c 173 | out ldprto 174 | ret 175 | ; 176 | listst: 177 | if Altos 178 | mvi a,10h 179 | out lstato 180 | endif 181 | in lstato 182 | ani lmsko 183 | cpi lmsko 184 | mvi a,0 185 | rnz 186 | dcr a 187 | ret 188 | ; 189 | ; utility subroutines 190 | error: 191 | lxi h,0ffffh 192 | mov a,h 193 | ret 194 | 195 | prmsg: ;print message at h,l to 0 196 | mov a,m 197 | ora a ;zero? 198 | rz 199 | ; more to print 200 | push h 201 | mov c,a 202 | call conout 203 | pop h 204 | inx h 205 | jmp prmsg 206 | ; 207 | 208 | end 209 | -------------------------------------------------------------------------------- /dist/src/cpnos.asm: -------------------------------------------------------------------------------- 1 | ; Stub to jump to bootstrap for CP/NOS 2 | ; Typical link: 3 | ; ; example for ROM at F000 and RAM data at EC000 (excluded from iamge) 4 | ; LINK CPNOS,CPNDOS,CPNIOS,CPBDOS,CPBIOS[LF000,DEC000] 5 | 6 | extrn bios 7 | 8 | boot: jmp bios 9 | 10 | end boot 11 | -------------------------------------------------------------------------------- /dist/vcpm/gencom.com: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/durgadas311/cpnet-z80/20e06f4badb7dda7af6c7102dab0e91611056da7/dist/vcpm/gencom.com -------------------------------------------------------------------------------- /dist/vcpm/hexcom.com: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/durgadas311/cpnet-z80/20e06f4badb7dda7af6c7102dab0e91611056da7/dist/vcpm/hexcom.com -------------------------------------------------------------------------------- /dist/vcpm/link.com: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/durgadas311/cpnet-z80/20e06f4badb7dda7af6c7102dab0e91611056da7/dist/vcpm/link.com -------------------------------------------------------------------------------- /dist/vcpm/mac.com: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/durgadas311/cpnet-z80/20e06f4badb7dda7af6c7102dab0e91611056da7/dist/vcpm/mac.com -------------------------------------------------------------------------------- /dist/vcpm/rmac.com: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/durgadas311/cpnet-z80/20e06f4badb7dda7af6c7102dab0e91611056da7/dist/vcpm/rmac.com -------------------------------------------------------------------------------- /dist/xsubnet.com: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/durgadas311/cpnet-z80/20e06f4badb7dda7af6c7102dab0e91611056da7/dist/xsubnet.com -------------------------------------------------------------------------------- /doc/CPNET-WIZ850io.odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/durgadas311/cpnet-z80/20e06f4badb7dda7af6c7102dab0e91611056da7/doc/CPNET-WIZ850io.odt -------------------------------------------------------------------------------- /doc/CPNET-WIZ850io.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/durgadas311/cpnet-z80/20e06f4badb7dda7af6c7102dab0e91611056da7/doc/CPNET-WIZ850io.pdf -------------------------------------------------------------------------------- /doc/CpnetSerialServer.odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/durgadas311/cpnet-z80/20e06f4badb7dda7af6c7102dab0e91611056da7/doc/CpnetSerialServer.odt -------------------------------------------------------------------------------- /doc/CpnetSerialServer.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/durgadas311/cpnet-z80/20e06f4badb7dda7af6c7102dab0e91611056da7/doc/CpnetSerialServer.pdf -------------------------------------------------------------------------------- /doc/CpnetServers.odg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/durgadas311/cpnet-z80/20e06f4badb7dda7af6c7102dab0e91611056da7/doc/CpnetServers.odg -------------------------------------------------------------------------------- /doc/CpnetServers.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/durgadas311/cpnet-z80/20e06f4badb7dda7af6c7102dab0e91611056da7/doc/CpnetServers.pdf -------------------------------------------------------------------------------- /doc/CpnetSocketServer.odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/durgadas311/cpnet-z80/20e06f4badb7dda7af6c7102dab0e91611056da7/doc/CpnetSocketServer.odt -------------------------------------------------------------------------------- /doc/CpnetSocketServer.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/durgadas311/cpnet-z80/20e06f4badb7dda7af6c7102dab0e91611056da7/doc/CpnetSocketServer.pdf -------------------------------------------------------------------------------- /doc/dri-cpnet.odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/durgadas311/cpnet-z80/20e06f4badb7dda7af6c7102dab0e91611056da7/doc/dri-cpnet.odt -------------------------------------------------------------------------------- /doc/dri-cpnet.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/durgadas311/cpnet-z80/20e06f4badb7dda7af6c7102dab0e91611056da7/doc/dri-cpnet.pdf -------------------------------------------------------------------------------- /md/BUILD.md: -------------------------------------------------------------------------------- 1 | ## Build cpnet-z80 2 | 3 | Builds are performed for a single, specific, target platform (NIC and HBA). 4 | There is currently no make target to build all known/existing 5 | platforms. 6 | 7 | ### Prerequisites 8 | 9 | To build on linux or cygwin you need to install a few packages. 10 | 11 | 1. Install the dos2unix package, or otherwise provide the 'unix2dos' 12 | command. Alternatives that add CR to the lines may be used, but 13 | require customization of the Makefile (CRLFP and CRLF2 variables). 14 | 1. Copy tools/vcpm to a directory on your PATH, and edit it to change 15 | the JAR variable to match the path to tools/VirtualCpm.jar. 16 | See https://github.com/durgadas311/virtual-cpm for more information. 17 | 1. Copy tools/vcpmrc into ~/.vcpmrc, and edit it if you want to customize 18 | the top level (vcpm_root_dir) directory used for the system drives 19 | (default: ~/HostFileBdos). If you are running the JAVA CP/NET server 20 | on this system, you should make certain you use a different top-level 21 | directory or at least ensure the usage is compatible. 22 | 1. Create the VCPM root dir, and the "a" subdir. 23 | 1. Copy rmac.com, mac.com, link.com, gencom.com, and hexcom.com from 24 | a known-good CP/M distribution into the "a" subdir. Filenames must 25 | be lower-case. 26 | 27 | To test this setup, type the command "vcpm dir" and you should get a 28 | CP/M directory listing of the "a" subdir. 29 | 30 | At this point you should be able to do a make command with the 31 | required flags and you get a `bld` directory with the runable 32 | binaries in it. 33 | 34 | ### Example: W5500 on H8/H89 35 | To build for the Heathkit H8/H89 with the H8xSPI adapter with WIZ850io and NVRAM: 36 | 37 | 1. 'cd' into the repository top-level directory 38 | 1. type the command `make NIC=w5500 HBA=h8xspi` 39 | 40 | Results will be placed in a `bld` subdirectory: 41 | * CP/NET 1.2 files in `bld/w5500/h8xspi/bin/cpnet12` 42 | * CP/NET 3 files in `bld/w5500/h8xspi/bin/cpnet3`. 43 | 44 | ### Example: W5500 on RC2014/MT011 45 | To build for the RC2014 with the MT011 adapter with Feathwing WizNET module: 46 | 47 | 1. 'cd' into the repository top-level directory 48 | 1. type the command `make NIC=w5500 HBA=mt011` 49 | 50 | Results will be placed in a `bld` subdirectory: 51 | * CP/NET 1.2 files in `bld/w5500/mt011/bin/cpnet12` 52 | * CP/NET 3 files in `bld/w5500/mt011/bin/cpnet3`. 53 | 54 | The location of the `bld` directory may be changed using the 55 | `BUILD` make variable, for example: 56 | ``` 57 | make NIC=w5500 HBA=mt011 BUILD=~/cpnet-builds 58 | ``` 59 | -------------------------------------------------------------------------------- /md/CPNET-Z80.md: -------------------------------------------------------------------------------- 1 | ## Description of CPNET 2 | 3 | ## Further reading. 4 | -------------------------------------------------------------------------------- /md/CPNET12.md: -------------------------------------------------------------------------------- 1 | On CP/M 2.2, CP/NET is started by typing the command "cpnetldr". 2 | This should result in a load map being printed and return to the command prompt. 3 | 4 | Once CP/NET is loaded, the normal CP/NET commands are used to map drives, etc. 5 | 6 | CP/NET 1.2 cannot be unloaded. 7 | A RESET (or power cycle) and reboot is required to return to normal CP/M. 8 | This means that (on w5500 systems) the sockets are not cleanly shutdown. 9 | On some systems, RESET leaves the sockets initialized and open. 10 | The command "netdown" is provided to close all server connections 11 | (shut down the network). 12 | At that point, the system may be RESET or powered off without leaving 13 | any open connections on servers. Pressing any key will resume CP/NET 14 | (return to the prompt), and re-open connections as needed. 15 | 16 | A sample CP/NET 1.2 session follows, where local drive P: is mapped to 17 | server 00 drive C: and file details are printed. 18 | 19 | ``` 20 | A>cpnetldr 21 | 22 | 23 | CP/NET 1.2 Loader 24 | ================= 25 | 26 | BIOS EB00H 1500H 27 | BDOS DD00H 0E00H 28 | SNIOS SPR D900H 0400H 29 | NDOS SPR CD00H 0C00H 30 | TPA 0000H CD00H 31 | 32 | CP/NET 1.2 loading complete. 33 | 34 | A>network p:=c: 35 | 36 | A>dir p: 37 | P: PRE422 ASM : ROM422 SYM : ROM422 ASM : ROM422 PRN 38 | P: SUF422 ASM : NET422 ASM : ROM422 HEX 39 | A>stat p:*.* 40 | 41 | Recs Bytes Ext Acc 42 | 180 32k 1 R/W P:NET422.ASM 43 | 90 16k 1 R/W P:PRE422.ASM 44 | 423 64k 1 R/W P:ROM422.ASM 45 | 102 16k 1 R/W P:ROM422.HEX 46 | 843 112k 1 R/W P:ROM422.PRN 47 | 37 16k 1 R/W P:ROM422.SYM 48 | 154 32k 1 R/W P:SUF422.ASM 49 | Bytes Remaining On P: 2048k 50 | 51 | A>netdown 52 | Ready for RESET/power-off 53 | (press any key to resume CP/NET) 54 | ``` 55 | -------------------------------------------------------------------------------- /md/CPNET3.md: -------------------------------------------------------------------------------- 1 | On CP/M 3, CP/NET is starting by typing the command "ndos3". 2 | This should result in the message "NDOS3 Started." and return to the command prompt. 3 | 4 | Note that the Heathkit versions will automatically configure the W5500 from NVRAM. 5 | Other platforms must perform the W5500 initialization prior to running NDOS3. 6 | 7 | With the NDOS3 RSX loaded, the normal CP/NET commands are used to map drives, etc. 8 | 9 | CP/NET3 may be shutdown by typing the command "rsxrm ndos3". 10 | This is currently the only way to cleanly close 11 | all connections to servers on w5500 systems. 12 | RESET or power-off will leave connections open, 13 | pending keepalive timeout on the servers. 14 | 15 | A sample CP/NET 3 session follows, where local drive N: is mapped to 16 | server 00 drive F: and an assembly of a file is done. 17 | Note that shutting down CP/NET is only necessary when you are going to 18 | power-off or RESET the system, if you need to reclaim TPA, 19 | or are running an application that is not compatible with CP/NET. 20 | ``` 21 | A>ndos3 22 | NDOS3 Started. 23 | 24 | A>network n:=f: 25 | 26 | A>dir n: 27 | N: FMTZ89 ASM : FMT500 ASM : Z80 LIB : FMTMAIN ASM : FMTTBL ASM 28 | N: FMTDISP ASM 29 | A>rmac n:fmtz89.asm $SZLN 30 | CP/M RMAC ASSEM 1.1 31 | 0A6F 32 | 038H USE FACTOR 33 | END OF ASSEMBLY 34 | 35 | A>date 36 | Mon 10/22/2018 17:05:47 37 | A>dir n: [full] 38 | 39 | Scanning Directory... 40 | 41 | Sorting Directory... 42 | 43 | Directory For Drive N: User 0 44 | 45 | Name Bytes Recs Attributes Prot Update Access 46 | ------------ ------ ------ ------------ ------ -------------- -------------- 47 | 48 | FMT500 ASM 16k 77 Dir RW None 10/22/18 09:17 10/22/18 09:17 49 | FMTDISP ASM 16k 46 Dir RW None 10/22/18 09:17 10/22/18 09:17 50 | FMTMAIN ASM 64k 392 Dir RW None 10/22/18 09:17 10/22/18 09:17 51 | FMTTBL ASM 16k 39 Dir RW None 10/22/18 09:17 10/22/18 09:17 52 | FMTZ89 ASM 32k 223 Dir RW None 10/22/18 09:17 10/22/18 17:02 53 | FMTZ89 PRN 64k 417 Dir RW None 10/22/18 17:05 10/22/18 17:02 54 | FMTZ89 REL 16k 27 Dir RW None 10/22/18 17:05 10/22/18 17:02 55 | Z80 LIB 16k 47 Dir RW None 10/22/18 09:17 10/22/18 09:32 56 | 57 | Total Bytes = 240k Total Records = 1268 Files Found = 8 58 | Total 1k Blocks = 161 Used/Max Dir Entries For Drive N: 9/ 64 59 | 60 | A>netstat 61 | 62 | CP/NET Status 63 | ============= 64 | Requester ID = C9H 65 | Network Status Byte = 10H 66 | Device status: 67 | Drive N: = Drive F: on Network Server ID = 00H 68 | A>srvstat 0 69 | 70 | Server Status 71 | ============= 72 | Server ID = 00H 73 | Server Status Byte = 10H 74 | Temp Drive = P: 75 | Maximum Requesters = 16 76 | Number of Requesters = 1 77 | Requesters logged in: 78 | C9H 79 | 80 | A>rsxrm ndos3 81 | NDOS3 Ending. 82 | RSX set to remove 83 | 84 | A> 85 | ``` 86 | -------------------------------------------------------------------------------- /md/DEVEL.md: -------------------------------------------------------------------------------- 1 | ## Developing in cpnet-z80 2 | 3 | The general source-code directory hierarchy for platform build 4 | configuration is: 5 | ``` 6 | src/ 7 | config.lib 8 | $(NIC)/ 9 | makevars 10 | config.lib 11 | $(HBA)/ 12 | makevars 13 | config.lib 14 | ``` 15 | 16 | `makevars` are optional, but they must contain valid 'make' assignments. 17 | See details in section below. 18 | Be aware that some use "+=" to append new items, and failure to use that 19 | syntax can cause dependencies to fail or incomplete builds. 20 | 'makevars' files are included in this order, after defaults are set: 21 | ``` 22 | src/$(NIC)/makevars 23 | src/$(HBA)/makevars 24 | ``` 25 | 26 | `config.lib` files are required for every NIC and HBA, although they 27 | may be empty. 28 | 29 | The `config.lib` files are concatinated in the order: 30 | ``` 31 | src/config.lib src/$(NIC)/config.lib src/$(HBA)/config.lib 32 | ``` 33 | The resulting file in placed in the build directory and used 34 | by various source files to define platform configuration. 35 | 36 | The NIC subdirectory typically contains the `snios.asm` file, 37 | since that is generally shared between different hardware implementations. 38 | The HBA subdirectory typically contains customization variables 39 | in `config.lib`, and a `chrio.asm` module in the case of 40 | serial port NICs. 41 | 42 | ### Recommended git workflow 43 | 44 | When starting work, create a side branch to contain the work. 45 | In these examples, that branch is called "newbranch". 46 | These examples are for using the git commandline interface. 47 | Other interfaces to git should have equivalent commands, 48 | or even provide a direct commandline interface. 49 | 50 | 1. Ensure your clone "master" branch is up-to-date. 51 | ``` 52 | git fetch origin master 53 | ``` 54 | 55 | 2. Switch to new branch. 56 | ``` 57 | git checkout -b newbranch master 58 | ``` 59 | 60 | Create and test changes on "newbranch", making commits as appropriate/desired. 61 | This branch may be provided to others, for testing and review, by pushing 62 | it to origin: `git push origin newbranch`, making it visible on github and 63 | available to others clones. 64 | 65 | If the branch has been pushed to origin, any developer may perform the 66 | following steps to publish it to "master". The following steps would 67 | orinarily be done all at once, to minimize the chance of other 68 | changes being made to "master" remotely and causing interference. 69 | 70 | 3. When changes are ready to publish, resync "master" with remote. 71 | ``` 72 | git fetch origin master 73 | ``` 74 | 75 | 4. Rebase the new branch onto the latest "master". 76 | ``` 77 | git checkout newbranch 78 | git rebase master 79 | ``` 80 | There is a possibility of merge conflicts at this point, those will 81 | need to be fixed and `git rebase --continue` run in order to finish 82 | the rebase. 83 | 84 | 5. Do a fast-forward merge with "master" 85 | ``` 86 | git checkout master 87 | git merge newbranch 88 | ``` 89 | 90 | 6. Confirm that all is well, then push new "master" to github. 91 | ``` 92 | git push origin master 93 | ``` 94 | 95 | 7. Branches may be deleted, at such point in the future where 96 | they are determined unneeded, using: 97 | ``` 98 | git branch -D newbranch 99 | ``` 100 | 101 | 8. Branches on (that were pushed to) github may be deleted from 102 | a clone using the following command. Use caution, as this may be the last 103 | copy of the branch and it's deletion may impact others. 104 | ``` 105 | git push origin :newbranch 106 | ``` 107 | 108 | 109 | ## Supporting new hardware 110 | 111 | Ideally, adding support for new hardware requires adding 112 | only a new HBA subdirectory (with files) and no other changes. 113 | 114 | ### Serial Port Based 115 | 116 | For adding a new serial port/platform that uses one of the 117 | existing serial protocols (`serial` or `ser-dri`), it should be sufficient 118 | to only add a new HBA subdirectory with `config.lib` and `chrio.asm` files. 119 | 120 | ### WizNET W5500 Based 121 | 122 | For the `w5500` NIC, adding new hardware support may become more complicated. 123 | Firstly, `w5500` requires that the HBA support "burst mode", that is, it 124 | allows the use of Z80 block I/O instructions. 125 | 126 | If the platform supports an NVRAM module to store network configuration, 127 | additional utilities may need to be added, which typically requires 128 | customization of the Makefile. Currently, many of the W5500 utilities 129 | are compiled differently depending on whether the platform has NVRAM. 130 | 131 | The W5500 HBAs currently are very similar. 132 | The `snios.asm` currently only checks for whether the SPI 133 | read data port is the same as the write data port (an anomaly of 134 | the MT011). Other differences in HBAs may require adding more conditionals 135 | to `snios.asm`. 136 | 137 | ### Makevars 138 | 139 | The following 'make' variables are typically modified by 'makevars' files: 140 | 141 | Variable|Use|Notes 142 | --------|---|---------------------- 143 | TARGETS|+=|Additional targets to build, typically COM file utilities. Initially "netstat.com srvstat.com rdate.com tr.com". 144 | SNDEPS|+=|Additional REL files required by SNIOS.REL. Initially "snios.rel". 145 | SNLINK|=|LINK command segment for SNIOS. Will be prefixed with target, suffixed with "[os,nr]" or "[op,nr]". Initially "snios". 146 | ND3DEP|=|The COM file to use as base for NDOS3. Default is 'ndos3dup.com'. 147 | WZCDEPS|+=|Additional REL files to build for WIZCFG (not used unless TARGETS adds "wizcfg.com"). 148 | WZCLINK|=|LINK command for WIZCFG. Will be suffixed with "[oc,nr]". 149 | CPNLDR|=|Custom CPNETLDR.COM to build. Default is original "dist/cpnetldr.com". 150 | 151 | ### See also 152 | 153 | [Build](BUILD.md) instructions. 154 | 155 | -------------------------------------------------------------------------------- /md/DUO.md: -------------------------------------------------------------------------------- 1 | ### Description 2 | 3 | The [Duodyne](https://github.com/lynchaj/duodyne) system provides 4 | a Disk I/O board that implements an SPI bus based on the 5 | [mt011](https://github.com/markt4311/MT011). It implements an 6 | ethernet controller based on the 7 | [w5500](https://www.wiznet.io/product-item/w5500/) wiznet chip 8 | and includes a 25LC512-based NVRAM chip on the same SPI bus. 9 | 10 | ### Building 11 | 12 | make NIC=w5500 HBA=duo 13 | 14 | ### Using 15 | 16 | To run this board with CP/NET, a Duodyne system with a Z80 CPU 17 | processor board and RAM/ROM board are required. It is assumed that 18 | the system is running [RomWBW](https://github.com/wwarthen/RomWBW) v3.4 19 | or newer. 20 | 21 | The Duodyne Disk I/O does not reset the W5500 during system RESET, 22 | so it retains settings during system RESET-reboot. 23 | The W5500 may be reset by software, when required. 24 | 25 | ## On your CP/M console: 26 | 27 | ### CP/M 2.2 28 | 29 | ``` 30 | (assumes your cpnet code is installed on the A: drive) 31 | A>wizcfg n F0 32 | A>wizcfg i 33 | A>wizcfg g 34 | A>wizcfg s 35 | A>wizcfg m 36 | A>wizcfg 0 00 31100 37 | A>cpnetldr 38 | A>cpnetsts 39 | A>network k:=c:[0] (drive letters may vary) 40 | ``` 41 | 42 | ### CP/M 3.0 43 | 44 | ``` 45 | (assumes your cpnet code is installed on the A: drive) 46 | A>wizcfg n F0 47 | A>wizcfg i 48 | A>wizcfg g 49 | A>wizcfg s 50 | A>wizcfg m 51 | A>wizcfg 0 00 31100 52 | A>ndos3 53 | A>cpnetsts 54 | A>network k:=c:[0] (drive letters may vary) 55 | ``` 56 | 57 | ## Caveat's 58 | 59 | The above assumes you have a server running on a host machine somewhere. 60 | See 61 | for information on running the server. 62 | -------------------------------------------------------------------------------- /md/FT245R.md: -------------------------------------------------------------------------------- 1 | ### Description: 2 | 3 | The [FT245R](https://www.ftdichip.com/Products/ICs/FT245R.htm) is a parallel 4 | to USB converter chip. 5 | 6 | ### Building 7 | 8 | make NIC=serial HBA=ft245r 9 | 10 | To get a binary build tree in a non standard (.bld) directory. 11 | make BUILD=/path/to/build/top [...] 12 | 13 | ### Using 14 | 15 | Use with CpnetSerialServer.jar with the **cpnet_protocol** property 16 | (or **proto=** commandline option) set to **ASCII**. 17 | 18 | ### Caveat's 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /md/H8XSPI.md: -------------------------------------------------------------------------------- 1 | ### Description 2 | 3 | This module implements the SPI-to-W5500 interface 4 | used on Heathkit H8/H89 computers. This interface 5 | includes an NVRAM chip for storing network configuration. 6 | 7 | See also [H8XSPI](http://koyado.com/Heathkit/H8_CP_NET_SPI_Wiznet_Network.html) 8 | 9 | ### Building 10 | 11 | make NIC=w5500 HBA=h8xspi 12 | 13 | ### Using 14 | 15 | A compatible server is implemented in CpnetSocketServer.jar. 16 | The utility WIZCFG.COM is used to setup the NVRAM, 17 | and the CP/NET startup code will program the W5500 18 | from NVRAM. 19 | 20 | The H8XSPI resets the W5500 during system RESET, 21 | so its settings are lost during system RESET-reboot. 22 | The NVRAM will retain the settings and is automatically 23 | used during CP/NET startup. 24 | 25 | ### Caveat's 26 | 27 | -------------------------------------------------------------------------------- /md/INS8250.md: -------------------------------------------------------------------------------- 1 | ### Description: 2 | 3 | This HBA target implements a serial transport over an INS8250 4 | serial port, which should be software compatible with the 16C550, 5 | 16C2550, and others in the family. 6 | The default code is configured for the "LP" serial port on 7 | a Heathkit H8/H89 (address 0E0H), using a 1.8432 MHz data clock. 8 | For most cases, the changes for different systems are 9 | limited to SERPORT (base port address) and 10 | SERBAUD (divisor latch value for desired BAUD). 11 | 12 | ### Building 13 | 14 | make NIC=ser-dri HBA=ins8250 15 | 16 | ### Using 17 | 18 | Use with CpnetSerialServer.jar with the **cpnet_protocol** property 19 | (or **proto=** commandline option) set to **DRI**. 20 | 21 | ### Caveat's 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /md/KAYPRO.md: -------------------------------------------------------------------------------- 1 | ### Description: 2 | 3 | This HBA target implements a serial transport over a Z80-SIO 4 | serial port. 5 | The default code is configured for the "serial data" Z80-SIO port on 6 | a Kaypro (address 004H), using WD1943 BAUD generator 7 | with a 5.0688 MHz data clock. 8 | For most cases, the changes for different systems are 9 | limited to SERPORT (base port address), 10 | BAUDPRT (WD1943 port), 11 | and SERBAUD (WD1943 value for desired BAUD). 12 | 13 | ### Building 14 | 15 | make NIC=ser-dri HBA=kaypro 16 | 17 | ### Using 18 | 19 | Use with CpnetSerialServer.jar with the **cpnet_protocol** property 20 | (or **proto=** commandline option) set to **DRI**. 21 | 22 | ### Caveat's 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /md/MINZ.md: -------------------------------------------------------------------------------- 1 | ### Description: 2 | 3 | The [MinZ-U Z180](http://www3.telus.net/public/wsm/MinZ180.pdf) 4 | "minimal" system may be used with a CpnetSerialServer attached to 5 | the second serial port (ASCI1). 6 | 7 | This system contains a 512K EEPROM, 512K RAM, and the Z80S180 CPU 8 | (with built-in peripherals). 9 | It is neatly packaged on a 2"x2" PCB and is powered via the (single) USB 10 | cable, which provides tty access to both serial ports. 11 | 12 | ### Building 13 | 14 | `make NIC=ser-dri HBA=minz` 15 | 16 | To get a binary build tree in a non standard (.bld) directory. 17 | 18 | `make BUILD=/path/to/build/top [...]` 19 | 20 | ### Using 21 | 22 | Use with CpnetSerialServer.jar with the **cpnet_protocol** property 23 | (or **proto=** commandline option) set to **DRI**. 24 | Serial speed is 115200 baud. 25 | Tested properties are: 26 | ``` 27 | cpnet_protocol = dri 28 | dri_ack_timeout = 100 29 | dri_char_timeout = 100 30 | cpnet_flow_control = rts/cts 31 | ``` 32 | 33 | The special command CPNBOOT.COM, which should be part of the 34 | standard delivered files on the MinZ-U, may be used to 35 | boot CP/NET off the server. 36 | This requires additional properties to setup the network boot 37 | feature: 38 | ``` 39 | netboot_dir = /some/path/to/boot/files 40 | netboot_org0 = none 41 | ``` 42 | 43 | The `/some/path/to/boot/files` directory should contain the 44 | `snios.spr` and `ndos.spr` files produced by this build. 45 | Then, run the command "p:cpnboot" on the MinZ to start CP/NET. 46 | 47 | ### Caveat's 48 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /md/MT011.md: -------------------------------------------------------------------------------- 1 | ### Description 2 | 3 | The [mt011](https://github.com/markt4311/MT011) 4 | is an [RC2014](http://www.rc2014.co.uk/) compaitible 5 | ethernet controller based on the 6 | [w5500](https://www.wiznet.io/product-item/w5500/) wiznet chip 7 | with a [Featherwing](https://learn.adafruit.com/adafruit-wiz5500-wiznet-ethernet-featherwing) breakout board. 8 | 9 | This board was developed by Mark T with input from Jay Cotton. 10 | 11 | It is highly recommended to use the 12 | [Adafruit FRAM breakout board](https://www.adafruit.com/product/1897) 13 | with this software, as it allows storing the CP/NET and WixNET configuration in 14 | non-volatile RAM and avoids the need to initialize the WizNET after a power on. 15 | This board is interfaced to the second SPI port, on the upper-left of the MT011. 16 | The FRAM board pinout does not match the MT011 SPI port pinout, so an adapter board 17 | (wiring) is required. The utility WIZCFG.COM may be used to store configuration in 18 | the FRAM. 19 | 20 | To build without the FRAM, you must modify src/mt011/config.lib 21 | and change the NVRAM variable to "0". 22 | 23 | ### Building 24 | 25 | make NIC=w5500 HBA=mt011 26 | 27 | ### Using 28 | 29 | To run this board with CP/NET there are a few things that are needed. 30 | A ROM/RAM board with [RomWBW](https://github.com/wwarthen/RomWBW) v3.0.1 or newer. 31 | The MT011 board. 32 | 33 | The MT011 does not reset the W5500 during system RESET, 34 | so it retains settings during system RESET-reboot. 35 | The W5500 may be reset by software, when required. 36 | 37 | ##On your CP/M console: 38 | ###CP/M 2.2 39 | ``` 40 | b:pip a:=c:ccp.spr (assumes your cpnet code is installed on the c drive) 41 | c:ifconfig -s (https://github.com/jayacotton/inettools-z80) (this command gets a DHCP address for the wiznet board) 42 | c:wizcfg 0 0 31100 45 43 | c:cpnetldr (this loads the cpnet bios code ) 44 | c:network k:=c:[0] (k on my machine, YMMV) 45 | ``` 46 | ###CP/M 3.0 47 | ``` 48 | c:ifconfig 49 | c:wizcfg 0 0 31100 45 50 | c:network k:=c:[0] 51 | ``` 52 | 53 | ##Caveat's 54 | 55 | The above assumes you have a server running on a host machine somewhere. 56 | See cpnet-z80/doc/CpnetSocketServer.pdf for information on running the 57 | server. 58 | -------------------------------------------------------------------------------- /md/RC-SIOB.md: -------------------------------------------------------------------------------- 1 | ### Description: 2 | 3 | This HBA target implements a serial transport over 4 | the device provided by RomWBW as "SIOB". 5 | Specifics of the serial port are configured in RomWBW. 6 | 7 | ### Building 8 | 9 | make NIC=ser-dri HBA=rc-siob 10 | 11 | ### Using 12 | 13 | Use with CpnetSerialServer.jar with the **cpnet_protocol** property 14 | (or **proto=** commandline option) set to **DRI**. 15 | 16 | ### Caveat's 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /md/RUN-RC2014.md: -------------------------------------------------------------------------------- 1 | ## How to run on CP/M 2.2 2 | ### Using MT011 3 | ### Using Serial 4 | ## How to run on CP/M 3.0 5 | ### Using MT011 6 | ### Using Serial 7 | -------------------------------------------------------------------------------- /md/SER-DRI.md: -------------------------------------------------------------------------------- 1 | ### Description 2 | 3 | This NIC (serial protocol driver) implements the CP/NET 4 | serial protocol defined by the Digital Research reference 5 | implementation of the SNIOS. 6 | 7 | In this protocol, the CP/NET header is sent 8 | separately, with a separate checksum and sync/acknowledge. 9 | 10 | The server should support the following special messages, which 11 | are not actually sent to a CP/NET server but are processed by 12 | the serial port proxy. 13 | 14 | #### Initialize and get node ID: 15 | 16 | 00 00 00 FF 00 00 (request) 17 | 01 NN 00 FF 00 00 (response, NN=client node ID) 18 | 19 | The proxy performs any required initialization and then responds 20 | after filling in the client node ID. 21 | 22 | #### Shutdown: 23 | 24 | 00 00 00 FE 00 00 (request) 25 | (no response) 26 | 27 | The proxy performs any required shutdown actions, such as closing 28 | any open sockets to CP/NET servers and releasing resources. 29 | 30 | ### Building 31 | 32 | make NIC=ser-dri HBA=xxx 33 | 34 | ### Using 35 | 36 | Use with CpnetSerialServer.jar with the **cpnet_protocol** property 37 | (or **proto=** commandline option) set to **DRI**. 38 | 39 | ### Caveat's 40 | 41 | The timing for this protocol can be 42 | difficult to tune. It is also highly dependent on 43 | CPU speed. As yet there is no automated method 44 | to configurev the timing, each new platform 45 | may require some trial-and-error. 46 | -------------------------------------------------------------------------------- /md/SERIAL.md: -------------------------------------------------------------------------------- 1 | ### Description 2 | 3 | This NIC (serial protocol driver) implements the CP/NET 4 | serial protocol designed as a simple protocol for fast 5 | transports such as USB. 6 | 7 | The protocol uses ASCII printable characters only. 8 | Synchronization is provided by "++" (begin) and "--" (end) 9 | sequences, with the CP/NET packet (header and data) 10 | in between, encoded in hexadecimal ASCII. The message includes 11 | a 16-bit CRC. 12 | 13 | For example, a message from client 1F to server 02 14 | for BDOS function 0E (select disk) for drive D: would be 15 | (including CRC16): 16 | 17 | ++00021F0E0003204D-- 18 | 19 | The server should support the following special messages, which 20 | are not actually sent to a CP/NET server but are processed by 21 | the serial port proxy. 22 | 23 | #### Initialize and get node ID: 24 | 25 | 00 00 00 FF 00 00 (request) 26 | 01 NN 00 FF 00 00 (response, NN=client node ID) 27 | 28 | The proxy performs any required initialization and then responds 29 | after filling in the client node ID. 30 | 31 | #### Shutdown: 32 | 33 | 00 00 00 FE 00 00 (request) 34 | (no response) 35 | 36 | The proxy performs any required shutdown actions, such as closing 37 | any open sockets to CP/NET servers and releasing resources. 38 | 39 | ### Building 40 | 41 | make NIC=serial HBA=xxx 42 | 43 | ### Using 44 | 45 | Use with CpnetSerialServer.jar with the **cpnet_protocol** property 46 | (or **proto=** commandline option) set to **ASCII**. 47 | 48 | ### Caveat's 49 | 50 | There is no ACK/NAK protocol, so this protocol is 51 | best suited for error-free transports such as USB. 52 | 53 | This protocol requires twice as many characters be 54 | transmitted compared to a binary protocol. 55 | -------------------------------------------------------------------------------- /md/USB1232H.md: -------------------------------------------------------------------------------- 1 | ### Description: 2 | 3 | The [USB1232H](https://www.dlpdesign.com/usb/usb1232h.shtml) is a parallel 4 | to USB converter chip. 5 | 6 | ### Building 7 | 8 | make NIC=serial HBA=usb1232 9 | 10 | To get a binary build tree in a non standard (.bld) directory. 11 | make BUILD=/path/to/build/top [...] 12 | 13 | ### Using 14 | 15 | Use with CpnetSerialServer.jar with the **cpnet_protocol** property 16 | (or **proto=** commandline option) set to **ASCII**. 17 | 18 | ### Caveat's 19 | 20 | This one works on S100 machines. Not limited to Z80, should work with 21 | I8080 (not tested). See www.s100computers.com for details. 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /md/VCPNET.md: -------------------------------------------------------------------------------- 1 | ### Description 2 | 3 | Virtual CP/NET Device in a fictitious device for emulators. 4 | It provides a simple client software interface using OUTIR/INIR. 5 | Due to the nature of the transport, no CRC or checksum is used 6 | and data is transfered in binary. 7 | 8 | While not strictly enforced, the CP/NET header is generally sent 9 | (or received) in a separate block I/O transfer than the data. 10 | Basically, the receiving end must determine how many characters 11 | are in the data block in order to properly terminate the message. 12 | 13 | The device uses two port addresses, data (+0) and control/status (+1). 14 | An output to the control port resets/resyncs the interface, and 15 | the next read of the data port returns the node ID assigned 16 | to the client. 17 | 18 | Reading the status port, bit 0 indicates a message is ready 19 | for INIR. The device is always ready for the client to send 20 | a message, however it is possible to get out of sync. 21 | Status bit 1 indicates that the OUTIR has overrun the expected data. 22 | Status bit 2 indicates that the INIR has overrun the available data. 23 | 24 | #### Example code for sendmsg: 25 | 26 | ; message address in HL 27 | sendmsg: 28 | push hl 29 | pop ix 30 | ld c,PORT+0 31 | ld b,5 ; CP/NET hdr len 32 | outir ; send header 33 | ld b,(ix+4) ; msg SIZ field 34 | inc b ; len is SIZ+1 35 | outir ; send payload 36 | inc c ; status port 37 | inp a 38 | and 02h ; send overrun? 39 | ret z ; send was OK 40 | or 0ffh ; flag error 41 | ret 42 | 43 | #### Example code for recvmsg: 44 | 45 | ; buffer address in HL 46 | recvmsg: 47 | push hl 48 | pop ix 49 | ld c,PORT+0 50 | inc c ; status port 51 | ; this loop should timeout 52 | recv0: inp a 53 | and 01h ; data available? 54 | jr z,recv0 55 | dec c ; data port 56 | ld b,5 ; CP/NET hdr len 57 | inir ; get header 58 | ; could check overrun, extra sanity 59 | ld b,(ix+4) ; msg SIZ field 60 | inc b ; len is SIZ+1 61 | inir ; get payload 62 | inc c ; status port 63 | inp a 64 | and 04h ; recv overrun? 65 | ret z ; recv was OK 66 | or 0ffh ; flag error 67 | ret 68 | 69 | ### Building 70 | 71 | make NIC=vcpnet HBA=null 72 | 73 | ### Using 74 | 75 | The message transfer is between two components in 76 | a virtual machine (emulation), and so there is no 77 | server/proxy component provided here as each emulator would 78 | typically require it's own solution. 79 | 80 | ### Caveat's 81 | 82 | -------------------------------------------------------------------------------- /md/W5500.md: -------------------------------------------------------------------------------- 1 | ### Description 2 | 3 | This is an implementation of a driver for the Wiznet 5500 class ethernet 4 | I/O chip. The chip is a hardware abstraction layer that captures most 5 | of the TCP/IP stack protocol inside a single part. 6 | 7 | For more information on the [W5500](https://www.wiznet.io/product-item/w5500/) click here. 8 | 9 | The client node ID is specified in the W5500 PMAGIC register, 10 | in the common register block. In addition, common registers 11 | must be setup to allow the client to operate on the local 12 | network. This typically includes the gateway (GAR), 13 | subnet mask (SUBR), harware MAC address (SHAR), 14 | and IP address (SIPR) registers. 15 | 16 | The chip provides 8 sockets. These are designated as CP/NET server 17 | mappings by setting the high byte of the socket source port (Sn_PORT0) 18 | to 0x31 and the low byte (Sn_PORT1) to the assigned CP/NET server node ID. 19 | Such sockets will be opened as TCP/IP sockets connecting to the 20 | server specified by Sn_DIPR and Sn_DPORT. 21 | 22 | Some connections, particularly going through certain routers or ISPs, 23 | may require "keep alive" be set. A value should be set in the 24 | Sn_KPALVTR register. Note this register value is in units of 5 seconds. 25 | A keep alive interval of 45 seconds has been effective, which 26 | requires a value in Sn_KPALVTR of "9". 27 | Keep alive is typically not needed for local-area network connections. 28 | Depending on the utility used to set this value, 29 | the 5-second units conversion may already be handled for you. 30 | 31 | CP/NET messages are sent and received in binary, with no CRC or checksum 32 | (TCP/IP will handle errors/retries). 33 | 34 | ### Building 35 | 36 | make NIC=w5500 HBA=xxx 37 | 38 | ### Using 39 | 40 | A compatible server is implemented in CpnetSocketServer.jar. 41 | Depending on the platform, different utilities and procedures are 42 | used to configure the network. The W5500 does not retain any 43 | settings during power off or RESET, and so generally requires 44 | configuration every time the system is booted. Some platforms 45 | will RESET the W5500 when the ZPU (system) is RESET, others provide 46 | a separate mechanism to reset the W5500. 47 | 48 | ### Caveat's 49 | 50 | -------------------------------------------------------------------------------- /md/Z180CSIO.md: -------------------------------------------------------------------------------- 1 | ### Description 2 | This module implements the SPI-to-W5500 interface 3 | using a W5500 breakout board connected to the second SPI 4 | interface on the SC126 Z180 board, the communication uses 5 | the Z180 CSIO 6 | 7 | ### Building 8 | 9 | make NIC=w5500c HBA=z180csio 10 | 11 | The w5500c NIC device is a modified copy of the w5500 driver to work with the 12 | Z180 CSIO interface. It works with the same socket server on the host. 13 | Currently, the only HBA supported on w5500c is z180csio. 14 | 15 | ### Board wiring 16 | 17 | The W5500 breakout board needs to be connected to the SC126 second SPI port. 18 | Connections are: 19 | 20 | SC126-SPI-2 | W5000 | 21 | ----|-----| 22 | 1 | CS| 23 | 2 |SCK| 24 | 3 |MOSI| 25 | 4 |MISO| 26 | 5 |Vcc| 27 | 6 |Gnd| 28 | N/C |3.3V 29 | N/C |RST| 30 | N/C |INT| 31 | N/C |N/C| 32 | 33 | Unused connections are marked N/C. 34 | 35 | There is a red power LED on the W5500 module, 36 | There are the usual Ethernet LEDs on the ethernet Jack. 37 | 38 | ### Using 39 | 40 | The distribution files need to be copied onto the target system before use. 41 | Kermit, xmodem, or FAT file copy are suitable tools available from CP/M on RomWBW 42 | 43 | There is sufficient room to copy the files onto the boot drive if needed. 44 | 45 | The W5500 retains settings during system RESET-reboot. 46 | The W5500 may be reset by software, when required. 47 | 48 | The supplied utility wizcfg is used to set the operating settings into the W5500 devece befor use 49 | the format of commands used is show in its help screen: 50 | ``` 51 | B>wizcfg --version 52 | WIZCFG version 1.4 53 | Usage: WIZCFG {G|I|S} ipadr 54 | WIZCFG M macadr 55 | WIZCFG N cid 56 | WIZCFG {0..7} sid ipadr port [keep] 57 | Sets network config in W5500 58 | Built for SC126 Z180 CSIO 59 | ``` 60 | If no command line tail is given the a summary of the present settings are shown. 61 | Note the socket IP parameters are not visible until after the socket has been used. 62 | 63 | Note, socketserver needs an older version of Java for the 64 | LST: redirection to work properly. JAVA 8 works, but JAVA 11 does not (yet). 65 | 66 | I found a link to download Java8 in this article here: 67 | https://tecadmin.net/install-oracle-java-8-ubuntu-via-ppa/ 68 | I installed it and modified the socketserver command to use it by invoking it 69 | withthe full path name of the V8 version instead of just java using the default version 70 | see socketserver example in contrib folder 71 | 72 | Windows needs an alternative socketserver invocation command, 73 | simple batch files for this are in contrib too. 74 | The java version on my Windows 10 laptop is fine with the defanlt java installation. 75 | 76 | ## On your CP/M console: 77 | ###CP/M 2.2 78 | ``` 79 | c:wizcfg 0 0 31100 45 80 | c:cpnetldr 81 | c:network k:=c:[0] 82 | ``` 83 | 84 | ###CP/M 3.0 85 | ``` 86 | c:wizcfg 0 0 31100 45 87 | c:network k:=c:[0] 88 | ``` 89 | 90 | Note, I found that the CP/M 2.2 version would also work 91 | on CP/M 3 but its better and easier to use the corect version. 92 | This may help to deploy a syemstem initailly where both sets 93 | of files could be copied onto the target system. 94 | 95 | ## Compatability 96 | 97 | The default microsd adapter card used by the SC126 98 | does not release the SPI MISO line when the device 99 | is de-selected, this prevents two SPI devices being used. 100 | A small modification is needed to the 101 | micro sd adapter card to fix this problem. 102 | 103 | See discussion here for details: 104 | https://groups.google.com/g/retro-comp/c/fcGZEa91NSc 105 | Another kind of micro SD card or SC126 modifications are alternative solotions. 106 | If no micro SD card is used then no modifications are needed, 107 | the W5500 board can always be used as is. 108 | 109 | No modification are needed to the stock RomWBW configuration, 110 | the default single SD drive should 111 | be used allowing the W5500 driver to use the second port. 112 | 113 | ## Enhancement 114 | 115 | A small non volatile memory device could be used to store the w5500 configuration 116 | instead of needing to issue a wizcfg command after a power off reset. On the SC126 117 | an IIC device may be more suitable than the SPI device used on other boards due to 118 | lack of available spare chip select lines. 119 | 120 | ## Caveats 121 | 122 | The above assumes you have a server running on a host machine somewhere. 123 | See cpnet-z80/doc/CpnetSocketServer.pdf for information on running the 124 | server. 125 | 126 | David Richards, December 2020. 127 | -------------------------------------------------------------------------------- /src/bnkntsrv.asm: -------------------------------------------------------------------------------- 1 | ;*************************************************************************** 2 | ;*************************************************************************** 3 | ;** ** 4 | ;** S e r v e r N e t w o r k M a i n M o d u l e ** 5 | ;** BANKED PORTION ** 6 | ;** ** 7 | ;*************************************************************************** 8 | ;*************************************************************************** 9 | ; Link: BNKNTSRV,NTWRKRCV,SERVERS,NIOS 10 | ; 11 | ; The mutex 'nmutex' must be "owned" in order to call the NIOS. 12 | ; The 'NtWrkRcv' process monitors for incoming network messages, 13 | ; receives them, and dispatches them to the appropriate server process 14 | ; via the matching server process message queue. Server processes 15 | ; perform the requested function and then acquire 'nmutex' and send 16 | ; the response back over network. 17 | 18 | public bdos,cfgadr,cfgcmd,nlock,nunlock,nwq0p,roveca 19 | extrn recvr ; The network receiver loop entry 20 | extrn qinit ; QCB/UQCB setup for message queues 21 | extrn pinit ; (Server) process(es) setup 22 | extrn NTWKIN,NTWKST,SNDMSG,RCVMSG,NWPOLL,NTWKER,NTWKDN,NWLOGO 23 | 24 | ;*************************************************************************** 25 | ;*************************************************************************** 26 | ;** ** 27 | ;** This module performs initialization of the processes and ** 28 | ;** provides shared resources. ** 29 | ;** ** 30 | ;*************************************************************************** 31 | ;*************************************************************************** 32 | maclib config 33 | maclib cfgnwif 34 | maclib z80 35 | 36 | cseg 37 | resadr: dw $-$ ; pointer to RES part 38 | dw stk0 ; initial stack pointer 39 | db 'NETSERVR' ; descriptive name - must match BRS filename? 40 | 41 | ; Stack area for the initial process: 42 | dw 0c7c7h,0c7c7h,0c7c7h,0c7c7h 43 | dw 0c7c7h,0c7c7h,0c7c7h,0c7c7h 44 | dw 0c7c7h,0c7c7h,0c7c7h,0c7c7h 45 | dw 0c7c7h,0c7c7h,0c7c7h,0c7c7h 46 | dw 0c7c7h,0c7c7h,0c7c7h,0c7c7h 47 | dw 0c7c7h,0c7c7h,0c7c7h 48 | stk0: dw setup 49 | 50 | bdos$adr: dw $-$ 51 | cfgadr: dw $-$ 52 | nwq0p: dw $-$ 53 | cfgcmd: dw $-$ 54 | roveca: dw $-$ 55 | 56 | ; UQCB for 'MXServer' - pre-filled (no open) 57 | smutex: dw 0 ; filled in by 'setup' 58 | ; ds 2 ; no MSGADR 59 | ; ds 8 ; no NAME - not opened 60 | 61 | ; UQCB for 'MXNetwrk' - pre-filled (no open) 62 | nmutex: dw 0 ; filled in by 'setup' 63 | ; ds 2 ; no MSGADR 64 | ; ds 8 ; no NAME - not opened 65 | 66 | if use$mxdisk 67 | ntmtx: dw 0 ; filled in by openqf 68 | dw 0 ; no MSGADR 69 | db 'MXDisk ' 70 | else 71 | ntmtx equ nmutex 72 | endif 73 | 74 | qcbname: db 'NtwrkQIX' 75 | 76 | ; NETWRKIF Utility Routines 77 | 78 | ; Operating system linkage routine 79 | bdos: lhld bdos$adr 80 | pchl 81 | 82 | nlock: lxi d,ntmtx 83 | mvi c,readqf 84 | jmp bdos 85 | 86 | nunlock: lxi d,ntmtx 87 | mvi c,writqf 88 | jmp bdos 89 | 90 | ; Initialize Network Processes and resources 91 | ; Runs in the context of 'NtWrkRcv' process. 92 | setup: 93 | lhld resadr 94 | mov e,m 95 | inx h 96 | mov d,m 97 | xchg 98 | shld bdos$adr ; snag a copy for easier use 99 | if use$mxdisk 100 | lxi d,ntmtx 101 | mvi c,openqf 102 | call bdos 103 | ora a 104 | jnz failed ; should never happen 105 | endif 106 | ; To avoid having to open all the queues, manually fixup 107 | ; the UQCB structures to point at QCBs 108 | mvi c,getpdf 109 | call bdos 110 | ; HL = 'networkio' in RESNTSRV.RSP 111 | lxi d,P$LEN 112 | dad d ; HL = mx$netwrk 113 | shld nmutex ; setup UQCB 114 | push h 115 | xchg ; DE=mx$netwrk 116 | mvi c,makeqf 117 | call bdos 118 | ; we own the mutex now, don't release until we've called NTWKIN 119 | pop h 120 | lxi d,26 121 | dad d ; HL = mx$servr 122 | shld smutex 123 | push h 124 | xchg ; DE=mx$servr 125 | mvi c,makeqf 126 | call bdos 127 | pop h 128 | lxi d,26 ; length of mutex 129 | dad d ; HL = SERVR0PR 130 | push h ; save SERVR0PR for proc create loop 131 | lxi d,nmb$rqstrs * P$LEN 132 | dad d ; HL = qcb$in$0 133 | push h 134 | shld nwq0p 135 | call qinit 136 | ora a 137 | jnz failed 138 | ; messages queues are ready now 139 | pop h 140 | lxi d,nmb$rqstrs * qcb$in$len 141 | dad d ; HL = CFGTBL 142 | shld cfgadr 143 | lxi d,G$CMD 144 | dad d 145 | shld cfgcmd 146 | inx h ; exnmtx = (ntmtx) 147 | lded ntmtx ; actual QCB 148 | mov m,e 149 | inx h 150 | mov m,d ; this makes G$MTX a real UQCB 151 | inx h 152 | shld roveca ; save R/O vector addr 153 | ; set CFGTBL into system data page 154 | mvi c,sysdatf 155 | call bdos 156 | mvi l,S$CPNET ; CP/NET config table address 157 | lded cfgadr 158 | mov m,e 159 | inx h 160 | mov m,d ; no one looking for this, yet 161 | pop h ; HL = SERVR0PR 162 | call pinit ; server procs start running now... 163 | ora a ; (each should be sleeping on input Q) 164 | jnz failed 165 | ; now wait for start signal... 166 | ; nmutex must not be "held" 167 | if not use$mxdisk 168 | call nunlock ; was created "locked" 169 | endif 170 | wait: 171 | lxi d,smutex 172 | mvi c,readqf 173 | call bdos ; sleeps until SRVSTART 174 | lhld cfgcmd 175 | mov a,m 176 | cpi NWSTART 177 | jrnz wait 178 | ; ...sysadmin has released us. 179 | call nlock 180 | call NTWKIN 181 | push psw 182 | call nunlock ; allow access to NIOS now 183 | pop psw 184 | ora a 185 | jnz failed 186 | call recvr ; now perform our designated function... 187 | ; returns here on shutdown, all cleanup finished. 188 | lhld cfgcmd 189 | mvi m,NWSTOP ; redundant? 190 | jr wait 191 | 192 | failed: 193 | mvi c,attconf 194 | call bdos 195 | lxi d,errmsg 196 | mvi c,printf 197 | call bdos 198 | mvi c,detconf 199 | call bdos 200 | fail0: ; do nothing, softly... 201 | mvi e,60 202 | mvi c,delayf 203 | call bdos 204 | jmp fail0 205 | 206 | errmsg: db CR,LF,'Network Init Error',CR,LF,'$' 207 | 208 | end 209 | -------------------------------------------------------------------------------- /src/cfgnwif.lib: -------------------------------------------------------------------------------- 1 | ; Constants for MP/M CP/NET Server 2 | ; (use caution if making changes) 3 | def$prot equ 0001b ; default write-protect drives vector 4 | 5 | nmb$bufs equ nmb$rqstrs+1 ; Number of message buffers 6 | srvr$stk$len equ 150 ; server process stack size 7 | qcb$out$buf equ 2*nmb$bufs ; length of qcb$out buffer 8 | ; 9 | ; ASCII control characters 10 | cr equ 13 11 | lf equ 10 12 | eof equ 26 13 | 14 | ; BDOS function numbers 15 | listf equ 5 16 | printf equ 9 17 | versf equ 12 18 | drivef equ 14 19 | openf equ 15 20 | closef equ 16 21 | searchf equ 17 22 | nextf equ 18 23 | rseqf equ 20 24 | wseqf equ 21 25 | makef equ 22 26 | dmaf equ 26 27 | getalvf equ 27 28 | wprotf equ 28 29 | userf equ 32 30 | rrndf equ 33 31 | wrndf equ 34 32 | freef equ 39 33 | defpwdf equ 106 34 | 35 | ; CP/NET function numbers 36 | loginf equ 64 37 | logoutf equ 65 38 | netend equ 76 ; end of CP/NET reserved 39 | 40 | ; XDOS function numbers 41 | makeqf equ 134 42 | openqf equ 135 43 | readqf equ 137 44 | crdqf equ 138 45 | writqf equ 139 46 | delayf equ 141 47 | dispatf equ 142 48 | makepf equ 144 49 | attconf equ 146 50 | detconf equ 147 51 | sysdatf equ 154 52 | getpdf equ 156 53 | attlstf equ 158 54 | detlstf equ 159 55 | setlstf equ 160 56 | getlstf equ 164 57 | 58 | ; UQCB elements 59 | Q$PTR equ 0 60 | Q$MSG equ 2 61 | Q$NAME equ 4 ; 8 bytes long 62 | Q$LEN equ 12 63 | 64 | ; CP/NET message buffer (MSGBUF) layout 65 | FMT equ 0 ; 00 for requests, 01 for responses 66 | DID equ 1 ; Dest node ID (target) 67 | SID equ 2 ; Source node ID (sender) 68 | FNC equ 3 ; BDOS/NDOS function number 69 | SIZ equ 4 ; payload length, -1 (00 means 1 byte) 70 | DAT equ 5 ; start of payload 71 | TMP equ DAT+1+128 ; unused space, when searchf/nextf used. 72 | ; Only DAT+2+F$LEN used by searchf reqs, 73 | ; DAT+1+D$LEN for responses. 74 | ; other intervening functions could destroy, 75 | ; possibly breaking searches. 76 | M$LEN equ DAT+256+1 ; Total, max, length of CP/NET message 77 | 78 | ; CP/NET Server config table, in NetWrkIF 79 | G$STS equ 0 ; server status byte 80 | G$NID equ 1 ; server node ID 81 | G$MAX equ 2 ; Maximum number of requesters supported 82 | G$NUM equ 3 ; Number of requesters currently logged-in 83 | G$VEC equ 4 ; 16-bit vector of login slots 84 | G$LOG equ 6 ; Array[16] of logged-in NIDs, per G$VEC 85 | G$PWD equ 22 ; login password (8 bytes) 86 | G$LEN equ 22 ; length exported, password never revealed. 87 | G$CMD equ 30 ; "command" (startup,shutdown,...) 88 | G$MTX equ 31 ; mutex (QCB) used to mutex NIOS 89 | G$ROV equ 33 ; R/O vector 90 | G$ALL equ 35 ; total length 91 | ; G$CMD values: 92 | NWSTOP equ 0 93 | NWSTART equ 1 94 | 95 | ; NOTE: CP/NET "compatability attributes" are kept in 96 | ; the server process descriptor "PD extent high byte", 97 | ; at offset 29 in PD. 98 | P$CONLST equ 14 ; CON:/LST: device 99 | P$DSEL equ 22 ; DISK SLCT 100 | P$DCNT equ 23 ; offset of DCNT,SEARCHL,SEARCHA in PD 101 | P$EXT equ 28 ; offset of "PD EXTENT" in PD 102 | P$ATTR equ P$EXT+1 ; CP/NET compat attrs in PD (bits 4-7) 103 | P$BC equ 46 ; BC register in PD 104 | P$LEN equ 52 ; PD length 105 | 106 | ; System Info in System Data Page 107 | S$CPNET equ 9 ; CP/NET master configuration table address 108 | S$TEMP equ 196 ; Temporary file drive 109 | 110 | ; These must match actual layout in originating files... 111 | qcb$in$len equ 26 ; length of input QCBs 112 | -------------------------------------------------------------------------------- /src/config.lib: -------------------------------------------------------------------------------- 1 | ; HBAs for W5500 modules 2 | H8xSPI equ 1 ; H8xSPI board for H8/H89 systems. Includes NVRAM. 3 | MT011 equ 2 ; MT011_SPI_WIZNET board for RC2014-Z80 systems. 4 | DUO equ 3 ; Disk I/O board for Duodyne systems. 5 | ; Other HBAs 6 | FT245R equ 4 7 | VCPNET equ 5 8 | Z180CSIO equ 6 ; For W5500 variation "w5500c" 9 | -------------------------------------------------------------------------------- /src/duo/config.lib: -------------------------------------------------------------------------------- 1 | ; Disk I/O board for Duodyne (https://github.com/lynchaj/duodyne) system 2 | ; Uses WIZ850io https://www.wiznet.io/product-item/wiz850io/ 3 | ; NVRAM (25LC512) is implemented on shared SPI bus 4 | ; SPI interface is based on MT011 5 | 6 | SPIDEV equ DUO 7 | NVRAM equ 1 ; true - has NVRAM 8 | NVWAIT equ 1 ; requires WIP wait 9 | NVERA equ 1 ; support erase commands 10 | 11 | spi equ 8ch ; base port of Duodyne Disk I/O SPI interface 12 | 13 | spi$wr equ spi+0 ; write and transfer 14 | spi$rd equ spi+1 ; read and transfer 15 | spi$ctl equ spi+2 ; control port (outputs) 16 | 17 | CS0 equ 00001000b 18 | CS1 equ 00010000b 19 | CS2 equ 00100000b 20 | CS3 equ 0 ; not available on Duodyne 21 | 22 | WZSCS equ CS0 ; ctl port val for WizNET /CS 23 | WZRST equ 0001b ; ctl port val for WizNet /RST 24 | NVSCS equ CS1 ; ctl port val for SPI NVRAM 25LC512 25 | -------------------------------------------------------------------------------- /src/duo/makevars: -------------------------------------------------------------------------------- 1 | TARGETS += nvram.com 2 | MPMTARG += nvram.com 3 | XCPN2 += cpnboot.com 4 | ND3DEP = ndos3wiz.com 5 | WZCDEPS += libnvram.rel 6 | WZCLINK = wizcfg,libwiznt,libnvram 7 | CPNLDR = $(BLD_SRC)/cpnldr-w.com 8 | CPBDEPS = libwiznt.rel libnvram.rel 9 | CPBLINK = ,libwiznt,libnvram 10 | -------------------------------------------------------------------------------- /src/duo/platform.asm: -------------------------------------------------------------------------------- 1 | public platfm 2 | platfm: db 'Duodyne WizNET$' 3 | end 4 | -------------------------------------------------------------------------------- /src/ft245r/chrio.asm: -------------------------------------------------------------------------------- 1 | ; SNIOS plug-in for Noberto's H89 USB/SERIAL board, 2 | ; Specifically, the FT245R chip. 3 | ; http://koyado.com/Heathkit/H-89_USB_Serial.html 4 | ; 5 | maclib z80 6 | maclib config 7 | 8 | public sendby,check,recvby,recvbt 9 | 10 | cseg 11 | 12 | ; Destroys C 13 | sendby: 14 | mov c,a 15 | sendb0: 16 | in STSPORT 17 | ani USBTXR 18 | jz sendb0 19 | mov a,c 20 | out USBPORT ; probably can't ever overrun? 21 | ret ; if not, should make this in-line 22 | 23 | check: 24 | ; do check for sane hardware... 25 | lxi h,0 26 | mvi e,3 ; approx 4.5 sec @ 2MHz 27 | check0: 28 | in STSPORT ; 11 29 | ani USBTXR ; 7, also NC 30 | rnz ; 5 (11) 31 | dcx h ; 6 32 | mov a,h ; 4 33 | ora l ; 4 34 | jnz check0 ; 10 = 47, * 65536 = 3080192 = 1.504 sec 35 | dcr e ; 4 36 | jnz check0 ; 10 37 | stc 38 | ret 39 | 40 | ; When using this, each byte must be coming soon... 41 | ; Destroys C 42 | ; Returns character in A 43 | recvby: 44 | push b 45 | lxi b,charTimeout 46 | recvb0: 47 | in STSPORT 48 | ani USBRXR 49 | jnz recvb1 50 | dcx b 51 | mov a,b 52 | ora c 53 | jnz recvb0 54 | pop b 55 | stc 56 | ret ; CY, timeout 57 | recvb1: 58 | in USBPORT 59 | pop b 60 | ret 61 | 62 | ; Receive initial message bytes (e.g. "++") 63 | ; Must preserve all regs (exc. A) 64 | ; May return CY on timeout. 65 | recvbt: 66 | push b 67 | lxi b,startTimeout 68 | recvbt0: 69 | in STSPORT 70 | ani USBRXR 71 | jnz recvbt1 72 | dcx b 73 | mov a,b 74 | ora c 75 | jnz recvbt0 76 | pop b 77 | stc 78 | ret ; CY, timeout 79 | recvbt1: 80 | in USBPORT 81 | pop b 82 | ret 83 | 84 | end 85 | -------------------------------------------------------------------------------- /src/ft245r/config.lib: -------------------------------------------------------------------------------- 1 | ; FT245R FIFO-to-USB module 2 | ; 3 | NVRAM equ 0 ; no NVRAM or special config needed 4 | 5 | USBPORT equ 0d8h ; port on H8/H89 interface 6 | STSPORT equ USBPORT+2 7 | ; Status port bits: 8 | ; bit 0: Tx space available in FIFO 9 | ; bit 1: Rx data available in FIFO 10 | 11 | USBRXR equ 00000010b ; Rx data available in FIFO 12 | USBTXR equ 00000001b ; Tx space available in FIFO 13 | 14 | -------------------------------------------------------------------------------- /src/ft245r/platform.asm: -------------------------------------------------------------------------------- 1 | public platfm 2 | platfm: db 'FT245R$' 3 | end 4 | -------------------------------------------------------------------------------- /src/gm.cpnet.asm: -------------------------------------------------------------------------------- 1 | ; default SYSTEM.DAT file for single-console system (e.g. CP/NET Server). 2 | ; Based on default$system$data in GENSYS.PLM 3 | ; 4 | ; If the XIOS support per-process drive protection (R/O vec), 5 | ; then the temp$file$drive must not be A: (or any protected drive). 6 | ; 7 | ; This should be assembled into the binary SYSTEM.DAT, 8 | ; and may be used as input to GENSYS (e.g. GENSYS $AR). 9 | 10 | ; Start of MP/M system data area 11 | mem$top: db 0ffh ; 64K address space 12 | nmb$cns: db 1 ; 1 console 13 | brkpt$RST: db 6 14 | sys$call$stks: db 0ffh ; system call stacks? 15 | bank$switched: db 0ffh ; bank-switch RAM 16 | z80$cpu: db 0ffh ; Z80 CPU 17 | banked$bdos: db 0ffh ; BNKBDOS 18 | xios$jmp$tbl$base: db 0 19 | resbdos$base: db 0 20 | mstr$cfg$tbl$addr: dw 0 21 | xdos$base: db 0 22 | rsp$base: db 0 23 | bnkxios$base: db 0 24 | bnkbdos$base: db 0 25 | nmb$mem$seg: db 8 ; Max possible memory 26 | ; base,size,attr,bank 27 | mem$seg$tbl: db 0,0c0h, 0, 0 28 | db 0,0c0h, 0, 1 29 | db 0,0c0h, 0, 2 30 | db 0,0c0h, 0, 3 31 | db 0,0c0h, 0, 4 32 | db 0,0c0h, 0, 5 33 | db 0,0c0h, 0, 6 34 | db 0,0c0h, 0, 7 35 | breakpoint$vector: dw 0,0,0,0,0,0,0,0 36 | ds 16 37 | user$stacks: dw 0,0,0,0,0,0,0,0 38 | compat$attrs: db 0ffh ; CP/NET typically needs compat attrs 39 | ds 23 40 | nmb$records: dw 0 ; filled in by GENSYS 41 | ticks$per$second: db 50 42 | system$drive: db 1 ; A: 43 | common$base: db 0c0h 44 | nmb$rsps: db 0 45 | listcpadr: dw 0 46 | submit$flags: dw 0,0,0,0,0,0,0,0 47 | copyright: db 'COPYRIGHT (C) 1981, DIGITAL RESEARCH ' 48 | serial$number: db '654321' 49 | max$locked$records: db 16 50 | max$open$files: db 16 51 | total$list$items: dw 0 52 | lock$free$space$adr: dw 0 53 | total$system$locked$records: db 32 54 | total$system$open$files: db 32 55 | day$file: db 0ffh 56 | temp$file$drive: db 'H'-40h ; H: is temp drive 57 | nmb$printers: db 1 ; 1 printer 58 | ds 43 59 | cmnxdos$base: db 0 60 | bnkxdos$base: db 0 61 | tmpd$base: db 0 62 | console$dat$base: db 0 63 | bdos$xdos$adr: dw 0 64 | tmp$base: db 0 65 | nmb$brsps: db 0 66 | brsp$base: db 0 67 | brspl: dw 0 68 | dw 0 69 | rspl: dw 0 70 | 71 | end 72 | -------------------------------------------------------------------------------- /src/h8xspi/config.lib: -------------------------------------------------------------------------------- 1 | ; H8xSPI board for H8/H89 systems. 2 | ; Uses WIZ850io https://www.wiznet.io/product-item/wiz850io/ 3 | 4 | SPIDEV equ H8xSPI 5 | NVRAM equ 1 ; true - has NVRAM 6 | NVWAIT equ 1 ; requires WIP wait 7 | NVERA equ 1 ; support erase commands 8 | 9 | spi equ 40h ; base port of H8-WIZx50io SPI interface 10 | 11 | spi$wr equ spi+0 ; write and transfer 12 | spi$rd equ spi+0 ; read and transfer 13 | spi$ctl equ spi+1 ; control port 14 | 15 | CS0 equ 00000001b 16 | CS1 equ 00000010b 17 | CS2 equ 00000100b 18 | CS3 equ 00001000b 19 | 20 | WZSCS equ CS0 ; ctl port val for WizNET /CS 21 | WZRST equ 0000b ; /RST connected to system /RESET 22 | NVSCS equ CS1 23 | -------------------------------------------------------------------------------- /src/h8xspi/makevars: -------------------------------------------------------------------------------- 1 | TARGETS += nvram.com 2 | ND3DEP = ndos3wiz.com 3 | WZCDEPS += libnvram.rel 4 | WZCLINK = wizcfg,libwiznt,libnvram 5 | CPNLDR = $(BLD_SRC)/cpnldr-w.com 6 | -------------------------------------------------------------------------------- /src/h8xspi/platform.asm: -------------------------------------------------------------------------------- 1 | public platfm 2 | platfm: db 'H8xSPI WizNET$' 3 | end 4 | -------------------------------------------------------------------------------- /src/ins8250/chrio.asm: -------------------------------------------------------------------------------- 1 | ; SNIOS plug-in for INS8250 and clones 2 | ; 3 | maclib z80 4 | maclib config 5 | 6 | public sendby,check,recvby,recvbt 7 | 8 | cseg 9 | 10 | ; Destroys C 11 | sendby: 12 | mov c,a 13 | sendb0: 14 | in STSPORT 15 | ani SERTXR 16 | jz sendb0 17 | mov a,c 18 | out SERPORT ; probably can't ever overrun? 19 | ret ; if not, should make this in-line 20 | 21 | check: 22 | ; initialize UART (baud) 23 | lxi h,SERBAUD 24 | mvi a,SERLCR+SERDLAB 25 | out SERPORT+3 26 | mov a,h 27 | out SERPORT+1 28 | mov a,l 29 | out SERPORT+0 30 | mvi a,SERLCR 31 | out SERPORT+3 32 | xra a ; interrupts off 33 | out SERPORT+1 34 | mvi a,SERMCR 35 | out SERPORT+4 ; set handshake outputs 36 | ; do check for sane hardware... 37 | lxi h,0 38 | mvi e,3 ; approx 4.5 sec @ 2MHz 39 | check0: 40 | in STSPORT ; 11 41 | ani SERTXR ; 7, also NC 42 | rnz ; 5 (11) 43 | dcx h ; 6 44 | mov a,h ; 4 45 | ora l ; 4 46 | jnz check0 ; 10 = 47, * 65536 = 3080192 = 1.504 sec 47 | dcr e ; 4 48 | jnz check0 ; 10 49 | stc 50 | ret 51 | 52 | ; When using this, each byte must be coming soon... 53 | ; Destroys C 54 | ; Returns character in A, CY on timeout 55 | recvby: 56 | push b 57 | lxi b,charTimeout 58 | recvb0: 59 | in STSPORT 60 | ani SERRXR 61 | jnz recvb1 62 | dcx b 63 | mov a,b 64 | ora c 65 | jnz recvb0 66 | pop b 67 | stc 68 | ret ; CY, timeout 69 | recvb1: 70 | in SERPORT 71 | pop b 72 | ret 73 | 74 | ; Receive initial message bytes (e.g. "++" or ENQ) 75 | ; Must preserve all regs (exc. A) 76 | ; Destroys C 77 | ; Returns character in A 78 | ; May return CY on timeout. 79 | recvbt: 80 | push b 81 | lxi b,startTimeout 82 | jr recvb0 83 | 84 | end 85 | -------------------------------------------------------------------------------- /src/ins8250/config.lib: -------------------------------------------------------------------------------- 1 | ; INS8250 UART, and compatibles (16550, 16C2550, ...) 2 | ; 3 | NVRAM equ 0 ; no NVRAM or special config needed 4 | 5 | SERPORT equ 0e0h ; "lp" port on H8/H89 interface 6 | STSPORT equ SERPORT+5 7 | 8 | ; TODO: use hardware handshake? 9 | SERRXR equ 00000001b ; Rx data available 10 | SERTXR equ 00100000b ; Tx holding reg empty 11 | SERDLAB equ 10000000b 12 | 13 | ; Port settings 14 | SERBAUD equ 000ch ; 9600 baud with standard 1.8432 MHz xtal, 16X 15 | SERLCR equ 00000011b ; 8 bit, 1 stop, no parity 16 | SERMCR equ 00001111b ; set all handshake lines ON 17 | -------------------------------------------------------------------------------- /src/ins8250/platform.asm: -------------------------------------------------------------------------------- 1 | public platfm 2 | platfm: db 'INS8250$' 3 | end 4 | -------------------------------------------------------------------------------- /src/kaypro/chrio.asm: -------------------------------------------------------------------------------- 1 | ; SNIOS plug-in for Z80-SIO 2 | ; 3 | maclib z80 4 | maclib config 5 | 6 | public sendby,check,recvby,recvbt 7 | 8 | cseg 9 | 10 | ; Destroys C 11 | sendby: 12 | mov c,a 13 | sendb0: 14 | xra a 15 | out CMDPORT 16 | in CMDPORT 17 | ani SERTXR 18 | jz sendb0 19 | mov a,c 20 | out SERPORT ; probably can't ever overrun? 21 | ret ; if not, should make this in-line 22 | 23 | sioprg: db 1,0 ; WR1, all off 24 | db 3,SIOWR3 ; WR3 Rx 25 | db 4,SIOWR4 ; WR4 UART 26 | db 5,SIOWR5 ; WR5 Tx 27 | prglen equ $-sioprg 28 | 29 | check: 30 | ; initialize UART (baud) 31 | mvi a,SERBAUD 32 | out BAUDPRT 33 | mvi c,CMDPORT 34 | lxi h,sioprg 35 | mvi b,prglen 36 | outir 37 | ; do check for sane hardware... 38 | lxi h,6452 ; approx 0.1 sec 39 | check0: 40 | xra a ; 4 41 | out CMDPORT ; 11 42 | in CMDPORT ; 11 43 | ani SERTXR ; 7, also NC 44 | rnz ; 5 (11) 45 | dcx h ; 6 46 | mov a,h ; 4 47 | ora l ; 4 48 | jnz check0 ; 10 = 62, * 6452 = 40000 = 0.1 sec 49 | stc 50 | ret 51 | 52 | ; When using this, each byte must be coming soon... 53 | ; Destroys C 54 | ; Returns character in A, CY on timeout 55 | recvby: 56 | push b 57 | lxi b,charTimeout*2 ; adjust to 4MHz 58 | recvb0: 59 | xra a 60 | out CMDPORT 61 | in CMDPORT 62 | ani SERRXR 63 | jnz recvb1 64 | dcx b 65 | mov a,b 66 | ora c 67 | jnz recvb0 68 | pop b 69 | mvi a,4 ; BEEP on timeout 70 | out 05h 71 | stc 72 | ret ; CY, timeout 73 | recvb1: 74 | in SERPORT 75 | pop b 76 | ret 77 | 78 | ; Receive initial message bytes (e.g. "++" or ENQ) 79 | ; Must preserve all regs (exc. A) 80 | ; Destroys C 81 | ; Returns character in A 82 | ; May return CY on timeout. 83 | recvbt: 84 | push b 85 | lxi b,startTimeout*2 ; adjust to 4MHz 86 | jr recvb0 87 | 88 | end 89 | -------------------------------------------------------------------------------- /src/kaypro/config.lib: -------------------------------------------------------------------------------- 1 | ; Z80-SIO UART and WD1943 BAUD generator. 2 | ; 3 | NVRAM equ 0 ; no NVRAM or special config needed 4 | 5 | SERPORT equ 004h ; "serial data" port on Kaypro 6 | CMDPORT equ SERPORT+2 7 | BAUDA equ 000h ; For Serial Data 8 | BAUDB equ 008h ; For Serial Printer 9 | BAUDPRT equ BAUDA ; Use Serial Data Baud 10 | 11 | ; TODO: use hardware handshake? 12 | SERRXR equ 00000001b ; RR0: Rx data available 13 | SERTXR equ 00000100b ; RR0: Tx holding reg empty 14 | 15 | ; Port settings 16 | SERBAUD equ 00eh ; 9600 baud with standard 5.0688 MHz xtal, 16X 17 | ; 19200 baud is 00fh... 18 | SIOWR3 equ 11000001b ; Rx: 8 bits, enable 19 | SIOWR4 equ 01000100b ; 16x, no parity, 1 stop 20 | SIOWR5 equ 11101010b ; Tx: DTR, RTS, 8 bits, enable 21 | -------------------------------------------------------------------------------- /src/kaypro/platform.asm: -------------------------------------------------------------------------------- 1 | public platfm 2 | platfm: db 'Kaypro$' 3 | end 4 | -------------------------------------------------------------------------------- /src/libcpnet.asm: -------------------------------------------------------------------------------- 1 | ; Basic CP/NET routines 2 | 3 | public cpnsetup 4 | 5 | maclib z80 6 | 7 | bdos equ 5 8 | 9 | print equ 9 10 | 11 | cr equ 13 12 | lf equ 10 13 | 14 | cseg 15 | 16 | ; HL=network config table 17 | ; DE=template (0FFH=skip) 18 | ; Reports any valid settings, assumes starting on newline 19 | cpnsetup: 20 | mvi b,16 ; 16 drives 21 | cpns0: inx h ; skip status/node ID 22 | inx h 23 | inx d 24 | inx d 25 | ldax d ; 26 | cpi 0ffh 27 | cnz netdrv 28 | djnz cpns0 29 | ; drives done, skip CON: 30 | inx h 31 | inx h 32 | inx d 33 | inx d 34 | ; check LST: 35 | ldax d 36 | cpi 0ffh 37 | rz 38 | mov m,a 39 | sta b0 40 | inx h 41 | inx d 42 | ldax d 43 | mov m,a 44 | sta b1 45 | lda b0 46 | ani 080h 47 | jrz loclst 48 | ; networked LST: 49 | ani 0fh 50 | lxi h,nl1 51 | call hexdig 52 | lda b1 53 | lxi h,nl2 54 | call hexout 55 | lxi d,nlst 56 | mvi c,print 57 | call bdos 58 | ret 59 | loclst: lxi d,llst 60 | mvi c,print 61 | call bdos 62 | ret 63 | 64 | netdrv: push h 65 | push d 66 | ldax d 67 | mov m,a 68 | sta b0 69 | inx h 70 | inx d 71 | ldax d 72 | mov m,a 73 | sta b1 74 | ; report drive setting 75 | push b 76 | mvi a,16 77 | sub b ; local drive number 78 | adi 'A' 79 | sta n0 80 | sta l0 81 | lda b0 82 | ani 080h 83 | jrz locdrv 84 | ; networked drive 85 | lda b0 86 | ani 0fh 87 | adi 'A' 88 | sta n1 89 | lda b1 90 | lxi h,n2 91 | call hexout 92 | lxi d,netwk 93 | mvi c,print 94 | call bdos 95 | jr retdrv 96 | 97 | locdrv: lxi d,ldrv 98 | mvi c,print 99 | call bdos 100 | retdrv: 101 | pop b 102 | pop d 103 | pop h 104 | ret 105 | 106 | hexout: push psw 107 | rrc 108 | rrc 109 | rrc 110 | rrc 111 | call hexdig 112 | pop psw 113 | hexdig: ani 0fh 114 | adi 90h 115 | daa 116 | aci 40h 117 | daa 118 | mov m,a 119 | inx h 120 | ret 121 | 122 | dseg 123 | b0: db 0 124 | b1: db 0 125 | 126 | ldrv: db 'Local ' 127 | l0: db '_:',cr,lf,'$' 128 | netwk: db 'Network ' 129 | n0: db '_: = ' 130 | n1: db '_:[' 131 | n2: db '__]',cr,lf,'$' 132 | 133 | llst: db 'Local LST:',cr,lf,'$' 134 | nlst: db 'Network LST: = ' 135 | nl1: db '_[' 136 | nl2: db '__]',cr,lf,'$' 137 | 138 | end 139 | -------------------------------------------------------------------------------- /src/libnvram.asm: -------------------------------------------------------------------------------- 1 | ; NVRAM library 2 | public cksum32, vcksum, scksum, nvget 3 | 4 | maclib z80 5 | maclib config 6 | 7 | ; NVRAM/SEEPROM commands 8 | NVRD equ 00000011b 9 | NVWR equ 00000010b 10 | RDSR equ 00000101b 11 | WREN equ 00000110b 12 | ; NVRAM/SEEPROM status bits 13 | WIP equ 00000001b 14 | 15 | cseg 16 | 17 | ; IX = buffer, BC = length 18 | ; return: HL = cksum hi, DE = cksum lo 19 | cksum32: 20 | lxi h,0 21 | lxi d,0 22 | cks0: ldx a,+0 23 | inxix 24 | add e 25 | mov e,a 26 | jrnc cks1 27 | inr d 28 | jrnz cks1 29 | inr l 30 | jrnz cks1 31 | inr h 32 | cks1: dcx b 33 | mov a,b 34 | ora c 35 | jrnz cks0 36 | ret 37 | 38 | ; Validates checksum in buffer IX 39 | ; return: NZ on checksum error 40 | ; a checksum of 00 00 00 00 means the buffer was all 00, 41 | ; which is invalid. 42 | vcksum: 43 | pushix 44 | lxi b,508 45 | call cksum32 ; HL:DE is checksum 46 | popix 47 | lxi b,500 ; get IX displacement in range... 48 | dadx b 49 | ldx c,+10 50 | ldx b,+11 51 | mov a,b ; 52 | ora c ; check first half zero 53 | dsbc b 54 | rnz 55 | ldx c,+08 56 | ldx b,+09 57 | ora b ; 58 | ora c ; check second half zero 59 | xchg 60 | dsbc b ; CY is clear 61 | rnz 62 | ora a ; was checksum all zero? 63 | jrz vcksm0 64 | xra a ; ZR 65 | ret 66 | vcksm0: inr a ; NZ 67 | ret 68 | 69 | ; Sets checksum in buffer IX 70 | ; Destroys (all) 71 | scksum: 72 | pushix 73 | lxi b,508 74 | call cksum32 75 | popix 76 | lxi b,500 ; get IX displacement in range... 77 | dadx b 78 | stx l,+10 79 | stx h,+11 80 | stx e,+08 81 | stx d,+09 82 | ret 83 | 84 | ; IX=buffer, HL = nvram address, DE = length 85 | nvget: 86 | mvi a,NVSCS 87 | out spi$ctl 88 | mvi a,NVRD 89 | out spi$wr 90 | mov a,h 91 | out spi$wr 92 | mov a,l 93 | out spi$wr 94 | in spi$rd ; prime pump 95 | mvi c,spi$rd 96 | mov a,e 97 | ora a 98 | jz nvget1 99 | inr d ; TODO: handle 64K... and overflow of 'buf'... 100 | nvget1: pushix 101 | pop h 102 | mov b,e 103 | nvget0: inir ; B = 0 after 104 | dcr d 105 | jrnz nvget0 106 | xra a ; not SCS 107 | out spi$ctl 108 | ret 109 | 110 | end 111 | -------------------------------------------------------------------------------- /src/minz/chrio.asm: -------------------------------------------------------------------------------- 1 | ; SNIOS I/O module for Z180 ASCI1 on MinZ-U 2 | 3 | maclib z180 4 | maclib config 5 | 6 | public sendby,check,recvby,recvbt 7 | 8 | cseg 9 | 10 | check: ; validate existence of port, also initialize 11 | mvi a,0ffh ; high = inactive (off) during init 12 | out0 a,trdr 13 | mvi a,10h 14 | out0 a,cntr ; shift out new /RTS value 15 | mvi a,00010100b ; disable Rx/Tx for init 16 | out0 a,ctla 17 | mvi a,00000100b ; need CTS1E=1... 18 | out0 a,stat 19 | lda 004fh ; CPU speed stored here 20 | cpi 36 21 | jrz ck2 22 | ; 33.333MHz, 115200 baud TCR to ~115400 baud 23 | mvi a,00000000b+asc$ps+asc$dr 24 | out0 a,ctlb 25 | mvi a,00000000b+asc$brg 26 | out0 a,asxt 27 | if astc 28 | lxi h,astc 29 | out0 l,astcl 30 | out0 h,astch 31 | endif 32 | jr ck3 33 | ck2: ; 36.864MHz uses "standard" dividers to 230800 baud 34 | mvi a,00000000b+fst$brg 35 | out0 a,asxt 36 | mvi a,00000000b+fst$ps+fst$dr+fst$ss 37 | out0 a,ctlb 38 | ck3: 39 | mvi a,01101100b ; enable Rx/Tx, CKA1D off, EFR 40 | out0 a,ctla 41 | ; ASCI1 on MinZ uses CSIO for RTS... 42 | xra a ; low = active (on) 43 | out0 a,trdr 44 | mvi a,10h 45 | out0 a,cntr ; shift out new /RTS value 46 | if 1 ; why is delay needed? 47 | lxi b,0100h 48 | ck0: dcx b 49 | mov a,b 50 | ora c 51 | jrnz ck0 52 | endif 53 | xra a 54 | ret 55 | 56 | sendby: push psw 57 | conot1: 58 | in0 a,ctlb 59 | ani 00100000b ; /CTS 60 | jrnz conot1 61 | in0 a,stat 62 | ani 00000010b ; TDRE 63 | jrz conot1 64 | pop psw 65 | out0 a,tdr 66 | ret 67 | 68 | ; For CP/NET, wait long timeout for first char 69 | ; Return: CY=timeout else A=char 70 | ; At 115200, one char is 1600 cycles... 71 | recvbt: 72 | push d 73 | push b 74 | mvi d,20 ; 20x = 3.1 seconds (5.6 seconds) 75 | rcvb0: ; loop = 156mS 76 | lxi b,0 ; 65536* = 2883584 = 5177344 77 | rcvb1: ; 0-wait 3-wait 78 | in0 a,stat ; 12 21? 79 | ani 10000000b ; 6 12 80 | jrnz rcvb2 ; 6n 12n 81 | dcx b ; 4 7 82 | mov a,b ; 4 7 83 | ora c ; 4 7 84 | jrnz rcvb1 ; 8t = 44 14t = 80 85 | dcr d 86 | jrnz rcvb0 87 | pop b 88 | pop d 89 | stc 90 | ret 91 | rcvb2: in0 a,rdr ; CY=0 from ANI 92 | pop b 93 | pop d 94 | ret 95 | 96 | ; For CP/NET, wait short timeout for next char 97 | recvby: 98 | push d 99 | push b 100 | mvi d,2 ; 2x = 312mS for next char 101 | jr rcvb0 102 | -------------------------------------------------------------------------------- /src/minz/config.lib: -------------------------------------------------------------------------------- 1 | ; The MinZ-U supports CTS on ASCI1, so we can use that port 2 | ; and leave CON: on ASCI0. 3 | 4 | NVRAM equ 0 ; no NVRAM or special config needed 5 | 6 | ; Z80S180 ASCI1 registers 7 | ctla equ 01h 8 | ctlb equ 03h ; for CTS 9 | stat equ 05h 10 | tdr equ 07h 11 | rdr equ 09h 12 | asxt equ 13h 13 | astcl equ 1ch 14 | astch equ 1dh 15 | ; For ASCI1 RTS control 16 | trdr equ 0bh 17 | cntr equ 0ah 18 | 19 | ; For 115200 baud with 16.667MHz clock, 20 | ; overclocked to 33.333MHz phy. 21 | 22 | ; Settings for 115200 baud at 33.334MHz 23 | asc$ss equ 00000$000b ; SS0-2, divide by 1 (*) 24 | asc$ps equ 00$0$00000b ; PS=0: divide by 10 (*) 25 | asc$dr equ 0000$0$000b ; DR=0: divide by 16 26 | asc$brg equ 0000$1$000b ; BRG=1: PS/SS0-2 ignored 27 | astc equ 0007h ; non-zero means set value 28 | ; baud = phi / (2 * (2 + astc)) 29 | ; 33.334MHz/18/16 = 115743 baud (~115200) 30 | 31 | ; For 230800 baud with 18.432MHz clock, 32 | ; overclocked to 36.864MHz phy. 33 | fst$ss equ 00000$000b ; SS0-2, divide by 1 34 | fst$ps equ 00$0$00000b ; PS=0: divide by 10 35 | fst$dr equ 0000$0$000b ; DR=0: divide by 16 36 | fst$brg equ 0000$0$000b ; BRG=0: PS/SS0-2 valid 37 | -------------------------------------------------------------------------------- /src/minz/makevars: -------------------------------------------------------------------------------- 1 | LIBS += z180.lib 2 | SNDEPS += chrio.rel 3 | SNLINK = snios,chrio 4 | XCPN2 += cpnboot.com 5 | CPBDEPS = 6 | CPBLINK = 7 | -------------------------------------------------------------------------------- /src/minz/platform.asm: -------------------------------------------------------------------------------- 1 | public platfm 2 | platfm: db 'MinZ ASCI1$' 3 | end 4 | -------------------------------------------------------------------------------- /src/mt011/config.lib: -------------------------------------------------------------------------------- 1 | ; MT011_SPI_WIZNET board for RC2014-Z80 systems. 2 | ; Uses "Ethernet FeatherWing" http://adafru.it/3201 3 | 4 | SPIDEV equ MT011 5 | NVRAM equ 1 ; true - has NVRAM 6 | NVWAIT equ 0 ; no WIP needed 7 | NVERA equ 0 ; has no erase commands 8 | 9 | spi equ 5ch ; base port of MT011_SPI_WIZNET SPI interface 10 | ; base port can also be 1ch to match MarkT's s/w 11 | 12 | spi$wr equ spi+0 ; write and transfer 13 | spi$rd equ spi+1 ; read and transfer 14 | spi$ctl equ spi+2 ; control port (outputs) 15 | 16 | CS0 equ 00001000b 17 | CS1 equ 00010000b 18 | CS2 equ 00100000b 19 | CS3 equ 0 ; not available on MT011 20 | 21 | WZSCS equ CS0 ; ctl port val for WizNET /CS 22 | WZRST equ 0001b ; Not attached inside FeatherWing module 23 | NVSCS equ CS2 24 | -------------------------------------------------------------------------------- /src/mt011/makevars: -------------------------------------------------------------------------------- 1 | TARGETS += nvram.com 2 | MPMTARG += nvram.com 3 | XCPN2 += cpnboot.com 4 | ND3DEP = ndos3wiz.com 5 | WZCDEPS += libnvram.rel 6 | WZCLINK = wizcfg,libwiznt,libnvram 7 | CPNLDR = $(BLD_SRC)/cpnldr-w.com 8 | CPBDEPS = libwiznt.rel libnvram.rel 9 | CPBLINK = ,libwiznt,libnvram 10 | -------------------------------------------------------------------------------- /src/mt011/platform.asm: -------------------------------------------------------------------------------- 1 | public platfm 2 | platfm: db 'MT011 WizNET$' 3 | end 4 | -------------------------------------------------------------------------------- /src/ndos3dup.asm: -------------------------------------------------------------------------------- 1 | ; Generic initialization code for NDOS3. 2 | ; Prevents duplicate NDOS3 loading. 3 | ; 4 | maclib z80 5 | 6 | cr equ 13 7 | lf equ 10 8 | 9 | ; System page-0 constants 10 | cpm equ 0 11 | bdos equ 5 12 | 13 | ; BDOS functions 14 | print equ 9 15 | 16 | ; RSX is already linked-in, but might be a duplicate 17 | 18 | org 100h 19 | lxi sp,stack 20 | 21 | lixd bdos+1 ; this should be our NDOS3 22 | sixd us 23 | jmp dup0 24 | dup1: 25 | ldx a,+18 ; LOADER3? 26 | cpi 0ffh 27 | jz ldr3 28 | call chkdup 29 | lxi d,dupmsg 30 | jz rm$us ; duplicate NDOS3, remove "us" 31 | dup0: 32 | ldx l,+4 ; next RSX... 33 | ldx h,+5 ; 34 | push h 35 | popix 36 | jmp dup1 37 | 38 | ; DE = message to print 39 | rm$us: 40 | lixd us 41 | mvix 0ffh,+8 ; set remove flag 42 | ; also short-circuit it 43 | ldx l,+4 ; next RSX... 44 | ldx h,+5 ; 45 | stx l,+1 ; by-pass duplicate 46 | stx h,+2 ; 47 | ; report what happened 48 | mvi c,print 49 | call bdos 50 | jmp cpm 51 | 52 | ; hit LOADER3 RSX, no dup found... 53 | ldr3: 54 | jmp cpm ; let RSX init itself 55 | 56 | chkdup: pushix 57 | pop h 58 | lxi d,10 ; offset of name 59 | dad d 60 | lxi d,ndos3 61 | lxi b,8 62 | chk0: ldax d 63 | cmp m 64 | rnz 65 | inx h 66 | inx d 67 | dcx b 68 | mov a,b 69 | ora c 70 | jnz chk0 71 | ret ; ZR = match 72 | 73 | us: dw 0 ; our copy of NDOS3 (remove if dup) 74 | 75 | dupmsg: db 'NDOS3 already loaded',cr,lf,'$' 76 | ndos3: db 'NDOS3 ' 77 | 78 | ds 64 79 | stack: ds 0 80 | 81 | end 82 | -------------------------------------------------------------------------------- /src/ndos3wiz.asm: -------------------------------------------------------------------------------- 1 | ; Initialization code for NDOS3 on WIZ850io 2 | ; Checks for CP/NET already running, then initializes WIZ850io 3 | ; 4 | maclib z80 5 | 6 | extrn wizcfg 7 | extrn cpnsetup 8 | public nvbuf 9 | 10 | cr equ 13 11 | lf equ 10 12 | 13 | ; System page-0 constants 14 | cpm equ 0 15 | bdos equ 5 16 | 17 | ; BDOS functions 18 | print equ 9 19 | vers equ 12 20 | ; NDOS functions 21 | cfgtbl equ 69 22 | 23 | ; RSX is already linked-in, but might be a duplicate 24 | 25 | cseg 26 | lxi sp,stack 27 | 28 | lixd bdos+1 ; this should be our NDOS3 29 | sixd us 30 | ldx l,+4 ; next RSX... 31 | ldx h,+5 ; 32 | shld next 33 | mvi c,vers 34 | call bdose ; by-pass ourself 35 | mov a,h 36 | ani 02h 37 | jz ldr3 38 | lixd us 39 | mvix 0ffh,+8 ; set remove flag 40 | ; also short-circuit it 41 | ldx l,+4 ; next RSX... 42 | ldx h,+5 ; 43 | stx l,+1 ; by-pass duplicate 44 | stx h,+2 ; 45 | ; report what happened 46 | lxi d,dupmsg 47 | mvi c,print 48 | call bdos 49 | jmp cpm 50 | 51 | ; hit LOADER3 RSX, no dup found... 52 | ldr3: 53 | call wizcfg 54 | jrc wizerr 55 | ; This will also cold-start NDOS... 56 | ; hopefully, no bad effects. 57 | mvi c,cfgtbl 58 | call bdos 59 | ; HL=cfgtbl (check error?) 60 | lxi d,nvbuf+288 ; 64 bytes for cfgtbl template 61 | call cpnsetup 62 | jmp cpm 63 | wizerr: 64 | call nocfg ; report error, but continue... 65 | jmp cpm ; let RSX init itself 66 | 67 | nocfg: lxi d,ncfg 68 | mvi c,print 69 | jmp bdos 70 | 71 | bdose: lhld next 72 | pchl 73 | 74 | dseg 75 | us: dw 0 ; our copy of NDOS3 (remove if dup) 76 | next: dw 0 77 | 78 | dupmsg: db 'CP/NET already loaded',cr,lf,'$' 79 | ncfg: db 'NVRAM not configured',cr,lf,'$' 80 | 81 | ds 64 82 | stack: ds 0 83 | 84 | nvbuf: ds 512 85 | 86 | end 87 | -------------------------------------------------------------------------------- /src/netboot.asm: -------------------------------------------------------------------------------- 1 | ; Implementation of the Network Boot protocol 2 | 3 | maclib z80 4 | 5 | public netboot 6 | ; from caller 7 | extrn ldmsg,srvid 8 | ; from linked SNIOS 9 | extrn NTWKIN,NTWKST,CNFTBL,SNDMSG,RCVMSG,NTWKER,NTWKBT,NTWKDN,CFGTBL 10 | 11 | false equ 0 12 | true equ not false 13 | 14 | $*MACRO 15 | 16 | ; offsets in msgbuf 17 | FMT equ 0 18 | DID equ 1 19 | SID equ 2 20 | FNC equ 3 21 | SIZ equ 4 22 | DAT equ 5 23 | 24 | cseg 25 | 26 | error: lda init 27 | ora a 28 | cnz NTWKDN 29 | stc 30 | ret 31 | 32 | ; Called with HL=msgbuf, filled out for first message (boot request) 33 | ; FNC, SIZ, and DAT... must be valid 34 | ; Return CY on error, else HL=start address 35 | netboot: 36 | push h 37 | call NTWKIN 38 | popix 39 | ora a 40 | jrnz error 41 | cma 42 | sta init 43 | loop: 44 | lda srvid 45 | stx a,DID 46 | lda CFGTBL+1 47 | stx a,SID 48 | mvix 0b0h,FMT 49 | call netsr ; send request, receive response 50 | rc ; network error 51 | ldx a,FMT 52 | cpi 0b1h 53 | jrnz error ; invalid response 54 | ldx a,FNC 55 | ora a 56 | jrz error ; NAK 57 | dcr a 58 | jrz ldtxt 59 | dcr a 60 | jrz stdma 61 | dcr a 62 | jrz load 63 | dcr a 64 | jrnz error ; unsupported function 65 | ; done - execute boot code 66 | ldx l,DAT 67 | ldx h,DAT+1 68 | xra a 69 | ret 70 | load: lhld dma 71 | xchg 72 | pushix 73 | pop h 74 | lxi b,DAT 75 | dad b 76 | lxi b,128 77 | ldir 78 | xchg 79 | shld dma 80 | netack: 81 | mvix 0,FNC ; ACK, get next 82 | mvix 0,SIZ 83 | jr loop 84 | stdma: 85 | ldx l,DAT 86 | ldx h,DAT+1 87 | shld dma 88 | jr netack 89 | ldtxt: 90 | pushix 91 | pop h 92 | push h 93 | lxi b,DAT 94 | dad b 95 | call ldmsg 96 | popix 97 | jr netack 98 | 99 | ; Returns CY on error 100 | netsr: ; must preserve IX 101 | pushix 102 | pop b 103 | push b 104 | call SNDMSG 105 | pop b 106 | ora a 107 | push b 108 | cz RCVMSG 109 | popix 110 | ora a 111 | rz 112 | stc 113 | ret 114 | 115 | dseg 116 | dma: dw 0 117 | init: db 0 118 | 119 | end 120 | -------------------------------------------------------------------------------- /src/netdown.asm: -------------------------------------------------------------------------------- 1 | ; NETDOWN - shutdown CP/NET 1.2 SNIOS and prepare for RESET 2 | 3 | maclib z80 4 | 5 | cr equ 13 6 | lf equ 10 7 | 8 | cpm equ 0 9 | bdos equ 5 10 | 11 | ; BDOS functions 12 | conin equ 1 13 | print equ 9 14 | getver equ 12 15 | ; CP/M 3 only 16 | callrsx equ 60 17 | ; NDOS functions 18 | netcfg equ 69 19 | 20 | org 0100h 21 | jmp start 22 | 23 | nocpn db 'Requires CP/NET 1.2',cr,lf,'$' 24 | rdymsg: db 'Ready for RESET/power-off',cr,lf 25 | db '(press any key to resume CP/NET)$' 26 | xsnios: db 'Not a recognized SNIOS',cr,lf,'$' 27 | norsx: db 'No NDOS3 RSX or not removable',cr,lf,'$' 28 | 29 | xconp: dw 0 ; CON: word in network config table 30 | xcon: db 0 ; saved CON: byte 31 | 32 | start: lxi sp,stack 33 | mvi c,getver 34 | call bdos 35 | mov a,h 36 | ani 02h 37 | jz notnet 38 | mov a,l 39 | cpi 30h 40 | jnc cpnet3 41 | mvi c,netcfg 42 | call bdos 43 | push h 44 | lxi d,34 ; CON: word offset 45 | dad d 46 | shld xconp 47 | popix 48 | ; check for at least 6 JMPs... 49 | ldx c,-3 50 | ldx b,-6 51 | ldx e,-9 52 | ldx d,-12 53 | ldx l,-15 54 | ldx h,-18 55 | mov a,c 56 | ana b 57 | ana e 58 | ana d 59 | ana l 60 | ana h 61 | cpi 0c3h ;JMP? 62 | jnz notcom 63 | mov a,c 64 | ora b 65 | ora e 66 | ora d 67 | ora l 68 | ora h 69 | cpi 0c3h ;JMP? 70 | jnz notcom 71 | ; looks OK, call NTWKDN... 72 | ; but first, make sure CON: is local... 73 | lhld xconp ; 74 | mov a,m ; 75 | sta xcon ; 76 | ani 01111111b 77 | mov m,a ; 78 | ldx l,-2 79 | ldx h,-1 80 | call callhl 81 | lxi d,rdymsg 82 | mvi c,print 83 | call bdos 84 | mvi c,conin 85 | call bdos 86 | ; if we return here, just resume... 87 | lhld xconp ; restore CON: 88 | lda xcon ; 89 | mov m,a ; 90 | jmp cpm 91 | 92 | callhl: pchl 93 | 94 | notnet: lxi d,nocpn 95 | mvi c,print 96 | call bdos 97 | jmp cpm 98 | 99 | ; Not a recognized SNIOS 100 | notcom: lxi d,xsnios 101 | mvi c,print 102 | call bdos 103 | jmp cpm 104 | 105 | cpnet3: ; CP/M 3 - use "RSXRM NDOS3" 106 | lxi d,rsxpb 107 | mvi c,callrsx 108 | call bdos 109 | ora a 110 | jz cpm 111 | lxi d,norsx 112 | mvi c,print 113 | call bdos 114 | jmp cpm 115 | 116 | rsxpb: db 113 ; "remove" - local extension 117 | db 1 ; one param, name of RSX 118 | dw ndos3 ; param1: name of RSX 119 | 120 | ndos3: db 'NDOS3 ' 121 | 122 | ds 64 123 | stack: ds 0 124 | 125 | end 126 | -------------------------------------------------------------------------------- /src/netstat.asm: -------------------------------------------------------------------------------- 1 | ; A version of CPNETSTS that minimizes output 2 | 3 | org 00100h 4 | 5 | jmp start 6 | 7 | l0103h: db 13,10,'CP/NET Status' 8 | db 13,10,'=============' 9 | db 13,10,'$' 10 | l012ch: db 'Requester ID = $' 11 | l013ch: db 13,10,'Network Status Byte = $' 12 | l0155h: db 13,10,'Device status:' 13 | db 13,10,'$' 14 | l016dh: db ' Drive $' 15 | l0176h: db ' = Drive $' 16 | l0180h: db ' on Network Server ID = $' 17 | l01a2h: db ' Console Device = $' 18 | l01b4h: db 'Console #$' 19 | l01ddh: db ' List Device = $' 20 | l01ech: db 'List #$' 21 | l01hhh: db ' All LOCAL$' 22 | l0212h: db 13,10,'CP/NET has not been loaded.$' 23 | 24 | start: 25 | lxi h,0 26 | dad sp 27 | shld usrstk 28 | lxi sp,stack 29 | call getver 30 | mov a,h 31 | ani 02h 32 | jz nocpnt 33 | 34 | lxi b,l0103h ; Intro 35 | call msgout 36 | call getcfg 37 | shld nettbl 38 | lxi b,l012ch ; Req ID (client ID) 39 | call msgout 40 | lhld nettbl 41 | inx h 42 | mov c,m 43 | call hexout 44 | lxi b,l013ch ; Net Sts Byte 45 | call msgout 46 | call getsts 47 | mov c,a 48 | call hexout 49 | lxi b,l0155h ; Disk device status: 50 | call msgout 51 | xra a 52 | sta count 53 | sta curdrv 54 | drvlup: 55 | lda curdrv 56 | cpi 16 57 | jnc trycon ; Done with drives A-P... 58 | 59 | mov l,a 60 | mvi h,0 61 | dad h ; *2 - 2 bytes per drive 62 | inx h 63 | inx h ; +2 - 2 bytes before drives 64 | xchg 65 | lhld nettbl 66 | dad d 67 | mov a,m 68 | ani 080h 69 | jz locdrv ; drive is local... 70 | 71 | push h 72 | lda count 73 | ora a 74 | cnz crlf 75 | lxi h,count 76 | inr m 77 | lxi b,l016dh ; Drive... 78 | call msgout 79 | lda curdrv 80 | adi 'A' 81 | mov c,a 82 | call chrout 83 | mvi c,':' 84 | call chrout 85 | lxi b,l0176h ; = Drive... i.e. REMOTE 86 | call msgout 87 | pop h 88 | push h 89 | mov a,m 90 | ani 00fh ; remote drive number 91 | adi 'A' 92 | mov c,a 93 | call chrout 94 | mvi c,':' 95 | call chrout 96 | lxi b,l0180h ; on server... 97 | call msgout 98 | pop h 99 | inx h 100 | mov a,m ; server ID 101 | mov c,a 102 | call hexout 103 | locdrv: ; Drive is LOCAL... 104 | lxi h,curdrv 105 | inr m 106 | jmp drvlup 107 | 108 | trycon: 109 | lxi b,00022h 110 | lhld nettbl 111 | dad b 112 | mov a,m 113 | ani 080h 114 | jz trylst 115 | 116 | push h 117 | lda count 118 | ora a 119 | cnz crlf 120 | lxi h,count 121 | inr m 122 | lxi b,l01a2h ; Console Device = ... 123 | call msgout 124 | lxi b,l01b4h ; Console # 125 | call msgout 126 | pop h 127 | push h 128 | mov a,m 129 | call hexdig 130 | lxi b,l0180h ; on Network Server ID = 131 | call msgout 132 | pop h 133 | inx h 134 | mov a,m 135 | mov c,a 136 | call hexout 137 | 138 | trylst: 139 | lxi b,00024h 140 | lhld nettbl 141 | dad b 142 | mov a,m 143 | ani 080h 144 | jz done 145 | 146 | push h 147 | lda count 148 | ora a 149 | cnz crlf 150 | lxi h,count 151 | inr m 152 | lxi b,l01ddh ; List Device = 153 | call msgout 154 | lxi b,l01ech ; List # 155 | call msgout 156 | pop h 157 | push h 158 | mov a,m 159 | call hexdig 160 | lxi b,l0180h ; on Network Server ID = 161 | call msgout 162 | pop h 163 | inx h 164 | mov a,m 165 | mov c,a 166 | call hexout 167 | done: 168 | lda count 169 | ora a 170 | jnz exit 171 | lxi b,l01hhh 172 | call msgout 173 | jmp exit 174 | 175 | nocpnt: 176 | lxi b,l0212h ; CP/NET has not been loaded 177 | call msgout 178 | exit: 179 | lhld usrstk 180 | sphl 181 | ret 182 | 183 | chrout: 184 | mov e,c 185 | mvi c,002h 186 | call 00005h 187 | ret 188 | 189 | msgout: 190 | mov d,b 191 | mov e,c 192 | mvi c,009h 193 | call 00005h 194 | ret 195 | 196 | getver: 197 | mvi c,12 198 | call 00005h 199 | ret 200 | 201 | getsts: 202 | mvi c,044h 203 | call 00005h 204 | ret 205 | 206 | getcfg: 207 | mvi c,045h 208 | call 00005h 209 | ret 210 | 211 | crlf: 212 | mvi c,13 213 | call chrout 214 | mvi c,10 215 | call chrout 216 | ret 217 | 218 | hexout: 219 | push b 220 | mov a,c 221 | rrc 222 | rrc 223 | rrc 224 | rrc 225 | call hexdig 226 | pop b 227 | mov a,c 228 | call hexdig 229 | mvi c,'H' 230 | call chrout 231 | ret 232 | 233 | hexdig: 234 | ani 0fh 235 | adi 90h 236 | daa 237 | aci 40h 238 | daa 239 | mov c,a 240 | jmp chrout 241 | 242 | ds 40 243 | stack: ds 0 244 | usrstk: dw 0 245 | count: db 0 246 | curdrv: db 0 247 | nettbl: dw 0 248 | 249 | end 250 | -------------------------------------------------------------------------------- /src/ntpdate.asm: -------------------------------------------------------------------------------- 1 | maclib z80 2 | 3 | extrn NTWKIN, NTWKST, CNFTBL, SNDMSG, RCVMSG, NTWKER, NTWKBT, NTWKDN, CFGTBL 4 | 5 | BDOS equ 0005h 6 | CMDLN equ 0080h 7 | 8 | ; BDOS functions 9 | CONOUT equ 2 10 | PRINT equ 9 11 | GETVER equ 12 12 | SGSCB equ 49 13 | 14 | ; CP/NET NDOS functions 15 | NSEND equ 66 16 | NRECV equ 67 17 | 18 | org 0100h 19 | jmp start 20 | 21 | ioport: db 018h 22 | 23 | vers: dw 0 24 | scbadr: dw 0 25 | 26 | gettime: db 0, 0, 2, 105, 0, 0 27 | gottime: db 1, 2, 0, 105, 4, 0, 0, 0, 0, 0 ; just prediction of what will be received 28 | 29 | scbpb: db 03ah ; offset of SCB address (reserved area) 30 | db 0 ; get word, (SCB address) 31 | dw 0 32 | 33 | ; assume < 100 34 | decout: 35 | mvi b,'0' 36 | decot0: 37 | sui 10 38 | jc decot1 39 | inr b 40 | jmp decot0 41 | decot1: 42 | adi 10 43 | adi '0' 44 | push psw 45 | mov a,b 46 | call prout 47 | pop psw 48 | jmp prout 49 | 50 | ; Keeps number in HL - caller must preserve/init 51 | ; Returns CY for invalid 52 | hexnum: 53 | sui '0' 54 | rc 55 | cpi 9+1 56 | jnc hexnm1 57 | hexnm2: 58 | dad h 59 | dad h 60 | dad h 61 | dad h 62 | ora l 63 | mov l,a 64 | ret 65 | hexnm1: 66 | sui 'A'-'9' 67 | rc 68 | cpi 5+1 69 | cmc 70 | rc 71 | adi 10 72 | jmp hexnm2 73 | 74 | hexout: 75 | push psw 76 | rrc 77 | rrc 78 | rrc 79 | rrc 80 | call hexdig 81 | pop psw 82 | hexdig: 83 | call tohex 84 | prout: 85 | mov e,a 86 | mvi c,CONOUT 87 | jmp BDOS 88 | 89 | tohex: 90 | ani 0fh 91 | adi 90h 92 | daa 93 | aci 40h 94 | daa 95 | ret 96 | 97 | wdays: db 'Sun$Mon$Tue$Wed$Thu$Fri$Sat$' 98 | 99 | ; HL = CP/M Date-time field, w/o seconds 100 | ; Print date and time to console. 101 | prdate: 102 | mov e,m 103 | inx h 104 | mov d,m 105 | inx h 106 | push h 107 | push d 108 | xchg 109 | call weekdy 110 | add a 111 | add a ; *4 112 | mov c,a 113 | mvi b,0 114 | lxi h,wdays 115 | dad b 116 | xchg 117 | call xitmsg 118 | mvi a,' ' 119 | call prout 120 | pop d 121 | ; compute year 122 | mvi c,78 ; base year, epoch, binary 123 | mvi b,078h ; year, BCD 124 | ; special-case date=0... 125 | mov a,e 126 | ora d 127 | jnz prdat0 128 | inx d 129 | prdat0: 130 | lxi h,365 131 | mov a,c 132 | ani 03h ; Not strictly true, but works until year 2100... 133 | jnz prdat1 134 | inx h 135 | prdat1: push h 136 | ora a 137 | dsbc d 138 | pop h 139 | jnc prdat2 ; done computing year... 140 | xchg 141 | ora a 142 | dsbc d 143 | xchg 144 | inr c 145 | mov a,b 146 | adi 1 147 | daa 148 | mov b,a 149 | jmp prdat0 150 | prdat2: ; DE = days within year 'C' 151 | push b ; save (2-digit) year, B = BCD, C = binary (until 2155) 152 | lxi h,month0+24 153 | mov a,c 154 | ani 03h 155 | jnz prdat3 156 | lxi h,month1+24 157 | prdat3: ; compute month, DE = days in year,HL = mon-yr-days table adj for leap 158 | mvi b,12 159 | prdat4: 160 | dcx h 161 | dcx h 162 | dcr b 163 | jm prdat5 ; should never happen... 164 | push h 165 | push d 166 | mov a,m 167 | inx h 168 | mov h,m 169 | mov l,a 170 | ; DE = days in year, HL = ytd[month] 171 | ora a 172 | dsbc d 173 | mov a,l ; potential remainder (neg) 174 | pop d 175 | pop h 176 | jnc prdat4 177 | prdat5: ; B = month, 0-11; A = -dom 178 | neg 179 | push psw 180 | inr b 181 | mov a,b 182 | call decout 183 | mvi e,'/' 184 | mvi c,CONOUT 185 | call BDOS 186 | pop psw 187 | call decout 188 | mvi e,'/' 189 | mvi c,CONOUT 190 | call BDOS 191 | pop b 192 | mov a,b ; already BCD 193 | call hexout 194 | mvi e,' ' 195 | mvi c,CONOUT 196 | call BDOS 197 | pop h ; -> BCD hours 198 | mov a,m 199 | inx h 200 | push h 201 | call hexout 202 | mvi e,':' 203 | mvi c,CONOUT 204 | call BDOS 205 | pop h ; -> BCD minutes 206 | mov a,m 207 | inx h 208 | push h 209 | call hexout 210 | mvi e,':' 211 | mvi c,CONOUT 212 | call BDOS 213 | pop h ; -> BCD seconds 214 | mov a,m 215 | jmp hexout 216 | 217 | ; J F M A M J J A S O N D 218 | month0: dw 0, 31, 59, 90,120,151,181,212,243,273,304,334 219 | month1: dw 0, 31, 60, 91,121,152,182,213,244,274,305,335 220 | 221 | start: 222 | mvi c,GETVER 223 | call BDOS 224 | shld vers 225 | mov a,l 226 | cpi 30 227 | jc badvers 228 | lxi h,CMDLN 229 | mov c,m 230 | inx h 231 | sid1: 232 | mov a,m 233 | cpi ' ' 234 | jnz sid0 235 | inx h 236 | dcr c 237 | jnz sid1 238 | jmp start1 ; no params, use defaults 239 | 240 | sid0: ; scan hex number as server ID 241 | xchg 242 | lxi h,0 243 | sid2: 244 | ldax d 245 | inx d 246 | call hexnum 247 | jc sid3 248 | dcr c 249 | jnz sid2 250 | sid3: 251 | mov a,l 252 | sta gettime+1 253 | 254 | start1: 255 | ; TODO: handle MP/M... 256 | lxi d,scbpb 257 | mvi c,SGSCB 258 | call BDOS 259 | shld scbadr 260 | 261 | lhld vers 262 | mvi a,2 ; bit for CP/Net 263 | ana h 264 | jz nocpnet 265 | 266 | lxi d,gettime 267 | mvi c,NSEND 268 | call BDOS 269 | ora a 270 | jnz error 271 | lxi d,gottime 272 | mvi c,NRECV 273 | call BDOS 274 | ora a 275 | jnz error 276 | jmp settime 277 | 278 | nocpnet: 279 | lda NTWKIN 280 | cpi 0c9h ; RET 281 | jz error2 282 | call NTWKIN 283 | lxi b, gettime 284 | call SNDMSG 285 | ora a 286 | jnz error 287 | 288 | lxi b, gottime 289 | call RCVMSG 290 | ora a 291 | jnz error 292 | call NTWKDN ; needed? desirable? 293 | settime: 294 | ; BDOS function 104 forces seconds to zero... 295 | ; but we need to inform the BIOS that time changed... 296 | ; So we set SCB fields then call BIOS function 297 | lhld scbadr 298 | lxi d,058h ; date/time 299 | dad d 300 | xchg 301 | lxi h,gottime+5 302 | lxi b,5 ; length of date/time 303 | di 304 | ldir 305 | ei 306 | lxi d,biospb 307 | mvi c,50 308 | call bdos 309 | lxi d,done 310 | mvi c,PRINT 311 | call BDOS 312 | lxi h,gottime+5 313 | call prdate 314 | ret 315 | 316 | biospb: db 26 ; BIOS TIME function 317 | db 0 ; A 318 | dw 00ffh ; BC - C=FF: SET TIME 319 | dw 0 ; DE 320 | dw 0 ; HL 321 | 322 | ; HL=CP/M date value (days since epoch) 323 | ; From DATE.PLM: week$day = (word$value + base$day - 1) mod 7; 324 | ; base$day lit '0', 325 | weekdy: dcx h ; 1/1/78 is "0" (Sun), -1 for offset 326 | lxi d,7000 327 | ora a 328 | wd0: dsbc d 329 | jrnc wd0 330 | dad d 331 | lxi d,700 332 | ora a 333 | wd1: dsbc d 334 | jrnc wd1 335 | dad d 336 | lxi d,70 337 | ora a 338 | wd2: dsbc d 339 | jrnc wd2 340 | dad d 341 | lxi d,7 342 | ora a 343 | wd3: dsbc d 344 | jrnc wd3 345 | dad d 346 | mov a,l 347 | ret 348 | 349 | error: 350 | lxi d,errmsg 351 | jmp xitmsg 352 | 353 | error2: 354 | lxi d,errcpn 355 | jmp xitmsg 356 | 357 | badvers: 358 | lxi d,vermsg 359 | xitmsg: 360 | mvi c,PRINT 361 | call BDOS 362 | ret 363 | 364 | done: db 'Time was set to: $' 365 | errmsg: db 7,'Error retrieving network time.$' 366 | errcpn: db 7,'This program requires CP/NET.$' 367 | vermsg: db 7,'This program requires BDOS >= 3.0.$' 368 | 369 | ; Must be linked with an SNIOS, at least SNIOS000 370 | 371 | end 372 | -------------------------------------------------------------------------------- /src/null/config.lib: -------------------------------------------------------------------------------- 1 | NVRAM equ 0 ; no NVRAM or special config needed 2 | -------------------------------------------------------------------------------- /src/rc-siob/chrio.asm: -------------------------------------------------------------------------------- 1 | ; SNIOS plug-in for SC131 sio port b , 2 | ; Notes: The Z180 chip used on the SC131 does not have the 3 | ; CTS/RTS signals. They simply do not exist. So, the max 4 | ; speed that this driver can run is 57600 baud. Not a barn 5 | ; stormer, but fast enough for copying info/programs into and 6 | ; out of the SC131 SD card. 7 | ; 8 | ; This driver uses the RomWBW interface in leu of direct I/O due to 9 | ; issues with the interrupt structure inside the Z180 chip. 10 | ; 11 | maclib z80 12 | ; maclib config 13 | 14 | public sendby,check,recvby,recvbt 15 | 16 | cseg 17 | 18 | ; Destroys C, E, B 19 | sendby: 20 | push hl 21 | push de 22 | push bc 23 | mov e,a ; e is the data byte 24 | ; function code is 1 the unit number 1 25 | lxi b,0101h 26 | rst 1 ; off to RomWBW 8080 syntax for rst 8 27 | pop bc 28 | pop de 29 | pop hl 30 | ret ; if not, should make this in-line 31 | 32 | check: ; check to see if the device is present.... 33 | ; empty the RomWBW input buffer befor proceeding. 34 | chklp: 35 | ; poll the input device it will be unit 1 36 | lxi b,0201h 37 | rst 1 ; off to get it. 38 | cpi 0 39 | jz chklp1 40 | ; function 0 unit number 1 41 | lxi b,0001h 42 | rst 1 ; go get it 43 | jmp chklp 44 | chklp1: stc ; since you can't unplug the sio port its always 45 | ; there 46 | cmc 47 | ret 48 | 49 | ; When using this, each byte must be coming soon... 50 | ; Destroys C, B, D 51 | ; Returns character in A 52 | recvby: ;s 0 53 | push bc ;s 1 54 | push de ;s 2 55 | push hl ;s 3 56 | lxi d,0 57 | recvb0: 58 | push de ;s 4 59 | ; poll the input device 60 | ; it will be unit 1 61 | lxi b,0201h 62 | rst 1 ; off to get it. 63 | pop de ; prep DE for down count ;s 3 64 | cpi 0 ; zero means no bytes 65 | jnz rcvb1 66 | dcx d ; count down 1 67 | mov a,d ; check for wrap 68 | ora e 69 | jnz recvb0 70 | pop hl ;-s 3 71 | pop de ;-s 2 72 | pop bc ;-s 1 73 | stc ; carry is err ; s 0 74 | ret ; CY, plus A not '-' 75 | ; Receive initial message bytes (e.g. "++") 76 | ; May need timeout, but must be long. 77 | ; Must preserve all regs (exc. A) 78 | ; May return CY on timeout. 79 | recvbt: 80 | push bc 81 | push de 82 | push hl 83 | rcvb1: lxi b,0001h 84 | ; function 0 unit number 1 85 | rst 1 ; go get it 86 | mov a,e ; copy to a 87 | pop hl 88 | pop de 89 | pop bc 90 | stc 91 | cmc ; no errors 92 | ret 93 | end 94 | -------------------------------------------------------------------------------- /src/rc-siob/config.lib: -------------------------------------------------------------------------------- 1 | ; RC2014 SIOB port. This will only work with a few 2 | ; of the serial boards. 3 | NVRAM equ 0 ; no NVRAM or special config needed 4 | -------------------------------------------------------------------------------- /src/rc-siob/platform.asm: -------------------------------------------------------------------------------- 1 | public platfm 2 | platfm: db 'RC-SIOB$' 3 | end 4 | -------------------------------------------------------------------------------- /src/rdate.asm: -------------------------------------------------------------------------------- 1 | ; Get time/date from a remote server and display it. 2 | ; 3 | maclib z80 4 | 5 | BDOS equ 0005h 6 | CMDLN equ 0080h 7 | 8 | ; BDOS functions 9 | CONOUT equ 2 10 | PRINT equ 9 11 | GETVER equ 12 12 | 13 | ; CP/NET NDOS functions 14 | NSEND equ 66 15 | NRECV equ 67 16 | 17 | org 0100h 18 | jmp start 19 | 20 | vers: dw 0 21 | 22 | gettime: db 0, 0, 2, 105, 0, 0 23 | gottime: db 1, 2, 0, 105, 0, 0, 0, 0, 0, 0 ; template of what is received 24 | 25 | ; assume < 100 26 | decout: 27 | mvi b,'0' 28 | decot0: 29 | sui 10 30 | jc decot1 31 | inr b 32 | jmp decot0 33 | decot1: 34 | adi 10 35 | adi '0' 36 | push psw 37 | mov a,b 38 | call prout 39 | pop psw 40 | jmp prout 41 | 42 | ; Keeps number in HL - caller must preserve/init 43 | ; Returns CY for invalid 44 | hexnum: 45 | sui '0' 46 | rc 47 | cpi 9+1 48 | jnc hexnm1 49 | hexnm2: 50 | dad h 51 | dad h 52 | dad h 53 | dad h 54 | ora l 55 | mov l,a 56 | ret 57 | hexnm1: 58 | sui 'A'-'9' 59 | rc 60 | cpi 5+1 61 | cmc 62 | rc 63 | adi 10 64 | jmp hexnm2 65 | 66 | hexout: 67 | push psw 68 | rrc 69 | rrc 70 | rrc 71 | rrc 72 | call hexdig 73 | pop psw 74 | hexdig: 75 | call tohex 76 | prout: 77 | mov e,a 78 | mvi c,CONOUT 79 | jmp BDOS 80 | 81 | tohex: 82 | ani 0fh 83 | adi 90h 84 | daa 85 | aci 40h 86 | daa 87 | ret 88 | 89 | wdays: db 'Sun$Mon$Tue$Wed$Thu$Fri$Sat$' 90 | 91 | ; HL = CP/M Date-time field, w/o seconds 92 | ; Print date and time to console. 93 | prdate: 94 | mov e,m 95 | inx h 96 | mov d,m 97 | inx h 98 | push h 99 | push d 100 | xchg 101 | call weekdy 102 | add a 103 | add a ; *4 104 | mov c,a 105 | mvi b,0 106 | lxi h,wdays 107 | dad b 108 | xchg 109 | call xitmsg 110 | mvi a,' ' 111 | call prout 112 | pop d 113 | ; compute year 114 | mvi c,78 ; base year, epoch, binary 115 | mvi b,078h ; year, BCD 116 | ; special-case date=0... 117 | mov a,e 118 | ora d 119 | jnz prdat0 120 | inx d 121 | prdat0: 122 | lxi h,365 123 | mov a,c 124 | ani 03h ; Not strictly true, but works until year 2100... 125 | jnz prdat1 126 | inx h 127 | prdat1: push h 128 | ora a 129 | dsbc d 130 | pop h 131 | jnc prdat2 ; done computing year... 132 | xchg 133 | ora a 134 | dsbc d 135 | xchg 136 | inr c 137 | mov a,b 138 | adi 1 139 | daa 140 | mov b,a 141 | jmp prdat0 142 | prdat2: ; DE = days within year 'C' 143 | push b ; save (2-digit) year, B = BCD, C = binary (until 2155) 144 | lxi h,month0+24 145 | mov a,c 146 | ani 03h 147 | jnz prdat3 148 | lxi h,month1+24 149 | prdat3: ; compute month, DE = days in year,HL = mon-yr-days table adj for leap 150 | mvi b,12 151 | prdat4: 152 | dcx h 153 | dcx h 154 | dcr b 155 | jm prdat5 ; should never happen... 156 | push h 157 | push d 158 | mov a,m 159 | inx h 160 | mov h,m 161 | mov l,a 162 | ; DE = days in year, HL = ytd[month] 163 | ora a 164 | dsbc d 165 | mov a,l ; potential remainder (neg) 166 | pop d 167 | pop h 168 | jnc prdat4 169 | prdat5: ; B = month, 0-11; A = -dom 170 | neg 171 | push psw 172 | inr b 173 | mov a,b 174 | call decout 175 | mvi e,'/' 176 | mvi c,CONOUT 177 | call BDOS 178 | pop psw 179 | call decout 180 | mvi e,'/' 181 | mvi c,CONOUT 182 | call BDOS 183 | pop b 184 | mov a,b ; already BCD 185 | call hexout 186 | mvi e,' ' 187 | mvi c,CONOUT 188 | call BDOS 189 | pop h ; -> BCD hours 190 | mov a,m 191 | inx h 192 | push h 193 | call hexout 194 | mvi e,':' 195 | mvi c,CONOUT 196 | call BDOS 197 | pop h ; -> BCD minutes 198 | mov a,m 199 | inx h 200 | push h 201 | call hexout 202 | mvi e,':' 203 | mvi c,CONOUT 204 | call BDOS 205 | pop h ; -> BCD seconds 206 | mov a,m 207 | jmp hexout 208 | 209 | ; J F M A M J J A S O N D 210 | month0: dw 0, 31, 59, 90,120,151,181,212,243,273,304,334 211 | month1: dw 0, 31, 60, 91,121,152,182,213,244,274,305,335 212 | 213 | start: 214 | mvi c,GETVER 215 | call BDOS 216 | shld vers 217 | lxi h,CMDLN 218 | mov c,m 219 | inx h 220 | sid1: 221 | mov a,m 222 | cpi ' ' 223 | jnz sid0 224 | inx h 225 | dcr c 226 | jnz sid1 227 | jmp start1 ; no params, use defaults 228 | 229 | sid0: ; scan hex number as server ID 230 | xchg 231 | lxi h,0 232 | sid2: 233 | ldax d 234 | inx d 235 | call hexnum 236 | jc sid3 237 | dcr c 238 | jnz sid2 239 | sid3: 240 | mov a,l 241 | sta gettime+1 242 | 243 | start1: 244 | lhld vers 245 | mvi a,2 ; bit for CP/Net 246 | ana h 247 | jz error2 248 | 249 | lxi d,gettime 250 | mvi c,NSEND 251 | call BDOS 252 | cpi 0ffh ; NDOS does not handle send errors well... 253 | jz error ; not sure if this works... 254 | lxi d,gottime 255 | mvi c,NRECV 256 | call BDOS 257 | cpi 0ffh ; NDOS does not handle recv errors well... 258 | jz error ; not sure if this works... 259 | ; do a little more checking... 260 | lda gottime+4 ; SIZ 261 | cpi 4 ; should be 5 bytes in length... 262 | jnz error 263 | jmp shwtime 264 | 265 | shwtime: 266 | lxi d,done 267 | mvi c,PRINT 268 | call BDOS 269 | lxi h,gottime+5 270 | call prdate 271 | ret 272 | 273 | ; From DATE.PLM: week$day = (word$value + base$day - 1) mod 7; 274 | ; base$day lit '0', 275 | weekdy: dcx h ; 1/1/78 is "0" (Sun), -1 for offset 276 | lxi d,7000 277 | ora a 278 | wd0: dsbc d 279 | jrnc wd0 280 | dad d 281 | lxi d,700 282 | ora a 283 | wd1: dsbc d 284 | jrnc wd1 285 | dad d 286 | lxi d,70 287 | ora a 288 | wd2: dsbc d 289 | jrnc wd2 290 | dad d 291 | lxi d,7 292 | ora a 293 | wd3: dsbc d 294 | jrnc wd3 295 | dad d 296 | mov a,l 297 | ret 298 | 299 | error: 300 | lxi d,errmsg 301 | jmp xitmsg 302 | 303 | error2: 304 | lxi d,errcpn 305 | ; jmp xitmsg 306 | 307 | xitmsg: 308 | mvi c,PRINT 309 | call BDOS 310 | ret 311 | 312 | done: db 'Remote Time is: $' 313 | errmsg: db 7,'Error retrieving network time.$' 314 | errcpn: db 7,'This program requires CP/NET.$' 315 | 316 | ; Must be linked with an SNIOS, at least SNIOS000 317 | 318 | end 319 | -------------------------------------------------------------------------------- /src/resntsrv.asm: -------------------------------------------------------------------------------- 1 | ;*************************************************************************** 2 | ;*************************************************************************** 3 | ;** ** 4 | ;** S e r v e r N e t w o r k I n t e r f a c e M o d u l e ** 5 | ;** RESIDENT PORTION ** 6 | ;** ** 7 | ;*************************************************************************** 8 | ;*************************************************************************** 9 | 10 | ;*************************************************************************** 11 | ;*************************************************************************** 12 | ;** ** 13 | ;** This module performs communication operations on a server ** 14 | ;** equipped with a WizNET W5500 Ethernet network adaptor. ** 15 | ;** ** 16 | ;*************************************************************************** 17 | ;*************************************************************************** 18 | maclib config 19 | maclib cfgnwif 20 | 21 | ; Each SERVRxPR process keeps it's local data on it's stack, 22 | ; so that it is re-entrant (same code shared for all procs). 23 | ; There is only one receiver process, so the code need not 24 | ; be re-entrant. 25 | ; 26 | ; References to stack data must take into account the current 27 | ; stack depth. Each push/pop must be accounted for to compute 28 | ; the correct offset to use when referencing stack variables. 29 | 30 | ; Items required in common memory... 31 | ; All must appear exactly in this order, so banked module 32 | ; can find/init/use them. 33 | 34 | ; TODO: to support polling, the NIOS poll routine 35 | ; must be in common memory. That may not be possible/practical. 36 | 37 | bdosadr: 38 | dw $-$ ; RSP XDOS entry point 39 | 40 | ; Network Receive Process Descriptors and Stack Space 41 | networkio: ; Receiver Process 42 | dw 0 ; link 43 | db 0 ; status 44 | db 66 ; priority 45 | dw 0 ; stack pointer - in banked portion 46 | db 'NetServr' ; name - must match BRS filename 47 | db 0 ; console 48 | db 0 ; memseg - 0=banked portion exists... 49 | ds 2 ; dparm 50 | ds 2 ; thread 51 | ds 2 ; buff 52 | ds 1 ; user code & disk slct 53 | ds 2 ; dcnt 54 | ds 1 ; searchl 55 | ds 2 ; searcha 56 | ds 2 ; PD extent, compat attr 57 | dw 0 ; HL' 58 | dw 0 ; DE' 59 | dw 0 ; BC' 60 | dw 0 ; AF' 61 | dw 0 ; IY 62 | dw 0 ; IX 63 | dw 0 ; HL 64 | dw 0 ; DE 65 | dw 0 ; BC 66 | dw 0 ; AF 67 | ds 2 ; scratch 68 | 69 | ; Mutex used to control access to the network hardware 70 | ; (NIOS interfaces). Process must own this mutex before 71 | ; calling the NIOS. Some systems use MXDisk instead. 72 | mx$netwrk: 73 | dw 0 ; LINK 74 | db 'MXNetwrk' 75 | dw 0 ; MSGLEN (mutex) 76 | dw 1 ; NMBMSGS 77 | dw 0,0,0,0,0 78 | dw 0 ; BUFFER (owning proc) 79 | 80 | ; Mutex used to control start/stop of the server. 81 | ; NetServr process waits on this before initializing network, 82 | ; and checks it for "messages" via G$CMD. 83 | mx$servr: 84 | dw 0 ; LINK 85 | db 'MXServer' 86 | dw 0 ; MSGLEN (mutex) 87 | dw 1 ; NMBMSGS 88 | dw 0,0,0,0,0 89 | dw 0 ; BUFFER (owning proc) 90 | 91 | ; Process Descriptors for all servers 92 | ; (one server proc per allowed requester) 93 | SERVR0PR: ; et al. 94 | dw 0 ; link 95 | db 0 ; status 96 | db 100 ; priority 97 | dw 0 ; stack pointer - in banked portion 98 | db 'SERV','R'+80h,'0P','R'+80h ; name 99 | db 0 ; console 100 | db 0 ; memseg - 0=banked portion exists... 101 | ds 2 ; dparm 102 | ds 2 ; thread 103 | ds 2 ; buff 104 | ds 1 ; user code & disk slct 105 | ds 2 ; dcnt 106 | ds 1 ; searchl 107 | ds 2 ; searcha 108 | ds 2 ; PD extent, compat attr 109 | dw 0 ; HL' 110 | dw 0 ; DE' 111 | dw 0 ; BC' 112 | dw 0 ; AF' 113 | dw 0 ; IY 114 | dw 0 ; IX 115 | dw 0 ; HL 116 | dw 0 ; DE 117 | dw 0 ; BC 118 | dw 0 ; AF 119 | ds 2 ; scratch 120 | ; the rest... 121 | ds (nmb$rqstrs-1) * P$LEN 122 | 123 | ; Input queue control blocks - one per requester. 124 | qcb$in$0: ; et al. 125 | ds nmb$rqstrs * qcb$in$len 126 | 127 | ; Server Configuration Table 128 | CFGTBL: 129 | db 0 ; Server status byte 130 | db 0ffh ; Server processor ID 131 | db nmb$rqstrs ; Max number of requesters supported at once 132 | db 0 ; Number of currently logged in requesters 133 | dw 0000h ; 16 bit vector of logged in requesters 134 | ds 16 ; Logged In Requester Node ID's 135 | ; Not officially part of config table: 136 | db 'PASSWORD' ; login password (DRI convention) 137 | db 0 ; cmd: start/stop server 138 | dw 0 ; exported mutex for network (may be MXDisk). 139 | dw def$prot ; initial R/O vector 140 | 141 | end 142 | -------------------------------------------------------------------------------- /src/rsxls.asm: -------------------------------------------------------------------------------- 1 | ; Generic RSX list utility. 2 | ; Lists all installed RSXs 3 | ; 4 | ; rsxls = short listing (names only) 5 | ; rsxls l = long listing (details) 6 | ; 7 | ; Always lists in order "bottom to top" (LOADER3 last) 8 | maclib z80 9 | 10 | cr equ 13 11 | lf equ 10 12 | 13 | ; System page-0 constants 14 | cpm equ 0 15 | bdos equ 5 16 | deffcb equ 5ch 17 | defdma equ 80h 18 | 19 | ; BDOS functions 20 | conout equ 2 21 | print equ 9 22 | 23 | ; LOADER3 is always installed at this point. 24 | 25 | org 100h 26 | lxi sp,stack 27 | 28 | lda deffcb+1 29 | cpi 'L' 30 | lxi d,header 31 | mvi c,print 32 | cz bdos 33 | 34 | lixd bdos+1 35 | ; check for no RSXs 36 | ldx a,+3 37 | cpi 0c3h ; JMP? 38 | jnz none ; SID/etc? 39 | ;might be RESBDOS3 40 | ldx a,+6 41 | cpi 0c3h ; JMP? 42 | jz none ; RESBDOS3... 43 | dup1: 44 | call show 45 | ldx a,+18 ; LOADER3? 46 | cpi 0ffh 47 | jz done 48 | ldx l,+4 ; next RSX... 49 | ldx h,+5 ; 50 | push h 51 | popix 52 | jmp dup1 53 | 54 | norsx: db 'No RSXs loaded',cr,lf,'$' 55 | 56 | none: lxi d,norsx 57 | mvi c,print 58 | call bdos 59 | done: jmp cpm 60 | 61 | show: lda deffcb+1 62 | cpi 'L' 63 | jrz long 64 | call pname 65 | call crlf 66 | ret 67 | 68 | header: db cr,lf 69 | db 'ADDR NAME PREV RM BK LD' 70 | db cr,lf,'$' 71 | 72 | long: call rsxadr 73 | call blank 74 | call pname 75 | call blank 76 | call prev 77 | call blank 78 | call remove 79 | call blank 80 | call banked 81 | call blank 82 | call loader 83 | call crlf 84 | ret 85 | 86 | pname: pushix 87 | pop h 88 | lxi d,10 ; offset of name 89 | dad d 90 | mvi b,8 91 | name0: mov a,m 92 | call chrout 93 | inx h 94 | djnz name0 95 | ret 96 | 97 | prev: ldx l,+6 ; offset of prev 98 | ldx h,+7 ; 99 | jmp hexadr 100 | 101 | remove: ldx a,+8 ; offset of remove flag 102 | jmp hexout 103 | 104 | banked: ldx a,+9 ; offset of banked flag 105 | jmp hexout 106 | 107 | loader: ldx a,+18 ; offset of first loader byte 108 | call hexout 109 | mvi a,',' 110 | call chrout 111 | ldx a,+19 ; second loader byte 112 | call hexout 113 | mvi a,',' 114 | call chrout 115 | ldx a,+19 ; third loader byte 116 | jmp hexout 117 | 118 | ; print address of current RSX 119 | rsxadr: pushix 120 | pop h 121 | ;jmp hexadr 122 | ; print HL as hex 123 | hexadr: mov a,h 124 | call hexout 125 | mov a,l 126 | ;jmp hexout 127 | ; print A in hex 128 | hexout: push psw 129 | rlc 130 | rlc 131 | rlc 132 | rlc 133 | call hexdig 134 | pop psw 135 | ;jmp hexdig 136 | hexdig: ani 0fh 137 | adi 90h 138 | daa 139 | aci 40h 140 | daa 141 | ;jmp chrout 142 | chrout: pushix 143 | push h 144 | push d 145 | push b 146 | mov e,a 147 | mvi c,conout 148 | call bdos 149 | pop b 150 | pop d 151 | pop h 152 | popix 153 | ret 154 | 155 | crlf: mvi a,cr 156 | call chrout 157 | mvi a,lf 158 | jr chrout 159 | 160 | blank: mvi a,' ' 161 | jr chrout 162 | 163 | ds 64 164 | stack: ds 0 165 | 166 | end 167 | -------------------------------------------------------------------------------- /src/rsxrm.asm: -------------------------------------------------------------------------------- 1 | ; This program can be used to remove an RSX that is persistent. 2 | ; The RSX must trap function 60 (CALL RSX) and honor sub function 113. 3 | ; The RSXPB is defined as: 4 | ; 5 | ; rsxpb: db 113 ; function code 6 | ; db 1 ; num params 7 | ; db name ; param: name of RSX to remove 8 | ; 9 | ; name: db 'TOREMOVE' ; must be 8 chars, blank padded 10 | ; 11 | ; This program expects the CCP to format the single commandline 12 | ; parameter into the default FCB, which will produce an 8-char 13 | ; (actually, 11) blank padded field. 14 | ; 15 | ; Usage: RSXRM 16 | ; Example: RSXRM RSXTEST 17 | ; 18 | ; A compatible RSX must accept BDOS Function 60 RSX Function 113, 19 | ; compare it's name to the parameter, and if matching then set 20 | ; it's own REMOVE flag. 21 | ; 22 | ; See RSXTEST.ASM for an example, in the RSXFUN routine. 23 | ; 24 | org 100h 25 | start: 26 | lxi d,rsxpb 27 | mvi c,60 28 | call 5 29 | jmp 0 30 | 31 | rsxpb: db 113 32 | db 1 33 | dw 005dh 34 | 35 | end 36 | -------------------------------------------------------------------------------- /src/ser-dri/config.lib: -------------------------------------------------------------------------------- 1 | ; Options for DRI SNIOS reference implementation. 2 | ; 3 | always$retry equ 0 ; match cpnet-0.8/P112 setting 4 | timeout$retries equ 100 ; timeout a max of 100 times 5 | max$retries equ 10 ; send message max of 10 times 6 | 7 | ASCII equ 0 8 | 9 | ; timeout values for chrio.asm (status loop counts): 10 | startTimeout equ 0000h ; for first char on receive 11 | charTimeout equ 0200h ; between adjacent chars of receive 12 | -------------------------------------------------------------------------------- /src/ser-dri/makevars: -------------------------------------------------------------------------------- 1 | SNDEPS += chrio.rel 2 | SNLINK = snios,chrio 3 | -------------------------------------------------------------------------------- /src/serial/config.lib: -------------------------------------------------------------------------------- 1 | ; timeout values for chrio.asm (status loop counts): 2 | startTimeout equ 0000h ; for first char on receive 3 | charTimeout equ 0100h ; between adjacent chars of receive 4 | -------------------------------------------------------------------------------- /src/serial/makevars: -------------------------------------------------------------------------------- 1 | SNDEPS += chrio.rel 2 | SNLINK = snios,chrio 3 | -------------------------------------------------------------------------------- /src/serial/snios.asm: -------------------------------------------------------------------------------- 1 | ; SNIOS for serial port (style) communication channels 2 | ; 3 | maclib z80 4 | maclib config 5 | 6 | public NTWKIN,NTWKST,CNFTBL,SNDMSG,RCVMSG,NTWKER,NTWKBT,NTWKDN,CFGTBL 7 | extrn sendby,check,recvby,recvbt 8 | cseg 9 | 10 | ; Slave Configuration Table - must be first in module 11 | CFGTBL: 12 | db 0 ; network status byte 13 | ds 1 ; slave processor ID number 14 | ds 2 ; A: Disk device 15 | ds 2 ; B: " 16 | ds 2 ; C: " 17 | ds 2 ; D: " 18 | ds 2 ; E: " 19 | ds 2 ; F: " 20 | ds 2 ; G: " 21 | ds 2 ; H: " 22 | ds 2 ; I: " 23 | ds 2 ; J: " 24 | ds 2 ; K: " 25 | ds 2 ; L: " 26 | ds 2 ; M: " 27 | ds 2 ; N: " 28 | ds 2 ; O: " 29 | ds 2 ; P: " 30 | 31 | ds 2 ; console device 32 | 33 | ds 2 ; list device: 34 | ds 1 ; buffer index 35 | db 0 ; FMT 36 | db 0 ; DID 37 | db 0ffh ; SID (CP/NOS must still initialize) 38 | db 5 ; FNC 39 | ds 1 ; SIZ 40 | ds 1 ; MSG(0) List number 41 | msgbuf: ; don't disturb LST: message header, above. 42 | ds 128 ; MSG(1) ... MSG(128) 43 | 44 | hostid: db 0 45 | 46 | ; Network Status Byte Equates 47 | ; 48 | active equ 00010000b ; slave logged in on network 49 | rcverr equ 00000010b ; error in received message 50 | senderr equ 00000001b ; unable to send message 51 | 52 | ; Utility Procedures 53 | ; 54 | ; page 55 | ; Network Initialization 56 | NTWKIN: 57 | call check ; confirm h/w exists... 58 | jc initerr 59 | ; Send "BDOS Func 255" message to other end, 60 | ; Response will tell us our, and their, node ID 61 | lxix msgbuf 62 | mvix 0,+0 ; FMT 63 | mvix 0ffh,+3 ; BDOS Func 64 | mvix 0,+4 ; Size 65 | lxi b,msgbuf 66 | call sndmsg0 ; avoid active check 67 | ora a 68 | jnz initerr 69 | lxi b,msgbuf 70 | call rcvmsg0 ; avoid active check 71 | ora a 72 | jnz initerr 73 | lxix msgbuf 74 | ldx b,+1 ; our node ID 75 | ldx c,+2 ; host node ID 76 | lxix CFGTBL 77 | mvi a,active 78 | stx a,+0 ; network status byte 79 | stx b,+1 ; our slave (client) ID 80 | mov a,c 81 | sta hostid 82 | xra a 83 | sta CFGTBL+36+7 ; clear SIZ - discard LST output 84 | ret 85 | 86 | ; Network Status 87 | NTWKST: 88 | lda CFGTBL+0 89 | mov b,a 90 | ani not (rcverr+senderr) 91 | sta CFGTBL+0 92 | mov a,b 93 | ret 94 | 95 | ; Return Configuration Table Address 96 | CNFTBL: 97 | lxi h,CFGTBL 98 | ret 99 | 100 | ; Destroys E,C 101 | sendhex: 102 | mov e,a 103 | rrc 104 | rrc 105 | rrc 106 | rrc 107 | call senddig 108 | mov a,e 109 | senddig: 110 | ani 0fh 111 | adi 90h 112 | daa 113 | aci 40h 114 | daa 115 | jmp sendby 116 | 117 | ; IY = message header, HL = crc 118 | ; Destroys B,C,E,D 119 | sendhdr: 120 | mvi a,'+' ; start of message - SYNC 121 | call sendby ; destroys C 122 | mvi a,'+' ; two sync bytes... 123 | call sendby ; destroys C 124 | lxi h,0ffffh ; init CRC 125 | mvi b,5 126 | sendh0: 127 | ldy a,+0 128 | inxiy 129 | mov d,a 130 | call sendhex ; destroys E,C,A 131 | mov a,d 132 | call crc ; destroys E,C,A 133 | dcr b 134 | jnz sendh0 135 | xra a 136 | ret 137 | 138 | POLY equ 8408h 139 | ; HL = cumulative CRC, A = new byte (used) 140 | ; Destroys C,E,A 141 | crc: 142 | mvi e,8 143 | crc0: mov c,a 144 | xra l ; clears CY 145 | rarr h 146 | rarr l 147 | ani 1 148 | jz crc1 149 | mvi a,LOW POLY 150 | xra l 151 | mov l,a 152 | mvi a,HIGH POLY 153 | xra h 154 | mov h,a 155 | crc1: mov a,c 156 | rar ; no need to worry about CY in, 157 | dcr e 158 | jnz crc0 159 | ora a ; but must not leave CY on return 160 | ret 161 | 162 | ; Send Message on Network 163 | SNDMSG: ; BC = message addr 164 | lda CFGTBL ; status 165 | ani active 166 | jz initerr 167 | sndmsg0: 168 | push b 169 | popix 170 | push b 171 | popiy 172 | lda CFGTBL+1 ; our ID 173 | stx a,+2 ; ensure SID is correct 174 | call sendhdr 175 | ora a 176 | jnz initerr 177 | ; HL points to payload now... 178 | ldx b,+4 ; msg siz field (-1) 179 | inr b ; might be 0, but that means 256 180 | call sendh0 181 | ora a 182 | jnz initerr 183 | mov a,l ; send CRC 184 | call sendhex ; 185 | mov a,h ; 186 | call sendhex ; 187 | mvi a,'-' 188 | call sendby 189 | mvi a,'-' 190 | call sendby 191 | xra a 192 | ret 193 | initerr: 194 | mvi a,0ffh 195 | ret 196 | 197 | ; IY = recv buffer, B = len 198 | ; HL = crc, destroys B,C,E 199 | recvhdr: 200 | lxi h,0ffffh ; init CRC 201 | mvi b,5 202 | recvh0: 203 | call recvhex ; destroys E,C 204 | rc 205 | sty a,+0 206 | inxiy 207 | call crc ; destroys E,C 208 | dcr b 209 | jnz recvh0 210 | ret 211 | 212 | ; Destroys E,C 213 | ; Returns Hex value in A 214 | recvhex: 215 | call recvdig ; destroys C 216 | rc 217 | rlc 218 | rlc 219 | rlc 220 | rlc 221 | mov e,a 222 | call recvdig ; destroys C 223 | rc 224 | ora e 225 | ret 226 | 227 | recvdig: 228 | call recvby ; destroys C 229 | rc 230 | sui '0' 231 | rc 232 | cpi 10 233 | jnc recvd1 234 | ora a 235 | ret 236 | recvd1: 237 | sui 'A'-'0' 238 | rc 239 | adi 10 240 | ret 241 | 242 | ; Receive Message from Network 243 | ; Wait for "++" sequence, discarding characters, then save message. 244 | ; TODO: need timeout? Must be long timeout... 245 | RCVMSG: ; BC = message addr 246 | lda CFGTBL ; status 247 | ani active 248 | jz initerr 249 | rcvmsg0: 250 | push b 251 | popix ; IX = message pointer 252 | push b 253 | popiy ; IY = message address (++) 254 | recev1: 255 | mvi b,2 256 | recev0: 257 | call recvbt 258 | jc recev2 259 | cpi '+' 260 | jnz recev1 ; reset count, too 261 | dcr b 262 | jnz recev0 263 | ; got SYNC "++", now just input bytes and decode - until "--" 264 | call recvhdr 265 | jc recev2 266 | ldx b,+4 ; msg siz field (-1) 267 | inr b ; might be 0, but that means 256 268 | call recvh0 269 | jc recev2 270 | call recvhex ; destroys C,E 271 | jc recev2 272 | call crc ; destroys C,E 273 | call recvhex ; destroys C,E 274 | jc recev2 275 | call crc ; destroys C,E 276 | mov a,h 277 | ora l 278 | jnz recev2 279 | ; Now confirm we get "--" EOM 280 | call recvby 281 | cpi '-' 282 | jnz recev2 283 | call recvby 284 | cpi '-' 285 | jnz recev2 286 | xra a 287 | ret 288 | recev2: 289 | mvi a,0ffh 290 | NTWKER: 291 | ret 292 | 293 | ; Shut down the network - notify serial client (dispatcher) 294 | NTWKDN: 295 | lxix msgbuf 296 | mvix 0,+0 ; FMT 297 | mvix 0feh,+3 ; BDOS Func 298 | mvix 0,+4 ; Size 299 | lxi b,msgbuf 300 | call sndmsg0 ; avoid active check 301 | NTWKBT: ; This procedure is called each time the CCP is reloaded from disk. 302 | xra a 303 | ret 304 | 305 | end 306 | -------------------------------------------------------------------------------- /src/snios000.asm: -------------------------------------------------------------------------------- 1 | ; nil SNIOS 2 | ; 3 | public NTWKIN, NTWKST, CNFTBL, SNDMSG, RCVMSG, NTWKER, NTWKBT, NTWKDN, CFGTBL 4 | 5 | cseg 6 | 7 | ; Slave Configuration Table 8 | CFGTBL: 9 | db 0 10 | 11 | ; Utility Procedures 12 | ; 13 | CNFTBL: 14 | lxi h,0 15 | NTWKIN: 16 | NTWKST: 17 | SNDMSG: 18 | RCVMSG: 19 | NTWKER: 20 | NTWKBT: 21 | NTWKDN: 22 | xra a 23 | ret 24 | 25 | end 26 | -------------------------------------------------------------------------------- /src/snios12.asm: -------------------------------------------------------------------------------- 1 | ; SNIOS Prefix (jump table) for CP/NET 1.2 on CP/M 2.2 2 | 3 | maclib z80 4 | 5 | extrn NTWKIN, NTWKST, CNFTBL, SNDMSG, RCVMSG, NTWKER, NTWKBT, NTWKDN 6 | 7 | cseg 8 | ; Jump vector for SNIOS entry points 9 | jmp NTWKIN ; network initialization 10 | jmp NTWKST ; network status 11 | jmp CNFTBL ; return config table addr 12 | jmp SNDMSG ; send message on network 13 | jmp RCVMSG ; receive message from network 14 | jmp NTWKER ; network error 15 | jmp NTWKBT ; network warm boot 16 | jmp NTWKDN ; network shutdown - extension 17 | 18 | end 19 | -------------------------------------------------------------------------------- /src/srvprot.asm: -------------------------------------------------------------------------------- 1 | ; Program to show/change NETSERVR RSP R/O vector (drive write protect). 2 | 3 | maclib z80 4 | maclib config 5 | maclib cfgnwif 6 | 7 | CR equ 13 8 | LF equ 10 9 | 10 | cpm equ 0 11 | bdos equ 5 12 | cmdlin equ 0080h 13 | 14 | org 100h 15 | jmp start 16 | 17 | help: db 'Use "D:" or "-D:" separated by space',CR,LF,'$' 18 | done: db 'CP/NET Server drives protected:',CR,LF,'$' 19 | nocpnt: db 'Not a CP/NET Configuration',CR,LF,'$' 20 | nompmm: db 'Requires MP/M-II' 21 | crlf: db CR,LF,'$' 22 | drive: db '?: $' 23 | 24 | rovadr: dw 0 25 | andvec: dw 0ffffh ; modified by "-A:" expressions 26 | orvec: dw 00000h ; modified by "A:" expressions 27 | change: db 0 28 | 29 | start: 30 | lxi sp,stack 31 | mvi c,versf 32 | call bdos 33 | mov a,h 34 | ani 00000001b 35 | jz nompm 36 | mvi c,sysdatf 37 | call bdos 38 | mvi l,S$CPNET 39 | mov e,m 40 | inx h 41 | mov d,m 42 | mov a,e 43 | ora d 44 | jz nonet 45 | lxi h,G$ROV 46 | dad d 47 | shld rovadr 48 | ; 49 | ; now parse commandline... 50 | ; 51 | lda cmdlin 52 | ora a 53 | jz show 54 | lxi h,cmdlin 55 | mov b,m 56 | inx h 57 | pars0: mov a,m 58 | cpi ' ' 59 | jnz pars1 60 | inx h 61 | djnz pars0 62 | jmp fini 63 | pars1: cpi '-' ; un-protect? 64 | mvi c,0 65 | jrnz pars2 66 | mvi c,1 ; flag as un-protect 67 | inx h 68 | dcr b 69 | jz error 70 | mov a,m 71 | pars2: sui 'A' 72 | jc error 73 | cpi 16 74 | jnc error 75 | ; TODO: is colon optional? is space? 76 | mov d,a 77 | inx h 78 | dcr b 79 | jz error 80 | mov a,m 81 | cpi ':' 82 | jnz error 83 | inx h 84 | dcr b 85 | jrz ok ; FIXME: B will go negative 86 | mov a,m 87 | cpi ' ' 88 | jnz error ; TODO: allow comma? 89 | ok: ; have drive in D, C flags add/remove 90 | lda change 91 | ori 0ffh 92 | sta change 93 | push h 94 | push b 95 | mov a,d 96 | dcr c 97 | jrz rmv 98 | ; add 99 | call adddrv 100 | jr join 101 | rmv: call rmvdrv 102 | join: pop b 103 | pop h 104 | inx h 105 | dcr b 106 | jm fini 107 | jnz pars0 108 | fini: 109 | lda change 110 | ora a 111 | jz show ; if no changes... 112 | lhld rovadr 113 | lded andvec 114 | call bitand 115 | lded orvec 116 | call bitor 117 | 118 | show: lxi d,done 119 | mvi c,printf 120 | call bdos 121 | lhld rovadr 122 | mov e,m 123 | inx h 124 | mov d,m 125 | mvi b,16 126 | mvi c,'A' 127 | sh0: bit 0,e 128 | cnz shdrv 129 | srlr d 130 | rarr e 131 | inr c 132 | djnz sh0 133 | lxi d,crlf 134 | exit: mvi c,printf 135 | call bdos 136 | jmp cpm 137 | 138 | error: lxi d,help 139 | jr exit 140 | 141 | ; C=drive letter 142 | shdrv: mov a,c 143 | sta drive 144 | push d 145 | push b 146 | lxi d,drive 147 | mvi c,printf 148 | call bdos 149 | pop b 150 | pop d 151 | ret 152 | 153 | ; add (set bit) drive A to orvec 154 | ; orvec |= vector(drive) 155 | adddrv: call drvvec ; get bit vec in HL 156 | xchg 157 | lhld orvec 158 | mov a,l 159 | ora e 160 | mov l,a 161 | mov a,h 162 | ora d 163 | mov h,a 164 | shld orvec 165 | ret 166 | 167 | ; remove (clear bit) drive A from andvec 168 | ; andvec &= ~vector(drive) 169 | rmvdrv: call drvvec ; get bit vec in HL 170 | xchg 171 | lhld andvec 172 | mov a,e 173 | cma 174 | ana l 175 | mov l,a 176 | mov a,d 177 | cma 178 | ana h 179 | mov h,a 180 | shld andvec 181 | ret 182 | 183 | ; convert drive A (0-15) to bitvec in HL 184 | drvvec: lxi h,1 185 | ora a 186 | rz 187 | dv0: dad h 188 | dcr a 189 | jrnz dv0 190 | ret 191 | 192 | ; (HL) &= DE 193 | bitand: 194 | mov a,m 195 | ana e 196 | mov m,a 197 | inx h 198 | mov a,m 199 | ana d 200 | mov m,a 201 | dcx h 202 | ret 203 | 204 | ; (HL) |= DE 205 | bitor: 206 | mov a,m 207 | ora e 208 | mov m,a 209 | inx h 210 | mov a,m 211 | ora d 212 | mov m,a 213 | dcx h 214 | ret 215 | 216 | nompm: lxi d,nompmm 217 | jmp exit 218 | 219 | nonet: lxi d,nocpnt 220 | jmp exit 221 | 222 | ds 64 223 | stack: ds 0 224 | 225 | end 226 | -------------------------------------------------------------------------------- /src/srvstart.asm: -------------------------------------------------------------------------------- 1 | ; Program to signal NETSERVR RSP to start network operations. 2 | ; This command is run once the network hardware is fully 3 | ; configured. 4 | 5 | maclib config 6 | maclib cfgnwif 7 | 8 | CR equ 13 9 | LF equ 10 10 | 11 | cpm equ 0 12 | bdos equ 5 13 | 14 | org 100h 15 | jmp start 16 | 17 | done: db 'CP/NET Server started',CR,LF,'$' 18 | qnfmsg: db 'No mutex: MXNetwrk',CR,LF,'$' 19 | nocpnt: db 'Not a CP/NET Configuration',CR,LF,'$' 20 | nompmm: db 'Requires MP/M-II',CR,LF,'$' 21 | did: db 'CP/NET Server already started',CR,LF,'$' 22 | 23 | mx$UQCB: 24 | dw 0 ; QCB filled by openqf 25 | dw 0 ; no message, no buffer 26 | db 'MXServer' 27 | 28 | cmdadr: dw 0 29 | 30 | start: 31 | lxi sp,stack 32 | mvi c,versf 33 | call bdos 34 | mov a,h 35 | ani 00000001b 36 | jz nompm 37 | mvi c,sysdatf 38 | call bdos 39 | mvi l,S$CPNET 40 | mov e,m 41 | inx h 42 | mov d,m 43 | mov a,e 44 | ora d 45 | jz nonet 46 | lxi h,G$CMD 47 | dad d 48 | shld cmdadr 49 | mov a,m 50 | cpi NWSTART ; already started? need 'force' option? 51 | jz alrdy 52 | lxi d,mx$UQCB 53 | mvi c,openqf 54 | call bdos 55 | ora a 56 | jnz noque 57 | lhld cmdadr 58 | mvi m,NWSTART 59 | lxi d,mx$UQCB 60 | mvi c,writqf 61 | call bdos 62 | ; no return value 63 | lxi d,done 64 | exit: mvi c,printf 65 | call bdos 66 | jmp cpm 67 | 68 | noque: lxi d,qnfmsg 69 | jmp exit 70 | 71 | nompm: lxi d,nompmm 72 | jmp exit 73 | 74 | nonet: lxi d,nocpnt 75 | jmp exit 76 | 77 | alrdy: lxi d,did 78 | jmp exit 79 | 80 | ds 64 81 | stack: ds 0 82 | 83 | end 84 | -------------------------------------------------------------------------------- /src/srvstat.asm: -------------------------------------------------------------------------------- 1 | ; Get Server Status 2 | maclib z80 3 | 4 | cpm equ 0 5 | bdos equ 5 6 | cmdbuf equ 0080h 7 | 8 | ; Offsets in Server Config Table 9 | TEMP equ 0 10 | STS equ 1 11 | ID equ 2 12 | MAX equ 3 13 | CUR equ 4 14 | VEC equ 5 ; 2 bytes 15 | RID equ 7 ; start of remote IDs 16 | 17 | org 00100h 18 | 19 | jmp start 20 | 21 | signon: db 13,10,'Server Status' 22 | db 13,10,'=============' 23 | db '$' 24 | sidmsg: db 13,10,'Server ID = $' 25 | stsmsg: db 13,10,'Server Status Byte = $' 26 | tmpmsg: db 13,10,'Temp Drive = $' 27 | maxmsg: db 13,10,'Maximum Requesters = $' 28 | nummsg: db 13,10,'Number of Requesters = $' 29 | reqmsg: db 13,10,'Requesters logged in:$' 30 | nonmsg: db 13,10,' (none)$' 31 | spcmsg: db 13,10,' $' 32 | cpnerr: db 13,10,'CP/NET has not been loaded.$' 33 | cfgerr: db 13,10,'Unable to get Server Config Table.$' 34 | 35 | start: 36 | sspd usrstk 37 | lxi sp,stack 38 | call getver 39 | mov a,h 40 | ani 01h 41 | jnz dompm 42 | mov a,h 43 | ani 02h 44 | jz nocpnt 45 | call parse ; might set 'sid' 46 | 47 | lxi d,signon ; Intro 48 | call msgout 49 | 50 | call getcfg 51 | mov a,l 52 | ora h 53 | jz nocfg 54 | mov a,l 55 | ana h 56 | cpi 0ffh 57 | jz nocfg 58 | 59 | shld nettbl 60 | show: 61 | lixd nettbl 62 | 63 | lxi d,sidmsg 64 | call msgout 65 | ldx c,ID 66 | call hexout 67 | 68 | lxi d,stsmsg ; Net Sts Byte 69 | call msgout 70 | ldx c,STS 71 | call hexout 72 | 73 | lxi d,tmpmsg 74 | call msgout 75 | ldx a,TEMP 76 | adi 'A' 77 | call chrout 78 | mvi a,':' 79 | call chrout 80 | 81 | lxi d,maxmsg 82 | call msgout 83 | ldx a,MAX 84 | call decout 85 | 86 | lxi d,nummsg 87 | call msgout 88 | ldx a,CUR 89 | call decout 90 | 91 | lxi d,reqmsg 92 | call msgout 93 | ldx l,VEC 94 | ldx h,VEC+1 95 | ldx a,CUR 96 | ora a 97 | jz none 98 | lxi d,RID 99 | dadx d 100 | mvi b,16 101 | drvlup: 102 | mov a,l 103 | ani 1 104 | jz noreq 105 | lxi d,spcmsg 106 | call msgout 107 | ldx c,+0 108 | call hexout 109 | noreq: inxix 110 | rarr h 111 | rarr l 112 | djnz drvlup 113 | jmp exit 114 | 115 | ; MP/M system - check for server config table 116 | dompm: 117 | lxi d,signon ; Intro - TODO: diff for MP/M? 118 | call msgout 119 | mvi c,154 120 | call bdos 121 | mvi l,9 ; CP/NET server cfg 122 | mov e,m 123 | inx h 124 | mov d,m ; 125 | mvi l,196 ; temp drive 126 | mov a,m ; (0=def, 1=A:, ...) 127 | dcr a ; unclear what 'def' should do 128 | sta mpmtbl+TEMP 129 | mov a,e 130 | ora d 131 | jz nocfg 132 | xchg 133 | lxi d,mpmtbl+STS 134 | lxi b,22 ; TODO: include password? 135 | ldir 136 | lxi h,mpmtbl 137 | shld nettbl 138 | jmp show 139 | 140 | none: lxi d,nonmsg 141 | call msgout 142 | jmp exit 143 | 144 | nocfg: lxi d,cfgerr 145 | jmp no1 146 | 147 | nocpnt: lxi d,cpnerr ; CP/NET has not been loaded 148 | no1: call msgout 149 | exit: lhld usrstk 150 | sphl 151 | ret 152 | 153 | chrout: 154 | pushix 155 | push h 156 | push b 157 | mov e,a 158 | mvi c,002h 159 | call bdos 160 | pop b 161 | pop h 162 | popix 163 | ret 164 | 165 | msgout: 166 | pushix 167 | push h 168 | push b 169 | mvi c,009h 170 | call bdos 171 | pop b 172 | pop h 173 | popix 174 | ret 175 | 176 | getver: 177 | mvi c,12 178 | call bdos 179 | ret 180 | 181 | getcfg: 182 | ; TODO: check if server "exists"? 183 | lda sid 184 | mov e,a 185 | mvi c,047h 186 | call bdos 187 | ret 188 | 189 | parse: lxi h,cmdbuf 190 | mov b,m 191 | inr b 192 | pars0: inx h 193 | dcr b 194 | rz 195 | mov a,m 196 | cpi ' ' 197 | jz pars0 198 | call parshx 199 | jc nocfg 200 | mov a,d 201 | sta sid 202 | ret 203 | 204 | ; HL=cmdbuf, B=len 205 | ; returns CY if error, Z if term char, NZ end of text, D=number 206 | parshx: 207 | mvi d,0 208 | pm0: mov a,m 209 | cpi ' ' 210 | jz nzret 211 | sui '0' 212 | rc 213 | cpi '9'-'0'+1 214 | jc pm3 215 | sui 'A'-'0' 216 | rc 217 | cpi 'F'-'A'+1 218 | cmc 219 | rc 220 | adi 10 221 | pm3: 222 | ani 0fh 223 | mov e,a 224 | mov a,d 225 | add a 226 | rc 227 | add a 228 | rc 229 | add a 230 | rc 231 | add a 232 | rc 233 | add e ; carry not possible 234 | mov d,a 235 | inx h 236 | djnz pm0 237 | nzret: 238 | xra a 239 | inr a ; NZ 240 | ret 241 | 242 | crlf: 243 | mvi a,13 244 | call chrout 245 | mvi a,10 246 | call chrout 247 | ret 248 | 249 | ; leading zeroes blanked - must preserve B 250 | decout: 251 | push b 252 | mvi c,0 253 | mvi d,100 254 | call divide 255 | mvi d,10 256 | call divide 257 | adi '0' 258 | call chrout 259 | pop b 260 | ret 261 | 262 | divide: mvi e,0 263 | div0: sub d 264 | inr e 265 | jrnc div0 266 | add d 267 | dcr e 268 | jrnz div1 269 | bit 0,c 270 | jrnz div1 271 | ret 272 | div1: setb 0,c 273 | push psw ; remainder 274 | mvi a,'0' 275 | add e 276 | call chrout 277 | pop psw ; remainder 278 | ret 279 | 280 | hexout: 281 | push b 282 | mov a,c 283 | rrc 284 | rrc 285 | rrc 286 | rrc 287 | call hexdig 288 | pop b 289 | mov a,c 290 | call hexdig 291 | mvi a,'H' 292 | call chrout 293 | ret 294 | 295 | hexdig: 296 | ani 0fh 297 | adi 90h 298 | daa 299 | aci 40h 300 | daa 301 | jmp chrout 302 | 303 | ds 40 304 | stack: ds 0 305 | usrstk: dw 0 306 | 307 | sid: db 0 308 | count: db 0 309 | nettbl: dw 0 310 | 311 | mpmtbl: ds 23 ; copied from MP/M system data 312 | ; TODO: also show password? 313 | 314 | end 315 | -------------------------------------------------------------------------------- /src/srvstop.asm: -------------------------------------------------------------------------------- 1 | ; Program to signal NETSERVR RSP to shutdown network operations. 2 | 3 | maclib config 4 | maclib cfgnwif 5 | 6 | CR equ 13 7 | LF equ 10 8 | 9 | cpm equ 0 10 | bdos equ 5 11 | 12 | org 100h 13 | jmp start 14 | 15 | done: db 'CP/NET Server stopped',CR,LF,'$' 16 | nocpnt: db 'Not a CP/NET Configuration',CR,LF,'$' 17 | nompmm: db 'Requires MP/M-II',CR,LF,'$' 18 | did: db 'CP/NET Server already stopped',CR,LF,'$' 19 | 20 | start: 21 | lxi sp,stack 22 | mvi c,versf 23 | call bdos 24 | mov a,h 25 | ani 00000001b 26 | jz nompm 27 | mvi c,sysdatf 28 | call bdos 29 | mvi l,S$CPNET 30 | mov e,m 31 | inx h 32 | mov d,m 33 | mov a,e 34 | ora d 35 | jz nonet 36 | lxi h,G$CMD 37 | dad d 38 | mov a,m 39 | cpi NWSTOP ; already stopped? need 'force' option? 40 | jz alrdy 41 | mvi m,NWSTOP ; should be detected soon... 42 | lxi d,done 43 | exit: mvi c,printf 44 | call bdos 45 | jmp cpm 46 | 47 | nompm: lxi d,nompmm 48 | jmp exit 49 | 50 | nonet: lxi d,nocpnt 51 | jmp exit 52 | 53 | alrdy: lxi d,did 54 | jmp exit 55 | 56 | ds 64 57 | stack: ds 0 58 | 59 | end 60 | -------------------------------------------------------------------------------- /src/usb1232/chrio.asm: -------------------------------------------------------------------------------- 1 | ; SNIOS plug-in Dual/SIO board for S100 buss. 2 | ; Specifically, the USB1232 chip on 8255 PIO. 3 | ; 4 | ; See www.s100computers.com et.al for further 5 | ; details. 6 | ; 7 | ; NOTE: this could be merged back into the original 8 | ; driver with conditional assembly, but I don't have a 9 | ; way to test the code on Noberto's H89 USB/SERIAL board. 10 | ; 11 | maclib z80 12 | maclib config 13 | 14 | public sendby,check,recvby,recvbt 15 | 16 | cseg 17 | 18 | ; Destroys C 19 | sendby: 20 | mov c,a 21 | sendb0: 22 | in STSPORT ; read the status PIO port. 23 | ani USBTXR 24 | jnz sendb0 ; loop forever. 25 | mov a,c ; but really not that long (FIFO). 26 | out USBPORT ; probably can't ever overrun? 27 | ret ; if not, should make this in-line 28 | 29 | check: 30 | ; program the pio port (just in case) 31 | mvi a,AinBout8255cfg ; program the PIO so 32 | out PortCtrl8255 ; we can read status bits. 33 | ; do check for sane hardware... 34 | lxi h,0 35 | ; on my s100 machine the cpu runs at 8mhz 36 | mvi e,12 ; approx 4.5 sec @8MHz 37 | ; this works on my machine, but the timout is not 38 | ; calibrated yet. 39 | check0: 40 | in STSPORT ; 11 41 | ani USBTXR ; 7, also NC 42 | rz ; 5 (11) 43 | dcx h ; 6 44 | mov a,h ; 4 45 | ora l ; 4 46 | jnz check0 ; 10 = 47, * 65536 = 3080192 = 1.504 sec 47 | dcr e ; 4 48 | jnz check0 ; 10 49 | stc 50 | ret 51 | 52 | ; When using this, each byte must be coming soon... 53 | ; Destroys C 54 | ; Returns character in A 55 | recvby: 56 | push b 57 | lxi b,charTimeout 58 | recvb0: 59 | in STSPORT ; test status bit 60 | ani USBRXR ; but don't hang here 61 | jz recvb1 ; to long. 62 | dcx b 63 | mov a,b 64 | ora c 65 | jnz recvb0 66 | pop b 67 | stc 68 | ret ; CY, timeout 69 | recvb1: 70 | in USBPORT ; get a byte (FIFO) 71 | pop b 72 | ret 73 | 74 | ; Receive initial message bytes (e.g. "++") 75 | ; Must preserve all regs (exc. A) 76 | ; May return CY on timeout. 77 | recvbt: 78 | push b 79 | lxi b,startTimeout 80 | recvbt0: 81 | in STSPORT 82 | ani USBRXR 83 | jz recvbt1 84 | dcx b 85 | mov a,b 86 | ora c 87 | jnz recvbt0 88 | pop b 89 | stc 90 | ret ; CY, timeout 91 | recvbt1: 92 | in USBPORT 93 | pop b 94 | ret 95 | 96 | end 97 | -------------------------------------------------------------------------------- /src/usb1232/config.lib: -------------------------------------------------------------------------------- 1 | ; Modified from the FT245R driver to support 2 | ; DLP-USB1232H on 8255 PIO. 3 | ; 4 | NVRAM equ 0 ; no NVRAM or special config needed 5 | 6 | PortCtrl8255 equ 0ABh 7 | AinBout8255cfg equ 10011000b 8 | USBPORT equ 0ACh ; port on Dual SIO S100 board interface 9 | STSPORT equ 0AAH ; Status port 10 | 11 | ; Status port bits: 12 | ; bit 6: Tx space available in FIFO 13 | ; bit 7: Rx data available in FIFO 14 | 15 | USBRXR equ 10000000b ; Rx data available in FIFO 16 | USBTXR equ 01000000b ; Tx space available in FIFO 17 | 18 | -------------------------------------------------------------------------------- /src/usb1232/platform.asm: -------------------------------------------------------------------------------- 1 | public platfm 2 | platfm: db 'USB1232$' 3 | end 4 | -------------------------------------------------------------------------------- /src/vcpnet/config.lib: -------------------------------------------------------------------------------- 1 | ; Config details for virtual CP/NET device. 2 | ; a generic, fictitious, hardware emulation 3 | NVRAM equ 0 ; no NVRAM or special config needed 4 | 5 | ; I/O port base address 6 | VCPN equ 038h 7 | 8 | ; Data port is VCPNET+0 - supports outir/inir 9 | ; Status/control port is VCPNET+1 10 | ; output - reset/resync (data ignored). next input on data port 11 | ; reads the client ID. 12 | ; input - bit 0: data ready 13 | ; bit 1: command overrun 14 | ; bit 2: response underrun 15 | ; bit 3: error 16 | -------------------------------------------------------------------------------- /src/vcpnet/platform.asm: -------------------------------------------------------------------------------- 1 | public platfm 2 | platfm: db 'VCPNET$' 3 | end 4 | -------------------------------------------------------------------------------- /src/vcpnet/snios.asm: -------------------------------------------------------------------------------- 1 | ; SNIOS for fictitious CPNetDevice 2 | ; 3 | maclib config 4 | maclib z80 5 | 6 | public NTWKIN, NTWKST, CNFTBL, SNDMSG, RCVMSG, NTWKER, NTWKBT, NTWKDN, CFGTBL 7 | 8 | cseg 9 | ; Slave Configuration Table - must be first in module 10 | CFGTBL: 11 | ds 1 ; network status byte 12 | ds 1 ; slave processor ID number 13 | ds 2 ; A: Disk device +2 14 | ds 2 ; B: " 15 | ds 2 ; C: " 16 | ds 2 ; D: " 17 | ds 2 ; E: " 18 | ds 2 ; F: " 19 | ds 2 ; G: " 20 | ds 2 ; H: " 21 | ds 2 ; I: " 22 | ds 2 ; J: " 23 | ds 2 ; K: " 24 | ds 2 ; L: " 25 | ds 2 ; M: " 26 | ds 2 ; N: " 27 | ds 2 ; O: " 28 | ds 2 ; P: " 29 | 30 | ds 2 ; console device +34 31 | 32 | ds 2 ; list device: +36... 33 | ds 1 ; buffer index +2 34 | db 0 ; FMT +3 35 | db 0 ; DID +4 36 | db 0ffh ; SID (CP/NOS must still initialize) 37 | db 5 ; FNC +6 38 | db 0 ; SIZ +7 39 | ds 1 ; MSG(0) List number +8 40 | ds 128 ; MSG(1) ... MSG(128) +9... 41 | 42 | ioport: db VCPN ; possibly configured here... 43 | 44 | ; Network Status Byte Equates 45 | ; 46 | active equ 0001$0000b ; slave logged in on network 47 | rcverr equ 0000$0010b ; error in received message 48 | senderr equ 0000$0001b ; unable to send message 49 | 50 | ; Utility Procedures 51 | ; 52 | ; Network Initialization 53 | NTWKIN: 54 | lxix CFGTBL 55 | mvi a,active 56 | stx a,+0 ; network status byte 57 | lda ioport 58 | mov c,a 59 | inr c ; status port 60 | xra a 61 | outp a 62 | dcr c 63 | inp a 64 | stx a,+1 ; our slave (client) ID 65 | xra a 66 | sta CFGTBL+36+7 67 | ret 68 | 69 | ; Network Status 70 | NTWKST: 71 | lda CFGTBL+0 72 | mov b,a 73 | ani not (rcverr+senderr) 74 | sta CFGTBL+0 75 | mov a,b 76 | ret 77 | 78 | ; Return Configuration Table Address 79 | ; Still need this for BDOS func 69 80 | CNFTBL: 81 | lxi h,CFGTBL 82 | ret 83 | 84 | ; Send Message on Network 85 | SNDMSG: ; BC = message addr 86 | mov h,b 87 | mov l,c ; HL = message address 88 | push h 89 | popix 90 | lda CFGTBL+1 91 | stx a,+2 ; Set Slave ID in header 92 | lda ioport 93 | mov c,a 94 | mvi b,5 ; length of header 95 | outir 96 | ldx b,+4 ; msg siz field (-1) 97 | inr b ; might be 0, but that means 256 98 | outir 99 | inr c ; status port 100 | inp a ; 101 | ani 02h ; cmd overrun 102 | rz 103 | mvi a,0ffh 104 | ret 105 | 106 | check: 107 | ; do check for sane receive time... 108 | lxi h,0 109 | mvi e,3 ; approx 4.5 sec @ 2MHz 110 | check0: 111 | inp a ; 12 112 | ani 01h ; 7 data ready 113 | rnz ; 5 (11) NC from "ani" 114 | dcx h ; 6 115 | mov a,h ; 4 116 | ora l ; 4 117 | jnz check0 ; 10 = 48, * 65536 = 3145728 = 1.536 sec 118 | dcr e ; 4 119 | jnz check0 ; 10 120 | stc 121 | ret 122 | 123 | ; Receive Message from Network 124 | RCVMSG: ; BC = message addr 125 | mov h,b 126 | mov l,c ; HL = message address 127 | push h 128 | popix 129 | lda ioport 130 | mov c,a 131 | inr c ; status port 132 | push h ; save msg adr for inir 133 | call check 134 | pop h 135 | jc rcvto 136 | dcr c ; data port 137 | mvi b,5 ; header length 138 | inir 139 | ; Could compare SLVID with "LDX r,1" and ignore messages. 140 | ; But this "hardware" is point-to-point (connection oriented) 141 | ; so the only messages we see are intended for us. 142 | ldx b,+4 ; msg siz 143 | inr b 144 | inir 145 | inr c ; status port 146 | inp a 147 | ani 04h ; rsp overrun 148 | rz 149 | rcvto: mvi a,0ffh 150 | NTWKER: ret 151 | 152 | NTWKDN: xra a 153 | ret 154 | 155 | NTWKBT: ; NETWORK WARM START 156 | lda ioport 157 | mov c,a 158 | xra a ; Future hardware might expect data 159 | outp a 160 | inp a ; this is our Slave ID, but we already have it 161 | ret 162 | 163 | end 164 | -------------------------------------------------------------------------------- /src/w5500/config.lib: -------------------------------------------------------------------------------- 1 | ; future options for W5500 2 | 3 | ; MP/M Server settings: 4 | 5 | ; The W5500 has 8 sockets, all are setup to listen. 6 | ; Limiting to 7 requesters allows one socket to remain 7 | ; active for servicing requests and possible admin purposes. 8 | nmb$rqstrs equ 7 ; Number of requesters supported at one time 9 | 10 | ; TODO: to support polling, the NIOS poll routine 11 | ; must be in common memory. That may not be possible/practical. 12 | ; In addition, the host XIOS must support polling and provide 13 | ; some method to access the poll table. 14 | polling equ 0 15 | 16 | ; If network and disk share hardware (SPI adapter), 17 | ; must use same mutex for both to avoid conflicts. 18 | use$mxdisk equ 1 19 | -------------------------------------------------------------------------------- /src/w5500/libwiznt.asm: -------------------------------------------------------------------------------- 1 | ; Basic WIZNET routines 2 | 3 | public wizcfg,wizcf0,wizcmd,wizget,wizset,wizclose,setsok,settcp 4 | public gkeep,skeep 5 | 6 | maclib config 7 | 8 | ; Caller must supply 'nvbuf' 9 | extrn nvbuf 10 | if NVRAM 11 | ; Requires linking with NVRAM.REL, for 'wizcfg'... 12 | extrn nvget, vcksum 13 | endif 14 | 15 | maclib z80 16 | 17 | ; WIZNET CTRL bit for writing 18 | WRITE equ 00000100b 19 | 20 | GAR equ 1 ; offset of GAR, etc. 21 | SUBR equ 5 22 | SHAR equ 9 23 | SIPR equ 15 24 | PMAGIC equ 29 ; used for node ID 25 | PDPORT equ 30 ; used for server listening port 26 | 27 | nsock equ 8 28 | SOCK0 equ 000$01$000b 29 | SOCK1 equ 001$01$000b 30 | SOCK2 equ 010$01$000b 31 | SOCK3 equ 011$01$000b 32 | SOCK4 equ 100$01$000b 33 | SOCK5 equ 101$01$000b 34 | SOCK6 equ 110$01$000b 35 | SOCK7 equ 111$01$000b 36 | 37 | SnMR equ 0 38 | SnCR equ 1 39 | SnIR equ 2 40 | SnSR equ 3 41 | SnPORT equ 4 42 | SnDIPR equ 12 43 | SnDPORT equ 16 44 | SnRESV1 equ 20 ; 0x14 reserved 45 | SnRESV2 equ 23 ; 0x17 reserved 46 | SnRESV3 equ 24 ; 0x18 reserved 47 | SnRESV4 equ 25 ; 0x19 reserved 48 | SnRESV5 equ 26 ; 0x1a reserved 49 | SnRESV6 equ 27 ; 0x1b reserved 50 | SnRESV7 equ 28 ; 0x1c reserved 51 | SnRESV8 equ 29 ; 0x1d reserved 52 | SnTXBUF equ 31 ; TXBUF_SIZE 53 | 54 | NvKPALVTR equ SnRESV8 ; where to stash keepalive in NVRAM 55 | SnKPALVTR equ 47 ; Keep alive timeout, 5s units 56 | 57 | ; Socket SR values 58 | CLOSED equ 00h 59 | 60 | ; Socket CR commands 61 | DISCON equ 08h 62 | 63 | cseg 64 | 65 | ; Send socket command to WIZNET chip, wait for done. 66 | ; A = command, D = socket BSB 67 | ; Destroys A 68 | wizcmd: 69 | push psw 70 | mvi a,WZSCS 71 | out spi$ctl 72 | xra a 73 | out spi$wr 74 | mvi a,SnCR 75 | out spi$wr 76 | mov a,d 77 | ori WRITE 78 | out spi$wr 79 | pop psw 80 | out spi$wr ; start command 81 | xra a ; 82 | out spi$ctl 83 | wc0: 84 | mvi a,WZSCS 85 | out spi$ctl 86 | xra a 87 | out spi$wr 88 | mvi a,SnCR 89 | out spi$wr 90 | mov a,d 91 | out spi$wr 92 | in spi$rd ; prime pump 93 | in spi$rd 94 | push psw 95 | xra a ; 96 | out spi$ctl 97 | pop psw 98 | ora a 99 | jnz wc0 100 | ret 101 | 102 | ; E = BSB, D = CTL, HL = data, B = length 103 | wizget: 104 | mvi a,WZSCS 105 | out spi$ctl 106 | xra a ; hi adr always 0 107 | out spi$wr 108 | mov a,e 109 | out spi$wr 110 | mov a,d 111 | out spi$wr 112 | in spi$rd ; prime pump 113 | mvi c,spi$rd 114 | inir 115 | xra a ; not SCS 116 | out spi$ctl 117 | ret 118 | 119 | ; HL = data to send, E = offset, D = BSB, B = length 120 | ; destroys HL, B, C, A 121 | wizset: 122 | mvi a,WZSCS 123 | out spi$ctl 124 | xra a ; hi adr always 0 125 | out spi$wr 126 | mov a,e 127 | out spi$wr 128 | mov a,d 129 | ori WRITE 130 | out spi$wr 131 | mvi c,spi$wr 132 | outir 133 | xra a ; not SCS 134 | out spi$ctl 135 | ret 136 | 137 | ; Close socket if active (SR <> CLOSED) 138 | ; D = socket BSB 139 | ; Destroys HL, E, B, C, A 140 | wizclose: 141 | lxi h,tmp 142 | mvi e,SnSR 143 | mvi b,1 144 | call wizget 145 | lda tmp 146 | cpi CLOSED 147 | rz 148 | mvi a,DISCON 149 | call wizcmd 150 | ; don't care about results? 151 | ret 152 | 153 | ; IX = base data buffer for socket, D = socket BSB, E = offset, B = length 154 | ; destroys HL, B, C 155 | setsok: 156 | pushix 157 | pop h 158 | push d 159 | mvi d,0 160 | dad d ; HL points to data in 'buf' 161 | pop d 162 | call wizset 163 | ret 164 | 165 | ; Set socket MR to TCP. 166 | ; D = socket BSB (result of "getsokn") 167 | ; Destroys all registers except D. 168 | settcp: 169 | lxi h,tmp 170 | mvi m,1 ; TCP/IP mode 171 | mvi e,SnMR 172 | mvi b,1 173 | call wizset ; force TCP/IP mode 174 | ret 175 | 176 | ; Get KEEP-ALIVE value 177 | ; D=socket BSB 178 | ; Return: A=keep-alive value 179 | gkeep: 180 | mvi e,SnKPALVTR 181 | lxi h,tmp 182 | mvi b,1 183 | call wizget 184 | lda tmp 185 | ret 186 | 187 | ; Set KEEP-ALIVE value - only for DIRECT mode 188 | ; A=keep-alive time, x5-seconds 189 | ; D=socket BSB 190 | skeep: ora a 191 | rz ; do not set, rather than "disable"... 192 | sta tmp 193 | mvi e,SnKPALVTR 194 | lxi h,tmp 195 | mvi b,1 196 | call wizset 197 | ret 198 | 199 | ; restore config from NVRAM 200 | ; Buffer is 'nvbuf' (512 bytes) 201 | ; Return: CY if no config 202 | wizcfg: 203 | if NVRAM 204 | lxix nvbuf 205 | lxi h,0 206 | lxi d,512 207 | call nvget 208 | lxix nvbuf 209 | call vcksum 210 | stc 211 | rnz 212 | else 213 | stc 214 | ret 215 | endif 216 | wizcf0: 217 | lxix nvbuf 218 | lxi h,nvbuf+GAR 219 | mvi d,0 220 | mvi e,GAR 221 | mvi b,18 ; GAR, SUBR, SHAR, SIPR 222 | call wizset 223 | lxi h,nvbuf+PMAGIC 224 | mvi d,0 225 | mvi e,PMAGIC 226 | mvi b,3 227 | call wizset 228 | lxix nvbuf+32 229 | mvi d,SOCK0 230 | mvi b,8 231 | rest0: push b 232 | ldx a,SnPORT 233 | cpi 31h 234 | jnz rest1 ; skip unconfigured sockets 235 | call wizclose 236 | call settcp ; ensure MR is set to TCP/IP 237 | ldx a,NvKPALVTR 238 | call skeep 239 | mvi e,SnPORT 240 | mvi b,2 241 | call setsok 242 | mvi e,SnDIPR 243 | mvi b,6 ; DIPR and DPORT 244 | call setsok 245 | rest1: lxi b,32 246 | dadx b 247 | mvi a,001$00$000b ; socket BSB incr value 248 | add d 249 | mov d,a 250 | pop b 251 | djnz rest0 252 | xra a 253 | ret 254 | 255 | dseg 256 | tmp: db 0 257 | 258 | end 259 | -------------------------------------------------------------------------------- /src/w5500/makevars: -------------------------------------------------------------------------------- 1 | TARGETS += wizcfg.com wizdbg.com wiztest.com 2 | WZCDEPS = wizcfg.rel libwiznt.rel 3 | WZCLINK = wizcfg,libwiznt 4 | MPMTARG += netservr.rsp netservr.brs wizcfg.com wizdbg.com srvstart.com srvstop.com \ 5 | srvprot.com system.dat 6 | LIBS += cfgnwif.lib 7 | -------------------------------------------------------------------------------- /src/w5500/wizdbg.asm: -------------------------------------------------------------------------------- 1 | ; A debug util for WizNET W5500-based devices, via parallel-SPI interface 2 | ; 3 | ; Commands: 4 | ; g Get bytes from at 5 | ; s ... Set bytes to at 6 | 7 | maclib z80 8 | 9 | maclib config 10 | 11 | WRITE equ 00000100b 12 | 13 | CR equ 13 14 | LF equ 10 15 | 16 | cpm equ 0 17 | bdos equ 5 18 | cmdlin equ 0080h 19 | 20 | print equ 9 21 | getver equ 12 22 | ; MP/M XDOS functions 23 | openqf equ 135 24 | readqf equ 137 25 | writqf equ 139 26 | sysdatf equ 154 27 | 28 | org 00100h 29 | 30 | jmp start 31 | 32 | usage: db 'Usage: WIZDBG {G bsb off num}',CR,LF 33 | db ' WIZDBG {S bsb off dat...}',CR,LF 34 | db ' bsb = Block Select Bits, hex 00..1F',CR,LF 35 | db ' off = Offset within BSB, hex',CR,LF 36 | db ' num = Number of bytes to GET, dec',CR,LF 37 | db ' dat = Byte(s) to SET, hex',CR,LF,'$' 38 | nocpn: db 'CP/NET is running. Stop it first or use F',CR,LF,'$' 39 | cpnet: db 0 40 | mpm: db 0 41 | force: db 0 42 | 43 | nmutex: dw 0 ; either 'MXDisk' opened, or mx-of-choice from NetServr. 44 | dw 0 ; no messages 45 | db 'MXDisk ' 46 | 47 | ; lock/unlock preserve DE,IX for WizNET cmd data 48 | nlock: push d 49 | pushix 50 | lxi d,nmutex 51 | mvi c,readqf 52 | call bdos 53 | popix 54 | pop d 55 | ret 56 | 57 | nunlock: 58 | push d 59 | pushix 60 | lxi d,nmutex 61 | mvi c,writqf 62 | call bdos 63 | popix 64 | pop d 65 | ret 66 | 67 | dompm: 68 | mvi c,sysdatf 69 | call bdos 70 | mvi l,9 ; S$CPNET 71 | mov e,m 72 | inx h 73 | mov d,m 74 | mov a,e 75 | ora d 76 | jz nosrv 77 | lxi d,31 ; G$MTX 78 | dad d 79 | mov e,m 80 | inx h 81 | mov d,m 82 | xchg 83 | shld nmutex ; as if opened... 84 | jr mpm1 85 | nosrv: lxi d,nmutex ; use as MXDisk UQCB 86 | mvi c,openqf 87 | call bdos 88 | ora a 89 | jrnz nocpn0 ; what to do? blunder ahead... 90 | mpm1: ori 0ffh 91 | sta mpm ; 'true' if nlock/nunlock required 92 | jr nocpn0 93 | 94 | start: 95 | sspd usrstk 96 | lxi sp,stack 97 | mvi c,getver 98 | call bdos 99 | bit 4,h 100 | jnz dompm 101 | mov a,h 102 | ani 02h 103 | sta cpnet 104 | nocpn0: 105 | lhld bdos+1 ; compute max buf space 106 | mvi l,0 ; 107 | dcr h ; safety margin 108 | lxi d,buf 109 | ora a 110 | dsbc d 111 | mvi l,0 ; more safety margins 112 | shld max 113 | ; start parsing commandline 114 | lda cmdlin 115 | ora a 116 | jz help 117 | 118 | lxi h,cmdlin 119 | mov b,m 120 | inx h 121 | pars0: 122 | mov a,m 123 | cpi 'F' 124 | jz pars4 125 | cpi ' ' 126 | jnz pars1 127 | pars3: inx h 128 | djnz pars0 129 | jmp help 130 | pars4: sta force 131 | jmp pars3 132 | 133 | pars1: 134 | cpi 'G' 135 | jz pars2 136 | cpi 'S' 137 | jnz help 138 | lda force 139 | ora a 140 | jnz pars5 141 | lda cpnet 142 | ora a 143 | jnz nocpnt 144 | pars5: 145 | mvi a,'S' 146 | pars2: 147 | sta com 148 | call skipb 149 | jc help 150 | ; and are always present, 151 | ; plus either or (at least) one . 152 | call parshx 153 | jc help 154 | mov a,d 155 | ora a 156 | jnz help 157 | mov a,e 158 | cpi 32 ; 00..1F allowed 159 | jnc help 160 | rlc 161 | rlc 162 | rlc 163 | sta bsb 164 | call skipb 165 | jc help 166 | call parshx 167 | jc help 168 | xchg 169 | shld off 170 | xchg 171 | call skipb 172 | jc help 173 | lda com 174 | cpi 'G' 175 | jz get 176 | mvi c,0 177 | lxix buf 178 | set0: 179 | call parshx 180 | jc help 181 | mov a,d 182 | ora a 183 | jnz help 184 | stx e,+0 185 | inxix 186 | inr c ; can't overflow with 128-byte buffer 187 | mov a,b 188 | ora a 189 | jz set1 190 | call skipb 191 | jnc set0 192 | set1: 193 | push h 194 | push b 195 | lda mpm 196 | ora a 197 | cnz nlock ; preserves DE, IX 198 | pop b 199 | pop h 200 | mov a,c 201 | sta num 202 | call wizset 203 | lda mpm 204 | ora a 205 | cnz nunlock 206 | jmp exit 207 | 208 | get: 209 | call parsnm 210 | jc help 211 | ; done parsing command, can destroy HL/B 212 | lhld max 213 | ora a 214 | dsbc d 215 | jc help ; or "overflow"? "too large"? 216 | push h 217 | push b 218 | lda mpm 219 | ora a 220 | cnz nlock ; preserves DE, IX 221 | pop b 222 | pop h 223 | sded num 224 | call wizget 225 | lda mpm 226 | ora a 227 | cnz nunlock 228 | lxi h,buf 229 | push h 230 | ; dump 'num' bytes from 'buf'... label with bsb/off... 231 | get0: 232 | lda bsb 233 | ani 11111000b 234 | rrc 235 | rrc 236 | rrc 237 | call hexout 238 | mvi a,':' 239 | call chrout 240 | lhld off 241 | call wrdout 242 | ; now output <=16 bytes " XX"... 243 | mvi b,16 244 | get1: 245 | mvi a,' ' 246 | call chrout 247 | pop h 248 | mov a,m 249 | inx h 250 | push h 251 | call hexout 252 | lhld off 253 | inx h 254 | shld off 255 | lhld num 256 | dcx h 257 | shld num 258 | mov a,h 259 | ora l 260 | jz get2 261 | djnz get1 262 | call crlf 263 | jmp get0 264 | get2: 265 | call crlf 266 | exit: 267 | jmp cpm 268 | 269 | help: 270 | lxi d,usage 271 | xitmsg: 272 | mvi c,print 273 | call bdos 274 | jmp exit 275 | 276 | nocpnt: 277 | lxi d,nocpn 278 | jmp xitmsg 279 | 280 | ; Read (GET) data from chip. 281 | ; 'num', 'bsb', 'off' setup. 282 | ; Returns: 'buf' filled with 'num' bytes. 283 | wizget: 284 | mvi a,WZSCS 285 | out spi$ctl 286 | lhld off 287 | mov a,h 288 | out spi$wr 289 | mov a,l 290 | out spi$wr 291 | lda bsb 292 | out spi$wr 293 | in spi$rd ; prime pump 294 | mvi c,spi$rd 295 | lxi h,buf 296 | lded num 297 | mov b,e 298 | mov a,e 299 | ora a 300 | jrz wg0 301 | inir ; do partial page 302 | mov a,d 303 | ora a 304 | jrz wg1 305 | wg0: inir 306 | dcr d 307 | jrnz wg0 308 | wg1: xra a ; not SCS 309 | out spi$ctl 310 | ret 311 | 312 | ; Write (SET) data in chip. 313 | ; 'num', 'buf', 'bsb', 'off' setup. 314 | wizset: 315 | mvi a,WZSCS 316 | out spi$ctl 317 | lhld off 318 | mov a,h 319 | out spi$wr 320 | mov a,l 321 | out spi$wr 322 | lda bsb 323 | ori WRITE 324 | out spi$wr 325 | lda num 326 | mov b,a 327 | mvi c,spi$wr 328 | lxi h,buf 329 | outir 330 | xra a ; not SCS 331 | out spi$ctl 332 | ret 333 | 334 | chrout: 335 | push h 336 | push d 337 | push b 338 | mov e,a 339 | mvi c,002h 340 | call bdos 341 | pop b 342 | pop d 343 | pop h 344 | ret 345 | 346 | crlf: 347 | mvi a,CR 348 | call chrout 349 | mvi a,LF 350 | call chrout 351 | ret 352 | 353 | ; Print 16-bit hex value from HL 354 | wrdout: 355 | push h 356 | mov a,h 357 | call hexout 358 | pop h 359 | mov a,l 360 | hexout: 361 | push psw 362 | rrc 363 | rrc 364 | rrc 365 | rrc 366 | call hexdig 367 | pop psw 368 | ;jmp hexdig 369 | hexdig: 370 | ani 0fh 371 | adi 90h 372 | daa 373 | aci 40h 374 | daa 375 | jmp chrout 376 | 377 | skipb: 378 | inx h ; skip option letter 379 | dcr b 380 | stc 381 | rz 382 | skip0: mov a,m 383 | ora a 384 | cpi ' ' 385 | rnz ; no carry? 386 | inx h 387 | djnz skip0 388 | stc 389 | ret 390 | 391 | ; Parse (up to) 16-bit hex value. 392 | ; input: HL is cmd buf, B remaining chars 393 | ; returns number in DE, CY if error, NZ end of text 394 | parshx: 395 | lxi d,0 396 | pm0: mov a,m 397 | cpi ' ' 398 | rz 399 | sui '0' 400 | rc 401 | cpi '9'-'0'+1 402 | jc pm3 403 | sui 'A'-'0' 404 | rc 405 | cpi 'F'-'A'+1 406 | cmc 407 | rc 408 | adi 10 409 | pm3: 410 | ani 0fh 411 | xchg 412 | dad h 413 | jc pme 414 | dad h 415 | jc pme 416 | dad h 417 | jc pme 418 | dad h 419 | jc pme 420 | xchg 421 | add e ; carry not possible 422 | mov e,a 423 | inx h 424 | djnz pm0 425 | nzret: 426 | xra a 427 | inr a ; NZ 428 | ret 429 | pme: xchg 430 | stc 431 | ret 432 | 433 | ; Parse a 16-bit (max) decimal number 434 | parsnm: 435 | lxi d,0 436 | pd0: mov a,m 437 | cpi ' ' 438 | rz 439 | cpi '0' 440 | rc 441 | cpi '9'+1 442 | cmc 443 | rc 444 | ani 0fh 445 | push h 446 | mov h,d 447 | mov l,e 448 | dad h ; *2 449 | jc pd1 450 | dad h ; *4 451 | jc pd1 452 | dad d ; *5 453 | jc pd1 454 | dad h ; *10 455 | jc pd1 456 | mov e,a 457 | mvi d,0 458 | dad d 459 | xchg 460 | pop h 461 | rc 462 | inx h 463 | djnz pd0 464 | ora a ; NC 465 | ret 466 | 467 | pd1: pop h 468 | ret ; CY still set 469 | 470 | ds 40 471 | stack: ds 0 472 | usrstk: dw 0 473 | 474 | com: db 0 475 | bsb: db 0 476 | off: dw 0 477 | num: dw 0 ; SET: one byte, GET: two bytes 478 | max: dw 0 ; maximum allowed (for GET) 479 | 480 | buf: ds 0 481 | 482 | end 483 | -------------------------------------------------------------------------------- /src/w5500/wiztest.asm: -------------------------------------------------------------------------------- 1 | ; A stress-test for WizNET W5500 SPI interfaces 2 | ; 3 | 4 | maclib z80 5 | 6 | maclib config 7 | 8 | ; W5500 constants 9 | WRITE equ 00000100b 10 | TX0BSB equ 0010b ; Socket BSB 11 | TX0BUF equ 0000h ; Tx FIFO buffer offset 12 | 13 | CTLC equ 3 14 | CR equ 13 15 | LF equ 10 16 | 17 | cpm equ 0 18 | bdos equ 5 19 | cmdlin equ 0080h 20 | 21 | dircon equ 6 22 | print equ 9 23 | getver equ 12 24 | 25 | org 00100h 26 | 27 | jmp start 28 | 29 | cpnet: db 0 30 | seed: db 0 31 | pass: dw 0 32 | verbos: db 0 ; also means stop on error 33 | 34 | faterr: db CR,LF,'Fatal error communicating with WizNet',CR,LF,'$' 35 | 36 | start: 37 | sspd usrstk 38 | lxi sp,stack 39 | mvi c,getver 40 | call bdos 41 | mov a,h 42 | ani 02h 43 | sta cpnet 44 | ; parse options 45 | lda cmdlin ; length 46 | ora a 47 | jrz begin 48 | lxi h,cmdlin 49 | mov b,m 50 | inx h 51 | skipb: mov a,m 52 | cpi ' ' 53 | jrnz noblk 54 | inx h 55 | djnz skipb 56 | ; A still ' ' 57 | noblk: cpi 'V' ; verbose 58 | jrnz begin 59 | sta verbos 60 | begin: 61 | ; all these are constant 62 | mvi a,TX0BSB 63 | rlc 64 | rlc 65 | rlc ; into position for W5500 66 | sta bsb 67 | lxi h,TX0BUF 68 | shld off 69 | lxi h,128 ; we only use 128 bytes 70 | shld num 71 | loop: 72 | mvi a,CR 73 | call conout 74 | lhld pass 75 | call wrdout 76 | 77 | call setbuf 78 | call wizset 79 | jc fatal 80 | call xxxbuf 81 | call wizget 82 | jc fatal 83 | call chkbuf 84 | jz ok 85 | ; C=error count 86 | mvi a,'!' 87 | call conout 88 | lda seed 89 | call hexout 90 | mvi a,' ' 91 | call conout 92 | mov a,c 93 | call decout 94 | call crlf 95 | lda verbos 96 | ora a 97 | jnz dump ; and exit 98 | ok: 99 | lda seed 100 | adi 1 101 | daa 102 | sta seed 103 | lhld pass 104 | inx h 105 | shld pass 106 | call conbrk 107 | jz loop 108 | exit: 109 | call crlf 110 | jmp cpm 111 | 112 | fatal: 113 | lxi d,faterr 114 | xitmsg: 115 | mvi c,print 116 | call bdos 117 | jmp exit 118 | 119 | setbuf: lxi h,buf 120 | mvi b,128 121 | lda seed 122 | sb0: mov m,a 123 | inx h 124 | adi 1 125 | daa 126 | djnz sb0 127 | ret 128 | 129 | xxxbuf: lxi h,buf 130 | mvi b,128 131 | mvi a,0ffh 132 | xb0: mov m,a 133 | inx h 134 | djnz xb0 135 | ret 136 | 137 | ; Returns NZ if miscompare 138 | ; Error count in C 139 | chkbuf: lxi h,buf 140 | mvi b,128 141 | mvi c,0 142 | lda seed 143 | cb0: cmp m 144 | jrz cb1 145 | inr c 146 | cb1: inx h 147 | adi 1 148 | daa 149 | djnz cb0 150 | mov a,c 151 | ora a 152 | ret 153 | 154 | dump: 155 | lxi h,buf 156 | mvi c,128/16 157 | lda seed 158 | dm2: mvi b,16 159 | dm0: push psw 160 | cmp m 161 | mvi a,' ' 162 | jrz dm1 163 | mvi a,'*' 164 | dm1: call conout 165 | mov a,m 166 | call hexout 167 | inx h 168 | pop psw 169 | adi 1 170 | daa 171 | djnz dm0 172 | push psw 173 | call crlf 174 | pop psw 175 | dcr c 176 | jrnz dm2 177 | jmp cpm 178 | 179 | conbrk: push h 180 | push d 181 | push b 182 | mvi e,0ffh 183 | mvi c,dircon 184 | call bdos 185 | pop b 186 | pop d 187 | pop h 188 | ora a 189 | rz 190 | cpi CTLC 191 | rnz 192 | mvi a,'*' 193 | call conout 194 | call crlf 195 | jmp exit 196 | 197 | conout: 198 | push h 199 | push d 200 | push b 201 | mov e,a 202 | mvi c,dircon 203 | call bdos 204 | pop b 205 | pop d 206 | pop h 207 | ret 208 | 209 | crlf: 210 | mvi a,CR 211 | call conout 212 | mvi a,LF 213 | call conout 214 | ret 215 | 216 | wrdout: mov a,h 217 | call hexout 218 | mov a,l 219 | hexout: push psw 220 | rlc 221 | rlc 222 | rlc 223 | rlc 224 | call hex0 225 | pop psw 226 | hex0: ani 0fh 227 | adi 90h 228 | daa 229 | aci 40h 230 | daa 231 | jmp conout 232 | 233 | ; leading zeroes printed - must preserve B 234 | decout: 235 | mvi d,100 236 | call divide 237 | mvi d,10 238 | call divide 239 | adi '0' 240 | jmp conout 241 | 242 | divide: mvi e,0 243 | div0: sub d 244 | inr e 245 | jrnc div0 246 | add d 247 | dcr e 248 | push psw ; remainder 249 | mvi a,'0' 250 | add e 251 | call conout 252 | pop psw ; remainder 253 | ret 254 | 255 | ; Read (GET) data from chip. 256 | ; 'num', 'bsb', 'off' setup. 257 | ; Returns: 'buf' filled with 'num' bytes. 258 | wizget: 259 | mvi a,WZSCS 260 | out spi$ctl 261 | lhld off 262 | mov a,h 263 | out spi$wr 264 | mov a,l 265 | out spi$wr 266 | lda bsb 267 | out spi$wr 268 | in spi$rd ; prime pump 269 | mvi c,spi$rd 270 | lxi h,buf 271 | lded num 272 | mov b,e 273 | mov a,e 274 | ora a 275 | jrz wg0 276 | inir ; do partial page 277 | mov a,d 278 | ora a 279 | jrz wg1 280 | wg0: inir 281 | dcr d 282 | jrnz wg0 283 | wg1: xra a ; not SCS 284 | out spi$ctl 285 | 286 | ; Write (SET) data in chip. 287 | ; 'num', 'buf', 'bsb', 'off' setup. 288 | wizset: 289 | mvi a,WZSCS 290 | out spi$ctl 291 | lhld off 292 | mov a,h 293 | out spi$wr 294 | mov a,l 295 | out spi$wr 296 | lda bsb 297 | ori WRITE 298 | out spi$wr 299 | lda num 300 | mov b,a 301 | mvi c,spi$wr 302 | lxi h,buf 303 | outir 304 | xra a ; not SCS 305 | out spi$ctl 306 | ret 307 | 308 | ds 40 309 | stack: ds 0 310 | usrstk: dw 0 311 | 312 | bsb: db 0 313 | off: dw 0 314 | num: dw 0 ; SET: one byte, GET: two bytes 315 | 316 | buf: ds 0 317 | 318 | end 319 | -------------------------------------------------------------------------------- /src/w5500c/config.lib: -------------------------------------------------------------------------------- 1 | ; Z180 CSIO on SC126 systems. 2 | 3 | ; definitions for chip select IO registers 4 | RTCIO EQU 0Ch ; RTC LATCH REGISTER ADR 5 | 6 | ; definitions for z180 CSIO registers 7 | Z180BASE equ 0C0h 8 | Z180CNTR EQU Z180BASE + 0Ah ; CSI/O CONTROL 9 | Z180TRDR EQU Z180BASE + 0Bh ; CSI/O TRANSMIT/RECEIVE 10 | 11 | ; names used is program 12 | OPRREG EQU RTCIO ; USES RTC LATCHES FOR OPERATION 13 | OPRDEF EQU 00001100b ; QUIESCENT STATE (/CS1 & /CS2 DEASSERTED) 14 | OPRMSK EQU 00001100b ; MASK FOR BITS WE OWN IN RTC LATCH PORT 15 | 16 | CS0 EQU 00000100b ; RTC:2 IS SELECT FOR PRIMARY SPI CARD 17 | CS1 EQU 00001000b ; RTC:3 IS SELECT FOR SECONDARY SPI CARD 18 | 19 | CNTR EQU Z180CNTR 20 | CNTRTE equ 10h 21 | CNTRRE equ 20h 22 | 23 | TRDR EQU Z180TRDR 24 | 25 | IOBASE EQU OPRREG ; IOBASE 26 | IOSYSTEM equ 0Ch 27 | 28 | -------------------------------------------------------------------------------- /src/w5500c/makevars: -------------------------------------------------------------------------------- 1 | LIBS += z180.lib 2 | TARGETS += wizcfg.com wizdbg.com 3 | WZCDEPS = wizcfg.rel libwiznt.rel 4 | WZCLINK = wizcfg,libwiznt 5 | -------------------------------------------------------------------------------- /src/z180.lib: -------------------------------------------------------------------------------- 1 | ; @CHK MACRO USED FOR CHECKING 8 BIT DISPLACMENTS 2 | ; 3 | @CHK MACRO ?DD ;; USED FOR CHECKING RANGE OF 8-BIT DISP.S 4 | IF (?DD GT 7FH) AND (?DD LT 0FF80H) 5 | DS 'DISPLACEMENT RANGE ERROR -' ?DD 6 | ENDIF 7 | ENDM 8 | @CHKR MACRO ?NN,?DD 9 | @CHK ?DD 10 | DB ?NN,?DD 11 | ENDM 12 | 13 | LDX MACRO ?R,?D 14 | @CHK ?D 15 | DB 0DDH,?R*8+46H,?D 16 | ENDM 17 | LDY MACRO ?R,?D 18 | @CHK ?D 19 | DB 0FDH,?R*8+46H,?D 20 | ENDM 21 | STX MACRO ?R,?D 22 | @CHK ?D 23 | DB 0DDH,70H+?R,?D 24 | ENDM 25 | STY MACRO ?R,?D 26 | @CHK ?D 27 | DB 0FDH,70H+?R,?D 28 | ENDM 29 | MVIX MACRO ?N,?D 30 | @CHK ?D 31 | DB 0DDH,36H,?D,?N 32 | ENDM 33 | MVIY MACRO ?N,?D 34 | @CHK ?D 35 | DB 0FDH,36H,?D,?N 36 | ENDM 37 | LDAI MACRO 38 | DB 0EDH,57H 39 | ENDM 40 | LDAR MACRO 41 | DB 0EDH,5FH 42 | ENDM 43 | STAI MACRO 44 | DB 0EDH,47H 45 | ENDM 46 | STAR MACRO 47 | DB 0EDH,4FH 48 | ENDM 49 | LXIX MACRO ?NNNN 50 | DB 0DDH,21H 51 | DW ?NNNN 52 | ENDM 53 | LXIY MACRO ?NNNN 54 | DB 0FDH,21H 55 | DW ?NNNN 56 | ENDM 57 | LDED MACRO ?NNNN 58 | DB 0EDH,5BH 59 | DW ?NNNN 60 | ENDM 61 | LBCD MACRO ?NNNN 62 | DB 0EDH,4BH 63 | DW ?NNNN 64 | ENDM 65 | LSPD MACRO ?NNNN 66 | DB 0EDH,07BH 67 | DW ?NNNN 68 | ENDM 69 | LIXD MACRO ?NNNN 70 | DB 0DDH,2AH 71 | DW ?NNNN 72 | ENDM 73 | LIYD MACRO ?NNNN 74 | DB 0FDH,2AH 75 | DW ?NNNN 76 | ENDM 77 | SBCD MACRO ?NNNN 78 | DB 0EDH,43H 79 | DW ?NNNN 80 | ENDM 81 | SDED MACRO ?NNNN 82 | DB 0EDH,53H 83 | DW ?NNNN 84 | ENDM 85 | SSPD MACRO ?NNNN 86 | DB 0EDH,73H 87 | DW ?NNNN 88 | ENDM 89 | SIXD MACRO ?NNNN 90 | DB 0DDH,22H 91 | DW ?NNNN 92 | ENDM 93 | SIYD MACRO ?NNNN 94 | DB 0FDH,22H 95 | DW ?NNNN 96 | ENDM 97 | SPIX MACRO 98 | DB 0DDH,0F9H 99 | ENDM 100 | SPIY MACRO 101 | DB 0FDH,0F9H 102 | ENDM 103 | PUSHIX MACRO 104 | DB 0DDH,0E5H 105 | ENDM 106 | PUSHIY MACRO 107 | DB 0FDH,0E5H 108 | ENDM 109 | POPIX MACRO 110 | DB 0DDH,0E1H 111 | ENDM 112 | POPIY MACRO 113 | DB 0FDH,0E1H 114 | ENDM 115 | EXAF MACRO 116 | DB 08H 117 | ENDM 118 | EXX MACRO 119 | DB 0D9H 120 | ENDM 121 | XTIX MACRO 122 | DB 0DDH,0E3H 123 | ENDM 124 | XTIY MACRO 125 | DB 0FDH,0E3H 126 | ENDM 127 | LDI MACRO 128 | DB 0EDH,0A0H 129 | ENDM 130 | LDIR MACRO 131 | DB 0EDH,0B0H 132 | ENDM 133 | LDD MACRO 134 | DB 0EDH,0A8H 135 | ENDM 136 | LDDR MACRO 137 | DB 0EDH,0B8H 138 | ENDM 139 | CCI MACRO 140 | DB 0EDH,0A1H 141 | ENDM 142 | CCIR MACRO 143 | DB 0EDH,0B1H 144 | ENDM 145 | CCD MACRO 146 | DB 0EDH,0A9H 147 | ENDM 148 | CCDR MACRO 149 | DB 0EDH,0B9H 150 | ENDM 151 | ADDX MACRO ?D 152 | @CHK ?D 153 | DB 0DDH,86H,?D 154 | ENDM 155 | ADDY MACRO ?D 156 | @CHK ?D 157 | DB 0FDH,86H,?D 158 | ENDM 159 | ADCX MACRO ?D 160 | @CHK ?D 161 | DB 0DDH,8EH,?D 162 | ENDM 163 | ADCY MACRO ?D 164 | @CHK ?D 165 | DB 0FDH,8EH,?D 166 | ENDM 167 | SUBX MACRO ?D 168 | @CHK ?D 169 | DB 0DDH,96H,?D 170 | ENDM 171 | SUBY MACRO ?D 172 | @CHK ?D 173 | DB 0FDH,96H,?D 174 | ENDM 175 | SBCX MACRO ?D 176 | @CHK ?D 177 | DB 0DDH,9EH,?D 178 | ENDM 179 | SBBX MACRO ?D 180 | SBCX ?D 181 | ENDM 182 | SBCY MACRO ?D 183 | @CHK ?D 184 | DB 0FDH,9EH,?D 185 | ENDM 186 | SBBY MACRO ?D 187 | SBCY ?D 188 | ENDM 189 | ANDX MACRO ?D 190 | @CHK ?D 191 | DB 0DDH,0A6H,?D 192 | ENDM 193 | ANAX MACRO ?D 194 | ANDX ?D 195 | ENDM 196 | ANDY MACRO ?D 197 | @CHK ?D 198 | DB 0FDH,0A6H,?D 199 | ENDM 200 | ANAY MACRO ?D 201 | ANDY ?D 202 | ENDM 203 | XORX MACRO ?D 204 | @CHK ?D 205 | DB 0DDH,0AEH,?D 206 | ENDM 207 | XRAX MACRO ?D 208 | XORX ?D 209 | ENDM 210 | XORY MACRO ?D 211 | @CHK ?D 212 | DB 0FDH,0AEH,?D 213 | ENDM 214 | XRAY MACRO ?D 215 | XORY ?D 216 | ENDM 217 | ORX MACRO ?D 218 | @CHK ?D 219 | DB 0DDH,0B6H,?D 220 | ENDM 221 | ORAX MACRO ?D 222 | ORX ?D 223 | ENDM 224 | ORY MACRO ?D 225 | @CHK ?D 226 | DB 0FDH,0B6H,?D 227 | ENDM 228 | ORAY MACRO ?D 229 | ORY ?D 230 | ENDM 231 | CMPX MACRO ?D 232 | @CHK ?D 233 | DB 0DDH,0BEH,?D 234 | ENDM 235 | CMPY MACRO ?D 236 | @CHK ?D 237 | DB 0FDH,0BEH,?D 238 | ENDM 239 | INRX MACRO ?D 240 | @CHK ?D 241 | DB 0DDH,34H,?D 242 | ENDM 243 | INRY MACRO ?D 244 | @CHK ?D 245 | DB 0FDH,34H,?D 246 | ENDM 247 | DCRX MACRO ?D 248 | @CHK ?D 249 | DB 0DDH,035H,?D 250 | ENDM 251 | DCRY MACRO ?D 252 | @CHK ?D 253 | DB 0FDH,35H,?D 254 | ENDM 255 | NEG MACRO 256 | DB 0EDH,44H 257 | ENDM 258 | IM0 MACRO 259 | DB 0EDH,46H 260 | ENDM 261 | IM1 MACRO 262 | DB 0EDH,56H 263 | ENDM 264 | IM2 MACRO 265 | DB 0EDH,5EH 266 | ENDM 267 | 268 | BC EQU 0 269 | DE EQU 2 270 | HL EQU 4 271 | IX EQU 4 272 | IY EQU 4 273 | DADC MACRO ?R 274 | DB 0EDH,?R*8+4AH 275 | ENDM 276 | DSBC MACRO ?R 277 | DB 0EDH,?R*8+42H 278 | ENDM 279 | DADX MACRO ?R 280 | DB 0DDH,?R*8+09H 281 | ENDM 282 | DADY MACRO ?R 283 | DB 0FDH,?R*8+09H 284 | ENDM 285 | INXIX MACRO 286 | DB 0DDH,23H 287 | ENDM 288 | INXIY MACRO 289 | DB 0FDH,23H 290 | ENDM 291 | DCXIX MACRO 292 | DB 0DDH,2BH 293 | ENDM 294 | DCXIY MACRO 295 | DB 0FDH,2BH 296 | ENDM 297 | BIT MACRO ?N,?R 298 | DB 0CBH,?N*8+?R+40H 299 | ENDM 300 | SETB MACRO ?N,?R 301 | DB 0CBH,?N*8+?R+0C0H 302 | ENDM 303 | RES MACRO ?N,?R 304 | DB 0CBH,?N*8+?R+80H 305 | ENDM 306 | BITX MACRO ?N,?D 307 | @CHK ?D 308 | DB 0DDH,0CBH,?D,?N*8+46H 309 | ENDM 310 | BITY MACRO ?N,?D 311 | @CHK ?D 312 | DB 0FDH,0CBH,?D,?N*8+46H 313 | ENDM 314 | SETX MACRO ?N,?D 315 | @CHK ?D 316 | DB 0DDH,0CBH,?D,?N*8+0C6H 317 | ENDM 318 | SETY MACRO ?N,?D 319 | @CHK ?D 320 | DB 0FDH,0CBH,?D,?N*8+0C6H 321 | ENDM 322 | RESX MACRO ?N,?D 323 | @CHK ?D 324 | DB 0DDH,0CBH,?D,?N*8+86H 325 | ENDM 326 | RESY MACRO ?N,?D 327 | @CHK ?D 328 | DB 0FDH,0CBH,?D,?N*8+86H 329 | ENDM 330 | JR MACRO ?N 331 | @CHKR 18H,?N-$-1 332 | ENDM 333 | JRC MACRO ?N 334 | @CHKR 38H,?N-$-1 335 | ENDM 336 | JRNC MACRO ?N 337 | @CHKR 30H,?N-$-1 338 | ENDM 339 | JRZ MACRO ?N 340 | @CHKR 28H,?N-$-1 341 | ENDM 342 | JRNZ MACRO ?N 343 | @CHKR 20H,?N-$-1 344 | ENDM 345 | DJNZ MACRO ?N 346 | @CHKR 10H,?N-$-1 347 | ENDM 348 | PCIX MACRO 349 | DB 0DDH,0E9H 350 | ENDM 351 | PCIY MACRO 352 | DB 0FDH,0E9H 353 | ENDM 354 | RETI MACRO 355 | DB 0EDH,4DH 356 | ENDM 357 | RETN MACRO 358 | DB 0EDH,45H 359 | ENDM 360 | INP MACRO ?R 361 | DB 0EDH,?R*8+40H 362 | ENDM 363 | OUTP MACRO ?R 364 | DB 0EDH,?R*8+41H 365 | ENDM 366 | INI MACRO 367 | DB 0EDH,0A2H 368 | ENDM 369 | INIR MACRO 370 | DB 0EDH,0B2H 371 | ENDM 372 | IND MACRO 373 | DB 0EDH,0AAH 374 | ENDM 375 | INDR MACRO 376 | DB 0EDH,0BAH 377 | ENDM 378 | OUTI MACRO 379 | DB 0EDH,0A3H 380 | ENDM 381 | OUTIR MACRO 382 | DB 0EDH,0B3H 383 | ENDM 384 | OUTD MACRO 385 | DB 0EDH,0ABH 386 | ENDM 387 | OUTDR MACRO 388 | DB 0EDH,0BBH 389 | ENDM 390 | RLCR MACRO ?R 391 | DB 0CBH, 00H + ?R 392 | ENDM 393 | RLCX MACRO ?D 394 | @CHK ?D 395 | DB 0DDH, 0CBH, ?D, 06H 396 | ENDM 397 | RLCY MACRO ?D 398 | @CHK ?D 399 | DB 0FDH, 0CBH, ?D, 06H 400 | ENDM 401 | RALR MACRO ?R 402 | DB 0CBH, 10H+?R 403 | ENDM 404 | RALX MACRO ?D 405 | @CHK ?D 406 | DB 0DDH, 0CBH, ?D, 16H 407 | ENDM 408 | RALY MACRO ?D 409 | @CHK ?D 410 | DB 0FDH, 0CBH, ?D, 16H 411 | ENDM 412 | RRCR MACRO ?R 413 | DB 0CBH, 08H + ?R 414 | ENDM 415 | RRCX MACRO ?D 416 | @CHK ?D 417 | DB 0DDH, 0CBH, ?D, 0EH 418 | ENDM 419 | RRCY MACRO ?D 420 | @CHK ?D 421 | DB 0FDH, 0CBH, ?D, 0EH 422 | ENDM 423 | RARR MACRO ?R 424 | DB 0CBH, 18H + ?R 425 | ENDM 426 | RARX MACRO ?D 427 | @CHK ?D 428 | DB 0DDH, 0CBH, ?D, 1EH 429 | ENDM 430 | RARY MACRO ?D 431 | @CHK ?D 432 | DB 0FDH, 0CBH, ?D, 1EH 433 | ENDM 434 | SLAR MACRO ?R 435 | DB 0CBH, 20H + ?R 436 | ENDM 437 | SLAX MACRO ?D 438 | @CHK ?D 439 | DB 0DDH, 0CBH, ?D, 26H 440 | ENDM 441 | SLAY MACRO ?D 442 | @CHK ?D 443 | DB 0FDH, 0CBH, ?D, 26H 444 | ENDM 445 | SRAR MACRO ?R 446 | DB 0CBH, 28H+?R 447 | ENDM 448 | SRAX MACRO ?D 449 | @CHK ?D 450 | DB 0DDH, 0CBH, ?D, 2EH 451 | ENDM 452 | SRAY MACRO ?D 453 | @CHK ?D 454 | DB 0FDH, 0CBH, ?D, 2EH 455 | ENDM 456 | SRLR MACRO ?R 457 | DB 0CBH, 38H + ?R 458 | ENDM 459 | SRLX MACRO ?D 460 | @CHK ?D 461 | DB 0DDH, 0CBH, ?D, 3EH 462 | ENDM 463 | SRLY MACRO ?D 464 | @CHK ?D 465 | DB 0FDH, 0CBH, ?D, 3EH 466 | ENDM 467 | RLD MACRO 468 | DB 0EDH, 6FH 469 | ENDM 470 | RRD MACRO 471 | DB 0EDH, 67H 472 | ENDM 473 | MLT MACRO ?R 474 | DB 0EDH, ?R*8+4CH 475 | ENDM 476 | TSTI MACRO ?N 477 | DB 0EDH, 64H, ?N 478 | ENDM 479 | TST MACRO ?R 480 | DB 0EDH, ?R*8+04H 481 | ENDM 482 | OUT0 MACRO ?R,?N 483 | DB 0EDH, ?R*8+01H, ?N 484 | ENDM 485 | IN0 MACRO ?R,?N 486 | DB 0EDH, ?R*8+00H, ?N 487 | ENDM 488 | TSTIO MACRO ?N 489 | DB 0EDH, 74H, ?N 490 | ENDM 491 | SLP MACRO 492 | DB 0EDH, 76H 493 | ENDM 494 | OUTIM MACRO 495 | DB 0EDH, 83H 496 | ENDM 497 | OUTDM MACRO 498 | DB 0EDH, 8BH 499 | ENDM 500 | OUTIMR MACRO 501 | DB 0EDH, 93H 502 | ENDM 503 | OUTDMR MACRO 504 | DB 0EDH, 9BH 505 | ENDM 506 | -------------------------------------------------------------------------------- /src/z180csio/config.lib: -------------------------------------------------------------------------------- 1 | ; Z180 CSIO on SC126 systems. 2 | NVRAM equ 0 ; no NVRAM or special config needed 3 | 4 | SPIDEV equ Z180CSIO 5 | -------------------------------------------------------------------------------- /src/z180csio/platform.asm: -------------------------------------------------------------------------------- 1 | public platfm 2 | platfm: db 'Z180-CSIO$' 3 | end 4 | -------------------------------------------------------------------------------- /src/z80.lib: -------------------------------------------------------------------------------- 1 | ; @CHK MACRO USED FOR CHECKING 8 BIT DISPLACMENTS 2 | ; 3 | @CHK MACRO ?DD ;; USED FOR CHECKING RANGE OF 8-BIT DISP.S 4 | IF (?DD GT 7FH) AND (?DD LT 0FF80H) 5 | DS 'DISPLACEMENT RANGE ERROR -' ?DD 6 | ENDIF 7 | ENDM 8 | @CHKR MACRO ?NN,?DD 9 | @CHK ?DD 10 | DB ?NN,?DD 11 | ENDM 12 | 13 | LDX MACRO ?R,?D 14 | @CHK ?D 15 | DB 0DDH,?R*8+46H,?D 16 | ENDM 17 | LDY MACRO ?R,?D 18 | @CHK ?D 19 | DB 0FDH,?R*8+46H,?D 20 | ENDM 21 | STX MACRO ?R,?D 22 | @CHK ?D 23 | DB 0DDH,70H+?R,?D 24 | ENDM 25 | STY MACRO ?R,?D 26 | @CHK ?D 27 | DB 0FDH,70H+?R,?D 28 | ENDM 29 | MVIX MACRO ?N,?D 30 | @CHK ?D 31 | DB 0DDH,36H,?D,?N 32 | ENDM 33 | MVIY MACRO ?N,?D 34 | @CHK ?D 35 | DB 0FDH,36H,?D,?N 36 | ENDM 37 | LDAI MACRO 38 | DB 0EDH,57H 39 | ENDM 40 | LDAR MACRO 41 | DB 0EDH,5FH 42 | ENDM 43 | STAI MACRO 44 | DB 0EDH,47H 45 | ENDM 46 | STAR MACRO 47 | DB 0EDH,4FH 48 | ENDM 49 | 50 | LXIX MACRO ?NNNN 51 | DB 0DDH,21H 52 | DW ?NNNN 53 | ENDM 54 | LXIY MACRO ?NNNN 55 | DB 0FDH,21H 56 | DW ?NNNN 57 | ENDM 58 | LDED MACRO ?NNNN 59 | DB 0EDH,5BH 60 | DW ?NNNN 61 | ENDM 62 | LBCD MACRO ?NNNN 63 | DB 0EDH,4BH 64 | DW ?NNNN 65 | ENDM 66 | LSPD MACRO ?NNNN 67 | DB 0EDH,07BH 68 | DW ?NNNN 69 | ENDM 70 | LIXD MACRO ?NNNN 71 | DB 0DDH,2AH 72 | DW ?NNNN 73 | ENDM 74 | LIYD MACRO ?NNNN 75 | DB 0FDH,2AH 76 | DW ?NNNN 77 | ENDM 78 | SBCD MACRO ?NNNN 79 | DB 0EDH,43H 80 | DW ?NNNN 81 | ENDM 82 | SDED MACRO ?NNNN 83 | DB 0EDH,53H 84 | DW ?NNNN 85 | ENDM 86 | SSPD MACRO ?NNNN 87 | DB 0EDH,73H 88 | DW ?NNNN 89 | ENDM 90 | SIXD MACRO ?NNNN 91 | DB 0DDH,22H 92 | DW ?NNNN 93 | ENDM 94 | SIYD MACRO ?NNNN 95 | DB 0FDH,22H 96 | DW ?NNNN 97 | ENDM 98 | SPIX MACRO 99 | DB 0DDH,0F9H 100 | ENDM 101 | SPIY MACRO 102 | DB 0FDH,0F9H 103 | ENDM 104 | PUSHIX MACRO 105 | DB 0DDH,0E5H 106 | ENDM 107 | PUSHIY MACRO 108 | DB 0FDH,0E5H 109 | ENDM 110 | POPIX MACRO 111 | DB 0DDH,0E1H 112 | ENDM 113 | POPIY MACRO 114 | DB 0FDH,0E1H 115 | ENDM 116 | EXAF MACRO 117 | DB 08H 118 | ENDM 119 | EXX MACRO 120 | DB 0D9H 121 | ENDM 122 | XTIX MACRO 123 | DB 0DDH,0E3H 124 | ENDM 125 | XTIY MACRO 126 | DB 0FDH,0E3H 127 | ENDM 128 | 129 | LDI MACRO 130 | DB 0EDH,0A0H 131 | ENDM 132 | LDIR MACRO 133 | DB 0EDH,0B0H 134 | ENDM 135 | LDD MACRO 136 | DB 0EDH,0A8H 137 | ENDM 138 | LDDR MACRO 139 | DB 0EDH,0B8H 140 | ENDM 141 | CCI MACRO 142 | DB 0EDH,0A1H 143 | ENDM 144 | CCIR MACRO 145 | DB 0EDH,0B1H 146 | ENDM 147 | CCD MACRO 148 | DB 0EDH,0A9H 149 | ENDM 150 | CCDR MACRO 151 | DB 0EDH,0B9H 152 | ENDM 153 | 154 | ADDX MACRO ?D 155 | @CHK ?D 156 | DB 0DDH,86H,?D 157 | ENDM 158 | ADDY MACRO ?D 159 | @CHK ?D 160 | DB 0FDH,86H,?D 161 | ENDM 162 | ADCX MACRO ?D 163 | @CHK ?D 164 | DB 0DDH,8EH,?D 165 | ENDM 166 | ADCY MACRO ?D 167 | @CHK ?D 168 | DB 0FDH,8EH,?D 169 | ENDM 170 | SUBX MACRO ?D 171 | @CHK ?D 172 | DB 0DDH,96H,?D 173 | ENDM 174 | SUBY MACRO ?D 175 | @CHK ?D 176 | DB 0FDH,96H,?D 177 | ENDM 178 | SBCX MACRO ?D 179 | @CHK ?D 180 | DB 0DDH,9EH,?D 181 | ENDM 182 | SBBX MACRO ?D 183 | SBCX ?D 184 | ENDM 185 | SBCY MACRO ?D 186 | @CHK ?D 187 | DB 0FDH,9EH,?D 188 | ENDM 189 | SBBY MACRO ?D 190 | SBCY ?D 191 | ENDM 192 | ANDX MACRO ?D 193 | @CHK ?D 194 | DB 0DDH,0A6H,?D 195 | ENDM 196 | ANAX MACRO ?D 197 | ANDX ?D 198 | ENDM 199 | ANDY MACRO ?D 200 | @CHK ?D 201 | DB 0FDH,0A6H,?D 202 | ENDM 203 | ANAY MACRO ?D 204 | ANDY ?D 205 | ENDM 206 | XORX MACRO ?D 207 | @CHK ?D 208 | DB 0DDH,0AEH,?D 209 | ENDM 210 | XRAX MACRO ?D 211 | XORX ?D 212 | ENDM 213 | XORY MACRO ?D 214 | @CHK ?D 215 | DB 0FDH,0AEH,?D 216 | ENDM 217 | XRAY MACRO ?D 218 | XORY ?D 219 | ENDM 220 | ORX MACRO ?D 221 | @CHK ?D 222 | DB 0DDH,0B6H,?D 223 | ENDM 224 | ORAX MACRO ?D 225 | ORX ?D 226 | ENDM 227 | ORY MACRO ?D 228 | @CHK ?D 229 | DB 0FDH,0B6H,?D 230 | ENDM 231 | ORAY MACRO ?D 232 | ORY ?D 233 | ENDM 234 | CMPX MACRO ?D 235 | @CHK ?D 236 | DB 0DDH,0BEH,?D 237 | ENDM 238 | CMPY MACRO ?D 239 | @CHK ?D 240 | DB 0FDH,0BEH,?D 241 | ENDM 242 | INRX MACRO ?D 243 | @CHK ?D 244 | DB 0DDH,34H,?D 245 | ENDM 246 | INRY MACRO ?D 247 | @CHK ?D 248 | DB 0FDH,34H,?D 249 | ENDM 250 | DCRX MACRO ?D 251 | @CHK ?D 252 | DB 0DDH,035H,?D 253 | ENDM 254 | DCRY MACRO ?D 255 | @CHK ?D 256 | DB 0FDH,35H,?D 257 | ENDM 258 | 259 | NEG MACRO 260 | DB 0EDH,44H 261 | ENDM 262 | IM0 MACRO 263 | DB 0EDH,46H 264 | ENDM 265 | IM1 MACRO 266 | DB 0EDH,56H 267 | ENDM 268 | IM2 MACRO 269 | DB 0EDH,5EH 270 | ENDM 271 | 272 | 273 | BC EQU 0 274 | DE EQU 2 275 | HL EQU 4 276 | IX EQU 4 277 | IY EQU 4 278 | DADC MACRO ?R 279 | DB 0EDH,?R*8+4AH 280 | ENDM 281 | DSBC MACRO ?R 282 | DB 0EDH,?R*8+42H 283 | ENDM 284 | DADX MACRO ?R 285 | DB 0DDH,?R*8+09H 286 | ENDM 287 | DADY MACRO ?R 288 | DB 0FDH,?R*8+09H 289 | ENDM 290 | INXIX MACRO 291 | DB 0DDH,23H 292 | ENDM 293 | INXIY MACRO 294 | DB 0FDH,23H 295 | ENDM 296 | DCXIX MACRO 297 | DB 0DDH,2BH 298 | ENDM 299 | DCXIY MACRO 300 | DB 0FDH,2BH 301 | ENDM 302 | 303 | BIT MACRO ?N,?R 304 | DB 0CBH,?N*8+?R+40H 305 | ENDM 306 | SETB MACRO ?N,?R 307 | DB 0CBH,?N*8+?R+0C0H 308 | ENDM 309 | RES MACRO ?N,?R 310 | DB 0CBH,?N*8+?R+80H 311 | ENDM 312 | 313 | BITX MACRO ?N,?D 314 | @CHK ?D 315 | DB 0DDH,0CBH,?D,?N*8+46H 316 | ENDM 317 | BITY MACRO ?N,?D 318 | @CHK ?D 319 | DB 0FDH,0CBH,?D,?N*8+46H 320 | ENDM 321 | SETX MACRO ?N,?D 322 | @CHK ?D 323 | DB 0DDH,0CBH,?D,?N*8+0C6H 324 | ENDM 325 | SETY MACRO ?N,?D 326 | @CHK ?D 327 | DB 0FDH,0CBH,?D,?N*8+0C6H 328 | ENDM 329 | RESX MACRO ?N,?D 330 | @CHK ?D 331 | DB 0DDH,0CBH,?D,?N*8+86H 332 | ENDM 333 | RESY MACRO ?N,?D 334 | @CHK ?D 335 | DB 0FDH,0CBH,?D,?N*8+86H 336 | ENDM 337 | 338 | JR MACRO ?N 339 | @CHKR 18H,?N-$-1 340 | ENDM 341 | JRC MACRO ?N 342 | @CHKR 38H,?N-$-1 343 | ENDM 344 | JRNC MACRO ?N 345 | @CHKR 30H,?N-$-1 346 | ENDM 347 | JRZ MACRO ?N 348 | @CHKR 28H,?N-$-1 349 | ENDM 350 | JRNZ MACRO ?N 351 | @CHKR 20H,?N-$-1 352 | ENDM 353 | DJNZ MACRO ?N 354 | @CHKR 10H,?N-$-1 355 | ENDM 356 | 357 | PCIX MACRO 358 | DB 0DDH,0E9H 359 | ENDM 360 | PCIY MACRO 361 | DB 0FDH,0E9H 362 | ENDM 363 | 364 | RETI MACRO 365 | DB 0EDH,4DH 366 | ENDM 367 | RETN MACRO 368 | DB 0EDH,45H 369 | ENDM 370 | 371 | INP MACRO ?R 372 | DB 0EDH,?R*8+40H 373 | ENDM 374 | OUTP MACRO ?R 375 | DB 0EDH,?R*8+41H 376 | ENDM 377 | INI MACRO 378 | DB 0EDH,0A2H 379 | ENDM 380 | INIR MACRO 381 | DB 0EDH,0B2H 382 | ENDM 383 | IND MACRO 384 | DB 0EDH,0AAH 385 | ENDM 386 | INDR MACRO 387 | DB 0EDH,0BAH 388 | ENDM 389 | OUTI MACRO 390 | DB 0EDH,0A3H 391 | ENDM 392 | OUTIR MACRO 393 | DB 0EDH,0B3H 394 | ENDM 395 | OUTD MACRO 396 | DB 0EDH,0ABH 397 | ENDM 398 | OUTDR MACRO 399 | DB 0EDH,0BBH 400 | ENDM 401 | 402 | 403 | RLCR MACRO ?R 404 | DB 0CBH, 00H + ?R 405 | ENDM 406 | RLCX MACRO ?D 407 | @CHK ?D 408 | DB 0DDH, 0CBH, ?D, 06H 409 | ENDM 410 | RLCY MACRO ?D 411 | @CHK ?D 412 | DB 0FDH, 0CBH, ?D, 06H 413 | ENDM 414 | RALR MACRO ?R 415 | DB 0CBH, 10H+?R 416 | ENDM 417 | RALX MACRO ?D 418 | @CHK ?D 419 | DB 0DDH, 0CBH, ?D, 16H 420 | ENDM 421 | RALY MACRO ?D 422 | @CHK ?D 423 | DB 0FDH, 0CBH, ?D, 16H 424 | ENDM 425 | RRCR MACRO ?R 426 | DB 0CBH, 08H + ?R 427 | ENDM 428 | RRCX MACRO ?D 429 | @CHK ?D 430 | DB 0DDH, 0CBH, ?D, 0EH 431 | ENDM 432 | RRCY MACRO ?D 433 | @CHK ?D 434 | DB 0FDH, 0CBH, ?D, 0EH 435 | ENDM 436 | RARR MACRO ?R 437 | DB 0CBH, 18H + ?R 438 | ENDM 439 | RARX MACRO ?D 440 | @CHK ?D 441 | DB 0DDH, 0CBH, ?D, 1EH 442 | ENDM 443 | RARY MACRO ?D 444 | @CHK ?D 445 | DB 0FDH, 0CBH, ?D, 1EH 446 | ENDM 447 | SLAR MACRO ?R 448 | DB 0CBH, 20H + ?R 449 | ENDM 450 | SLAX MACRO ?D 451 | @CHK ?D 452 | DB 0DDH, 0CBH, ?D, 26H 453 | ENDM 454 | SLAY MACRO ?D 455 | @CHK ?D 456 | DB 0FDH, 0CBH, ?D, 26H 457 | ENDM 458 | SRAR MACRO ?R 459 | DB 0CBH, 28H+?R 460 | ENDM 461 | SRAX MACRO ?D 462 | @CHK ?D 463 | DB 0DDH, 0CBH, ?D, 2EH 464 | ENDM 465 | SRAY MACRO ?D 466 | @CHK ?D 467 | DB 0FDH, 0CBH, ?D, 2EH 468 | ENDM 469 | SRLR MACRO ?R 470 | DB 0CBH, 38H + ?R 471 | ENDM 472 | SRLX MACRO ?D 473 | @CHK ?D 474 | DB 0DDH, 0CBH, ?D, 3EH 475 | ENDM 476 | SRLY MACRO ?D 477 | @CHK ?D 478 | DB 0FDH, 0CBH, ?D, 3EH 479 | ENDM 480 | RLD MACRO 481 | DB 0EDH, 6FH 482 | ENDM 483 | RRD MACRO 484 | DB 0EDH, 67H 485 | ENDM 486 | OUTPF MACRO 487 | DB 0EDH, 71H 488 | ENDM 489 | INPF MACRO 490 | DB 0EDH, 70H 491 | ENDM 492 | -------------------------------------------------------------------------------- /tools/VirtualCpm.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/durgadas311/cpnet-z80/20e06f4badb7dda7af6c7102dab0e91611056da7/tools/VirtualCpm.jar -------------------------------------------------------------------------------- /tools/vcpm: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Customize for path where JAR exists 3 | JAR=/path/to/cpnet-z80/tools/VirtualCpm.jar 4 | 5 | java -jar ${JAR} "${@}" 6 | -------------------------------------------------------------------------------- /tools/vcpmrc: -------------------------------------------------------------------------------- 1 | # Config file for 'vcpm' i.e. VirtualCpm.jar 2 | # 3 | # set top-level directory, uncomment property: 4 | #vcpm_root_dir = /path/to/VCPM 5 | 6 | # CP/M drive search order 7 | vcpm_dso = def,a:,b,c 8 | 9 | # eliminate extraneous output 10 | silent 11 | -------------------------------------------------------------------------------- /util/nvram.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Layout of NVRAM block used to store CP/NET configuration. 3 | */ 4 | 5 | /* 6 | * Unused bytes should be initialized to 0xff 7 | * (buffer is initially set to all 0xff). 8 | * 9 | * NOTE: Erased FLASH memory is 0xff, FRAM ships as 0x00. 10 | */ 11 | 12 | struct wizsok { 13 | uchar _resv1[4]; 14 | uchar cpnet; // Sn_PORT0: 0x31 if configured for CP/NET 15 | uchar sid; // Sn_PORT1: CP/NET server node ID 16 | uchar _resv2[6]; 17 | uchar dipr[4]; // destination (server) IP address 18 | uchar dport[2]; // destination (server) port 19 | uchar _resv3[11]; 20 | uchar kpalvtr; // moved to Sn_KPALVTR in W5500 21 | uchar _resv4[2]; 22 | }; 23 | 24 | struct wizcfg { 25 | uchar _resv1; 26 | uchar gar[4]; // gateway IP address 27 | uchar subr[4]; // subnet mask 28 | uchar shar[6]; // MAC address 29 | uchar sipr[4]; // client IP address 30 | uchar _resv2[10]; 31 | uchar pmagic; // client CP/NET node ID 32 | uchar port[2]; // server listening port 33 | 34 | struct wizsok sockets[8]; 35 | 36 | uchar cfgtbl[38]; // CP/NET config table template 37 | 38 | uchar _resv4[182]; // for expansion 39 | uchar chksum[4]; // 32-bit sum of first 508 bytes, little-endian 40 | }; 41 | 42 | /* sizeof(struct wizcfg) == 512 */ 43 | /* sizeof(struct wizsok) == 32 */ 44 | -------------------------------------------------------------------------------- /util/wizcfg.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | typedef unsigned char uchar; 9 | #include "nvram.h" 10 | 11 | static uchar nvbuf[512]; 12 | 13 | static int nvget(char *img) { 14 | int fd; 15 | int x; 16 | fd = open(img, O_RDONLY); 17 | if (fd < 0) return -1; 18 | x = read(fd, nvbuf, sizeof(nvbuf)); 19 | close(fd); 20 | if (x < 0) return -1; 21 | return 0; 22 | } 23 | 24 | static int nvset(char *img) { 25 | int fd; 26 | int x, y; 27 | fd = open(img, O_WRONLY | O_CREAT, 0666); 28 | if (fd < 0) return -1; 29 | x = write(fd, nvbuf, sizeof(nvbuf)); 30 | y = close(fd); 31 | if (x < 0 || y < 0) return -1; 32 | return 0; 33 | } 34 | 35 | static int checksum(struct wizcfg *cfg) { 36 | uchar *buf = (uchar *)cfg; 37 | long cs = 0; // must be >= 32 bits! 38 | long bcs; // ('') 39 | int x; 40 | bcs = cfg->chksum[0] | (cfg->chksum[1] << 8) | 41 | (cfg->chksum[2] << 16) | (cfg->chksum[3] << 24); 42 | for (x = 0; x < sizeof(*cfg) - sizeof(cfg->chksum); ++x) { 43 | cs += buf[x]; 44 | } 45 | return (cs == bcs); 46 | } 47 | 48 | static void setchksum(struct wizcfg *cfg) { 49 | uchar *buf = (uchar *)cfg; 50 | long cs = 0; // must be >= 32 bits! 51 | int x; 52 | for (x = 0; x < sizeof(*cfg) - sizeof(cfg->chksum); ++x) { 53 | cs += buf[x]; 54 | } 55 | cfg->chksum[0] = cs & 0xff; 56 | cfg->chksum[1] = (cs >> 8) & 0xff; 57 | cfg->chksum[2] = (cs >> 16) & 0xff; 58 | cfg->chksum[3] = (cs >> 24) & 0xff; 59 | } 60 | 61 | static void help(char *arg0) { 62 | fprintf(stderr, "WIZCFG for NVRAM images, v1.0\n"); 63 | fprintf(stderr, "Usage: %s [options] nvram-img\n" 64 | "Options:\n" 65 | " -n CID Client node ID\n" 66 | " -i IP Client IP addr\n" 67 | " -g GW Gateway IP addr\n" 68 | " -s MS Subnet mask\n" 69 | " -m MA MAC address\n" 70 | " -p PT Server port\n" 71 | " -# SID,IP,PT[,KP] Socket # (0-7) definition\n" 72 | " -x # Socket # (0-7) deletion\n" 73 | , arg0); 74 | } 75 | 76 | static void show(struct wizcfg *cfg) { 77 | int ns; 78 | int x; 79 | struct wizsok *sok; 80 | 81 | printf("Node ID: %02XH\n", cfg->pmagic); 82 | printf("IP Addr: %d.%d.%d.%d\n", 83 | cfg->sipr[0], cfg->sipr[1], cfg->sipr[2], cfg->sipr[3]); 84 | printf("Gateway: %d.%d.%d.%d\n", 85 | cfg->gar[0], cfg->gar[1], cfg->gar[2], cfg->gar[3]); 86 | printf("Subnet: %d.%d.%d.%d\n", 87 | cfg->subr[0], cfg->subr[1], cfg->subr[2], cfg->subr[3]); 88 | printf("MAC: %02X:%02X:%02X:%02X:%02X:%02X\n", 89 | cfg->shar[0], cfg->shar[1], cfg->shar[2], 90 | cfg->shar[3], cfg->shar[4], cfg->shar[5]); 91 | ns = (cfg->port[0] << 8) | cfg->port[1]; 92 | if (ns != 0 && ns != 0xffff) { 93 | printf("Srv Port: %d\n", ns); 94 | } 95 | ns = 0; 96 | for (x = 0; x < 8; ++x) { 97 | sok = &cfg->sockets[x]; 98 | if (sok->cpnet != 0x31) continue; 99 | ++ns; 100 | printf("Socket %d: %02XH %d.%d.%d.%d %d %d\n", x, 101 | sok->sid, 102 | sok->dipr[0], sok->dipr[1], sok->dipr[2], sok->dipr[3], 103 | (sok->dport[0] << 8) | sok->dport[1], 104 | sok->kpalvtr * 5); 105 | } 106 | if (!ns) { 107 | printf("No Sockets Configured\n"); 108 | } 109 | } 110 | 111 | int parse_nid(uchar *out, char *str) { 112 | unsigned int b0; 113 | if (!str) return 0; 114 | if (sscanf(str, "%x", &b0) != 1) { 115 | return -1; 116 | } 117 | if (b0 > 255) { 118 | return -2; 119 | } 120 | out[0] = b0; 121 | return 0; 122 | } 123 | 124 | int parse_ip(uchar *out, char *str) { 125 | unsigned int b0, b1, b2, b3; 126 | if (!str) return 0; 127 | if (sscanf(str, "%u.%u.%u.%u", &b0, &b1, &b2, &b3) != 4) { 128 | return -1; 129 | } 130 | if (b0 > 255 || b1 > 255 || b2 > 255 || b3 > 255) { 131 | return -2; 132 | } 133 | out[0] = b0; 134 | out[1] = b1; 135 | out[2] = b2; 136 | out[3] = b3; 137 | return 0; 138 | } 139 | 140 | int parse_mac(uchar *out, char *str) { 141 | unsigned int b0, b1, b2, b3, b4, b5; 142 | if (!str) return 0; 143 | if (sscanf(str, "%x:%x:%x:%x:%x:%x", &b0, &b1, &b2, &b3, &b4, &b5) != 6) { 144 | return -1; 145 | } 146 | if (b0 > 255 || b1 > 255 || b2 > 255 || b3 > 255 || b4 > 255 || b5 > 255) { 147 | return -2; 148 | } 149 | out[0] = b0; 150 | out[1] = b1; 151 | out[2] = b2; 152 | out[3] = b3; 153 | out[4] = b4; 154 | out[5] = b5; 155 | return 0; 156 | } 157 | 158 | int parse_port(uchar *out, char *str) { 159 | unsigned int b0; 160 | if (!str) return 0; 161 | if (sscanf(str, "%u", &b0) != 1) { 162 | return -1; 163 | } 164 | if (b0 > 65535) { 165 | return -2; 166 | } 167 | out[0] = (b0 >> 8) & 0xff; 168 | out[1] = b0 & 0xff; 169 | return 0; 170 | } 171 | 172 | int parse_keep(uchar *out, char *str) { 173 | unsigned int b0; 174 | if (!str) return 0; 175 | if (sscanf(str, "%u", &b0) != 1) { 176 | return -1; 177 | } 178 | b0 = (b0 + 4) / 5; 179 | if (b0 > 255) { 180 | return -2; 181 | } 182 | out[0] = b0 & 0xff; 183 | return 0; 184 | } 185 | 186 | static int parse_sok(struct wizsok *sok, char *str) { 187 | char *s0, *s1, *s2, *s3; 188 | if (str == NULL) return 0; 189 | if (str == (char *)-1) { 190 | sok->cpnet = 0xff; 191 | return 0; 192 | } 193 | s0 = strtok(str, ","); 194 | s1 = strtok(NULL, ","); 195 | s2 = strtok(NULL, ","); 196 | s3 = strtok(NULL, ","); 197 | if (s0 == NULL || s1 == NULL || s2 == NULL) { 198 | return -1; 199 | } 200 | if (parse_nid(&sok->sid, s0) < 0) return -1; 201 | if (parse_ip(sok->dipr, s1) < 0) return -1; 202 | if (parse_port(sok->dport, s2) < 0) return -1; 203 | if (parse_keep(&sok->kpalvtr, s3) < 0) return -1; 204 | sok->cpnet = 0x31; 205 | return 0; 206 | } 207 | 208 | static char *cid = NULL; 209 | static char *sipr = NULL; 210 | static char *gar = NULL; 211 | static char *subr = NULL; 212 | static char *shar = NULL; 213 | static char *lport = NULL; 214 | static char *soks[8] = { NULL }; 215 | 216 | int parse(struct wizcfg *cfg) { 217 | int x; 218 | if (parse_nid(&cfg->pmagic, cid) < 0) return -1; 219 | if (parse_ip(cfg->sipr, sipr) < 0) return -1; 220 | if (parse_ip(cfg->subr, subr) < 0) return -1; 221 | if (parse_ip(cfg->gar, gar) < 0) return -1; 222 | if (parse_mac(cfg->shar, shar) < 0) return -1; 223 | if (parse_port(cfg->port, lport) < 0) return -1; 224 | for (x = 0; x < 8; ++x) { 225 | if (parse_sok(&cfg->sockets[x], soks[x]) < 0) return -1; 226 | } 227 | } 228 | 229 | int main(int argc, char **argv) { 230 | int fd; 231 | int x; 232 | int ns; 233 | int set = 0; 234 | int new = 0; 235 | int verbose = 0; 236 | char *img; 237 | struct wizcfg *cfg; 238 | struct wizsok *sok; 239 | 240 | extern char *optarg; 241 | extern int optind; 242 | 243 | while ((x = getopt(argc, argv, "n:i:g:s:m:p:0:1:2:3:4:5:6:7:vx:")) != EOF) { 244 | switch (x) { 245 | case 'n': 246 | cid = optarg; 247 | ++set; 248 | break; 249 | case 'i': 250 | sipr = optarg; 251 | ++set; 252 | break; 253 | case 'g': 254 | gar = optarg; 255 | ++set; 256 | break; 257 | case 's': 258 | subr = optarg; 259 | ++set; 260 | break; 261 | case 'm': 262 | shar = optarg; 263 | ++set; 264 | break; 265 | case 'p': 266 | lport = optarg; 267 | ++set; 268 | break; 269 | case '0': 270 | case '1': 271 | case '2': 272 | case '3': 273 | case '4': 274 | case '5': 275 | case '6': 276 | case '7': 277 | soks[x - '0'] = optarg; 278 | ++set; 279 | break; 280 | case 'v': 281 | ++verbose; 282 | break; 283 | case 'x': 284 | if (*optarg < '0' || *optarg > '7') { 285 | goto error; 286 | } 287 | soks[*optarg - '0'] = (char *)-1; 288 | ++set; 289 | break; 290 | default: 291 | error: 292 | help(argv[0]); 293 | return 1; 294 | } 295 | } 296 | if (optind >= argc) { 297 | help(argv[0]); 298 | return 1; 299 | } 300 | img = argv[optind]; 301 | if (nvget(img) < 0) { 302 | if (set) { 303 | printf("Initializing new NVRAM block\n"); 304 | memset(nvbuf, 0xff, sizeof(nvbuf)); 305 | ++new; 306 | } else { 307 | perror(img); 308 | return 1; 309 | } 310 | } 311 | cfg = (struct wizcfg *)nvbuf; 312 | if (!new && !checksum(cfg)) { 313 | printf("NVRAM block not initialized\n"); 314 | return 1; 315 | } 316 | if (!set) { 317 | show(cfg); 318 | return 0; 319 | } 320 | if (parse(cfg) < 0) { 321 | fprintf(stderr, "Syntax error\n"); 322 | return 1; 323 | } 324 | if (verbose) { 325 | show(cfg); 326 | } 327 | setchksum(cfg); 328 | if (nvset(img) < 0) { 329 | perror(img); 330 | return 1; 331 | } 332 | return 0; 333 | } 334 | --------------------------------------------------------------------------------