feat: gfxm: a layer provides user space access to low level interfacing of graphic...
[lunaix-os.git] / lunaix-os / includes / hal / hwrtc.h
1 #ifndef __LUNAIX_HWRTC_H
2 #define __LUNAIX_HWRTC_H
3
4 #include <lunaix/device.h>
5 #include <lunaix/ds/ldga.h>
6 #include <lunaix/ds/llist.h>
7 #include <lunaix/time.h>
8
9 #define RTC_STATE_MASKED 0x1
10
11 #define EXPORT_RTC_DEVICE(id, init_fn)                                         \
12     export_ldga_el(rtcdev, id, ptr_t, init_fn)
13
14 struct hwrtc
15 {
16     struct llist_header rtc_list;
17     struct device* rtc_dev;
18
19     char* name;
20     void* data;
21     ticks_t base_freq;
22     int state;
23
24     void (*get_walltime)(struct hwrtc*, datetime_t*);
25     void (*set_walltime)(struct hwrtc*, datetime_t*);
26     void (*set_mask)(struct hwrtc*);
27     void (*cls_mask)(struct hwrtc*);
28     int (*get_counts)(struct hwrtc*);
29     int (*chfreq)(struct hwrtc*, int);
30 };
31
32 extern const struct hwrtc* primary_rtc;
33
34 void
35 hwrtc_init();
36
37 struct hwrtc*
38 hwrtc_alloc_new(struct device_def* def, char* name);
39
40 void
41 hwrtc_walltime(datetime_t* dt);
42
43 #endif /* __LUNAIX_HWRTC_H */