summaryrefslogtreecommitdiffstats
path: root/purgatory
diff options
context:
space:
mode:
authorMaxim Uvarov <muvarov@gmail.com>2010-05-12 11:08:41 +0400
committerSimon Horman <horms@verge.net.au>2010-05-13 23:47:28 +0900
commit00f6fff403c6bbb3241def8451d17f5f2544b5a9 (patch)
treeda4ac430f191fb9e9e8031cf5c6fb86e6e33c118 /purgatory
parent51234576b4ed8d4fcaf2ef1bbd625e050c592d15 (diff)
downloadkexec-tools-00f6fff403c6bbb3241def8451d17f5f2544b5a9.tar.gz
Fix kexec on powerpc32
Signed-off-by: Maxim Uvarov <muvarov@gmail.com> Signed-off-by: Maxim Uvarov <muvarov@gmail.com> Signed-off-by: Simon Horman <horms@verge.net.au>
Diffstat (limited to 'purgatory')
-rw-r--r--purgatory/arch/ppc/Makefile2
-rw-r--r--purgatory/arch/ppc/purgatory-ppc.c38
-rw-r--r--purgatory/arch/ppc/purgatory-ppc.h4
-rw-r--r--purgatory/arch/ppc/v2wrap.S66
-rw-r--r--purgatory/arch/ppc/v2wrap_32.S91
5 files changed, 124 insertions, 77 deletions
diff --git a/purgatory/arch/ppc/Makefile b/purgatory/arch/ppc/Makefile
index 0dd18b67..72289a09 100644
--- a/purgatory/arch/ppc/Makefile
+++ b/purgatory/arch/ppc/Makefile
@@ -2,7 +2,7 @@
# Purgatory ppc
#
-ppc_PURGATORY_SRCS += purgatory/arch/ppc/v2wrap.S
+ppc_PURGATORY_SRCS += purgatory/arch/ppc/v2wrap_32.S
ppc_PURGATORY_SRCS += purgatory/arch/ppc/misc.S
ppc_PURGATORY_SRCS += purgatory/arch/ppc/purgatory-ppc.c
ppc_PURGATORY_SRCS += purgatory/arch/ppc/console-ppc.c
diff --git a/purgatory/arch/ppc/purgatory-ppc.c b/purgatory/arch/ppc/purgatory-ppc.c
index 01d0f386..3d7d4849 100644
--- a/purgatory/arch/ppc/purgatory-ppc.c
+++ b/purgatory/arch/ppc/purgatory-ppc.c
@@ -1,19 +1,41 @@
+/*
+ * kexec: Linux boots Linux
+ *
+ * Created by: Mohan Kumar M (mohan@in.ibm.com)
+ *
+ * Copyright (C) IBM Corporation, 2005. All rights reserved
+ *
+ * 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 (version 2 of the License).
+ *
+ * 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, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
#include <purgatory.h>
#include "purgatory-ppc.h"
-unsigned int pul_stack = 0;
-unsigned int dt_offset = 0;
-unsigned int kernel = 0;
-unsigned int epapr_magic = 0;
-unsigned int mem_size = 0;
+unsigned int panic_kernel = 0;
+unsigned long backup_start = 0;
+unsigned long stack = 0;
+unsigned long dt_offset = 0;
+unsigned long my_toc = 0;
+unsigned long kernel = 0;
void setup_arch(void)
{
- /* Nothing for now */
+ return;
}
-/* This function can be used to execute after the SHA256 verification. */
void post_verification_setup_arch(void)
{
- /* Nothing for now */
+ if (panic_kernel)
+ crashdump_backup_memory();
}
diff --git a/purgatory/arch/ppc/purgatory-ppc.h b/purgatory/arch/ppc/purgatory-ppc.h
index e931cae6..7eff8aaa 100644
--- a/purgatory/arch/ppc/purgatory-ppc.h
+++ b/purgatory/arch/ppc/purgatory-ppc.h
@@ -1,6 +1,6 @@
#ifndef PURGATORY_PPC_H
#define PURGATORY_PPC_H
-/* nothing yet */
-
+void crashdump_backup_memory(void);
+void post_verification_setup_arch(void);
#endif /* PURGATORY_PPC_H */
diff --git a/purgatory/arch/ppc/v2wrap.S b/purgatory/arch/ppc/v2wrap.S
deleted file mode 100644
index 79d188f0..00000000
--- a/purgatory/arch/ppc/v2wrap.S
+++ /dev/null
@@ -1,66 +0,0 @@
-#
-# kexec: Linux boots Linux
-#
-# Copyright (C) 2004 - 2005, Milton D Miller II, IBM Corporation
-# Copyright (C) 2006, Mohan Kumar M (mohan@in.ibm.com), IBM Corporation
-# Copyright (C) 2008, Sebastian Andrzej Siewior (bigeasy@linutronix.de), linutronix
-#
-# 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 (version 2 of the License).
-#
-# 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, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-#
-
-#include "ppc_asm.h"
-
-# v2wrap.S
-# a wrapper to call purgatory code
-# Invokes ppc kernel with the arguments according to ePAPR v1.0
-# It assumes that the MSR is allready correct.
-
-# calling convention:
-# no register are considred
-#
-
-#define LOADADDR(rn,name) \
- lis rn,name##@h; \
- ori rn,rn,name##@l; \
-
- .globl purgatory_start
-purgatory_start:
-
- LOADADDR(r6,pul_stack)
- lwz r1,0(r6) #setup stack
-
- subi r1, r1, 112
- bl purgatory
- nop
-
- LOADADDR(r6,kernel)
- lwz r4,0(r6) # load the kernel address
- mtlr r4 # prepare branch too
-
- LOADADDR(r6, dt_offset)
- lwz r3, 0(r6) # load device-tree address
-
- li r4, 0
- li r5, 0
-
- LOADADDR(r6, epapr_magic) # ePAPR magic value
- lwz r6, 0(r6)
-
- LOADADDR(r7, mem_size) # the Initial Mapped Area
- lwz r7, 0(r6)
-
- li r8, 0
- li r9, 0
-
- blr # start kernel
diff --git a/purgatory/arch/ppc/v2wrap_32.S b/purgatory/arch/ppc/v2wrap_32.S
new file mode 100644
index 00000000..8442d162
--- /dev/null
+++ b/purgatory/arch/ppc/v2wrap_32.S
@@ -0,0 +1,91 @@
+#
+# kexec: Linux boots Linux
+#
+# Copyright (C) 2004 - 2005, Milton D Miller II, IBM Corporation
+# Copyright (C) 2006, Mohan Kumar M (mohan@in.ibm.com), 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 (version 2 of the License).
+#
+# 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, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+#
+
+# v2wrap.S
+# a wrapper to call purgatory code to backup first
+# 32kB of first kernel into the backup region
+# reserved by kexec-tools.
+# Invokes powerpc kernel with the expected arguments
+# of kernel(device-tree, phys-offset, 0)
+
+#
+# calling convention:
+# r3 = physical number of this cpu (all cpus)
+# r4 = address of this chunk (master only)
+# master enters at purgatory_start (aka first byte of this chunk)
+# slaves (additional cpus), if any, enter a copy of the
+# first 0x100 bytes of this code relocated to 0x0
+#
+# in other words,
+# a copy of the first 0x100 bytes of this code is copied to 0
+# and the slaves are sent to address 0x60
+# with r3 = their physical cpu number.
+
+ .globl purgatory_start
+purgatory_start: b master
+ .org purgatory_start + 0x60 # ABI: slaves start at 60 with r3=phys
+slave: b $
+ .org purgatory_start + 0x100 # ABI: end of copied region
+ .size purgatory_start, . - purgatory_start
+
+#
+# The above 0x100 bytes at purgatory_start are replaced with the
+# code from the kernel (or next stage) by kexec/arch/powerpc/kexec-powerpc.c
+#
+
+master:
+ or 1,1,1 # low priority to let other threads catchup
+ isync
+ mr 17,3 # save cpu id to r17
+ mr 15,4 # save physical address in reg15
+
+ lis 6,stack@h
+ ori 6,6,stack@l
+ lwz 1,0(6) #setup stack
+
+ subi 1,1,112
+ bl purgatory
+ nop
+
+ or 3,3,3 # ok now to high priority, lets boot
+ lis 6,0x1
+ mtctr 6 # delay a bit for slaves to catch up
+83: bdnz 83b # before we overwrite 0-100 again
+
+ lis 6,dt_offset@h
+ ori 6,6,dt_offset@l
+ lwz 3,0(6) # load device-tree address
+ lwz 6,20(3) # fetch version number
+ cmpwi 0,6,2 # v2 ?
+ blt 80f
+ stw 17,28(3) # save my cpu number as boot_cpu_phys
+80:
+ lis 6,kernel@h
+ ori 6,6,kernel@l
+ lwz 4,0(6) # load the kernel address
+ li 5,0 # r5 will be 0 for kernel
+ li 6,0 # clear r6 for good measure
+ mtctr 4 # prepare branch too
+
+ lwz 8,0(4) # get the first instruction that we stole
+ stw 8,0(0) # and put it in the slave loop at 0
+ # skip cache flush, do we care?
+
+ bctr # start kernel