summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/include/kernel/hbterminatetypes.H1
-rw-r--r--src/include/kernel/terminate.H12
-rw-r--r--src/kernel/kernel.C3
-rw-r--r--src/kernel/makefile2
-rw-r--r--src/kernel/terminate.C60
-rw-r--r--src/usr/initservice/baseinitsvc/initservice.C15
-rw-r--r--src/usr/initservice/baseinitsvc/makefile6
7 files changed, 77 insertions, 22 deletions
diff --git a/src/include/kernel/hbterminatetypes.H b/src/include/kernel/hbterminatetypes.H
index e95a77010..593919ca3 100644
--- a/src/include/kernel/hbterminatetypes.H
+++ b/src/include/kernel/hbterminatetypes.H
@@ -107,6 +107,7 @@ enum hb_terminate_type
// Enum used in the flag indicating who initiated the TI
enum hb_terminate_source
{
+ NO_TI_ERROR = 0x0000,
TI_KERNEL_ASSERT = 0x0001,
TI_CRIT_ASSERT = 0x0002,
TI_SHUTDOWN = 0x0003,
diff --git a/src/include/kernel/terminate.H b/src/include/kernel/terminate.H
index 551f66057..b80331495 100644
--- a/src/include/kernel/terminate.H
+++ b/src/include/kernel/terminate.H
@@ -30,12 +30,17 @@
#include <kernel/types.h>
-
/** @fn terminateExecuteTI
* @brief Sequence to execute a TI attn
*/
void terminateExecuteTI();
+/** @fn initKernelMutex
+ * @brief initialize the internal kernel mutex used to lock
+ * the HB TI area.
+ */
+void initKernelTIMutex();
+
/** @fn termWritePlid
* Update TI data area with a PLID.
* @param[in] i_source: indicates what type of fail forced the TI
@@ -50,12 +55,15 @@ void termWritePlid(uint16_t i_source, uint32_t plid);
* @param[in] i_reasoncode: reasoncode for the failure(assert or shutdown)
* @param[in] i_failAddr: i_linkRegister() value (address of failure)
* @param[in] i_error_info: addt'l error info to add to TI data
+ * @param[in] i_forceWrite: force the HB TI area to be overwritten with
+ * the passed parameters.
* @param[out] NONE:
*/
void termWriteSRC(uint16_t i_source,
uint16_t i_reasoncode,
uint64_t i_failAddr = 0,
- uint32_t i_error_info = 0);
+ uint32_t i_error_info = 0,
+ bool i_forceWrite = false);
/** @fn termModifySRC
* Modify an SRC and the TI data area for Bootloader
diff --git a/src/kernel/kernel.C b/src/kernel/kernel.C
index da9470546..866170679 100644
--- a/src/kernel/kernel.C
+++ b/src/kernel/kernel.C
@@ -44,6 +44,7 @@
#include <usr/debugpointers.H>
#include <kernel/segmentmgr.H>
#include <kernel/block.H>
+#include <kernel/terminate.H>
#include <stdlib.h>
@@ -111,6 +112,8 @@ int main()
static_cast<uint64_t>(getPIR()));
MAGIC_INST_PRINT_ISTEP(6,2);
+ initKernelTIMutex();
+
// Erase task-pointer so that TaskManager::getCurrentTask() returns NULL.
setSPRG3(NULL);
diff --git a/src/kernel/makefile b/src/kernel/makefile
index 004dfbe74..211a8b10e 100644
--- a/src/kernel/makefile
+++ b/src/kernel/makefile
@@ -69,5 +69,7 @@ OBJS += workitem.o
OBJS += bltohbdatamgr.o
+EXTRAINCDIR += ${ROOTPATH}/src/include
+
include ${ROOTPATH}/config.mk
diff --git a/src/kernel/terminate.C b/src/kernel/terminate.C
index 6158b3c49..cb70e9be6 100644
--- a/src/kernel/terminate.C
+++ b/src/kernel/terminate.C
@@ -26,6 +26,7 @@
#include <kernel/hbdescriptor.H>
#include <kernel/hbterminatetypes.H>
#include <kernel/terminate.H>
+#include <sys/sync.h>
#ifndef BOOTLOADER
#include <stdint.h>
#include <kernel/console.H>
@@ -37,10 +38,11 @@
extern "C" void p9_force_attn() NO_RETURN;
-
#ifndef BOOTLOADER
+mutex_t g_kernelMutex;
+
/* Instance of the TI Data Area */
-HB_TI_DataArea kernel_TIDataArea;
+HB_TI_DataArea kernel_TIDataArea = {};
/* Instance of the HB descriptor struct */
HB_Descriptor kernel_hbDescriptor =
@@ -58,6 +60,13 @@ void terminateExecuteTI()
p9_force_attn();
}
+void initKernelTIMutex()
+{
+#ifndef BOOTLOADER
+ mutex_init(&g_kernelMutex);
+#endif
+}
+
#ifndef BOOTLOADER
void termWritePlid(uint16_t i_source, uint32_t plid)
{
@@ -68,24 +77,37 @@ void termWritePlid(uint16_t i_source, uint32_t plid)
#endif // BOOTLOADER
void termWriteSRC(uint16_t i_source, uint16_t i_reasoncode,uint64_t i_failAddr,
- uint32_t i_error_data)
+ uint32_t i_error_data, bool i_forceWrite)
{
- // Update the TI structure with the type of TI, who called,
- // and extra error data (if applicable, otherwise 0)
- kernel_TIDataArea.type = TI_WITH_SRC;
- kernel_TIDataArea.source = i_source;
- kernel_TIDataArea.error_data = i_error_data;
-
- // Update TID data area with the SRC info we have avail
- kernel_TIDataArea.src.ID = 0xBC;
- kernel_TIDataArea.src.subsystem = 0x8A;
- kernel_TIDataArea.src.reasoncode = i_reasoncode;
- kernel_TIDataArea.src.moduleID = 0;
- kernel_TIDataArea.src.iType = TI_WITH_SRC;
- kernel_TIDataArea.src.iSource = i_source;
-
- // Update User Data with address of fail location
- kernel_TIDataArea.src.word6 = i_failAddr;
+#ifndef BOOTLOADER
+ mutex_lock(&g_kernelMutex);
+#endif
+ // If this is the first TI on the system or if i_forceWrite is true, then
+ // overwrite the HB TI area with the given info. Unless i_forceWrite is
+ // true, all subsequent TI codes will NOT overwrite the original TI
+ // information.
+ if(kernel_TIDataArea.src.reasoncode == NO_TI_ERROR || i_forceWrite)
+ {
+ // Update the TI structure with the type of TI, who called,
+ // and extra error data (if applicable, otherwise 0)
+ kernel_TIDataArea.type = TI_WITH_SRC;
+ kernel_TIDataArea.source = i_source;
+ kernel_TIDataArea.error_data = i_error_data;
+
+ // Update TID data area with the SRC info we have avail
+ kernel_TIDataArea.src.ID = 0xBC;
+ kernel_TIDataArea.src.subsystem = 0x8A;
+ kernel_TIDataArea.src.reasoncode = i_reasoncode;
+ kernel_TIDataArea.src.moduleID = 0;
+ kernel_TIDataArea.src.iType = TI_WITH_SRC;
+ kernel_TIDataArea.src.iSource = i_source;
+
+ // Update User Data with address of fail location
+ kernel_TIDataArea.src.word6 = i_failAddr;
+ }
+#ifndef BOOTLOADER
+ mutex_unlock(&g_kernelMutex);
+#endif
}
void termModifySRC(uint8_t i_moduleID, uint32_t i_word7, uint32_t i_word8)
diff --git a/src/usr/initservice/baseinitsvc/initservice.C b/src/usr/initservice/baseinitsvc/initservice.C
index 2f88aa723..f62e49264 100644
--- a/src/usr/initservice/baseinitsvc/initservice.C
+++ b/src/usr/initservice/baseinitsvc/initservice.C
@@ -33,6 +33,9 @@
#define __HIDDEN_SYSCALL_SHUTDOWN
#include <kernel/console.H> // printk status
+#include <kernel/terminate.H> // termWriteSRC
+#include <kernel/hbterminatetypes.H> // TI_SHUTDOWN
+#include <builtins.h> // linkRegister
#include <sys/vfs.h>
#include <vfs/vfs.H>
@@ -667,6 +670,11 @@ void doShutdown(uint64_t i_status,
uint64_t i_masterHBInstance,
uint32_t i_error_info)
{
+ termWriteSRC(TI_SHUTDOWN,
+ i_status,
+ reinterpret_cast<uint64_t>(linkRegister()),
+ i_error_info);
+
class ShutdownExecute
{
public:
@@ -886,6 +894,13 @@ void InitService::doShutdown(uint64_t i_status,
TRACFCOMP(g_trac_initsvc, "doShutdown> Final status=%.16X",worst_status);
MAGIC_INST_PRINT_ISTEP(21,4);
+ // Update the HB TI area with the worst status.
+ termWriteSRC(TI_SHUTDOWN,
+ worst_status,
+ reinterpret_cast<uint64_t>(linkRegister()),
+ i_error_info,
+ true); // Force write
+
shutdown(worst_status,
i_payload_base,
i_payload_entry,
diff --git a/src/usr/initservice/baseinitsvc/makefile b/src/usr/initservice/baseinitsvc/makefile
index a7c608747..3b05ca4c0 100644
--- a/src/usr/initservice/baseinitsvc/makefile
+++ b/src/usr/initservice/baseinitsvc/makefile
@@ -5,7 +5,9 @@
#
# OpenPOWER HostBoot Project
#
-# COPYRIGHT International Business Machines Corp. 2011,2014
+# Contributors Listed Below - COPYRIGHT 2011,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.
@@ -25,4 +27,6 @@ MODULE = initservice
OBJS += initservice.o
+EXTRAINCDIR += ${ROOTPATH}/src/include
+
include ${ROOTPATH}/config.mk
OpenPOWER on IntegriCloud