28 if (private->buffer ==
NULL)
34 private->isReadClosed =
false;
35 private->isWriteClosed =
false;
39 private->readEnd =
file;
40 private->writeEnd =
file;
54 if (private->buffer ==
NULL)
60 private->isReadClosed =
false;
61 private->isWriteClosed =
false;
68 files[0]->private =
private;
69 files[1]->private =
private;
77 if (private->readEnd ==
file)
79 private->isReadClosed =
true;
81 if (private->writeEnd ==
file)
83 private->isWriteClosed =
true;
87 if (private->isWriteClosed && private->isReadClosed)
107 if (private->readEnd !=
file)
142 if (private->writeEnd !=
file)
162 if (private->isReadClosed)
194 return &
private->waitQueue;
211 panic(
NULL,
"Failed to initialize pipe directory");
217 panic(
NULL,
"Failed to initialize pipe new file");
NORETURN void panic(const interrupt_frame_t *frame, const char *format,...)
Panic the kernel, printing a message and halting.
void pmm_free(void *address)
Frees a single physical page.
void * pmm_alloc(void)
Allocates a single physical page.
uint64_t wait_unblock(wait_queue_t *waitQueue, uint64_t amount, errno_t err)
Unblock threads waiting on a wait queue.
void wait_queue_init(wait_queue_t *waitQueue)
Initialize wait queue.
#define WAIT_ALL
Wait for all.
#define WAIT_BLOCK_LOCK(waitQueue, lock, condition)
Block with a spinlock.
void wait_queue_deinit(wait_queue_t *waitQueue)
Deinitialize wait queue.
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.
static uint64_t ring_write(ring_t *ring, const void *buffer, uint64_t count)
Write data to the ring buffer.
static uint64_t ring_free_length(const ring_t *ring)
Get the length of free space in the ring buffer.
static uint64_t ring_data_length(const ring_t *ring)
Get the length of data currently stored in the ring buffer.
static uint64_t ring_read(ring_t *ring, void *buffer, uint64_t count)
Read data from the ring buffer.
static void ring_init(ring_t *ring, void *buffer, uint64_t size)
Initialize a ring buffer.
#define EINVAL
Invalid argument.
#define EPIPE
Broken pipe.
#define ENOTSUP
Operation not supported.
#define errno
Error number variable.
#define PIPE_READ
Pipe read end.
#define PIPE_WRITE
Pipe write end.
poll_events_t
Poll events type.
@ POLLIN
File descriptor is ready to read.
@ POLLOUT
File descriptor is ready to write.
#define PAGE_SIZE
Memory page size.
#define NULL
Pointer error value.
#define ERR
Integer error value.
EFI_PHYSICAL_ADDRESS buffer
static uint64_t pipe_open(file_t *file)
static dentry_t * pipeDir
static void pipe_close(file_t *file)
static uint64_t pipe_write(file_t *file, const void *buffer, uint64_t count, uint64_t *offset)
static dentry_t * newFile
static uint64_t pipe_open2(file_t *files[2])
static file_ops_t fileOps
static uint64_t pipe_read(file_t *file, void *buffer, uint64_t count, uint64_t *offset)
static wait_queue_t * pipe_poll(file_t *file, poll_events_t *revents)
_PUBLIC void * malloc(size_t size)
_PUBLIC void free(void *ptr)
Directory entry structure.
File operations structure.
uint64_t(* open)(file_t *file)
dentry_t * sysfs_dir_new(dentry_t *parent, const char *name, const inode_ops_t *inodeOps, void *private)
Create a new directory inside a mounted SysFS instance.
dentry_t * sysfs_file_new(dentry_t *parent, const char *name, const inode_ops_t *inodeOps, const file_ops_t *fileOps, void *private)
Create a new file inside a mounted SysFS instance.