SpaceOS wire protocol codecs for host-guest communication
at main 129 lines 3.6 kB view raw
1(** Shared memory page accessors (4096 bytes). 2 3 {v 4 Offset Size Field 5 0x000 8 bytes Guest heartbeat counter (uint64) 6 0x008 8 bytes Host heartbeat ack (uint64) 7 0x010 4 bytes Time version (uint32, seqlock) 8 0x014 8 bytes Mission time seconds (uint64) 9 0x01C 4 bytes Mission time nanoseconds (uint32) 10 0x020 4 bytes Guest status word (uint32) 11 0x024 4 bytes Host command word (uint32) 12 0x028 4 bytes Guest command ack (uint32) 13 0x100 256 bytes Guest health string (UTF-8, null-terminated) 14 v} *) 15 16val page_size : int 17(** Shared memory page size: 4096 bytes. *) 18 19(** {1 Field offsets} *) 20 21val off_heartbeat : int 22(** Offset of the guest heartbeat counter (8 bytes). *) 23 24val off_heartbeat_ack : int 25(** Offset of the host heartbeat acknowledgement (8 bytes). *) 26 27val off_time_version : int 28(** Offset of the time version seqlock (4 bytes). *) 29 30val off_time_seconds : int 31(** Offset of mission time seconds (8 bytes). *) 32 33val off_time_nanos : int 34(** Offset of mission time nanoseconds (4 bytes). *) 35 36val off_guest_status : int 37(** Offset of the guest status word (4 bytes). *) 38 39val off_host_cmd : int 40(** Offset of the host command word (4 bytes). *) 41 42val off_guest_cmd_ack : int 43(** Offset of the guest command acknowledgement (4 bytes). *) 44 45val off_health_string : int 46(** Offset of the guest health string (256 bytes). *) 47 48val health_string_len : int 49(** Maximum health string length: 256 bytes. *) 50 51(** {1 Accessors} 52 53 All accessors work on a [bytes] buffer of at least [page_size] bytes, using 54 big-endian byte order. *) 55 56val heartbeat : bytes -> int64 57(** Read the guest heartbeat counter. *) 58 59val set_heartbeat : bytes -> int64 -> unit 60(** Write the guest heartbeat counter. *) 61 62val heartbeat_ack : bytes -> int64 63(** Read the host heartbeat acknowledgement. *) 64 65val set_heartbeat_ack : bytes -> int64 -> unit 66(** Write the host heartbeat acknowledgement. *) 67 68val time_version : bytes -> int 69(** Read the time version seqlock. *) 70 71val set_time_version : bytes -> int -> unit 72(** Write the time version seqlock. *) 73 74val time_seconds : bytes -> int64 75(** Read the mission time seconds. *) 76 77val set_time_seconds : bytes -> int64 -> unit 78(** Write the mission time seconds. *) 79 80val time_nanos : bytes -> int 81(** Read the mission time nanoseconds. *) 82 83val set_time_nanos : bytes -> int -> unit 84(** Write the mission time nanoseconds. *) 85 86val guest_status : bytes -> int 87(** Read the guest status word. *) 88 89val set_guest_status : bytes -> int -> unit 90(** Write the guest status word. *) 91 92val host_cmd : bytes -> int 93(** Read the host command word. *) 94 95val set_host_cmd : bytes -> int -> unit 96(** Write the host command word. *) 97 98val guest_cmd_ack : bytes -> int 99(** Read the guest command acknowledgement. *) 100 101val set_guest_cmd_ack : bytes -> int -> unit 102(** Write the guest command acknowledgement. *) 103 104val health_string : bytes -> string 105(** Read the guest health string. *) 106 107val set_health_string : bytes -> string -> unit 108(** Write the guest health string. *) 109 110(** {1 Mission time with seqlock} *) 111 112type mission_time = { seconds : int64; nanos : int } 113 114val write_mission_time : bytes -> mission_time -> unit 115(** Host: write mission time with seqlock protocol. *) 116 117val read_mission_time : bytes -> mission_time 118(** Guest: read mission time with seqlock retry. *) 119 120(** {1 Command word bits} *) 121 122val cmd_shutdown : int 123(** Shutdown command bit. *) 124 125val cmd_param_reload : int 126(** Parameter reload command bit. *) 127 128val cmd_dp_ack : int 129(** Data product acknowledgement command bit. *)