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