dev: implement writing/reading input events to/from input devices

This commit is contained in:
2023-05-10 20:33:40 +01:00
parent ad8865fe66
commit 05395542a8
4 changed files with 242 additions and 0 deletions

View File

@@ -4,11 +4,15 @@
#include <socks/queue.h>
#include <socks/status.h>
#include <socks/object.h>
#include <socks/ringbuffer.h>
struct device;
struct input_event;
#define DEV_NAME_MAX OBJECT_NAME_MAX
#define INPUT_DEVICE_EVENT_QUEUE_SIZE 128
#define BLOCK_DEVICE(dev) ((dev)->dev_type == DEV_TYPE_BLOCK ? &(dev)->blk : NULL);
#define CHAR_DEVICE(dev) ((dev)->dev_type == DEV_TYPE_CHAR ? &(dev)->chr : NULL);
#define NET_DEVICE(dev) ((dev)->dev_type == DEV_TYPE_NET ? &(dev)->net : NULL);
@@ -63,6 +67,7 @@ struct net_device {
struct input_device {
struct input_device_ops *i_ops;
struct ringbuffer i_events;
};
struct bus_device {
@@ -103,6 +108,11 @@ static inline void device_unlock_irqrestore(struct device *dev, unsigned long fl
object_unlock(&dev->dev_base, flags);
}
extern kern_status_t device_read(struct device *dev, void *buf, size_t size, size_t *bytes_read);
extern kern_status_t device_write(struct device *dev, const void *buf, size_t size, size_t *bytes_written);
extern struct device *cast_to_device(struct object *obj);
extern struct char_device *char_device_create(void);
extern struct block_device *block_device_create(void);
extern struct net_device *net_device_create(void);
@@ -136,4 +146,7 @@ static inline struct device *bus_device_base(struct bus_device *dev)
extern kern_status_t device_register(struct device *dev, struct device *parent);
extern kern_status_t input_device_report_event(struct input_device *dev, const struct input_event *ev, bool noblock);
extern kern_status_t input_device_read(struct device *dev, void *buf, size_t size, size_t *bytes_read);
#endif