Developer World
Spresense SDK Library
v3.3.0-375c679
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
120
typedef
void (*
mpcomm_user_func_t
)(
void
*data);
121
131
typedef
struct
helper_info
132
{
135
mpmq_t
mq
;
136
139
cpuid_t
cpuid
;
140
}
helper_info_t
;
141
152
typedef
struct
mpcomm_context
153
{
156
uint8_t
mode
;
157
160
mpmq_t
mq_2_supervisor
;
161
164
mpmq_t
mq_2_controller
;
165
168
helper_info_t
helpers
[
MPCOMM_MAX_HELPERS
];
169
172
cpu_set_t
helpers_cpuset
;
173
179
cpu_set_t
helpers_doneset
;
180
186
uint8_t
supervisor_done
;
187
190
uint8_t
helpers_num
;
191
194
mpcomm_user_func_t
controller_user_func
;
195
198
mpcomm_user_func_t
helper_user_func
;
199
202
uintptr_t
loadaddr
;
203
206
uint8_t
quit_loop
;
207
}
mpcomm_context_t
;
208
218
typedef
struct
mpcomm_init_msg
219
{
222
uint8_t
mode
;
223
226
cpuid_t
controller_cpuid
;
227
230
cpu_set_t
helpers_cpuset
;
231
234
uintptr_t
loadaddr
;
235
}
mpcomm_init_msg_t
;
236
246
typedef
struct
mpcomm_malloc_msg
247
{
250
cpuid_t
cpuid
;
251
254
void
**
ptr
;
255
258
size_t
size
;
259
}
mpcomm_malloc_msg_t
;
260
270
typedef
struct
mpcomm_free_msg
271
{
274
cpuid_t
cpuid
;
275
278
void
*
ptr
;
279
}
mpcomm_free_msg_t
;
280
290
typedef
struct
mpcomm_error_msg
291
{
294
cpuid_t
cpuid
;
295
298
int
error
;
299
}
mpcomm_error_msg_t
;
300
310
typedef
struct
mpcomm_log_msg
311
{
314
cpuid_t
cpuid
;
315
318
char
*
log
;
319
}
mpcomm_log_msg_t
;
320
321
/****************************************************************************
322
* Public Function Prototypes
323
****************************************************************************/
324
337
int
mpcomm_main
(
mpcomm_user_func_t
controller_user_func,
338
mpcomm_user_func_t
helper_user_func);
339
350
int
mpcomm_send_helper
(uint8_t helper_index,
void
*data);
351
361
int
mpcomm_wait_helper_done
(uint8_t helper_index);
362
370
int
mpcomm_wait_helpers_done
(
void
);
371
378
int
mpcomm_get_helpers_num
(
void
);
379
386
bool
mpcomm_is_controller
(
void
);
387
396
void
*
mpcomm_memory_virt_to_phys
(
void
*addr);
397
410
int
mpcomm_send_malloc
(
void
**ptr,
size_t
size);
411
422
int
mpcomm_send_free
(
void
*ptr);
423
433
int
mpcomm_send_error
(
int
err);
434
444
int
mpcomm_send_log
(
char
*log);
445
446
#endif
/* __MODULES_INCLUDE_MPCOMM_MPCOMM_H */
cpuid_t
int16_t cpuid_t
Definition:
types.h:64
mpcomm_user_func_t
void(* mpcomm_user_func_t)(void *data)
Definition:
mpcomm.h:120
mpcomm_wait_helpers_done
int mpcomm_wait_helpers_done(void)
mpcomm_error_msg_t
struct mpcomm_error_msg mpcomm_error_msg_t
mpcomm_get_helpers_num
int mpcomm_get_helpers_num(void)
mpcomm_free_msg_t
struct mpcomm_free_msg mpcomm_free_msg_t
mpcomm_malloc_msg_t
struct mpcomm_malloc_msg mpcomm_malloc_msg_t
mpcomm_send_error
int mpcomm_send_error(int err)
helper_info_t
struct helper_info helper_info_t
mpcomm_log_msg_t
struct mpcomm_log_msg mpcomm_log_msg_t
mpcomm_send_log
int mpcomm_send_log(char *log)
mpcomm_send_helper
int mpcomm_send_helper(uint8_t helper_index, void *data)
mpcomm_context_t
struct mpcomm_context mpcomm_context_t
mpcomm_main
int mpcomm_main(mpcomm_user_func_t controller_user_func, mpcomm_user_func_t helper_user_func)
mpcomm_init_msg_t
struct mpcomm_init_msg mpcomm_init_msg_t
mpcomm_send_free
int mpcomm_send_free(void *ptr)
mpcomm_send_malloc
int mpcomm_send_malloc(void **ptr, size_t size)
mpcomm_wait_helper_done
int mpcomm_wait_helper_done(uint8_t helper_index)
MPCOMM_MAX_HELPERS
#define MPCOMM_MAX_HELPERS
Definition:
mpcomm.h:90
mpcomm_memory_virt_to_phys
void * mpcomm_memory_virt_to_phys(void *addr)
mpcomm_is_controller
bool mpcomm_is_controller(void)
mpmq.h
helper_info
Definition:
mpcomm.h:132
helper_info::cpuid
cpuid_t cpuid
Definition:
mpcomm.h:139
helper_info::mq
mpmq_t mq
Definition:
mpcomm.h:135
mpcomm_context
Definition:
mpcomm.h:153
mpcomm_context::mq_2_supervisor
mpmq_t mq_2_supervisor
Definition:
mpcomm.h:160
mpcomm_context::mq_2_controller
mpmq_t mq_2_controller
Definition:
mpcomm.h:164
mpcomm_context::helper_user_func
mpcomm_user_func_t helper_user_func
Definition:
mpcomm.h:198
mpcomm_context::mode
uint8_t mode
Definition:
mpcomm.h:156
mpcomm_context::helpers_doneset
cpu_set_t helpers_doneset
Definition:
mpcomm.h:179
mpcomm_context::supervisor_done
uint8_t supervisor_done
Definition:
mpcomm.h:186
mpcomm_context::controller_user_func
mpcomm_user_func_t controller_user_func
Definition:
mpcomm.h:194
mpcomm_context::loadaddr
uintptr_t loadaddr
Definition:
mpcomm.h:202
mpcomm_context::helpers_num
uint8_t helpers_num
Definition:
mpcomm.h:190
mpcomm_context::quit_loop
uint8_t quit_loop
Definition:
mpcomm.h:206
mpcomm_context::helpers
helper_info_t helpers[MPCOMM_MAX_HELPERS]
Definition:
mpcomm.h:168
mpcomm_context::helpers_cpuset
cpu_set_t helpers_cpuset
Definition:
mpcomm.h:172
mpcomm_error_msg
Definition:
mpcomm.h:291
mpcomm_error_msg::error
int error
Definition:
mpcomm.h:298
mpcomm_error_msg::cpuid
cpuid_t cpuid
Definition:
mpcomm.h:294
mpcomm_free_msg
Definition:
mpcomm.h:271
mpcomm_free_msg::cpuid
cpuid_t cpuid
Definition:
mpcomm.h:274
mpcomm_free_msg::ptr
void * ptr
Definition:
mpcomm.h:278
mpcomm_init_msg
Definition:
mpcomm.h:219
mpcomm_init_msg::mode
uint8_t mode
Definition:
mpcomm.h:222
mpcomm_init_msg::loadaddr
uintptr_t loadaddr
Definition:
mpcomm.h:234
mpcomm_init_msg::controller_cpuid
cpuid_t controller_cpuid
Definition:
mpcomm.h:226
mpcomm_init_msg::helpers_cpuset
cpu_set_t helpers_cpuset
Definition:
mpcomm.h:230
mpcomm_log_msg
Definition:
mpcomm.h:311
mpcomm_log_msg::cpuid
cpuid_t cpuid
Definition:
mpcomm.h:314
mpcomm_log_msg::log
char * log
Definition:
mpcomm.h:318
mpcomm_malloc_msg
Definition:
mpcomm.h:247
mpcomm_malloc_msg::ptr
void ** ptr
Definition:
mpcomm.h:254
mpcomm_malloc_msg::cpuid
cpuid_t cpuid
Definition:
mpcomm.h:250
mpcomm_malloc_msg::size
size_t size
Definition:
mpcomm.h:258
mpmq
Definition:
mpmq.h:77
types.h
spresense
sdk
modules
include
mpcomm
mpcomm.h
Generated by
1.9.4