Spresense SDK Library v3.4.5-e9a4f17
Loading...
Searching...
No Matches
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
39
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
57
58#define MPCOMM_MSG_ID_INIT 1
59
61
62#define MPCOMM_MSG_ID_DEINIT 2
63
65
66#define MPCOMM_MSG_ID_USER_FUNC 3
67
69
70#define MPCOMM_MSG_ID_DONE 4
71
73
74#define MPCOMM_MSG_ID_MALLOC 5
75
77
78#define MPCOMM_MSG_ID_FREE 6
79
81
82#define MPCOMM_MSG_ID_ERROR 7
83
85
86#define MPCOMM_MSG_ID_LOG 8
87
89
90#define MPCOMM_MAX_HELPERS 4
91
93
94#define MPCOMM_CPUID_MAX 8
95
97
98#define MPCOMM_MODE_CONTROLLER 0
99
101
102#define MPCOMM_MODE_HELPER 1
103
105
106#define MEM_V2P(addr) mpcomm_memory_virt_to_phys(addr)
107
108/****************************************************************************
109 * Public Types
110 ****************************************************************************/
111
119
120typedef void (*mpcomm_user_func_t)(void *data);
121
130
131typedef struct helper_info
132{
134
136
138
141
151
208
217
218typedef struct mpcomm_init_msg
219{
221
222 uint8_t mode;
223
225
227
229
230 cpu_set_t helpers_cpuset;
231
233
234 uintptr_t loadaddr;
236
245
246typedef struct mpcomm_malloc_msg
247{
249
251
253
254 void **ptr;
255
257
258 size_t size;
260
269
270typedef struct mpcomm_free_msg
271{
273
275
277
278 void *ptr;
280
289
290typedef struct mpcomm_error_msg
291{
293
295
297
298 int error;
300
309
310typedef struct mpcomm_log_msg
311{
313
315
317
318 char *log;
320
321/****************************************************************************
322 * Public Function Prototypes
323 ****************************************************************************/
324
336
337int mpcomm_main(mpcomm_user_func_t controller_user_func,
338 mpcomm_user_func_t helper_user_func);
339
349
350int mpcomm_send_helper(uint8_t helper_index, void *data);
351
360
361int mpcomm_wait_helper_done(uint8_t helper_index);
362
369
371
377
379
385
387
395
397
409
410int mpcomm_send_malloc(void **ptr, size_t size);
411
421
422int mpcomm_send_free(void *ptr);
423
432
433int mpcomm_send_error(int err);
434
443
444int mpcomm_send_log(char *log);
445
446#endif /* __MODULES_INCLUDE_MPCOMM_MPCOMM_H */
int16_t cpuid_t
Definition types.h:64
struct mpmq mpmq_t
void(* mpcomm_user_func_t)(void *data)
Definition mpcomm.h:120
int mpcomm_wait_helpers_done(void)
int mpcomm_get_helpers_num(void)
int mpcomm_send_error(int err)
struct helper_info helper_info_t
struct mpcomm_free_msg mpcomm_free_msg_t
int mpcomm_send_log(char *log)
int mpcomm_send_helper(uint8_t helper_index, void *data)
int mpcomm_main(mpcomm_user_func_t controller_user_func, mpcomm_user_func_t helper_user_func)
int mpcomm_send_free(void *ptr)
int mpcomm_send_malloc(void **ptr, size_t size)
struct mpcomm_malloc_msg mpcomm_malloc_msg_t
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)
struct mpcomm_init_msg mpcomm_init_msg_t
struct mpcomm_context mpcomm_context_t
struct mpcomm_error_msg mpcomm_error_msg_t
bool mpcomm_is_controller(void)
struct mpcomm_log_msg mpcomm_log_msg_t
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