SIM_INTERFACE(ms1553_link) { int (*connect_terminal)(conf_object_t *link, conf_object_t *NOTNULL obj); void (*disconnect_terminal)(conf_object_t *link, int id); void (*send_data)(conf_object_t *link, int id, ms1553_phase_t phase, ms1553_words_t data); void (*set_terminal_address)(conf_object_t *link, int id, int address); void (*clr_terminal_address)(conf_object_t *link, int id); void (*set_idle)(conf_object_t *link, int id); void (*inject_data)(conf_object_t *link, ms1553_phase_t phase, ms1553_words_t data); void (*inject_error)(conf_object_t *link, ms1553_error_t err); }; #define MS1553_LINK_INTERFACE "ms1553_link"
This interface is implemented by the MIL-STD-1553 link objects that provide a protocol level interface for message delivery.
The connect_terminal() function attaches an 1553 device to the
link. The device must implement the ms1553_terminal
interface. The return value is an identification number that should be used
in subsequent calls to the link to identify the device. On failure, for
example if there is not room for more terminals on the link, the connect
function will return -1. Terminals should always reconnect to the link when
starting from a checkpoint.
The disconnect_terminal() function detaches an 1553 device from the link. It will not receive any more data from the link and may not call any functions in the interface again, except connect_terminal().
A remote terminal may, and should preferably, register its terminal address using the set_terminal_address() to only receive data destined for it. If no address is registered it will receive all data sent on the bus. The clr_terminal_address() is used to unregister a previously installed terminal address from the 1553 link. Models of bus monitors should typically not register any address, but instead receive all data traffic.
The send_data() function is used by all devices to send data
words to the link. Devices must observe the 1553 protocol standards. I.e.
a message starts with a command from the bus controller device. This
command will be sent to the addressed remote terminal, or all of them in
case of broadcast, using the receive_data() function in the
ms1553_terminal
interface. The addressed terminal responds
with status and data, in case of a "Transmit" command, using the
send_data() function. For a "Receive" command, the bus
controller sends the data with send_data() and the addressed
remote terminal finally sends the status word.
Commands, status and data are always sent in separate calls to
send_data(), where the phase parameter describes
what kind is sent. The phase is provided to simplify the
implementation of the protocol handling in devices, it is possible to figure
out the kind of the sent data by decoding the words sent on the link as in
a real case. The values in the ms1553_phase_t
type correspond to
the Idle, Transmit Command, Receive Command,
Transmit Mode Command, Receive Mode Command,
No-data Mode Command, Data and Status phases.
Commands, status and data words should always be stored in host endian byte order, when packed in a ms1553_words_t structure.
A terminal may not respond by calling send_data() directly from its own receive_data(). A simple way to delay the reply transfer is to post it as a Simics event.
The set_idle() function should be used by the bus controller to restore the protocol checking engine in the link after a protocol error has occurred, for example after an RT timeout.
Common link errors are reported by the link using receive_error(), simplifying the implementation of device models. Some error types are not detected in Simics itself, such as Manchester decoding errors, due to the modeling abstraction in Simics but may be injected to test error handling in drivers.
Errors can also be injected in the link with inject_error(), and terminals should be prepared to handle calls to their receive_error().
Data traffic can be also be injected with inject_data(), to simulate generic traffic without registering a device.