dev: start implementing framebuffer devices
This commit is contained in:
25
dev/core.c
25
dev/core.c
@@ -19,6 +19,19 @@ static kern_status_t device_object_get_child_named(struct object *, const char *
|
||||
|
||||
extern kern_status_t init_driver_tree(void);
|
||||
|
||||
extern struct device_type_ops input_type_ops;
|
||||
extern struct device_type_ops framebuffer_type_ops;
|
||||
|
||||
static struct device_type_ops *type_ops[] = {
|
||||
[DEV_TYPE_UNKNOWN] = NULL,
|
||||
[DEV_TYPE_BLOCK] = NULL,
|
||||
[DEV_TYPE_CHAR] = NULL,
|
||||
[DEV_TYPE_NET] = NULL,
|
||||
[DEV_TYPE_INPUT] = &input_type_ops,
|
||||
[DEV_TYPE_BUS] = NULL,
|
||||
[DEV_TYPE_FRAMEBUFFER] = &framebuffer_type_ops,
|
||||
};
|
||||
|
||||
static struct object_type device_type = {
|
||||
.ob_name = "device",
|
||||
.ob_size = sizeof(struct device),
|
||||
@@ -60,7 +73,7 @@ kern_status_t device_init(void)
|
||||
struct bus_device *system_dev = bus_device_create();
|
||||
struct device *system_dev_base = bus_device_base(system_dev);
|
||||
snprintf(system_dev_base->dev_name, sizeof system_dev_base->dev_name, "system");
|
||||
__root_device = bus_device_base(system_dev);
|
||||
set_root_device(bus_device_base(system_dev));
|
||||
|
||||
struct bus_device *misc_dev = bus_device_create();
|
||||
struct device *misc_dev_base = bus_device_base(misc_dev);
|
||||
@@ -236,14 +249,12 @@ kern_status_t device_register(struct device *dev, struct driver *owner, struct d
|
||||
|
||||
driver_add_device(owner, dev);
|
||||
|
||||
switch (dev->dev_type) {
|
||||
case DEV_TYPE_INPUT:
|
||||
status = input_device_register(INPUT_DEVICE(dev));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
if (type_ops[dev->dev_type] && type_ops[dev->dev_type]->register_device) {
|
||||
status = type_ops[dev->dev_type]->register_device(dev);
|
||||
}
|
||||
|
||||
/* TODO remove device if registration failed */
|
||||
|
||||
driver_unlock(owner);
|
||||
device_unlock_irqrestore(dev, flags);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user