Developer World
Spresense SDK Library v3.2.0-ebc0364
mpcomm.h
Go to the documentation of this file.
1/****************************************************************************
2 * mpcomm/mpcomm.h
3 *
4 * Copyright 2021 Sony Semiconductor Solutions Corporation
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
15 * distribution.
16 * 3. Neither the name of Sony Semiconductor Solutions Corporation nor
17 * the names of its contributors may be used to endorse or promote
18 * products derived from this software without specific prior written
19 * permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
28 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
29 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 * POSSIBILITY OF SUCH DAMAGE.
33 *
34 ****************************************************************************/
35
40#ifndef __MODULES_INCLUDE_MPCOMM_MPCOMM_H
41#define __MODULES_INCLUDE_MPCOMM_MPCOMM_H
42
43/****************************************************************************
44 * Included Files
45 ****************************************************************************/
46
47#include <stdbool.h>
48
49#include <asmp/types.h>
50#include <asmp/mpmq.h>
51
52/****************************************************************************
53 * Pre-processor Definitions
54 ****************************************************************************/
55
58#define MPCOMM_MSG_ID_INIT 1
59
62#define MPCOMM_MSG_ID_DEINIT 2
63
66#define MPCOMM_MSG_ID_USER_FUNC 3
67
70#define MPCOMM_MSG_ID_DONE 4
71
74#define MPCOMM_MSG_ID_MALLOC 5
75
78#define MPCOMM_MSG_ID_FREE 6
79
82#define MPCOMM_MSG_ID_ERROR 7
83
86#define MPCOMM_MSG_ID_LOG 8
87
90#define MPCOMM_MAX_HELPERS 4
91
94#define MPCOMM_CPUID_MAX 8
95
98#define MPCOMM_MODE_CONTROLLER 0
99
102#define MPCOMM_MODE_HELPER 1
103
106#define MEM_V2P(addr) mpcomm_memory_virt_to_phys(addr)
107
108/****************************************************************************
109 * Public Types
110 ****************************************************************************/
111
120typedef void (*mpcomm_user_func_t)(void *data);
121
131typedef struct helper_info
132{
136
141
152typedef struct mpcomm_context
153{
156 uint8_t mode;
157
161
165
169
172 cpu_set_t helpers_cpuset;
173
180
187
190 uint8_t helpers_num;
191
195
199
202 uintptr_t loadaddr;
203
206 uint8_t quit_loop;
208
218typedef struct mpcomm_init_msg
219{
222 uint8_t mode;
223
227
230 cpu_set_t helpers_cpuset;
231
234 uintptr_t loadaddr;
236
246typedef struct mpcomm_malloc_msg
247{
251
254 void **ptr;
255
258 size_t size;
260
270typedef struct mpcomm_free_msg
271{
275
278 void *ptr;
280
290typedef struct mpcomm_error_msg
291{
295
298 int error;
300
310typedef struct mpcomm_log_msg
311{
315
318 char *log;
320
321/****************************************************************************
322 * Public Function Prototypes
323 ****************************************************************************/
324
337int mpcomm_main(mpcomm_user_func_t controller_user_func,
338 mpcomm_user_func_t helper_user_func);
339
350int mpcomm_send_helper(uint8_t helper_index, void *data);
351
361int mpcomm_wait_helper_done(uint8_t helper_index);
362
371
379
387
397
410int mpcomm_send_malloc(void **ptr, size_t size);
411
422int mpcomm_send_free(void *ptr);
423
433int mpcomm_send_error(int err);
434
444int mpcomm_send_log(char *log);
445
446#endif /* __MODULES_INCLUDE_MPCOMM_MPCOMM_H */
int16_t cpuid_t
Definition: types.h:64
void(* mpcomm_user_func_t)(void *data)
Definition: mpcomm.h:120
int mpcomm_wait_helpers_done(void)
struct mpcomm_error_msg mpcomm_error_msg_t
int mpcomm_get_helpers_num(void)
struct mpcomm_free_msg mpcomm_free_msg_t
struct mpcomm_malloc_msg mpcomm_malloc_msg_t
int mpcomm_send_error(int err)
struct helper_info helper_info_t
struct mpcomm_log_msg mpcomm_log_msg_t
int mpcomm_send_log(char *log)
int mpcomm_send_helper(uint8_t helper_index, void *data)
struct mpcomm_context mpcomm_context_t
int mpcomm_main(mpcomm_user_func_t controller_user_func, mpcomm_user_func_t helper_user_func)
struct mpcomm_init_msg mpcomm_init_msg_t
int mpcomm_send_free(void *ptr)
int mpcomm_send_malloc(void **ptr, size_t size)
int mpcomm_wait_helper_done(uint8_t helper_index)
#define MPCOMM_MAX_HELPERS
Definition: mpcomm.h:90
void * mpcomm_memory_virt_to_phys(void *addr)
bool mpcomm_is_controller(void)
Definition: mpcomm.h:132
cpuid_t cpuid
Definition: mpcomm.h:139
mpmq_t mq
Definition: mpcomm.h:135
Definition: mpcomm.h:153
mpmq_t mq_2_supervisor
Definition: mpcomm.h:160
mpmq_t mq_2_controller
Definition: mpcomm.h:164
mpcomm_user_func_t helper_user_func
Definition: mpcomm.h:198
uint8_t mode
Definition: mpcomm.h:156
cpu_set_t helpers_doneset
Definition: mpcomm.h:179
uint8_t supervisor_done
Definition: mpcomm.h:186
mpcomm_user_func_t controller_user_func
Definition: mpcomm.h:194
uintptr_t loadaddr
Definition: mpcomm.h:202
uint8_t helpers_num
Definition: mpcomm.h:190
uint8_t quit_loop
Definition: mpcomm.h:206
helper_info_t helpers[MPCOMM_MAX_HELPERS]
Definition: mpcomm.h:168
cpu_set_t helpers_cpuset
Definition: mpcomm.h:172
Definition: mpcomm.h:291
int error
Definition: mpcomm.h:298
cpuid_t cpuid
Definition: mpcomm.h:294
Definition: mpcomm.h:271
cpuid_t cpuid
Definition: mpcomm.h:274
void * ptr
Definition: mpcomm.h:278
Definition: mpcomm.h:219
uint8_t mode
Definition: mpcomm.h:222
uintptr_t loadaddr
Definition: mpcomm.h:234
cpuid_t controller_cpuid
Definition: mpcomm.h:226
cpu_set_t helpers_cpuset
Definition: mpcomm.h:230
Definition: mpcomm.h:311
cpuid_t cpuid
Definition: mpcomm.h:314
char * log
Definition: mpcomm.h:318
Definition: mpcomm.h:247
void ** ptr
Definition: mpcomm.h:254
cpuid_t cpuid
Definition: mpcomm.h:250
size_t size
Definition: mpcomm.h:258
Definition: mpmq.h:77