kernel: add equeue object

equeue is a way for the kernel to deliver events to userspace programs.
This commit is contained in:
2026-03-12 20:37:51 +00:00
parent 7d4cede788
commit 3fd608b623
4 changed files with 149 additions and 15 deletions

View File

@@ -4,24 +4,44 @@
#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 VM_REGION_ANY_OFFSET ((off_t) - 1)
#define KERN_HANDLE_INVALID ((kern_handle_t)0xFFFFFFFF)
#define VM_REGION_ANY_OFFSET ((off_t) - 1)
#define KERN_HANDLE_INVALID ((kern_handle_t)0xFFFFFFFF)
#define KERN_CFG_INVALID 0x00u
#define KERN_CFG_PAGE_SIZE 0x01u
#define KERN_CFG_INVALID 0x00u
#define KERN_CFG_PAGE_SIZE 0x01u
#define KERN_MSG_MAX_HANDLES 64
#define KERN_MSG_HANDLE_IGNORE 0
#define KERN_MSG_HANDLE_MOVE 1
#define KERN_MSG_HANDLE_COPY 2
/* maximum number of handles that can be sent in a single message */
#define KERN_MSG_MAX_HANDLES 64
/* the corresponding handle should be ignored */
#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
/* 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
/* maximum number of objects that can be waited on in a single call to
* kern_object_wait */
#define KERN_WAIT_MAX_ITEMS 64
/* equeue packet types */
#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 IOVEC(p, len) \
{ \
@@ -46,13 +66,17 @@ typedef uintptr_t virt_addr_t;
typedef uint64_t msgid_t;
typedef uint64_t off_t;
typedef uint64_t koid_t;
typedef uintptr_t equeue_key_t;
typedef unsigned int tid_t;
typedef unsigned int vm_controller_packet_type_t;
typedef unsigned int kern_status_t;
typedef uint32_t kern_handle_t;
typedef uint32_t kern_config_key_t;
typedef uint32_t vm_prot_t;
typedef int64_t ssize_t;
typedef unsigned short equeue_packet_type_t;
typedef unsigned int umode_t;
typedef struct {
@@ -60,6 +84,12 @@ typedef struct {
size_t io_len;
} kern_iovec_t;
typedef struct {
kern_handle_t w_handle;
uint32_t w_waitfor;
uint32_t w_observed;
} kern_wait_item_t;
typedef struct {
unsigned int hnd_mode;
kern_handle_t hnd_value;
@@ -84,4 +114,36 @@ typedef struct {
size_t msg_handles_count;
} kern_msg_t;
typedef struct {
uint32_t s_observed;
} equeue_packet_async_signal_t;
typedef struct {
/* the key of the vm-object for which the page request relates, as
* specified when the vm-object was created */
equeue_key_t req_vmo;
/* page request type. one of PAGE_REQUEST_* */
unsigned short req_type;
/* of the offset into the vm-object for which pages are being requested
*/
off_t req_offset;
/* the length in bytes of the region being requested */
size_t req_length;
} equeue_packet_page_request_t;
typedef struct {
/* the type of packet. one of EQUEUE_PKT_* */
equeue_packet_type_t p_type;
/* the key of the object that is responsible for the event, as specified
* when the event was first subscribed to */
equeue_key_t p_key;
union {
/* p_type = EQUEUE_PKT_PAGE_REQUEST */
equeue_packet_page_request_t page_request;
/* p_type = EQUEUE_PKT_ASYNC_SIGNAL */
equeue_packet_async_signal_t async_signal;
};
} equeue_packet_t;
#endif