1 #ifndef __LUNAIX_DEVICE_H
2 #define __LUNAIX_DEVICE_H
4 #define DEVICE_NAME_SIZE 32
6 #include <lunaix/ds/hstr.h>
7 #include <lunaix/ds/llist.h>
8 #include <lunaix/types.h>
10 #define DEV_STRUCT_MAGIC 0x5645444c
12 #define DEV_MSKIF 0x00000003
14 #define DEV_IFVOL 0x0 // volumetric (block) device
15 #define DEV_IFSEQ 0x1 // sequential (character) device
16 #define DEV_IFCAT 0x2 // a device category (as device groupping)
18 typedef unsigned int dev_t;
23 struct llist_header siblings;
24 struct llist_header children;
25 struct device* parent;
29 char name_val[DEVICE_NAME_SIZE];
31 int (*read)(struct device* dev, void* buf, size_t offset, size_t len);
32 int (*write)(struct device* dev, void* buf, size_t offset, size_t len);
33 int (*exec_cmd)(struct device* dev, uint32_t req, va_list args);
37 device_add(struct device* parent,
44 device_addseq(struct device* parent, void* underlay, char* name_fmt, ...);
47 device_addvol(struct device* parent, void* underlay, char* name_fmt, ...);
50 device_addcat(struct device* parent, char* name_fmt, ...);
53 device_remove(struct device* dev);
56 device_getbyid(struct llist_header* devlist, dev_t id);
59 device_getbyhname(struct device* root_dev, struct hstr* name);
62 device_getbyname(struct device* root_dev, const char* name, size_t len);
65 device_getbyoffset(struct device* root_dev, int pos);
67 #endif /* __LUNAIX_DEVICE_H */