Skip to content

Serial Protocol

CoPokBl edited this page Feb 8, 2026 · 2 revisions

This is WIP, this has not yet been implemented.

There are two types of serial instructions, in and out. You specify a port and then get or receive data from that port. In the VM, virtual 'hardware' can register itself as a serial device, this allows applications to interact with a wide variety of things using one simple protocol.

Ports

A port number is a uint (4 bytes) and therefore has too many different values for applications to scan. So here is how ports should be mapped:

  • The first 16 (0x00-0x0F) ports are dedicated to specific types of hardware.
  • The rest of the ports (0x10+) are for generic hardware to bind to and should be bound in order so that software can simply stop scanning as soon as it finds an unused port.
Port Hardware Type
0x0 Input Device
0x1 Sound Device
0x2 Storage Device
0x3-0xF Reserved
0x10+ Any

Discovery

In order to make it easy for software to determinate whether a device exists or what it does serial devices should follow this simple protocol.

  • Software sends 0 (capabilities request) to hardware
  • Hardware should respond with an ID representing what it does the next time in is called (see the hardware types table below)
Hardware Type ID
Input Device 0
Sound Device 1
Storage Device 2

If hardware does one of the above functions then it should implement the relevant protocol defined in this document and return the relevant ID when queried.

When implementing hardware that follows its own protocol, please generate a random uint and always return that to avoid collisions with others and avoid confusion.

Protocols

Input Protocol

Clone this wiki locally