3 #ifndef LIBS_ACTIA_INCLUDE_IPC_H_
4 #define LIBS_ACTIA_INCLUDE_IPC_H_
22 #define A_IPC_MAGIC 0xA1FC600D
23 #define A_IPC_LEGACY_MSG_BUF_SIZE 512
37 uint8_t *_outbox_buffer;
45 uint8_t *_inbox_buffer;
56 #define A_IPC_ALLOC_MSG_BUFFER(name, size, modifiers) \
59 uint8_t buf[(size)]; \
60 } name##_buf __attribute__((aligned(8))) = { .msg = { .info = { \
61 ._magic = A_IPC_MAGIC, \
62 .msg_alloc_size = (size), \
64 modifiers a_ipc_msg *name = &name##_buf.msg
83 #define A_IPC_MSG_ON_STACK(name, size) A_IPC_ALLOC_MSG_BUFFER(name, (size), )
102 #define A_IPC_STATIC_MSG(name, size) A_IPC_ALLOC_MSG_BUFFER(name, (size), static)
125 #define A_IPC_STATIC_BUFFERS(name, inbox_size, outbox_size) \
126 A_IPC_STATIC_BUFFERS_BYTES( \
127 name, ((inbox_size)*A_IPC_LEGACY_MSG_BUF_SIZE), ((outbox_size)*A_IPC_LEGACY_MSG_BUF_SIZE))
147 #define A_IPC_STATIC_BUFFERS_BYTES(name, inbox_size, outbox_size) \
148 static uint8_t name##_outbox[(outbox_size)] __attribute__((aligned(8))); \
149 static uint8_t name##_inbox[(inbox_size)] __attribute__((aligned(8))); \
150 static a_ipc_buffers name = { ._outbox_buffer = name##_outbox, \
151 ._outbox_size = (outbox_size), \
152 ._inbox_buffer = name##_inbox, \
153 ._inbox_size = (inbox_size) }
176 #define A_IPC_ALLOCATE_BUFFERS(name, inbox_size, outbox_size) \
177 A_IPC_ALLOCATE_BUFFERS_BYTES( \
178 name, ((inbox_size)*A_IPC_LEGACY_MSG_BUF_SIZE), ((outbox_size)*A_IPC_LEGACY_MSG_BUF_SIZE))
198 #define A_IPC_ALLOCATE_BUFFERS_BYTES(name, inbox_size, outbox_size) \
199 a_ipc_buffers *name = (a_ipc_buffers *)malloc(sizeof(a_ipc_buffers)); \
200 if (name != NULL) { \
201 name->_outbox_size = outbox_size; \
202 name->_inbox_size = inbox_size; \
203 name->_inbox_buffer = (uint8_t *)memalign(8, name->_inbox_size); \
204 name->_outbox_buffer = (uint8_t *)memalign(8, name->_outbox_size); \
239 #define A_IPC_MAX_ID 30000
244 #define A_IPC_HOST_MIN_ID 0
245 #define A_IPC_HOST_MAX_ID 14500
253 #define A_IPC_GUEST_MIN_ID 14501
258 #define A_IPC_GUEST_MAX_ID 30000
int a_ipc_dump_stats(a_ipc_handle *handle)
Outputs information to the log about the current IPC instance.
size_t msg_used_size
How much of the message that is used - including struct members.
Definition: ipc.h:293
int type
The message type, as given by the user-provided IPC IDs file.
Definition: ipc.h:289
int a_ipc_get_fd(a_ipc_handle *handle)
Get file descriptor for selecting/polling for new messages.
A_IPC_RESULT a_ipc_send(a_ipc_handle *handle, int to, a_ipc_msg *msg)
Send an IPC message.
a_ipc_handle * a_ipc_init_ex(int id, a_ipc_buffers *buffers, unsigned int outstanding_window)
Initialize AIPC and make application available to other IPC applications.
const char * a_ipc_result_str(A_IPC_RESULT result)
Get the string representation for the given result value.
A_IPC_RESULT a_ipc_recv(a_ipc_handle *handle, int *from, a_ipc_msg *msg)
Receive an IPC message.
a_ipc_handle * a_ipc_init(int id, a_ipc_buffers *buffers)
Initialize AIPC and make application available to other IPC applications.
struct a_ipc_handle a_ipc_handle
Handle to an IPC instance.
Definition: ipc.h:270
void a_ipc_free_buffers(a_ipc_buffers *buffers)
Free the memory of a dynamically alloctated ipc inbox/outbox buffers struct.
void a_ipc_destroy(a_ipc_handle *handle)
Destroy AIPC.
size_t msg_alloc_size
Total message size - including struct members.
Definition: ipc.h:291
A_IPC_RESULT a_ipc_copy_message(a_ipc_msg *dst, const a_ipc_msg *src)
Copy an IPC message.
const char * a_ipc_msg_type_str(int msg_type)
Get the string representation (enum constant) for the given msg_type.
struct a_ipc_buffers a_ipc_buffers
Handle to a struct containing IPC inbox/outbox buffers.
Definition: ipc.h:264
A_IPC_RESULT
IPC function result codes.
Definition: ipc.h:211
@ A_IPC_RET_OK
Operation succeeded.
Definition: ipc.h:213
@ A_IPC_RET_OUT_OF_MEMORY
Not enough memory (allocated) to perform the request action.
Definition: ipc.h:231
@ A_IPC_RET_INVALID_ARGUMENT
Invalid arguments given.
Definition: ipc.h:233
@ A_IPC_RET_SEND_ERROR
Error when signaling message to be sent.
Definition: ipc.h:223
@ A_IPC_RET_MALFORMED_PACKET
Malformed packet in transport layer.
Definition: ipc.h:227
@ A_IPC_RET_NO_MSG
No message found/received.
Definition: ipc.h:221
@ A_IPC_RET_NOT_IMPLEMENTED
Functionality not implemented.
Definition: ipc.h:229
@ A_IPC_RET_BAD_TYPE
The message type is not known.
Definition: ipc.h:219
@ A_IPC_RET_ERROR
Unspecified error.
Definition: ipc.h:215
@ A_IPC_RET_BUFFER_TOO_SMALL
The provided buffer is too small.
Definition: ipc.h:217
@ A_IPC_RET_OUTBOX_FULL
Outbox full.
Definition: ipc.h:235
@ A_IPC_RET_TIMEOUT
Timeout while waiting.
Definition: ipc.h:225
IPC message basic info.
Definition: ipc.h:282
AIPC Message.
Definition: ipc_generated.h:1204