Listing 3. BSP Types

typedef enum
{
  DSP_K_STATE_NULL,
  DSP_K_STATE_READY,
  DSP_K_STATE_RUN,
  DSP_K_STATE_PEND,
  DSP_K_STATE_TIMER,
  DSP_K_STATE_WAIT,

} t__DSP_K_STATES;

typedef struct
{
  t__DSP_K_TSK function;  /* task main thread */
  t__DSP_K_STATES state;  /* initial task state */
  t__DSP_K_SCHD scheduler; /* task scheduler */
  void *stack; /* main thread & scheduler stack */
  size_t stacksz; /* size of stack */

} t__DSP_K_TASK_DSCR;

 /* 
  * work out total size of context stack needed 
 */
#define _DSP_K_SAVEREG \
  ( _DSP_K_CTXTAST + \
    _DSP_K_CTXTREG + \
    _DSP_K_CTXTIDX + \
    _DSP_K_CTXTMOD + \
    _DSP_K_CTXTBSE + \
    _DSP_K_CTXTLEN + \
    _DSP_K_MULTLEN )

typedef struct
{
  t__DSP_K_STATES state; /* kernel 'queue' */
    /* thread context save stack */
  unsigned int ctxt[ _DSP_K_SAVEREG ];
  int errno; /* per. task errno */
  int eval;  /* per. task exit value */
  struct waitevent waits; /* task wait structure */
  timer_t timer;  /* timer assigned to task */
  pid_t parent; /* parent of task when run */
  gid_t group;  /* process group task belongs to */
  unsigned int drivers; /* bit set if driver open */
# if( DSP_K_STATS > 0 )
     /* see usr/src/linux/include/kernel.h etc. */
    int schedcnt;  /* count of schedules */
    int schedcall; /* scheduler invocations */
    int resetcnt; /* task reset count */
# endif

} t__DSP_K_tcb;


/* ----------------------------------------------
 * BSP DATA STRUCTURE
*/
typedef struct
{
  t__DSP_K_TSKID current;
    /* +1 for 'main' context */
  t__DSP_K_tcb tasks[ DSP_K_NUM_TASKS + 1 ];
  t__DSP_K_TASK_DSCR *tl; /* copy of entry point */
  int argc;    /* environment variables */
  char **argv;
  void *arg0;
# if( DSP_K_STATS > 0 )
    int tickcnt;  /* count of ticks */
# endif

} t__DSP_K_context;

extern t__DSP_K_context __DSP_K_context;