dev: implement bus device enumeration

This commit is contained in:
2023-06-09 21:24:51 +01:00
parent 27387aa080
commit 20f77893cf
4 changed files with 65 additions and 2 deletions

View File

@@ -21,6 +21,7 @@ extern kern_status_t init_driver_tree(void);
extern struct device_type_ops input_type_ops;
extern struct device_type_ops framebuffer_type_ops;
extern struct device_type_ops bus_type_ops;
static struct device_type_ops *type_ops[] = {
[DEV_TYPE_UNKNOWN] = NULL,
@@ -28,7 +29,7 @@ static struct device_type_ops *type_ops[] = {
[DEV_TYPE_CHAR] = NULL,
[DEV_TYPE_NET] = NULL,
[DEV_TYPE_INPUT] = &input_type_ops,
[DEV_TYPE_BUS] = NULL,
[DEV_TYPE_BUS] = &bus_type_ops,
[DEV_TYPE_FRAMEBUFFER] = &framebuffer_type_ops,
};
@@ -108,6 +109,18 @@ struct device *device_alloc(void)
return DEVICE_CAST(dev_object);
}
struct device *generic_device_create(void)
{
struct device *dev = device_alloc();
if (!dev) {
return NULL;
}
dev->dev_type = DEV_TYPE_UNKNOWN;
return dev;
}
kern_status_t device_read(struct device *dev, void *buf, size_t size, size_t *bytes_read, socks_flags_t flags)
{
switch (dev->dev_type) {