refactor: one more step towards arch-agnostic design
[lunaix-os.git] / lunaix-os / kernel / device / builtin / devnull.c
1 #include <lunaix/device.h>
2 #include <lunaix/mm/page.h>
3
4 int
5 __null_wr_pg(struct device* dev, void* buf, size_t offset)
6 {
7     // do nothing
8     return PG_SIZE;
9 }
10
11 int
12 __null_wr(struct device* dev, void* buf, size_t offset, size_t len)
13 {
14     // do nothing
15     return len;
16 }
17
18 int
19 __null_rd_pg(struct device* dev, void* buf, size_t offset)
20 {
21     // do nothing
22     return 0;
23 }
24
25 int
26 __null_rd(struct device* dev, void* buf, size_t offset, size_t len)
27 {
28     // do nothing
29     return 0;
30 }
31
32 void
33 devbuiltin_init_null()
34 {
35     struct device* devnull = device_addseq(NULL, NULL, "null");
36     devnull->write_page = __null_wr_pg;
37     devnull->write = __null_wr;
38     devnull->read_page = __null_rd_pg;
39     devnull->read = __null_rd;
40 }