4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 /* Copyright (c) 1990, 1991 UNIX System Laboratories, Inc. */
28 /* Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T */
29 /* All Rights Reserved */
31 #include <sys/param.h>
33 #include <sys/systm.h>
34 #include <sys/archsystm.h>
35 #include <sys/lockstat.h>
37 #include <sys/clock.h>
38 #include <sys/debug.h>
39 #include <sys/smp_impldefs.h>
43 * This file contains all generic part of clock and timer handling.
44 * Specifics are now in separate files and may be overridden by TOD
48 char *tod_module_name
; /* Settable in /etc/system */
50 extern void tod_set_prev(timestruc_t
);
53 * Write the specified time into the clock chip.
54 * Must be called with tod_lock held.
57 tod_set(timestruc_t ts
)
59 ASSERT(MUTEX_HELD(&tod_lock
));
61 tod_set_prev(ts
); /* for tod_validate() */
62 TODOP_SET(tod_ops
, ts
);
63 tod_status_set(TOD_SET_DONE
); /* TOD was modified */
67 * Read the current time from the clock chip and convert to UNIX form.
68 * Assumes that the year in the clock chip is valid.
69 * Must be called with tod_lock held.
76 ASSERT(MUTEX_HELD(&tod_lock
));
78 ts
= TODOP_GET(tod_ops
);
79 ts
.tv_sec
= tod_validate(ts
.tv_sec
);
84 * The following wrappers have been added so that locking
85 * can be exported to platform-independent clock routines
86 * (ie adjtime(), clock_setttime()), via a functional interface.
98 hr_clock_unlock(int s
)
104 * Support routines for horrid GMT lag handling
107 static time_t gmt_lag
; /* offset in seconds of gmt to local time */
121 /* rtcsync() - set 'time', assuming RTC and GMT lag are correct */
128 mutex_enter(&tod_lock
);
129 ts
= TODOP_GET(tod_ops
);
131 mutex_exit(&tod_lock
);