Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/powerpc Add an ofw_bootstrap() function, called dur...
details: https://anonhg.NetBSD.org/src/rev/1fa60cb4d332
branches: trunk
changeset: 952815:1fa60cb4d332
user: thorpej <thorpej%NetBSD.org@localhost>
date: Thu Feb 18 18:31:22 2021 +0000
description:
Add an ofw_bootstrap() function, called during early bootstrap from
ofwinit() to perform additional early initialization in C code. Use
this to get the memory config while we're still running in the OpenFirmware
client environment, rather than waiting until we've started fiddling with
the system state.
diffstat:
sys/arch/powerpc/include/ofw_machdep.h | 38 ++++++++++++++++++++++++++
sys/arch/powerpc/oea/ofw_subr.S | 10 +++++-
sys/arch/powerpc/powerpc/ofw_machdep.c | 49 +++++++++++++++++++++++----------
3 files changed, 80 insertions(+), 17 deletions(-)
diffs (163 lines):
diff -r 439fa604783f -r 1fa60cb4d332 sys/arch/powerpc/include/ofw_machdep.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/powerpc/include/ofw_machdep.h Thu Feb 18 18:31:22 2021 +0000
@@ -0,0 +1,38 @@
+/* $NetBSD: ofw_machdep.h,v 1.1 2021/02/18 18:31:22 thorpej Exp $ */
+
+/*-
+ * Copyright (c) 2021 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.
+ *
+ * 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 _POWERPC_OFW_MACHDEP_H_
+#define _POWERPC_OFW_MACHDEP_H_
+
+#ifdef _KERNEL
+#include <machine/powerpc.h>
+
+void ofw_bootstrap(void);
+#endif /* _KERNEL */
+
+#endif /* _POWERPC_OFW_MACHDEP_H_ */
diff -r 439fa604783f -r 1fa60cb4d332 sys/arch/powerpc/oea/ofw_subr.S
--- a/sys/arch/powerpc/oea/ofw_subr.S Thu Feb 18 18:27:24 2021 +0000
+++ b/sys/arch/powerpc/oea/ofw_subr.S Thu Feb 18 18:31:22 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ofw_subr.S,v 1.14 2021/02/18 16:29:12 thorpej Exp $ */
+/* $NetBSD: ofw_subr.S,v 1.15 2021/02/18 18:31:22 thorpej Exp $ */
/*
* Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -113,7 +113,13 @@
lis %r9,_C_LABEL(OF_buf)@ha
stw %r8,_C_LABEL(OF_buf)@l(%r9)
- /* XXX Do other stuff in C code. */
+ /*
+ * Call into C code to perform additional early initialization.
+ */
+ lis %r8,_C_LABEL(ofw_bootstrap)@ha
+ addi %r8,%r8,_C_LABEL(ofw_bootstrap)@l
+ mtctr %r8
+ bctrl
/*
* Jump off the trampoline for all subsequent calls
diff -r 439fa604783f -r 1fa60cb4d332 sys/arch/powerpc/powerpc/ofw_machdep.c
--- a/sys/arch/powerpc/powerpc/ofw_machdep.c Thu Feb 18 18:27:24 2021 +0000
+++ b/sys/arch/powerpc/powerpc/ofw_machdep.c Thu Feb 18 18:31:22 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ofw_machdep.c,v 1.26 2021/01/27 03:17:24 thorpej Exp $ */
+/* $NetBSD: ofw_machdep.c,v 1.27 2021/02/18 18:31:22 thorpej Exp $ */
/*
* Copyright (C) 1996 Wolfgang Solfrank.
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ofw_machdep.c,v 1.26 2021/01/27 03:17:24 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ofw_machdep.c,v 1.27 2021/02/18 18:31:22 thorpej Exp $");
#include <sys/param.h>
#include <sys/buf.h>
@@ -50,6 +50,8 @@
#include <machine/powerpc.h>
#include <machine/autoconf.h>
+#include <powerpc/ofw_machdep.h>
+
#ifdef DEBUG
#define DPRINTF aprint_error
#else
@@ -59,15 +61,8 @@
#define OFMEM_REGIONS 32
static struct mem_region OFmem[OFMEM_REGIONS + 1], OFavail[OFMEM_REGIONS + 3];
-/*
- * This is called during initppc, before the system is really initialized.
- * It shall provide the total and the available regions of RAM.
- * Both lists must have a zero-size entry as terminator.
- * The available regions need not take the kernel into account, but needs
- * to provide space for two additional entry beyond the terminating one.
- */
-void
-mem_regions(struct mem_region **memp, struct mem_region **availp)
+static void
+ofw_bootstrap_get_memory(void)
{
const char *macrisc[] = {"MacRISC", "MacRISC2", "MacRISC4", NULL};
int hroot, hmem, i, cnt, memcnt, regcnt, acells, scells;
@@ -225,8 +220,6 @@
}
}
- *memp = OFmem;
- *availp = OFavail;
return;
error:
@@ -239,14 +232,40 @@
OFavail[0].start = 0x3000;
OFavail[0].size = 0x20000000 - 0x3000;
- *memp = OFmem;
- *availp = OFavail;
#else
panic("no memory?");
#endif
return;
}
+/*
+ * Called from ofwinit() very early in bootstrap. We are still
+ * running on the stack provided by OpenFirmware and in the same
+ * OpenFirmware client environment as the boot loader. Our calls
+ * to OpenFirmware are direct, and not via the trampoline that
+ * saves / restores kernel state.
+ */
+void
+ofw_bootstrap(void)
+{
+ /* Get the system memory configuration. */
+ ofw_bootstrap_get_memory();
+}
+
+/*
+ * This is called during initppc, before the system is really initialized.
+ * It shall provide the total and the available regions of RAM.
+ * Both lists must have a zero-size entry as terminator.
+ * The available regions need not take the kernel into account, but needs
+ * to provide space for two additional entry beyond the terminating one.
+ */
+void
+mem_regions(struct mem_region **memp, struct mem_region **availp)
+{
+ *memp = OFmem;
+ *availp = OFavail;
+}
+
void
ppc_exit(void)
{
Home |
Main Index |
Thread Index |
Old Index