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