10#if defined(__cplusplus)
27#define IO_OFF_CUR ((ssize_t) - 1)
30#define IO_SEEK_SET (1)
31#define IO_SEEK_END (2)
32#define IO_SEEK_CUR (3)
35#define IO_POLL_READ (1 << 0)
36#define IO_POLL_WRITE (1 << 1)
37#define IO_POLL_ERROR (1 << 2)
38#define IO_POLL_HUP (1 << 3)
39#define IO_POLL_NVAL (1 << 4)
56#define SQE_REG_NONE (7)
57#define SQE_REGS_MAX (7)
58#define SQE_REG_SHIFT (3)
59#define SQE_REG_MASK (0b111)
62#define SQE_LOAD1 (SQE_LOAD0 + SQE_REG_SHIFT)
63#define SQE_LOAD2 (SQE_LOAD1 + SQE_REG_SHIFT)
64#define SQE_LOAD3 (SQE_LOAD2 + SQE_REG_SHIFT)
65#define SQE_LOAD4 (SQE_LOAD3 + SQE_REG_SHIFT)
66#define SQE_SAVE (SQE_LOAD4 + SQE_REG_SHIFT)
68#define _SQE_FLAGS (SQE_SAVE + SQE_REG_SHIFT)
73#define SQE_LINK (1 << (_SQE_FLAGS))
77#define SQE_HARDLINK (1 << (_SQE_FLAGS + 1))
117static_assert(
sizeof(
sqe_t) == 64,
"sqe_t is not 64 bytes");
128#define SQE_CREATE(_op, _flags, _timeout, _data) \
132 .timeout = (_timeout), \
133 .data = (void*)(_data), \
158static_assert(
sizeof(
cqe_t) == 32,
"cqe_t is not 32 bytes");
170typedef struct ALIGNED(64) ioring_ctrl
172 atomic_uint32_t shead;
173 atomic_uint32_t ctail;
174 uint8_t _padding0[64 -
sizeof(atomic_uint32_t) * 2];
175 atomic_uint32_t stail;
176 atomic_uint32_t chead;
177 uint8_t _padding1[64 -
sizeof(atomic_uint32_t) * 2];
261 if ((tail - head) >= ring->
sentries)
297#if defined(__cplusplus)
static uintptr_t address
Mapped virtual address of the HPET registers.
uint32_t io_op_t
I/O operation code type.
#define SQE_REGS_MAX
The maximum number of registers.
uint64_t io_whence_t
Seek origin type.
uint64_t io_events_t
Poll events type.
uint32_t sqe_flags_t
Submission queue entry (SQE) flags.
#define ALIGNED(alignment)
GCC aligned attribute.
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).
uint64_t ioring_teardown(ioring_id_t id)
System call to deinitialize the I/O ring.
uint64_t ioring_id_t
I/O ring ID type.
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.
ioring_id_t ioring_setup(ioring_t *ring, void *address, size_t sentries, size_t centries)
System call to initialize the I/O ring.
__INT64_TYPE__ ssize_t
Signed size type.
__UINT64_TYPE__ fd_t
File descriptor type.
__UINT64_TYPE__ clock_t
A nanosecond time.
#define atomic_load_explicit(object, order)
#define atomic_store_explicit(object, desired, order)
Asynchronous completion queue entry (CQE).
errno_t error
Error code, if not equal to EOK an error occurred.
io_op_t op
The operation that was performed.
void * data
Private data from the submission entry.
Shared ring control structure.
ioring_ctrl_t * ctrl
Pointer to the shared control structure.
sqe_t * squeue
Pointer to the submission queue.
size_t smask
Bitmask for submission queue (sentries - 1).
cqe_t * cqueue
Pointer to the completion queue.
size_t cmask
Bitmask for completion queue (centries - 1).
size_t sentries
Number of entries in the submission queue.
size_t centries
Number of entries in the completion queue.
ioring_id_t id
The ID of the ring.
Asynchronous submission queue entry (SQE).
void * data
Private data for the operation, will be returned in the completion entry.
io_op_t op
The operation to perform.
clock_t timeout
Timeout for the operation, CLOCKS_NEVER for no timeout.
sqe_flags_t flags
Submission flags.