lib: msg: implement generic messave init and receive
This commit is contained in:
@@ -1,3 +1,33 @@
|
||||
void msg_tmp(void)
|
||||
#include <rosetta/msg.h>
|
||||
#include <string.h>
|
||||
|
||||
void rosetta_msg_init(
|
||||
struct rosetta_msg *msg,
|
||||
uint32_t protocol_id,
|
||||
uint16_t msg_id)
|
||||
{
|
||||
memset(msg, 0x0, sizeof *msg);
|
||||
|
||||
msg->msg_magic = ROSETTA_MSG_MAGIC;
|
||||
msg->msg_protocol = protocol_id;
|
||||
msg->msg_id = msg_id;
|
||||
}
|
||||
|
||||
kern_status_t rosetta_msg_recv(
|
||||
kern_handle_t channel,
|
||||
msgid_t *out_id,
|
||||
struct rosetta_msg *out_msg)
|
||||
{
|
||||
struct iovec iov = IOVEC(out_msg, sizeof *out_msg);
|
||||
struct msg kmsg = MSG(&iov, 1, NULL, 0);
|
||||
kern_status_t status = msg_recv(channel, 0, out_id, &kmsg);
|
||||
if (status != KERN_OK) {
|
||||
return status;
|
||||
}
|
||||
|
||||
if (out_msg->msg_magic != ROSETTA_MSG_MAGIC) {
|
||||
return KERN_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
return KERN_OK;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user