Ignore:
Timestamp:
Jan 22, 2017, 2:01:55 PM (4 years ago)
Author:
Daniel Hellstrom <daniel@…>
Branches:
5, master
Children:
29c2304
Parents:
f46f5f84
git-author:
Daniel Hellstrom <daniel@…> (01/22/17 14:01:55)
git-committer:
Daniel Hellstrom <daniel@…> (03/06/17 06:54:55)
Message:

leon, grspw_pkt: added work-task configuration options

Following changes:

  • possible for user to create work-tasks and assign custom message queues.
  • possible for user to override default ISR message to implement custom handling of DMA error, DMA RX/TX and link error from ISR.
  • work-task now checks message to determine which work to perform rather than looking at registers only, this makes it possible for user to implement custom handling.
  • exported work-queue message definitions and separated them so that a user can assign custom DMA RX/TX handling of a specific DMA channel.
  • added a work-task event callback to let user add custom handling or monitoring of DMA Stop, DMA error, Link Error or work-task exits etc.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/sparc/shared/include/grspw_pkt.h

    rf46f5f84 rab9b447  
    312312};
    313313
     314/* ISR message sending call back. Compatible with rtems_message_queue_send().
     315 * The 'buf' parameter has a pointer to a WORK-TASK message defined by the
     316 * WORK_* macros below. The message indicates what GRSPW device operations
     317 * are pending, thus what caused the interrupt.
     318 *
     319 * \param data   defined by grspw_work_config.msgisr_arg, default a rtems_id.
     320 * \param buf    Pointer to a 32-bit message word
     321 * \param n      Always 4 (byte size of buf).
     322 */
     323typedef int (*grspw_msgqisr_t)(void *data, unsigned int *buf, unsigned int n);
     324
     325/* Work message definitions, the int sent to *buf
     326 * Bits 31..24: reserved.
     327 * Bits 23..16: GRSPW device number message is associated with.
     328 * Bit  15:     reserved.
     329 * Bit  14:     work-task shall delete message queue on exit.
     330 * Bit  13:     work-task shall exit and delete itself.
     331 * Bit  12:     link error - shut down all DMA operations (stop DMA channels).
     332 * Bit  11..8:  Indicats DMA error on DMA channel 3..0.
     333 * Bit  7..0:   Indicats RX and/or TX packets completed on channel 3..0.
     334 */
     335#define WORK_NONE         0
     336#define WORK_SHUTDOWN     0x1000 /* Signal shut down */
     337#define WORK_QUIT_TASK    0x2000 /* Work task shall exit (delete itself) */
     338#define WORK_FREE_MSGQ    0x4000 /* Delete MsgQ (valid when WORK_QUIT_TASK) */
     339#define WORK_DMA(chan, rxtx) (((rxtx) & 0x3) << ((chan) * 2))
     340#define WORK_DMA_TX(chan) WORK_DMA(chan, 1)
     341#define WORK_DMA_RX(chan) WORK_DMA(chan, 2)
     342#define WORK_DMA_ER(chan) (0x1 << ((chan) + 8))
     343#define WORK_DMA_MASK     0xfff /* max 4 channels all work */
     344#define WORK_DMA_TX_MASK  0x055 /* max 4 channels TX work */
     345#define WORK_DMA_RX_MASK  0x0aa /* max 4 channels RX work */
     346#define WORK_DMA_ER_MASK  0xf00 /* max 4 channels Error work */
     347#define WORK_DMA_CHAN_MASK(chan) (WORK_DMA_ER(chan) | WORK_DMA(chan, 0x3))
     348#define WORK_CORE_BIT     16
     349#define WORK_CORE_MASK    0x00ff0000
     350#define WORK_CORE(device) ((device) << WORK_CORE_BIT)
     351
     352/* Message Q used to send messages to work task */
     353struct grspw_work_config {
     354        grspw_msgqisr_t msgisr;
     355        void *msgisr_arg; /* example: rtems_id to Msg Q */
     356};
     357
    314358extern void grspw_initialize_user(
    315359        /* Callback every time a GRSPW device is found. Args: DeviceIndex */
     
    321365        void (*devremove)(int,void*)
    322366        );
     367
     368/* Creates a MsgQ (optional) and spawns a worker task associated with the
     369 * message Q. The task can also be associated with a custom msgQ if *msgQ.
     370 * is non-zero.
     371 *
     372 * \param prio     Task priority, set to -1 for default.
     373 * \param stack    Task stack size, set to 0 for default.
     374 * \param msgQ     pMsgQ=NULL: illegal,
     375 *                 pMsqQ==0: create new MsgQ with task and place in *pMsgQ,
     376 *                 *pmsqQ!=0: pointer to MsgQ used for task.
     377 * \param msgMax   Maximum number of messages, set to 0 for default.
     378 * \return         0 on failure, task id on success.
     379 */
     380extern rtems_id grspw_work_spawn(int prio, int stack, rtems_id *pMsgQ, int msgMax);
     381
     382/* Free task associated with message queue and optionally also the message
     383 * queue itself. The message queue is deleted by the work task and is therefore
     384 * delayed until it the work task resumes its execution.
     385 */
     386extern rtems_status_code grspw_work_free(rtems_id msgQ, int freeMsgQ);
     387
     388/* Configure a GRSPW device Work task and Message Q set up.
     389 * This affects messages to:
     390 *  - DMA AHB error interrupt handling (mandatory)
     391 *  - Link status interrupt handling (optional)
     392 *  - RX DMA, defaults to common msgQ (configured per DMA channel)
     393 */
     394extern void grspw_work_cfg(void *d, struct grspw_work_config *wc);
     395
     396/* Work-task function, called only from the work task. The function is provided
     397 * as a way for the user to create its own work tasks.
     398 * The argument determines which message queue the task shall read its
     399 * work jobs from.
     400 *
     401 * The messages are always 32-bit words and follows the format defined by the
     402 * WORK_* macros above.
     403 */
     404extern void grspw_work_func(rtems_id msgQ);
     405
     406enum grspw_worktask_ev {
     407        WORKTASK_EV_NONE = 0,
     408        WORKTASK_EV_QUIT = 1,
     409        WORKTASK_EV_SHUTDOWN = 2,
     410        WORKTASK_EV_DMA_STOP = 3,
     411};
     412
     413/* Weak function to let user override. Function called every time one of the
     414 * events above is handled by the work-task. The message 'msg' is the current
     415 * message being processed by the work-task.
     416 * The user can for example add custom code to invoke on a DMA error, link
     417 * error or monitor when the work-task exits after a call to grspw_work_free().
     418 */
     419extern void grspw_work_event(enum grspw_worktask_ev ev, unsigned int msg);
     420
    323421extern int grspw_dev_count(void);
    324422extern void *grspw_open(int dev_no);
Note: See TracChangeset for help on using the changeset viewer.