Manual

Writing New Devices - target
instance
If it is possible to have multiple instances of a device then this argument identifies the particular instance, for
example eth0 or eth1. Otherwise a NULL pointer can be used.
data
This argument can be used to pass additional initialization data from eCos to the host-side support. This
is useful for devices where eCos configury must control certain aspects of the device, rather than host-side
configury such as the target definition file, because eCos has compile-time dependencies on some or all of the
relevant options. An example might be an emulated frame buffer where eCos has been statically configured
for a particular screen size, orientation and depth. There is no fixed format for this string, it will be interpreted
only by the device-specific host-side Tcl script. However the string length should be limited to a couple of
hundred bytes to avoid possible buffer overflow problems.
Typical usage would look like:
if (!synth_auxiliary_running) {
return;
}
id = synth_auxiliary_instantiate("devs/eth/synth/ecosynth",
SYNTH_MAKESTRING(CYGPKG_DEVS_ETH_ECOSYNTH),
"ethernet",
"eth0",
(const char*) 0);
The return value will be a device identifier which can be used for subsequent calls to synth_auxiliary_xchgmsg.
If the device could not be instantiated then -1 will be returned. It is the responsibility of the host-side software to
issue suitable diagnostics explaining what went wrong, so normally the target-side code should fail silently.
Once the desired device has been instantiated, often it will be necessary to do some additional initialization by
a message exchange. For example an ethernet device might need information from the host-side about the MAC
address, the interrupt vector, and whether or not multicasting is supported.
Communicating with a Device
Once a device has been instantiated it is possible to perform I/O by sending messages to the appropriate Tcl script
running inside the auxiliary, and optionally getting back replies. I/O operations are always initiated by the eCos
target-side, it is not possible for the host-side software to initiate data transfers. However the host-side can raise
interrupts, and the interrupt handler inside the target can then exchange one or more messages with the host.
There is a single function to perform I/O operations, synth_auxiliary_xchgmsg. This takes the following argu-
ments:
device_id
This should be one of the identifiers returned by a previous call to synth_auxiliary_instantiate, speci-
fying the particular device which should perform some I/O.
request
Request are just signed 32-bit integers that identify the particular I/O operation being requested. There is no
fixed set of codes, instead each type of device can define its own.
667