summaryrefslogtreecommitdiffstats
path: root/src/usr/testcore/kernel/misctest.H
diff options
context:
space:
mode:
Diffstat (limited to 'src/usr/testcore/kernel/misctest.H')
-rw-r--r--src/usr/testcore/kernel/misctest.H54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/usr/testcore/kernel/misctest.H b/src/usr/testcore/kernel/misctest.H
index 9a7cbb2ba..e31b3cc9c 100644
--- a/src/usr/testcore/kernel/misctest.H
+++ b/src/usr/testcore/kernel/misctest.H
@@ -26,6 +26,7 @@
#include <sys/misc.h>
#include <kernel/cpumgr.H>
+#include <targeting/common/targetservice.H>
/** @file misctest.H
*
@@ -49,6 +50,59 @@ class MiscTest : public CxxTest::TestSuite
TS_FAIL("LPCR value is not as expected.");
}
}
+
+ /** Tests for mm_virt_to_phys() */
+ void testVirtToPhys()
+ {
+ uint64_t phys = 0;
+ uint64_t hrmor = cpu_spr_value(CPU_SPR_HRMOR);
+
+ // Verify a regular heap address
+ uint8_t* heap = (uint8_t*)malloc(1);
+ *heap = 0xAB; //to make sure it gets paged in
+ phys = mm_virt_to_phys( heap );
+ if( phys != (reinterpret_cast<uint64_t>(heap)|hrmor) )
+ {
+ TS_FAIL("Unexpected Physical Address for Heap.");
+ TS_TRACE( "heap> virt=%p, phys=%lX", (void*)heap, phys );
+ }
+ free(heap);
+
+ // Verify a regular stack address
+ phys = mm_virt_to_phys( (void*)&phys );
+ if( phys < hrmor )
+ {
+ TS_FAIL("Unexpected Physical Address for Stack.");
+ TS_TRACE( "stack> virt=%p, phys=%lX", &phys, phys );
+ }
+
+ // Verify a MMIO (XSCOM)
+ TARGETING::EntityPath epath(TARGETING::EntityPath::PATH_PHYSICAL);
+ epath.addLast(TARGETING::TYPE_SYS,0);
+ epath.addLast(TARGETING::TYPE_NODE,0);
+ epath.addLast(TARGETING::TYPE_PROC,1);
+ TARGETING::Target* l_targ =
+ TARGETING::targetService().toTarget(epath);
+ if(l_targ != NULL)
+ {
+ uint64_t xscom =
+ l_targ->getAttr<TARGETING::ATTR_XSCOM_VIRTUAL_ADDR>();
+ phys = mm_virt_to_phys( (void*)xscom );
+ if( (phys != (1020*TERABYTE+32*GIGABYTE))
+ && (xscom != 0) ) //never got set
+ {
+ TS_FAIL("Unexpected Physical Address for MMIO.");
+ TS_TRACE( "mmio1> virt=%lX, phys=%lX\n", xscom, phys );
+ }
+ }
+
+
+ /* Hardcoded interrupt presenter address for testing on 1-proc model
+ uint64_t intr = 0x20800000000;
+ phys = mm_virt_to_phys( (void*)intr );
+ TS_TRACE( "mmio2> virt=%lX, phys=%lX\n", intr, phys );
+ */
+ }
};
#endif
OpenPOWER on IntegriCloud