11 Target Environment
The original GEOS SDK used two PCs: the development machine ran the tools and Swat, the target machine ran GEOS, and both were connected by a serial cable (see System Configuration). Today the target runs in an emulator on the development machine. The target script in %ROOT_DIR%/bin starts the emulator with the composed target environment and attaches Swat to it.
Two emulators can be used as target host:
DOSBox or basebox (default). basebox is the DOSBox variant made for PC/GEOS (pcgeos-basebox). The target directory is mounted as drive C:, and Swat is connected over emulated IPX networking.
86Box (optional). 86Box emulates real PC hardware (BIOS, chipset, serial ports, video cards), from a 286 up to a Pentium. The target is put on a bootable FreeDOS hard disk image, and Swat is connected over the emulated serial port with the serial Swat stub.
Both use the same target environment, built with buildbbx (see the README of the repository). If you build both the EC and the NC target, target starts the EC target and target -n the NC target.
11.1 DOSBox and basebox
11.1.1 Setup
DOSBox is used if it is on the executable path. To use basebox instead, set BASEBOX to basebox if it is on the executable path, or to the full path of the basebox executable:
set BASEBOX=basebox
The settings of the emulated PC are in %ROOT_DIR%/bin/basebox.conf.
11.1.2 Starting the Target
%ROOT_DIR%/bin/targetlaunches the EC (“debug”) version,target -nthe NC version.- Swat stops immediately after the first stage of the boot process.
- Enter
quitat the “=>” prompt to detach the debugger and launch PC/GEOS stand-alone, or entercto launch with the debugger running in the background (slower).
On Linux, install the xdotool package; it makes sure Swat gets the keyboard focus when needed.
11.1.3 Customizing the Target Environment
To customize the settings of the emulated PC only for yourself, do not change %ROOT_DIR%/bin/basebox.conf. Instead:
- Create a file called
basebox_user.confin the%LOCAL_ROOT%folder. - Enter the new settings there. They override those of
basebox.conf. Example:
[cpu]
cycles=55000
Further environment variables used by target:
GEOS_CDROM_DRIVE: a CD-ROM drive or an ISO image, mounted as drive R:.GEOS_CENTRAL_STORAGE: a directory mounted as drive S:.
11.2 86Box
With 86Box, the composed target is copied to a bootable FreeDOS hard disk image. 86Box boots it, FreeDOS starts the target under the serial Swat stub, and Swat connects over the emulated serial port COM1:
- Windows: COM1 is a named pipe; Swat connects with
-serialpipe. - Linux: COM1 is a pseudo terminal that 86Box forwards to a local TCP port with socat; Swat connects to that port.
11.2.1 Requirements
- 86Box 6.0 or newer with its ROM set. Put the ROMs into the
romsfolder next to the 86Box executable, or setBOX86_ROMSto the ROM directory.targetchecks that the ROMs of the selected machine are present. - Linux:
socat. - The SDK tools (including
img86boxand Swat), the target components (including the serial Swat stub) and the target environment are built. - FreeDOS. By default it is downloaded on first use: FreeDOS 1.4 LiteUSB, the 8086 FreeDOS kernel and FreeCOM, as listed in
%ROOT_DIR%/bin/86box/freedos.manifest. The files are fetched over HTTPS and checked against their SHA-256 before use. Alternatively setFREEDOS_IMGto a bootable FreeDOS hard disk image of your own. Drivers that the image only carries as packages (CuteMouse, HIMEMX, FDXMS286, CD-ROM drivers) are unpacked automatically. Drivers that FreeDOS does not include (the EMS driver LTEMM and the Crynwr packet drivers NE1000 and NE2000) are downloaded the same way, from fixed versions listed in the manifest. Files in a directory given byFREEDOS_SYSDIRtake precedence (for example a different kernel or driver).
11.2.2 Setup and Activation
- Set
USE_86BOXto the full path of the 86Box executable, likeBASEBOXfor basebox. A value like1uses 86Box from the executable path. Examples:
set USE_86BOX=C:\86Box\86Box.exe
export USE_86BOX=$HOME/86Box/86Box.AppImage
- Optionally select the emulated machine with
TARGET_PLATFORM(see below; defaultpm32). - Build the target environment as usual with
buildbbx. WithUSE_86BOXset, the build also creates or updates the disk image. %ROOT_DIR%/bin/target(ortarget -n) updates the disk image, starts 86Box and then Swat. Swat waits until GEOS has booted on the emulated PC.- To switch back to DOSBox/basebox, clear
USE_86BOX(set USE_86BOX=).
11.2.3 Emulated Machines
TARGET_PLATFORM selects the emulated machine:
| pm32 (default) | pm16 | rm16 | |
|---|---|---|---|
| Purpose | 32 bit protected mode | 16 bit protected mode | real mode, pure 16 bit |
| CPU, RAM | Pentium 100, 32 MB | 286 at 12.5 MHz, 8 MB | 8086 at 12 MHz, 640 KB |
| Board | ASUS P/I-P55TP4XE (Award BIOS) | Hyundai Solomon 286KP (SCAT, Award BIOS) | Compaq Deskpro |
| Hard disk | on-board IDE | on-board IDE | XT-IDE with XTIDE Universal BIOS |
| Video | S3 Trio64 PCI | Cirrus Logic GD5428 ISA | Tseng ET4000AX (8 bit ISA) |
| Extra memory | XMS (HIMEMX) | XMS (FDXMS286) | 2 MB EMS (Lo-tech EMS board, LTEMM) |
| Mouse | PS/2, CuteMouse | serial on COM2, CuteMouse | serial on COM2, GEOS serial mouse driver |
| Network | NE2000, I/O 340h, IRQ 5 | NE2000, I/O 340h, IRQ 5 | NE1000 (8 bit), I/O 340h, IRQ 2 |
| Swat link | COM1, 115200 baud | COM1, 57600 baud | COM1, 38400 baud |
Notes on the machines:
- The 286 and 8086 machines need a FreeDOS image whose MBR and boot code run on these CPUs (a FAT16 partition and the MBR of FreeDOS FDISK, as in FreeDOS 1.4 LiteUSB). The downloaded kernel is the 8086 build, which runs on all machines.
pm16uses FDXMS286, the FreeDOS XMS driver for 286 machines, as HIMEMX needs a 386. The SCAT chipset of the board keeps 2 MB of the RAM as chipset EMS by default (BIOS setup, “EMS MEMORY”); set it to 0 there to get all of it as XMS.rm16uses a real 8086, so that 186 and 286 instructions are caught. For more speed, a NEC V30 at 16 MHz can be used instead (cpu_family = necv30andcpu_speed = 16000000in the[Machine]section of%LOCAL_ROOT%/86box_user.rm16.cfg). The EMS board is driven by LTEMM (page frame E000h, I/O 260h). CuteMouse needs a 286, so the mouse is driven by the GEOS serial mouse driver (msser) directly; the [mouse] settings of the target’s NET.INI are changed for this on the disk image.- All machines have a network card with a Crynwr packet driver on software interrupt 60h, loaded from AUTOEXEC.BAT. 86Box connects it to the host network through its built-in NAT (SLiRP): the emulated PC gets its address by DHCP (10.0.2.15, gateway 10.0.2.2) and can reach the host and the internet, but cannot be reached from outside. Other 86Box network types (e.g. pcap) can be set in the
[Network]section of the personal settings.
11.2.4 First Start of a New Machine
pm32: the BIOS reports a CMOS checksum error once; press F1. 86Box keeps the settings.pm16: the Award 286 BIOS cannot detect hard disks and reports a CMOS error. Enter the BIOS setup with Ctrl-Alt-Esc, set Disk 1 to type 49 with the cylinders printed bytarget(“image geometry”), 16 heads and 63 sectors, then save with F10 and F5. If the BIOS then reports a memory size error, enter the setup once more and save again (F10, F5); the setup takes over the detected memory sizes.rm16: nothing to do; the XTIDE Universal BIOS detects the disk.
11.2.5 Settings
Environment variables:
USE_86BOX: full path of the 86Box executable. If it is set,buildbbxandtargetuse 86Box; if it is empty, DOSBox/basebox is used.TARGET_PLATFORM: emulated machine,pm32(default),pm16orrm16.BOX86_ROMS: 86Box ROM directory.BOX86_PORT: TCP port of the serial link on Linux (default 8079).BOX86_NOSWAT=1:targetstarts 86Box only, without Swat.BOX86_KEEP_CFG=1: keep the existing 86Box configuration instead of regenerating it (for example while trying settings in the 86Box GUI).SWAT_ATTACH_WAIT: how long Swat waits for GEOS to come up on the emulated PC, in seconds (default 180).FREEDOS_IMG,FREEDOS_SYSDIR: FreeDOS image and files to use instead of the download (see above).GEOS_IMG_SIZE: size of a new disk image in MB (default 256, at most 504).GEOS_CDROM_DRIVE: an ISO image, attached as CD-ROM (drive R: in DOS).GEOS_CENTRAL_STORAGEis only supported with DOSBox/basebox.
The configuration of the emulated PC is generated from layers on every start of target:
%ROOT_DIR%/bin/86box/base.cfg: common settings%ROOT_DIR%/bin/86box/platform/<platform>.cfg: the machine%ROOT_DIR%/bin/86box/serial-win32.cfgorserial-linux.cfg: the serial link%ROOT_DIR%/bin/86box/cdrom.cfg: only with an ISO inGEOS_CDROM_DRIVE%LOCAL_ROOT%/86box_user.cfg: optional personal settings for all machines%LOCAL_ROOT%/86box_user.<platform>.cfg: optional personal settings for one machine
Later layers override single keys of earlier ones. Personal settings use the configuration file format of 86Box. The [img86box] section of these files changes the disk image settings (image size, baud rate, XMS driver, mouse options, GEOS ini settings, further DOS drivers; see base.cfg). For example, device = FILE ARGS adds a DEVICE= line to CONFIG.SYS and load = FILE ARGS a program to AUTOEXEC.BAT (both may be given several times); FILE is looked up like the FreeDOS files. Do not change the files in %ROOT_DIR%/bin/86box for personal settings.
11.2.6 How It Works
- Disk image.
buildbbx(withUSE_86BOXset) andtargetcreate or update the disk image with theimg86boxtool. The image has 16 heads, 63 sectors per track and at most 504 MB, so it boots on every emulated machine without BIOS translation. Updates are done in place: new and changed files of the target are copied; files removed from the target are deleted inENSEMBLE\SYSTEM,ENSEMBLE\WORLDandENSEMBLE\FREEGEOSonly, so data written inside the emulator (ini changes, documents, state files) is kept. The IPX Swat stub of the target is replaced by the serial Swat stub. Files without a DOS 8.3 name are skipped with a warning.perl %ROOT_DIR%/bin/box86.pl image --fresh(add-nfor the NC target) recreates the image. - Boot. The image boots FreeDOS, loads CuteMouse (the target’s mouse driver uses it), and starts the target with
ENSEMBLE\SETUP.BATandSS.BAT.CONFIG.SYSandAUTOEXEC.BATare generated on every update. - Start.
targetwrites the 86Box configuration, starts 86Box and then Swat. Swat waits for the emulated PC (up to a minute for the connection,SWAT_ATTACH_WAITfor GEOS).
11.2.7 Files
%ROOT_DIR%/bin/86box/
Configuration layers and freedos.manifest (versioned defaults).
**%LOCAL_ROOT%/86box_user.cfg, %LOCAL_ROOT%/86box_user.
**%LOCAL_ROOT%/86box/
86box.cfg: the generated configurationnvr/: the BIOS settings (written by 86Box)geos.img: the disk imagebox86.log: the messages of the lasttargetstart86box.log: the log of 86Box, if it writes one
Deleting the directory resets the machine; the next build or start creates it again.
%LOCAL_ROOT%/86box/freedos/
Downloaded FreeDOS files and drivers (cache). A freedos.manifest in this directory overrides entries of the one in %ROOT_DIR%/bin/86box.
11.2.8 Troubleshooting
- Swat clears the console when it starts. The messages of
targetare kept inbox86.login the machine directory. - Set
BOX86_NOSWAT=1to start the machine without Swat and check what it does. Attach Swat later by hand withswat -serialpipe \\.\pipe\geosswat-<platform>-<ec|nec>(Windows) orswat(Linux; it connects to 127.0.0.1:8079, seeSWAT_SERIAL_TCPin Swat Introduction). - After updating the sources, rebuild the SDK tools (
pmake installin%ROOT_DIR%/Installed/Tools), so thatimg86boxand Swat matchbin/box86.pl. - A 286 or 8086 machine that hangs right after the BIOS has a FreeDOS image whose MBR or boot code needs a 386 (see 11.2.3).
- “Invalid Opcode” while DOS starts on
rm16means a DOS program for 286 or later was loaded, for example CuteMouse. - If PC/GEOS has no mouse, CuteMouse was not found: put
CTMOUSE.EXEinto theFREEDOS_SYSDIRdirectory.