]> git.ipfire.org Git - thirdparty/util-linux.git/blame - sys-utils/hwclock.h
hwclock: cleanup hwclock_params[] use
[thirdparty/util-linux.git] / sys-utils / hwclock.h
CommitLineData
9abb2685
KZ
1#ifndef HWCLOCK_CLOCK_H
2#define HWCLOCK_CLOCK_H
3
7eda085c 4#include <stdio.h>
66ee8158 5#include <stdlib.h>
7eda085c 6#include <string.h>
f2ff0adf 7#include <sys/time.h>
7eda085c
KZ
8#include <time.h>
9
b940bae3 10#include "c.h"
ff4e18bd 11#include "debug.h"
6097b12d 12#include "nls.h"
ff4e18bd
WP
13
14#define HWCLOCK_DEBUG_INIT (1 << 0)
15#define HWCLOCK_DEBUG_RANDOM_SLEEP (1 << 1)
16#define HWCLOCK_DEBUG_DELTA_VS_TARGET (1 << 2)
17#define HWCLOCK_DEBUG_ALL 0xFFFF
18
19UL_DEBUG_DECLARE_MASK(hwclock);
20#define DBG(m, x) __UL_DBG(hwclock, HWCLOCK_DEBUG_, m, x)
21#define ON_DBG(m, x) __UL_DBG_CALL(hwclock, HWCLOCK_DEBUG_, m, x)
b940bae3 22
336f7c5f
SK
23struct hwclock_control {
24 char *date_opt;
336f7c5f 25 char *adj_file_name;
df4f1a66 26 double rtc_delay; /* --delay <seconds> */
039a0cec 27#if defined(__linux__) && defined(__alpha__)
f7599b4f 28 char *epoch_option;
039a0cec 29#endif
336f7c5f
SK
30#ifdef __linux__
31 char *rtc_dev_name;
32#endif
6097b12d 33 char *param_get_option;
b22b78b1 34 char *param_set_option;
336f7c5f 35 unsigned int
336f7c5f 36 hwaudit_on:1,
336f7c5f 37 adjust:1,
336f7c5f
SK
38 show:1,
39 hctosys:1,
40 utc:1,
41 systohc:1,
039a0cec 42#if defined(__linux__) && defined(__alpha__)
336f7c5f
SK
43 getepoch:1,
44 setepoch:1,
45#endif
46 noadjfile:1,
47 local_opt:1,
336f7c5f
SK
48 directisa:1,
49 testing:1,
50 systz:1,
51 predict:1,
52 get:1,
53 set:1,
54 update:1,
ff4e18bd
WP
55 universal:1, /* will store hw_clock_is_utc() return value */
56 verbose:1;
336f7c5f
SK
57};
58
7eda085c
KZ
59struct clock_ops {
60 char *interface_name;
ef71b8f1 61 int (*get_permissions) (void);
336f7c5f
SK
62 int (*read_hardware_clock) (const struct hwclock_control *ctl, struct tm * tm);
63 int (*set_hardware_clock) (const struct hwclock_control *ctl, const struct tm * tm);
64 int (*synchronize_to_clock_tick) (const struct hwclock_control *ctl);
df4f1a66 65 const char *(*get_device_path) (void);
7eda085c
KZ
66};
67
68extern struct clock_ops *probe_for_cmos_clock(void);
336f7c5f 69extern struct clock_ops *probe_for_rtc_clock(const struct hwclock_control *ctl);
7eda085c 70
7eda085c 71/* hwclock.c */
982a4a5d 72extern double time_diff(struct timeval subtrahend, struct timeval subtractor);
7eda085c
KZ
73
74/* rtc.c */
039a0cec 75#if defined(__linux__) && defined(__alpha__)
af68bd01 76extern int get_epoch_rtc(const struct hwclock_control *ctl, unsigned long *epoch);
336f7c5f 77extern int set_epoch_rtc(const struct hwclock_control *ctl);
039a0cec 78#endif
88058a71 79
6097b12d
BK
80struct rtc_param {
81 uint64_t param;
82 union {
83 uint64_t uvalue;
84 int64_t svalue;
85 uint64_t ptr;
86 };
87 uint32_t index;
88 uint32_t __pad;
89};
90
91#define RTC_PARAM_GET _IOW('p', 0x13, struct rtc_param)
b22b78b1 92#define RTC_PARAM_SET _IOW('p', 0x14, struct rtc_param)
6097b12d
BK
93
94#define RTC_PARAM_FEATURES 0
95#define RTC_PARAM_CORRECTION 1
96#define RTC_PARAM_BACKUP_SWITCH_MODE 2
97
98struct hwclock_param {
99 int id;
100 const char *name;
101 const char *help;
102};
103
63d81834 104extern const struct hwclock_param *get_hwclock_params(void);
6097b12d 105extern int get_param_rtc(const struct hwclock_control *ctl, struct rtc_param *param);
b22b78b1 106extern int set_param_rtc(const struct hwclock_control *ctl);
6097b12d 107
39ff5b34
RM
108extern void __attribute__((__noreturn__))
109hwclock_exit(const struct hwclock_control *ctl, int status);
9abb2685 110
8e1b131e
KZ
111extern int parse_date(struct timespec *, char const *, struct timespec const *);
112
ef71b8f1 113#endif /* HWCLOCK_CLOCK_H */