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/target launches the EC (“debug”) version, target -n the NC version.
  • Swat stops immediately after the first stage of the boot process.
  • Enter quit at the “=>” prompt to detach the debugger and launch PC/GEOS stand-alone, or enter c to 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.conf in 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 roms folder next to the 86Box executable, or set BOX86_ROMS to the ROM directory. target checks that the ROMs of the selected machine are present.
  • Linux: socat.
  • The SDK tools (including img86box and 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 set FREEDOS_IMG to 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 by FREEDOS_SYSDIR take precedence (for example a different kernel or driver).

11.2.2 Setup and Activation

  • Set USE_86BOX to the full path of the 86Box executable, like BASEBOX for basebox. A value like 1 uses 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; default pm32).
  • Build the target environment as usual with buildbbx. With USE_86BOX set, the build also creates or updates the disk image.
  • %ROOT_DIR%/bin/target (or target -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)pm16rm16
Purpose32 bit protected mode16 bit protected modereal mode, pure 16 bit
CPU, RAMPentium 100, 32 MB286 at 12.5 MHz, 8 MB8086 at 12 MHz, 640 KB
BoardASUS P/I-P55TP4XE (Award BIOS)Hyundai Solomon 286KP (SCAT, Award BIOS)Compaq Deskpro
Hard diskon-board IDEon-board IDEXT-IDE with XTIDE Universal BIOS
VideoS3 Trio64 PCICirrus Logic GD5428 ISATseng ET4000AX (8 bit ISA)
Extra memoryXMS (HIMEMX)XMS (FDXMS286)2 MB EMS (Lo-tech EMS board, LTEMM)
MousePS/2, CuteMouseserial on COM2, CuteMouseserial on COM2, GEOS serial mouse driver
NetworkNE2000, I/O 340h, IRQ 5NE2000, I/O 340h, IRQ 5NE1000 (8 bit), I/O 340h, IRQ 2
Swat linkCOM1, 115200 baudCOM1, 57600 baudCOM1, 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.
  • pm16 uses 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.
  • rm16 uses 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 = necv30 and cpu_speed = 16000000 in 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 by target (“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, buildbbx and target use 86Box; if it is empty, DOSBox/basebox is used.
  • TARGET_PLATFORM: emulated machine, pm32 (default), pm16 or rm16.
  • BOX86_ROMS: 86Box ROM directory.
  • BOX86_PORT: TCP port of the serial link on Linux (default 8079).
  • BOX86_NOSWAT=1: target starts 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_STORAGE is only supported with DOSBox/basebox.

The configuration of the emulated PC is generated from layers on every start of target:

  1. %ROOT_DIR%/bin/86box/base.cfg: common settings
  2. %ROOT_DIR%/bin/86box/platform/<platform>.cfg: the machine
  3. %ROOT_DIR%/bin/86box/serial-win32.cfg or serial-linux.cfg: the serial link
  4. %ROOT_DIR%/bin/86box/cdrom.cfg: only with an ISO in GEOS_CDROM_DRIVE
  5. %LOCAL_ROOT%/86box_user.cfg: optional personal settings for all machines
  6. %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 (with USE_86BOX set) and target create or update the disk image with the img86box tool. 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 in ENSEMBLE\SYSTEM, ENSEMBLE\WORLD and ENSEMBLE\FREEGEOS only, 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 -n for 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.BAT and SS.BAT. CONFIG.SYS and AUTOEXEC.BAT are generated on every update.
  • Start. target writes the 86Box configuration, starts 86Box and then Swat. Swat waits for the emulated PC (up to a minute for the connection, SWAT_ATTACH_WAIT for 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..cfg** Optional personal settings.

**%LOCAL_ROOT%/86box/.<ec|nec>/** One machine per platform and build type:

  • 86box.cfg: the generated configuration
  • nvr/: the BIOS settings (written by 86Box)
  • geos.img: the disk image
  • box86.log: the messages of the last target start
  • 86box.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 target are kept in box86.log in the machine directory.
  • Set BOX86_NOSWAT=1 to start the machine without Swat and check what it does. Attach Swat later by hand with swat -serialpipe \\.\pipe\geosswat-<platform>-<ec|nec> (Windows) or swat (Linux; it connects to 127.0.0.1:8079, see SWAT_SERIAL_TCP in Swat Introduction).
  • After updating the sources, rebuild the SDK tools (pmake install in %ROOT_DIR%/Installed/Tools), so that img86box and Swat match bin/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 rm16 means a DOS program for 286 or later was loaded, for example CuteMouse.
  • If PC/GEOS has no mouse, CuteMouse was not found: put CTMOUSE.EXE into the FREEDOS_SYSDIR directory.

Using Tools <–    Table of Contents