PatchworkOS  19e446b
A non-POSIX operating system.
Loading...
Searching...
No Matches
I/O Subsystem

I/O Subsystem. More...

Collaboration diagram for I/O Subsystem:

Detailed Description

I/O Subsystem.

The I/O subsystem is responsible for asynchronous input and output operations within PatchworkOS.

Modules

 I/O Request Packet
 I/O Request Packet.
 
 Kernel-side I/O Ring Interface
 Programmable submission/completion interface.
 

Data Structures

struct  sqe_t
 Asynchronous submission queue entry (SQE). More...
 
struct  cqe_t
 Asynchronous completion queue entry (CQE). More...
 
struct  ioring_ctrl_t
 Shared ring control 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.
 

Functions

struct ALIGNED (64) ioring_ctrl
 

Variables

 ioring_ctrl_t
 

Macro Definition Documentation

◆ IO_OFF_CUR

#define IO_OFF_CUR   ((ssize_t) - 1)

Use the current file offset.

Definition at line 27 of file ioring.h.

◆ IO_SEEK_SET

#define IO_SEEK_SET   (1)

Use the start of the file.

Definition at line 30 of file ioring.h.

◆ IO_SEEK_END

#define IO_SEEK_END   (2)

Use the end of the file.

Definition at line 31 of file ioring.h.

◆ IO_SEEK_CUR

#define IO_SEEK_CUR   (3)

Use the current file offset.

Definition at line 32 of file ioring.h.

◆ IO_POLL_READ

#define IO_POLL_READ   (1 << 0)

File descriptor is ready to read.

Definition at line 35 of file ioring.h.

◆ IO_POLL_WRITE

#define IO_POLL_WRITE   (1 << 1)

File descriptor is ready to write.

Definition at line 36 of file ioring.h.

◆ IO_POLL_ERROR

#define IO_POLL_ERROR   (1 << 2)

File descriptor caused an error.

Definition at line 37 of file ioring.h.

◆ IO_POLL_HUP

#define IO_POLL_HUP   (1 << 3)

File descriptor is closed.

Definition at line 38 of file ioring.h.

◆ IO_POLL_NVAL

#define IO_POLL_NVAL   (1 << 4)

Invalid file descriptor.

Definition at line 39 of file ioring.h.

◆ IO_OP_NOP

#define IO_OP_NOP   0

No-op operation.

Definition at line 42 of file ioring.h.

◆ IO_OP_READ

#define IO_OP_READ   1

Read operation.

Definition at line 43 of file ioring.h.

◆ IO_OP_WRITE

#define IO_OP_WRITE   2

Write operation.

Definition at line 44 of file ioring.h.

◆ IO_OP_POLL

#define IO_OP_POLL   3

Poll operation.

Definition at line 45 of file ioring.h.

◆ IO_OP_MAX

#define IO_OP_MAX   4

The maximum number of operation.

Definition at line 46 of file ioring.h.

◆ SQE_REG0

#define SQE_REG0   (0)

The first register.

Definition at line 49 of file ioring.h.

◆ SQE_REG1

#define SQE_REG1   (1)

The second register.

Definition at line 50 of file ioring.h.

◆ SQE_REG2

#define SQE_REG2   (2)

The third register.

Definition at line 51 of file ioring.h.

◆ SQE_REG3

#define SQE_REG3   (3)

The fourth register.

Definition at line 52 of file ioring.h.

◆ SQE_REG4

#define SQE_REG4   (4)

The fifth register.

Definition at line 53 of file ioring.h.

◆ SQE_REG5

#define SQE_REG5   (5)

The sixth register.

Definition at line 54 of file ioring.h.

◆ SQE_REG6

#define SQE_REG6   (6)

The seventh register.

Definition at line 55 of file ioring.h.

◆ SQE_REG_NONE

#define SQE_REG_NONE   (7)

No register.

Definition at line 56 of file ioring.h.

