Files
magenta/include/kernel/msg.h
T
2026-04-30 20:30:36 +01:00

59 lines
1.1 KiB
C

#ifndef KERNEL_MSG_H_
#define KERNEL_MSG_H_
#include <kernel/btree.h>
#include <kernel/locks.h>
#include <magenta/status.h>
#include <magenta/types.h>
struct port;
struct thread;
enum kmsg_status {
KMSG_WAIT_RECEIVE,
KMSG_WAIT_REPLY,
KMSG_REPLY_SENT,
KMSG_ASYNC,
};
struct msg {
spin_lock_t msg_lock;
enum kmsg_status msg_status;
struct btree_node msg_node;
msgid_t msg_id;
union {
/* only valid for asynchronous messages (msg_status ==
* KMSG_ASYNC) */
struct {
koid_t msg_sender_port_id;
tid_t msg_sender_thread_id;
};
/* only valid for synchronous messages (msg_status !=
* KMSG_ASYNC) */
struct {
struct port *msg_sender_port;
struct thread *msg_sender_thread;
};
};
kern_status_t msg_result;
kern_msg_type_t msg_type;
union {
/* msg_type = KERN_MSG_TYPE_DATA */
struct {
kern_msg_t msg_req, msg_resp;
};
/* msg_type = KERN_MSG_TYPE_EVENT */
struct {
kern_msg_event_type_t msg_event;
};
};
};
extern void msg_init(void);
extern struct msg *msg_alloc(void);
extern void msg_free(struct msg *msg);
#endif