sd: remove 'ssd' driver support
[unleashed/tickless.git] / arch / x86 / kernel / platform / i86pc / io / hardclk.c
blobc24ea2bfadefb066da4c410a06a33821f0f9397b
1 /*
2 * CDDL HEADER START
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]
19 * CDDL HEADER END
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>
32 #include <sys/time.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>
40 #include <sys/rtc.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
45 * modules.
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.
56 void
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.
71 timestruc_t
72 tod_get(void)
74 timestruc_t ts;
76 ASSERT(MUTEX_HELD(&tod_lock));
78 ts = TODOP_GET(tod_ops);
79 ts.tv_sec = tod_validate(ts.tv_sec);
80 return (ts);
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.
88 int
89 hr_clock_lock(void)
91 ushort_t s;
93 CLOCK_LOCK(&s);
94 return (s);
97 void
98 hr_clock_unlock(int s)
100 CLOCK_UNLOCK(s);
104 * Support routines for horrid GMT lag handling
107 static time_t gmt_lag; /* offset in seconds of gmt to local time */
109 void
110 sgmtl(time_t arg)
112 gmt_lag = arg;
115 time_t
116 ggmtl(void)
118 return (gmt_lag);
121 /* rtcsync() - set 'time', assuming RTC and GMT lag are correct */
123 void
124 rtcsync(void)
126 timestruc_t ts;
128 mutex_enter(&tod_lock);
129 ts = TODOP_GET(tod_ops);
130 set_hrestime(&ts);
131 mutex_exit(&tod_lock);