NOTICE: The Processors Wiki will End-of-Life in December of 2020. It is recommended to download any files or other content you may need that are hosted on The site is now set to read only.

DSPLink Signal Handling in Codec Engine

From Texas Instruments Wiki
Jump to: navigation, search

DSPLink Signal Handling in Codec Engine

DSPLink (on Linux) contains a "signal" handler that can be enabled/disabled by way of the DSPLink configuration mechanism. When used in conjunction with Codec Engine, DSPLink configuration is handled by Codec Engine's Processor module (located in ti.sdo.ce.ipc.dsplink). While a few of the DSPLink configuration elements are exposed to the user through Codec Engine configuration, most aspects of configuration are hard-coded by the Processor module. This article discusses one hard-coded element in particular: DSPLink signal handling.

DSPLink Signal Handling

Prior to support for access by multiple processes, DSPLink signal handling was sufficient for most all situations. With the added support for multiple process access, DSPLink's signal handling became insufficient for the more complicated multiple-process or multiple-thread application. It became clear that the only way to provide the correct signal handling was to have the application install its own signal handler, with its own custom needs based on the application architecture. This article does not approach the subject of *what* to do in a DSPLink-under-Codec Engine signal handler, it just discusses *how* to override DSPLink's signal handler in favor of an application-defined one.

There is a related DSPLink FAQ on the signal handler here.

Configuring DSPLink

DSPLink configuration involves defining a few C structures with initialization values. When used outside of Codec Engine, DSPLink defines these C structures based on input to the DSPLink configuration tool (a PERL script in the latest DSPLink release). When used underneath Codec Engine, Codec Engine overrides these generated C files with its own copies (and even dynamically defines part of the configuration during runtime).

One of the configuration structures relates to OS signal handling, defining a structure of type LINKCFG_GppOs. For the Linux OS, Codec Engine defines this structure in a file named "Processor_dsplink_linkcfg_OS.c". This defined structure is named "LINKCFG_gppOsObject", and it is referenced by another structure that is part of the DSPLink configuration, "LINKCFG_gppObject" of type LINKCFG_Gpp defined in the architecture-specific file "Processor_dsplink_linkcfg_<arch>.c", and that structure is referenced by the top-level DSPLink configuration structure,"LINKCFG_config" of type LINKCFG_Object.

The signal handling configuration in "LINKCFG_gppOsObject" specifies the group of signals to handle as well as a boolean value named "handleSignals". Codec Engine sets "handleSignals" to TRUE, which causes DSPLink to install its signal handler. In order to override this and allow the application to install its own signal handler, the application will need to define this structure itself with an identifier (i.e., name) identical to the one defined by Codec Engine - "LINKCFG_gppOsObject". The application's build mechanism will need to ensure that this structure is encountered by the application's linking stage before the time when the Codec Engine libraries are consulted, so that there will be no need to satisfy the reference to "LINKCFG_gppOsObject" from the Codec Engine libraries. The simplest way to ensure this is to define the structure in the application's "main()" C file (the one that defines the main() function).

The most fool-proof way of defining this structure is to cut-and-paste the contents of Codec Engine's definition and change the initialization of "handleSignals" from TRUE to FALSE. When doing so, the other elements of the structure actually become unused and therefore no longer need to be defined at all, but leaving them as-is is harmless and merely consumes a few more bytes of memory (and, to be exact, the only savings would be the "LINKCFG_sigNumArray" definition since this array is not part of "LINKCFG_gppOsObject").

Steps to override Codec Engine's configuration

The following steps are the suggested method of overriding Codec Engine's configuration of DSPLink's signal handling:

  • copy the contents of the file <codec_engine>/packages/ti/sdo/ce/ipc/dsplink/Processor_dsplink_linkcfg_OS.c into your application's "main" C file.
  • snip all the "header" and "footer" C comment clauses (Copyright, file description, etc.)
  • change the "handleSignals" structure member of LINKCFG_gppOsObject from TRUE to FALSE.

Also, since a Codec Engine application typically doesn't make direct calls to DSPLink APIs or macros, an application's compile command won't already contain a reference to the DSPLink header file locations. DSPLink header files are needed to build your new signal handling structures. Be sure to add the DSPLink header file location to your compile command, using the "-I" option:

   gcc -I <DSPLink_dir>/packages/dsplink/gpp/inc/usr ...

Contents of modified <codec_engine>/packages/ti/sdo/ce/ipc/dsplink/Processor_dsplink_linkcfg_OS.c

The following code can be inserted directly into the application C file to disable DSPLink's signal handling:

<syntaxhighlight lang='c'> /*

* DSP LINK Headers
  1. include <dsplink.h>
  2. include <procdefs.h>


* Table of signals we're not going to handle.

static Uint32 sigNumArray [] = {

   1u,                         /* SIGHUP   */
   2u,                         /* SIGINT   */
   4u,                         /* SIGILL   */
   6u,                         /* SIGABRT  */
   8u,                         /* SIGFPE   */
   11u,                        /* SIGSEGV  */
   14u,                        /* SIGALRM  */
   15u                         /* SIGTERM  */

} ;


* Symbol/struct we're overriding (with HANDLESIGNALS = FALSE)

LINKCFG_GppOs ti_sdo_ce_ipc_Processor_linkcfg_OS = {

   FALSE,                  /* HANDLESIGNALS  : Should signals be handled for cleanup */
   8u,                     /* NUMSIGNALS     : Number of signals to be handled */
   (Uint32 *)&sigNumArray  /* SIGNUMARRAY    : Pointer to the array of signals to be handled */

}; </syntaxhighlight>