Convert to MI todr framework.

This commit is contained in:
gdamore 2006-09-03 18:12:48 +00:00
parent 7b0092122f
commit 57933cb8b6
3 changed files with 3 additions and 133 deletions

View File

@ -1,130 +0,0 @@
/* $NetBSD: todclock.c,v 1.9 2005/12/11 12:16:37 christos Exp $ */
/*
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
* This software was developed by the Computer Systems Engineering group
* at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
* contributed to Berkeley.
*
* All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Lawrence Berkeley Laboratory.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)clock.c 8.1 (Berkeley) 6/11/93
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: todclock.c,v 1.9 2005/12/11 12:16:37 christos Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/systm.h>
#include <sys/device.h>
#include <dev/clock_subr.h>
static todr_chip_handle_t todr_handle;
/*
* Common parts of todclock autoconfiguration.
*/
void
todr_attach(todr_chip_handle_t handle)
{
if (todr_handle)
panic("todr_attach: too many todclocks configured");
todr_handle = handle;
}
/*
* Set up the system's time, given a `reasonable' time value.
*/
void
inittodr(time_t base)
{
int badbase, waszero;
badbase = 0;
waszero = (base == 0);
if (base < 5 * SECYR) {
/*
* If base is 0, assume filesystem time is just unknown
* in stead of preposterous. Don't bark.
*/
if (base != 0)
printf("WARNING: preposterous time in file system\n");
/* not going to use it anyway, if the chip is readable */
/* 2002/7/1 12:00:00 */
base = 32*SECYR + 186*SECDAY + SECDAY/2;
badbase = 1;
}
if (todr_gettime(todr_handle, &time) != 0 ||
time.tv_sec == 0) {
printf("WARNING: bad date in battery clock");
/*
* Believe the time in the file system for lack of
* anything better, resetting the clock.
*/
time.tv_sec = base;
if (!badbase)
resettodr();
} else {
int deltat = time.tv_sec - base;
if (deltat < 0)
deltat = -deltat;
if (waszero || deltat < 2 * SECDAY)
return;
printf("WARNING: clock %s %d days",
time.tv_sec < base ? "lost" : "gained", deltat / SECDAY);
}
printf(" -- CHECK AND RESET THE DATE!\n");
}
/*
* Reset the clock based on the current time.
* Used when the current clock is preposterous, when the time is changed,
* and when rebooting. Do nothing if the time is not yet known, e.g.,
* when crashing during autoconfig.
*/
void
resettodr(void)
{
if (time.tv_sec == 0)
return;
if (todr_settime(todr_handle, &time) != 0)
printf("resettodr: cannot set time in time-of-day clock\n");
}

View File

@ -1,4 +1,4 @@
# $NetBSD: files.arc,v 1.55 2006/06/25 16:11:41 tsutsui Exp $
# $NetBSD: files.arc,v 1.56 2006/09/03 18:12:48 gdamore Exp $
# $OpenBSD: files.arc,v 1.21 1999/09/11 10:20:20 niklas Exp $
#
# maxpartitions must be first item in files.${ARCH}
@ -69,7 +69,6 @@ file arch/arc/arc/disksubr.c
file arch/arc/arc/machdep.c
#file arch/arc/arc/minidebug.c
file arch/arc/arc/timer.c
file arch/arc/arc/todclock.c
file arch/arc/arc/interrupt.c
file arch/arc/arc/bus_space.c
file arch/arc/arc/bus_space_sparse.c

View File

@ -1,10 +1,11 @@
/* $NetBSD: types.h,v 1.17 2006/09/03 13:51:23 bjh21 Exp $ */
/* $NetBSD: types.h,v 1.18 2006/09/03 18:12:48 gdamore Exp $ */
#define _MIPS_PADDR_T_64BIT
#include <mips/types.h>
#define __HAVE_GENERIC_SOFT_INTERRUPTS
#define __HAVE_GENERIC_TODR
#define __HAVE_DEVICE_REGISTER
#define __HAVE_MIPS_MACHDEP_CACHE_CONFIG