47 if (
kbd->writeIndex !=
file->pos)
51 return &
kbd->waitQueue;
63 if (*offset >= nameLen)
#define MAX_NAME
Maximum length of names.
#define KBD_MAX_EVENT
Maximum number of queued keyboard events.
void kbd_push(kbd_t *kbd, kbd_event_type_t type, keycode_t code)
Push a keyboard event to the keyboard event queue.
void kbd_free(kbd_t *kbd)
Free and deinitialize a keyboard structure.
kbd_t * kbd_new(const char *name)
Allocate and initialize a keyboard structure.
clock_t clock_uptime(void)
Retrieve the time in nanoseconds since boot.
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.
#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 errno
Error number variable.
poll_events_t
Poll events type.
@ POLLIN
File descriptor is ready to read.
keycode_t
Keyboard keycode type.
kbd_mods_t
Keyboard modifiers type.
kbd_event_type_t
Keyboard event type.
@ KBD_RIGHT_SUPER
Right Super key.
@ KBD_LEFT_ALT
Left Alt key.
@ KBD_LEFT_SHIFT
Left Shift key.
@ KBD_RIGHT_SHIFT
Right Shift key.
@ KBD_LEFT_CTRL
Left Control key.
@ KBD_RIGHT_ALT
Right Alt key.
@ KBD_CAPS_LOCK
Caps Lock key.
@ KBD_RIGHT_CTRL
Right Control key.
@ KBD_LEFT_SUPER
Left Super key.
@ KBD_MOD_SUPER
Super (Windows/Command) modifier.
@ KBD_MOD_CAPS
Caps Lock modifier.
@ KBD_MOD_NONE
No modifier.
@ KBD_MOD_CTRL
Control modifier.
@ KBD_MOD_ALT
Alt modifier.
@ KBD_MOD_SHIFT
Shift modifier.
@ KBD_RELEASE
Key release event.
@ KBD_PRESS
Key press event.
#define ROUND_DOWN(number, multiple)
#define NULL
Pointer error value.
#define ERR
Integer error value.
static atomic_uint64_t newId
static uint64_t kbd_name_read(file_t *file, void *buffer, uint64_t count, uint64_t *offset)
static void kbd_dir_cleanup(inode_t *inode)
static void kbd_update_mod(kbd_t *kbd, kbd_event_type_t type, kbd_mods_t mod)
static wait_queue_t * kbd_events_poll(file_t *file, poll_events_t *revents)
static file_ops_t nameOps
static inode_ops_t dirInodeOps
static file_ops_t eventsOps
static uint64_t kbd_events_read(file_t *file, void *buffer, uint64_t count, uint64_t *offset)
EFI_PHYSICAL_ADDRESS buffer
#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 free(void *ptr)
char * strdup(const char *src)
_PUBLIC size_t strlen(const char *s)
Directory entry structure.
inode_t * inode
Will be NULL if the dentry is negative, once positive it will never be NULL.
File operations structure.
uint64_t(* read)(file_t *file, void *buffer, uint64_t count, uint64_t *offset)
Inode operations structure.
void(* cleanup)(inode_t *inode)
Cleanup function called when the inode is being freed.
Keyboard event structure.
The primitive that threads block on.
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.