dev: start implementing framebuffer devices
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
#include <socks/status.h>
|
||||
#include <socks/bitmap.h>
|
||||
#include <socks/object.h>
|
||||
#include <socks/fb.h>
|
||||
#include <socks/ringbuffer.h>
|
||||
|
||||
struct device;
|
||||
@@ -19,12 +20,14 @@ struct input_event;
|
||||
|
||||
#define INPUT_DEVICE_EVENT_QUEUE_SIZE 128
|
||||
#define INPUT_DEVICE_MAX 4096
|
||||
#define FRAMEBUFFER_DEVICE_MAX 4096
|
||||
|
||||
#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)
|
||||
#define INPUT_DEVICE(dev) ((dev)->dev_type == DEV_TYPE_INPUT ? &(dev)->input : NULL)
|
||||
#define BUS_DEVICE(dev) ((dev)->dev_type == DEV_TYPE_BUS ? &(dev)->bus : NULL)
|
||||
#define FRAMEBUFFER_DEVICE(dev) ((dev)->dev_type == DEV_TYPE_FRAMEBUFFER ? &(dev)->fb : NULL)
|
||||
|
||||
enum device_type {
|
||||
DEV_TYPE_UNKNOWN = 0,
|
||||
@@ -33,6 +36,11 @@ enum device_type {
|
||||
DEV_TYPE_NET,
|
||||
DEV_TYPE_INPUT,
|
||||
DEV_TYPE_BUS,
|
||||
DEV_TYPE_FRAMEBUFFER,
|
||||
};
|
||||
|
||||
struct device_type_ops {
|
||||
kern_status_t(*register_device)(struct device *);
|
||||
};
|
||||
|
||||
struct block_device_ops {
|
||||
@@ -61,6 +69,10 @@ struct bus_device_ops {
|
||||
kern_status_t(*scan)(struct device *);
|
||||
};
|
||||
|
||||
struct framebuffer_device_ops {
|
||||
kern_status_t(*scan)(struct device *);
|
||||
};
|
||||
|
||||
struct block_device {
|
||||
struct block_device_ops *b_ops;
|
||||
};
|
||||
@@ -83,6 +95,13 @@ struct bus_device {
|
||||
struct bus_device_ops *b_ops;
|
||||
};
|
||||
|
||||
struct framebuffer_device {
|
||||
unsigned int fb_id;
|
||||
struct framebuffer_device_ops *fb_ops;
|
||||
struct framebuffer_varinfo fb_varinfo;
|
||||
struct framebuffer_fixedinfo fb_fixedinfo;
|
||||
};
|
||||
|
||||
struct device {
|
||||
struct object dev_base;
|
||||
unsigned int dev_minor;
|
||||
@@ -103,6 +122,7 @@ struct device {
|
||||
struct net_device net;
|
||||
struct input_device input;
|
||||
struct bus_device bus;
|
||||
struct framebuffer_device fb;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -160,6 +180,7 @@ extern struct block_device *block_device_create(void);
|
||||
extern struct net_device *net_device_create(void);
|
||||
extern struct input_device *input_device_create(void);
|
||||
extern struct bus_device *bus_device_create(void);
|
||||
extern struct framebuffer_device *framebuffer_device_create(void);
|
||||
|
||||
static inline struct device *char_device_base(struct char_device *dev)
|
||||
{
|
||||
@@ -186,11 +207,15 @@ static inline struct device *bus_device_base(struct bus_device *dev)
|
||||
return (struct device *)((char *)dev - offsetof(struct device, bus));
|
||||
}
|
||||
|
||||
static inline struct device *framebuffer_device_base(struct framebuffer_device *dev)
|
||||
{
|
||||
return (struct device *)((char *)dev - offsetof(struct device, fb));
|
||||
}
|
||||
|
||||
extern kern_status_t device_register(struct device *dev, struct driver *owner, 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, socks_flags_t flags);
|
||||
extern kern_status_t input_device_register(struct input_device *dev);
|
||||
|
||||
extern struct driver *driver_create(struct kext *self, const char *name);
|
||||
extern kern_status_t driver_destroy(struct driver *driver);
|
||||
|
||||
33
include/socks/fb.h
Normal file
33
include/socks/fb.h
Normal file
@@ -0,0 +1,33 @@
|
||||
#ifndef SOCKS_FB_H_
|
||||
#define SOCKS_FB_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
enum framebuffer_flags {
|
||||
FB_VGATEXT = 0x01u,
|
||||
};
|
||||
|
||||
struct framebuffer_bitfield {
|
||||
uint32_t b_offset;
|
||||
uint16_t b_length;
|
||||
};
|
||||
|
||||
struct framebuffer_varinfo {
|
||||
enum framebuffer_flags fb_flags;
|
||||
|
||||
uint32_t fb_xres;
|
||||
uint32_t fb_yres;
|
||||
uint32_t fb_bpp;
|
||||
uint32_t fb_stride;
|
||||
|
||||
struct framebuffer_bitfield fb_red;
|
||||
struct framebuffer_bitfield fb_green;
|
||||
struct framebuffer_bitfield fb_blue;
|
||||
struct framebuffer_bitfield fb_alpha;
|
||||
};
|
||||
|
||||
struct framebuffer_fixedinfo {
|
||||
uint64_t fb_baseptr;
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user