summaryrefslogtreecommitdiffstats
path: root/src/usr/vfs
diff options
context:
space:
mode:
authorDoug Gilbert <dgilbert@us.ibm.com>2011-09-19 10:17:02 -0500
committerDouglas R. Gilbert <dgilbert@us.ibm.com>2011-09-28 10:42:18 -0500
commit3e955c10be1734e2d438f337e7064c3ba8884a73 (patch)
tree8f2991425ba0f201eebf4f0718cdd2d99830e6d9 /src/usr/vfs
parentd034089348a197fa870bada40ac9f62523088d09 (diff)
downloadtalos-hostboot-3e955c10be1734e2d438f337e7064c3ba8884a73.tar.gz
talos-hostboot-3e955c10be1734e2d438f337e7064c3ba8884a73.zip
VFS provide assess to read-only data modules
Change-Id: I0178e5b9154f43e092af217931f4570941393d62 Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/357 Reviewed-by: Douglas R. Gilbert <dgilbert@us.ibm.com> Tested-by: Jenkins Server
Diffstat (limited to 'src/usr/vfs')
-rw-r--r--src/usr/vfs/makefile2
-rw-r--r--src/usr/vfs/test/makefile37
-rw-r--r--src/usr/vfs/test/vfstest.H77
-rw-r--r--src/usr/vfs/vfsrp.C60
-rw-r--r--src/usr/vfs/vfsrp.H9
5 files changed, 178 insertions, 7 deletions
diff --git a/src/usr/vfs/makefile b/src/usr/vfs/makefile
index 294bf10d1..69d0f53a2 100644
--- a/src/usr/vfs/makefile
+++ b/src/usr/vfs/makefile
@@ -25,6 +25,6 @@ MODULE = vfs
OBJS = vfsrp.o
-#SUBDIRS = test.d
+SUBDIRS = test.d
include ${ROOTPATH}/config.mk
diff --git a/src/usr/vfs/test/makefile b/src/usr/vfs/test/makefile
new file mode 100644
index 000000000..15f157d47
--- /dev/null
+++ b/src/usr/vfs/test/makefile
@@ -0,0 +1,37 @@
+# IBM_PROLOG_BEGIN_TAG
+# This is an automatically generated prolog.
+#
+# $Source: src/usr/vfs/test/makefile $
+#
+# IBM CONFIDENTIAL
+#
+# COPYRIGHT International Business Machines Corp. 2011
+#
+# 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 other-
+# wise divested of its trade secrets, irrespective of what has
+# been deposited with the U.S. Copyright Office.
+#
+# Origin: 30
+#
+# IBM_PROLOG_END
+ROOTPATH = ../../../..
+
+MODULE = testvfs
+
+TESTS = *.H
+
+${ROOTPATH}/img/testdata:
+ echo "This is a test image" > ${ROOTPATH}/img/testdata
+
+code_pass: ${ROOTPATH}/img/testdata
+
+EXTRA_PARTS = ${ROOTPATH}/img/testdata
+
+include ${ROOTPATH}/config.mk
+
diff --git a/src/usr/vfs/test/vfstest.H b/src/usr/vfs/test/vfstest.H
new file mode 100644
index 000000000..6c85152e9
--- /dev/null
+++ b/src/usr/vfs/test/vfstest.H
@@ -0,0 +1,77 @@
+// IBM_PROLOG_BEGIN_TAG
+// This is an automatically generated prolog.
+//
+// $Source: src/usr/vfs/test/vfstest.H $
+//
+// IBM CONFIDENTIAL
+//
+// COPYRIGHT International Business Machines Corp. 2011
+//
+// 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 other-
+// wise divested of its trade secrets, irrespective of what has
+// been deposited with the U.S. Copyright Office.
+//
+// Origin: 30
+//
+// IBM_PROLOG_END
+#ifndef __VFSTEST_H
+#define __VFSTEST_H
+
+#include <cxxtest/TestSuite.H>
+#include <vfs/vfs.H>
+#include <errl/errlentry.H>
+#include <errl/errlmanager.H>
+#include <string.h>
+
+
+class VfsTest: public CxxTest::TestSuite
+{
+ public:
+
+ /**
+ * @brief VFS read data module
+ */
+ void test_readDataModule( void )
+ {
+ errlHndl_t err = NULL;
+ size_t size = 0;
+ const char * addr = NULL;
+
+ err = VFS::module_load("testdata");
+ if(err)
+ {
+ TS_FAIL("module_load failed");
+ ERRORLOG::errlCommit(err);
+ }
+
+ err = VFS::module_address("testdata",addr,size);
+ if(err)
+ {
+ TS_FAIL("module_address failed");
+ ERRORLOG::errlCommit(err);
+ }
+ else
+ {
+ if(memcmp(addr,"This is a test image",20))
+ {
+ TS_FAIL("Data module addr = %p, size = %ld",addr,size);
+ TS_FAIL("%s",addr);
+ }
+ }
+
+ err = VFS::module_unload("testdata");
+ if(err)
+ {
+ TS_FAIL("module_unload failed");
+ }
+ }
+};
+
+
+#endif
diff --git a/src/usr/vfs/vfsrp.C b/src/usr/vfs/vfsrp.C
index bb487da25..266cdecba 100644
--- a/src/usr/vfs/vfsrp.C
+++ b/src/usr/vfs/vfsrp.C
@@ -28,7 +28,6 @@
#include <limits.h>
#include <string.h>
#include <errno.h>
-#include <sys/msg.h>
#include <sys/vfs.h>
#include <vfs/vfs.H>
#include <vfs/vfs_reasoncodes.H>
@@ -261,6 +260,7 @@ void VfsRp::_load_unload(msg_t * i_msg)
if(module)
{
int rc = 0;
+
if(i_msg->type == VFS_MSG_LOAD)
{
rc = vfs_module_perms(module);
@@ -280,13 +280,13 @@ void VfsRp::_load_unload(msg_t * i_msg)
(module->fini)(NULL);
}
- // TODO
- //rc = mm_set_permission(module->text,
- // module->page_size*PAGESIZE,
- // READ_ONLY); // TODO NO_ACCESS
+ rc = mm_set_permission(module->text,
+ module->page_count*PAGESIZE,
+ NO_ACCESS);
+
rc = mm_remove_pages(RELEASE,
module->text,
- module->page_size*PAGESIZE);
+ module->page_count*PAGESIZE);
}
if(rc)
{
@@ -390,6 +390,15 @@ bool VfsRp::module_exists(const char * i_name) const
// ----------------------------------------------------------------------------
+const VfsSystemModule * VfsRp::get_vfs_info(const char * i_name) const
+{
+ return vfs_find_module((VfsSystemModule *)(iv_pnor_vaddr +
+ VFS_EXTENDED_MODULE_TABLE_OFFSET),
+ i_name);
+}
+
+// ----------------------------------------------------------------------------
+
void VfsRp::get_test_modules(std::vector<const char *> & o_list) const
{
o_list.clear();
@@ -470,3 +479,42 @@ bool VFS::module_exists(const char * i_name)
return Singleton<VfsRp>::instance().module_exists(i_name);
}
+// -----------------------------------------------------------------------------
+
+errlHndl_t VFS::module_address(const char * i_name, const char *& o_address, size_t & o_size)
+{
+ errlHndl_t err = NULL;
+ o_address = NULL;
+ o_size = 0;
+
+ const VfsSystemModule * vfs = Singleton<VfsRp>::instance().get_vfs_info(i_name);
+ if(!vfs || (vfs->text != vfs->data))
+ {
+ // module not found or is not a data module
+ /*@ errorlog tag
+ * @errortype ERRL_SEV_INFORMATIONAL
+ * @moduleid VFS_MODULE_ID
+ * @reasoncode VFS_INVALID_DATA_MODULE
+ * @userdata1 0
+ * @userdata2 0
+ *
+ * @defdesc Module is not a data module
+ *
+ */
+ err = new ERRORLOG::ErrlEntry
+ (
+ ERRORLOG::ERRL_SEV_INFORMATIONAL, // severity
+ VFS::VFS_MODULE_ID, // moduleid
+ VFS::VFS_INVALID_DATA_MODULE, // reason Code
+ 0,
+ 0
+ );
+ }
+ else
+ {
+ o_address = (const char *)vfs->data;
+ o_size = vfs->page_count * PAGESIZE;
+ }
+ return err;
+}
+
diff --git a/src/usr/vfs/vfsrp.H b/src/usr/vfs/vfsrp.H
index 129b4bd37..c5a74c91f 100644
--- a/src/usr/vfs/vfsrp.H
+++ b/src/usr/vfs/vfsrp.H
@@ -26,6 +26,7 @@
#include <stdint.h>
#include <builtins.h>
#include <errl/errltypes.H>
+#include <sys/msg.h>
struct msg_t;
@@ -59,6 +60,14 @@ namespace VFS
*/
bool module_exists(const char * i_name) const;
+ /**
+ * get VfsSystemModule information
+ * @param[in] i_name module name
+ * @return pointer to VfsSystemModule entree
+ * or NULL if not found
+ */
+ const VfsSystemModule * get_vfs_info(const char * i_name) const;
+
protected:
/**
* Ctor
OpenPOWER on IntegriCloud