Skip to content

Commit

Permalink
PPE Registers to be saved-off in the interrupt context
Browse files Browse the repository at this point in the history
Change-Id: I90b9b21957bb58ab7e1ed1802d8723dcf4b05b6f
Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/48094
Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com>
Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com>
Reviewed-by: Sachin Gupta <sgupta2m@in.ibm.com>
Reviewed-by: Soma Bhanutej <soma.bhanu@in.ibm.com>
Reviewed-by: Jennifer A. Stofer <stofer@us.ibm.com>
  • Loading branch information
Raja Das authored and Jennifer A. Stofer committed Jan 18, 2018
1 parent 26dd579 commit c68fb43
Show file tree
Hide file tree
Showing 5 changed files with 177 additions and 5 deletions.
9 changes: 8 additions & 1 deletion src/sbefw/core/pk_app_cfg.h
Expand Up @@ -5,7 +5,8 @@
/* */
/* OpenPOWER sbe Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2015,2017 */
/* Contributors Listed Below - COPYRIGHT 2015,2018 */
/* [+] International Business Machines Corp. */
/* */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); */
Expand Down Expand Up @@ -135,6 +136,12 @@
#endif
#define PPE42_MACHINE_CHECK_HANDLER SBE_MACHINE_CHECK_HANDLER

// Added default register-save handler to the interrupt
#ifdef PPE_CAPTURE_INTERRUPT_FFDC
#undef PPE_CAPTURE_INTERRUPT_FFDC
#endif
#define PPE_CAPTURE_INTERRUPT_FFDC SBE_INTERRUPT_REGISTER_SAVEOFF

// Set the trace buffer size
#ifdef PK_TRACE_SZ
#undef PK_TRACE_SZ
Expand Down
3 changes: 2 additions & 1 deletion src/sbefw/core/sbecmdgeneric.C
Expand Up @@ -5,7 +5,8 @@
/* */
/* OpenPOWER sbe Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2015,2017 */
/* Contributors Listed Below - COPYRIGHT 2015,2018 */
/* [+] International Business Machines Corp. */
/* */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); */
Expand Down
96 changes: 94 additions & 2 deletions src/sbefw/core/sbeirq.C
Expand Up @@ -5,7 +5,8 @@
/* */
/* OpenPOWER sbe Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2015,2017 */
/* Contributors Listed Below - COPYRIGHT 2015,2018 */
/* [+] International Business Machines Corp. */
/* */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); */
Expand Down Expand Up @@ -35,6 +36,7 @@
#include "sbeglobals.H"
#include "ppe42_scom.h"
#include "p9_misc_scom_addresses.H"
#include "sbeirqregistersave.H"

////////////////////////////////////////////////////////////////
// @brief: SBE control loop ISR:
Expand Down Expand Up @@ -225,6 +227,94 @@ extern "C" void i2c_reset()
}
}

///////////////////////////////////////////////////////////////////
// SBE handler to save off specific registers
///////////////////////////////////////////////////////////////////
registersave_t __g_register_ffdc;
uint64_t __g_address_for_register_ffdc = (uint32_t)&__g_register_ffdc;

extern "C" void __sbe_register_saveoff()
{
asm(
"# Save r4, r5, r6 to stack, since it is going to be used\n"
"# inside here, move the stack by 12\n"
"stwu %r1, -12(%r1)\n"
"# Store r4 into stack\n"
"stw %r4, 0(%r1)\n"
"# Store r5 into stack\n"
"stw %r5, 4(%r1)\n"
"# Store r6 into stack\n"
"stw %r6, 8(%r1)\n"
"# Write zero to r4,r5,r6 to clear off the content\n"
"lis %r4, 0\n"
"lis %r5, 0\n"
"lis %r6, 0\n"

"# Check for loop condition if this branch is happening repetitively\n"
"# load first 4bytes of __g_register_ffdc, it should be initialized\n"
"# with zero, if not zero than this is repetitive entry, exit now\n"
"lvd %d5, __g_register_ffdc@sda21(0)\n"
"# if r5 and r4 not equal, then it's loop inside loop, exit condition\n"
"cmplwbne %r4, %r5, __goto_exit\n"

"# Start gathering registers into FFDC\n"
"# Read SRR0 into r4\n"
"mfsrr0 %r4\n"
"stw %r4, __g_register_ffdc+4@sda21(0)\n"

"# Read SRR1 into r4\n"
"mfsrr1 %r4\n"
"stw %r4, __g_register_ffdc+8@sda21(0)\n"

"# Read ISR into r4\n"
"mfisr %r4\n"
"stw %r4, __g_register_ffdc+12@sda21(0)\n"

"# Load address to r4\n"
"lis %r4, 0xC000\n"
"ori %r4, %r4, 0x0800\n"
"# getscom 0xC0000800\n"
"lvd %d5, 0(%r4)\n"
"stw %r5, __g_register_ffdc+16@sda21(0)\n"
"stw %r6, __g_register_ffdc+20@sda21(0)\n"

"# Load address to r4\n"
"lis %r4, 0xC000\n"
"ori %r4, %r4, 0x0820\n"
"# getscom 0xC0000820\n"
"lvd %d5, 0(%r4)\n"
"stw %r5, __g_register_ffdc+24@sda21(0)\n"
"stw %r6, __g_register_ffdc+28@sda21(0)\n"

"# Read LR into r4\n"
"mflr %r4\n"
"stw %r4, __g_register_ffdc+32@sda21(0)\n"

"# Write versioning into the lower 32bit of d5 i.e. r6\n"
"#lvd %d5, __g_sbe_register_save_version@sda21(0)\n"
"# Directly load Versioninfo into upper 16bits in r4 \n"
"# RTC:183752, Remove this hard-coding of versioning\n"
"lis %r4, 0x11\n"
"#rlwinm %r4, %r6, 16, 0, 0x1F\n"
"# Write magicbyte and validbyte in the lower 16bits\n"
"ori %r4, %r4, 0xA501\n"
"stw %r4, __g_register_ffdc@sda21(0)\n"

"# Get the address of the register ffdc struct and store it in sprg0\n"
"lvd %d5, __g_address_for_register_ffdc@sda21(0)\n"
"# Store the content of r6 read above into sprg0\n"
"mtsprg0 %r6\n"

"__goto_exit:\n"
"# Get back the original value of the registers stored in stack\n"
"lwz %r6, 8(%r1)\n"
"lwz %r5, 4(%r1)\n"
"lwz %r4, 0(%r1)\n"
"addi %r1, %r1, 12\n"
"b pk_halt\n"
);
}

