fix: separate any i/o to sequential device from caching layer
[lunaix-os.git] / lunaix-os / includes / lunaix / device.h
1 #ifndef __LUNAIX_DEVICE_H
2 #define __LUNAIX_DEVICE_H
3
4 #define DEVICE_NAME_SIZE 32
5
6 #include <lunaix/ds/hstr.h>
7 #include <lunaix/ds/llist.h>
8
9 struct device
10 {
11     struct llist_header dev_list;
12     struct device* parent;
13     struct hstr name;
14     char name_val[DEVICE_NAME_SIZE];
15     void* underlay;
16     void* fs_node;
17     int (*read)(struct device* dev,
18                 void* buf,
19                 unsigned int offset,
20                 unsigned int len);
21     int (*write)(struct device* dev,
22                  void* buf,
23                  unsigned int offset,
24                  unsigned int len);
25 };
26
27 void
28 device_init();
29
30 struct device*
31 device_addseq(struct device* parent, void* underlay, char* name_fmt, ...);
32
33 struct device*
34 device_addvol(struct device* parent, void* underlay, char* name_fmt, ...);
35
36 void
37 device_remove(struct device* dev);
38
39 #endif /* __LUNAIX_DEVICE_H */