hardclk.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1990, 1991 UNIX System Laboratories, Inc. */
/* Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T */
/* All Rights Reserved */
/* Copyright (c) 1987, 1988 Microsoft Corporation */
/* All Rights Reserved */
#pragma ident "%Z%%M% %I% %E% SMI"
#include <sys/archsystm.h>
#include <sys/sysmacros.h>
#include <sys/lockstat.h>
/*
* Machine-dependent clock routines.
*/
extern long gmt_lag;
/*
* Write the specified time into the clock chip.
* Must be called with tod_lock held.
*/
void
{
return;
/*
* rtc bytes are in binary-coded decimal, so we have to convert.
* We assume that we wrap the rtc year back to zero at 2000.
*/
/* LINTED: YRBASE = 0 for x86 */
} else
/* dow < 10, so no conversion */
}
/*
* Read the current time from the clock chip and convert to UNIX form.
* Assumes that the year in the clock chip is valid.
* Must be called with tod_lock held.
*/
pc_tod_get(void)
{
int compute_century;
static int range_warn = 1;
return (ts);
}
/* assume that we wrap the rtc year back to zero at 2000 */
"of range -- time needs to be reset");
range_warn = 0;
}
compute_century = 20;
} else {
/* LINTED: YRBASE = 0 for x86 */
compute_century = 19;
}
"The hardware real-time clock appears to have the "
"wrong century: %d.\nSolaris will still operate "
"not.\nUse date(1) to set the date to the current "
"time to correct the RTC.",
century_warn = 0;
}
return (ts);
}
/*
* Routine to read contents of real time clock to the specified buffer.
* Returns -1 if clock not valid, or -2 if clock data cannot be read
* else 0.
* The routine will busy wait for the Update-In-Progress flag to clear.
* On completion of the reads the Seconds register is re-read and the
* UIP flag is rechecked to confirm that an clock update did not occur
* during the accesses. Routine will error exit after 256 attempts.
* (See bugid 1158298.)
* Routine returns RTC_NREG (which is 15) bytes of data, as given in the
* technical reference. This data includes both time and status registers.
*/
static int
{
unsigned char reg;
int i;
int retries = 256;
unsigned char *rawp;
return (-1);
if (retries-- < 0)
return (-2);
tenmicrosec();
goto checkuip;
}
}
/* update occured during reads */
goto checkuip;
return (0);
}
/*
* This routine writes the contents of the given buffer to the real time
* clock. It is given RTC_NREGP bytes of data, which are the 10 bytes used
* to write the time and set the alarm. It should be called with the priority
* raised to 5.
*/
static void
{
unsigned char reg;
int i;
for (i = 0; i < RTC_NREGP; i++) { /* set the time */
}
}
/*
* The following wrappers have been added so that locking
* can be exported to platform-independent clock routines
* (ie adjtime(), clock_setttime()), via a functional interface.
*/
int
hr_clock_lock(void)
{
ushort_t s;
CLOCK_LOCK(&s);
return (s);
}
void
hr_clock_unlock(int s)
{
CLOCK_UNLOCK(s);
}