bce0f3aff70fa062486ed28075e1e3f2e01bab42
[lunaix-os.git] / lunaix-os / kernel / device / builtin / devrand.c
1 #include <hal/rnd.h>
2 #include <lunaix/device.h>
3 #include <lunaix/mm/page.h>
4 #include <lunaix/syslog.h>
5
6 LOG_MODULE("rand")
7
8 int
9 __rand_rd_pg(struct device* dev, void* buf, size_t offset)
10 {
11     // rnd_fill(buf, PG_SIZE);
12     return PG_SIZE;
13 }
14
15 int
16 __rand_rd(struct device* dev, void* buf, size_t offset, size_t len)
17 {
18     // rnd_fill(buf, len);
19     return len;
20 }
21
22 void
23 devbuiltin_init_rand()
24 {
25     // TODO rnd device need better abstraction
26     if (1) {
27         kprintf(KWARN "not supported.\n");
28         return;
29     }
30     struct device* devrand = device_addseq(NULL, NULL, "rand");
31     devrand->read = __rand_rd;
32     devrand->read_page = __rand_rd_pg;
33 }