diff options
author | Prachi Gupta <pragupta@us.ibm.com> | 2014-10-28 15:41:49 -0500 |
---|---|---|
committer | A. Patrick Williams III <iawillia@us.ibm.com> | 2015-01-16 12:34:43 -0600 |
commit | c068f50829ec46e4e5b056064dcbe9d786d549a4 (patch) | |
tree | 36c5fd8f2f6b5d420644ed83b877f6d0d8657f42 /src/usr/pnor/runtime/test | |
parent | 5412ba2270945edcfb23f60c34de01dccd44c098 (diff) | |
download | talos-hostboot-c068f50829ec46e4e5b056064dcbe9d786d549a4.tar.gz talos-hostboot-c068f50829ec46e4e5b056064dcbe9d786d549a4.zip |
hbrt interface for PNOR access
RTC:108836
Change-Id: I49e568e7f4fcad13fcd75dfdfa4aee8a263c5001
Reviewed-on: http://gfw160.aus.stglabs.ibm.com:8080/gerrit/14307
Reviewed-by: STEPHEN M. CPREK <smcprek@us.ibm.com>
Tested-by: Jenkins Server
Reviewed-by: A. Patrick Williams III <iawillia@us.ibm.com>
Diffstat (limited to 'src/usr/pnor/runtime/test')
-rw-r--r-- | src/usr/pnor/runtime/test/makefile | 31 | ||||
-rw-r--r-- | src/usr/pnor/runtime/test/testpnor_rt.H | 257 |
2 files changed, 288 insertions, 0 deletions
diff --git a/src/usr/pnor/runtime/test/makefile b/src/usr/pnor/runtime/test/makefile new file mode 100644 index 000000000..e53d87f15 --- /dev/null +++ b/src/usr/pnor/runtime/test/makefile @@ -0,0 +1,31 @@ +# IBM_PROLOG_BEGIN_TAG +# This is an automatically generated prolog. +# +# $Source: src/usr/pnor/runtime/test/makefile $ +# +# OpenPOWER HostBoot Project +# +# Contributors Listed Below - COPYRIGHT 2014,2015 +# [+] 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 +HOSTBOOT_RUNTIME = 1 +ROOTPATH = ../../../../.. + +MODULE = testpnor_rt +TESTS = *.H + +include ${ROOTPATH}/config.mk diff --git a/src/usr/pnor/runtime/test/testpnor_rt.H b/src/usr/pnor/runtime/test/testpnor_rt.H new file mode 100644 index 000000000..5a81ea9ac --- /dev/null +++ b/src/usr/pnor/runtime/test/testpnor_rt.H @@ -0,0 +1,257 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/usr/pnor/runtime/test/testpnor_rt.H $ */ +/* */ +/* OpenPOWER HostBoot Project */ +/* */ +/* Contributors Listed Below - COPYRIGHT 2014,2015 */ +/* [+] 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 */ +#include <cxxtest/TestSuite.H> +#include <errl/errlmanager.H> +#include <errl/errlentry.H> +#include <devicefw/userif.H> + +#include <pnor/pnorif.H> +#include "../../pnor_common.H" +#include "../rt_pnor.H" + +#include <runtime/interface.h> +#include <trace/interface.H> + +#include "../../ffs.h" //Common header file with BuildingBlock. +#include "../../common/ffs_hb.H" //Hostboot def of user data in ffs_entry struct + +extern trace_desc_t* g_trac_pnor; +using namespace TARGETING; + +/* + * these taest cases are turned off as they have dependency on pnorddtest cases + */ +class PnorRtTest : public CxxTest::TestSuite +{ + public: + /** + * @brief: testTOC + * tests that the TOC is read/parsed properly during runtime + */ + void testTOC (void) + { +#if 1 + TRACFCOMP(g_trac_pnor, "PnorRtTest::testTOC - skipping - as it" + " adversly affects pnorddtests"); +#else + TRACFCOMP(g_trac_pnor, "PnorRtTest::testTOC Start" ); + errlHndl_t l_err = NULL; + uint32_t l_proc = 0; + uint64_t offset = 0; + uint8_t* tocHeader = new uint8_t[PAGESIZE]; + uint8_t* tocEntry = new uint8_t[PAGESIZE]; + uint8_t* corruptBuffer = new uint8_t[PAGESIZE]; + + // Corrupt both ffs header and first entry for each TOC + for (uint32_t cur_TOC = 0; cur_TOC < PNOR::NUM_TOCS; ++cur_TOC) + { + uint32_t TOC_used = cur_TOC; + offset = (cur_TOC == 0) ? PNOR::TOC_0_OFFSET : PNOR::TOC_1_OFFSET; + + // Read cur_TOC header data + l_err = RtPnor::getInstance().readFromDevice(l_proc,PNOR::TOC, + offset,PAGESIZE,false,tocHeader); + if (l_err) + { + TS_FAIL("PnorRtTest::testTOC: readFromDevice failed"); + break; + } + + // Corrupt cur_TOC header data + memcpy(corruptBuffer, tocHeader, PAGESIZE); + corruptBuffer[0] = 0xFF; + corruptBuffer[1] = 0xFF; + + l_err = RtPnor::getInstance().writeToDevice(l_proc,PNOR::TOC, + offset,PAGESIZE,false,corruptBuffer); + if (l_err) + { + TS_FAIL("PnorRtTest::testTOC: writeToDevice failed"); + } + + // Check if cur_TOC failed that other TOC is used + l_err = RtPnor::getInstance().readTOC(); + if (l_err) + { + TS_FAIL("PnorRtTest::testTOC: readTOC failed"); + } + + TOC_used = RtPnor::getInstance().iv_TOC_used; + TRACFCOMP(g_trac_pnor, "PnorRtTest::testTOC : TOC %d Corrupt" + " Header, Toc_used = %d", cur_TOC, TOC_used); + + if (TOC_used == cur_TOC) + { + TS_FAIL("PnorRtTest::testTOC>ERROR:TOC %d header is corrupted," + " did not use other TOC"); + break; + } + // Fix cur_TOC header + l_err = RtPnor::getInstance().writeToDevice(l_proc,PNOR::TOC, + offset,PAGESIZE,false,tocHeader); + if (l_err) + { + TS_FAIL("PnorRtTest::testTOC: writeToDevice failed"); + } + + // Read cur_TOC first entry data + l_err = RtPnor::getInstance().readFromDevice(l_proc,PNOR::TOC, + offset+FFS_HDR_SIZE,PAGESIZE,false,tocEntry); + if (l_err) + { + TS_FAIL("PnorRtTest::testTOC: readTOC failed"); + break; + } + + // Corrupt cur_TOC header data + memcpy(corruptBuffer, tocEntry, PAGESIZE); + corruptBuffer[0] = 0xFF; + corruptBuffer[1] = 0xFF; + + l_err = RtPnor::getInstance().writeToDevice(l_proc,PNOR::TOC, + offset+FFS_HDR_SIZE,PAGESIZE,false,corruptBuffer); + if (l_err) + { + TS_FAIL("PnorRtTest::testTOC: writeToDevice failed"); + } + + // Check if cur_TOC failed that other TOC is used + TOC_used = cur_TOC; + l_err = RtPnor::getInstance().readTOC(); + if (l_err) + { + TS_FAIL("PnorRtTest::testTOC: readTOC failed"); + } + TOC_used = RtPnor::getInstance().iv_TOC_used; + TRACFCOMP(g_trac_pnor,"PnorRtTest::testTOC:TOC %d Corrupt" + " Entry, Toc_used = %d", cur_TOC, TOC_used); + + if (TOC_used == cur_TOC) + { + TS_FAIL("PnorRtTest::testTOC>ERROR: TOC %d entry is corrupted," + " did not use other TOC", cur_TOC); + } + + // Fix cur_TOC first entry + l_err = RtPnor::getInstance().writeToDevice(l_proc,PNOR::TOC, + offset+FFS_HDR_SIZE,PAGESIZE,false,tocEntry); + if (l_err) + { + TS_FAIL("PnorRtTest::testTOC: writeToDevice failed"); + } + } + + delete tocHeader; + delete tocEntry; + delete corruptBuffer; + + TRACFCOMP(g_trac_pnor, "PnorRtTest::testTOC End"); +#endif + } + + /** + * @brief RtPnor::testPnorReadWrite + * Compares the values read and written by runtime interfaces and + * IPL interfaces + */ + void testPnorReadWrite(void) + { + TRACFCOMP(g_trac_pnor, ENTER_MRK"testPnorReadWrite"); + do { + errlHndl_t l_err = NULL; + uint32_t l_proc = 0; + uint64_t l_offset = PNOR::pnorTestSec_rt_readwrite_offset; + uint64_t l_writeData = 0x0123456789ABCDEF; + PNOR::SectionId l_id = PNOR::TEST; + PNOR::SectionInfo_t l_info; + + size_t l_sizeBytes = (RtPnor::getInstance().iv_TOC[l_id].size) - + l_offset; + void* l_readData = malloc (l_sizeBytes); + + //read via hostInterfaces + l_err = RtPnor::getInstance().readFromDevice(l_proc,l_id,l_offset, + l_sizeBytes,true,l_readData); + if(l_err) + { + TS_FAIL("testPnorReadWrite: readFromDevice failed"); + break; + } + + //read using getSectionInfo + l_err = PNOR::getSectionInfo(l_id, l_info); + if (l_err) + { + TS_FAIL("testPnorReadWrite: getSectionInfo failed"); + break; + } + + void* l_gData = reinterpret_cast<void*> (l_info.vaddr); + + //verify that data is read correctly + if (0 != memcmp (l_readData, l_gData, l_sizeBytes)) + { + TS_FAIL("testPnorReadWrite: read failed"); + break; + } + TRACFCOMP(g_trac_pnor, "testPnorReadWrite: read successfull"); + + /***********************************************************/ + //make changes to the getSectionInfo pointer and call flush + uint8_t* l_vaddr = reinterpret_cast<uint8_t*>(l_info.vaddr); + + memcpy(l_vaddr, &l_writeData, 4); + memcpy(l_vaddr+PAGESIZE+20, &l_writeData, 4); + + l_err = PNOR::flush(l_id); + if (l_err) + { + TS_FAIL("testPnorReadWrite: flush failed"); + break; + } + + /***********************************************************/ + //calling read again to make sure data was written properly + //using pnor_wirte + l_err = RtPnor::getInstance().readFromDevice(l_proc,l_id,l_offset, + l_sizeBytes,true,l_readData); + if(l_err) + { + TS_FAIL("testPnorReadWrite: readFromDevice failed"); + break; + } + + if (0 != memcmp (l_readData, l_gData, l_sizeBytes)) + { + TS_FAIL("testPnorReadWrite: flush failed"); + break; + } + TRACFCOMP(g_trac_pnor, "testPnorReadWrite: flush passed"); + + } while (0); + TRACFCOMP(g_trac_pnor, EXIT_MRK"testPnorReadWrite"); + } + +}; |