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_MSKIF 0x00000003
12 #define DEV_IFVOL 0x0 // volumetric (block) device
13 #define DEV_IFSEQ 0x1 // sequential (character) device
14 #define DEV_IFCAT 0x2 // a device category (as device groupping)
16 typedef unsigned int dev_t;
20 struct llist_header siblings;
21 struct llist_header children;
22 struct device* parent;
26 char name_val[DEVICE_NAME_SIZE];
28 int (*read)(struct device* dev, void* buf, size_t offset, size_t len);
29 int (*write)(struct device* dev, void* buf, size_t offset, size_t len);
33 device_add(struct device* parent,
40 device_addseq(struct device* parent, void* underlay, char* name_fmt, ...);
43 device_addvol(struct device* parent, void* underlay, char* name_fmt, ...);
46 device_addcat(struct device* parent, char* name_fmt, ...);
49 device_remove(struct device* dev);
52 device_getbyid(struct llist_header* devlist, dev_t id);
55 device_getbyhname(struct device* root_dev, struct hstr* name);
58 device_getbyname(struct device* root_dev, const char* name, size_t len);
61 device_getbyoffset(struct device* root_dev, int pos);
63 #endif /* __LUNAIX_DEVICE_H */