diff options
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | config.mk | 4 | ||||
-rw-r--r-- | src/include/errno.h | 1 | ||||
-rw-r--r-- | src/include/sys/vfs.h | 2 | ||||
-rw-r--r-- | src/include/usr/vfs/vfs.H | 11 | ||||
-rw-r--r-- | src/include/usr/vfs/vfs_reasoncodes.H | 1 | ||||
-rw-r--r-- | src/makefile | 4 | ||||
-rw-r--r-- | src/sys/vfs/vfs_init.C | 2 | ||||
-rw-r--r-- | src/usr/vfs/makefile | 2 | ||||
-rw-r--r-- | src/usr/vfs/test/makefile | 37 | ||||
-rw-r--r-- | src/usr/vfs/test/vfstest.H | 77 | ||||
-rw-r--r-- | src/usr/vfs/vfsrp.C | 60 | ||||
-rw-r--r-- | src/usr/vfs/vfsrp.H | 9 |
13 files changed, 200 insertions, 11 deletions
diff --git a/.gitignore b/.gitignore index d9d9c23c8..480ee641d 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ customrc *.log my.sandboxrc cxxtest_sb/ +testdata @@ -175,11 +175,13 @@ endef $(foreach img,$(IMGS),$(eval $(call ELF_template,$(img)))) ${IMGDIR}/%.bin ${IMGDIR}/%.list ${IMGDIR}/%.syms: ${IMGDIR}/%.elf \ - $(wildcard ${IMGDIR}/*.so) ${CUSTOM_LINKER_EXE} + $(wildcard ${IMGDIR}/*.so) $(addprefix ${IMGDIR}/, $($*_DATA_MODULES)) \ + ${CUSTOM_LINKER_EXE} ${CUSTOM_LINKER} $@ $< \ $(addprefix ${IMGDIR}/lib, $(addsuffix .so, $($*_MODULES))) \ --extended=0x40000 ${IMGDIR}/$*_extended.bin \ $(addprefix ${IMGDIR}/lib, $(addsuffix .so, $($*_EXTENDED_MODULES))) \ + $(addprefix ${IMGDIR}/, $($*_DATA_MODULES)) \ > ${IMGDIR}/.$*.lnkout ${ROOTPATH}/src/build/tools/addimgid $@ $< (cd ${ROOTPATH}; \ diff --git a/src/include/errno.h b/src/include/errno.h index 678f20131..d4c296179 100644 --- a/src/include/errno.h +++ b/src/include/errno.h @@ -30,6 +30,7 @@ #define EAGAIN 11 // Try again #define EFAULT 14 // Bad address #define EINVAL 22 // Invalid argument +#define ENFILE 23 // Too many open files in system #define EWOULDBLOCK EAGAIN // operation would block diff --git a/src/include/sys/vfs.h b/src/include/sys/vfs.h index 2f99e39c8..6ab24c9b8 100644 --- a/src/include/sys/vfs.h +++ b/src/include/sys/vfs.h @@ -81,7 +81,7 @@ struct VfsSystemModule void (*fini)(void*); //!< ptr to fini() uint64_t * text; //!< ptr to text (code) section uint64_t * data; //!< ptr to data section - uint64_t page_size; //!< no. of memory pages used + uint64_t page_count; //!< no. of memory pages used }; extern VfsSystemModule VFS_MODULES[VFS_MODULE_MAX]; diff --git a/src/include/usr/vfs/vfs.H b/src/include/usr/vfs/vfs.H index 9b921c317..c916eb8ce 100644 --- a/src/include/usr/vfs/vfs.H +++ b/src/include/usr/vfs/vfs.H @@ -25,6 +25,7 @@ #include <errl/errlentry.H> #include <sys/vfs.h> +#include <sys/sync.h> #include <vector> namespace VFS @@ -72,6 +73,16 @@ namespace VFS */ bool module_exists(const char * i_name); + /** + * Get the start memory address of a data module + * @param[in] module name + * @param[out] o_address memory address + * @param[out] o_size module size + * @retun error log on error + * @pre load_module() must have been called + */ + errlHndl_t module_address(const char * i_name, const char *& o_address, size_t & o_size); + }; #endif diff --git a/src/include/usr/vfs/vfs_reasoncodes.H b/src/include/usr/vfs/vfs_reasoncodes.H index 3054980cd..ea4410de7 100644 --- a/src/include/usr/vfs/vfs_reasoncodes.H +++ b/src/include/usr/vfs/vfs_reasoncodes.H @@ -40,6 +40,7 @@ namespace VFS VFS_ALLOC_VMEM_FAILED = VFS_COMP_ID | 0x03, VFS_PERMS_VMEM_FAILED = VFS_COMP_ID | 0x04, VFS_MODULE_DOES_NOT_EXIST = VFS_COMP_ID | 0x05, + VFS_INVALID_DATA_MODULE = VFS_COMP_ID | 0x06, }; }; diff --git a/src/makefile b/src/makefile index 21d737ecb..d407f6549 100644 --- a/src/makefile +++ b/src/makefile @@ -54,19 +54,21 @@ RUNTIME_MODULES = TESTCASE_MODULES = cxxtest testerrl testdevicefw testsyslib \ testscom testxscom testtargeting testinitservice testkernel \ testhwpf testecmddatabuffer initsvctasktest2 testcxxtest \ - testpnor testi2c testfsi + testpnor testi2c testfsi testvfs RELOCATABLE_IMAGE_LDFLAGS = -pie --export-dynamic hbicore_OBJECTS = ${BASE_OBJECTS} ${DIRECT_BOOT_OBJECTS} ${STUB_TESTCASE_OBJECT} hbicore_MODULES = ${BASE_MODULES} ${DIRECT_BOOT_MODULES} hbicore_EXTENDED_MODULES = ${EXTENDED_MODULES} +hbicore_DATA_MODULES = hbicore_LIDNUMBER = 80f00100 hbicore_test_OBJECTS = ${BASE_OBJECTS} ${DIRECT_BOOT_OBJECTS} hbicore_test_MODULES = ${hbicore_MODULES} hbicore_test_EXTENDED_MODULES = ${hbicore_EXTENDED_MODULES} ${TESTCASE_MODULES} +hbicore_test_DATA_MODULES = ${hbicore_DATA_MODULES} testdata #halruntime_OBJECTS = ${BASE_OBJECTS} ${RUNTIME_OBJECTS} #halruntime_MODULES = ${BASE_MODULES} ${EXTENDED_MODULES} ${RUNTIME_MODULES} diff --git a/src/sys/vfs/vfs_init.C b/src/sys/vfs/vfs_init.C index 63ed5b08b..ad08d0d7f 100644 --- a/src/sys/vfs/vfs_init.C +++ b/src/sys/vfs/vfs_init.C @@ -36,7 +36,7 @@ uint64_t VFS_LAST_ADDRESS; int vfs_module_perms(VfsSystemModule* module) { int rc = 0; - uint64_t memsize = (module->page_size*PAGESIZE); + uint64_t memsize = (module->page_count*PAGESIZE); uint64_t textsize= (uint64_t)module->data - (uint64_t)module->text; uint64_t datasize = memsize - textsize; 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 |