Move timer{match,attach}_mainbus() back into timer.c, since the `timer at

mainbus' configuration declaration is orthogonal to the configured SUN4[CM]
platform options.
This commit is contained in:
pk 2002-11-28 14:18:31 +00:00
parent 512a461832
commit f19c04e3ed
3 changed files with 56 additions and 39 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: timer.c,v 1.11 2002/11/26 14:43:39 pk Exp $ */
/* $NetBSD: timer.c,v 1.12 2002/11/28 14:18:31 pk Exp $ */
/*
* Copyright (c) 1992, 1993
@ -194,3 +194,29 @@ timerattach_obio(struct device *parent, struct device *self, void *aux)
CFATTACH_DECL(timer_obio, sizeof(struct device),
timermatch_obio, timerattach_obio, NULL, NULL);
/*
* Only sun4c attaches a timer at mainbus
*/
static int
timermatch_mainbus(struct device *parent, struct cfdata *cf, void *aux)
{
#if defined(SUN4C)
struct mainbus_attach_args *ma = aux;
return (strcmp("counter-timer", ma->ma_name) == 0);
#else
return (0);
#endif
}
static void
timerattach_mainbus(struct device *parent, struct device *self, void *aux)
{
#if defined(SUN4C)
timerattach_mainbus_4c(parent, self, aux);
#endif /* SUN4C */
}
CFATTACH_DECL(timer_mainbus, sizeof(struct device),
timermatch_mainbus, timerattach_mainbus, NULL, NULL);

View File

@ -1,4 +1,4 @@
/* $NetBSD: timer_sun4.c,v 1.4 2002/10/02 16:02:12 thorpej Exp $ */
/* $NetBSD: timer_sun4.c,v 1.5 2002/11/28 14:18:31 pk Exp $ */
/*
* Copyright (c) 1992, 1993
@ -129,42 +129,6 @@ statintr_4(void *cap)
return (1);
}
#if defined(SUN4C)
static int
timermatch_mainbus(struct device *parent, struct cfdata *cf, void *aux)
{
struct mainbus_attach_args *ma = aux;
return (strcmp("counter-timer", ma->ma_name) == 0);
}
static void
timerattach_mainbus(struct device *parent, struct device *self, void *aux)
{
struct mainbus_attach_args *ma = aux;
bus_space_handle_t bh;
/*
* This time we ignore any existing virtual address because
* we have a fixed virtual address for the timer, to make
* microtime() faster.
*/
if (bus_space_map2(ma->ma_bustag,
ma->ma_paddr,
sizeof(struct timerreg_4),
BUS_SPACE_MAP_LINEAR,
TIMERREG_VA, &bh) != 0) {
printf(": can't map registers\n");
return;
}
timerattach(&timerreg4->t_c14.t_counter, &timerreg4->t_c14.t_limit);
}
CFATTACH_DECL(timer_mainbus, sizeof(struct device),
timermatch_mainbus, timerattach_mainbus, NULL, NULL);
#endif /* SUN4C */
#if defined(SUN4)
void
timerattach_obio_4(struct device *parent, struct device *self, void *aux)
@ -186,3 +150,28 @@ timerattach_obio_4(struct device *parent, struct device *self, void *aux)
timerattach(&timerreg4->t_c14.t_counter, &timerreg4->t_c14.t_limit);
}
#endif /* SUN4 */
#if defined(SUN4C)
void
timerattach_mainbus_4c(struct device *parent, struct device *self, void *aux)
{
struct mainbus_attach_args *ma = aux;
bus_space_handle_t bh;
/*
* This time we ignore any existing virtual address because
* we have a fixed virtual address for the timer, to make
* microtime() faster.
*/
if (bus_space_map2(ma->ma_bustag,
ma->ma_paddr,
sizeof(struct timerreg_4),
BUS_SPACE_MAP_LINEAR,
TIMERREG_VA, &bh) != 0) {
printf(": can't map registers\n");
return;
}
timerattach(&timerreg4->t_c14.t_counter, &timerreg4->t_c14.t_limit);
}
#endif /* SUN4C */

View File

@ -1,4 +1,4 @@
/* $NetBSD: timervar.h,v 1.1 2002/08/25 16:10:36 thorpej Exp $ */
/* $NetBSD: timervar.h,v 1.2 2002/11/28 14:18:31 pk Exp $ */
/*
* Copyright (c) 1992, 1993
@ -50,6 +50,7 @@ int statintr_4(void *);
void timer_init_4(void);
void timerattach_obio_4(struct device *, struct device *, void *);
void timerattach_mainbus_4c(struct device *, struct device *, void *);
#endif /* SUN4 || SUN4C */
#if defined(SUN4M)
@ -65,6 +66,7 @@ extern int statvar, statmin, statint;
extern int timerblurb;
extern void (*timer_init)(void);
/* Common timer attach routine in timer.c: */
void timerattach(volatile int *, volatile int *);
static __inline u_long __attribute__((__unused__))