X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/blobdiff_plain/a36758a5018f6a3792c164cd2a313d4f61b7111e..f6ab9c9ababa2cf6e5c723b83ffb9362094054e8:/lunaix-os/includes/lunaix/device.h diff --git a/lunaix-os/includes/lunaix/device.h b/lunaix-os/includes/lunaix/device.h index fd234f0..2634d81 100644 --- a/lunaix-os/includes/lunaix/device.h +++ b/lunaix-os/includes/lunaix/device.h @@ -4,9 +4,18 @@ #define DEVICE_NAME_SIZE 32 #include +#include #include +#include #include +/** + * @brief Export pseudo device + * + */ +#define EXPORT_PSEUDODEV(id, init_fn) \ + export_ldga_el(pseudo_dev, id, ptr_t, init_fn) + #define DEV_STRUCT_MAGIC 0x5645444c #define DEV_MSKIF 0x00000003 @@ -14,34 +23,44 @@ #define DEV_IFVOL 0x0 // volumetric (block) device #define DEV_IFSEQ 0x1 // sequential (character) device #define DEV_IFCAT 0x2 // a device category (as device groupping) +#define DEV_IFSYS 0x3 // a system device typedef unsigned int dev_t; struct device { - uint32_t magic; + u32_t magic; struct llist_header siblings; struct llist_header children; struct device* parent; + // TODO investigate event polling + struct hstr name; dev_t dev_id; int dev_type; char name_val[DEVICE_NAME_SIZE]; void* underlay; - int (*read)(struct device* dev, void* buf, size_t offset, size_t len); - int (*write)(struct device* dev, void* buf, size_t offset, size_t len); - int (*read_page)(struct device* dev, void* buf, size_t offset); - int (*write_page)(struct device* dev, void* buf, size_t offset); - int (*exec_cmd)(struct device* dev, uint32_t req, va_list args); + + struct + { + int (*read)(struct device* dev, void* buf, size_t offset, size_t len); + int (*write)(struct device* dev, void* buf, size_t offset, size_t len); + int (*read_page)(struct device* dev, void* buf, size_t offset); + int (*write_page)(struct device* dev, void* buf, size_t offset); + int (*exec_cmd)(struct device* dev, u32_t req, va_list args); + } ops; }; struct device* device_add(struct device* parent, void* underlay, char* name_fmt, - uint32_t type, + u32_t type, va_list args); +struct device* +device_addsys(struct device* parent, void* underlay, char* name_fmt, ...); + struct device* device_addseq(struct device* parent, void* underlay, char* name_fmt, ...); @@ -66,4 +85,7 @@ device_getbyname(struct device* root_dev, const char* name, size_t len); struct device* device_getbyoffset(struct device* root_dev, int pos); +void +device_install_pseudo(); + #endif /* __LUNAIX_DEVICE_H */