1 /*******************************************************************************
2 * Copyright (C) 2018 Cadence Design Systems, Inc.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining
5 * a copy of this software and associated documentation files (the
6 * "Software"), to use this Software with Cadence processor cores only and
7 * not with any other processors and platforms, subject to
8 * the following conditions:
9 *
10 * The above copyright notice and this permission notice shall be included
11 * in all copies or substantial portions of the Software.
12 *
13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
14 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
15 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
16 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
17 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
18 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
19 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20 
21 ******************************************************************************/
22 
23 /*******************************************************************************
24  * xf-isr.c
25  *
26  * DSP processing framework - code running from interrupt context
27  *
28  ******************************************************************************/
29 
30 #define MODULE_TAG                      ISR
31 
32 /*******************************************************************************
33  * Includes
34  ******************************************************************************/
35 
36 #include "xf.h"
37 
38 /*******************************************************************************
39  * API functions definitions
40  ******************************************************************************/
41 
42 /* ...submit command message from interrupt context on local core */
xf_msg_schedule_isr(xf_message_t * m)43 void xf_msg_schedule_isr(xf_message_t *m)
44 {
45     u32                 core = XF_MSG_DST_CORE(m->id);
46     xf_core_data_t     *cd = XF_CORE_DATA(core);
47 
48     /* ...interrupt masking protocol is used for protecting local message queue */
49     if (xf_msg_enqueue(&cd->queue, m))
50     {
51         /* ...resume local scheduler if that is the first message */
52         xf_ipi_resume(core);
53     }
54 }
55 
56 /* ...complete message from interrupt handler */
xf_msg_complete_isr(xf_message_t * m)57 void xf_msg_complete_isr(xf_message_t *m)
58 {
59     u32                 core = XF_MSG_DST_CORE(m->id);
60     xf_core_data_t     *cd = XF_CORE_DATA(core);
61 
62     /* ...place message into response queue */
63     if (xf_msg_enqueue(&cd->response, m))
64     {
65         /* ...notify local scheduler if that is the first message */
66         xf_ipi_resume(core);
67     }
68 }
69