PatchworkOS  19e446b
A non-POSIX operating system.
Loading...
Searching...
No Matches
ioring.h File Reference
#include <stdatomic.h>
#include <stddef.h>
#include <stdint.h>
#include <sys/defs.h>
#include <sys/list.h>
#include "_libstd/MAX_NAME.h"
#include "_libstd/MAX_PATH.h"
#include "_libstd/clock_t.h"
#include "_libstd/errno_t.h"
#include "_libstd/fd_t.h"
#include "_libstd/ssize_t.h"
Include dependency graph for ioring.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  sqe_t
 Asynchronous submission queue entry (SQE). More...
 
struct  cqe_t
 Asynchronous completion queue entry (CQE). More...
 
struct  ioring_t
 User I/O ring structure. More...
 

Macros

#define IO_OFF_CUR   ((ssize_t) - 1)
 Use the current file offset.
 
#define IO_SEEK_SET   (1)
 Use the start of the file.
 
#define IO_SEEK_END   (2)
 Use the end of the file.
 
#define IO_SEEK_CUR   (3)
 Use the current file offset.
 
#define IO_POLL_READ   (1 << 0)
 File descriptor is ready to read.
 
#define IO_POLL_WRITE   (1 << 1)
 File descriptor is ready to write.
 
#define IO_POLL_ERROR   (1 << 2)
 File descriptor caused an error.
 
#define IO_POLL_HUP   (1 << 3)
 File descriptor is closed.
 
#define IO_POLL_NVAL   (1 << 4)
 Invalid file descriptor.
 
#define IO_OP_NOP   0
 No-op operation.
 
#define IO_OP_READ   1
 Read operation.
 
#define IO_OP_WRITE   2
 Write operation.
 
#define IO_OP_POLL   3
 Poll operation.
 
#define IO_OP_MAX   4
 The maximum number of operation.
 
#define SQE_REG0   (0)
 The first register.
 
#define SQE_REG1   (1)
 The second register.
 
#define SQE_REG2   (2)
 The third register.
 
#define SQE_REG3   (3)
 The fourth register.
 
#define SQE_REG4   (4)
 The fifth register.
 
#define SQE_REG5   (5)
 The sixth register.
 
#define SQE_REG6   (6)
 The seventh register.
 
#define SQE_REG_NONE   (7)
 No register.
 
#define SQE_REGS_MAX   (7)
 The maximum number of registers.
 
#define SQE_REG_SHIFT   (3)
 The bitshift for each register specifier in a sqe_flags_t.
 
#define SQE_REG_MASK   (0b111)
 The bitmask for a register specifier in a sqe_flags_t.
 
#define SQE_LOAD0   (0)
 The offset to specify the register to load into the first argument.
 
#define SQE_LOAD1   (SQE_LOAD0 + SQE_REG_SHIFT)
 The offset to specify the register to load into the second argument.
 
#define SQE_LOAD2   (SQE_LOAD1 + SQE_REG_SHIFT)
 The offset to specify the register to load into the third argument.
 
#define SQE_LOAD3   (SQE_LOAD2 + SQE_REG_SHIFT)
 The offset to specify the register to load into the fourth argument.
 
#define SQE_LOAD4   (SQE_LOAD3 + SQE_REG_SHIFT)
 The offset to specify the register to load into the fifth argument.
 
#define SQE_SAVE   (SQE_LOAD4 + SQE_REG_SHIFT)
 The offset to specify the register to save the result into.
 
#define _SQE_FLAGS   (SQE_SAVE + SQE_REG_SHIFT)
 The bitshift for where bit flags start in a sqe_flags_t.
 
#define SQE_LINK   (1 << (_SQE_FLAGS))
 
#define SQE_HARDLINK   (1 << (_SQE_FLAGS + 1))
 
#define SQE_CREATE(_op, _flags, _timeout, _data)
 Macro to create an asynchronous submission queue entry (SQE).
 

Typedefs

typedef uint64_t io_whence_t
 Seek origin type.
 
typedef uint64_t io_events_t
 Poll events type.
 
typedef uint32_t io_op_t
 I/O operation code type.
 
typedef uint32_t sqe_flags_t
 Submission queue entry (SQE) flags.
 
typedef uint64_t ioring_id_t
 I/O ring ID type.
 

Functions

struct ALIGNED (64) ioring_ctrl
 
ioring_id_t ioring_setup (ioring_t *ring, void *address, size_t sentries, size_t centries)
 System call to initialize the I/O ring.
 
uint64_t ioring_teardown (ioring_id_t id)
 System call to deinitialize the I/O ring.
 
uint64_t ioring_enter (ioring_id_t id, size_t amount, size_t wait)
 System call to notify the kernel of new submission queue entries (SQEs).
 
static bool sqe_push (ioring_t *ring, sqe_t *sqe)
 Pushes a submission queue entry (SQE) to the submission queue.
 
static bool cqe_pop (ioring_t *ring, cqe_t *cqe)
 Pops a completion queue entry (CQE) from the completion queue.
 

Variables

 ioring_ctrl_t