summaryrefslogtreecommitdiff
path: root/hifi/xaf/hifi-dpf/include/xf-core.h
blob: 4daea6f29274fcc420418ff6af1f754840bae1d4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
/*******************************************************************************
* Copyright (C) 2018 Cadence Design Systems, Inc.
* 
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to use this Software with Cadence processor cores only and 
* not with any other processors and platforms, subject to
* the following conditions:
* 
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
* 
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

******************************************************************************/

/*******************************************************************************
 * xf-core.h
 *
 * DSP processing framework core definitions
 *
 *******************************************************************************/

#ifndef __XF_H
#error "xf-core.h mustn't be included directly"
#endif

/*******************************************************************************
 * Shared core data
 ******************************************************************************/

/* ...core data with read-only access from remote cores */
typedef struct xf_core_ro_data
{
    /* ...platform-specific multi-core mutex data (want to have an array? - tbd) */
    xf_mutex_t          lock;

    /* ...opaque platform-specific IPC-data handle */
    xf_ipc_handle_t     ipc;

    /* ...shared memory message pool data - here? - tbd */
    xf_msg_pool_t       pool;
    
    /* ...anything else? - tbd */

}   xf_core_ro_data_t;

/* ...core data with read-write access from remote cores */
typedef struct xf_core_rw_data
{
    /* ...message queue containing local commands/responses */
    xf_msg_queue_t      local;

    /* ...message queue containing responses to remote proxy (if enabled) */
    xf_msg_queue_t      remote;

    /* ...pointer to shared memory data? anything else? - tbd */

}   xf_core_rw_data_t;

/* ...proper cache-line aligned core data */
XF_ALIGNED_TYPEDEF(xf_core_ro_data_t, __xf_core_ro_data_t);
XF_ALIGNED_TYPEDEF(xf_core_rw_data_t, __xf_core_rw_data_t);

/*******************************************************************************
 * Global data definition - hmm... - tbd
 ******************************************************************************/

/* ...per-core shared memory with read-only remote access */
extern __xf_core_ro_data_t  xf_core_ro_data[XF_CFG_CORES_NUM];

/* ...per-core shared memory with read-write remote access */
extern __xf_core_rw_data_t  xf_core_rw_data[XF_CFG_CORES_NUM];

/* ...shared read-only memory access */
#define XF_CORE_RO_DATA(core)   ((xf_core_ro_data_t *)(&xf_core_ro_data[(core)]))

/* ...shared read-write memory access */
#define XF_CORE_RW_DATA(core)   ((xf_core_rw_data_t *)(&xf_core_rw_data[(core)]))

/*******************************************************************************
 * Local core data (not accessible from remote cores)
 ******************************************************************************/

/* ...component map entry */
typedef union xf_cmap_link
{
    /* ...poiner to active client */
    xf_component_t     *c;
    
    /* ...index to a client in the list (values 0..XF_CFG_MAX_CLIENTS) */
    u32                 next;

}   xf_cmap_link_t;

/* ...per-core local data */
typedef struct xf_core_data
{
    /* ...scheduler queue (sorted by execution timestamp) */
    xf_sched_t          sched;

    /* ...command/response queue for communication within local core (including ISRs) */
    xf_msg_queue_t      queue;

    /* ...pending response queue (submitted from ISR context) */
    xf_msg_queue_t      response;
    
    /* ...per-core component mapping */
    xf_cmap_link_t      cmap[XF_CFG_MAX_CLIENTS];

    /* ...index of first free client */
    u32                 free;
    
    /* ...local DSP memory pool */
    xf_mm_pool_t        local_pool;
    
    /* ...shared AP-DSP memory pool (if enabled) */
    xf_mm_pool_t        shared_pool;    

    /* ...opaque system-specific shared memory data handle */
    xf_shmem_handle_t   shmem;

    /* ...scratch memory pointer */
    void               *scratch;

    /* ...tracer data */
    xf_trace_data_t     trace;

    /* ...any debugging information? for memory allocation etc... ? */

}   xf_core_data_t;

/*******************************************************************************
 * API functions
 ******************************************************************************/

/* ...initialize per-core framework data */
extern int  xf_core_init(u32 core);

/* ...global data initialization function */
extern int  xf_global_init(void);

/* ...process core events */
extern void xf_core_service(u32 core);