Valid 3 code version
This commit is contained in:
@@ -131,14 +131,14 @@ bool ipc_msg_get_nth_arg(struct IpcMsg* msg, const int arg_num, void* data, cons
|
||||
return true;
|
||||
}
|
||||
|
||||
void ipc_msg_send_wait(struct IpcMsg* msg)
|
||||
void ipc_msg_send_wait(struct Session* session, struct IpcMsg* msg)
|
||||
{
|
||||
msg->header.magic = IPC_MSG_MAGIC;
|
||||
msg->header.valid = 1;
|
||||
msg->header.done = 0;
|
||||
while (msg->header.done == 0) {
|
||||
/// @todo syscall yield with prio decrease
|
||||
yield(SYS_TASK_YIELD_BLOCK_IPC);
|
||||
wait_session_call(session);
|
||||
}
|
||||
assert(msg->header.done == 1);
|
||||
}
|
||||
@@ -155,7 +155,7 @@ int ipc_session_wait(struct Session* session)
|
||||
struct IpcMsg* msg = IPCSESSION_MSG(session);
|
||||
while (msg->header.done == 0) {
|
||||
/// @todo syscall yield with prio decrease
|
||||
yield(SYS_TASK_YIELD_BLOCK_IPC);
|
||||
wait_session_call(session);
|
||||
}
|
||||
assert(msg->header.done == 1);
|
||||
return msg->header.ret_val;
|
||||
|
||||
@@ -180,7 +180,7 @@ __attribute__((__always_inline__)) static inline bool ipc_session_forward(struct
|
||||
struct IpcMsg* new_ipc_msg(struct Session* session, const int argc, const int* arg_size);
|
||||
bool ipc_msg_set_nth_arg(struct IpcMsg* msg, const int arg_num, const void* const data, const int len);
|
||||
bool ipc_msg_get_nth_arg(struct IpcMsg* msg, const int arg_num, void* data, const int len);
|
||||
void ipc_msg_send_wait(struct IpcMsg* msg);
|
||||
void ipc_msg_send_wait(struct Session* session, struct IpcMsg* msg);
|
||||
void ipc_msg_send_nowait(struct IpcMsg* msg);
|
||||
int ipc_session_wait(struct Session* session);
|
||||
|
||||
@@ -230,7 +230,7 @@ void ipc_server_loop(struct IpcNode* ipc_node);
|
||||
struct IpcMsg* msg = IPC_CREATE_MSG_FUNC(ipc_name)(session, _VA_FRONT_ARG##argc(__VA_ARGS__)); \
|
||||
int ret = IPC_MSG_ARGS_COPY_SET_FUNC(ipc_name)(msg, _VA_FRONT_ARG##argc(__VA_ARGS__)); \
|
||||
ret = ipc_msg_set_opcode(msg, ipc_name); \
|
||||
ipc_msg_send_wait(msg); \
|
||||
ipc_msg_send_wait(session, msg); \
|
||||
ret = IPC_MSG_ARGS_COPY_GET_FUNC(ipc_name)(msg, _VA_FRONT_ARG##argc(__VA_ARGS__)); \
|
||||
int32_t res = 0; \
|
||||
ipc_msg_get_return(msg, &res); \
|
||||
@@ -278,9 +278,10 @@ uintptr_t _ipc_buf_to_addr(char* buf);
|
||||
char addr_buf[17]; \
|
||||
_ipc_addr_to_buf((uintptr_t)msg, addr_buf); \
|
||||
char* param[] = { #ipc_name, addr_buf, NULL }; \
|
||||
msg->header.handling = 1; \
|
||||
int tid = thread(IPC_THREAD_SERVE(ipc_name), #ipc_name, param); \
|
||||
if (tid > 0) { \
|
||||
msg->header.handling = 1; \
|
||||
if (tid <= 0) { \
|
||||
msg->header.handling = 0; \
|
||||
} \
|
||||
return 0; \
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ Modification:
|
||||
#include "libserial.h"
|
||||
|
||||
struct Session {
|
||||
int id;
|
||||
uintptr_t id;
|
||||
int capacity;
|
||||
int head;
|
||||
int tail;
|
||||
|
||||
@@ -72,6 +72,11 @@ int close_session(struct Session* session)
|
||||
return syscall(SYSCALL_CLOSE_SESSION, (intptr_t)session, 0, 0, 0);
|
||||
}
|
||||
|
||||
int wait_session_call(struct Session* userland_session)
|
||||
{
|
||||
return syscall(SYSCALL_WAIT_SESSION, (intptr_t)userland_session, 0, 0, 0);
|
||||
}
|
||||
|
||||
int get_memblock_info(sys_state_info* info)
|
||||
{
|
||||
return syscall(SYSCALL_SYS_STATE, SYS_STATE_MEMBLOCK_INFO, (intptr_t)info, 0, 0);
|
||||
|
||||
@@ -35,6 +35,8 @@
|
||||
|
||||
#define SYSCALL_SEMAPHORE 13 // semaphore related operations
|
||||
#define SYSCALL_SLEEP 14 // sleep
|
||||
|
||||
#define SYSCALL_WAIT_SESSION 15
|
||||
// clang-format on
|
||||
|
||||
typedef enum {
|
||||
@@ -87,7 +89,8 @@ int kill(int pid);
|
||||
|
||||
int register_server(char* name);
|
||||
int session(char* path, int capacity, struct Session* user_session);
|
||||
int poll_session(struct Session* userland_session_arr, int arr_capacity);
|
||||
int poll_session(struct Session* userland_session, int arr_capacity);
|
||||
int wait_session_call(struct Session* userland_session);
|
||||
int close_session(struct Session* session);
|
||||
int register_irq(int irq, int opcode);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user