51 for (
size_t i = 0; i < size; i++)
85 if (irp->deadline < entry->deadline)
178 if (irp->deadline > now)
194 else if (handler !=
NULL)
226 assert(irp->index == idx);
256 mdl_t* mdl = &irp->mdl;
#define assert(expression)
#define SELF_PTR(ptr)
Macro to get a pointer to a percpu variable on the current CPU.
#define SELF
Macro to access data in the current cpu.
#define CPU_PTR(id, ptr)
Macro to get a pointer to a percpu variable on a specific CPU.
#define PERCPU_DEFINE_CTOR(type, name)
Macro to define a percpu variable with a constructor.
uint16_t cpu_id_t
Type used to identify a CPU.
#define CPU_ID_INVALID
Invalid CPU ID.
void irp_timeouts_check(void)
Check and handle expired IRP timeouts on the current CPU.
#define IRP_CANCELLED
Sentinel value indicating that the IRP has been cancelled.
void irp_complete(irp_t *irp)
Complete the current frame in the IRP stack.
irp_t * irp_new(irp_pool_t *pool)
Allocate a new IRP from a pool.
static irp_frame_t * irp_current(irp_t *irp)
Retrieve the current frame in the IRP stack.
uint64_t(* irp_cancel_t)(irp_t *irp)
IRP cancellation callback type.
#define IRP_FRAME_MAX
The maximum number of frames in a IRP stack.
irp_pool_t * irp_pool_new(size_t size, process_t *process, void *ctx)
Allocate a new IRP pool.
void irp_call_direct(irp_t *irp, irp_func_t func)
Send an IRP to a specified function directly.
static irp_cancel_t irp_set_cancel(irp_t *irp, irp_cancel_t cancel)
Set the cancellation callback for an IRP.
void irp_pool_free(irp_pool_t *pool)
Free a IRP pool.
static void irp_error(irp_t *irp, uint8_t err)
Helper to set an error code and complete the IRP.
static process_t * irp_get_process(irp_t *irp)
Retrieve the process that owns an IRP.
static irp_pool_t * irp_get_pool(irp_t *irp)
Retrieve the IRP pool that an IRP was allocated from.
void irp_call(irp_t *irp, vnode_t *vnode)
Send an IRP to a specified vnode.
void irp_timeout_remove(irp_t *irp)
Remove an IRP from its per-CPU timeout queue.
uint64_t irp_cancel(irp_t *irp)
Attempt to cancel an IRP.
void(* irp_func_t)(irp_t *irp)
IRP function type.
mdl_t * irp_get_mdl(irp_t *irp, const void *addr, size_t size)
Retrieve a memory descriptor list and associate it with an IRP.
void irp_timeout_add(irp_t *irp, clock_t timeout)
Add an IRP to a per-CPU timeout queue.
void mdl_free_chain(mdl_t *mdl, void(*free)(void *))
Free a Memory Descriptor List chain.
void mdl_deinit(mdl_t *mdl)
Deinitialize a Memory Descriptor List.
static void mdl_init(mdl_t *next, mdl_t *prev)
Initialize a Memory Descriptor List.
uint64_t mdl_add(mdl_t *mdl, space_t *space, const void *addr, size_t size)
Add a memory region to the Memory Descriptor List.
pool_idx_t pool_alloc(pool_t *pool)
Allocate an element from the pool.
void pool_free(pool_t *pool, pool_idx_t idx)
Free an element back to the pool.
#define POOL_IDX_MAX
The maximum index value for pool.
void pool_init(pool_t *pool, void *elements, size_t capacity, size_t elementSize, size_t nextOffset)
Initialize a pool.
uint16_t pool_idx_t
Pool index type.
clock_t clock_uptime(void)
Retrieve the time in nanoseconds since boot.
static void lock_init(lock_t *lock)
Initializes a lock.
#define LOCK_SCOPE(lock)
Acquires a lock for the reminder of the current scope.
static void lock_release(lock_t *lock)
Releases a lock.
static void lock_acquire(lock_t *lock)
Acquires a lock, blocking until it is available.
void timer_set(clock_t now, clock_t deadline)
Schedule a one-shot timer interrupt on the current CPU.
#define REF(ptr)
Increment reference count.
#define UNREF(ptr)
Decrement reference count.
#define ENOSPC
No space left on device.
#define EINVAL
Invalid argument.
#define ENOSYS
Function not implemented.
#define ETIMEDOUT
Connection timed out.
#define ENOMEM
Out of memory.
#define EBUSY
Device or resource busy.
#define ECANCELED
Operation Canceled.
#define errno
Error number variable.
#define UNLIKELY(x)
Mark a condition as unlikely.
#define LIST_FOR_EACH(elem, list, member)
Iterates over a list.
static void list_remove(list_entry_t *entry)
Removes a list entry from its current list.
static list_entry_t * list_first(list_t *list)
Gets the first entry in the list without removing it.
static void list_push_back(list_t *list, list_entry_t *entry)
Pushes an entry to the end of the list.
static void list_prepend(list_entry_t *head, list_entry_t *entry)
Prepends an entry to the list.
static void list_entry_init(list_entry_t *entry)
Initializes a list entry.
static void list_init(list_t *list)
Initializes a list.
#define NULL
Pointer error value.
#define ERR
Integer error value.
#define CONTAINER_OF_SAFE(ptr, type, member)
Safe container of macro.
#define CLOCKS_DEADLINE(timeout, uptime)
Safely calculate deadline from timeout.
__UINT64_TYPE__ clock_t
A nanosecond time.
static void irp_perform_completion(irp_t *irp)
#define atomic_store(object, desired)
#define atomic_exchange(object, desired)
#define atomic_fetch_sub(object, operand)
#define atomic_store_explicit(object, desired, order)
#define atomic_fetch_add(object, operand)
#define atomic_init(obj, value)
#define offsetof(type, member)
_PUBLIC void * malloc(size_t size)
_PUBLIC void free(void *ptr)
_PUBLIC void * memset(void *s, int c, size_t n)
IRP stack frame structure.
vnode_t * vnode
Vnode associated with the operation.
irp_complete_t complete
Completion callback.
irp_major_t major
Major function number.
process_t * process
Will only hold a reference if there is at least one active IRP.
I/O Request Packet structure.
irp_func_t funcs[IRP_MJ_MAX]
A simple ticket lock implementation.
Memory Descriptor List structure.
uint32_t amount
Number of memory segments.
struct mdl * next
Pointer to the next MDL.
const irp_vtable_t * vtable