todpc_subr.c revision ae115bc77f6fcde83175c75b4206dc2e50747966
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (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 2007 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>
static int todpc_rtcget(unsigned char *buf);
static void todpc_rtcput(unsigned char *buf);
/*
* Machine-dependent clock routines.
*/
/*
* Write the specified time into the clock chip.
* Must be called with tod_lock held.
*/
/*ARGSUSED*/
static void
{
if (todpc_rtcget((unsigned char *)&rtc))
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 */
todpc_rtcput((unsigned char *)&rtc);
}
/*
* 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.
*/
/*ARGSUSED*/
static timestruc_t
{
int compute_century;
static int range_warn = 1;
if (todpc_rtcget((unsigned char *)&rtc)) {
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 ENXIO if clock not valid, or EAGAIN 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
todpc_rtcget(unsigned char *buf)
{
unsigned char reg;
int i;
int retries = 256;
unsigned char *rawp;
return (ENXIO);
if (retries-- < 0)
return (EAGAIN);
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
todpc_rtcput(unsigned char *buf)
{
unsigned char reg;
int i;
for (i = 0; i < RTC_NREGP; i++) { /* set the time */
}
}
};
/*
* Initialize for the default TOD ops vector for use on hardware.
*/