From: Milton Miller <miltonm@bga.com>
To: linuxppc-dev@ozlabs.org
Cc: Paul Mackerras <paulus@samba.org>,
David Gibson <david@gibson.dropbear.id.au>
Subject: [PATCH/EXAMPLE 15/15] bootwrapper: example sreset marshalling
Date: Tue, 10 Jul 2007 17:12:59 -0500 (CDT) [thread overview]
Message-ID: <boot-6-15.miltonm@bga.com> (raw)
In-Reply-To: <boot-6-00.miltonm@bga.com>
An example using the marshalling code that can be entered by sreset.
By linking the marshalling code is at 0 and differentiating a cpu
id from a device tree, it also works for kexec.
Signed-off-by: Milton Miller <miltonm@bga.com>
---
For reference only, not intended to be merged.
Index: work.git/arch/powerpc/boot/crt0_sample.S
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ work.git/arch/powerpc/boot/crt0_sample.S 2007-07-10 16:47:25.000000000 -0500
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2006-2007 Milton Miller, IBM Corporation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ */
+ /*
+ * This can be either a kexec started image or a sreset initiated
+ * one. kexec-tools purgatory is suppposed to copy from entry
+ * point, but instead copies from image start, so put marshal_low
+ * at address 0.
+ */
+
+ .globl _zimage_start
+_zimage_start:
+#include "marshal_low.S"
+
+ .org 0x100
+ bl get_cpu_id
+1: mflr 0
+ lis r4,1b@ha
+ addi r4,r4,1b@l
+ subf r0,r4,r0
+
+ lis r4,elected_master@ha
+ addi r4,r4,elected_master@l
+ add r4,r4,r0
+2: lwarx r6,r0,r4
+ cmpwi r6,0
+ bge 3f
+ stwcx. r3,r0,r4
+ bne- 2b
+ lwz r6,0(r4)
+
+3: lis r4,cpus_found@ha
+ addi r4,r4,cpus_found@l
+ add r4,r4,r0
+4: lwarx r12,r0,r4
+ addi r12,r12,1
+ stwcx. r12,r0,r4
+ bne- 4b
+
+ cmpw r6,r3
+ bne slave
+
+ mr r4,r0
+ li r5,0
+ b master
+
+
+ .globl _zimage_start_plat
+_zimage_start_plat:
+ b _zimage_start_lib
+
+ .weak get_cpu_id
+get_cpu_id:
+
+get_pir:
+ mfspr r3,1023 /* SPRN_PIR */
+ blr
+
+ .balign 8
+ .globl elected_master
+elected_master:
+ .long -1
+ .globl cpus_expected
+cpus_expected:
+ .long 8
+ .globl cpus_found
+cpus_found:
+ .long 0
Index: work.git/arch/powerpc/boot/sample.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ work.git/arch/powerpc/boot/sample.c 2007-07-10 16:48:45.000000000 -0500
@@ -0,0 +1,62 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Copyright IBM Corporation 2007
+ *
+ * Authors: Milton Miller <miltonm@bga.com>
+ */
+
+#include "ops.h"
+#include "reg.h"
+#include "flatdevtree.h"
+
+extern struct boot_param_header _dtb_start[], _dtb_end[];
+struct boot_param_header *sample_dt_blob;
+
+extern unsigned int get_cpu_id(void);
+extern unsigned int cpus_found, cpus_expected;
+
+void platform_init(unsigned long boot_cpu_id)
+{
+ if (boot_cpu_id > 1024) {
+ sample_dt_blob = (void *)boot_cpu_id;
+ boot_cpu_id = get_cpu_id();
+ }
+
+ if (!sample_dt_blob)
+ if (_dtb_start != _dtb_end)
+ sample_dt_blob = _dtb_start;
+
+ if (!sample_dt_blob)
+ sample_dt_blob = 31 * 1024 * 1024 + (void *)0;
+
+ if (sample_dt_blob->magic != OF_DT_HEADER)
+ fatal("No device tree at %p\n", sample_dt_blob);
+
+ if (sample_dt_blob->version < 2)
+ conv_flattree_inplace(sample_dt_blob);
+
+ sample_dt_blob->boot_cpuid_phys = boot_cpu_id;
+
+ if (cpus_found && cpus_found < cpus_expected) {
+ HMT_LOW;
+ while (cpus_found < cpus_expected) {
+ barrier();
+ }
+ HMT_MEDIUM;
+ }
+
+ kexec_platform_init(sample_dt_blob);
+}
Index: work.git/arch/powerpc/boot/Makefile
===================================================================
--- work.git.orig/arch/powerpc/boot/Makefile 2007-07-10 16:41:01.000000000 -0500
+++ work.git/arch/powerpc/boot/Makefile 2007-07-10 16:47:45.000000000 -0500
@@ -48,7 +48,7 @@ src-wlib := string.S crt0.S stdio.c main
44x.c ebony.c mv64x60.c mpsc.c mv64x60_i2c.c cuboot.c
src-plat := of.c cuboot-83xx.c cuboot-85xx.c holly.c crt0_kexec.S \
cuboot-ebony.c treeboot-ebony.c prpmc2800.c \
- ps3-head.S ps3-hvcall.S ps3.c
+ ps3-head.S ps3-hvcall.S ps3.c crt0_sample.S sample.c
src-boot := $(src-wlib) $(src-plat) empty.c
src-boot := $(addprefix $(obj)/, $(src-boot))
@@ -128,7 +128,7 @@ quiet_cmd_wrap = WRAP $@
$(if $6,$6,vmlinux)
kexec-$(CONFIG_PPC32) += zImage.kexec
-kexec-$(CONFIG_PPC64) += zImage.kexec64
+kexec-$(CONFIG_PPC64) += zImage.kexec64 zImage.sample
image-$(CONFIG_PPC_PSERIES) += zImage.pseries
image-$(CONFIG_PPC_MAPLE) += zImage.pseries
Index: work.git/arch/powerpc/boot/wrapper
===================================================================
--- work.git.orig/arch/powerpc/boot/wrapper 2007-07-10 16:41:01.000000000 -0500
+++ work.git/arch/powerpc/boot/wrapper 2007-07-10 16:47:25.000000000 -0500
@@ -139,6 +139,9 @@ kexec)
kexec64)
platformo="-e _zimage_start_64 $object/crt0_kexec.o"
;;
+sample)
+ platformo="$object/crt0_sample.o $object/sample.o"
+ ;;
miboot|uboot)
# miboot and U-boot want just the bare bits, not an ELF binary
ext=bin
prev parent reply other threads:[~2007-07-10 22:12 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-07-10 22:07 [PATCH 0/15] bootwrapper: support for kexec to zImage Milton Miller
2007-07-10 22:07 ` [PATCH 1/15] boot: find initrd location from device-tree Milton Miller
2007-07-19 2:10 ` David Gibson
2007-07-10 22:08 ` [PATCH 2/15] boot: record header bytes in gunzip_start Milton Miller
2007-07-19 2:11 ` David Gibson
2007-07-19 4:46 ` Milton Miller
2007-07-10 22:08 ` [PATCH 3/15] boot: simplfy gunzip_finish Milton Miller
2007-07-19 2:39 ` David Gibson
2007-07-19 4:01 ` Milton Miller
2007-07-19 4:31 ` David Gibson
2007-07-10 22:08 ` [PATCH 4/15] bootwrapper: smp support code Milton Miller
2007-07-10 22:09 ` [PATCH 5/15] bootwrapper: occupied memory ranges Milton Miller
2007-07-10 22:09 ` [PATCH 6/15] bootwrapper: switch 64 bit cpus to 32 bit mode Milton Miller
2007-07-10 22:57 ` Segher Boessenkool
2007-07-10 22:10 ` [PATCH 7/15] bootwrapper: Add kexec callable zImage wrapper Milton Miller
2007-07-10 23:16 ` Segher Boessenkool
2007-07-10 22:10 ` [PATCH 8/15] bootwrapper: convert flatdevtree to version 16 Milton Miller
2007-07-10 22:11 ` [PATCH 9/15] bootwrapper: rtas support Milton Miller
2007-07-10 22:11 ` [PATCH 10/15] bootwrapper: add cpio file extraction library Milton Miller
2007-07-10 22:12 ` [PATCH 11/15] bootwrapper: allow vmlinuz to be an external payload Milton Miller
2007-07-10 23:11 ` Segher Boessenkool
2007-07-10 22:12 ` [PATCH 12/15] bootwrapper: extract the vmlinux from initramfs Milton Miller
2007-07-10 22:12 ` [PATCH 13/15] bootwrapper: attach an empty vmlinux Milton Miller
2007-07-10 22:12 ` [PATCH 14/15] boot: add a hook to start cpus Milton Miller
2007-07-10 22:12 ` Milton Miller [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=boot-6-15.miltonm@bga.com \
--to=miltonm@bga.com \
--cc=david@gibson.dropbear.id.au \
--cc=linuxppc-dev@ozlabs.org \
--cc=paulus@samba.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).