summaryrefslogtreecommitdiff
path: root/sys/arch
diff options
context:
space:
mode:
authorMartin Pieuchot <mpi@cvs.openbsd.org>2015-03-31 16:00:39 +0000
committerMartin Pieuchot <mpi@cvs.openbsd.org>2015-03-31 16:00:39 +0000
commit38e4dfdfe8f2a635f9087712cdedbf7c317a936f (patch)
treeacafcc82665b9860e060e5d7642c25539234bebd /sys/arch
parentf6a0d1cdffc58ecb54fb52ce0c752f4668c8da9e (diff)
Make it possisble to disable block address translation mechanism on
processors that support it. Due to the way trap code is patched it is currently not possible to enabled/disable BAT at runtime. ok miod@, kettenis@
Diffstat (limited to 'sys/arch')
-rw-r--r--sys/arch/macppc/include/bat.h3
-rw-r--r--sys/arch/macppc/macppc/cpu.c37
-rw-r--r--sys/arch/macppc/macppc/locore.S12
-rw-r--r--sys/arch/macppc/macppc/machdep.c83
-rw-r--r--sys/arch/powerpc/include/bat.h7
-rw-r--r--sys/arch/powerpc/include/cpu.h12
-rw-r--r--sys/arch/powerpc/include/pmap.h3
-rw-r--r--sys/arch/powerpc/powerpc/cpu_subr.c51
-rw-r--r--sys/arch/powerpc/powerpc/pmap.c124
-rw-r--r--sys/arch/socppc/include/bat.h3
-rw-r--r--sys/arch/socppc/socppc/locore.S12
-rw-r--r--sys/arch/socppc/socppc/machdep.c91
12 files changed, 176 insertions, 262 deletions
diff --git a/sys/arch/macppc/include/bat.h b/sys/arch/macppc/include/bat.h
deleted file mode 100644
index fad8efe22b8..00000000000
--- a/sys/arch/macppc/include/bat.h
+++ /dev/null
@@ -1,3 +0,0 @@
-/* $OpenBSD: bat.h,v 1.1 2001/09/01 15:49:06 drahn Exp $ */
-
-#include <powerpc/bat.h>
diff --git a/sys/arch/macppc/macppc/cpu.c b/sys/arch/macppc/macppc/cpu.c
index 3ef74fae4ff..c6b055e5234 100644
--- a/sys/arch/macppc/macppc/cpu.c
+++ b/sys/arch/macppc/macppc/cpu.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.c,v 1.80 2015/03/31 15:51:05 mpi Exp $ */
+/* $OpenBSD: cpu.c,v 1.81 2015/03/31 16:00:38 mpi Exp $ */
/*
* Copyright (c) 1997 Per Fogelstrom
@@ -45,7 +45,7 @@
#include <dev/ofw/openfirm.h>
#include <machine/autoconf.h>
-#include <machine/bat.h>
+#include <powerpc/bat.h>
#include <machine/cpu.h>
#include <machine/trap.h>
#include <powerpc/hid.h>
@@ -529,7 +529,6 @@ struct cpu_hatch_data {
uint64_t hid4;
uint64_t hid5;
int l2cr;
- int sdr1;
int running;
};
@@ -581,7 +580,6 @@ cpu_spinup(struct device *self, struct cpu_info *ci)
h->ci = ci;
h->running = 0;
h->hid0 = ppc_mfhid0();
- h->sdr1 = ppc_mfsdr1();
if (ppc_proc_is_64b) {
h->hid1 = ppc64_mfhid1();
h->hid4 = ppc64_mfhid4();
@@ -672,8 +670,7 @@ void
cpu_hatch(void)
{
volatile struct cpu_hatch_data *h = cpu_hatch_data;
- int intrstate;
- int scratch, i, s;
+ int intrstate, s;
/* Initialize timebase. */
ppc_mttb(0);
@@ -681,10 +678,6 @@ cpu_hatch(void)
/* Initialize curcpu(). */
ppc_mtsprg0((u_int)h->ci);
- /*
- * Initialize BAT registers to unmapped to not generate
- * overlapping mappings below.
- */
ppc_mtibat0u(0);
ppc_mtibat1u(0);
ppc_mtibat2u(0);
@@ -694,26 +687,6 @@ cpu_hatch(void)
ppc_mtdbat2u(0);
ppc_mtdbat3u(0);
- /*
- * Now setup fixed bat registers
- *
- * Note that we still run in real mode, and the BAT
- * registers were cleared above.
- */
- /* IBAT0 used for initial 256 MB segment */
- ppc_mtibat0l(battable[0].batl);
- ppc_mtibat0u(battable[0].batu);
-
- /* DBAT0 used similar */
- ppc_mtdbat0l(battable[0].batl);
- ppc_mtdbat0u(battable[0].batu);
-
- /*
- * Initialize segment registers.
- */
- for (i = 0; i < 16; i++)
- ppc_mtsrin(PPC_KERNEL_SEG0 + i, i << ADDR_SR_SHIFT);
-
if (ppc_proc_is_64b) {
/*
* The Hardware Interrupt Offset Register should be
@@ -743,13 +716,11 @@ cpu_hatch(void)
ppc_mtl2cr(h->l2cr);
}
- ppc_mtsdr1(h->sdr1);
/*
* Now enable translation (and machine checks/recoverable interrupts).
*/
- __asm__ volatile ("eieio; mfmsr %0; ori %0,%0,%1; mtmsr %0; sync;isync"
- : "=r"(scratch) : "K"(PSL_IR|PSL_DR|PSL_ME|PSL_RI));
+ pmap_enable_mmu();
/* XXX OpenPIC */
{
diff --git a/sys/arch/macppc/macppc/locore.S b/sys/arch/macppc/macppc/locore.S
index c738d339720..f9b4b7da1c0 100644
--- a/sys/arch/macppc/macppc/locore.S
+++ b/sys/arch/macppc/macppc/locore.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: locore.S,v 1.48 2014/10/27 21:56:57 kettenis Exp $ */
+/* $OpenBSD: locore.S,v 1.49 2015/03/31 16:00:38 mpi Exp $ */
/* $NetBSD: locore.S,v 1.2 1996/10/16 19:33:09 ws Exp $ */
/*
@@ -363,7 +363,7 @@ nop32_3e:
mfxer %r30 /* save XER */
mtsprg 2,%r30 /* in SPRG2 */
mfsrr1 %r31 /* test kernel mode */
-nop64_1s:
+nopbat_1s:
mtcr %r31
bc 12,17,1f /* branch if PSL_PR is set */
mfdar %r31 /* get fault address */
@@ -393,7 +393,7 @@ nop64_1s:
mfsprg 1,%r1
rfi /* return to trapped code */
1:
-nop64_1e:
+nopbat_1e:
mflr %r28 /* save LR */
bla s_dsitrap
_C_LABEL(dsisize) = .-_C_LABEL(dsitrap)
@@ -1332,9 +1332,9 @@ _C_LABEL(rfi_start):
.long 0, 0
- .globl _C_LABEL(nop64_start)
-_C_LABEL(nop64_start):
- .long nop64_1s, nop64_1e
+ .globl _C_LABEL(nopbat_start)
+_C_LABEL(nopbat_start):
+ .long nopbat_1s, nopbat_1e
.long 0, 0
.globl _C_LABEL(nop32_start)
diff --git a/sys/arch/macppc/macppc/machdep.c b/sys/arch/macppc/macppc/machdep.c
index 2a35378a4c8..85ce70b75bf 100644
--- a/sys/arch/macppc/macppc/machdep.c
+++ b/sys/arch/macppc/macppc/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.168 2015/02/06 09:27:17 mpi Exp $ */
+/* $OpenBSD: machdep.c,v 1.169 2015/03/31 16:00:38 mpi Exp $ */
/* $NetBSD: machdep.c,v 1.4 1996/10/16 19:33:11 ws Exp $ */
/*
@@ -59,7 +59,6 @@
#include <dev/cons.h>
-#include <machine/bat.h>
#include <machine/pmap.h>
#include <powerpc/powerpc.h>
#include <machine/trap.h>
@@ -98,8 +97,6 @@ struct pool ppc_vecpl;
struct uvm_constraint_range dma_constraint = { 0x0, (paddr_t)-1 };
struct uvm_constraint_range *uvm_md_constraints[] = { NULL };
-struct bat battable[16];
-
struct vm_map *exec_map = NULL;
struct vm_map *phys_map = NULL;
@@ -160,7 +157,7 @@ initppc(startkernel, endkernel, args)
#endif
extern void callback(void *);
extern void *msgbuf_addr;
- int exc, scratch;
+ int exc;
proc0.p_cpu = &cpu_info[0];
proc0.p_addr = proc0paddr;
@@ -170,40 +167,12 @@ initppc(startkernel, endkernel, args)
curpm = curpcb->pcb_pmreal = curpcb->pcb_pm = pmap_kernel();
- ppc_check_procid();
-
- /*
- * Initialize BAT registers to unmapped to not generate
- * overlapping mappings below.
- */
- ppc_mtibat0u(0);
- ppc_mtibat1u(0);
- ppc_mtibat2u(0);
- ppc_mtibat3u(0);
- ppc_mtdbat0u(0);
- ppc_mtdbat1u(0);
- ppc_mtdbat2u(0);
- ppc_mtdbat3u(0);
-
- /*
- * Set up initial BAT table to only map the lowest 256 MB area
- */
- battable[0].batl = BATL(0x00000000, BAT_M);
- battable[0].batu = BATU(0x00000000, BAT_BL_256M);
+ cpu_bootstrap();
/*
- * Now setup fixed bat registers
- *
- * Note that we still run in real mode, and the BAT
- * registers were cleared above.
+ * Initialize pmap module.
*/
- /* DBAT0 used for initial 256 MB segment */
- ppc_mtdbat0l(battable[0].batl);
- ppc_mtdbat0u(battable[0].batu);
-
- /* IBAT0 only covering the kernel .text */
- ppc_mtibat0l(battable[0].batl);
- ppc_mtibat0u(BATU(0x00000000, BAT_BL_8M));
+ pmap_bootstrap(startkernel, endkernel);
/*
* Set up trap vectors
@@ -263,50 +232,10 @@ initppc(startkernel, endkernel, args)
syncicache((void *)EXC_RST, EXC_LAST - EXC_RST + 0x100);
-
- uvmexp.pagesize = 4096;
- uvm_setpagesize();
-
- /*
- * Initialize pmap module.
- */
- pmap_bootstrap(startkernel, endkernel);
-
- /* now that we know physmem size, map physical memory with BATs */
- if (physmem > atop(0x10000000)) {
- battable[0x1].batl = BATL(0x10000000, BAT_M);
- battable[0x1].batu = BATU(0x10000000, BAT_BL_256M);
- }
- if (physmem > atop(0x20000000)) {
- battable[0x2].batl = BATL(0x20000000, BAT_M);
- battable[0x2].batu = BATU(0x20000000, BAT_BL_256M);
- }
- if (physmem > atop(0x30000000)) {
- battable[0x3].batl = BATL(0x30000000, BAT_M);
- battable[0x3].batu = BATU(0x30000000, BAT_BL_256M);
- }
- if (physmem > atop(0x40000000)) {
- battable[0x4].batl = BATL(0x40000000, BAT_M);
- battable[0x4].batu = BATU(0x40000000, BAT_BL_256M);
- }
- if (physmem > atop(0x50000000)) {
- battable[0x5].batl = BATL(0x50000000, BAT_M);
- battable[0x5].batu = BATU(0x50000000, BAT_BL_256M);
- }
- if (physmem > atop(0x60000000)) {
- battable[0x6].batl = BATL(0x60000000, BAT_M);
- battable[0x6].batu = BATU(0x60000000, BAT_BL_256M);
- }
- if (physmem > atop(0x70000000)) {
- battable[0x7].batl = BATL(0x70000000, BAT_M);
- battable[0x7].batu = BATU(0x70000000, BAT_BL_256M);
- }
-
/*
* Now enable translation (and machine checks/recoverable interrupts).
*/
- __asm__ volatile ("eieio; mfmsr %0; ori %0,%0,%1; mtmsr %0; sync;isync"
- : "=r"(scratch) : "K"(PSL_IR|PSL_DR|PSL_ME|PSL_RI));
+ pmap_enable_mmu();
/*
* use the memory provided by pmap_bootstrap for message buffer
diff --git a/sys/arch/powerpc/include/bat.h b/sys/arch/powerpc/include/bat.h
index d2601d9a2bd..030cc56a330 100644
--- a/sys/arch/powerpc/include/bat.h
+++ b/sys/arch/powerpc/include/bat.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: bat.h,v 1.5 2014/10/27 21:56:57 kettenis Exp $ */
+/* $OpenBSD: bat.h,v 1.6 2015/03/31 16:00:38 mpi Exp $ */
/*
* Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -59,6 +59,11 @@ struct bat {
#define BAT_BL_64M 0x000007fc
#define BAT_BL_128M 0x00000ffc
#define BAT_BL_256M 0x00001ffc
+/* Extended Block Lengths (7455+) */
+#define BAT_BL_512M 0x00003ffc
+#define BAT_BL_1G 0x00007ffc
+#define BAT_BL_2G 0x0000fffc
+#define BAT_BL_4G 0x0001fffc
#ifdef _KERNEL
extern struct bat battable[16];
diff --git a/sys/arch/powerpc/include/cpu.h b/sys/arch/powerpc/include/cpu.h
index 11cc4cc5670..b41167ceefa 100644
--- a/sys/arch/powerpc/include/cpu.h
+++ b/sys/arch/powerpc/include/cpu.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.h,v 1.60 2015/02/11 07:05:39 dlg Exp $ */
+/* $OpenBSD: cpu.h,v 1.61 2015/03/31 16:00:38 mpi Exp $ */
/* $NetBSD: cpu.h,v 1.1 1996/09/30 16:34:21 ws Exp $ */
/*
@@ -150,7 +150,12 @@ extern struct cpu_info cpu_info[PPC_MAXPROCS];
#define CLKF_PC(frame) ((frame)->srr0)
#define CLKF_INTR(frame) ((frame)->depth != 0)
-extern int ppc_cpuidle;
+extern int ppc_cpuidle;
+extern int ppc_proc_is_64b;
+extern int ppc_nobat;
+
+void cpu_bootstrap(void);
+
/*
* This is used during profiling to integrate system time.
*/
@@ -385,8 +390,6 @@ ppc_intr_disable(void)
}
int ppc_cpuspeed(int *);
-void ppc_check_procid(void);
-extern int ppc_proc_is_64b;
/*
* PowerPC CPU types
@@ -409,6 +412,7 @@ extern int ppc_proc_is_64b;
#define PPC_CPU_MPC7450 0x8000
#define PPC_CPU_MPC7455 0x8001
#define PPC_CPU_MPC7457 0x8002
+#define PPC_CPU_MPC83xx 0x8083
/*
* This needs to be included late since it relies on definitions higher
diff --git a/sys/arch/powerpc/include/pmap.h b/sys/arch/powerpc/include/pmap.h
index ba66701637c..d422f56c249 100644
--- a/sys/arch/powerpc/include/pmap.h
+++ b/sys/arch/powerpc/include/pmap.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: pmap.h,v 1.55 2015/02/15 21:34:33 miod Exp $ */
+/* $OpenBSD: pmap.h,v 1.56 2015/03/31 16:00:38 mpi Exp $ */
/* $NetBSD: pmap.h,v 1.1 1996/09/30 16:34:29 ws Exp $ */
/*-
@@ -134,6 +134,7 @@ boolean_t pteclrbits(struct vm_page *pg, u_int mask, u_int clear);
#define __HAVE_PMAP_DIRECT
void pmap_bootstrap(u_int kernelstart, u_int kernelend);
+void pmap_enable_mmu();
void pmap_pinit(struct pmap *);
void pmap_release(struct pmap *);
diff --git a/sys/arch/powerpc/powerpc/cpu_subr.c b/sys/arch/powerpc/powerpc/cpu_subr.c
index d6198aa6a40..5f8235270c6 100644
--- a/sys/arch/powerpc/powerpc/cpu_subr.c
+++ b/sys/arch/powerpc/powerpc/cpu_subr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu_subr.c,v 1.6 2015/03/31 15:51:05 mpi Exp $ */
+/* $OpenBSD: cpu_subr.c,v 1.7 2015/03/31 16:00:38 mpi Exp $ */
/*
* Copyright (c) 2013 Martin Pieuchot
@@ -19,21 +19,22 @@
#include <sys/param.h>
-#include <machine/cpu.h>
+#include <powerpc/cpu.h>
+
+int ppc_cpuidle; /* Support DOZE, NAP or DEEP NAP? */
+int ppc_altivec; /* CPU has altivec support. */
+int ppc_proc_is_64b; /* CPU is 64bit */
+int ppc_nobat; /* Do not use BAT registers. */
struct patch {
uint32_t *s;
uint32_t *e;
};
-extern struct patch rfi_start, nop32_start, nop64_start;
-extern uint32_t rfi_inst, rfid_inst, nop_inst;
-
-int ppc_cpuidle; /* Support DOZE, NAP or DEEP NAP? */
-int ppc_altivec;
-int ppc_proc_is_64b;
+extern struct patch rfi_start, nop32_start, nopbat_start;
+extern uint32_t rfid_inst, nop_inst;
void
-ppc_check_procid(void)
+cpu_bootstrap(void)
{
uint32_t cpu;
uint32_t *inst;
@@ -45,22 +46,44 @@ ppc_check_procid(void)
case PPC_CPU_IBM970:
case PPC_CPU_IBM970FX:
case PPC_CPU_IBM970MP:
+ ppc_nobat = 1;
ppc_proc_is_64b = 1;
+
for (p = &rfi_start; p->s; p++) {
for (inst = p->s; inst < p->e; inst++)
*inst = rfid_inst;
syncicache(p->s, (p->e - p->s) * sizeof(*p->e));
}
- for (p = &nop64_start; p->s; p++) {
+ break;
+ case PPC_CPU_MPC83xx:
+ ppc_mtibat4u(0);
+ ppc_mtibat5u(0);
+ ppc_mtibat6u(0);
+ ppc_mtibat7u(0);
+ ppc_mtdbat4u(0);
+ ppc_mtdbat5u(0);
+ ppc_mtdbat6u(0);
+ ppc_mtdbat7u(0);
+ /* FALLTHROUGH */
+ default:
+ ppc_mtibat0u(0);
+ ppc_mtibat1u(0);
+ ppc_mtibat2u(0);
+ ppc_mtibat3u(0);
+ ppc_mtdbat0u(0);
+ ppc_mtdbat1u(0);
+ ppc_mtdbat2u(0);
+ ppc_mtdbat3u(0);
+
+ for (p = &nop32_start; p->s; p++) {
for (inst = p->s; inst < p->e; inst++)
*inst = nop_inst;
syncicache(p->s, (p->e - p->s) * sizeof(*p->e));
}
+ }
- break;
- default:
- ppc_proc_is_64b = 0;
- for (p = &nop32_start; p->s; p++) {
+ if (ppc_nobat) {
+ for (p = &nopbat_start; p->s; p++) {
for (inst = p->s; inst < p->e; inst++)
*inst = nop_inst;
syncicache(p->s, (p->e - p->s) * sizeof(*p->e));
diff --git a/sys/arch/powerpc/powerpc/pmap.c b/sys/arch/powerpc/powerpc/pmap.c
index bde7f17c1ac..622002ee4ce 100644
--- a/sys/arch/powerpc/powerpc/pmap.c
+++ b/sys/arch/powerpc/powerpc/pmap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pmap.c,v 1.143 2015/03/31 15:51:05 mpi Exp $ */
+/* $OpenBSD: pmap.c,v 1.144 2015/03/31 16:00:38 mpi Exp $ */
/*
* Copyright (c) 2001, 2002, 2007 Dale Rahn.
@@ -85,12 +85,15 @@
#include <machine/pcb.h>
#include <powerpc/powerpc.h>
+#include <powerpc/bat.h>
#include <machine/pmap.h>
#include <machine/db_machdep.h>
#include <ddb/db_extern.h>
#include <ddb/db_output.h>
+struct bat battable[16];
+
struct dumpmem dumpmem[VM_PHYSSEG_MAX];
u_int ndumpmem;
@@ -1566,6 +1569,11 @@ pmap_bootstrap(u_int kernelstart, u_int kernelend)
struct pmapvp *vp2;
/*
+ * set the page size (default value is 4K which is ok)
+ */
+ uvm_setpagesize();
+
+ /*
* Get memory.
*/
pmap_avail_setup();
@@ -1630,7 +1638,17 @@ pmap_bootstrap(u_int kernelstart, u_int kernelend)
}
}
- if (ppc_proc_is_64b) {
+ /*
+ * Initialize kernel pmap and hardware.
+ */
+#if NPMAPS >= PPC_KERNEL_SEGMENT / 16
+ usedsr[PPC_KERNEL_SEGMENT / 16 / (sizeof usedsr[0] * 8)]
+ |= 1 << ((PPC_KERNEL_SEGMENT / 16) % (sizeof usedsr[0] * 8));
+#endif
+ for (i = 0; i < 16; i++)
+ pmap_kernel()->pm_sr[i] = (PPC_KERNEL_SEG0 + i) | SR_NOEXEC;
+
+ if (ppc_nobat) {
vp1 = pmap_steal_avail(sizeof (struct pmapvp), 4);
bzero (vp1, sizeof(struct pmapvp));
pmap_kernel()->pm_vp[0] = vp1;
@@ -1645,39 +1663,56 @@ pmap_bootstrap(u_int kernelstart, u_int kernelend)
vp2->vp[k] = pted;
}
}
- }
- ppc_kvm_stolen += reserve_dumppages( (caddr_t)(VM_MIN_KERNEL_ADDRESS +
- ppc_kvm_stolen));
-
-
- /*
- * Initialize kernel pmap and hardware.
- */
-#if NPMAPS >= PPC_KERNEL_SEGMENT / 16
- usedsr[PPC_KERNEL_SEGMENT / 16 / (sizeof usedsr[0] * 8)]
- |= 1 << ((PPC_KERNEL_SEGMENT / 16) % (sizeof usedsr[0] * 8));
-#endif
- for (i = 0; i < 16; i++) {
- pmap_kernel()->pm_sr[i] = (PPC_KERNEL_SEG0 + i) | SR_NOEXEC;
- ppc_mtsrin(PPC_KERNEL_SEG0 + i, i << ADDR_SR_SHIFT);
- }
-
- if (ppc_proc_is_64b) {
/* first segment contains executable pages */
pmap_kernel()->pm_exec[0]++;
pmap_kernel()->pm_sr[0] &= ~SR_NOEXEC;
+ } else {
+ /*
+ * Setup fixed BAT registers.
+ *
+ * Note that we still run in real mode, and the BAT
+ * registers were cleared in cpu_bootstrap().
+ */
+ battable[0].batl = BATL(0x00000000, BAT_M);
+ if (physmem > atop(0x08000000))
+ battable[0].batu = BATU(0x00000000, BAT_BL_256M);
+ else
+ battable[0].batu = BATU(0x00000000, BAT_BL_128M);
- asm volatile ("sync; mtsdr1 %0; isync"
- :: "r"((u_int)pmap_ptable64 | HTABSIZE_64));
- } else
- asm volatile ("sync; mtsdr1 %0; isync"
- :: "r"((u_int)pmap_ptable32 | (pmap_ptab_mask >> 10)));
-
- pmap_avail_fixup();
-
+ /* Map physical memory with BATs. */
+ if (physmem > atop(0x10000000)) {
+ battable[0x1].batl = BATL(0x10000000, BAT_M);
+ battable[0x1].batu = BATU(0x10000000, BAT_BL_256M);
+ }
+ if (physmem > atop(0x20000000)) {
+ battable[0x2].batl = BATL(0x20000000, BAT_M);
+ battable[0x2].batu = BATU(0x20000000, BAT_BL_256M);
+ }
+ if (physmem > atop(0x30000000)) {
+ battable[0x3].batl = BATL(0x30000000, BAT_M);
+ battable[0x3].batu = BATU(0x30000000, BAT_BL_256M);
+ }
+ if (physmem > atop(0x40000000)) {
+ battable[0x4].batl = BATL(0x40000000, BAT_M);
+ battable[0x4].batu = BATU(0x40000000, BAT_BL_256M);
+ }
+ if (physmem > atop(0x50000000)) {
+ battable[0x5].batl = BATL(0x50000000, BAT_M);
+ battable[0x5].batu = BATU(0x50000000, BAT_BL_256M);
+ }
+ if (physmem > atop(0x60000000)) {
+ battable[0x6].batl = BATL(0x60000000, BAT_M);
+ battable[0x6].batu = BATU(0x60000000, BAT_BL_256M);
+ }
+ if (physmem > atop(0x70000000)) {
+ battable[0x7].batl = BATL(0x70000000, BAT_M);
+ battable[0x7].batu = BATU(0x70000000, BAT_BL_256M);
+ }
+ }
- tlbia();
+ ppc_kvm_stolen += reserve_dumppages( (caddr_t)(VM_MIN_KERNEL_ADDRESS +
+ ppc_kvm_stolen));
pmap_avail_fixup();
for (mp = pmap_avail; mp->size; mp++) {
@@ -1690,6 +1725,37 @@ pmap_bootstrap(u_int kernelstart, u_int kernelend)
}
}
+void
+pmap_enable_mmu(void)
+{
+ uint32_t scratch, sdr1;
+ int i;
+
+ if (!ppc_nobat) {
+ /* DBAT0 used for initial segment */
+ ppc_mtdbat0l(battable[0].batl);
+ ppc_mtdbat0u(battable[0].batu);
+
+ /* IBAT0 only covering the kernel .text */
+ ppc_mtibat0l(battable[0].batl);
+ ppc_mtibat0u(BATU(0x00000000, BAT_BL_8M));
+ }
+
+ for (i = 0; i < 16; i++)
+ ppc_mtsrin(PPC_KERNEL_SEG0 + i, i << ADDR_SR_SHIFT);
+
+ if (ppc_proc_is_64b)
+ sdr1 = (uint32_t)pmap_ptable64 | HTABSIZE_64;
+ else
+ sdr1 = (uint32_t)pmap_ptable32 | (pmap_ptab_mask >> 10);
+
+ asm volatile ("sync; mtsdr1 %0; isync" :: "r"(sdr1));
+ tlbia();
+
+ asm volatile ("eieio; mfmsr %0; ori %0,%0,%1; mtmsr %0; sync; isync"
+ : "=r"(scratch) : "K"(PSL_IR|PSL_DR|PSL_ME|PSL_RI));
+}
+
/*
* activate a pmap entry
* NOOP on powerpc, all PTE entries exist in the same hash table.
diff --git a/sys/arch/socppc/include/bat.h b/sys/arch/socppc/include/bat.h
deleted file mode 100644
index 16a586e725d..00000000000
--- a/sys/arch/socppc/include/bat.h
+++ /dev/null
@@ -1,3 +0,0 @@
-/* $OpenBSD: bat.h,v 1.1 2008/05/10 12:02:21 kettenis Exp $ */
-
-#include <powerpc/bat.h>
diff --git a/sys/arch/socppc/socppc/locore.S b/sys/arch/socppc/socppc/locore.S
index 603634f27f4..a7bacaf87d0 100644
--- a/sys/arch/socppc/socppc/locore.S
+++ b/sys/arch/socppc/socppc/locore.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: locore.S,v 1.15 2014/10/27 21:56:57 kettenis Exp $ */
+/* $OpenBSD: locore.S,v 1.16 2015/03/31 16:00:38 mpi Exp $ */
/* $NetBSD: locore.S,v 1.2 1996/10/16 19:33:09 ws Exp $ */
/*
@@ -382,7 +382,7 @@ nop32_3e:
mfxer %r30 /* save XER */
mtsprg 2,%r30 /* in SPRG2 */
mfsrr1 %r31 /* test kernel mode */
-nop64_1s:
+nopbat_1s:
mtcr %r31
bc 12,17,1f /* branch if PSL_PR is set */
mfdar %r31 /* get fault address */
@@ -412,7 +412,7 @@ nop64_1s:
mfsprg 1,%r1
rfi /* return to trapped code */
1:
-nop64_1e:
+nopbat_1e:
mflr %r28 /* save LR */
bla s_dsitrap
_C_LABEL(dsisize) = .-_C_LABEL(dsitrap)
@@ -1351,9 +1351,9 @@ _C_LABEL(rfi_start):
.long 0, 0
- .globl _C_LABEL(nop64_start)
-_C_LABEL(nop64_start):
- .long nop64_1s, nop64_1e
+ .globl _C_LABEL(nopbat_start)
+_C_LABEL(nopbat_start):
+ .long nopbat_1s, nopbat_1e
.long 0, 0
.globl _C_LABEL(nop32_start)
diff --git a/sys/arch/socppc/socppc/machdep.c b/sys/arch/socppc/socppc/machdep.c
index 5bacf057b29..ffcf331b9dc 100644
--- a/sys/arch/socppc/socppc/machdep.c
+++ b/sys/arch/socppc/socppc/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.63 2015/03/01 17:22:17 miod Exp $ */
+/* $OpenBSD: machdep.c,v 1.64 2015/03/31 16:00:38 mpi Exp $ */
/* $NetBSD: machdep.c,v 1.4 1996/10/16 19:33:11 ws Exp $ */
/*
@@ -51,7 +51,6 @@
#include <net/if.h>
#include <uvm/uvm_extern.h>
-#include <machine/bat.h>
#include <machine/bus.h>
#include <machine/fdt.h>
#include <machine/pio.h>
@@ -75,8 +74,6 @@ extern struct user *proc0paddr;
struct uvm_constraint_range dma_constraint = { 0x0, (paddr_t)-1 };
struct uvm_constraint_range *uvm_md_constraints[] = { NULL };
-struct bat battable[16];
-
struct vm_map *exec_map = NULL;
struct vm_map *phys_map = NULL;
@@ -152,7 +149,7 @@ initppc(u_int startkernel, u_int endkernel, char *args)
extern void *ddblow; extern int ddbsize;
#endif
extern void *msgbuf_addr;
- int exc, scratch;
+ int exc;
void *node;
extern char __bss_start[], __end[];
@@ -223,49 +220,12 @@ initppc(u_int startkernel, u_int endkernel, char *args)
curpm = curpcb->pcb_pmreal = curpcb->pcb_pm = pmap_kernel();
- ppc_check_procid();
-
- /*
- * Initialize BAT registers to unmapped to not generate
- * overlapping mappings below.
- */
- ppc_mtibat0u(0);
- ppc_mtibat1u(0);
- ppc_mtibat2u(0);
- ppc_mtibat3u(0);
- ppc_mtibat4u(0);
- ppc_mtibat5u(0);
- ppc_mtibat6u(0);
- ppc_mtibat7u(0);
- ppc_mtdbat0u(0);
- ppc_mtdbat1u(0);
- ppc_mtdbat2u(0);
- ppc_mtdbat3u(0);
- ppc_mtdbat4u(0);
- ppc_mtdbat5u(0);
- ppc_mtdbat6u(0);
- ppc_mtdbat7u(0);
-
- /*
- * Set up initial BAT table to only map the lowest 256 MB area
- */
- battable[0].batl = BATL(0x00000000, BAT_M);
- /* XXX only map 128MB for now */
- battable[0].batu = BATU(0x00000000, BAT_BL_128M);
+ cpu_bootstrap();
/*
- * Now setup fixed bat registers
- *
- * Note that we still run in real mode, and the BAT
- * registers were cleared above.
+ * Initialize pmap module.
*/
- /* DBAT0 used for initial 256 MB segment */
- ppc_mtdbat0l(battable[0].batl);
- ppc_mtdbat0u(battable[0].batu);
-
- /* IBAT0 only covering the kernel .text */
- ppc_mtibat0l(battable[0].batl);
- ppc_mtibat0u(BATU(0x00000000, BAT_BL_8M));
+ pmap_bootstrap(startkernel, endkernel);
/*
* Set up trap vectors
@@ -312,49 +272,10 @@ initppc(u_int startkernel, u_int endkernel, char *args)
syncicache((void *)EXC_RST, EXC_LAST - EXC_RST + 0x100);
- uvmexp.pagesize = 4096;
- uvm_setpagesize();
-
- /*
- * Initialize pmap module.
- */
- pmap_bootstrap(startkernel, endkernel);
-
- /* now that we know physmem size, map physical memory with BATs */
- if (physmem > atop(0x10000000)) {
- battable[0x1].batl = BATL(0x10000000, BAT_M);
- battable[0x1].batu = BATU(0x10000000, BAT_BL_256M);
- }
- if (physmem > atop(0x20000000)) {
- battable[0x2].batl = BATL(0x20000000, BAT_M);
- battable[0x2].batu = BATU(0x20000000, BAT_BL_256M);
- }
- if (physmem > atop(0x30000000)) {
- battable[0x3].batl = BATL(0x30000000, BAT_M);
- battable[0x3].batu = BATU(0x30000000, BAT_BL_256M);
- }
- if (physmem > atop(0x40000000)) {
- battable[0x4].batl = BATL(0x40000000, BAT_M);
- battable[0x4].batu = BATU(0x40000000, BAT_BL_256M);
- }
- if (physmem > atop(0x50000000)) {
- battable[0x5].batl = BATL(0x50000000, BAT_M);
- battable[0x5].batu = BATU(0x50000000, BAT_BL_256M);
- }
- if (physmem > atop(0x60000000)) {
- battable[0x6].batl = BATL(0x60000000, BAT_M);
- battable[0x6].batu = BATU(0x60000000, BAT_BL_256M);
- }
- if (physmem > atop(0x70000000)) {
- battable[0x7].batl = BATL(0x70000000, BAT_M);
- battable[0x7].batu = BATU(0x70000000, BAT_BL_256M);
- }
-
/*
* Now enable translation (and machine checks/recoverable interrupts).
*/
- __asm__ volatile ("eieio; mfmsr %0; ori %0,%0,%1; mtmsr %0; sync;isync"
- : "=r"(scratch) : "K"(PSL_IR|PSL_DR|PSL_ME|PSL_RI));
+ pmap_enable_mmu();
/*
* use the memory provided by pmap_bootstrap for message buffer