summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/include/errno.h7
-rw-r--r--src/include/sys/msg.h9
-rw-r--r--src/include/sys/vfs.h6
-rw-r--r--src/kernel/basesegment.C2
-rw-r--r--src/kernel/devicesegment.C10
-rw-r--r--src/kernel/syscall.C11
-rw-r--r--src/lib/syscall_task.C14
-rw-r--r--src/sys/init/init_main.C2
-rw-r--r--src/sys/vfs/vfs_main.C22
-rw-r--r--src/usr/initservice/extinitsvc/extinitsvc.C4
-rw-r--r--src/usr/initservice/istepdispatcher/splesscommon.H6
-rw-r--r--src/usr/vfs/vfsrp.C8
12 files changed, 68 insertions, 33 deletions
diff --git a/src/include/errno.h b/src/include/errno.h
index 0db3043ec..678f20131 100644
--- a/src/include/errno.h
+++ b/src/include/errno.h
@@ -23,9 +23,12 @@
#ifndef _ERRNO_H
#define _ERRNO_H
-#define EIO 5 // I/O error
+#define ENOENT 2 // No such file or directory
+#define EIO 5 // I/O error
+#define ENOEXEC 8 // Exec format error
+#define EBADF 9 // Bad file descriptor
#define EAGAIN 11 // Try again
-#define EFAULT 14 // Bad address
+#define EFAULT 14 // Bad address
#define EINVAL 22 // Invalid argument
#define EWOULDBLOCK EAGAIN // operation would block
diff --git a/src/include/sys/msg.h b/src/include/sys/msg.h
index 215da312e..be7ba397a 100644
--- a/src/include/sys/msg.h
+++ b/src/include/sys/msg.h
@@ -171,7 +171,11 @@ ALWAYS_INLINE
*
* @param[in] q - message queue
* @param[in] msg - message
- * @return Always returns zero.
+ *
+ * @return Status of message send.
+ * @retval 0 - Success
+ * @retval -EINVAL - Invalid pointer passed to kernel.
+ * @retval -EINVAL - Message type is in kernel range.
*/
int msg_send(msg_q_t q, msg_t* msg);
@@ -197,7 +201,10 @@ int msg_sendrecv(msg_q_t q, msg_t* msg);
*
* @param[in] q - message queue
* @param[in] msg - response message
+ *
* @return Zero on success, else negative.
+ * @retval -EBADF - Message was not sent synchronously.
+ *
*/
int msg_respond(msg_q_t q, msg_t* msg);
diff --git a/src/include/sys/vfs.h b/src/include/sys/vfs.h
index 52629499b..f16e91b23 100644
--- a/src/include/sys/vfs.h
+++ b/src/include/sys/vfs.h
@@ -62,7 +62,7 @@ extern const char* VFS_ROOT;
extern const char* VFS_ROOT_BIN;
extern const char* VFS_ROOT_DATA;
extern const char* VFS_ROOT_MSG;
-extern const char* VFS_MSG;
+extern const char* VFS_ROOT_MSG_VFS;
enum VfsMessages
{
@@ -105,7 +105,9 @@ VfsSystemModule * vfs_find_module(VfsSystemModule * i_table, const char * i_name
* Call the module start routine
* @param[in] i_module VfsSystemModule data for the module
* @param[in] i_param parameter to pass to task_create() for this module
- * @return tid_t of started task | -1 if i_module is NULL | -2 if there is no start()
+ * @return tid_t of started task or negative value on error.
+ * @retval -ENOENT if i_module is NULL
+ * @retval -ENOEXEC if there is no start()
*/
tid_t vfs_exec(VfsSystemModule * i_module, void* i_param);
#endif
diff --git a/src/kernel/basesegment.C b/src/kernel/basesegment.C
index 94aafec40..2c5b73c19 100644
--- a/src/kernel/basesegment.C
+++ b/src/kernel/basesegment.C
@@ -121,7 +121,7 @@ int BaseSegment::_mmAllocBlock(MessageQueue* i_mq,void* i_va,uint64_t i_size)
l_vaddr >= (this->getBaseAddress() + (1ull << SLBE_s)) ||
(l_blockSizeTotal + ALIGN_PAGE(i_size)) >= (1ull << SLBE_s))
{
- return -1;
+ return -EINVAL;
}
Block* l_block = new Block(l_vaddr, ALIGN_PAGE(i_size), i_mq);
l_block->setParent(this);
diff --git a/src/kernel/devicesegment.C b/src/kernel/devicesegment.C
index 793b29f1c..f158ab3ec 100644
--- a/src/kernel/devicesegment.C
+++ b/src/kernel/devicesegment.C
@@ -102,7 +102,7 @@ bool DeviceSegment::handlePageFault(task_t* i_task, uint64_t i_addr)
//Verify the device is mapped
uint64_t segment_ea = i_addr - this->getBaseAddress();
size_t idx = segment_ea / ((1ull << SLBE_s) / MMIO_MAP_DEVICES);
- uint64_t device_offset = segment_ea -
+ uint64_t device_offset = segment_ea -
(idx * (1ull << SLBE_s) / MMIO_MAP_DEVICES);
if (0 == iv_mmioMap[idx].addr ||
@@ -128,7 +128,7 @@ void* DeviceSegment::_mmioMap(void* ra, size_t pages)
{
iv_mmioMap[i].size = THIRTYTWO_GB;
iv_mmioMap[i].addr = reinterpret_cast<uint64_t>(ra);
- return reinterpret_cast<void*>(i *
+ return reinterpret_cast<void*>(i *
((1ull << SLBE_s) / MMIO_MAP_DEVICES) +
this->getBaseAddress());
}
@@ -142,7 +142,7 @@ void* DeviceSegment::_mmioMap(void* ra, size_t pages)
*/
int DeviceSegment::_mmioUnmap(void* ea, size_t pages)
{
- uint64_t segment_ea = reinterpret_cast<uint64_t>(ea) -
+ uint64_t segment_ea = reinterpret_cast<uint64_t>(ea) -
this->getBaseAddress();
size_t idx = segment_ea / ((1ull << SLBE_s) / MMIO_MAP_DEVICES);
if (0 != iv_mmioMap[idx].addr)
@@ -154,7 +154,7 @@ int DeviceSegment::_mmioUnmap(void* ea, size_t pages)
return 0;
}
- return -1;
+ return -EINVAL;
}
/**
@@ -203,7 +203,7 @@ void *DeviceSegment::_devMap(void *ra, SEG_DATA_SIZES i_devDataSize)
*/
int DeviceSegment::_devUnmap(void *ea)
{
- int rc = -1;
+ int rc = -EINVAL;
uint64_t segment_ea = reinterpret_cast<uint64_t>(ea);
//Verify input address falls within this segment's address range
if (segment_ea < this->getBaseAddress() ||
diff --git a/src/kernel/syscall.C b/src/kernel/syscall.C
index 622c970a7..af84cc173 100644
--- a/src/kernel/syscall.C
+++ b/src/kernel/syscall.C
@@ -220,6 +220,15 @@ namespace Systemcalls
{
MessageQueue* mq = (MessageQueue*) TASK_GETARG0(t);
msg_t* m = (msg_t*) TASK_GETARG1(t);
+
+ if ((NULL == mq) || (NULL == m))
+ {
+ printkd("NULL pointer for message queue (%p) or message (%p).\n",
+ mq, m);
+ TASK_SETRTN(t, -EINVAL);
+ return;
+ }
+
m->__reserved__async = 0; // set to async msg.
if (m->type >= MSG_FIRST_SYS_TYPE)
@@ -327,7 +336,7 @@ namespace Systemcalls
}
else
{
- TASK_SETRTN(t, -1);
+ TASK_SETRTN(t, -EBADF);
mq->lock.unlock();
}
}
diff --git a/src/lib/syscall_task.C b/src/lib/syscall_task.C
index 2e28afd0e..38b8adee4 100644
--- a/src/lib/syscall_task.C
+++ b/src/lib/syscall_task.C
@@ -27,6 +27,7 @@
#include <kernel/cpu.H>
#include <sys/vfs.h>
#include <sys/msg.h>
+#include <errno.h>
using namespace Systemcalls;
@@ -71,7 +72,8 @@ tid_t task_exec(const char* file, void* ptr)
// The VFS process is responsible for finding the module and creating the
// new process. So, we send a message over to that process.
- tid_t child = -1;
+ tid_t child = 0;
+ int rc = 0;
// Create message, send.
msg_q_t vfsQ = (msg_q_t)_syscall0(MSGQ_RESOLVE_ROOT);
@@ -79,7 +81,15 @@ tid_t task_exec(const char* file, void* ptr)
msg->type = VFS_MSG_EXEC;
msg->data[0] = (uint64_t) file;
msg->data[1] = (uint64_t) ptr;
- int rc = msg_sendrecv(vfsQ, msg);
+ if (vfsQ)
+ {
+ msg_sendrecv(vfsQ, msg);
+ }
+ else
+ {
+ // VFS process isn't fully up yet, return EAGAIN.
+ rc = -EAGAIN;
+ }
if (0 == rc)
{
diff --git a/src/sys/init/init_main.C b/src/sys/init/init_main.C
index ffc552dad..96fea57a8 100644
--- a/src/sys/init/init_main.C
+++ b/src/sys/init/init_main.C
@@ -50,7 +50,7 @@ void init_main(void* unused)
// run initialization service to start up everything else.
printk("init_main: Starting Initialization Service...\n");
tidrc = task_exec( "libinitservice.so", NULL );
- if ( (int16_t)tidrc < 0 ) // task_exec returned a -1
+ if ( (int16_t)tidrc < 0 ) // task_exec returned an error.
{
printk( "ERROR: init_main: failed to launch initservice: %d\n", tidrc );
diff --git a/src/sys/vfs/vfs_main.C b/src/sys/vfs/vfs_main.C
index 599668cc3..06a7f9d07 100644
--- a/src/sys/vfs/vfs_main.C
+++ b/src/sys/vfs/vfs_main.C
@@ -21,6 +21,7 @@
//
// IBM_PROLOG_END
#include <string.h>
+#include <errno.h>
#include <sys/msg.h>
#include <sys/vfs.h>
@@ -34,7 +35,7 @@ const char* VFS_ROOT = "/";
const char* VFS_ROOT_BIN = "/bin/";
const char* VFS_ROOT_DATA = "/data/";
const char* VFS_ROOT_MSG = "/msg/";
-const char* VFS_MSG = "/vfs/";
+const char* VFS_ROOT_MSG_VFS = "/msg/vfs";
void vfs_module_init();
@@ -42,7 +43,9 @@ void vfs_module_init();
* Call the module start routine
* @param[in] i_module VfsSystemModule data for the module
* @param[in] i_param parameter to pass to task_create() for this module
- * @return tid_t of started task | -1 if i_module is NULL | -2 if there is no start()
+ * @return tid_t of started task or negative value on error.
+ * @retval -ENOENT if i_module is NULL
+ * @retval -ENOEXEC if there is no start()
*/
tid_t vfs_exec(VfsSystemModule * i_module, void* i_param);
@@ -122,13 +125,14 @@ void vfs_main(void* i_barrier)
tid_t child = vfs_exec(module,(void*) msg->data[1]);
- // child == -1 means module not found in base image so send
- // a message to VFS_MSG queue to look in the extended image
- // VFS_MSG queue will handle the msg_respond()
- if( child == (tid_t)-1 ) // forward msg to usr vfs
+ // child == -ENOENT means module not found in base image
+ // so send a message to VFS_MSG queue to look in the
+ // extended image VFS_MSG queue will handle the
+ // msg_respond()
+ if( child == (tid_t)-ENOENT ) // forward msg to usr vfs
{
VfsEntry::key_type k;
- strcpy(k.key, VFS_MSG);
+ strcpy(k.key, VFS_ROOT_MSG_VFS);
VfsEntry* e = vfsContents.find(k);
if(e != NULL)
{
@@ -163,12 +167,12 @@ void vfs_main(void* i_barrier)
tid_t vfs_exec(VfsSystemModule * i_module, void* i_param)
{
- tid_t child = -1;
+ tid_t child = -ENOENT;
if(i_module != NULL)
{
if (i_module->start == NULL)
{
- child = -2; // module has no start() routine
+ child = -ENOEXEC; // module has no start() routine
}
else
{
diff --git a/src/usr/initservice/extinitsvc/extinitsvc.C b/src/usr/initservice/extinitsvc/extinitsvc.C
index 03bae9364..d721ff8cd 100644
--- a/src/usr/initservice/extinitsvc/extinitsvc.C
+++ b/src/usr/initservice/extinitsvc/extinitsvc.C
@@ -180,7 +180,7 @@ void ExtInitSvc::init( void *i_ptr )
* hbicore.bin (HostBoot shippable image)
* hbicore_test.bin (runs all unit tests)
* Only hbicore_test.bin has the libcxxtest.so module, so when
- * we execute startTask() below on hbicore.bin, it will return -1,
+ * we execute startTask() below on hbicore.bin, it will return -ENOENT,
* no module present. This is OK.
*
* @todo can we call call module_load() to see if libcxxtest.so exists?
@@ -206,7 +206,7 @@ void ExtInitSvc::init( void *i_ptr )
// If the test task does not exist then don't run it.
if(!VFS::module_exists(l_pcxxtask->taskname)) break;
-
+
l_cxxerrl = InitService::getTheInstance().startTask( l_pcxxtask,
&l_cxxtestargs );
diff --git a/src/usr/initservice/istepdispatcher/splesscommon.H b/src/usr/initservice/istepdispatcher/splesscommon.H
index 113d712fd..8602901a6 100644
--- a/src/usr/initservice/istepdispatcher/splesscommon.H
+++ b/src/usr/initservice/istepdispatcher/splesscommon.H
@@ -194,9 +194,9 @@ namespace SPLESSSTS
* Sub-step Running, bits 16:31 - the substep that is currently running.
* Task Status, bits 32:47 - the status that IStep Dispatcher returns when
* trying to run the task. For example:
- * -3 IStep number is invalid
- * -1, -2 (return code from kernel) IStep could not be launched as a
- * task or as a function within a task
+ * -EINVAL IStep number is invalid
+ * -ENOENT, -ENOEXEC (return code from kernel) IStep could not
+ * be launched as a task or as a function within a task
* IStep Status, bits 48:63 - status returned from the IStep.
*
*/
diff --git a/src/usr/vfs/vfsrp.C b/src/usr/vfs/vfsrp.C
index e31cd629a..723e565a3 100644
--- a/src/usr/vfs/vfsrp.C
+++ b/src/usr/vfs/vfsrp.C
@@ -112,7 +112,7 @@ errlHndl_t VfsRp::_init()
errlHndl_t err = NULL;
size_t rc = 0;
iv_msgQ = msg_q_create();
- rc = msg_q_register(iv_msgQ, VFS_MSG);
+ rc = msg_q_register(iv_msgQ, VFS_ROOT_MSG_VFS);
// Discover PNOR virtual address of extended image
PNOR::SectionInfo_t l_pnor_info;
@@ -325,7 +325,7 @@ void VfsRp::get_test_modules(std::vector<const char *> & o_list) const
o_list.clear();
o_list.reserve(32);
- VfsSystemModule * vfsItr =
+ VfsSystemModule * vfsItr =
(VfsSystemModule *) (iv_pnor_vaddr + VFS_EXTENDED_MODULE_TABLE_OFFSET);
//TRACDCOMP(g_trac_vfs,"finding test modules...");
@@ -341,7 +341,7 @@ void VfsRp::get_test_modules(std::vector<const char *> & o_list) const
}
}
vfsItr++;
- }
+ }
}
@@ -350,7 +350,7 @@ void VfsRp::get_test_modules(std::vector<const char *> & o_list) const
errlHndl_t VFS::module_load_unload(const char * i_module, VfsMessages i_msgtype)
{
errlHndl_t err = NULL;
- msg_q_t vfsQ = msg_q_resolve(VFS_MSG);
+ msg_q_t vfsQ = msg_q_resolve(VFS_ROOT_MSG_VFS);
msg_t* msg = msg_allocate();
msg->type = i_msgtype;
msg->data[0] = (uint64_t) i_module;
OpenPOWER on IntegriCloud