#include <stdbool.h>
#include <asmp/types.h>
#include <asmp/mpmq.h>
Go to the source code of this file.
◆ MPCOMM_MSG_ID_INIT
| #define MPCOMM_MSG_ID_INIT 1 |
The helper and controller initialization message ID.
◆ MPCOMM_MSG_ID_DEINIT
| #define MPCOMM_MSG_ID_DEINIT 2 |
The helper and controller deinitialization message ID.
◆ MPCOMM_MSG_ID_USER_FUNC
| #define MPCOMM_MSG_ID_USER_FUNC 3 |
Message ID to send user data to controller and helper.
◆ MPCOMM_MSG_ID_DONE
| #define MPCOMM_MSG_ID_DONE 4 |
Message ID confirming that the message has been processed.
◆ MPCOMM_MSG_ID_MALLOC
| #define MPCOMM_MSG_ID_MALLOC 5 |
Message ID to request malloc() from supervisor.
◆ MPCOMM_MSG_ID_FREE
| #define MPCOMM_MSG_ID_FREE 6 |
Message ID to request free() from supervisor.
◆ MPCOMM_MSG_ID_ERROR
| #define MPCOMM_MSG_ID_ERROR 7 |
Message ID to send error code to supervisor.
◆ MPCOMM_MSG_ID_LOG
| #define MPCOMM_MSG_ID_LOG 8 |
Message ID to send log message to supervisor.
◆ MPCOMM_MAX_HELPERS
| #define MPCOMM_MAX_HELPERS 4 |
Maximum number of helpers.
◆ MPCOMM_CPUID_MAX
| #define MPCOMM_CPUID_MAX 8 |
◆ MPCOMM_MODE_CONTROLLER
| #define MPCOMM_MODE_CONTROLLER 0 |
◆ MPCOMM_MODE_HELPER
| #define MPCOMM_MODE_HELPER 1 |
◆ MEM_V2P
Convert address from virtual to physical
◆ mpcomm_user_func_t
| typedef void(* mpcomm_user_func_t) (void *data) |
Definition of callback function.
User-defined callback that is called by mpcomm_main() after receiving data from the supervisor or controller.
- Parameters
-
◆ helper_info_t
◆ mpcomm_context_t
◆ mpcomm_init_msg_t
◆ mpcomm_malloc_msg_t
◆ mpcomm_free_msg_t
◆ mpcomm_error_msg_t
◆ mpcomm_log_msg_t
◆ mpcomm_main()
Start the MPCOMM framework on the controller or the helper. The user can register a callbacks that will handle the data received from the supervisor and controller.
- Parameters
-
| [in] | controller_user_func | User-defined callback for the contoller. |
| [in] | helper_user_func | User-defined callback for the helper. |
- Returns
- On success, 0 is returned. On failure, negative value is returned according to <errno.h>.
◆ mpcomm_send_helper()
| int mpcomm_send_helper |
( |
uint8_t |
helper_index, |
|
|
void * |
data |
|
) |
| |
Send the user data to the helper for processing.
- Parameters
-
| [in] | helper_index | Helper index. |
| [in] | data | User data. |
- Returns
- On success, 0 is returned. On failure, negative value is returned according to <errno.h>.
◆ mpcomm_wait_helper_done()
| int mpcomm_wait_helper_done |
( |
uint8_t |
helper_index | ) |
|
Wait until user data has been processed by helper.
- Parameters
-
| [in] | helper_index | Helper index. |
- Returns
- On success, 0 is returned. On failure, negative value is returned according to <errno.h>.
◆ mpcomm_wait_helpers_done()
| int mpcomm_wait_helpers_done |
( |
void |
| ) |
|
Wait until user data has been processed by all helpers.
- Returns
- On success, 0 is returned. On failure, negative value is returned according to <errno.h>.
◆ mpcomm_get_helpers_num()
| int mpcomm_get_helpers_num |
( |
void |
| ) |
|
Return number of helpers.
- Returns
- Number of helpers.
◆ mpcomm_is_controller()
| bool mpcomm_is_controller |
( |
void |
| ) |
|
Return true if it is controller. Otherwise, return false.
- Returns
- True, if it is controller.
◆ mpcomm_memory_virt_to_phys()
| void * mpcomm_memory_virt_to_phys |
( |
void * |
addr | ) |
|
Convert address from virtual to physical.
- Parameters
-
- Returns
- Physical address.
◆ mpcomm_send_malloc()
| int mpcomm_send_malloc |
( |
void ** |
ptr, |
|
|
size_t |
size |
|
) |
| |
Send a request to the supervisor to call malloc() and save the address of the allocated memory in the ptr.
- Parameters
-
| [out] | ptr | The address of the allocated memory received from the supervisor. |
| [in] | size | Requested size. |
- Returns
- On success, 0 is returned. On failure, negative value is returned according to <errno.h>.
◆ mpcomm_send_free()
| int mpcomm_send_free |
( |
void * |
ptr | ) |
|
Send a request to the supervisor to call free() on the ptr.
- Parameters
-
| [in] | ptr | The address of the allocated memory to be freed by the supervisor. |
- Returns
- On success, 0 is returned. On failure, negative value is returned according to <errno.h>.
◆ mpcomm_send_error()
| int mpcomm_send_error |
( |
int |
err | ) |
|
Send the error number to the supervisor.
- Parameters
-
- Returns
- On success, 0 is returned. On failure, negative value is returned according to <errno.h>.
◆ mpcomm_send_log()
| int mpcomm_send_log |
( |
char * |
log | ) |
|
Send the log for printing by supervisor.
- Parameters
-
| [in] | log | Log to be printed. |
- Returns
- On success, 0 is returned. On failure, negative value is returned according to <errno.h>.