kernel: msg: implement asynchronous event messages

This commit is contained in:
2026-03-24 18:32:33 +00:00
parent 110f625f04
commit 89d02c72ee
7 changed files with 178 additions and 56 deletions

View File

@@ -4,61 +4,71 @@
#include <stddef.h>
#include <stdint.h>
#define VM_PROT_READ 0x01u
#define VM_PROT_WRITE 0x02u
#define VM_PROT_EXEC 0x04u
#define VM_PROT_USER 0x08u
#define VM_PROT_SVR 0x10u
#define VM_PROT_NOCACHE 0x10u
#define VM_PROT_MAP_SPECIFIC 0x40u
#define VM_PROT_READ 0x01u
#define VM_PROT_WRITE 0x02u
#define VM_PROT_EXEC 0x04u
#define VM_PROT_USER 0x08u
#define VM_PROT_SVR 0x10u
#define VM_PROT_NOCACHE 0x10u
#define VM_PROT_MAP_SPECIFIC 0x40u
#define MAP_ADDRESS_ANY ((virt_addr_t) - 1)
#define MAP_ADDRESS_INVALID ((virt_addr_t)0)
#define KERN_HANDLE_INVALID ((kern_handle_t)0xFFFFFFFF)
#define MAP_ADDRESS_ANY ((virt_addr_t) - 1)
#define MAP_ADDRESS_INVALID ((virt_addr_t)0)
#define KERN_HANDLE_INVALID ((kern_handle_t)0xFFFFFFFF)
/* config keys for use with kern_config_get/kern_config_set */
#define KERN_CFG_INVALID 0x00000u
#define KERN_CFG_PAGE_SIZE 0x00001u
#define KERN_CFG_INVALID 0x00000u
#define KERN_CFG_PAGE_SIZE 0x00001u
/* config keys for use with task_config_get/task_config_set */
#define TASK_CFG_INVALID 0x00000u
#define TASK_CFG_INVALID 0x00000u
/* config keys for use with thread_config_get/thread_config_set */
#define THREAD_CFG_INVALID 0x00000u
#define THREAD_CFG_FSBASE 0x20001u
#define THREAD_CFG_GSBASE 0x20002u
#define THREAD_CFG_INVALID 0x00000u
#define THREAD_CFG_FSBASE 0x20001u
#define THREAD_CFG_GSBASE 0x20002u
/* maximum number of handles that can be sent in a single message */
#define KERN_MSG_MAX_HANDLES 64
#define KERN_MSG_MAX_HANDLES 64
/* the corresponding handle should be ignored */
#define KERN_MSG_HANDLE_IGNORE 0
#define KERN_MSG_HANDLE_IGNORE 0
/* the corresponding handle should be moved to the recipient task. the handle
* will be closed. */
#define KERN_MSG_HANDLE_MOVE 1
#define KERN_MSG_HANDLE_MOVE 1
/* the corresponding handle should be copied to the recipient task. the handle
* will remain valid for the sending task. */
#define KERN_MSG_HANDLE_COPY 2
#define KERN_MSG_HANDLE_COPY 2
/* maximum number of objects that can be waited on in a single call to
* kern_object_wait */
#define KERN_WAIT_MAX_ITEMS 64
#define KERN_WAIT_MAX_ITEMS 64
/* message types */
#define KERN_MSG_TYPE_NONE 0
#define KERN_MSG_TYPE_DATA 1
#define KERN_MSG_TYPE_EVENT 2
/* event message types */
#define KERN_MSG_EVENT_NONE 0
#define KERN_MSG_EVENT_CONNECTION 1
#define KERN_MSG_EVENT_DISCONNECTION 2
/* equeue packet types */
#define EQUEUE_PKT_PAGE_REQUEST 0x01u
#define EQUEUE_PKT_ASYNC_SIGNAL 0x02u
#define EQUEUE_PKT_PAGE_REQUEST 0x01u
#define EQUEUE_PKT_ASYNC_SIGNAL 0x02u
/* page request types */
#define PAGE_REQUEST_READ 0x01u
#define PAGE_REQUEST_DIRTY 0x02u
#define PAGE_REQUEST_DETACH 0x03u
#define PAGE_REQUEST_READ 0x01u
#define PAGE_REQUEST_DIRTY 0x02u
#define PAGE_REQUEST_DETACH 0x03u
/* futex special values */
#define FUTEX_WAKE_ALL ((size_t)-1)
#define FUTEX_WAKE_ALL ((size_t)-1)
/* futex flags */
#define FUTEX_PRIVATE 0x01u
#define FUTEX_SHARED 0x02u
#define FUTEX_PRIVATE 0x01u
#define FUTEX_SHARED 0x02u
#define IOVEC(p, len) \
{ \
@@ -92,6 +102,8 @@ typedef uint32_t kern_config_key_t;
typedef uint32_t vm_prot_t;
typedef int64_t ssize_t;
typedef uint32_t kern_futex_t;
typedef uint32_t kern_msg_type_t;
typedef uint32_t kern_msg_event_type_t;
typedef unsigned short equeue_packet_type_t;
@@ -122,14 +134,27 @@ typedef struct {
tid_t msg_sender;
/* the id of the port or channel used to send a particular message. */
koid_t msg_endpoint;
/* a list of iovecs that point to the buffers that make up the main
* message data. */
kern_iovec_t *msg_data;
size_t msg_data_count;
/* a list of handle entries that contain the kernel handles included
* in a message. */
kern_msg_handle_t *msg_handles;
size_t msg_handles_count;
/* the message type */
kern_msg_type_t msg_type;
union {
/* msg_type = KERN_MSG_TYPE_DATA */
struct {
/* a list of iovecs that point to the buffers that make
* up the main message data. */
kern_iovec_t *msg_data;
size_t msg_data_count;
/* a list of handle entries that contain the kernel
* handles included in a message. */
kern_msg_handle_t *msg_handles;
size_t msg_handles_count;
};
/* msg_type = KERN_MSG_TYPE_EVENT */
struct {
kern_msg_event_type_t msg_event;
};
};
} kern_msg_t;
typedef struct {