The TU environment specified in this document is designed to provide source code portability of TUs across multiple operating environments. TUs should only use the device and system interfaces specified in this document to ensure portability. However, experience has shown that it is good programming practice to isolate and abstract external functions so that any problems in porting can be corrected within a single source code file. For this reason, it is strongly recommended that TU developers include a special source file in their TU library for the purpose of providing that isolation and abstraction. The following describes a recommended implementation of that source file, given to help promote consistency in TU development. The consistency is very important for long-term maintenance of the Test Unit code.
TU libraries should include a C source file called interface.c, which provides a set of abstracted device functions that can be used by the actual TU functions. The following is a list of functions that should be implemented within the interface.c.
TU Function | Description |
---|---|
dd_open | Prepares a device for testing and obtains needed device attributes. |
dd_close | Cleans up after testing. |
dd_read | Performs a read operation. |
dd_write | Performs a write operation. |
dd_dma | Initializes, pins, and cross-memory attaches the user buffer for a DMA operation. |
dd_dma_enable | Enables/Disables a DMA operation. |
dd_dma_cleanup | Deallocates any resources previously allocated for a DMA operation. |
dd_interrupt | Processes interrupt conditions. |
As illustrated below, these functions should provide mappings to one or more of the services described in "Programming Interfaces for TUs and Interrupt Handlers" .
The figure also illustrates how TU libraries should include a C source file that implements the exectu() interface, which provides the program entry point for the TU library, decodes the specified TU number to the correct internal function, and calls that function.