2026-02-23 21:56:16 +00:00
|
|
|
#include <rosetta/msg.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
|
|
void rosetta_msg_init(
|
|
|
|
|
struct rosetta_msg *msg,
|
|
|
|
|
uint32_t protocol_id,
|
|
|
|
|
uint16_t msg_id)
|
2026-02-19 19:29:17 +00:00
|
|
|
{
|
2026-02-23 21:56:16 +00:00
|
|
|
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;
|
2026-02-19 19:29:17 +00:00
|
|
|
}
|