summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPatrick Williams <iawillia@us.ibm.com>2013-10-29 16:50:08 -0500
committerA. Patrick Williams III <iawillia@us.ibm.com>2013-11-07 14:58:22 -0600
commitc46a0d9db4701cca885329a29adf589da75f0ba7 (patch)
tree06acb104a582182de2c0093d1eb04310df7a735f /src
parent61716e5c9f9ffd3acc5169688739d223c0344a93 (diff)
downloadtalos-hostboot-c46a0d9db4701cca885329a29adf589da75f0ba7.tar.gz
talos-hostboot-c46a0d9db4701cca885329a29adf589da75f0ba7.zip
Runtime LidMgr.
Change-Id: Ib456f3a41d79775a2af027e0bf80e36ce1d49232 RTC: 76679 Reviewed-on: http://gfw160.aus.stglabs.ibm.com:8080/gerrit/6971 Tested-by: Jenkins Server Reviewed-by: Douglas R. Gilbert <dgilbert@us.ibm.com> Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com> Reviewed-by: A. Patrick Williams III <iawillia@us.ibm.com>
Diffstat (limited to 'src')
-rw-r--r--src/include/runtime/interface.h24
-rw-r--r--src/include/usr/util/util_reasoncodes.H3
-rw-r--r--src/include/usr/util/utillidmgr.H87
-rw-r--r--src/include/usr/vfs/vfs_reasoncodes.H1
-rw-r--r--src/makefile8
-rw-r--r--src/runtime/makefile2
-rw-r--r--src/runtime/rt_task.C25
-rw-r--r--src/runtime/rt_vfs.C22
-rw-r--r--src/usr/errl/runtime/makefile2
-rw-r--r--src/usr/errl/runtime/rt_vfs.C84
-rw-r--r--src/usr/testcore/rtloader/loader.H69
-rw-r--r--src/usr/util/makefile2
-rw-r--r--src/usr/util/runtime/makefile32
-rw-r--r--src/usr/util/runtime/test/makefile30
-rw-r--r--src/usr/util/runtime/test/testlidmgr.H44
-rw-r--r--src/usr/util/runtime/utillidmgr_rt.C145
16 files changed, 501 insertions, 79 deletions
diff --git a/src/include/runtime/interface.h b/src/include/runtime/interface.h
index 7dd49d202..b5d55acaa 100644
--- a/src/include/runtime/interface.h
+++ b/src/include/runtime/interface.h
@@ -59,13 +59,13 @@ typedef struct hostInterfaces
/** realloc */
void* (*realloc)(void*, size_t);
- /** sendErrorLog
+ /** sendErrorLog
* @param[in] plid Platform Log identifier
* @param[in] data size in bytes
* @param[in] pointer to data
* @return 0 on success else error code
*/
- int (*sendErrorLog)(uint32_t,uint32_t,void *);
+ int (*sendErrorLog)(uint32_t,uint32_t,void *);
/** Scan communication read
* @param[in] chip_id (based on devtree defn)
@@ -83,6 +83,26 @@ typedef struct hostInterfaces
*/
int (*scom_write)(uint32_t, uint32_t, void* );
+ /** lid_load
+ * Load a LID from PNOR, FSP, etc.
+ *
+ * @param[in] LID number.
+ * @param[out] Allocated buffer for LID.
+ * @param[out] Size of LID (in bytes).
+ *
+ * @return 0 on success, else RC.
+ */
+ int (*lid_load)(uint32_t, void**, size_t*);
+
+ /** lid_unload
+ * Release memory from previously loaded LID.
+ *
+ * @param[in] Allocated buffer for LID to release.
+ *
+ * @return 0 on success, else RC.
+ */
+ int (*lid_unload)(void*);
+
} hostInterfaces_t;
typedef struct runtimeInterfaces
diff --git a/src/include/usr/util/util_reasoncodes.H b/src/include/usr/util/util_reasoncodes.H
index 4295bc4d6..2ca895f18 100644
--- a/src/include/usr/util/util_reasoncodes.H
+++ b/src/include/usr/util/util_reasoncodes.H
@@ -34,7 +34,8 @@ namespace Util
UTIL_MOD_MEM_WRITE = 0x02, // UtilMem::Write
UTIL_LIDMGR_GETLID = 0x03, // UtilLidMgr::getLid
UTIL_LIDMGR_GETLIDSIZE = 0x04, // UtilLidMgr::getLidSize
- UTIL_LIDMGR_GETLIDPNOR = 0x06, // UtilLidMgr::getLidPnor
+ UTIL_LIDMGR_GETLIDPNOR = 0x05, // UtilLidMgr::getLidPnor
+ UTIL_LIDMGR_RT = 0x06,
};
enum ReasonCode
diff --git a/src/include/usr/util/utillidmgr.H b/src/include/usr/util/utillidmgr.H
index d6839a802..53560faa8 100644
--- a/src/include/usr/util/utillidmgr.H
+++ b/src/include/usr/util/utillidmgr.H
@@ -58,7 +58,7 @@ class UtilLidMgr
* Ensures member variables are initialized to sane values.
* Sets the initial LID ID.
*
- * @param[in] i_lidId
+ * @param[in] i_lidId
* LID ID.
*
*/
@@ -81,7 +81,7 @@ class UtilLidMgr
* to work with. It can also be used to reset the
* object to a different LID Id..
*
- * @param[in] i_lidId
+ * @param[in] i_lidId
* LID ID.
*
* @return errlHndl_t
@@ -97,7 +97,7 @@ class UtilLidMgr
* Returns useful LID metrics to the user. Currently
* this is only the size of the LID in bytes.
*
- * @param[out] o_lidSize
+ * @param[out] o_lidSize
* Size of the LID in bytes.
*
* @return errlHndl_t
@@ -115,11 +115,11 @@ class UtilLidMgr
* allocate the indicated memory space before
* calling this function.
*
- * @param[in] i_dest
+ * @param[in] i_dest
* Pointer to where LID should be stored in
* hostboot memory
*
- * @param[in] i_destSeze
+ * @param[in] i_destSeze
* Reserved space in bytes at destintion address
* for LID.
*
@@ -132,6 +132,29 @@ class UtilLidMgr
protected:
/**
+ * @brief Updates the lidId in the object
+ *
+ * @par Detailed Description:
+ * Updates the lidId in the object
+ * Also composes the LID filename
+ * This function assumes the lid name is of the format
+ * <uppercase hex>.lidbin
+ * The file is not technically a lid, thus the slightly
+ * different name
+ *
+ * @param[in] i_lidId
+ * LID ID.
+ */
+ void updateLid(uint32_t i_lidId);
+
+ /**
+ * @brief performs object cleanup when a new lidId is set
+ * Function is also called by the destructor.
+ */
+ errlHndl_t cleanup();
+
+#ifndef __HOSTBOOT_RUNTIME
+ /**
* @brief Get LID Size PNOR
*
* @par Detailed Description:
@@ -142,10 +165,10 @@ class UtilLidMgr
* The file is not technically a lid, thus the slightly
* different name
*
- * @param[out] o_lidSize
+ * @param[out] o_lidSize
* Size of the LID in bytes.
*
- * @param[out] o_imgInPnor
+ * @param[out] o_imgInPnor
* Indicates image was found in PNOR
*
* @return errlHndl_t
@@ -167,15 +190,15 @@ class UtilLidMgr
* The file is not technically a lid, thus the slightly
* different name
*
- * @param[in] i_dest
+ * @param[in] i_dest
* pointer where LID should be stored in
* hostboot memory
*
- * @param[in] i_destSeze
+ * @param[in] i_destSeze
* Reserved space in bytes at destintion address
* for LID.
*
- * @param[out] o_imgInPnor
+ * @param[out] o_imgInPnor
* Indicates image was found in PNOR
*
* @return errlHndl_t
@@ -187,30 +210,6 @@ class UtilLidMgr
bool& o_imgInPnor);
/**
- * @brief performs object cleanup when a new lidId is set
- * Function is also called by the destructor.
- */
- errlHndl_t cleanup();
-
-
- /**
- * @brief Updates the lidId in the object
- *
- * @par Detailed Description:
- * Updates the lidId in the object
- * Also composes the LID filename
- * This function assumes the lid name is of the format
- * <uppercase hex>.lidbin
- * The file is not technically a lid, thus the slightly
- * different name
- *
- * @param[in] i_lidId
- * LID ID.
- */
- void updateLid(uint32_t i_lidId);
-
-
- /**
* @enum UtilLidMgr::MBOX_MSG_TYPE
*
* @brief Message enum to determine if msg should be sent
@@ -261,7 +260,7 @@ class UtilLidMgr
* ::MBOX_MSG_TYPE passed in to define the
* message sending policy.
*
- * @param[in/out] i_msg
+ * @param[in/out] i_msg
* This parameter is used as both input and an
* output parameter. If the message is sent
* synchronusly the response will be populated
@@ -296,6 +295,24 @@ class UtilLidMgr
* @brief Pointer to message queue
*/
msg_q_t iv_HbMsgQ;
+#else // __HOSTBOOT_RUNTIME
+
+ /**
+ * @brief Loads the LID using the Host interfaces.
+ */
+ errlHndl_t loadLid();
+
+ /**
+ * @brief Cached value of the LID location. (Host vs PNOR)
+ */
+ bool iv_isPnor;
+
+ /**
+ * @brief Pointer to the buffer containing the LID.
+ */
+ void* iv_lidBuffer;
+
+#endif // __HOSTBOOT_RUNTIME
/**
* @brief LID fileName
diff --git a/src/include/usr/vfs/vfs_reasoncodes.H b/src/include/usr/vfs/vfs_reasoncodes.H
index 2607c2f1b..0fa4e5abb 100644
--- a/src/include/usr/vfs/vfs_reasoncodes.H
+++ b/src/include/usr/vfs/vfs_reasoncodes.H
@@ -31,6 +31,7 @@ namespace VFS
{
UNDEFINED_MODULE_ERRL_ID = 0x00,
VFS_MODULE_ID = 0x01,
+ VFS_RT_MODULE_ID = 0x02,
};
enum VfsReasonCode
diff --git a/src/makefile b/src/makefile
index 8e803d4ba..fe32d003b 100644
--- a/src/makefile
+++ b/src/makefile
@@ -70,13 +70,15 @@ TESTCASE_MODULES = cxxtest testtrace testerrl testdevicefw testsyslib \
testfsiscom testrtloader testsbe
RUNTIME_OBJECTS = rt_start.o rt_main.o rt_console.o rt_stdlib.o rt_sync.o \
- rt_assert.o rt_vfs.o
+ rt_assert.o rt_vfs.o rt_task.o
-RUNTIME_MODULES = trace_rt errl_rt targeting_rt devicefw_rt xscom_rt scom_rt
+RUNTIME_MODULES = trace_rt errl_rt targeting_rt util_rt devicefw_rt \
+ xscom_rt scom_rt
RUNTIME_DATA_MODULES =
RUNTIME_TESTCASE_MODULES = cxxtest_rt testsyslib_rt testtargeting_rt \
- testxscom_rt testerrl_rt testdevicefw_rt testscom_rt
+ testxscom_rt testerrl_rt testdevicefw_rt \
+ testscom_rt testutil_rt
RELOCATABLE_IMAGE_LDFLAGS = -pie --export-dynamic
diff --git a/src/runtime/makefile b/src/runtime/makefile
index 06ea1d3bc..440b6adda 100644
--- a/src/runtime/makefile
+++ b/src/runtime/makefile
@@ -24,6 +24,6 @@ HOSTBOOT_RUNTIME = 1
ROOTPATH = ../..
OBJS = rt_start.o rt_main.o rt_console.o rt_stdlib.o rt_sync.o rt_assert.o \
- rt_vfs.o
+ rt_vfs.o rt_task.o
include ${ROOTPATH}/config.mk
diff --git a/src/runtime/rt_task.C b/src/runtime/rt_task.C
new file mode 100644
index 000000000..f25e7bc69
--- /dev/null
+++ b/src/runtime/rt_task.C
@@ -0,0 +1,25 @@
+/* IBM_PROLOG_BEGIN_TAG */
+/* This is an automatically generated prolog. */
+/* */
+/* $Source: src/runtime/rt_task.C $ */
+/* */
+/* IBM CONFIDENTIAL */
+/* */
+/* COPYRIGHT International Business Machines Corp. 2013 */
+/* */
+/* p1 */
+/* */
+/* Object Code Only (OCO) source materials */
+/* Licensed Internal Code Source Materials */
+/* IBM HostBoot Licensed Internal Code */
+/* */
+/* The source code for this program is not published or otherwise */
+/* divested of its trade secrets, irrespective of what has been */
+/* deposited with the U.S. Copyright Office. */
+/* */
+/* Origin: 30 */
+/* */
+/* IBM_PROLOG_END_TAG */
+#include <sys/task.h>
+
+tid_t task_gettid() { return 0; }
diff --git a/src/runtime/rt_vfs.C b/src/runtime/rt_vfs.C
index 7558f222c..894cd47cb 100644
--- a/src/runtime/rt_vfs.C
+++ b/src/runtime/rt_vfs.C
@@ -23,7 +23,6 @@
#include <runtime/interface.h>
#include <kernel/console.H>
#include <util/align.H>
-#include <kernel/console.H>
#include <sys/vfs.h>
#include <vector>
#include <errno.h>
@@ -102,24 +101,3 @@ void* vfs_start_entrypoint(VfsSystemModule * i_module)
}
return ptr;
}
-
-namespace VFS
-{
- void find_test_modules(std::vector<const char*> & o_list)
- {
- o_list.clear();
-
- for(VfsSystemModule* vfsItr = &VFS_MODULES[0];
- '\0' != vfsItr->module[0];
- vfsItr++)
- {
- if (0 == memcmp(vfsItr->module, "libtest", 7))
- {
- if (NULL != vfsItr->start)
- {
- o_list.push_back(vfsItr->module);
- }
- }
- }
- }
-}
diff --git a/src/usr/errl/runtime/makefile b/src/usr/errl/runtime/makefile
index dd47962ea..025cd2dd5 100644
--- a/src/usr/errl/runtime/makefile
+++ b/src/usr/errl/runtime/makefile
@@ -27,7 +27,7 @@ MODULE = errl_rt
OBJS = errlentry.o rt_errlmanager.o errlsctn.o errlsctnhdr.o errlprvt.o errluh.o \
errlud.o errlsrc.o errluserdetails.o backtrace.o errludtarget.o \
errludstring.o errludbacktrace.o errludattribute.o \
- errludcallout.o
+ errludcallout.o rt_vfs.o
SUBDIRS = test.d
diff --git a/src/usr/errl/runtime/rt_vfs.C b/src/usr/errl/runtime/rt_vfs.C
new file mode 100644
index 000000000..e1650f09c
--- /dev/null
+++ b/src/usr/errl/runtime/rt_vfs.C
@@ -0,0 +1,84 @@
+/* IBM_PROLOG_BEGIN_TAG */
+/* This is an automatically generated prolog. */
+/* */
+/* $Source: src/usr/errl/runtime/rt_vfs.C $ */
+/* */
+/* IBM CONFIDENTIAL */
+/* */
+/* COPYRIGHT International Business Machines Corp. 2013 */
+/* */
+/* p1 */
+/* */
+/* Object Code Only (OCO) source materials */
+/* Licensed Internal Code Source Materials */
+/* IBM HostBoot Licensed Internal Code */
+/* */
+/* The source code for this program is not published or otherwise */
+/* divested of its trade secrets, irrespective of what has been */
+/* deposited with the U.S. Copyright Office. */
+/* */
+/* Origin: 30 */
+/* */
+/* IBM_PROLOG_END_TAG */
+#include <string.h>
+#include <sys/vfs.h>
+#include <vfs/vfs_reasoncodes.H>
+#include <errl/errlentry.H>
+#include <errl/errludstring.H>
+
+using namespace ERRORLOG;
+
+namespace VFS
+{
+ void find_test_modules(std::vector<const char*> & o_list)
+ {
+ o_list.clear();
+
+ for(VfsSystemModule* vfsItr = &VFS_MODULES[0];
+ '\0' != vfsItr->module[0];
+ vfsItr++)
+ {
+ if (0 == memcmp(vfsItr->module, "libtest", 7))
+ {
+ if (NULL != vfsItr->start)
+ {
+ o_list.push_back(vfsItr->module);
+ }
+ }
+ }
+ }
+
+ errlHndl_t module_address(const char * i_name,
+ const char *& o_address, size_t & o_size)
+ {
+ errlHndl_t l_errl = NULL;
+ VfsSystemModule* entry = vfs_find_module(&VFS_MODULES[0], i_name);
+
+ if ((NULL == entry) || (entry->text != entry->data))
+ {
+ /*@ errorlog tag
+ * @errortype ERRL_SEV_INFORMATIONAL
+ * @moduleid VFS_RT_MODULE_ID
+ * @reasoncode VFS_INVALID_DATA_MODULE
+ * @userdata1 0
+ * @userdata2 0
+ *
+ * @devdesc Module is not a data module
+ *
+ */
+ l_errl = new ErrlEntry(
+ ERRORLOG::ERRL_SEV_INFORMATIONAL, // severity
+ VFS::VFS_RT_MODULE_ID, // moduleid
+ VFS::VFS_INVALID_DATA_MODULE, // reason Code
+ 0, 0);
+ ErrlUserDetailsString(i_name).addToLog(l_errl);
+ }
+ else
+ {
+ o_address = (const char *)entry->data;
+ o_size = entry->byte_count;
+ }
+
+ return l_errl;
+ }
+}
diff --git a/src/usr/testcore/rtloader/loader.H b/src/usr/testcore/rtloader/loader.H
index 60272aa63..a5734f3bc 100644
--- a/src/usr/testcore/rtloader/loader.H
+++ b/src/usr/testcore/rtloader/loader.H
@@ -30,6 +30,7 @@
#include <targeting/common/attributes.H>
#include <targeting/common/utilFilter.H>
#include <errl/errlmanager.H>
+#include <util/utillidmgr.H>
#include <map>
#include <runtime/interface.h>
@@ -105,6 +106,8 @@ class RuntimeLoaderTest : public CxxTest::TestSuite
intf->sendErrorLog = rt_logErr;
intf->scom_read = rt_scom_read;
intf->scom_write = rt_scom_write;
+ intf->lid_load = rt_lid_load;
+ intf->lid_unload = rt_lid_unload;
// Call init.
runtimeInterfaces_t* rtInterface =
@@ -168,9 +171,6 @@ class RuntimeLoaderTest : public CxxTest::TestSuite
assert(false);
}
-
-
-
static int rt_scom_read(uint32_t chipid,
uint32_t addr,
void* data)
@@ -199,15 +199,12 @@ class RuntimeLoaderTest : public CxxTest::TestSuite
return rc;
}
-
-
-
static int rt_scom_write(uint32_t chipid,
uint32_t addr,
void* data)
{
int rc = 0;
-
+
TRACFCOMP(g_trac_test,
"RUNTIME MSG: Scom write chipid: 0x%08x Address: 0x%08x",
chipid,
@@ -221,8 +218,9 @@ class RuntimeLoaderTest : public CxxTest::TestSuite
return rc;
}
-
-
+ typedef std::pair<uint32_t,uint32_t> SCOM_KEY;
+ typedef std::map<SCOM_KEY,uint64_t> SCOM_MAP;
+ static SCOM_MAP cv_scomMap;
static int rt_logErr(uint32_t plid,
uint32_t data_len,
@@ -236,7 +234,7 @@ class RuntimeLoaderTest : public CxxTest::TestSuite
TRACDBIN(g_trac_test, "RUNTIME ERROR LOG:",data,data_len);
-
+
errlHndl_t err =
new ERRORLOG::ErrlEntry(ERRORLOG::ERRL_SEV_INFORMATIONAL,
0,0);
@@ -247,13 +245,58 @@ class RuntimeLoaderTest : public CxxTest::TestSuite
return rc;
}
+ static std::map<void*, UtilLidMgr*> cv_loadedLids;
+
+ static int rt_lid_load(uint32_t lid, void** buffer, size_t* size)
+ {
+ errlHndl_t l_errl = NULL;
+ UtilLidMgr* lidmgr = new UtilLidMgr(lid);
+
+ do
+ {
+ l_errl = lidmgr->getLidSize(*size);
+ if (l_errl) break;
+
+ *buffer = malloc(*size);
+ l_errl = lidmgr->getLid(*buffer, *size);
+ if (l_errl) break;
+
+ } while(0);
+
+ if (l_errl)
+ {
+ free(*buffer);
+ *buffer = NULL;
+ *size = 0;
+
+ delete l_errl;
+ delete lidmgr;
+ return -1;
+ }
+ else
+ {
+ cv_loadedLids[*buffer] = lidmgr;
+ return 0;
+ }
+
+ }
+
+ static int rt_lid_unload(void* buffer)
+ {
+ UtilLidMgr* lidmgr = cv_loadedLids[buffer];
+ if (NULL == lidmgr) return -1;
+
+ cv_loadedLids.erase(buffer);
+ free(buffer);
+ delete lidmgr;
+ return 0;
+ }
- typedef std::pair<uint32_t,uint32_t> SCOM_KEY;
- typedef std::map<SCOM_KEY,uint64_t> SCOM_MAP;
- static SCOM_MAP cv_scomMap;
};
RuntimeLoaderTest::SCOM_MAP RuntimeLoaderTest::cv_scomMap;
+std::map<void*, UtilLidMgr*> RuntimeLoaderTest::cv_loadedLids;
+
#endif
diff --git a/src/usr/util/makefile b/src/usr/util/makefile
index 33f61e90d..f8018dcd9 100644
--- a/src/usr/util/makefile
+++ b/src/usr/util/makefile
@@ -26,6 +26,6 @@ MODULE = util
OBJS = threadpool.o utilbase.o utilstream.o utilmem.o utilfile.o \
utillidmgr.o
-SUBDIRS = test.d
+SUBDIRS = test.d runtime.d
include ${ROOTPATH}/config.mk
diff --git a/src/usr/util/runtime/makefile b/src/usr/util/runtime/makefile
new file mode 100644
index 000000000..b27eaf55f
--- /dev/null
+++ b/src/usr/util/runtime/makefile
@@ -0,0 +1,32 @@
+# IBM_PROLOG_BEGIN_TAG
+# This is an automatically generated prolog.
+#
+# $Source: src/usr/util/runtime/makefile $
+#
+# IBM CONFIDENTIAL
+#
+# COPYRIGHT International Business Machines Corp. 2013
+#
+# p1
+#
+# Object Code Only (OCO) source materials
+# Licensed Internal Code Source Materials
+# IBM HostBoot Licensed Internal Code
+#
+# The source code for this program is not published or otherwise
+# divested of its trade secrets, irrespective of what has been
+# deposited with the U.S. Copyright Office.
+#
+# Origin: 30
+#
+# IBM_PROLOG_END_TAG
+HOSTBOOT_RUNTIME = 1
+ROOTPATH = ../../../..
+MODULE = util_rt
+
+OBJS = utilbase.o utilstream.o utilmem.o utillidmgr_rt.o
+
+SUBDIRS = test.d
+
+VPATH += ..
+include $(ROOTPATH)/config.mk
diff --git a/src/usr/util/runtime/test/makefile b/src/usr/util/runtime/test/makefile
new file mode 100644
index 000000000..ead555514
--- /dev/null
+++ b/src/usr/util/runtime/test/makefile
@@ -0,0 +1,30 @@
+# IBM_PROLOG_BEGIN_TAG
+# This is an automatically generated prolog.
+#
+# $Source: src/usr/util/runtime/test/makefile $
+#
+# IBM CONFIDENTIAL
+#
+# COPYRIGHT International Business Machines Corp. 2013
+#
+# p1
+#
+# Object Code Only (OCO) source materials
+# Licensed Internal Code Source Materials
+# IBM HostBoot Licensed Internal Code
+#
+# The source code for this program is not published or otherwise
+# divested of its trade secrets, irrespective of what has been
+# deposited with the U.S. Copyright Office.
+#
+# Origin: 30
+#
+# IBM_PROLOG_END_TAG
+HOSTBOOT_RUNTIME = 1
+ROOTPATH = ../../../../..
+
+MODULE = testutil_rt
+
+TESTS = *.H
+
+include $(ROOTPATH)/config.mk
diff --git a/src/usr/util/runtime/test/testlidmgr.H b/src/usr/util/runtime/test/testlidmgr.H
new file mode 100644
index 000000000..f76e9af13
--- /dev/null
+++ b/src/usr/util/runtime/test/testlidmgr.H
@@ -0,0 +1,44 @@
+/* IBM_PROLOG_BEGIN_TAG */
+/* This is an automatically generated prolog. */
+/* */
+/* $Source: src/usr/util/runtime/test/testlidmgr.H $ */
+/* */
+/* IBM CONFIDENTIAL */
+/* */
+/* COPYRIGHT International Business Machines Corp. 2013 */
+/* */
+/* p1 */
+/* */
+/* Object Code Only (OCO) source materials */
+/* Licensed Internal Code Source Materials */
+/* IBM HostBoot Licensed Internal Code */
+/* */
+/* The source code for this program is not published or otherwise */
+/* divested of its trade secrets, irrespective of what has been */
+/* deposited with the U.S. Copyright Office. */
+/* */
+/* Origin: 30 */
+/* */
+/* IBM_PROLOG_END_TAG */
+#include <util/utillidmgr.H>
+
+class LidMgrTest : public CxxTest::TestSuite
+{
+ public:
+ void testMissingLid()
+ {
+ UtilLidMgr lidmgr(-1);
+
+ size_t l_size = 0;
+ errlHndl_t l_errl = lidmgr.getLidSize(l_size);
+
+ if (NULL == l_errl)
+ {
+ TS_FAIL("Found missing lid -1.");
+ }
+ else
+ {
+ delete l_errl;
+ }
+ }
+};
diff --git a/src/usr/util/runtime/utillidmgr_rt.C b/src/usr/util/runtime/utillidmgr_rt.C
new file mode 100644
index 000000000..397cc6074
--- /dev/null
+++ b/src/usr/util/runtime/utillidmgr_rt.C
@@ -0,0 +1,145 @@
+/* IBM_PROLOG_BEGIN_TAG */
+/* This is an automatically generated prolog. */
+/* */
+/* $Source: src/usr/util/runtime/utillidmgr_rt.C $ */
+/* */
+/* IBM CONFIDENTIAL */
+/* */
+/* COPYRIGHT International Business Machines Corp. 2013 */
+/* */
+/* p1 */
+/* */
+/* Object Code Only (OCO) source materials */
+/* Licensed Internal Code Source Materials */
+/* IBM HostBoot Licensed Internal Code */
+/* */
+/* The source code for this program is not published or otherwise */
+/* divested of its trade secrets, irrespective of what has been */
+/* deposited with the U.S. Copyright Office. */
+/* */
+/* Origin: 30 */
+/* */
+/* IBM_PROLOG_END_TAG */
+#include <stdio.h>
+#include <algorithm>
+
+#include <util/utillidmgr.H>
+#include <util/util_reasoncodes.H>
+#include <errl/errlmanager.H>
+#include <vfs/vfs.H>
+#include <runtime/interface.h>
+
+UtilLidMgr::UtilLidMgr(uint32_t i_lidId) :
+ iv_isPnor(false), iv_lidBuffer(NULL), iv_lidSize(0)
+{
+ updateLid(i_lidId);
+}
+
+UtilLidMgr::~UtilLidMgr()
+{
+ errlHndl_t l_err = NULL;
+
+ l_err = cleanup();
+ if(l_err)
+ {
+ //cleanup errors are extermely rare
+ ERRORLOG::errlCommit( l_err, UTIL_COMP_ID );
+ }
+}
+
+errlHndl_t UtilLidMgr::setLidId(uint32_t i_lidId)
+{
+ errlHndl_t l_err = NULL;
+
+ //must call cleanup before updateLid
+ l_err = cleanup();
+
+ updateLid(i_lidId);
+
+ return l_err;
+}
+
+errlHndl_t UtilLidMgr::getLidSize(size_t& o_lidSize)
+{
+ errlHndl_t l_err = loadLid();
+ o_lidSize = iv_lidSize;
+
+ return l_err;
+}
+
+errlHndl_t UtilLidMgr::getLid(void* i_dest, size_t i_destSize)
+{
+ errlHndl_t l_err = loadLid();
+
+ if (iv_lidBuffer != NULL)
+ {
+ memcpy(i_dest, iv_lidBuffer, std::min(i_destSize, iv_lidSize));
+ }
+
+ return l_err;
+}
+
+errlHndl_t UtilLidMgr::loadLid()
+{
+ // Check if it is already loaded.
+ if (NULL != iv_lidBuffer) return NULL;
+
+ const char* l_addr = NULL;
+ size_t l_size = 0;
+ errlHndl_t l_errl = VFS::module_address(iv_lidFileName, l_addr, l_size);
+
+ if (l_errl)
+ {
+ delete l_errl;
+ int rc =
+ g_hostInterfaces->lid_load(iv_lidId, &iv_lidBuffer, &iv_lidSize);
+
+ if (0 != rc)
+ {
+ /*@
+ * @errortype ERRL_SEV_INFORMATIONAL
+ * @moduleid Util::UTIL_LIDMGR_RT
+ * @reasoncode Util::UTIL_LIDMGR_RC_FAIL
+ * @userdata1 Return code from lid_load call.
+ * @devdesc Unable to load LID via host interface.
+ */
+ l_errl = new ERRORLOG::ErrlEntry(
+ ERRORLOG::ERRL_SEV_INFORMATIONAL,
+ Util::UTIL_LIDMGR_RT,
+ Util::UTIL_LIDMGR_RC_FAIL,
+ rc);
+ }
+ }
+ else
+ {
+ iv_isPnor = true;
+ iv_lidBuffer = const_cast<void*>(reinterpret_cast<const void*>(l_addr));
+ iv_lidSize = l_size;
+ }
+
+ return l_errl;
+}
+
+errlHndl_t UtilLidMgr::cleanup()
+{
+ if ((!iv_isPnor) && (NULL != iv_lidBuffer))
+ {
+ g_hostInterfaces->lid_unload(iv_lidBuffer);
+ }
+ iv_lidBuffer = NULL;
+
+ iv_lidSize = 0;
+ iv_isPnor = false;
+ return NULL;
+}
+
+void UtilLidMgr::updateLid(uint32_t i_lidId)
+{
+ iv_lidId = i_lidId;
+
+ //if it's in PNOR, it's not technically lid, so use a slightly
+ //different extension.
+ sprintf(iv_lidFileName, "%x.lidbin", iv_lidId);
+
+ return;
+}
OpenPOWER on IntegriCloud