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>
9 #define DEV_MSKIF 0x00000003
11 #define DEV_IFVOL 0x0 // volumetric (block) device
12 #define DEV_IFSEQ 0x1 // sequential (character) device
13 #define DEV_IFCAT 0x2 // a device category (as device groupping)
15 typedef unsigned int dev_t;
19 struct llist_header siblings;
20 struct device* parent;
24 char name_val[DEVICE_NAME_SIZE];
26 int (*read)(struct device* dev, void* buf, size_t offset, size_t len);
27 int (*write)(struct device* dev, void* buf, size_t offset, size_t len);
31 device_addseq(struct device* parent, void* underlay, char* name_fmt, ...);
34 device_addvol(struct device* parent, void* underlay, char* name_fmt, ...);
37 device_addcat(struct device* parent, char* name_fmt, ...);
40 device_remove(struct device* dev);
43 device_getbyid(struct llist_header* devlist, dev_t id);
46 device_getbyname(struct llist_header* devlist, struct hstr* name);
49 device_getbyoffset(struct llist_header* devlist, int pos);
51 #endif /* __LUNAIX_DEVICE_H */