summaryrefslogtreecommitdiff
path: root/sys/arch/sparc64/include
diff options
context:
space:
mode:
authorcdi <cdi@NetBSD.org>2006-01-27 18:37:49 +0000
committercdi <cdi@NetBSD.org>2006-01-27 18:37:49 +0000
commit4c2e4320bd13e4cbea1e7f2bb4e130202d00a523 (patch)
tree221f0a253d99b181928545feb19a2b2493c85401 /sys/arch/sparc64/include
parent97aa1417ff2c6fb2f1ce0c64e018be5211e81769 (diff)
Alter sparc64 bootstrap, catch up to ofwboot v1.9:
- Accept bootinfo structure passed down from ofwboot v1.9 - Drop kernel re-mapping code - Use permanent 4MB mappings provided by the loader instead - Change kernel entry address to point directly at the code instead of pointing at the trap table's first slot. This allows the bootloader to detect those kernels which are aware of the new boot scheme - Due to the changes in kernel mapping code, alter secondary CPU bootstrap code to use trampoline just like FreeBSD does (some FreeBSD code is used here as well)
Diffstat (limited to 'sys/arch/sparc64/include')
-rw-r--r--sys/arch/sparc64/include/autoconf.h6
-rw-r--r--sys/arch/sparc64/include/bootinfo.h134
-rw-r--r--sys/arch/sparc64/include/cpu.h30
-rw-r--r--sys/arch/sparc64/include/loadfile_machdep.h73
-rw-r--r--sys/arch/sparc64/include/pmap.h8
-rw-r--r--sys/arch/sparc64/include/vmparam.h10
6 files changed, 243 insertions, 18 deletions
diff --git a/sys/arch/sparc64/include/autoconf.h b/sys/arch/sparc64/include/autoconf.h
index da30063446d..dbcb1474a0f 100644
--- a/sys/arch/sparc64/include/autoconf.h
+++ b/sys/arch/sparc64/include/autoconf.h
@@ -1,4 +1,4 @@
-/* $NetBSD: autoconf.h,v 1.23 2005/12/11 12:19:10 christos Exp $ */
+/* $NetBSD: autoconf.h,v 1.24 2006/01/27 18:37:49 cdi Exp $ */
/*-
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -157,6 +157,8 @@ struct device *parsedisk __P((char *, int, int, dev_t *));
void mountroot_hook_establish __P((void (*) __P((struct device *)),
struct device *));
-void bootstrap __P((int));
+/* Kernel initialization routine. */
+void bootstrap(void *, void *, void *, void *, void *);
+
struct device *getdevunit __P((const char *, int));
int romgetcursoraddr __P((int **, int **));
diff --git a/sys/arch/sparc64/include/bootinfo.h b/sys/arch/sparc64/include/bootinfo.h
index 8147ddf2b11..bc63f4a704a 100644
--- a/sys/arch/sparc64/include/bootinfo.h
+++ b/sys/arch/sparc64/include/bootinfo.h
@@ -1,3 +1,135 @@
-/* $NetBSD: bootinfo.h,v 1.1 2002/07/20 11:52:21 mrg Exp $ */
+/* $NetBSD: bootinfo.h,v 1.2 2006/01/27 18:37:49 cdi Exp $ */
+/*-
+ * Copyright (c) 2005 The NetBSD Foundation, Inc.
+ * 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 the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``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 FOUNDATION OR CONTRIBUTORS
+ * 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 _BOOTINFO_H_
+#define _BOOTINFO_H_
+
+#include <machine/param.h>
#include <sparc/bootinfo.h>
+
+/*
+ * The bootloader v1.9 and higher makes a call into a kernel with the following
+ * arguments:
+ *
+ * %o0 OpenFirmware entry point, to keep Sun's updaters happy
+ * %o1 Address of boot information vector (see below)
+ * %o2 Length of the vector, in bytes
+ * %o3 OpenFirmware entry point, to mimic Sun bootloader behavior
+ * %o4 OpenFirmware entry point, to meet earlier NetBSD kernels
+ * expectations
+ *
+ * All parameters are of void* type except for vector length which is of
+ * integer type.
+ *
+ * The boot information vector format was dictated by earlier kernels and
+ * starting from ofwboot v1.9 has four entries:
+ *
+ * +-------------------------------------+
+ * #0 | NetBSD boot magic number ('DDB2') |
+ * +-------------------------------------+
+ * #1 | ksyms' table end address |
+ * +-------------------------------------+
+ * #2 | ksyms' table start address |
+ * +-------------------------------------+
+ * #3 | Pointer to a bootinfo binary object |
+ * +-------------------------------------+
+ *
+ * Kernels written for pre-v1.8 ofwboot require first three cells to present
+ * in this particular order, those that rely on v1.9 and higher won't work if
+ * the last pointer is not in the table; therefore, the vector cannot be
+ * shorter than 4 * sizeof(u_int32_t) or 4 * sizeof(u_int64_t) for 32-bit and
+ * 64-bit boot loader, respectively.
+ *
+ * As of ofwboot v1.9, bootinfo binary object is placed right after the kernel
+ * data segment end, i.e. in the permanently locked 4MB page. There is no order
+ * for the data located in bootinfo binary object. The kernel however expects
+ * at least following parameters to exist in there:
+ *
+ * - Symbol information (size, start, end; see struct btinfo_symtab)
+ * - Kernel end address, calculated as true kernel end address plus size of
+ * space reserved for bootinfo binary object (struct btinfo_kernend)
+ * - Number of text segment pages (struct btinfo_count)
+ * - Number of data segment pages (struct btinfo_count)
+ * - Array of text pages VA/PA (struct btinfo_tlb)
+ * - Array of data pages VA/PA (struct btinfo_tlb)
+ *
+ * The last four data structures fully describe kernel mappings. ofwboot v1.9
+ * and higher map the kernel with 4MB permanent pages and this is the only
+ * way to let kernel know how exactly it was mapped.
+ */
+
+/* Boot magic number */
+#define SPARC_MACHINE_OPENFIRMWARE 0x44444230
+
+#ifdef BOOTINFO_SIZE
+#undef BOOTINFO_SIZE
+#endif
+
+#define BOOTINFO_SIZE NBPG
+
+#define BTINFO_DTLB_SLOTS 100
+#define BTINFO_ITLB_SLOTS 101
+#define BTINFO_DTLB 102
+#define BTINFO_ITLB 103
+#define BTINFO_KERNEND 104
+
+#define LOOKUP_BOOTINFO(btp, info) \
+do { \
+ if ( ((btp) = lookup_bootinfo(info)) == NULL) { \
+ panic("lookup_bootinfo: No " #info " found.\n"); \
+ } \
+} while (0)
+
+struct tlb_entry {
+ uint64_t te_pa;
+ uint64_t te_va;
+};
+
+struct btinfo_count {
+ struct btinfo_common common;
+ int count;
+};
+
+struct btinfo_tlb {
+ struct btinfo_common common;
+ struct tlb_entry tlb[1];
+};
+
+struct btinfo_kernend {
+ struct btinfo_common common;
+ uint64_t addr;
+};
+
+#endif /* _BOOTINFO_H_ */
diff --git a/sys/arch/sparc64/include/cpu.h b/sys/arch/sparc64/include/cpu.h
index 7480a2e53e4..cf20c1ca140 100644
--- a/sys/arch/sparc64/include/cpu.h
+++ b/sys/arch/sparc64/include/cpu.h
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.h,v 1.50 2005/12/24 20:07:37 perry Exp $ */
+/* $NetBSD: cpu.h,v 1.51 2006/01/27 18:37:49 cdi Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -109,11 +109,19 @@ struct cpu_info {
/* Most important fields first */
struct lwp *ci_curlwp;
- struct cpu_data ci_data; /* MI per-cpu data */
struct pcb *ci_cpcb;
struct cpu_info *ci_next;
struct lwp *ci_fplwp;
+
+ void *ci_eintstack;
+ struct pcb *ci_idle_u;
+
+ /* Spinning up the CPU */
+ void (*ci_spinup) __P((void));
+ void *ci_initstack;
+ paddr_t ci_paddr;
+
int ci_number;
int ci_upaid;
int ci_cpuid;
@@ -123,11 +131,6 @@ struct cpu_info {
*/
struct cc_microtime_state ci_cc;
- /* Spinning up the CPU */
- void (*ci_spinup) __P((void));
- void *ci_initstack;
- paddr_t ci_paddr;
-
/* CPU PROM information. */
u_int ci_node;
@@ -135,8 +138,7 @@ struct cpu_info {
int ci_want_ast;
int ci_want_resched;
- void *ci_eintstack;
- struct pcb *ci_idle_u;
+ struct cpu_data ci_data; /* MI per-cpu data */
};
#define CPUF_PRIMARY 1
@@ -191,7 +193,15 @@ extern struct cpu_info *cpus;
void cpu_proc_fork(struct proc *, struct proc *);
#if defined(MULTIPROCESSOR)
-void cpu_mp_startup __P((void));
+extern vaddr_t cpu_spinup_trampoline;
+
+extern char *mp_tramp_code;
+extern u_long mp_tramp_code_len;
+extern u_long mp_tramp_tlb_slots;
+extern u_long mp_tramp_func;
+extern u_long mp_tramp_ci;
+
+void cpu_hatch __P((void));
void cpu_boot_secondary_processors __P((void));
#endif
diff --git a/sys/arch/sparc64/include/loadfile_machdep.h b/sys/arch/sparc64/include/loadfile_machdep.h
index 0b117662c3a..75bd4089f05 100644
--- a/sys/arch/sparc64/include/loadfile_machdep.h
+++ b/sys/arch/sparc64/include/loadfile_machdep.h
@@ -1,3 +1,72 @@
-/* $NetBSD: loadfile_machdep.h,v 1.1 2000/08/16 08:17:50 mrg Exp $ */
+/* $NetBSD: loadfile_machdep.h,v 1.2 2006/01/27 18:37:49 cdi Exp $ */
-#include <sparc/loadfile_machdep.h>
+/*-
+ * Copyright (c) 2005 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Christos Zoulas.
+ *
+ * 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 the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``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 FOUNDATION OR CONTRIBUTORS
+ * 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.
+ */
+
+#define LOAD_KERNEL LOAD_ALL
+#define COUNT_KERNEL COUNT_ALL
+
+#ifdef _STANDALONE
+#define LOADADDR(a) ((long)(a))
+#define ALIGNENTRY(a) ((u_long)(a))
+#define READ(f, b, c) sparc64_read((f), (void *)LOADADDR(b), (c))
+#define BCOPY(s, d, c) sparc64_memcpy((void *)LOADADDR(d), \
+ (void *)(s), (c))
+#define BZERO(d, c) sparc64_memset((void *)LOADADDR(d), 0, (c))
+#define WARN(a) (void)(printf a, \
+ printf((errno ? ": %s\n" : "\n"), \
+ strerror(errno)))
+#define PROGRESS(a) (void) printf a
+#define ALLOC(a) alloc(a)
+#define DEALLOC(a, b) dealloc(a, b)
+#define OKMAGIC(a) ((a) == OMAGIC)
+
+extern ssize_t sparc64_read(int, void *, size_t);
+extern void* sparc64_memcpy(void *, const void *, size_t);
+extern void* sparc64_memset(void *, int, size_t);
+
+#else
+#define LOADADDR(a) (((u_long)(a)) + (u_long)offset)
+#define ALIGNENTRY(a) ((u_long)(a))
+#define READ(f, b, c) read((f), (void *)LOADADDR(b), (c))
+#define BCOPY(s, d, c) memcpy((void *)LOADADDR(d), (void *)(s), (c))
+#define BZERO(d, c) memset((void *)LOADADDR(d), 0, (c))
+#define WARN(a) warn a
+#define PROGRESS(a) /* nothing */
+#define ALLOC(a) malloc(a)
+#define FREE(a, b) free(a)
+#define OKMAGIC(a) ((a) == OMAGIC)
+#endif
diff --git a/sys/arch/sparc64/include/pmap.h b/sys/arch/sparc64/include/pmap.h
index f19454f9078..dfd7933b92a 100644
--- a/sys/arch/sparc64/include/pmap.h
+++ b/sys/arch/sparc64/include/pmap.h
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.h,v 1.34 2005/12/11 12:19:10 christos Exp $ */
+/* $NetBSD: pmap.h,v 1.35 2006/01/27 18:37:49 cdi Exp $ */
/*-
* Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -173,7 +173,7 @@ int pmap_count_wired __P((struct pmap *));
void pmap_activate_pmap(struct pmap *);
void pmap_update(struct pmap *);
-void pmap_bootstrap __P((u_long kernelstart, u_long kernelend, u_int numctx));
+void pmap_bootstrap __P((u_long, u_long));
/* make sure all page mappings are modulo 16K to prevent d$ aliasing */
#define PMAP_PREFER(pa, va, sz, td) (*(va)+=(((*(va))^(pa))&(1<<(PGSHIFT))))
@@ -194,6 +194,10 @@ void pmap_kprotect(vaddr_t, vm_prot_t);
int ctx_alloc __P((struct pmap *));
void ctx_free __P((struct pmap *));
+/* Installed physical memory, as discovered during bootstrap. */
+extern int phys_installed_size;
+extern struct mem_region *phys_installed;
+
#endif /* _KERNEL */
#endif /* _LOCORE */
diff --git a/sys/arch/sparc64/include/vmparam.h b/sys/arch/sparc64/include/vmparam.h
index 0d2a704c830..d800806a6bc 100644
--- a/sys/arch/sparc64/include/vmparam.h
+++ b/sys/arch/sparc64/include/vmparam.h
@@ -1,4 +1,4 @@
-/* $NetBSD: vmparam.h,v 1.28 2005/12/11 12:19:10 christos Exp $ */
+/* $NetBSD: vmparam.h,v 1.29 2006/01/27 18:37:49 cdi Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -56,6 +56,14 @@
#define PAGE_MASK (PAGE_SIZE - 1)
/*
+ * The kernel itself is mapped by the boot loader with 4Mb locked VM pages,
+ * so let's keep 4Mb definitions here as well.
+ */
+#define PAGE_SHIFT_4M 22
+#define PAGE_SIZE_4M (1UL<<PAGE_SHIFT_4M)
+#define PAGE_MASK_4M (PAGE_SIZE_4M-1)
+
+/*
* USRSTACK is the top (end) of the user stack.
*/
#define USRSTACK32 0xffffe000L