summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2013-11-03 09:42:56 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2013-11-03 09:42:56 +0000
commit760ba43cf6946c6268893914c56967c7aa3eb994 (patch)
tree59b24389a621a954df09ed2fcb8a984f620cd78d
parent344cdb7f54d236c36edfbbb8456046e896d6d91c (diff)
Even saner kernel layout, so that .rodata can be batc mapped by a read-only
dbatc. Add batc mapping support for 88110 systems as well.
-rw-r--r--sys/arch/aviion/conf/ld.script17
-rw-r--r--sys/arch/luna88k/conf/ld.script17
-rw-r--r--sys/arch/m88k/m88k/m8820x_machdep.c19
-rw-r--r--sys/arch/m88k/m88k/pmap.c12
-rw-r--r--sys/arch/mvme88k/conf/ld.script17
-rw-r--r--sys/arch/mvme88k/mvme88k/m88110.c94
6 files changed, 127 insertions, 49 deletions
diff --git a/sys/arch/aviion/conf/ld.script b/sys/arch/aviion/conf/ld.script
index 01005c38a4f..d2c7645712e 100644
--- a/sys/arch/aviion/conf/ld.script
+++ b/sys/arch/aviion/conf/ld.script
@@ -1,4 +1,4 @@
-/* $OpenBSD: ld.script,v 1.1 2013/11/02 23:42:12 miod Exp $ */
+/* $OpenBSD: ld.script,v 1.2 2013/11/03 09:42:55 miod Exp $ */
/*
* Copyright (c) 2012 Miodrag Vallat.
@@ -16,11 +16,6 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-/*
- * This linker script is used to merge .rodata into .text and pad .text to
- * a page size. This allows objcopy to correctly be able to convert it to
- * an OMAGIC binary, suitable to be booted from the PROM.
- */
OUTPUT_FORMAT("elf32-m88k")
OUTPUT_ARCH(m88k)
ENTRY(__start)
@@ -29,11 +24,15 @@ SECTIONS
.text :
{
*(.text)
- *(.rodata*)
PROVIDE(etext = ABSOLUTE(.));
- FILL(0)
- . = ALIGN(0x80000);
}
+ . = ALIGN(0x80000);
+ .rodata :
+ {
+ *(.rodata*)
+ PROVIDE(erodata = ABSOLUTE(.));
+ }
+ . = ALIGN(0x80000);
.data :
{
*(.data)
diff --git a/sys/arch/luna88k/conf/ld.script b/sys/arch/luna88k/conf/ld.script
index 945ea663f55..468e22adba8 100644
--- a/sys/arch/luna88k/conf/ld.script
+++ b/sys/arch/luna88k/conf/ld.script
@@ -1,4 +1,4 @@
-/* $OpenBSD: ld.script,v 1.3 2013/11/02 23:42:12 miod Exp $ */
+/* $OpenBSD: ld.script,v 1.4 2013/11/03 09:42:55 miod Exp $ */
/*
* Copyright (c) 2012 Miodrag Vallat.
@@ -16,11 +16,6 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-/*
- * This linker script is used to merge .rodata into .text and pad .text to
- * a page size. This allows objcopy to correctly be able to convert it to
- * an OMAGIC binary, suitable to be booted from the PROM.
- */
OUTPUT_FORMAT("elf32-m88k")
OUTPUT_ARCH(m88k)
ENTRY(__start)
@@ -29,11 +24,15 @@ SECTIONS
.text :
{
*(.text)
- *(.rodata*)
PROVIDE(etext = ABSOLUTE(.));
- FILL(0)
- . = ALIGN(0x80000);
}
+ . = ALIGN(0x80000);
+ .rodata :
+ {
+ *(.rodata*)
+ PROVIDE(erodata = ABSOLUTE(.));
+ }
+ . = ALIGN(0x80000);
.data :
{
*(.data)
diff --git a/sys/arch/m88k/m88k/m8820x_machdep.c b/sys/arch/m88k/m88k/m8820x_machdep.c
index f5751b7b1f6..90cf25c5480 100644
--- a/sys/arch/m88k/m88k/m8820x_machdep.c
+++ b/sys/arch/m88k/m88k/m8820x_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: m8820x_machdep.c,v 1.59 2013/11/02 23:10:30 miod Exp $ */
+/* $OpenBSD: m8820x_machdep.c,v 1.60 2013/11/03 09:42:55 miod Exp $ */
/*
* Copyright (c) 2004, 2007, 2010, 2011, 2013, Miodrag Vallat.
*
@@ -360,11 +360,12 @@ m8820x_ibatc_set(cpuid_t cpu, uint batcno, uint32_t batc)
void
m8820x_batc_setup(cpuid_t cpu, apr_t cmode)
{
- paddr_t s_text, e_text, s_data, e_data;
+ paddr_t s_text, e_text, s_data, e_data, e_rodata;
uint batcno;
uint32_t batc, proto;
extern caddr_t kernelstart;
extern caddr_t etext;
+ extern caddr_t erodata;
extern caddr_t end;
proto = BATC_SO | BATC_V;
@@ -374,8 +375,8 @@ m8820x_batc_setup(cpuid_t cpu, apr_t cmode)
proto |= BATC_INH;
s_text = round_batc((paddr_t)&kernelstart);
- e_text = round_batc((paddr_t)&etext);
- s_data = trunc_batc((paddr_t)&etext);
+ s_data = e_text = round_batc((paddr_t)&etext);
+ e_rodata = round_batc((paddr_t)&erodata);
#if 0 /* not until pmap makes sure kvm starts on a BATC boundary */
e_data = round_batc((paddr_t)&end);
#else
@@ -397,8 +398,7 @@ m8820x_batc_setup(cpuid_t cpu, apr_t cmode)
break;
}
-#if !defined(MULTIPROCESSOR) /* XXX */
- /* map s_data..e_data with DBATC */
+ /* map e_text..e_data with DBATC */
if (cmode & CACHE_GLOBAL)
proto |= BATC_GLOBAL;
batcno = 0;
@@ -406,6 +406,12 @@ m8820x_batc_setup(cpuid_t cpu, apr_t cmode)
batc = (s_data >> BATC_BLKSHIFT) << BATC_VSHIFT;
batc |= (s_data >> BATC_BLKSHIFT) << BATC_PSHIFT;
batc |= proto;
+ if (s_data < e_rodata)
+ batc |= BATC_PROT;
+#if defined(MULTIPROCESSOR) /* XXX */
+ else
+ break;
+#endif
#ifdef DEBUG
printf("cpu%d dbat%d %p(%08x)\n", cpu, batcno, s_data, batc);
#endif
@@ -414,7 +420,6 @@ m8820x_batc_setup(cpuid_t cpu, apr_t cmode)
if (++batcno == BATC_MAX)
break;
}
-#endif
}
/*
diff --git a/sys/arch/m88k/m88k/pmap.c b/sys/arch/m88k/m88k/pmap.c
index ca992455ea7..a9a73e87ebb 100644
--- a/sys/arch/m88k/m88k/pmap.c
+++ b/sys/arch/m88k/m88k/pmap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pmap.c,v 1.73 2013/11/02 23:10:30 miod Exp $ */
+/* $OpenBSD: pmap.c,v 1.74 2013/11/03 09:42:55 miod Exp $ */
/*
* Copyright (c) 2001-2004, 2010, Miodrag Vallat.
@@ -540,7 +540,7 @@ pmap_map(paddr_t pa, psize_t sz, vm_prot_t prot, u_int cmode)
void
pmap_bootstrap(paddr_t s_rom, paddr_t e_rom)
{
- paddr_t s_low, s_text, e_text;
+ paddr_t s_low, s_text, e_rodata;
unsigned int npdtpg, nsdt, npdt;
unsigned int i;
sdt_entry_t *sdt;
@@ -548,12 +548,12 @@ pmap_bootstrap(paddr_t s_rom, paddr_t e_rom)
paddr_t pa, sdtpa, ptepa;
const struct pmap_table *ptable;
extern void *kernelstart;
- extern void *etext;
+ extern void *erodata;
virtual_avail = (vaddr_t)avail_end;
s_text = trunc_page((vaddr_t)&kernelstart);
- e_text = round_page((vaddr_t)&etext);
+ e_rodata = round_page((vaddr_t)&erodata);
/*
* Reserve space for 1:1 memory mapping in supervisor space.
@@ -622,9 +622,9 @@ pmap_bootstrap(paddr_t s_rom, paddr_t e_rom)
/* memory below the kernel image */
for (i = atop(s_text); i != 0; i--)
*pte++ = PG_NV;
- /* kernel text */
+ /* kernel text and rodata */
pa = s_text;
- for (i = atop(e_text) - atop(pa); i != 0; i--) {
+ for (i = atop(e_rodata) - atop(pa); i != 0; i--) {
*pte++ = pa | PG_SO | PG_RO | PG_W | PG_V;
pa += PAGE_SIZE;
}
diff --git a/sys/arch/mvme88k/conf/ld.script b/sys/arch/mvme88k/conf/ld.script
index 01005c38a4f..d2c7645712e 100644
--- a/sys/arch/mvme88k/conf/ld.script
+++ b/sys/arch/mvme88k/conf/ld.script
@@ -1,4 +1,4 @@
-/* $OpenBSD: ld.script,v 1.1 2013/11/02 23:42:12 miod Exp $ */
+/* $OpenBSD: ld.script,v 1.2 2013/11/03 09:42:55 miod Exp $ */
/*
* Copyright (c) 2012 Miodrag Vallat.
@@ -16,11 +16,6 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-/*
- * This linker script is used to merge .rodata into .text and pad .text to
- * a page size. This allows objcopy to correctly be able to convert it to
- * an OMAGIC binary, suitable to be booted from the PROM.
- */
OUTPUT_FORMAT("elf32-m88k")
OUTPUT_ARCH(m88k)
ENTRY(__start)
@@ -29,11 +24,15 @@ SECTIONS
.text :
{
*(.text)
- *(.rodata*)
PROVIDE(etext = ABSOLUTE(.));
- FILL(0)
- . = ALIGN(0x80000);
}
+ . = ALIGN(0x80000);
+ .rodata :
+ {
+ *(.rodata*)
+ PROVIDE(erodata = ABSOLUTE(.));
+ }
+ . = ALIGN(0x80000);
.data :
{
*(.data)
diff --git a/sys/arch/mvme88k/mvme88k/m88110.c b/sys/arch/mvme88k/mvme88k/m88110.c
index a04f923760d..5b6152f553f 100644
--- a/sys/arch/mvme88k/mvme88k/m88110.c
+++ b/sys/arch/mvme88k/mvme88k/m88110.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: m88110.c,v 1.81 2013/11/02 23:10:30 miod Exp $ */
+/* $OpenBSD: m88110.c,v 1.82 2013/11/03 09:42:55 miod Exp $ */
/*
* Copyright (c) 2010, 2011, Miodrag Vallat.
@@ -181,23 +181,39 @@ const struct cmmu_p cmmu88410 = {
size_t mc88410_linesz[2] = { 5, 5 }; /* log2 of L2 cache line size */
size_t mc88410_cachesz[2] = { 256, 256 }; /* L2 cache size in KB */
-void patc_clear(void);
+void m88110_dbatc_set(uint, uint32_t);
+void m88110_ibatc_set(uint, uint32_t);
+void m88110_patc_clear(void);
void m88110_cmmu_wb_locked(paddr_t, psize_t);
void m88110_cmmu_wbinv_locked(paddr_t, psize_t);
void m88110_cmmu_inv_locked(paddr_t, psize_t);
void
-patc_clear(void)
+m88110_dbatc_set(uint batno, uint32_t val)
{
- int i;
+ set_dir(batno);
+ set_dbp(val);
+}
+
+void
+m88110_ibatc_set(uint batno, uint32_t val)
+{
+ set_iir(batno);
+ set_ibp(val);
+}
- for (i = 0; i < 32; i++) {
- set_dir(i << 5);
+void
+m88110_patc_clear(void)
+{
+ uint patcno;
+
+ for (patcno = 0; patcno < 32; patcno++) {
+ set_dir(patcno << 5);
set_dppu(0);
set_dppl(0);
- set_iir(i << 5);
+ set_iir(patcno << 5);
set_ippu(0);
set_ippl(0);
}
@@ -296,6 +312,66 @@ m88410_init(void)
void
m88110_batc_setup(cpuid_t cpu, apr_t cmode)
{
+ paddr_t s_text, e_text, s_data, e_data, e_rodata;
+ uint batcno;
+ uint32_t batc, proto;
+ extern caddr_t kernelstart;
+ extern caddr_t etext;
+ extern caddr_t erodata;
+ extern caddr_t end;
+
+ proto = BATC_SO | BATC_V;
+ if (cmode & CACHE_WT)
+ proto |= BATC_WT;
+ if (cmode & CACHE_INH)
+ proto |= BATC_INH;
+
+ s_text = round_batc((paddr_t)&kernelstart);
+ s_data = e_text = round_batc((paddr_t)&etext);
+ e_rodata = round_batc((paddr_t)&erodata);
+#if 0 /* not until pmap makes sure kvm starts on a BATC boundary */
+ e_data = round_batc((paddr_t)&end);
+#else
+ e_data = trunc_batc((paddr_t)&end);
+#endif
+
+ /* map s_text..e_text with IBATC */
+ batcno = 0;
+ while (s_text != e_text) {
+ batc = (s_text >> BATC_BLKSHIFT) << BATC_VSHIFT;
+ batc |= (s_text >> BATC_BLKSHIFT) << BATC_PSHIFT;
+ batc |= proto;
+#ifdef DEBUG
+ printf("cpu%d ibat%d %p(%08x)\n", cpu, batcno, s_text, batc);
+#endif
+ m88110_ibatc_set(batcno, batc);
+ s_text += BATC_BLKBYTES;
+ if (++batcno == BATC_MAX)
+ break;
+ }
+
+ /* map e_text..e_data with DBATC */
+ if (cmode & CACHE_GLOBAL)
+ proto |= BATC_GLOBAL;
+ batcno = 0;
+ while (s_data != e_data) {
+ batc = (s_data >> BATC_BLKSHIFT) << BATC_VSHIFT;
+ batc |= (s_data >> BATC_BLKSHIFT) << BATC_PSHIFT;
+ batc |= proto;
+ if (s_data < e_rodata)
+ batc |= BATC_PROT;
+#if defined(MULTIPROCESSOR) /* XXX */
+ else
+ break;
+#endif
+#ifdef DEBUG
+ printf("cpu%d dbat%d %p(%08x)\n", cpu, batcno, s_data, batc);
+#endif
+ m88110_dbatc_set(batcno, batc);
+ s_data += BATC_BLKBYTES;
+ if (++batcno == BATC_MAX)
+ break;
+ }
}
cpuid_t
@@ -329,7 +405,7 @@ m88110_initialize_cpu(cpuid_t cpu)
}
/* clear PATCs */
- patc_clear();
+ m88110_patc_clear();
ictl = BATC_512K | CMMU_ICTL_DID | CMMU_ICTL_CEN | CMMU_ICTL_BEN;
@@ -487,7 +563,7 @@ m88110_set_sapr(apr_t ap)
set_isap(ap);
set_dsap(ap);
- patc_clear();
+ m88110_patc_clear();
set_icmd(CMMU_ICMD_INV_UATC);
set_icmd(CMMU_ICMD_INV_SATC);