Decoupling Architectural-specific Code (#35)
[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     int id;
20     char* name;
21     void* data;
22     ticks_t base_freq;
23     int state;
24
25     void (*get_walltime)(struct hwrtc*, datetime_t*);
26     void (*set_walltime)(struct hwrtc*, datetime_t*);
27     void (*set_mask)(struct hwrtc*);
28     void (*cls_mask)(struct hwrtc*);
29     int (*get_counts)(struct hwrtc*);
30     int (*chfreq)(struct hwrtc*, int);
31 };
32
33 struct hwrtc*
34 hwrtc_alloc_new(char* name);
35
36 void
37 hwrtc_walltime(datetime_t* dt);
38
39 void
40 hwrtc_register(struct devclass* class, struct hwrtc* rtc);
41
42 #endif /* __LUNAIX_HWRTC_H */