PatchworkOS
Loading...
Searching...
No Matches
kbd.c File Reference
#include <kernel/drivers/abstractions/kbd.h>
#include <kernel/fs/file.h>
#include <kernel/fs/sysfs.h>
#include <kernel/fs/vfs.h>
#include <kernel/sched/timer.h>
#include <kernel/sync/lock.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/io.h>
#include <sys/math.h>
#include <sys/proc.h>

Go to the source code of this file.

Functions

static uint64_t kbd_events_read (file_t *file, void *buffer, uint64_t count, uint64_t *offset)
 
static wait_queue_tkbd_events_poll (file_t *file, poll_events_t *revents)
 
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)
 
kbd_tkbd_new (const char *name)
 Allocate and initialize a keyboard structure.
 
void kbd_free (kbd_t *kbd)
 Free and deinitialize a keyboard structure.
 
static void kbd_update_mod (kbd_t *kbd, kbd_event_type_t type, kbd_mods_t mod)
 
void kbd_push (kbd_t *kbd, kbd_event_type_t type, keycode_t code)
 Push a keyboard event to the keyboard event queue.
 

Variables

static dentry_tkbdDir = NULL
 
static atomic_uint64_t newId = ATOMIC_VAR_INIT(0)
 
static file_ops_t eventsOps
 
static file_ops_t nameOps
 
static inode_ops_t dirInodeOps
 

Function Documentation

◆ kbd_dir_cleanup()

static void kbd_dir_cleanup ( inode_t inode)
static

Definition at line 74 of file kbd.c.

References free(), kbd, inode_t::private, wait_queue_deinit(), and kbd_t::waitQueue.

◆ kbd_events_poll()

static wait_queue_t * kbd_events_poll ( file_t file,
poll_events_t revents 
)
static

◆ kbd_events_read()

static uint64_t kbd_events_read ( file_t file,
void *  buffer,
uint64_t  count,
uint64_t offset 
)
static

◆ kbd_name_read()

static uint64_t kbd_name_read ( file_t file,
void *  buffer,
uint64_t  count,
uint64_t offset 
)
static

Definition at line 58 of file kbd.c.

References buffer, BUFFER_READ, count, file, dentry_t::inode, kbd, MAX_NAME, kbd_t::name, inode_t::private, and strnlen_s().

◆ kbd_update_mod()

static void kbd_update_mod ( kbd_t kbd,
kbd_event_type_t  type,
kbd_mods_t  mod 
)
static

Definition at line 160 of file kbd.c.

References kbd, KBD_PRESS, KBD_RELEASE, and kbd_t::mods.

Referenced by kbd_push().

Variable Documentation

◆ dirInodeOps

inode_ops_t dirInodeOps
static
Initial value:
= {
.cleanup = kbd_dir_cleanup,
}
static void kbd_dir_cleanup(inode_t *inode)
Definition kbd.c:74

Definition at line 81 of file kbd.c.

Referenced by kbd_new().

◆ eventsOps

file_ops_t eventsOps
static
Initial value:
= {
.read = kbd_events_read,
.poll = kbd_events_poll,
}
static wait_queue_t * kbd_events_poll(file_t *file, poll_events_t *revents)
Definition kbd.c:42
static uint64_t kbd_events_read(file_t *file, void *buffer, uint64_t count, uint64_t *offset)
Definition kbd.c:21

Definition at line 53 of file kbd.c.

Referenced by kbd_new().

◆ kbdDir

dentry_t* kbdDir = NULL
static

Definition at line 17 of file kbd.c.

Referenced by kbd_new().

◆ nameOps

file_ops_t nameOps
static
Initial value:
= {
.read = kbd_name_read,
}
static uint64_t kbd_name_read(file_t *file, void *buffer, uint64_t count, uint64_t *offset)
Definition kbd.c:58

Definition at line 70 of file kbd.c.

Referenced by kbd_new().

◆ newId

atomic_uint64_t newId = ATOMIC_VAR_INIT(0)
static

Definition at line 19 of file kbd.c.

Referenced by kbd_new().