Module: xenomai-3
Branch: next
Commit: fea9dc159cb32cbe1f179b8bcc37a2cc54918d59
URL:    
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=fea9dc159cb32cbe1f179b8bcc37a2cc54918d59

Author: Philippe Gerum <r...@xenomai.org>
Date:   Tue May 12 17:10:44 2015 +0200

boilerplate/setup: add tuning step in setup process

A ->tune() handler is added to the setup descriptor, which will be
fired from xenomai_init() before the option parsing step runs.

Both configuration and runtime tunables may be assigned in the
->tune() handler. Their values can be overwritten by the command line
options passed to the application program.

---

 include/boilerplate/setup.h |    1 +
 lib/boilerplate/setup.c     |   17 +++++++++++++----
 2 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/include/boilerplate/setup.h b/include/boilerplate/setup.h
index f1ff7b1..40449fd 100644
--- a/include/boilerplate/setup.h
+++ b/include/boilerplate/setup.h
@@ -36,6 +36,7 @@ struct option;
 struct setup_descriptor {
        const char *name;
        int (*init)(void);
+       int (*tune)(void);
        const struct option *options;
        int (*parse_option)(int optnum, const char *optarg);
        void (*help)(void);
diff --git a/lib/boilerplate/setup.c b/lib/boilerplate/setup.c
index 24b2550..96a3a06 100644
--- a/lib/boilerplate/setup.c
+++ b/lib/boilerplate/setup.c
@@ -498,10 +498,21 @@ void xenomai_init(int *argcp, char *const **argvp)
 
        /*
         * Now that we have bootstrapped the core, we may call the
-        * setup handlers for parsing their own options, which in turn
-        * may create system objects on the fly.
+        * setup handlers for tuning the configuration, then parsing
+        * their own options, and eventually doing the init chores.
         */
        if (!pvlist_empty(&setup_list)) {
+
+               CANCEL_DEFER(svc);
+
+               pvlist_for_each_entry(setup, &setup_list, __reserved.next) {
+                       if (setup->tune) {
+                               ret = setup->tune();
+                               if (ret)
+                                       break;
+                       }
+               }
+               
                ret = parse_setup_options(argcp, largc, uargv, options);
                if (ret)
                        goto fail;
@@ -512,8 +523,6 @@ void xenomai_init(int *argcp, char *const **argvp)
                 */
                __config_done = 1;
        
-               CANCEL_DEFER(svc);
-
                pvlist_for_each_entry(setup, &setup_list, __reserved.next) {
                        if (setup->init) {
                                ret = setup->init();


_______________________________________________
Xenomai-git mailing list
Xenomai-git@xenomai.org
http://www.xenomai.org/mailman/listinfo/xenomai-git

Reply via email to