
6-14
Motorola DSP56000 Family Optimizing C Compiler User’s Manual
For More Information On This Product,
Go to: www.freescale.com
Motorola
Host-Supported I/O (printf (), et al)
messages between the DSP and the host, with the host eventually returning a message
containing the completion status of the original request. The file dsp/include/ioprim.h is
included by both the host-side I/O driver, and the standard I/O library code; it defines the
constant definitions used in the aforementioned messages. A typical series of events and
messages that comprise a standard I/O call might look like this:
1. The application running on the DSP makes a call to
fopen ()
.
2. The library code in lib56c[xyl].clb calls
__send ()
, with a buffer that contains the
code DSP_OPEN, the flags, the mode, and the string length of the path.
3. The host receives the message into the buffer
hio_receive
, sets its valid flag, and
calls
process_pending_host_io ()
. The state machine inside
process_pending_host_io ()
notes that it is now in the middle of an open file
request, records the values from the first message, and then returns. At this point,
code written by the application developer must check the valid flag of the buffer
hio_send; in this case, the buffer
hio_send
has not been marked valid.
4. The library code in lib56c[xyl].clb calls
__send ()
again, this time sending the path.
5. Again, the host receives the message into the buffer
hio_receive
, and calls
process_pending_host_io ()
after setting the buffer’s valid flag.
6.
process_pending_host_io ()
uses the information from the two messages to
perform the file open. It then builds an operation status message, places it in the
buffer
hio_send
, and sets that buffer’s valid flag.
process_pending_host_io ()
resets its internal state and returns.
7. The host checks the buffer valid flag on
hio_send
, sees that it is true, and transmits
the message to the DSP.
8. The library code running on the DSP finishes the
fopen ()
call and returns.
On the host side of the interface, the application writer must write the code that exchanges
data with the DSP, the code that calls
process_pending_host_io ()
, and the code that
checks buffer valid flags. On the DSP side of the interface, the application writer must
write the routines
__send ()
and
__receive ()
. The communication between the DSP and
the host is always initiated by the DSP and always follows a predetermined pattern,
depending on the initial message. Because this communication is so simple, the code that
calls
process_pending_host_io ()
can also be quite simple.
Example 6-7
is a
hypothetical
non-reentrant interrupt handler written in C. It uses two
functions,
peek ()
and
poke ()
, to access some sort of hardware communication device
connected to the DSP. The functions
peek ()
and
poke ()
aren’t provided; they’re simply
an abstraction for host-side hardware access. This code assumes that the DSP sends the
size of a message directly before sending a message. CHECK_BUFFER_SIZE is a macro
F
Freescale Semiconductor, Inc.
n
.