summaryrefslogtreecommitdiffstats
path: root/clockB/hwclock.h
blob: 6a3ab14bd09d76f7ca067b129bf62f29ee680ce8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#include <time.h>
#include <sys/time.h>
#include <unistd.h>

typedef int bool;
#define TRUE 1
#define FALSE 0

#define MYNAME "hwclock"
#define VERSION "2.5"


enum clock_access_method {ISA, RTC_IOCTL, KD, DEV_PORT, NOCLOCK};
  /* A method for accessing (reading, writing) the hardware clock:
     
     ISA: 
       via direct CPU I/O instructions that work on an ISA family
       machine (IBM PC compatible) or most DEC Alphas, which implement
       enough of ISA to get by.

     RTC_IOCTL: 
       via the rtc device driver, using device special file /dev/rtc.

     KD:
       via the console driver, using device special file /dev/tty1.
       This is the m68k ioctl interface, known as KDGHWCLK.

     DEV_PORT:
       via the /dev/port device, which is almost the same thing as 
       direct I/O instructions via the ISA method, but works on a Jensen 
       model of Alpha, whereas ISA does not.  Also, use I/O addresses
       0x170 and 0x171 instead of the ISA 0x70 and 0x71.

     NO_CLOCK:
       Unable to determine a usable access method for the system clock.
   */
       



/* hwclock.c */
extern int debug;
extern const bool alpha_machine;
extern const bool isa_machine;

/* directio.c */

extern void
assume_interrupts_enabled(void);

extern void
synchronize_to_clock_tick_ISA(int *retcode_p, const int dev_port,
                              const bool use_uf_bit);

extern void
read_hardware_clock_isa(struct tm *tm, const int dev_port,
                        int hc_zero_year);

extern void
set_hardware_clock_isa(const struct tm new_tm, 
                       const int hc_zero_year,
                       const int dev_port,
                       const bool testing);

extern void
get_inb_outb_privilege(const enum clock_access_method clock_access, 
                       bool * const no_auth_p);

extern void
get_dev_port_access(const enum clock_access_method clock_access,
                    int * dev_port_p);

extern bool
uf_bit_needed(const bool user_wants_uf);

extern int
zero_year(const bool arc_opt, const bool srm_opt);


/* rtc.c */
extern void
synchronize_to_clock_tick_RTC(int *retcode_p);

extern void
read_hardware_clock_rtc_ioctl(struct tm *tm);

extern void
set_hardware_clock_rtc_ioctl(const struct tm new_broken_time, 
                             const bool testing);
extern void
see_if_rtc_works(bool * const rtc_works_p);

extern void
get_epoch(unsigned long *epoch_p, char **reason_p);

extern void
set_epoch(unsigned long epoch, const bool testing, int *retcode_p);


/* kd.c */

extern void
synchronize_to_clock_tick_KD(int *retcode_p);

extern void
read_hardware_clock_kd(struct tm *tm);

extern void
set_hardware_clock_kd(const struct tm new_broken_time, 
                      const bool testing);

extern void
see_if_kdghwclk_works(bool * const kdghwclk_works_p);

extern const bool got_kdghwclk;

/* util.c */
extern bool
is_in_cpuinfo(const char * const fmt, const char * const str);

extern char *
ctime2(const time_t time);

extern struct timeval
t2tv(time_t argument);

extern struct timeval
t2tv(time_t argument);

extern float 
time_diff(struct timeval subtrahend, struct timeval subtractor);

extern struct timeval
time_inc(struct timeval addend, float increment);