summaryrefslogtreecommitdiff
path: root/sys/arch/aviion
diff options
context:
space:
mode:
Diffstat (limited to 'sys/arch/aviion')
-rw-r--r--sys/arch/aviion/aviion/av400_machdep.c33
-rw-r--r--sys/arch/aviion/aviion/machdep.c125
-rw-r--r--sys/arch/aviion/include/board.h66
-rw-r--r--sys/arch/aviion/include/cpu.h10
-rw-r--r--sys/arch/aviion/include/param.h14
-rw-r--r--sys/arch/aviion/include/trap.h3
6 files changed, 181 insertions, 70 deletions
diff --git a/sys/arch/aviion/aviion/av400_machdep.c b/sys/arch/aviion/aviion/av400_machdep.c
index c6600f7281a..61e5cf00434 100644
--- a/sys/arch/aviion/aviion/av400_machdep.c
+++ b/sys/arch/aviion/aviion/av400_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: av400_machdep.c,v 1.2 2006/05/20 11:57:02 miod Exp $ */
+/* $OpenBSD: av400_machdep.c,v 1.3 2006/05/20 12:04:51 miod Exp $ */
/*
* Copyright (c) 2006, Miodrag Vallat.
*
@@ -142,6 +142,7 @@
#include <uvm/uvm_extern.h>
#include <machine/asm_macro.h>
+#include <machine/board.h>
#include <machine/cmmu.h>
#include <machine/cpu.h>
#include <machine/reg.h>
@@ -155,14 +156,17 @@
u_int safe_level(u_int mask, u_int curlevel);
-void av400_bootstrap(void);
-void av400_ext_int(u_int, struct trapframe *);
-u_int av400_getipl(void);
-void av400_init_clocks(void);
-vaddr_t av400_memsize(void);
-u_int av400_raiseipl(u_int);
-u_int av400_setipl(u_int);
-void av400_startup(void);
+struct board board_av400 = {
+ "100/200/300/400/3000/4000/4300 series",
+ av400_bootstrap,
+ av400_memsize,
+ av400_startup,
+ av400_intr,
+ av400_init_clocks,
+ av400_getipl,
+ av400_setipl,
+ av400_raiseipl
+};
/*
* The MVME188 interrupt arbiter has 25 orthogonal interrupt sources.
@@ -179,7 +183,7 @@ void av400_startup(void);
*/
unsigned int int_mask_reg[] = { 0, 0, 0, 0 };
-unsigned int av400_curspl[] = {0, 0, 0, 0};
+u_int av400_curspl[] = { 0, 0, 0, 0 };
/*
* external interrupt masks per spl.
@@ -195,8 +199,6 @@ const unsigned int int_mask_val[INT_LEVEL] = {
MASK_LVL_7
};
-vaddr_t utilva;
-
/*
* Figure out how much memory is available, by asking the PROM.
*/
@@ -230,11 +232,6 @@ av400_bootstrap()
extern u_char hostaddr[6];
cmmu = &cmmu8820x;
- md_interrupt_func_ptr = av400_ext_int;
- md_getipl = av400_getipl;
- md_setipl = av400_setipl;
- md_raiseipl = av400_raiseipl;
- md_init_clocks = av400_init_clocks;
/* clear and disable all interrupts */
*(volatile u_int32_t *)AV400_IENALL = 0;
@@ -357,7 +354,7 @@ const unsigned int obio_vec[32] = {
#define VME_BERR_MASK 0x100 /* timeout during VME IACK cycle */
void
-av400_ext_int(u_int v, struct trapframe *eframe)
+av400_intr(u_int v, struct trapframe *eframe)
{
int cpu = cpu_number();
unsigned int cur_mask, ign_mask;
diff --git a/sys/arch/aviion/aviion/machdep.c b/sys/arch/aviion/aviion/machdep.c
index b2391a28de4..4cbca926d1e 100644
--- a/sys/arch/aviion/aviion/machdep.c
+++ b/sys/arch/aviion/aviion/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.2 2006/05/16 23:22:10 miod Exp $ */
+/* $OpenBSD: machdep.c,v 1.3 2006/05/20 12:04:51 miod Exp $ */
/*
* Copyright (c) 1998, 1999, 2000, 2001 Steve Murphree, Jr.
* Copyright (c) 1996 Nivas Madhur
@@ -69,6 +69,7 @@
#include <machine/asm.h>
#include <machine/asm_macro.h>
#include <machine/autoconf.h>
+#include <machine/board.h>
#include <machine/cmmu.h>
#include <machine/cpu.h>
#include <machine/kcore.h>
@@ -90,7 +91,9 @@
caddr_t allocsys(caddr_t);
void aviion_bootstrap(void);
+int aviion_identify(void);
void consinit(void);
+__dead void doboot(void);
void dumpconf(void);
void dumpsys(void);
u_int getipl(void);
@@ -98,23 +101,9 @@ void identifycpu(void);
void savectx(struct pcb *);
void secondary_main(void);
void secondary_pre_main(void);
-void doboot(void);
-
-extern void setlevel(unsigned int);
-
-extern void av400_bootstrap(void);
-extern vaddr_t av400_memsize(void);
-extern void av400_startup(void);
intrhand_t intr_handlers[NVMEINTR];
-/* board dependent pointers */
-void (*md_interrupt_func_ptr)(u_int, struct trapframe *);
-void (*md_init_clocks)(void);
-u_int (*md_getipl)(void);
-u_int (*md_setipl)(u_int);
-u_int (*md_raiseipl)(u_int);
-
int physmem; /* available physical memory, in pages */
struct vm_map *exec_map = NULL;
@@ -160,6 +149,8 @@ u_int bootdev, bootunit, bootpart; /* set in locore.S */
int cputyp; /* set in locore.S */
int cpuspeed = 20; /* safe guess */
+int avtyp;
+struct board *platform;
vaddr_t first_addr;
vaddr_t last_addr;
@@ -215,7 +206,7 @@ identifycpu()
cpuspeed = getcpuspeed(&brdid);
#endif
- strlcpy(cpu_model, "AV400 or compatible", sizeof cpu_model);
+ strlcpy(cpu_model, platform->descr, sizeof cpu_model);
}
/*
@@ -225,7 +216,7 @@ identifycpu()
void
cpu_initclocks()
{
- (*md_init_clocks)();
+ platform->init_clocks();
}
void
@@ -275,7 +266,7 @@ cpu_startup()
/*
* Grab machine dependent memory spaces
*/
- av400_startup(); /* XXX should be a function pointer */
+ platform->startup();
/*
* Now allocate buffers proper. They are different than the above
@@ -831,35 +822,42 @@ aviion_bootstrap()
/* Save a copy of our commandline before it gets overwritten. */
strlcpy(bootargs, prom_bootargs, sizeof bootargs);
- cn_tab = &bootcons;
+ avtyp = aviion_identify();
/* Set up interrupt and fp exception handlers based on the machine. */
- switch (cputyp) {
-#ifdef M88100
- case CPU_88100:
+ switch (avtyp) {
#ifdef AV400
- /*
- * Right now, we do not know how to tell 400 designs from
- * 5000 designs...
- */
-#if 0
- if (badaddr(AV400_VIRQV, 4) != 0)
-#else
- if (1)
+ case AV_400:
+ platform = &board_av400;
+ break;
+#endif
+#ifdef AV530
+ case AV_530:
+ platform = &board_av530;
+ break;
+#endif
+#ifdef AV5000
+ case AV_5000:
+ platform = &board_av5000;
+ break;
+#endif
+#ifdef AV6280
+ case AV_6280:
+ platform = &board_av6280;
+ break;
#endif
- {
- av400_bootstrap();
- break;
- }
-#endif /* AV400 */
-#endif /* 88100 */
default:
- printf("Sorry, OpenBSD/" MACHINE
+ scm_printf("Sorry, OpenBSD/" MACHINE
" does not support this model.\n");
scm_halt();
break;
};
+ cn_tab = &bootcons;
+ /* we can use printf() from here. */
+
+ platform->bootstrap();
+
/* Parse the commandline */
cmdline_parse();
@@ -867,7 +865,7 @@ aviion_bootstrap()
uvm_setpagesize();
first_addr = round_page((vaddr_t)&end); /* XXX temp until symbols */
- last_addr = av400_memsize(); /* XXX should be a function pointer */
+ last_addr = platform->memsize();
physmem = btoc(last_addr);
setup_board_config();
@@ -966,7 +964,7 @@ getipl(void)
u_int curspl, psr;
disable_interrupt(psr);
- curspl = (*md_getipl)();
+ curspl = platform->getipl();
set_psr(psr);
return curspl;
}
@@ -977,7 +975,7 @@ setipl(u_int level)
u_int curspl, psr;
disable_interrupt(psr);
- curspl = (*md_setipl)(level);
+ curspl = platform->setipl(level);
/*
* The flush pipeline is required to make sure the above change gets
@@ -996,7 +994,7 @@ raiseipl(u_int level)
u_int curspl, psr;
disable_interrupt(psr);
- curspl = (*md_raiseipl)(level);
+ curspl = platform->raiseipl(level);
/*
* The flush pipeline is required to make sure the above change gets
@@ -1016,3 +1014,48 @@ myetheraddr(u_char *cp)
{
bcopy(hostaddr, cp, 6);
}
+
+/*
+ * Attempt to identify which AViiON flavour we are running on.
+ * The only thing we can do at this point is peek at random addresses and
+ * see if they cause bus errors, or not.
+ *
+ * These heuristics are probably not the best; feel free to come with better
+ * ones...
+ */
+int
+aviion_identify()
+{
+ /*
+ * We don't know anything about 88110-based models.
+ * Note that we can't use CPU_IS81x0 here since these are optimized
+ * if the kernel you're running is compiled for only one processor
+ * type, and we want to check against the real hardware.
+ */
+ if (cputyp == CPU_88110)
+ return (0);
+
+ /*
+ * Series 100/200/300/400/3000/4000/4300 do not have the VIRQLV
+ * register at 0xfff85000.
+ */
+ if (badaddr(0xfff85000, 4) != 0)
+ return (AV_400);
+
+ /*
+ * Series 5000 and 6000 do not have an RTC counter at 0xfff8f084.
+ */
+ if (badaddr(0xfff8f084, 4) != 0)
+ return (AV_5000);
+
+ /*
+ * Series 4600/530 have IOFUSEs at 0xfffb0040 and 0xfffb00c0.
+ */
+ if (badaddr(0xfffb0040, 1) == 0 && badaddr(0xfffb00c0, 1) == 0)
+ return (AV_530);
+
+ /*
+ * Series 6280/8000-8 fall here.
+ */
+ return (AV_6280);
+}
diff --git a/sys/arch/aviion/include/board.h b/sys/arch/aviion/include/board.h
new file mode 100644
index 00000000000..15bd2fac301
--- /dev/null
+++ b/sys/arch/aviion/include/board.h
@@ -0,0 +1,66 @@
+/* $OpenBSD: board.h,v 1.1 2006/05/20 12:04:54 miod Exp $ */
+/*
+ * Copyright (c) 2006, Miodrag Vallat
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
+ */
+
+#ifndef _MACHINE_BOARD_H_
+#define _MACHINE_BOARD_H_
+
+#if !defined(_LOCORE)
+
+struct board {
+ const char *descr;
+ void (*bootstrap)(void);
+ vaddr_t (*memsize)(void);
+ void (*startup)(void);
+
+ void (*intr)(u_int, struct trapframe *);
+ void (*init_clocks)(void);
+ u_int (*getipl)(void);
+ u_int (*setipl)(u_int);
+ u_int (*raiseipl)(u_int);
+};
+
+#define md_interrupt_func(t, f) platform->intr(t, f)
+
+#define DECLARE_BOARD(b) \
+extern struct board board_av##b; \
+void av##b##_bootstrap(void); \
+vaddr_t av##b##_memsize(void); \
+void av##b##_startup(void); \
+void av##b##_intr(u_int, struct trapframe *); \
+void av##b##_init_clocks(void); \
+u_int av##b##_getipl(void); \
+u_int av##b##_setipl(u_int); \
+u_int av##b##_raiseipl(u_int);
+
+DECLARE_BOARD(400);
+DECLARE_BOARD(530);
+DECLARE_BOARD(5000);
+DECLARE_BOARD(6280);
+
+extern struct board *platform; /* just to have people confuse both names */
+
+#endif /* _LOCORE */
+#endif /* _MACHINE_BOARD_H_ */
diff --git a/sys/arch/aviion/include/cpu.h b/sys/arch/aviion/include/cpu.h
index 3510ef0954b..f24ae82aab0 100644
--- a/sys/arch/aviion/include/cpu.h
+++ b/sys/arch/aviion/include/cpu.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.h,v 1.1 2006/05/09 18:19:21 miod Exp $ */
+/* $OpenBSD: cpu.h,v 1.2 2006/05/20 12:04:54 miod Exp $ */
/*
* Copyright (c) 1996 Nivas Madhur
* Copyright (c) 1992, 1993
@@ -45,14 +45,6 @@
#ifdef _KERNEL
-/* board dependent pointers */
-extern void (*md_interrupt_func_ptr)(u_int, struct trapframe *);
-#define md_interrupt_func (*md_interrupt_func_ptr)
-extern u_int (*md_getipl)(void);
-extern u_int (*md_setipl)(u_int);
-extern u_int (*md_raiseipl)(u_int);
-extern void (*md_init_clocks)(void);
-
struct intrhand {
SLIST_ENTRY(intrhand) ih_link;
int (*ih_fn)(void *);
diff --git a/sys/arch/aviion/include/param.h b/sys/arch/aviion/include/param.h
index 2bbb019d23a..a926e8f6d87 100644
--- a/sys/arch/aviion/include/param.h
+++ b/sys/arch/aviion/include/param.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: param.h,v 1.1 2006/05/09 18:19:04 miod Exp $ */
+/* $OpenBSD: param.h,v 1.2 2006/05/20 12:04:54 miod Exp $ */
/*
* Copyright (c) 1999 Steve Murphree, Jr.
* Copyright (c) 1988 University of Utah.
@@ -49,4 +49,16 @@
#define KERNBASE 0x00000000 /* start of kernel virtual */
#define KERNTEXTOFF 0x00001000 /* start of kernel text */
+#if !defined(_LOCORE)
+extern int avtyp;
+#endif
+
+/*
+ * Values for the avtyp variable.
+ */
+#define AV_400 1 /* 100/200/300/400/3000/4000/4300 */
+#define AV_530 2 /* 4600/530 */
+#define AV_5000 3 /* 5000/6000 */
+#define AV_6280 4 /* 6280/8000-8 */
+
#endif /* !_MACHINE_PARAM_H_ */
diff --git a/sys/arch/aviion/include/trap.h b/sys/arch/aviion/include/trap.h
index d7ea00a0640..cb81662344c 100644
--- a/sys/arch/aviion/include/trap.h
+++ b/sys/arch/aviion/include/trap.h
@@ -1,3 +1,4 @@
-/* $OpenBSD: trap.h,v 1.1 2006/04/18 10:56:57 miod Exp $ */
+/* $OpenBSD: trap.h,v 1.2 2006/05/20 12:04:54 miod Exp $ */
/* public domain */
+#include <machine/board.h> /* md_interrupt_func */
#include <m88k/trap.h>