////////////////////////////////////////////////////////////////
// SBE handler for the PPE machine check interrupt
////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -274,7 +364,8 @@ extern "C" void __sbe_machine_check_handler()
"blt __scom_error\n"
"# Else, halt the SBE\n"
"__halt_sbe:\n"
"b pk_halt\n"
"# Save-off Register FFDC and Halt\n"
"b __sbe_register_saveoff\n"
"__scom_error:\n"
"# The srr0 contains the address of the instruction that caused the machine\n"
"# check (since the the interrupt is raised *before* the instruction\n"
Expand Down Expand Up @@ -314,3 +405,4 @@ extern "C" void __sbe_machine_check_handler()
);
}


6 changes: 5 additions & 1 deletion src/sbefw/core/sbeirq.H
Expand Up @@ -5,7 +5,8 @@
/* */
/* OpenPOWER sbe Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2015,2017 */
/* Contributors Listed Below - COPYRIGHT 2015,2018 */
/* [+] International Business Machines Corp. */
/* */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); */
Expand Down Expand Up @@ -106,4 +107,7 @@
#define SBE_MACHINE_CHECK_HANDLER \
b __sbe_machine_check_handler

#define SBE_INTERRUPT_REGISTER_SAVEOFF \
bl __sbe_register_saveoff

#endif //_SBE_IRQ_H
68 changes: 68 additions & 0 deletions src/sbefw/core/sbeirqregistersave.H
@@ -0,0 +1,68 @@
/* IBM_PROLOG_BEGIN_TAG */
/* This is an automatically generated prolog. */
/* */
/* $Source: src/sbefw/core/sbeirqregistersave.H $ */
/* */
/* OpenPOWER sbe Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2017,2018 */
/* [+] International Business Machines Corp. */
/* */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); */
/* you may not use this file except in compliance with the License. */
/* You may obtain a copy of the License at */
/* */
/* http://www.apache.org/licenses/LICENSE-2.0 */
/* */
/* Unless required by applicable law or agreed to in writing, software */
/* distributed under the License is distributed on an "AS IS" BASIS, */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */
/* implied. See the License for the specific language governing */
/* permissions and limitations under the License. */
/* */
/* IBM_PROLOG_END_TAG */
/*
* $file: ppe/sbe/sbefw/sbeirqregistersave.H
*
* @brief This file contains structs of registers to be saved during interrupt
* contxt.
*/

#ifndef _SBE_IRQ_REGISTER_SAVE_H
#define _SBE_IRQ_REGISTER_SAVE_H

/**
* @brief Register Save Structure
* Total of 4 * 9 = 36Bytes of Data
*/
typedef struct registersave
{
uint32_t version:16; // Structure Versioning, won't change unless,
// there is change in this structure
uint32_t magicbyte:8; // Magic byte for address validation (0xA5) in SPRG0

// Valid Byte, if the Register below could be saved off
uint32_t validbyte:8; // One byte for all the registers below

// Registers to be saved off
uint32_t register_SRR0;
uint32_t register_SRR1;
uint32_t register_ISR;
uint32_t register_FI2C_CONFIG_LOWER_32BITS;
uint32_t register_FI2C_CONFIG_UPPER_32BITS;
uint32_t register_FI2C_STAT_LOWER_32BITS;
uint32_t register_FI2C_STAT_UPPER_32BITS;
uint32_t register_LR;

// Default Constructor to initialize
registersave()
{
version = 0;
magicbyte = 0;
validbyte = 0;
}
}registersave_t;

extern registersave_t __g_register_save_addr;
#endif //_SBE_IRQ_REGISTER_SAVE_H

0 comments on commit c68fb43

Please sign in to comment.