1 /*
2 * Copyright (c) 2022 Bjarki Arge Andreasen
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7 #include <zephyr/drivers/rtc.h>
8 #include <zephyr/internal/syscall_handler.h>
9
z_vrfy_rtc_set_time(const struct device * dev,const struct rtc_time * timeptr)10 static inline int z_vrfy_rtc_set_time(const struct device *dev, const struct rtc_time *timeptr)
11 {
12 K_OOPS(K_SYSCALL_DRIVER_RTC(dev, set_time));
13 K_OOPS(K_SYSCALL_MEMORY_READ(timeptr, sizeof(struct rtc_time)));
14 return z_impl_rtc_set_time(dev, timeptr);
15 }
16 #include <syscalls/rtc_set_time_mrsh.c>
17
z_vrfy_rtc_get_time(const struct device * dev,struct rtc_time * timeptr)18 static inline int z_vrfy_rtc_get_time(const struct device *dev, struct rtc_time *timeptr)
19 {
20 K_OOPS(K_SYSCALL_DRIVER_RTC(dev, get_time));
21 K_OOPS(K_SYSCALL_MEMORY_WRITE(timeptr, sizeof(struct rtc_time)));
22 return z_impl_rtc_get_time(dev, timeptr);
23 }
24 #include <syscalls/rtc_get_time_mrsh.c>
25
26 #ifdef CONFIG_RTC_ALARM
z_vrfy_rtc_alarm_get_supported_fields(const struct device * dev,uint16_t id,uint16_t * mask)27 static inline int z_vrfy_rtc_alarm_get_supported_fields(const struct device *dev, uint16_t id,
28 uint16_t *mask)
29 {
30 K_OOPS(K_SYSCALL_DRIVER_RTC(dev, alarm_get_supported_fields));
31 K_OOPS(K_SYSCALL_MEMORY_WRITE(mask, sizeof(uint16_t)));
32 return z_impl_rtc_alarm_get_supported_fields(dev, id, mask);
33 }
34 #include <syscalls/rtc_alarm_get_supported_fields_mrsh.c>
35
z_vrfy_rtc_alarm_set_time(const struct device * dev,uint16_t id,uint16_t mask,const struct rtc_time * timeptr)36 static inline int z_vrfy_rtc_alarm_set_time(const struct device *dev, uint16_t id, uint16_t mask,
37 const struct rtc_time *timeptr)
38 {
39 K_OOPS(K_SYSCALL_DRIVER_RTC(dev, alarm_set_time));
40 K_OOPS(K_SYSCALL_MEMORY_READ(timeptr, sizeof(struct rtc_time)));
41 return z_impl_rtc_alarm_set_time(dev, id, mask, timeptr);
42 }
43 #include <syscalls/rtc_alarm_set_time_mrsh.c>
44
z_vrfy_rtc_alarm_get_time(const struct device * dev,uint16_t id,uint16_t * mask,struct rtc_time * timeptr)45 static inline int z_vrfy_rtc_alarm_get_time(const struct device *dev, uint16_t id, uint16_t *mask,
46 struct rtc_time *timeptr)
47 {
48 K_OOPS(K_SYSCALL_DRIVER_RTC(dev, alarm_get_time));
49 K_OOPS(K_SYSCALL_MEMORY_WRITE(mask, sizeof(uint16_t)));
50 K_OOPS(K_SYSCALL_MEMORY_WRITE(timeptr, sizeof(struct rtc_time)));
51 return z_impl_rtc_alarm_get_time(dev, id, mask, timeptr);
52 }
53 #include <syscalls/rtc_alarm_get_time_mrsh.c>
54
z_vrfy_rtc_alarm_is_pending(const struct device * dev,uint16_t id)55 static inline int z_vrfy_rtc_alarm_is_pending(const struct device *dev, uint16_t id)
56 {
57 K_OOPS(K_SYSCALL_DRIVER_RTC(dev, alarm_is_pending));
58 return z_impl_rtc_alarm_is_pending(dev, id);
59 }
60 #include <syscalls/rtc_alarm_is_pending_mrsh.c>
61 #endif /* CONFIG_RTC_ALARM */
62
63 #ifdef CONFIG_RTC_CALIBRATION
z_vrfy_rtc_set_calibration(const struct device * dev,int32_t calibration)64 static inline int z_vrfy_rtc_set_calibration(const struct device *dev, int32_t calibration)
65 {
66 K_OOPS(K_SYSCALL_DRIVER_RTC(dev, set_calibration));
67 return z_impl_rtc_set_calibration(dev, calibration);
68 }
69
70 #include <syscalls/rtc_set_calibration_mrsh.c>
71
z_vrfy_rtc_get_calibration(const struct device * dev,int32_t * calibration)72 static inline int z_vrfy_rtc_get_calibration(const struct device *dev, int32_t *calibration)
73 {
74 K_OOPS(K_SYSCALL_DRIVER_RTC(dev, get_calibration));
75 K_OOPS(K_SYSCALL_MEMORY_WRITE(calibration, sizeof(int32_t)));
76 return z_impl_rtc_get_calibration(dev, calibration);
77 }
78 #include <syscalls/rtc_get_calibration_mrsh.c>
79 #endif /* CONFIG_RTC_CALIBRATION */
80