Add MI todr(9) support and timercounter(9) support with kern_cctr.c to alpha:
- use todr(9) API with MI mc146818(4) driver and remove homegrown todr stuff from MD alpha/clock.c and alpha/mcclock.c - also remove obsolete cc_microtime stuff from MD code - add ci_pcc_freq member in struct cpu_info for cpu_frequency(), and calibrate it with mc146818 interval clock in mcclock attachment - call cc_init() in cpu_initclocks(9) because all alpha cpus have a pcc counter Tested on DEC 3000/300 and AlphaPC 164, but not on any SMP machines yet.
This commit is contained in:
parent
ccee2438df
commit
13084fc846
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: clock.c,v 1.36 2005/12/11 12:16:10 christos Exp $ */
|
||||
/* $NetBSD: clock.c,v 1.37 2007/07/21 11:59:55 tsutsui Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992, 1993
|
||||
@ -76,96 +76,51 @@
|
||||
* @(#)clock.c 8.1 (Berkeley) 6/10/93
|
||||
*/
|
||||
|
||||
#include "opt_multiprocessor.h"
|
||||
|
||||
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
|
||||
|
||||
__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.36 2005/12/11 12:16:10 christos Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.37 2007/07/21 11:59:55 tsutsui Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/device.h>
|
||||
#include <sys/sched.h>
|
||||
|
||||
#include <dev/clock_subr.h>
|
||||
|
||||
#include <machine/autoconf.h>
|
||||
#include <machine/cpuconf.h>
|
||||
#include <machine/cpu_counter.h>
|
||||
|
||||
#include <dev/dec/clockvar.h>
|
||||
#include <alpha/alpha/clockvar.h>
|
||||
|
||||
#include "opt_clock_compat_osf1.h"
|
||||
#include "opt_ntp.h"
|
||||
#define PCC_QUAL 1000
|
||||
|
||||
#define MINYEAR 1998 /* "today" */
|
||||
#ifdef CLOCK_COMPAT_OSF1
|
||||
/*
|
||||
* According to OSF/1's /usr/sys/include/arch/alpha/clock.h,
|
||||
* the console adjusts the RTC years 13..19 to 93..99 and
|
||||
* 20..40 to 00..20. (historical reasons?)
|
||||
* DEC Unix uses an offset to the year to stay outside
|
||||
* the dangerous area for the next couple of years.
|
||||
*/
|
||||
#define UNIX_YEAR_OFFSET 52 /* 41=>1993, 12=>2064 */
|
||||
#else
|
||||
#define UNIX_YEAR_OFFSET 0
|
||||
#endif
|
||||
|
||||
struct device *clockdev;
|
||||
const struct clockfns *clockfns;
|
||||
int clockinitted;
|
||||
void (*clock_init)(void *);
|
||||
void *clockdev;
|
||||
|
||||
void
|
||||
clockattach(dev, fns)
|
||||
struct device *dev;
|
||||
const struct clockfns *fns;
|
||||
clockattach(void (*fns)(void *), void *dev)
|
||||
{
|
||||
|
||||
/*
|
||||
* Just bookkeeping.
|
||||
*/
|
||||
printf("\n");
|
||||
|
||||
if (clockfns != NULL)
|
||||
if (clock_init != NULL)
|
||||
panic("clockattach: multiple clocks");
|
||||
clock_init = fns;
|
||||
clockdev = dev;
|
||||
clockfns = fns;
|
||||
}
|
||||
|
||||
/*
|
||||
* Machine-dependent clock routines.
|
||||
*
|
||||
* Startrtclock restarts the real-time clock, which provides
|
||||
* hardclock interrupts to kern_clock.c.
|
||||
*
|
||||
* Inittodr initializes the time of day hardware which provides
|
||||
* date functions. Its primary function is to use some file
|
||||
* system information in case the hardware clock lost state.
|
||||
*
|
||||
* Resettodr restores the time of day hardware after a time change.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Start the real-time and statistics clocks. Leave stathz 0 since there
|
||||
* are no other timers available.
|
||||
*/
|
||||
void
|
||||
cpu_initclocks()
|
||||
cpu_initclocks(void)
|
||||
{
|
||||
if (clockfns == NULL)
|
||||
uint64_t pcc_freq;
|
||||
|
||||
if (clock_init == NULL)
|
||||
panic("cpu_initclocks: no clock attached");
|
||||
|
||||
tick = 1000000 / hz; /* number of microseconds between interrupts */
|
||||
tickfix = 1000000 - (hz * tick);
|
||||
if (tickfix) {
|
||||
int ftp;
|
||||
|
||||
ftp = min(ffs(tickfix), ffs(hz));
|
||||
tickfix >>= (ftp - 1);
|
||||
tickfixinterval = hz >> (ftp - 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Establish the clock interrupt; it's a special case.
|
||||
*
|
||||
@ -181,10 +136,16 @@ cpu_initclocks()
|
||||
platform.clockintr = hardclock;
|
||||
schedhz = 16;
|
||||
|
||||
/*
|
||||
* Initialize PCC timecounter.
|
||||
*/
|
||||
pcc_freq = cpu_frequency(curcpu());
|
||||
cc_init(pcc_freq, "PCC", PCC_QUAL);
|
||||
|
||||
/*
|
||||
* Get the clock started.
|
||||
*/
|
||||
(*clockfns->cf_init)(clockdev);
|
||||
(*clock_init)(clockdev);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -199,123 +160,3 @@ setstatclockrate(newhz)
|
||||
|
||||
/* nothing we can do */
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialize the time of day register, based on the time base which is, e.g.
|
||||
* from a filesystem. Base provides the time to within six months,
|
||||
* and the time of year clock (if any) provides the rest.
|
||||
*/
|
||||
void
|
||||
inittodr(base)
|
||||
time_t base;
|
||||
{
|
||||
struct clocktime ct;
|
||||
int year;
|
||||
struct clock_ymdhms dt;
|
||||
time_t deltat;
|
||||
int badbase;
|
||||
|
||||
if (base < (MINYEAR-1970)*SECYR) {
|
||||
printf("WARNING: preposterous time in file system");
|
||||
/* read the system clock anyway */
|
||||
base = (MINYEAR-1970)*SECYR;
|
||||
badbase = 1;
|
||||
} else
|
||||
badbase = 0;
|
||||
|
||||
(*clockfns->cf_get)(clockdev, base, &ct);
|
||||
#ifdef DEBUG
|
||||
printf("readclock: %d/%d/%d/%d/%d/%d", ct.year, ct.mon, ct.day,
|
||||
ct.hour, ct.min, ct.sec);
|
||||
#endif
|
||||
clockinitted = 1;
|
||||
|
||||
year = 1900 + UNIX_YEAR_OFFSET + ct.year;
|
||||
if (year < 1970)
|
||||
year += 100;
|
||||
/* simple sanity checks (2037 = time_t overflow) */
|
||||
if (year < MINYEAR || year > 2037 ||
|
||||
ct.mon < 1 || ct.mon > 12 || ct.day < 1 ||
|
||||
ct.day > 31 || ct.hour > 23 || ct.min > 59 || ct.sec > 59) {
|
||||
/*
|
||||
* Believe the time in the file system for lack of
|
||||
* anything better, resetting the TODR.
|
||||
*/
|
||||
time.tv_sec = base;
|
||||
if (!badbase) {
|
||||
printf("WARNING: preposterous clock chip time\n");
|
||||
resettodr();
|
||||
}
|
||||
goto bad;
|
||||
}
|
||||
|
||||
dt.dt_year = year;
|
||||
dt.dt_mon = ct.mon;
|
||||
dt.dt_day = ct.day;
|
||||
dt.dt_hour = ct.hour;
|
||||
dt.dt_min = ct.min;
|
||||
dt.dt_sec = ct.sec;
|
||||
time.tv_sec = clock_ymdhms_to_secs(&dt);
|
||||
#ifdef DEBUG
|
||||
printf("=>%ld (%d)\n", time.tv_sec, base);
|
||||
#endif
|
||||
cc_microset_time = time;
|
||||
cc_microset(curcpu());
|
||||
|
||||
if (!badbase) {
|
||||
/*
|
||||
* See if we gained/lost two or more days;
|
||||
* if so, assume something is amiss.
|
||||
*/
|
||||
deltat = time.tv_sec - base;
|
||||
if (deltat < 0)
|
||||
deltat = -deltat;
|
||||
if (deltat < 2 * SECDAY)
|
||||
return;
|
||||
printf("WARNING: clock %s %ld days",
|
||||
time.tv_sec < base ? "lost" : "gained",
|
||||
(long)deltat / SECDAY);
|
||||
}
|
||||
bad:
|
||||
printf(" -- CHECK AND RESET THE DATE!\n");
|
||||
}
|
||||
|
||||
/*
|
||||
* Reset the TODR based on the time value; used when the TODR
|
||||
* has a preposterous value and also when the time is reset
|
||||
* by the stime system call. Also called when the TODR goes past
|
||||
* TODRZERO + 100*(SECYEAR+2*SECDAY) (e.g. on Jan 2 just after midnight)
|
||||
* to wrap the TODR around.
|
||||
*/
|
||||
void
|
||||
resettodr()
|
||||
{
|
||||
struct clock_ymdhms dt;
|
||||
struct clocktime ct;
|
||||
|
||||
if (!clockinitted)
|
||||
return;
|
||||
|
||||
cc_microset_time = time;
|
||||
#if defined(MULTIPROCESSOR)
|
||||
alpha_multicast_ipi(cpus_running, ALPHA_IPI_MICROSET);
|
||||
#endif
|
||||
cc_microset(curcpu());
|
||||
|
||||
clock_secs_to_ymdhms(time.tv_sec, &dt);
|
||||
|
||||
/* rt clock wants 2 digits */
|
||||
ct.year = (dt.dt_year - UNIX_YEAR_OFFSET) % 100;
|
||||
ct.mon = dt.dt_mon;
|
||||
ct.day = dt.dt_day;
|
||||
ct.hour = dt.dt_hour;
|
||||
ct.min = dt.dt_min;
|
||||
ct.sec = dt.dt_sec;
|
||||
ct.dow = dt.dt_wday;
|
||||
#ifdef DEBUG
|
||||
printf("setclock: %d/%d/%d/%d/%d/%d\n", ct.year, ct.mon, ct.day,
|
||||
ct.hour, ct.min, ct.sec);
|
||||
#endif
|
||||
|
||||
(*clockfns->cf_set)(clockdev, &ct);
|
||||
}
|
||||
|
34
sys/arch/alpha/alpha/clockvar.h
Normal file
34
sys/arch/alpha/alpha/clockvar.h
Normal file
@ -0,0 +1,34 @@
|
||||
/* $NetBSD: clockvar.h,v 1.5 2007/07/21 11:59:56 tsutsui Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994, 1995 Carnegie-Mellon University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Author: Chris G. Demetriou
|
||||
*
|
||||
* Permission to use, copy, modify and distribute this software and
|
||||
* its documentation is hereby granted, provided that both the copyright
|
||||
* notice and this permission notice appear in all copies of the
|
||||
* software, derivative works or modified versions, and any portions
|
||||
* thereof, and that both notices appear in supporting documentation.
|
||||
*
|
||||
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
|
||||
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
|
||||
* FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
|
||||
*
|
||||
* Carnegie Mellon requests users of this software to return to
|
||||
*
|
||||
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
|
||||
* School of Computer Science
|
||||
* Carnegie Mellon University
|
||||
* Pittsburgh PA 15213-3890
|
||||
*
|
||||
* any improvements or extensions that they make and grant Carnegie the
|
||||
* rights to redistribute these changes.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Definitions for CPU-independent clock handling for the alpha
|
||||
*/
|
||||
|
||||
void clockattach(void (*)(void *), void *);
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: cpu.c,v 1.75 2007/05/18 02:45:18 mhitch Exp $ */
|
||||
/* $NetBSD: cpu.c,v 1.76 2007/07/21 11:59:55 tsutsui Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998, 1999, 2000, 2001 The NetBSD Foundation, Inc.
|
||||
@ -66,7 +66,7 @@
|
||||
|
||||
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
|
||||
|
||||
__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.75 2007/05/18 02:45:18 mhitch Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.76 2007/07/21 11:59:55 tsutsui Exp $");
|
||||
|
||||
#include "opt_ddb.h"
|
||||
#include "opt_multiprocessor.h"
|
||||
@ -284,6 +284,7 @@ recognized:
|
||||
#endif
|
||||
ci->ci_cpuid = ma->ma_slot;
|
||||
ci->ci_softc = sc;
|
||||
ci->ci_pcc_freq = hwrpb->rpb_cc_freq;
|
||||
|
||||
/*
|
||||
* Though we could (should?) attach the LCA cpus' PCI
|
||||
@ -562,7 +563,7 @@ cpu_hatch(struct cpu_info *ci)
|
||||
ALPHA_TBIA();
|
||||
alpha_pal_imb();
|
||||
|
||||
cc_microset(ci);
|
||||
cc_calibrate_cpu(ci);
|
||||
|
||||
/* Initialize our base "runtime". */
|
||||
microtime(&ci->ci_schedstate.spc_runtime);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: interrupt.c,v 1.73 2007/05/17 14:51:11 yamt Exp $ */
|
||||
/* $NetBSD: interrupt.c,v 1.74 2007/07/21 11:59:56 tsutsui Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2000, 2001 The NetBSD Foundation, Inc.
|
||||
@ -72,7 +72,7 @@
|
||||
|
||||
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
|
||||
|
||||
__KERNEL_RCSID(0, "$NetBSD: interrupt.c,v 1.73 2007/05/17 14:51:11 yamt Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: interrupt.c,v 1.74 2007/07/21 11:59:56 tsutsui Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -206,7 +206,6 @@ void
|
||||
interrupt(unsigned long a0, unsigned long a1, unsigned long a2,
|
||||
struct trapframe *framep)
|
||||
{
|
||||
static int microset_iter; /* call cc_microset() once per sec. */
|
||||
struct cpu_info *ci = curcpu();
|
||||
struct cpu_softc *sc = ci->ci_softc;
|
||||
|
||||
@ -240,23 +239,6 @@ interrupt(unsigned long a0, unsigned long a1, unsigned long a2,
|
||||
*/
|
||||
sc->sc_evcnt_clock.ev_count++;
|
||||
uvmexp.intrs++;
|
||||
/*
|
||||
* Update the PCC frequency for use by microtime().
|
||||
*/
|
||||
if (
|
||||
#if defined(MULTIPROCESSOR)
|
||||
CPU_IS_PRIMARY(ci) &&
|
||||
#endif
|
||||
|
||||
microset_iter-- == 0) {
|
||||
microset_iter = hz - 1;
|
||||
cc_microset_time = time;
|
||||
#if defined(MULTIPROCESSOR)
|
||||
alpha_multicast_ipi(cpus_running,
|
||||
ALPHA_IPI_MICROSET);
|
||||
#endif
|
||||
cc_microset(ci);
|
||||
}
|
||||
if (platform.clockintr) {
|
||||
/*
|
||||
* Call hardclock(). This will also call
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ipifuncs.c,v 1.35 2007/05/17 14:51:12 yamt Exp $ */
|
||||
/* $NetBSD: ipifuncs.c,v 1.36 2007/07/21 11:59:56 tsutsui Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998, 1999, 2000, 2001 The NetBSD Foundation, Inc.
|
||||
@ -39,7 +39,7 @@
|
||||
|
||||
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
|
||||
|
||||
__KERNEL_RCSID(0, "$NetBSD: ipifuncs.c,v 1.35 2007/05/17 14:51:12 yamt Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: ipifuncs.c,v 1.36 2007/07/21 11:59:56 tsutsui Exp $");
|
||||
|
||||
/*
|
||||
* Interprocessor interrupt handlers.
|
||||
@ -257,7 +257,7 @@ void
|
||||
alpha_ipi_microset(struct cpu_info *ci, struct trapframe *framep)
|
||||
{
|
||||
|
||||
cc_microset(ci);
|
||||
cc_calibrate_cpu(ci);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: mcclock.c,v 1.10 1998/01/12 10:21:04 thorpej Exp $ */
|
||||
/* $NetBSD: mcclock.c,v 1.11 2007/07/21 11:59:56 tsutsui Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University.
|
||||
@ -29,108 +29,108 @@
|
||||
|
||||
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
|
||||
|
||||
__KERNEL_RCSID(0, "$NetBSD: mcclock.c,v 1.10 1998/01/12 10:21:04 thorpej Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: mcclock.c,v 1.11 2007/07/21 11:59:56 tsutsui Exp $");
|
||||
|
||||
#include "opt_clock_compat_osf1.h"
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/device.h>
|
||||
|
||||
#include <dev/dec/clockvar.h>
|
||||
#include <dev/dec/mcclockvar.h>
|
||||
#include <machine/bus.h>
|
||||
#include <machine/cpu_counter.h>
|
||||
|
||||
#include <dev/clock_subr.h>
|
||||
|
||||
#include <dev/ic/mc146818reg.h>
|
||||
#include <dev/ic/mc146818var.h>
|
||||
|
||||
void mcclock_init __P((struct device *));
|
||||
void mcclock_get __P((struct device *, time_t, struct clocktime *));
|
||||
void mcclock_set __P((struct device *, struct clocktime *));
|
||||
#include <alpha/alpha/mcclockvar.h>
|
||||
#include <alpha/alpha/clockvar.h>
|
||||
|
||||
const struct clockfns mcclock_clockfns = {
|
||||
mcclock_init, mcclock_get, mcclock_set,
|
||||
};
|
||||
#ifdef CLOCK_COMPAT_OSF1
|
||||
/*
|
||||
* According to OSF/1's /usr/sys/include/arch/alpha/clock.h,
|
||||
* the console adjusts the RTC years 13..19 to 93..99 and
|
||||
* 20..40 to 00..20. (historical reasons?)
|
||||
* DEC Unix uses an offset to the year to stay outside
|
||||
* the dangerous area for the next couple of years.
|
||||
*/
|
||||
#define UNIX_YEAR_OFFSET 52 /* 41=>1993, 12=>2064 */
|
||||
#else
|
||||
#define UNIX_YEAR_OFFSET 0
|
||||
#endif
|
||||
|
||||
#define mc146818_write(dev, reg, datum) \
|
||||
(*(dev)->sc_busfns->mc_bf_write)(dev, reg, datum)
|
||||
#define mc146818_read(dev, reg) \
|
||||
(*(dev)->sc_busfns->mc_bf_read)(dev, reg)
|
||||
|
||||
static void mcclock_set_pcc_freq(struct mc146818_softc *);
|
||||
static void mcclock_init(void *);
|
||||
|
||||
void
|
||||
mcclock_attach(sc, busfns)
|
||||
struct mcclock_softc *sc;
|
||||
const struct mcclock_busfns *busfns;
|
||||
mcclock_attach(struct mc146818_softc *sc)
|
||||
{
|
||||
|
||||
printf(": mc146818 or compatible");
|
||||
sc->sc_year0 = 1900 + UNIX_YEAR_OFFSET;
|
||||
sc->sc_flag = 0; /* BINARY, 24HR */
|
||||
|
||||
sc->sc_busfns = busfns;
|
||||
mc146818_attach(sc);
|
||||
|
||||
aprint_normal("\n");
|
||||
|
||||
/* Turn interrupts off, just in case. */
|
||||
mc146818_write(sc, MC_REGB, MC_REGB_BINARY | MC_REGB_24HR);
|
||||
(*sc->sc_mcwrite)(sc, MC_REGB, MC_REGB_BINARY | MC_REGB_24HR);
|
||||
|
||||
clockattach(&sc->sc_dev, &mcclock_clockfns);
|
||||
mcclock_set_pcc_freq(sc);
|
||||
|
||||
todr_attach(&sc->sc_handle);
|
||||
clockattach(mcclock_init, (void *)sc);
|
||||
}
|
||||
|
||||
void
|
||||
mcclock_init(dev)
|
||||
struct device *dev;
|
||||
static void
|
||||
mcclock_set_pcc_freq(struct mc146818_softc *sc)
|
||||
{
|
||||
struct mcclock_softc *sc = (struct mcclock_softc *)dev;
|
||||
struct cpu_info *ci;
|
||||
uint64_t freq;
|
||||
uint32_t pcc_start, pcc_count;
|
||||
uint8_t reg_a;
|
||||
|
||||
mc146818_write(sc, MC_REGA, MC_BASE_32_KHz | MC_RATE_1024_Hz);
|
||||
mc146818_write(sc, MC_REGB,
|
||||
/* save REG_A */
|
||||
reg_a = (*sc->sc_mcread)(sc, MC_REGA);
|
||||
|
||||
/* set interval 16Hz to measure pcc */
|
||||
(*sc->sc_mcwrite)(sc, MC_REGA, MC_BASE_32_KHz | MC_RATE_16_Hz);
|
||||
|
||||
/* clear interrupt flags */
|
||||
(void)(*sc->sc_mcread)(sc, MC_REGC);
|
||||
|
||||
/* wait till the periodic interupt flag is set */
|
||||
while (((*sc->sc_mcread)(sc, MC_REGC) & MC_REGC_PF) == 0)
|
||||
;
|
||||
pcc_start = cpu_counter32();
|
||||
|
||||
/* wait till the periodic interupt flag is set again */
|
||||
while (((*sc->sc_mcread)(sc, MC_REGC) & MC_REGC_PF) == 0)
|
||||
;
|
||||
|
||||
pcc_count = cpu_counter32() - pcc_start;
|
||||
|
||||
freq = pcc_count * 16;
|
||||
|
||||
/* restore REG_A */
|
||||
(*sc->sc_mcwrite)(sc, MC_REGA, reg_a);
|
||||
|
||||
/* XXX assume all processors have the same clock and frequency */
|
||||
for (ci = &cpu_info_primary; ci; ci = ci->ci_next)
|
||||
ci->ci_pcc_freq = freq;
|
||||
}
|
||||
|
||||
static void
|
||||
mcclock_init(void *dev)
|
||||
{
|
||||
struct mc146818_softc *sc = dev;
|
||||
|
||||
/* enable interval clock interrupt */
|
||||
(*sc->sc_mcwrite)(sc, MC_REGA, MC_BASE_32_KHz | MC_RATE_1024_Hz);
|
||||
(*sc->sc_mcwrite)(sc, MC_REGB,
|
||||
MC_REGB_PIE | MC_REGB_SQWE | MC_REGB_BINARY | MC_REGB_24HR);
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the time of day, based on the clock's value and/or the base value.
|
||||
*/
|
||||
void
|
||||
mcclock_get(dev, base, ct)
|
||||
struct device *dev;
|
||||
time_t base;
|
||||
struct clocktime *ct;
|
||||
{
|
||||
struct mcclock_softc *sc = (struct mcclock_softc *)dev;
|
||||
mc_todregs regs;
|
||||
int s;
|
||||
|
||||
s = splclock();
|
||||
MC146818_GETTOD(sc, ®s)
|
||||
splx(s);
|
||||
|
||||
ct->sec = regs[MC_SEC];
|
||||
ct->min = regs[MC_MIN];
|
||||
ct->hour = regs[MC_HOUR];
|
||||
ct->dow = regs[MC_DOW];
|
||||
ct->day = regs[MC_DOM];
|
||||
ct->mon = regs[MC_MONTH];
|
||||
ct->year = regs[MC_YEAR];
|
||||
}
|
||||
|
||||
/*
|
||||
* Reset the TODR based on the time value.
|
||||
*/
|
||||
void
|
||||
mcclock_set(dev, ct)
|
||||
struct device *dev;
|
||||
struct clocktime *ct;
|
||||
{
|
||||
struct mcclock_softc *sc = (struct mcclock_softc *)dev;
|
||||
mc_todregs regs;
|
||||
int s;
|
||||
|
||||
s = splclock();
|
||||
MC146818_GETTOD(sc, ®s);
|
||||
splx(s);
|
||||
|
||||
regs[MC_SEC] = ct->sec;
|
||||
regs[MC_MIN] = ct->min;
|
||||
regs[MC_HOUR] = ct->hour;
|
||||
regs[MC_DOW] = ct->dow;
|
||||
regs[MC_DOM] = ct->day;
|
||||
regs[MC_MONTH] = ct->mon;
|
||||
regs[MC_YEAR] = ct->year;
|
||||
|
||||
s = splclock();
|
||||
MC146818_PUTTOD(sc, ®s);
|
||||
splx(s);
|
||||
}
|
||||
|
30
sys/arch/alpha/alpha/mcclockvar.h
Normal file
30
sys/arch/alpha/alpha/mcclockvar.h
Normal file
@ -0,0 +1,30 @@
|
||||
/* $NetBSD: mcclockvar.h,v 1.5 2007/07/21 11:59:56 tsutsui Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996 Carnegie-Mellon University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Author: Chris G. Demetriou
|
||||
*
|
||||
* Permission to use, copy, modify and distribute this software and
|
||||
* its documentation is hereby granted, provided that both the copyright
|
||||
* notice and this permission notice appear in all copies of the
|
||||
* software, derivative works or modified versions, and any portions
|
||||
* thereof, and that both notices appear in supporting documentation.
|
||||
*
|
||||
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
|
||||
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
|
||||
* FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
|
||||
*
|
||||
* Carnegie Mellon requests users of this software to return to
|
||||
*
|
||||
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
|
||||
* School of Computer Science
|
||||
* Carnegie Mellon University
|
||||
* Pittsburgh PA 15213-3890
|
||||
*
|
||||
* any improvements or extensions that they make and grant Carnegie the
|
||||
* rights to redistribute these changes.
|
||||
*/
|
||||
|
||||
void mcclock_attach(struct mc146818_softc *);
|
@ -1,4 +1,4 @@
|
||||
# $NetBSD: files.alpha,v 1.173 2007/07/07 05:13:14 tsutsui Exp $
|
||||
# $NetBSD: files.alpha,v 1.174 2007/07/21 11:59:56 tsutsui Exp $
|
||||
#
|
||||
# alpha-specific configuration info
|
||||
|
||||
@ -392,7 +392,7 @@ file arch/alpha/a12/a12dc.c a12dc needs-flag
|
||||
# Devices that can live on multiple busses
|
||||
#
|
||||
|
||||
device mcclock
|
||||
device mcclock: mc146818
|
||||
attach mcclock at ioasic with mcclock_ioasic
|
||||
attach mcclock at isa with mcclock_isa
|
||||
attach mcclock at gbus with mcclock_tlsb
|
||||
@ -415,7 +415,6 @@ file arch/alpha/alpha/ipifuncs.c multiprocessor
|
||||
file arch/alpha/alpha/machdep.c
|
||||
file arch/alpha/alpha/mainbus.c
|
||||
file arch/alpha/alpha/mem.c
|
||||
file kern/kern_microtime.c
|
||||
file arch/alpha/alpha/pmap.c
|
||||
file arch/alpha/alpha/process_machdep.c
|
||||
file arch/alpha/alpha/procfs_machdep.c procfs
|
||||
@ -429,6 +428,7 @@ file arch/alpha/alpha/disksubr.c
|
||||
file arch/alpha/common/bus_dma.c
|
||||
file arch/alpha/common/comlogout.c
|
||||
file dev/cons.c
|
||||
file kern/kern_cctr.c
|
||||
|
||||
# Network protocol checksum routines
|
||||
file arch/alpha/alpha/in_cksum.c inet
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: cpu.h,v 1.70 2007/05/19 17:09:35 mhitch Exp $ */
|
||||
/* $NetBSD: cpu.h,v 1.71 2007/07/21 11:59:56 tsutsui Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998, 1999, 2000, 2001 The NetBSD Foundation, Inc.
|
||||
@ -129,7 +129,7 @@
|
||||
|
||||
#ifdef _KERNEL
|
||||
#include <sys/cpu_data.h>
|
||||
#include <sys/cc_microtime.h>
|
||||
#include <sys/cctr.h>
|
||||
#include <machine/frame.h>
|
||||
|
||||
/*
|
||||
@ -152,7 +152,7 @@ struct cpu_info {
|
||||
*/
|
||||
struct lwp *ci_curlwp; /* current owner of the processor */
|
||||
struct cpu_data ci_data; /* MI per-cpu data */
|
||||
struct cc_microtime_state ci_cc;/* cc_microtime state */
|
||||
struct cctr_state ci_cc; /* cycle counter state */
|
||||
struct cpu_info *ci_next; /* next cpu_info structure */
|
||||
int ci_mtx_count;
|
||||
int ci_mtx_oldspl;
|
||||
@ -166,6 +166,7 @@ struct cpu_info {
|
||||
u_long ci_want_resched; /* preempt current process */
|
||||
u_long ci_intrdepth; /* interrupt trap depth */
|
||||
struct trapframe *ci_db_regs; /* registers for debuggers */
|
||||
uint64_t ci_pcc_freq; /* cpu cycles/second */
|
||||
|
||||
#if defined(MULTIPROCESSOR)
|
||||
volatile u_long ci_flags; /* flags; see below */
|
||||
@ -296,7 +297,6 @@ struct rpb;
|
||||
struct trapframe;
|
||||
|
||||
int badaddr(void *, size_t);
|
||||
#define microtime(tv) cc_microtime(tv)
|
||||
|
||||
#define cpu_idle() /* nothing */
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: cpu_counter.h,v 1.3 2006/02/16 20:17:13 perry Exp $ */
|
||||
/* $NetBSD: cpu_counter.h,v 1.4 2007/07/21 11:59:56 tsutsui Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2000 The NetBSD Foundation, Inc.
|
||||
@ -48,6 +48,9 @@
|
||||
#include <machine/cpu.h>
|
||||
#include <machine/rpb.h>
|
||||
|
||||
#define cc_calibrate_mp(ci) \
|
||||
alpha_multicast_ipi(cpus_running, ALPHA_IPI_MICROSET)
|
||||
|
||||
/* Process Cycle Counter is always available. */
|
||||
#define cpu_hascounter() (1)
|
||||
#define cpu_counter() cpu_counter32()
|
||||
@ -68,7 +71,7 @@ static __inline uint64_t
|
||||
cpu_frequency(struct cpu_info *ci)
|
||||
{
|
||||
|
||||
return (hwrpb->rpb_cc_freq);
|
||||
return (ci->ci_pcc_freq);
|
||||
}
|
||||
|
||||
#endif /* _KERNEL */
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: types.h,v 1.36 2007/07/14 21:48:17 ad Exp $ */
|
||||
/* $NetBSD: types.h,v 1.37 2007/07/21 11:59:57 tsutsui Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990, 1993
|
||||
@ -65,6 +65,8 @@ typedef volatile int __cpu_simple_lock_t;
|
||||
#define __HAVE_SYSCALL_INTERN
|
||||
#define __HAVE_MINIMAL_EMUL
|
||||
#define __HAVE_AST_PERPROC
|
||||
#define __HAVE_GENERIC_TODR
|
||||
#define __HAVE_TIMECOUNTER
|
||||
|
||||
#if defined(_KERNEL)
|
||||
#define __HAVE_RAS
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: mcclock_isa.c,v 1.15 2005/12/11 12:16:16 christos Exp $ */
|
||||
/* $NetBSD: mcclock_isa.c,v 1.16 2007/07/21 11:59:57 tsutsui Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1995, 1996 Carnegie-Mellon University.
|
||||
@ -29,7 +29,7 @@
|
||||
|
||||
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
|
||||
|
||||
__KERNEL_RCSID(0, "$NetBSD: mcclock_isa.c,v 1.15 2005/12/11 12:16:16 christos Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: mcclock_isa.c,v 1.16 2007/07/21 11:59:57 tsutsui Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/kernel.h>
|
||||
@ -38,36 +38,25 @@ __KERNEL_RCSID(0, "$NetBSD: mcclock_isa.c,v 1.15 2005/12/11 12:16:16 christos Ex
|
||||
|
||||
#include <machine/bus.h>
|
||||
|
||||
#include <dev/dec/clockvar.h>
|
||||
#include <dev/dec/mcclockvar.h>
|
||||
#include <dev/clock_subr.h>
|
||||
|
||||
#include <dev/ic/mc146818reg.h>
|
||||
#include <dev/ic/mc146818var.h>
|
||||
#include <dev/isa/isavar.h>
|
||||
|
||||
struct mcclock_isa_softc {
|
||||
struct mcclock_softc sc_mcclock;
|
||||
#include <alpha/alpha/mcclockvar.h>
|
||||
|
||||
bus_space_tag_t sc_iot;
|
||||
bus_space_handle_t sc_ioh;
|
||||
};
|
||||
int mcclock_isa_match(struct device *, struct cfdata *, void *);
|
||||
void mcclock_isa_attach(struct device *, struct device *, void *);
|
||||
|
||||
int mcclock_isa_match __P((struct device *, struct cfdata *, void *));
|
||||
void mcclock_isa_attach __P((struct device *, struct device *, void *));
|
||||
|
||||
CFATTACH_DECL(mcclock_isa, sizeof (struct mcclock_isa_softc),
|
||||
CFATTACH_DECL(mcclock_isa, sizeof(struct mc146818_softc),
|
||||
mcclock_isa_match, mcclock_isa_attach, NULL, NULL);
|
||||
|
||||
void mcclock_isa_write __P((struct mcclock_softc *, u_int, u_int));
|
||||
u_int mcclock_isa_read __P((struct mcclock_softc *, u_int));
|
||||
|
||||
const struct mcclock_busfns mcclock_isa_busfns = {
|
||||
mcclock_isa_write, mcclock_isa_read,
|
||||
};
|
||||
void mcclock_isa_write(struct mc146818_softc *, u_int, u_int);
|
||||
u_int mcclock_isa_read(struct mc146818_softc *, u_int);
|
||||
|
||||
int
|
||||
mcclock_isa_match(parent, match, aux)
|
||||
struct device *parent;
|
||||
struct cfdata *match;
|
||||
void *aux;
|
||||
mcclock_isa_match(struct device *parent, struct cfdata *match, void *aux)
|
||||
{
|
||||
struct isa_attach_args *ia = aux;
|
||||
bus_space_handle_t ioh;
|
||||
@ -106,42 +95,37 @@ mcclock_isa_match(parent, match, aux)
|
||||
}
|
||||
|
||||
void
|
||||
mcclock_isa_attach(parent, self, aux)
|
||||
struct device *parent, *self;
|
||||
void *aux;
|
||||
mcclock_isa_attach(struct device *parent, struct device *self, void *aux)
|
||||
{
|
||||
struct isa_attach_args *ia = aux;
|
||||
struct mcclock_isa_softc *sc = (struct mcclock_isa_softc *)self;
|
||||
struct mc146818_softc *sc = (void *)self;
|
||||
|
||||
sc->sc_iot = ia->ia_iot;
|
||||
if (bus_space_map(sc->sc_iot, ia->ia_io[0].ir_addr,
|
||||
ia->ia_io[0].ir_size, 0, &sc->sc_ioh))
|
||||
sc->sc_bst = ia->ia_iot;
|
||||
if (bus_space_map(sc->sc_bst, ia->ia_io[0].ir_addr,
|
||||
ia->ia_io[0].ir_size, 0, &sc->sc_bsh))
|
||||
panic("mcclock_isa_attach: couldn't map clock I/O space");
|
||||
|
||||
mcclock_attach(&sc->sc_mcclock, &mcclock_isa_busfns);
|
||||
sc->sc_mcread = mcclock_isa_read;
|
||||
sc->sc_mcwrite = mcclock_isa_write;
|
||||
|
||||
mcclock_attach(sc);
|
||||
}
|
||||
|
||||
void
|
||||
mcclock_isa_write(mcsc, reg, datum)
|
||||
struct mcclock_softc *mcsc;
|
||||
u_int reg, datum;
|
||||
mcclock_isa_write(struct mc146818_softc *sc, u_int reg, u_int datum)
|
||||
{
|
||||
struct mcclock_isa_softc *sc = (struct mcclock_isa_softc *)mcsc;
|
||||
bus_space_tag_t iot = sc->sc_iot;
|
||||
bus_space_handle_t ioh = sc->sc_ioh;
|
||||
bus_space_tag_t iot = sc->sc_bst;
|
||||
bus_space_handle_t ioh = sc->sc_bsh;
|
||||
|
||||
bus_space_write_1(iot, ioh, 0, reg);
|
||||
bus_space_write_1(iot, ioh, 1, datum);
|
||||
}
|
||||
|
||||
u_int
|
||||
mcclock_isa_read(mcsc, reg)
|
||||
struct mcclock_softc *mcsc;
|
||||
u_int reg;
|
||||
mcclock_isa_read(struct mc146818_softc *sc, u_int reg)
|
||||
{
|
||||
struct mcclock_isa_softc *sc = (struct mcclock_isa_softc *)mcsc;
|
||||
bus_space_tag_t iot = sc->sc_iot;
|
||||
bus_space_handle_t ioh = sc->sc_ioh;
|
||||
bus_space_tag_t iot = sc->sc_bst;
|
||||
bus_space_handle_t ioh = sc->sc_bsh;
|
||||
|
||||
bus_space_write_1(iot, ioh, 0, reg);
|
||||
return bus_space_read_1(iot, ioh, 1);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: mcclock_jensenio.c,v 1.4 2002/10/02 04:06:38 thorpej Exp $ */
|
||||
/* $NetBSD: mcclock_jensenio.c,v 1.5 2007/07/21 11:59:57 tsutsui Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1999 The NetBSD Foundation, Inc.
|
||||
@ -65,7 +65,7 @@
|
||||
|
||||
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
|
||||
|
||||
__KERNEL_RCSID(0, "$NetBSD: mcclock_jensenio.c,v 1.4 2002/10/02 04:06:38 thorpej Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: mcclock_jensenio.c,v 1.5 2007/07/21 11:59:57 tsutsui Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/kernel.h>
|
||||
@ -74,18 +74,17 @@ __KERNEL_RCSID(0, "$NetBSD: mcclock_jensenio.c,v 1.4 2002/10/02 04:06:38 thorpej
|
||||
|
||||
#include <machine/bus.h>
|
||||
|
||||
#include <dev/dec/clockvar.h>
|
||||
#include <dev/dec/mcclockvar.h>
|
||||
#include <dev/clock_subr.h>
|
||||
|
||||
#include <dev/ic/mc146818reg.h>
|
||||
#include <dev/ic/mc146818var.h>
|
||||
#include <dev/eisa/eisavar.h>
|
||||
#include <dev/isa/isavar.h>
|
||||
#include <alpha/jensenio/jenseniovar.h>
|
||||
#include <alpha/alpha/mcclockvar.h>
|
||||
|
||||
struct mcclock_jensenio_softc {
|
||||
struct mcclock_softc sc_mcclock;
|
||||
|
||||
bus_space_tag_t sc_iot;
|
||||
bus_space_handle_t sc_ioh;
|
||||
struct mc146818_softc sc_mc146818;
|
||||
|
||||
bus_space_handle_t sc_std_rtc_ioh;
|
||||
};
|
||||
@ -96,12 +95,9 @@ void mcclock_jensenio_attach(struct device *, struct device *, void *);
|
||||
CFATTACH_DECL(mcclock_jensenio, sizeof (struct mcclock_jensenio_softc),
|
||||
mcclock_jensenio_match, mcclock_jensenio_attach, NULL, NULL);
|
||||
|
||||
void mcclock_jensenio_write(struct mcclock_softc *, u_int, u_int);
|
||||
u_int mcclock_jensenio_read(struct mcclock_softc *, u_int);
|
||||
void mcclock_jensenio_write(struct mc146818_softc *, u_int, u_int);
|
||||
u_int mcclock_jensenio_read(struct mc146818_softc *, u_int);
|
||||
|
||||
const struct mcclock_busfns mcclock_jensenio_busfns = {
|
||||
mcclock_jensenio_write, mcclock_jensenio_read,
|
||||
};
|
||||
|
||||
int
|
||||
mcclock_jensenio_match(struct device *parent, struct cfdata *match, void *aux)
|
||||
@ -119,40 +115,42 @@ void
|
||||
mcclock_jensenio_attach(struct device *parent, struct device *self, void *aux)
|
||||
{
|
||||
struct jensenio_attach_args *ja = aux;
|
||||
struct mcclock_jensenio_softc *sc = (void *) self;
|
||||
struct mcclock_jensenio_softc *jsc = (void *)self;
|
||||
struct mc146818_softc *sc = &jsc->sc_mc146818;
|
||||
|
||||
sc->sc_iot = ja->ja_iot;
|
||||
if (bus_space_map(sc->sc_iot, ja->ja_ioaddr, 0x02, 0,
|
||||
&sc->sc_ioh))
|
||||
sc->sc_bst = ja->ja_iot;
|
||||
if (bus_space_map(sc->sc_bst, ja->ja_ioaddr, 0x02, 0,
|
||||
&sc->sc_bsh))
|
||||
panic("mcclock_jensenio_attach: couldn't map clock I/O space");
|
||||
|
||||
/*
|
||||
* Map the I/O space normally used by the ISA RTC (port 0x70) so
|
||||
* as to avoid a false match at that address, as well.
|
||||
*/
|
||||
(void) bus_space_map(sc->sc_iot, 0x70, 0x02, 0,
|
||||
&sc->sc_std_rtc_ioh);
|
||||
(void)bus_space_map(sc->sc_bst, 0x70, 0x02, 0,
|
||||
&jsc->sc_std_rtc_ioh);
|
||||
|
||||
mcclock_attach(&sc->sc_mcclock, &mcclock_jensenio_busfns);
|
||||
sc->sc_mcread = mcclock_jensenio_read;
|
||||
sc->sc_mcwrite = mcclock_jensenio_write;
|
||||
|
||||
mcclock_attach(sc);
|
||||
}
|
||||
|
||||
void
|
||||
mcclock_jensenio_write(struct mcclock_softc *mcsc, u_int reg, u_int datum)
|
||||
mcclock_jensenio_write(struct mc146818_softc *sc, u_int reg, u_int datum)
|
||||
{
|
||||
struct mcclock_jensenio_softc *sc = (void *) mcsc;
|
||||
bus_space_tag_t iot = sc->sc_iot;
|
||||
bus_space_handle_t ioh = sc->sc_ioh;
|
||||
bus_space_tag_t iot = sc->sc_bst;
|
||||
bus_space_handle_t ioh = sc->sc_bsh;
|
||||
|
||||
bus_space_write_1(iot, ioh, 0, reg);
|
||||
bus_space_write_1(iot, ioh, 1, datum);
|
||||
}
|
||||
|
||||
u_int
|
||||
mcclock_jensenio_read(struct mcclock_softc *mcsc, u_int reg)
|
||||
mcclock_jensenio_read(struct mc146818_softc *sc, u_int reg)
|
||||
{
|
||||
struct mcclock_jensenio_softc *sc = (void *) mcsc;
|
||||
bus_space_tag_t iot = sc->sc_iot;
|
||||
bus_space_handle_t ioh = sc->sc_ioh;
|
||||
bus_space_tag_t iot = sc->sc_bst;
|
||||
bus_space_handle_t ioh = sc->sc_bsh;
|
||||
|
||||
bus_space_write_1(iot, ioh, 0, reg);
|
||||
return bus_space_read_1(iot, ioh, 1);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: a12c.c,v 1.16 2005/12/11 12:16:17 christos Exp $ */
|
||||
/* $NetBSD: a12c.c,v 1.17 2007/07/21 11:59:57 tsutsui Exp $ */
|
||||
|
||||
/* [Notice revision 2.2]
|
||||
* Copyright (c) 1997, 1998 Avalon Computer Systems, Inc.
|
||||
@ -38,7 +38,7 @@
|
||||
#include "opt_avalon_a12.h" /* Config options headers */
|
||||
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
|
||||
|
||||
__KERNEL_RCSID(0, "$NetBSD: a12c.c,v 1.16 2005/12/11 12:16:17 christos Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: a12c.c,v 1.17 2007/07/21 11:59:57 tsutsui Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -53,10 +53,11 @@ __KERNEL_RCSID(0, "$NetBSD: a12c.c,v 1.16 2005/12/11 12:16:17 christos Exp $");
|
||||
|
||||
#include <dev/isa/isareg.h>
|
||||
#include <dev/isa/isavar.h>
|
||||
#include <dev/dec/clockvar.h>
|
||||
#include <dev/pci/pcireg.h>
|
||||
#include <dev/pci/pcivar.h>
|
||||
|
||||
#include <alpha/alpha/clockvar.h>
|
||||
|
||||
#include <alpha/pci/a12creg.h>
|
||||
#include <alpha/pci/a12cvar.h>
|
||||
#include <alpha/pci/pci_a12.h>
|
||||
@ -127,7 +128,6 @@ a12cattach(parent, self, aux)
|
||||
struct a12c_softc *sc = (struct a12c_softc *)self;
|
||||
struct a12c_config *ccp;
|
||||
struct pcibus_attach_args pba;
|
||||
extern const struct clockfns *clockfns; /* XXX? */
|
||||
|
||||
/* note that we've attached the chipset; can't have 2 A12Cs. */
|
||||
a12cfound = 1;
|
||||
@ -141,11 +141,11 @@ a12cattach(parent, self, aux)
|
||||
a12c_init(ccp, 1);
|
||||
|
||||
/* XXX print chipset information */
|
||||
printf(": driver %s over logic %x\n", "$Revision: 1.16 $",
|
||||
printf(": driver %s over logic %x\n", "$Revision: 1.17 $",
|
||||
A12_ALL_EXTRACT(REGVAL(A12_VERS)));
|
||||
|
||||
pci_a12_pickintr(ccp);
|
||||
clockfns = &noclock_fns; /* XXX? */
|
||||
clockattach(noclock_init, NULL); /* XXX? */
|
||||
|
||||
memset(&pba, 0, sizeof(pba));
|
||||
pba.pba_iot = 0;
|
||||
@ -167,19 +167,8 @@ a12cattach(parent, self, aux)
|
||||
config_found_ia(self, "a12c_a12dc", &pba, NULL);
|
||||
}
|
||||
|
||||
static void noclock_init(struct device *dev) {
|
||||
dev = dev;
|
||||
}
|
||||
|
||||
static void
|
||||
noclock_get(struct device *dev, time_t t, struct clocktime *ct)
|
||||
static void noclock_init(void (*)(void *), void *)
|
||||
{
|
||||
*ct = zeroct;
|
||||
}
|
||||
|
||||
static void
|
||||
noclock_set(struct device *dev, struct clocktime *ct)
|
||||
{
|
||||
if(dev!=NULL)
|
||||
*ct = *ct;
|
||||
/* nothing */
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: mcclock_ioasic.c,v 1.11 2002/10/02 04:06:40 thorpej Exp $ */
|
||||
/* $NetBSD: mcclock_ioasic.c,v 1.12 2007/07/21 11:59:57 tsutsui Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University.
|
||||
@ -29,48 +29,46 @@
|
||||
|
||||
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
|
||||
|
||||
__KERNEL_RCSID(0, "$NetBSD: mcclock_ioasic.c,v 1.11 2002/10/02 04:06:40 thorpej Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: mcclock_ioasic.c,v 1.12 2007/07/21 11:59:57 tsutsui Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/device.h>
|
||||
|
||||
#include <dev/dec/clockvar.h>
|
||||
#include <dev/dec/mcclockvar.h>
|
||||
#include <machine/bus.h>
|
||||
|
||||
#include <dev/clock_subr.h>
|
||||
|
||||
#include <dev/ic/mc146818reg.h>
|
||||
#include <dev/ic/mc146818var.h>
|
||||
#include <dev/tc/tcvar.h>
|
||||
#include <dev/tc/ioasicvar.h> /* XXX */
|
||||
|
||||
#include <alpha/alpha/mcclockvar.h>
|
||||
|
||||
struct mcclock_ioasic_clockdatum {
|
||||
u_char datum;
|
||||
char pad[3];
|
||||
};
|
||||
|
||||
struct mcclock_ioasic_softc {
|
||||
struct mcclock_softc sc_mcclock;
|
||||
struct mc146818_softc sc_mc146818;
|
||||
|
||||
struct mcclock_ioasic_clockdatum *sc_dp;
|
||||
};
|
||||
|
||||
int mcclock_ioasic_match __P((struct device *, struct cfdata *, void *));
|
||||
void mcclock_ioasic_attach __P((struct device *, struct device *, void *));
|
||||
int mcclock_ioasic_match(struct device *, struct cfdata *, void *);
|
||||
void mcclock_ioasic_attach(struct device *, struct device *, void *);
|
||||
|
||||
CFATTACH_DECL(mcclock_ioasic, sizeof (struct mcclock_ioasic_softc),
|
||||
CFATTACH_DECL(mcclock_ioasic, sizeof(struct mcclock_ioasic_softc),
|
||||
mcclock_ioasic_match, mcclock_ioasic_attach, NULL, NULL);
|
||||
|
||||
void mcclock_ioasic_write __P((struct mcclock_softc *, u_int, u_int));
|
||||
u_int mcclock_ioasic_read __P((struct mcclock_softc *, u_int));
|
||||
|
||||
const struct mcclock_busfns mcclock_ioasic_busfns = {
|
||||
mcclock_ioasic_write, mcclock_ioasic_read,
|
||||
};
|
||||
void mcclock_ioasic_write(struct mc146818_softc *, u_int, u_int);
|
||||
u_int mcclock_ioasic_read(struct mc146818_softc *, u_int);
|
||||
|
||||
int
|
||||
mcclock_ioasic_match(parent, match, aux)
|
||||
struct device *parent;
|
||||
struct cfdata *match;
|
||||
void *aux;
|
||||
mcclock_ioasic_match(struct device *parent, struct cfdata *match, void *aux)
|
||||
{
|
||||
struct ioasicdev_attach_args *d = aux;
|
||||
|
||||
@ -81,34 +79,34 @@ mcclock_ioasic_match(parent, match, aux)
|
||||
}
|
||||
|
||||
void
|
||||
mcclock_ioasic_attach(parent, self, aux)
|
||||
struct device *parent, *self;
|
||||
void *aux;
|
||||
mcclock_ioasic_attach(struct device *parent, struct device *self, void *aux)
|
||||
{
|
||||
struct ioasicdev_attach_args *ioasicdev = aux;
|
||||
struct mcclock_ioasic_softc *sc = (struct mcclock_ioasic_softc *)self;
|
||||
struct mcclock_ioasic_softc *isc = (void *)self;
|
||||
struct mc146818_softc *sc = &isc->sc_mc146818;
|
||||
|
||||
sc->sc_dp = (struct mcclock_ioasic_clockdatum *)ioasicdev->iada_addr;
|
||||
/* XXX no bus_space(9) for TURBOchannel yet */
|
||||
isc->sc_dp = (void *)ioasicdev->iada_addr;
|
||||
|
||||
mcclock_attach(&sc->sc_mcclock, &mcclock_ioasic_busfns);
|
||||
sc->sc_mcread = mcclock_ioasic_read;
|
||||
sc->sc_mcwrite = mcclock_ioasic_write;
|
||||
|
||||
/* call alpha common mcclock attachment */
|
||||
mcclock_attach(sc);
|
||||
}
|
||||
|
||||
void
|
||||
mcclock_ioasic_write(dev, reg, datum)
|
||||
struct mcclock_softc *dev;
|
||||
u_int reg, datum;
|
||||
mcclock_ioasic_write(struct mc146818_softc *sc, u_int reg, u_int datum)
|
||||
{
|
||||
struct mcclock_ioasic_softc *sc = (struct mcclock_ioasic_softc *)dev;
|
||||
struct mcclock_ioasic_softc *isc = (void *)sc;
|
||||
|
||||
sc->sc_dp[reg].datum = datum;
|
||||
isc->sc_dp[reg].datum = datum;
|
||||
}
|
||||
|
||||
u_int
|
||||
mcclock_ioasic_read(dev, reg)
|
||||
struct mcclock_softc *dev;
|
||||
u_int reg;
|
||||
mcclock_ioasic_read(struct mc146818_softc *sc, u_int reg)
|
||||
{
|
||||
struct mcclock_ioasic_softc *sc = (struct mcclock_ioasic_softc *)dev;
|
||||
struct mcclock_ioasic_softc *isc = (void *)sc;
|
||||
|
||||
return (sc->sc_dp[reg].datum);
|
||||
return isc->sc_dp[reg].datum;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: mcclock_tlsb.c,v 1.12 2007/03/04 05:59:12 christos Exp $ */
|
||||
/* $NetBSD: mcclock_tlsb.c,v 1.13 2007/07/21 11:59:57 tsutsui Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1997 by Matthew Jacob
|
||||
@ -32,7 +32,7 @@
|
||||
|
||||
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
|
||||
|
||||
__KERNEL_RCSID(0, "$NetBSD: mcclock_tlsb.c,v 1.12 2007/03/04 05:59:12 christos Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: mcclock_tlsb.c,v 1.13 2007/07/21 11:59:57 tsutsui Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/kernel.h>
|
||||
@ -41,14 +41,18 @@ __KERNEL_RCSID(0, "$NetBSD: mcclock_tlsb.c,v 1.12 2007/03/04 05:59:12 christos E
|
||||
|
||||
#include <machine/bus.h>
|
||||
|
||||
#include <dev/dec/clockvar.h>
|
||||
#include <dev/dec/mcclockvar.h>
|
||||
|
||||
#include <alpha/tlsb/gbusvar.h>
|
||||
|
||||
#include <alpha/tlsb/tlsbreg.h> /* XXX */
|
||||
|
||||
#include <dev/clock_subr.h>
|
||||
|
||||
#include <dev/ic/mc146818reg.h>
|
||||
#include <dev/ic/mc146818var.h>
|
||||
|
||||
#include <alpha/alpha/mcclockvar.h>
|
||||
|
||||
#include "ioconf.h"
|
||||
|
||||
#define KV(_addr) ((void *)ALPHA_PHYS_TO_K0SEG((_addr)))
|
||||
/*
|
||||
@ -57,69 +61,62 @@ __KERNEL_RCSID(0, "$NetBSD: mcclock_tlsb.c,v 1.12 2007/03/04 05:59:12 christos E
|
||||
#define REGSHIFT 6
|
||||
|
||||
struct mcclock_tlsb_softc {
|
||||
struct mcclock_softc sc_mcclock;
|
||||
struct mc146818_softc sc_mc146818;
|
||||
unsigned long regbase;
|
||||
};
|
||||
|
||||
int mcclock_tlsb_match __P((struct device *, struct cfdata *, void *));
|
||||
void mcclock_tlsb_attach __P((struct device *, struct device *, void *));
|
||||
int mcclock_tlsb_match(struct device *, struct cfdata *, void *);
|
||||
void mcclock_tlsb_attach(struct device *, struct device *, void *);
|
||||
|
||||
CFATTACH_DECL(mcclock_tlsb, sizeof (struct mcclock_tlsb_softc),
|
||||
mcclock_tlsb_match, mcclock_tlsb_attach, NULL, NULL);
|
||||
|
||||
extern struct cfdriver mcclock_cd;
|
||||
static void mcclock_tlsb_write(struct mc146818_softc *, u_int, u_int);
|
||||
static u_int mcclock_tlsb_read(struct mc146818_softc *, u_int);
|
||||
|
||||
static void mcclock_tlsb_write __P((struct mcclock_softc *, u_int, u_int));
|
||||
static u_int mcclock_tlsb_read __P((struct mcclock_softc *, u_int));
|
||||
|
||||
const struct mcclock_busfns mcclock_tlsb_busfns = {
|
||||
mcclock_tlsb_write, mcclock_tlsb_read,
|
||||
};
|
||||
|
||||
int
|
||||
mcclock_tlsb_match(parent, match, aux)
|
||||
struct device *parent;
|
||||
struct cfdata *match;
|
||||
void *aux;
|
||||
mcclock_tlsb_match(struct device *parent, struct cfdata *match, void *aux)
|
||||
{
|
||||
struct gbus_attach_args *ga = aux;
|
||||
|
||||
if (strcmp(ga->ga_name, mcclock_cd.cd_name))
|
||||
return (0);
|
||||
return (1);
|
||||
}
|
||||
|
||||
void
|
||||
mcclock_tlsb_attach(parent, self, aux)
|
||||
struct device *parent, *self;
|
||||
void *aux;
|
||||
mcclock_tlsb_attach(struct device *parent, struct device *self, void *aux)
|
||||
{
|
||||
struct mcclock_tlsb_softc *sc = (struct mcclock_tlsb_softc *)self;
|
||||
struct gbus_attach_args *ga = aux;
|
||||
struct mcclock_tlsb_softc *tsc = (void *)self;
|
||||
struct mc146818_softc *sc = &tsc->sc_mc146818;
|
||||
|
||||
/* XXX Should be bus.h'd, so we can accommodate the kn7aa. */
|
||||
sc->regbase = TLSB_GBUS_BASE + ga->ga_offset;
|
||||
tsc->regbase = TLSB_GBUS_BASE + ga->ga_offset;
|
||||
|
||||
mcclock_attach(&sc->sc_mcclock, &mcclock_tlsb_busfns);
|
||||
sc->sc_mcread = mcclock_tlsb_read;
|
||||
sc->sc_mcwrite = mcclock_tlsb_write;
|
||||
|
||||
mcclock_attach(sc);
|
||||
}
|
||||
|
||||
static void
|
||||
mcclock_tlsb_write(mcsc, reg, val)
|
||||
struct mcclock_softc *mcsc;
|
||||
u_int reg, val;
|
||||
mcclock_tlsb_write(struct mc146818_softc *sc, u_int reg, u_int val)
|
||||
{
|
||||
struct mcclock_tlsb_softc *sc = (struct mcclock_tlsb_softc *)mcsc;
|
||||
struct mcclock_tlsb_softc *tsc = (void *)sc;
|
||||
unsigned char *ptr = (unsigned char *)
|
||||
KV(sc->regbase + (reg << REGSHIFT));
|
||||
KV(tsc->regbase + (reg << REGSHIFT));
|
||||
|
||||
*ptr = val;
|
||||
}
|
||||
|
||||
static u_int
|
||||
mcclock_tlsb_read(mcsc, reg)
|
||||
struct mcclock_softc *mcsc;
|
||||
u_int reg;
|
||||
mcclock_tlsb_read(struct mc146818_softc *sc, u_int reg)
|
||||
{
|
||||
struct mcclock_tlsb_softc *sc = (struct mcclock_tlsb_softc *)mcsc;
|
||||
struct mcclock_tlsb_softc *tsc = (void *)sc;
|
||||
unsigned char *ptr = (unsigned char *)
|
||||
KV(sc->regbase + (reg << REGSHIFT));
|
||||
KV(tsc->regbase + (reg << REGSHIFT));
|
||||
|
||||
return *ptr;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user