124 return &
kbd->waitQueue;
174 kbd->name[
sizeof(
kbd->name) - 1] =
'\0';
260 int length =
snprintf(event,
sizeof(event),
"%u_", code);
263 LOG_ERR(
"failed to format keyboard press event\n");
278 int length =
snprintf(event,
sizeof(event),
"%u^", code);
281 LOG_ERR(
"failed to format keyboard release event\n");
#define MAX_NAME
Maximum length of names.
#define assert(expression)
EFI_PHYSICAL_ADDRESS buffer
void kbd_release(kbd_t *kbd, keycode_t code)
Push a keyboard release event to the keyboard event queue.
void kbd_press(kbd_t *kbd, keycode_t code)
Push a keyboard press event to the keyboard event queue.
void kbd_free(kbd_t *kbd)
Frees a keyboard.
kbd_t * kbd_new(const char *name)
Allocate and initialize a new keyboard.
uint64_t devfs_files_new(list_t *out, dentry_t *parent, const devfs_file_desc_t *descs)
Create multiple files in a devfs directory.
void devfs_files_free(list_t *files)
Free all files in a list created by devfs_files_new().
dentry_t * devfs_dir_new(dentry_t *parent, const char *name, const vnode_ops_t *vnodeOps, void *data)
Create a new directory inside a mounted devfs instance.
#define LOG_ERR(format,...)
uint64_t wait_unblock(wait_queue_t *queue, uint64_t amount, errno_t err)
Unblock threads waiting on a wait queue.
void wait_queue_deinit(wait_queue_t *queue)
Deinitialize wait queue.
#define WAIT_ALL
Used to indicate that the wait should unblock all waiting threads.
void wait_queue_init(wait_queue_t *queue)
Initialize wait queue.
#define WAIT_BLOCK_LOCK(queue, lock, condition)
Blocks until the condition is true, condition will be tested on every wakeup. Will release the lock b...
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 size_t fifo_read(fifo_t *fifo, void *buffer, size_t count)
Read data from a fifo buffer at a specific offset.
static size_t fifo_bytes_writeable(const fifo_t *fifo)
Return the number of bytes available for writing in a fifo buffer.
static void fifo_init(fifo_t *fifo, uint8_t *buffer, size_t size)
Initialize a fifo buffer.
static size_t fifo_write(fifo_t *fifo, const void *buffer, size_t count)
Write data to the fifo buffer.
static size_t fifo_bytes_readable(const fifo_t *fifo)
Return the number of bytes available for reading in a fifo buffer.
#define UNREF(ptr)
Decrement reference count.
#define BUFFER_READ(buffer, count, offset, src, size)
Helper macros for implementing file operations dealing with simple buffers.
#define EINVAL
Invalid argument.
#define ENOMEM
Out of memory.
#define errno
Error number variable.
#define UNUSED(x)
Mark a variable as unused.
poll_events_t
Poll events type.
@ POLLIN
File descriptor is ready to read.
keycode_t
Keyboard keycode type.
#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 void list_push_back(list_t *list, list_entry_t *entry)
Pushes an entry to the end of 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.
static atomic_uint64_t newId
static size_t kbd_events_read(file_t *file, void *buffer, size_t count, size_t *offset)
static size_t kbd_name_read(file_t *file, void *buffer, size_t count, size_t *offset)
static void kbd_events_close(file_t *file)
static void kbd_dir_cleanup(vnode_t *vnode)
static wait_queue_t * kbd_events_poll(file_t *file, poll_events_t *revents)
static file_ops_t nameOps
static file_ops_t eventsOps
static vnode_ops_t dirVnodeOps
static uint64_t kbd_events_open(file_t *file)
static void kbd_broadcast(kbd_t *kbd, const char *string, size_t length)
#define ATOMIC_VAR_INIT(value)
#define atomic_fetch_add(object, operand)
_PUBLIC int snprintf(char *_RESTRICT s, size_t n, const char *_RESTRICT format,...)
_PUBLIC void * calloc(size_t nmemb, size_t size)
_PUBLIC void * malloc(size_t size)
_PUBLIC void free(void *ptr)
_PUBLIC char * strncpy(char *_RESTRICT s1, const char *_RESTRICT s2, size_t n)
_PUBLIC size_t strlen(const char *s)
Directory entry structure.
Descriptor for batch file creation.
File operations structure.
size_t(* read)(file_t *file, void *buffer, size_t count, size_t *offset)
uint64_t(* open)(file_t *file)
Keyboard event client structure.
uint8_t buffer[KBD_CLIENT_BUFFER_SIZE]
vnode operations structure.
void(* cleanup)(vnode_t *vnode)
Cleanup function called when the vnode is being freed.
void * data
Filesystem defined data.
The primitive that threads block on.