Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/powerpc/mpc6xx Add common routines to do BAT initia...
details: https://anonhg.NetBSD.org/src/rev/5b1901b0c3be
branches: trunk
changeset: 533350:5b1901b0c3be
user: matt <matt%NetBSD.org@localhost>
date: Fri Jun 28 02:32:16 2002 +0000
description:
Add common routines to do BAT initialization, trap vector setup,
interrupt vector installation, VM initialization, core-dumps (stubbed),
and network soft interrupts. Also kvtop and mapiodev.
diffstat:
sys/arch/powerpc/mpc6xx/mpc6xx_machdep.c | 540 +++++++++++++++++++++++++++++++
1 files changed, 540 insertions(+), 0 deletions(-)
diffs (truncated from 544 to 300 lines):
diff -r 58dac7e0ebd9 -r 5b1901b0c3be sys/arch/powerpc/mpc6xx/mpc6xx_machdep.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/powerpc/mpc6xx/mpc6xx_machdep.c Fri Jun 28 02:32:16 2002 +0000
@@ -0,0 +1,540 @@
+/* $NetBSD: mpc6xx_machdep.c,v 1.1 2002/06/28 02:32:16 matt Exp $ */
+
+/*
+ * Copyright (C) 2002 Matt Thomas
+ * Copyright (C) 1995, 1996 Wolfgang Solfrank.
+ * Copyright (C) 1995, 1996 TooLs GmbH.
+ * All rights reserved.
+ *
+ * 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. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by TooLs GmbH.
+ * 4. The name of TooLs GmbH may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``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 TOOLS GMBH 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.
+ */
+
+#include "opt_compat_netbsd.h"
+#include "opt_ddb.h"
+#include "opt_kgdb.h"
+#include "opt_ipkdb.h"
+#include "opt_multiprocessor.h"
+#include "opt_altivec.h"
+
+#include <sys/param.h>
+#include <sys/buf.h>
+#include <sys/exec.h>
+#include <sys/malloc.h>
+#include <sys/map.h>
+#include <sys/mbuf.h>
+#include <sys/mount.h>
+#include <sys/msgbuf.h>
+#include <sys/proc.h>
+#include <sys/reboot.h>
+#include <sys/syscallargs.h>
+#include <sys/syslog.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/user.h>
+#include <sys/boot_flag.h>
+
+#include <uvm/uvm_extern.h>
+
+#include <net/netisr.h>
+
+#ifdef DDB
+#include <machine/db_machdep.h>
+#include <ddb/db_extern.h>
+#endif
+
+#ifdef KGDB
+#include <sys/kgdb.h>
+#endif
+
+#ifdef IPKDB
+#include <ipkdb/ipkdb.h>
+#endif
+
+#include <powerpc/mpc6xx/bat.h>
+#include <powerpc/trap.h>
+#include <machine/powerpc.h>
+
+/*
+ * This should probably be in autoconf! XXX
+ */
+char machine[] = MACHINE; /* from <machine/param.h> */
+char machine_arch[] = MACHINE_ARCH; /* from <machine/param.h> */
+
+struct vm_map *exec_map = NULL;
+struct vm_map *mb_map = NULL;
+struct vm_map *phys_map = NULL;
+
+/*
+ * Global variables used here and there
+ */
+#ifndef MULTIPROCESSOR
+struct pcb *curpcb;
+struct pmap *curpm;
+struct proc *fpuproc;
+#endif
+
+extern struct user *proc0paddr;
+
+struct bat battable[16];
+paddr_t msgbuf_paddr;
+
+void
+mpc6xx_init(void (*handler)(void))
+{
+ extern int trapcode, trapsize;
+ extern int alitrap, alisize;
+ extern int dsitrap, dsisize;
+ extern int isitrap, isisize;
+ extern int decrint, decrsize;
+ extern int tlbimiss, tlbimsize;
+ extern int tlbdlmiss, tlbdlmsize;
+ extern int tlbdsmiss, tlbdsmsize;
+#if defined(DDB) || defined(KGDB)
+ extern int ddblow, ddbsize;
+#endif
+#ifdef IPKDB
+ extern int ipkdblow, ipkdbsize;
+#endif
+ int exc, scratch;
+ size_t size;
+#ifdef MULTIPROCESSOR
+ struct cpu_info * const ci = &cpu_info[0];
+#else
+ struct cpu_info * const ci = &cpu_info_store;
+#endif
+
+ __asm __volatile ("mtsprg 0,%0" :: "r"(ci));
+
+
+ /*
+ * Initialize proc0 and current pcb and pmap pointers.
+ */
+ proc0.p_cpu = ci;
+ proc0.p_addr = proc0paddr;
+ memset(proc0.p_addr, 0, sizeof *proc0.p_addr);
+
+ curpcb = &proc0paddr->u_pcb;
+ curpm = curpcb->pcb_pmreal = curpcb->pcb_pm = pmap_kernel();
+
+ /*
+ * Cause a PGM trap if we branch to 0.
+ */
+ memset(0, 0, 0x100);
+
+ /*
+ * Set up trap vectors. Don't assume vectors are on 0x100.
+ */
+ for (exc = EXC_RST; exc <= EXC_LAST; exc += 0x100) {
+ switch (exc) {
+ default:
+ size = (size_t)&trapsize;
+ memcpy((void *)exc, &trapcode, size);
+ break;
+#if 0
+ case EXC_EXI:
+ /*
+ * This one is (potentially) installed during autoconf
+ */
+ break;
+#endif
+ case EXC_ALI:
+ size = (size_t)&alisize;
+ memcpy((void *)EXC_ALI, &alitrap, size);
+ break;
+ case EXC_DSI:
+ size = (size_t)&dsisize;
+ memcpy((void *)EXC_DSI, &dsitrap, size);
+ break;
+ case EXC_ISI:
+ size = (size_t)&isisize;
+ memcpy((void *)EXC_ISI, &isitrap, size);
+ break;
+ case EXC_DECR:
+ size = (size_t)&decrsize;
+ memcpy((void *)EXC_DECR, &decrint, size);
+ break;
+ case EXC_IMISS:
+ size = (size_t)&tlbimsize;
+ memcpy((void *)EXC_IMISS, &tlbimiss, size);
+ break;
+ case EXC_DLMISS:
+ size = (size_t)&tlbdlmsize;
+ memcpy((void *)EXC_DLMISS, &tlbdlmiss, size);
+ break;
+ case EXC_DSMISS:
+ size = (size_t)&tlbdsmsize;
+ memcpy((void *)EXC_DSMISS, &tlbdsmiss, size);
+ break;
+ case EXC_PERF:
+ size = (size_t)&trapsize;
+ memcpy((void *)EXC_PERF, &trapcode, size);
+ memcpy((void *)EXC_VEC, &trapcode, size);
+ break;
+#if defined(DDB) || defined(IPKDB) || defined(KGDB)
+ case EXC_PGM:
+ case EXC_TRC:
+ case EXC_BPT:
+#if defined(DDB) || defined(KGDB)
+ size = (size_t)&ddbsize;
+ memcpy((void *)exc, &ddblow, size);
+#if defined(IPKDB)
+#error "cannot enable IPKDB with DDB or KGDB"
+#endif
+#else
+ size = (size_t)&ipkdbsize;
+ memcpy((void *)exc, &ipkdblow, size);
+#endif
+ break;
+#endif /* DDB || IPKDB || KGDB */
+ }
+#if 0
+ exc += roundup(size, 32);
+#endif
+ }
+
+ /*
+ * Get the cache sizes because install_extint calls __syncicache.
+ */
+ cpu_probe_cache();
+
+ /*
+ * external interrupt handler install
+ */
+ mpc6xx_install_extint(handler);
+
+ __syncicache(0, EXC_LAST + 0x100);
+
+ /*
+ * Now enable translation (and machine checks/recoverable interrupts).
+ */
+ __asm __volatile ("mfmsr %0; ori %0,%0,%1; mtmsr %0; isync"
+ : "=r"(scratch)
+ : "K"(PSL_IR|PSL_DR|PSL_ME|PSL_RI));
+}
+
+void
+mpc6xx_batinit(int iobatmask, int primary_iobat)
+{
+ struct mem_region *allmem, *availmem, *mp;
+ int bat;
+
+ /*
+ * Initialize BAT registers to unmapped to not generate
+ * overlapping mappings below.
+ */
+ __asm __volatile ("mtibatu 0,%0" :: "r"(0));
+ __asm __volatile ("mtibatu 1,%0" :: "r"(0));
+ __asm __volatile ("mtibatu 2,%0" :: "r"(0));
+ __asm __volatile ("mtibatu 3,%0" :: "r"(0));
+ __asm __volatile ("mtdbatu 0,%0" :: "r"(0));
+ __asm __volatile ("mtdbatu 1,%0" :: "r"(0));
+ __asm __volatile ("mtdbatu 2,%0" :: "r"(0));
+ __asm __volatile ("mtdbatu 3,%0" :: "r"(0));
+
+ /*
+ * Set up BAT0 to only map the lowest 256 MB area
+ */
+ battable[0].batl = BATL(0x00000000, BAT_M, BAT_PP_RW);
+ battable[0].batu = BATU(0x00000000, BAT_BL_256M, BAT_Vs);
+
+ /*
+ * Map PCI memory space.
+ */
+ for (bat = 0; bat < 16; bat++) {
+ if ((iobatmask & (1 << bat)) == 0)
+ continue;
+ battable[bat].batl = BATL((bat << 28), BAT_I|BAT_G, BAT_PP_RW);
+ battable[bat].batu = BATU((bat << 28), BAT_BL_256M, BAT_Vs);
+ }
+
+ /*
+ * Now setup fixed bat registers
+ *
+ * Note that we still run in real mode, and the BAT
+ * registers were cleared above.
+ */
+ /* BAT0 used for initial 256 MB segment */
+ __asm __volatile ("mtibatl 0,%0; mtibatu 0,%1;"
+ "mtdbatl 0,%0; mtdbatu 0,%1;"
+ :: "r"(battable[0].batl), "r"(battable[0].batu));
+ if (primary_iobat != 0) {
+ /* BAT1 used for primary I/O 256 MB segment */
+ __asm __volatile ("mtdbatl 1,%0; mtdbatu 1,%1;"
+ :: "r"(battable[primary_iobat].batl),
+ "r"(battable[primary_iobat].batu));
+ }
+
+ /*
+ * Set up battable to map all RAM regions.
+ * This is here because mem_regions() call needs bat0 set up.
+ */
+ mem_regions(&allmem, &availmem);
+ for (mp = allmem; mp->size; mp++) {
+ paddr_t pa = mp->start & 0xf0000000;
Home |
Main Index |
Thread Index |
Old Index