Print this page
7127 remove -Wno-missing-braces from Makefile.uts
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/i86xpv/io/xpvtod.c
+++ new/usr/src/uts/i86xpv/io/xpvtod.c
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
↓ open down ↓ |
16 lines elided |
↑ open up ↑ |
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21
22 22 /*
23 23 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
24 24 * Use is subject to license terms.
25 25 */
26 26
27 -#pragma ident "%Z%%M% %I% %E% SMI"
28 -
29 27 #include <sys/types.h>
30 28 #include <sys/systm.h>
31 29 #include <sys/mutex.h>
32 30 #include <sys/time.h>
33 31 #include <sys/clock.h>
34 32 #include <sys/archsystm.h>
35 33 #include <sys/modctl.h>
36 34 #include <sys/autoconf.h>
37 35 #include <sys/cmn_err.h>
38 36 #include <sys/atomic.h>
39 37 #include <sys/hypervisor.h>
40 38
41 39 /*
42 40 * tod driver module for i86xpv
43 41 */
44 42
45 43 static timestruc_t
46 44 todxen_get(tod_ops_t *top)
47 45 {
48 46 todinfo_t tod;
49 47 timestruc_t ts, wcts;
50 48 shared_info_t *si = HYPERVISOR_shared_info;
51 49 uint32_t xen_wc_version;
52 50 hrtime_t now;
53 51
54 52 ASSERT(MUTEX_HELD(&tod_lock));
55 53
56 54 /*
57 55 * Pick up the wallclock base time
58 56 */
59 57 do {
60 58 xen_wc_version = si->wc_version;
61 59
62 60 membar_consumer();
63 61
64 62 wcts.tv_sec = si->wc_sec;
65 63 wcts.tv_nsec = si->wc_nsec;
66 64
67 65 membar_consumer();
68 66
69 67 } while ((si->wc_version & 1) | (xen_wc_version ^ si->wc_version));
70 68
71 69 /*
72 70 * Compute the TOD as the wallclock (boot) time plus time-since-boot
73 71 * (/not/ hrtime!) and normalize.
74 72 */
75 73 now = xpv_getsystime() +
76 74 (hrtime_t)wcts.tv_nsec + (hrtime_t)wcts.tv_sec * NANOSEC;
77 75 ts.tv_sec = (time_t)(now / NANOSEC);
78 76 ts.tv_nsec = (long)(now % NANOSEC);
79 77
80 78 /*
81 79 * Apply GMT lag correction from /etc/rtc_config to get UTC time
82 80 */
83 81 ts.tv_sec += ggmtl();
84 82
85 83 /*
86 84 * Validate the TOD in case of total insanity
87 85 */
88 86 tod = utc_to_tod(ts.tv_sec);
89 87 if (tod.tod_year < 69) {
90 88 static int range_warn = 1; /* warn only once */
91 89
92 90 if (range_warn) {
93 91 /*
94 92 * If we're dom0, go invoke the underlying driver; the
95 93 * routine should complain if it discovers something
96 94 * wrong.
97 95 */
98 96 if (DOMAIN_IS_INITDOMAIN(xen_info))
99 97 (void) TODOP_GET(top->tod_next);
100 98
101 99 /*
102 100 * Check the virtual hardware.
103 101 */
104 102 if (tod.tod_year > 38)
105 103 cmn_err(CE_WARN,
106 104 "hypervisor wall clock is out "
107 105 "of range -- time needs to be reset");
108 106 range_warn = 0;
109 107 }
110 108 tod.tod_year += 100;
111 109 ts.tv_sec = tod_to_utc(tod);
112 110 }
113 111
114 112 return (ts);
115 113 }
116 114
117 115 /*
118 116 * On dom0, invoke the underlying driver to update the physical RTC,
119 117 * and tell the hypervisor to update its idea of global time.
120 118 *
121 119 * On domU, we don't have permission to update the machine's physical RTC,
122 120 * so quietly ignore the attempt.
123 121 */
124 122 static void
125 123 todxen_set(tod_ops_t *top, timestruc_t ts)
126 124 {
127 125 xen_platform_op_t op;
128 126
129 127 if (DOMAIN_IS_INITDOMAIN(xen_info)) {
130 128 ASSERT(MUTEX_HELD(&tod_lock));
131 129 TODOP_SET(top->tod_next, ts);
132 130
133 131 op.cmd = XENPF_settime;
134 132 op.interface_version = XENPF_INTERFACE_VERSION;
135 133 op.u.settime.secs = ts.tv_sec - ggmtl();
136 134 op.u.settime.nsecs = ts.tv_nsec;
137 135 op.u.settime.system_time = xpv_getsystime();
138 136 (void) HYPERVISOR_platform_op(&op);
139 137 }
140 138 }
141 139
142 140 static tod_ops_t todxen_ops = {
143 141 TOD_OPS_VERSION,
144 142 todxen_get,
145 143 todxen_set,
↓ open down ↓ |
107 lines elided |
↑ open up ↑ |
146 144 NULL
147 145 };
148 146
149 147 static struct modlmisc modlmisc = {
150 148 &mod_miscops,
151 149 "TOD module for i86xpv"
152 150 };
153 151
154 152 static struct modlinkage modl = {
155 153 MODREV_1,
156 - &modlmisc
154 + { &modlmisc, NULL }
157 155 };
158 156
159 157 int
160 158 _init(void)
161 159 {
162 160 /*
163 161 * In future we might need to do something more sophisticated
164 162 * for versioning, i.e. dealing with older hardware TOD modules
165 163 * underneath us, but for now, anything else but "same" is a
166 164 * fatal error.
167 165 */
168 166 if (tod_ops->tod_version != todxen_ops.tod_version)
169 167 panic("TOD module version mismatch");
170 168
171 169 /*
172 170 * Stitch the ops vector linkage together, with this module
173 171 * sitting on the "front" of the ops list.
174 172 */
175 173 todxen_ops.tod_next = tod_ops;
176 174 tod_ops = &todxen_ops;
177 175
178 176 return (mod_install(&modl));
179 177 }
180 178
181 179 int
182 180 _fini(void)
183 181 {
184 182 return (EBUSY);
185 183 }
186 184
187 185 int
188 186 _info(struct modinfo *modinfo)
189 187 {
190 188 return (mod_info(&modl, modinfo));
191 189 }
↓ open down ↓ |
25 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX