Skip to content
andyleap edited this page Dec 2, 2016 · 3 revisions

GEMU Protocol

Overview

The GEMU server consists of a collection of device trees. Each device tree is rooted by the cpu core, and consists of all the devices connected to that cpu core. Devices range from simple clocks and floppy drives up to complex radio communication systems.

Protocol

Each packet will consist of a header, followed by a message. The header will specify the device tree that the packet is for, with the device tree ID 0 specifing a packet for the server itself(in most cases this will be for creating a new device tree). The Device ID will be unique to the device tree. Any responses to a packet will contain a matching TXID, to allow easier matching of request/response pairs.

Device Tree ID Device ID Packet Type Packet TX ID Packet Length Packet Data
uint32 uint16 uint16 uint16 uint16 uint8[n]

Packet Types

Class List

The client sends a request for the class list to the server. This request must be sent to device tree 0.

Request Response
0x0001 0x8001
Request

No packet body

Response
struct {
	ClassID uint32
    Name 	string
    Desc 	string
}[n]

Create DT

The client sends a request for the creation of a device tree, which includes the specification of a CPU and any parameters associated with it. This request must be sent to device tree 0.

Request Response
0x0101 0x8101
Request
ClassID 	uint32
Parameters
Response
DeviceTreeID 	uint32
Error 			uint32

Delete DT

The client sends a request to delete a device tree. The device tree is NOT serialized to persistent storage, and is immediately irretrievable. This request is sent to the device to be deleted

Request Response
0x0102 0x8102
Request

No packet body

Response
Error uint32

Attach DT Device

The client sends a request to attach a device to the device tree. The created device is attached to the specific device that this request was directed to. To attach to the main root of the tree, send the request to device ID 0. The device is inserted at the requested location, pushing the item at that location towards higher indices. A Where value of 0xFFFF indicates to insert the item at the end of the list.

Request Response
0x0103 0x8103
Request
ClassID 	uint32
Where 	 	uint16
Parameters
Response
ClassID		uint32
DeviceID 	uint16
Error 		uint32

Remove DT Device

The client sends a request to remove a device from the device tree.

Request Response
0x0104 0x8104
Request

No packet body

Response
Error uint32

Start DT

The client sends a request to start a device tree. This does not imply resetting the device tree, merely starting the processor ticking and similar tasks.

Request Response
0x0105 0x8105
Request

No packet body

Response
Error uint32

Stop DT

The client sends a request to stop a device tree.

Request Response
0x0106 0x8106
Request

No packet body

Response
Error uint32

Reset DT

The client sends a request to reset a device tree. This causes all devices attached to the tree to be reset as well

Request Response
0x0107 0x8107
Request

No packet body

Response
Error uint32

List DT

The client sends a request to list a device tree. This returns all the devices in the tree.

Request Response
0x0108 0x8108
Request

No packet body

Response
struct Device {
    ID uint16
    Class uint32
    ChildCount uint16
    Children [uint16]Device
}

Send Device Message

This packet sends a message to a specific device. It can be sent in either direction, to allow events to pass to or from the emulated device. The exact details of this message depend on the device the message is sent to. Examples include key presses for a keyboard and similar. This packet does not follow a "request/response" pattern.

Packet Type
0x0110

Request StateSync

The client sends a request to start recieving StateSync updates for a specific device tree node over this connection. Note: StateSync is automatically registered for the connection that creates a device. This packet does not follow a "request/response" pattern.

Packet Type
0x0120
Request

No packet body

Request MemSync

The client sends a request to start recieving MemSync updates for a specific device tree node over this connection. This packet does not follow a "request/response" pattern.

Packet Type
0x0121
Request

No packet body

Cancel StateSync

The client sends a request to stop recieving StateSync updates for a specific device tree node over this connection. This packet does not follow a "request/response" pattern.

Packet Type
0x0122
Request

No packet body

Cancel MemSync

The client sends a request to stop recieving MemSync updates for a specific device tree node over this connection. This packet does not follow a "request/response" pattern.

Packet Type
0x0123
Request

No packet body

StateSync

This packet is sent when an update to the state of a device is performed. It can be sent in either direction, to allow updates to pass to or from the emulated device, though typically they will pass from the emulator to the client. The exact details of this message depend on the device the message is sent to. Examples include memory base pointers for LEM displays. This packet does not follow a "request/response" pattern.

Packet Type
0x0130

MemSync

This packet is sent when an update to the memory of a device is performed. It can be sent in either direction, to allow updates to pass to or from the emulated device, though typically they will pass from the emulator to the client. This packet does not follow a "request/response" pattern.

Packet Type
0x0131
Packet Body
SectionCount uint16
struct {
	StartChunk 	uint16
	Count 		uint8
	Ram 		uint16[Count*16]
}[SectionCount]

Parameters

ParamCount uint8
struct {
	ID 		uint8
    Len 	uint8
	Data 	uint8[Len]
}[ParamCount]