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-core.h
25  *
26  * DSP processing framework core definitions
27  *
28  *******************************************************************************/
29 
30 #ifndef __XF_H
31 #error "xf-core.h mustn't be included directly"
32 #endif
33 
34 /*******************************************************************************
35  * Shared core data
36  ******************************************************************************/
37 
38 /* ...core data with read-only access from remote cores */
39 typedef struct xf_core_ro_data
40 {
41     /* ...platform-specific multi-core mutex data (want to have an array? - tbd) */
42     xf_mutex_t          lock;
43 
44     /* ...opaque platform-specific IPC-data handle */
45     xf_ipc_handle_t     ipc;
46 
47     /* ...shared memory message pool data - here? - tbd */
48     xf_msg_pool_t       pool;
49 
50     /* ...anything else? - tbd */
51 
52 }   xf_core_ro_data_t;
53 
54 /* ...core data with read-write access from remote cores */
55 typedef struct xf_core_rw_data
56 {
57     /* ...message queue containing local commands/responses */
58     xf_msg_queue_t      local;
59 
60     /* ...message queue containing responses to remote proxy (if enabled) */
61     xf_msg_queue_t      remote;
62 
63     /* ...pointer to shared memory data? anything else? - tbd */
64 
65 }   xf_core_rw_data_t;
66 
67 /* ...proper cache-line aligned core data */
68 XF_ALIGNED_TYPEDEF(xf_core_ro_data_t, __xf_core_ro_data_t);
69 XF_ALIGNED_TYPEDEF(xf_core_rw_data_t, __xf_core_rw_data_t);
70 
71 /*******************************************************************************
72  * Global data definition - hmm... - tbd
73  ******************************************************************************/
74 
75 /* ...per-core shared memory with read-only remote access */
76 extern __xf_core_ro_data_t  xf_core_ro_data[XF_CFG_CORES_NUM];
77 
78 /* ...per-core shared memory with read-write remote access */
79 extern __xf_core_rw_data_t  xf_core_rw_data[XF_CFG_CORES_NUM];
80 
81 /* ...shared read-only memory access */
82 #define XF_CORE_RO_DATA(core)   ((xf_core_ro_data_t *)(&xf_core_ro_data[(core)]))
83 
84 /* ...shared read-write memory access */
85 #define XF_CORE_RW_DATA(core)   ((xf_core_rw_data_t *)(&xf_core_rw_data[(core)]))
86 
87 /*******************************************************************************
88  * Local core data (not accessible from remote cores)
89  ******************************************************************************/
90 
91 /* ...component map entry */
92 typedef union xf_cmap_link
93 {
94     /* ...poiner to active client */
95     xf_component_t     *c;
96 
97     /* ...index to a client in the list (values 0..XF_CFG_MAX_CLIENTS) */
98     u32                 next;
99 
100 }   xf_cmap_link_t;
101 
102 /* ...per-core local data */
103 typedef struct xf_core_data
104 {
105     /* ...scheduler queue (sorted by execution timestamp) */
106     xf_sched_t          sched;
107 
108     /* ...command/response queue for communication within local core (including ISRs) */
109     xf_msg_queue_t      queue;
110 
111     /* ...pending response queue (submitted from ISR context) */
112     xf_msg_queue_t      response;
113 
114     /* ...per-core component mapping */
115     xf_cmap_link_t      cmap[XF_CFG_MAX_CLIENTS];
116 
117     /* ...index of first free client */
118     u32                 free;
119 
120     /* ...local DSP memory pool */
121     xf_mm_pool_t        local_pool;
122 
123     /* ...shared AP-DSP memory pool (if enabled) */
124     xf_mm_pool_t        shared_pool;
125 
126     /* ...opaque system-specific shared memory data handle */
127     xf_shmem_handle_t   shmem;
128 
129     /* ...scratch memory pointer */
130     void               *scratch;
131 
132     /* ...tracer data */
133     xf_trace_data_t     trace;
134 
135     /* ...any debugging information? for memory allocation etc... ? */
136 
137 }   xf_core_data_t;
138 
139 /*******************************************************************************
140  * API functions
141  ******************************************************************************/
142 
143 /* ...initialize per-core framework data */
144 extern int  xf_core_init(u32 core);
145 
146 /* ...global data initialization function */
147 extern int  xf_global_init(void);
148 
149 /* ...process core events */
150 extern void xf_core_service(u32 core);
151