diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2012-12-19 17:54:26 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2012-12-19 17:54:26 +0000 |
commit | 913f876fac94f21a683809d9f648e4793f61e237 (patch) | |
tree | 1587afb37a0e1b5a87f007f452e147ff3c2dcc04 /nuttx/binfmt/binfmt_execmodule.c | |
parent | bbef9f93daeb6a3565c4c28572d73130dfb6ac85 (diff) | |
download | nuttx-913f876fac94f21a683809d9f648e4793f61e237.tar.gz nuttx-913f876fac94f21a683809d9f648e4793f61e237.tar.bz2 nuttx-913f876fac94f21a683809d9f648e4793f61e237.zip |
Incorporate address environment interfaces in binfmt/ logic
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5443 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/binfmt/binfmt_execmodule.c')
-rw-r--r-- | nuttx/binfmt/binfmt_execmodule.c | 45 |
1 files changed, 43 insertions, 2 deletions
diff --git a/nuttx/binfmt/binfmt_execmodule.c b/nuttx/binfmt/binfmt_execmodule.c index 37f445966..400451c40 100644 --- a/nuttx/binfmt/binfmt_execmodule.c +++ b/nuttx/binfmt/binfmt_execmodule.c @@ -86,11 +86,26 @@ ****************************************************************************/ #ifdef CONFIG_BINFMT_CONSTRUCTORS -static inline void exec_ctors(FAR const struct binary_s *binp) +static inline int exec_ctors(FAR const struct binary_s *binp) { binfmt_ctor_t *ctor = binp->ctors; +#ifdef CONFIG_ADDRENV + hw_addrenv_t oldenv; + int ret; +#endif int i; + /* Instantiate the address enviroment containing the constructors */ + +#ifdef CONFIG_ADDRENV + ret = up_addrenv_select(binp->addrenv, &oldenv); + if (ret < 0) + { + bdbg("up_addrenv_select() failed: %d\n", ret); + return ret; + } +#endif + /* Execute each constructor */ for (i = 0; i < binp->nctors; i++) @@ -100,6 +115,14 @@ static inline void exec_ctors(FAR const struct binary_s *binp) (*ctor)(); ctor++; } + + /* Restore the address enviroment */ + +#ifdef CONFIG_ADDRENV + return up_addrenv_restore(oldenv); +#else + return OK; +#endif } #endif @@ -190,6 +213,18 @@ int exec_module(FAR const struct binary_s *binp, int priority) up_initial_state(tcb); #endif + /* Assign the address environment to the task */ + +#ifdef CONFIG_ADDRENV + ret = up_addrenv_assign(binp->addrenv, tcb); + if (ret < 0) + { + err = -ret; + bdbg("up_addrenv_assign() failed: %d\n", ret); + goto errout_with_stack; + } +#endif + /* Get the assigned pid before we start the task */ pid = tcb->pid; @@ -197,7 +232,13 @@ int exec_module(FAR const struct binary_s *binp, int priority) /* Execute all of the C++ static constructors */ #ifdef CONFIG_BINFMT_CONSTRUCTORS - exec_ctors(binp); + ret = exec_ctors(binp); + if (ret < 0) + { + err = -ret; + bdbg("exec_ctors() failed: %d\n", ret); + goto errout_with_stack; + } #endif /* Then activate the task at the provided priority */ |