From 39a4574652f2f7bae2f18b4eb6f5f9bf788466a6 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Mon, 24 Jun 2013 15:21:46 +0200 Subject: powerpc: Add r2 to CPU context The r2 may be used for thread-local storage. --- c/src/lib/libcpu/powerpc/new-exceptions/cpu.c | 2 ++ c/src/lib/libcpu/powerpc/new-exceptions/cpu_asm.S | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'c/src/lib/libcpu/powerpc') diff --git a/c/src/lib/libcpu/powerpc/new-exceptions/cpu.c b/c/src/lib/libcpu/powerpc/new-exceptions/cpu.c index 120ee07c9d..d6a883a6ad 100644 --- a/c/src/lib/libcpu/powerpc/new-exceptions/cpu.c +++ b/c/src/lib/libcpu/powerpc/new-exceptions/cpu.c @@ -68,6 +68,7 @@ void _CPU_Context_Initialize( ppc_context *the_ppc_context; uint32_t msr_value; uint32_t sp; + register uint32_t gpr2 __asm__("2"); sp = (uint32_t)stack_base + size - PPC_MINIMUM_STACK_FRAME_SIZE; @@ -127,6 +128,7 @@ void _CPU_Context_Initialize( the_ppc_context->gpr1 = sp; the_ppc_context->msr = msr_value; the_ppc_context->lr = (uint32_t) entry_point; + the_ppc_context->gpr2 = gpr2; #ifdef __ALTIVEC__ _CPU_Context_initialize_altivec( the_ppc_context ); diff --git a/c/src/lib/libcpu/powerpc/new-exceptions/cpu_asm.S b/c/src/lib/libcpu/powerpc/new-exceptions/cpu_asm.S index 0a96c32ef1..c40803ac2a 100644 --- a/c/src/lib/libcpu/powerpc/new-exceptions/cpu_asm.S +++ b/c/src/lib/libcpu/powerpc/new-exceptions/cpu_asm.S @@ -23,7 +23,7 @@ * COPYRIGHT (c) 1989-1997. * On-Line Applications Research Corporation (OAR). * - * Copyright (c) 2011-2012 embedded brains GmbH. + * Copyright (c) 2011-2013 embedded brains GmbH. * * The license and distribution terms for this file may in * the file LICENSE in this distribution or at @@ -323,6 +323,8 @@ PROC (_CPU_Context_switch): PPC_GPR_STORE r30, PPC_CONTEXT_OFFSET_GPR30(r3) PPC_GPR_STORE r31, PPC_CONTEXT_OFFSET_GPR31(r3) + stw r2, PPC_CONTEXT_OFFSET_GPR2(r3) + /* Restore context from r4 */ restore_context: @@ -363,6 +365,8 @@ restore_context: PPC_GPR_LOAD r30, PPC_CONTEXT_OFFSET_GPR30(r4) PPC_GPR_LOAD r31, PPC_CONTEXT_OFFSET_GPR31(r4) + lwz r2, PPC_CONTEXT_OFFSET_GPR2(r4) + mtcr r7 mtlr r6 mtmsr r5 -- cgit v1.2.3