◆ SQE_REGS_MAX

#define SQE_REGS_MAX   (7)

The maximum number of registers.

Definition at line 57 of file ioring.h.

◆ SQE_REG_SHIFT

#define SQE_REG_SHIFT   (3)

The bitshift for each register specifier in a sqe_flags_t.

Definition at line 58 of file ioring.h.

◆ SQE_REG_MASK

#define SQE_REG_MASK   (0b111)

The bitmask for a register specifier in a sqe_flags_t.

Definition at line 59 of file ioring.h.

◆ SQE_LOAD0

#define SQE_LOAD0   (0)

The offset to specify the register to load into the first argument.

Definition at line 61 of file ioring.h.

◆ SQE_LOAD1

#define SQE_LOAD1   (SQE_LOAD0 + SQE_REG_SHIFT)

The offset to specify the register to load into the second argument.

Definition at line 62 of file ioring.h.

◆ SQE_LOAD2

#define SQE_LOAD2   (SQE_LOAD1 + SQE_REG_SHIFT)

The offset to specify the register to load into the third argument.

Definition at line 63 of file ioring.h.

◆ SQE_LOAD3

#define SQE_LOAD3   (SQE_LOAD2 + SQE_REG_SHIFT)

The offset to specify the register to load into the fourth argument.

Definition at line 64 of file ioring.h.

◆ SQE_LOAD4

#define SQE_LOAD4   (SQE_LOAD3 + SQE_REG_SHIFT)

The offset to specify the register to load into the fifth argument.

Definition at line 65 of file ioring.h.

◆ SQE_SAVE

#define SQE_SAVE   (SQE_LOAD4 + SQE_REG_SHIFT)

The offset to specify the register to save the result into.

Definition at line 66 of file ioring.h.

◆ _SQE_FLAGS

#define _SQE_FLAGS   (SQE_SAVE + SQE_REG_SHIFT)

The bitshift for where bit flags start in a sqe_flags_t.

Definition at line 68 of file ioring.h.

◆ SQE_LINK

#define SQE_LINK   (1 << (_SQE_FLAGS))

Only process the next SQE when this one completes successfully) only applies within one enter() call.

Definition at line 73 of file ioring.h.

◆ SQE_HARDLINK

#define SQE_HARDLINK   (1 << (_SQE_FLAGS + 1))

Like SQE_LINK but will process the next SQE even if this one fails.

Definition at line 77 of file ioring.h.

◆ SQE_CREATE

#define SQE_CREATE (   _op,
  _flags,
  _timeout,
  _data 
)
Value:
{ \
.op = (_op), \
.flags = (_flags), \
.timeout = (_timeout), \
.data = (void*)(_data), \
}
static fd_t data
Definition dwm.c:21
static const path_flag_t flags[]
Definition path.c:47

Macro to create an asynchronous submission queue entry (SQE).

Parameters
_opThe operation to perform.
_flagsSubmission flags.
_timeoutTimeout for the operation, CLOCKS_NEVER for no timeout.
_dataPrivate data for the operation.

Definition at line 128 of file ioring.h.

Typedef Documentation

◆ io_whence_t

Seek origin type.

Definition at line 29 of file ioring.h.

◆ io_events_t

Poll events type.

Definition at line 34 of file ioring.h.

◆ io_op_t

typedef uint32_t io_op_t

I/O operation code type.

Definition at line 41 of file ioring.h.

◆ sqe_flags_t

Submission queue entry (SQE) flags.

Definition at line 48 of file ioring.h.

Function Documentation

◆ ALIGNED()

struct ALIGNED ( 64  )

< Submission head index, updated by the kernel.

< Completion tail index, updated by the kernel.

< Submission tail index, updated by userspace.

< Completion head index, updated by userspace.

< General purpose registers.

Definition at line 48 of file ioring.h.

Variable Documentation

◆ ioring_ctrl_t

Definition at line 180 of file ioring.h.