Refactoring and improving the communication subsystem
authorAnselm Busse <anselm.busse@tu-berlin.de>
Tue, 26 Jan 2016 17:48:45 +0000 (18:48 +0100)
committerAnselm Busse <anselm.busse@tu-berlin.de>
Tue, 26 Jan 2016 17:48:45 +0000 (18:48 +0100)
34 files changed:
framework/generated/fw_comm_generated.c
framework/generated/topo_lb_rr_dual.c
framework/generated/topo_lb_rr_fcfs.c
framework/generated/topo_lb_rr_multi.c
framework/generated/topo_lb_rr_quad.c
framework/generated/topo_lb_rr_single.c
framework/generated/topo_rr_single.c
framework/include/fw.h
framework/include/fw_comm.h
framework/include/fw_modules.h
framework/include/fw_pipe.h
framework/include/fw_task.h
framework/include/fw_types.h
framework/include/os.h
framework/include/topics/admit.h [new file with mode: 0644]
framework/include/topics/block.h [new file with mode: 0644]
framework/include/topics/cpu_status.h [new file with mode: 0644]
framework/include/topics/release.h [new file with mode: 0644]
framework/include/topics/relinquish.h [new file with mode: 0644]
framework/include/topics/unblock.h [new file with mode: 0644]
framework/lib/fw.c
framework/lib/fw_comm.c
framework/lib/fw_modules.c
framework/lib/fw_pipe.c
framework/lib/fw_sched.c
framework/modules/affinities.c
framework/modules/fcfs.c
framework/modules/include/topics/affinity.h [new file with mode: 0644]
framework/modules/load_balance.c
framework/modules/load_balance_old.c [deleted file]
framework/modules/load_balance_old2.c [deleted file]
framework/modules/round_robin.c
framework/modules/template.c
framework/os/linux/linux_sched.c

index e0af6d4..1c89f0e 100644 (file)
@@ -4,9 +4,5 @@
 
 void fw_comm_register_generated(void)
 {
-       fw_register_topic(RR_ADMIT);
-       fw_register_topic(RR_RELEASE);
-       fw_register_topic(RR_UNBLOCK);
-       fw_register_topic(RR_BLOCK);
-       fw_register_topic(RR_DISPATCH);
+
 }
index 2d5b5d9..1dfbe5d 100644 (file)
@@ -22,7 +22,7 @@ int fw_build_topo(void)
 
        fw_num_instances = NUM_INSTANCES;
 
-       if ((fw_component_instances = fw_malloc(fw_num_instances * sizeof(fw_module_inst*))) == NULL) {
+       if ((fw_component_instances = fw_malloc(fw_num_instances * sizeof(fw_component_inst*))) == NULL) {
                        fw_panic("failed to allocate memory for instance references\n");
                        /* never reached */;
        }
index afad8cd..1ad36e5 100644 (file)
@@ -22,7 +22,7 @@ int fw_build_topo(void)
 
        fw_num_instances = NUM_INSTANCES;
 
-       if ((fw_component_instances = fw_malloc(fw_num_instances * sizeof(fw_module_inst*))) == NULL) {
+       if ((fw_component_instances = fw_malloc(fw_num_instances * sizeof(fw_component_inst*))) == NULL) {
                        fw_panic("failed to allocate memory for instance references\n");
                        /* never reached */;
        }
index 915064d..152e1b3 100644 (file)
@@ -33,7 +33,7 @@ int fw_build_topo(void)
        num_links = fw_num_cpus * 2;
        fw_num_instances = fw_num_cpus + 2; // one RR for each core + load-balancer + affinity module
 
-       if ((fw_component_instances = fw_malloc(fw_num_instances * sizeof(fw_module_inst*))) == NULL) {
+       if ((fw_component_instances = fw_malloc(fw_num_instances * sizeof(fw_component_inst*))) == NULL) {
                        fw_panic("failed to allocate memory for instance references\n");
                        /* never reached */;
        }
index 969d57d..cda8e13 100644 (file)
@@ -38,7 +38,7 @@ int fw_build_topo(void)
 
        fw_num_instances = NUM_INSTANCES;
 
-       if ((fw_component_instances = fw_malloc(fw_num_instances * sizeof(fw_module_inst*))) == NULL) {
+       if ((fw_component_instances = fw_malloc(fw_num_instances * sizeof(fw_component_inst*))) == NULL) {
                        fw_panic("failed to allocate memory for instance references\n");
                        /* never reached */;
        }
index 172a958..ae757bf 100644 (file)
@@ -32,7 +32,7 @@ int fw_build_topo(void)
 
        fw_num_instances = NUM_INSTANCES;
 
-       if ((fw_component_instances = fw_malloc(fw_num_instances * sizeof(fw_module_inst*))) == NULL) {
+       if ((fw_component_instances = fw_malloc(fw_num_instances * sizeof(fw_component_inst*))) == NULL) {
                        fw_panic("failed to allocate memory for instance references\n");
                        /* never reached */;
        }
index 0494b76..4b6fea8 100644 (file)
@@ -31,7 +31,7 @@ int fw_build_topo(void)
 
        fw_num_instances = NUM_INSTANCES;
 
-       if ((fw_component_instances = fw_malloc(fw_num_instances * sizeof(fw_module_inst*))) == NULL) {
+       if ((fw_component_instances = fw_malloc(fw_num_instances * sizeof(fw_component_inst*))) == NULL) {
                        fw_panic("failed to allocate memory for instance references\n");
                        /* never reached */;
        }
index cfea228..fef605c 100644 (file)
  */
 #define fw_printf(fmt, ...) os_printf("CoBaS: " fmt, ## __VA_ARGS__)
 
+/**
+ * \brief Print an error message.
+ *
+ * @param formatstring The format string to print on screen.
+ */
+#define fw_error(fmt, ...) os_printf("CoBaS Error: " fmt, ## __VA_ARGS__)
+
 /**
  * \brief Panic if we do not know what else to do.
  *
  * @param formatstring The format string to print on screen.
  */
-#define fw_panic(fmt, ...) os_panic("CoBaS: " fmt, ## __VA_ARGS__)
+#define fw_panic(fmt, ...) os_panic("CoBaS Panic: " fmt, ## __VA_ARGS__)
 
 /**
  * CPU information.
@@ -57,7 +64,7 @@
 
 #define FW_SMP_STARTED OS_SMP_STARTED
 
-extern fw_module_inst **fw_component_instances;
+extern fw_component_inst **fw_component_instances;
 extern unsigned int fw_num_instances;
 
 // TODO move to helper .h
index fbd8046..2e47868 100644 (file)
 #define FW_COMM_H_
 
 typedef struct fw_task fw_task_t;
-typedef struct fw_module fw_module_inst;
+typedef struct fw_component fw_component_inst;
 
+/**
+ * The type of topics in CoBaS.
+ */
+#define fw_topic_t unsigned int
+
+/**
+ * The maximum number of topics in CoBaS. Note that the identifier number of
+ * topics is also limited by this number.
+ */
 #define FW_MAX_TOPICS 64
 
 /**
- * Prototypes:
+ * \brief Creates a new subscription to the given topic.
  *
- * FW_FORK:                    void (fw_task_t *task);
- * FW_ADMIT:           void (fw_task_t *task);
- * FW_RELEASE:         void (fw_task_t *task);
- * FW_DISPATCH:                void (void);
- * FW_RELINQUISH:      void (fw_task_t *task);
- * FW_BLOCK:           void (fw_task_t *task);
- * FW_UNBLOCK:         void (fw_task_t *task);
- * FW_SUSPEND:         void (fw_task_t *task);
- * FW_ACTIVATE:                void (fw_task_t *task);
- * FW_TICK:                    void (void);
+ * This function creates a subscription to a function with a callback that is
+ * invoked every time a notification for that topic is submitted. The callback
+ * has to have the following signature:
+ * \code{.c}
+ * (fw_module_inst *self, fw_[TOPIC]_msg_t *affinity)
+ * \endcode
  *
- * Note: Do not use ID 0.
+ * @param topic The topic identifier to register for.
+ * @param callback A reference to the callback function that is invoked every
+ *                 time a notification arrives.
+ * @param inst A reference to the instance that is notified.
  */
-#define FW_FORK                                1
-#define FW_ADMIT                       2
-#define FW_RELEASE                     3
-#define FW_DISPATCH                    4
-#define FW_RELINQUISH          5
-#define FW_BLOCK                       6
-#define FW_UNBLOCK                     7
-#define FW_SUSPEND                     8
-#define FW_ACTIVATE                    9
-#define FW_BALANCE                     12
-
-#define FW_CPU_ONLINE          14
-
-#define FW_AFFINITY                    16
-
+void fw_subscribe(fw_topic_t topic, void *callback, fw_component_inst *inst);
 
+/**
+ * \brief Publishes a notification in the framework.
+ *
+ * This function publishes a notification into the framework based on the given
+ * topic. The <code>info</code> field has to be of the type
+ * <code>fw_[TOPIC]_msg_t</code>.
+ *
+ * @param topic The topic for the notification
+ * @param info The message published. Has to be be of the type
+ * <code>fw_[TOPIC]_msg_t</code>.
+ */
+void fw_notify(fw_topic_t topic, void *info);
 
-void fw_subscribe(unsigned int topic, void *callback, fw_module_inst *private_data);
-
-void fw_notify(unsigned int topic, void *info);
+/**
+ * \brief Registers a new topic in the framework.
+ *
+ * This function registers a new topic in the framework. It initializes all
+ * necessary structures and saves informations about the topic. It also checks
+ * if a topic with the given id was already given.
+ *
+ * @param topic Topic identifier used in the framwork.
+ * @param uuid A unique number to avoid identifier collisions.
+ * @param name A string with a human readable name of the topic.
+ * @param description A short description of the topic.
+ * @param topic_struct A string with the definition of the data structure used by the topic
+ * @return Returns the number of regististrations for that
+ */
+int fw_register_topic(fw_topic_t topic, unsigned long uuid, const char* name, const char* description, const char* topic_struct);
 
-int fw_register_topic(unsigned int topic);
+/**
+ * \brief A helper function for standardized topic registration.
+ *
+ * This definition registers a topic based on a single parameter. It requires
+ * that the definitions <code>FW_TOPIC_[TOPIC], FW_TUUID_[TOPIC],
+ * FW_TNAME_[TOPIC], FW_TDESC_[TOPIC], FW_TSTRUCT_[TOPIC]</code> exists when
+ * registering the topic with the name <code>TOPIC</code>.
+ */
+#define FW_REGISTER_TOPIC(NAME) fw_register_topic(FW_TOPIC_ ## NAME, FW_TUUID_ ## NAME, FW_TNAME_ ## NAME, FW_TDESC_ ## NAME, FW_TSTRUCT_ ## NAME);
 
-int fw_request(unsigned int topic, void *result);
+/**
+ * \brief Request an answer based on a topic.
+ *
+ * This function requests a reply based on the given topic. The result is
+ * returned in the <code>result</code> parameter that is in general of the type
+ * <code>fw_[TOPIC]_msg_t</code>.
+ *
+ * @param topic The requested topic.
+ * @param result A pointer to a <code>fw_[TOPIC]_msg_t</code> type to save the result
+ * @return The exit code of the performed request. It will be <code>-0xFF</code>
+ * if no responder is registered
+ */
+int fw_request(fw_topic_t topic, void *result);
 
-void fw_register_responder(unsigned int topic, void *callback, fw_module_inst *inst);
+/**
+ * \brief Registers a responder for a certain topic.
+ *
+ * This function registers a responder for a given topic. The responder is
+ * called by the supplied callback function that has to have the following
+ * signature:
+ * \code{.c}
+ * (fw_module_inst *self, fw_[TOPIC]_msg_t *msg)
+ * \endcode
+ * The <CODE>self</CODE> parameter will be a reference to the responder
+ * component instance and the <CODE>msg</CODE> parameter will contain data
+ * specific to the request.
+ *
+ * @param topic        The responding topic.
+ * @param callback Pointer to the callback function that is registered.
+ * @param inst Pointer to the component instance responsible for this topic.
+ * @return Returns 0 if successful.
+ */
+int fw_register_responder(fw_topic_t topic, void *callback, fw_component_inst *inst);
 
+/**
+ * \brief The main initialization function for the communication subsystem.
+ *
+ * This function initializes the communication system of CoBaS. It sets up the
+ * data structures with the initial values and registers all build in topics.
+ */
 void fw_comm_init(void);
 
 #endif /* FW_COMM_H_ */
index 25426fc..764cb2c 100644 (file)
@@ -11,26 +11,29 @@ typedef struct fw_task fw_task_t;
 typedef int mod_uuid_t;
 typedef int inst_uuid_t;
 
-typedef struct fw_module fw_module_inst;
+typedef struct fw_component fw_component_inst;
 typedef struct fw_pipe fw_pipe_t;
 
 typedef struct fw_module_operations {
-       fw_module_inst* (*_new) (inst_uuid_t inst_id, int link_count, fw_pipe_t **links);
-       void (*_destroy) (fw_module_inst *self);
-       void (*schedule) (fw_module_inst *self, int cpu);
-       void (*dispatch) (fw_module_inst *self, int cpu, fw_task_t *next);
-       void (*task_init) (fw_module_inst *self, fw_task_t *task);
-       void (*task_destroy) (fw_module_inst *self, fw_task_t *task);
-       void (*pipe_update) (fw_module_inst *self, fw_pipe_t *pipe);
+       fw_component_inst* (*_new) (inst_uuid_t inst_id, int link_count, fw_pipe_t **links);
+       void (*_destroy) (fw_component_inst *self);
+       void (*schedule) (fw_component_inst *self, int cpu);
+       void (*dispatch) (fw_component_inst *self, int cpu, fw_task_t *next);
+       void (*task_init) (fw_component_inst *self, fw_task_t *task);
+       void (*task_destroy) (fw_component_inst *self, fw_task_t *task);
+       void (*pipe_update) (fw_component_inst *self, fw_pipe_t *pipe);
 } fw_module_operations_t;
 
-typedef struct fw_module {
+/**
+ * The structure describing a component instance in the CoBaS Framework.
+ */
+typedef struct fw_component {
        mod_uuid_t uuid;
        const char *name;
        inst_uuid_t id;
        fw_module_operations_t ops;
        void *inst_data;
-} fw_module_inst;
+} fw_component_inst;
 
 #define inst_data(type) ((type*) self->inst_data)
 
@@ -50,6 +53,6 @@ void fw_modules_init(void);
 int fw_modules_register(int uuid, const char *module_name, fw_module_operations_t *operations);
 int fw_module_available(int uuid);
 
-fw_module_inst *fw_module_clone(fw_module_inst *other);
+fw_component_inst *fw_module_clone(fw_component_inst *other);
 
 #endif /* FW_MODULES_H_ */
index 603e694..664e962 100644 (file)
@@ -32,8 +32,8 @@ typedef struct fw_pipe {
        fw_list_head_t tasks_removed;   /**< Tasks removed from the pipe since the last access. */
        fw_list_head_t tasks_moved;             /**< Tasks moved inside the pipe since the last access. */
 
-       fw_module_inst *in;                             /**< Reference to the source component instance connected to the pipe. */
-       fw_module_inst *out;                    /**< Reference to the target component instance connected to the pipe. */
+       fw_component_inst *in;                          /**< Reference to the source component instance connected to the pipe. */
+       fw_component_inst *out;                 /**< Reference to the target component instance connected to the pipe. */
 } fw_pipe_t;
 
 /**
@@ -46,9 +46,9 @@ fw_pipe_t *fw_pipe_alloc(void);
 
 void fw_pipe_free(fw_pipe_t *pipe);
 
-int fw_pipe_task_init(fw_module_inst *self, fw_task_t *task);
+int fw_pipe_task_init(fw_component_inst *self, fw_task_t *task);
 
-void fw_pipe_task_destroy(fw_module_inst *self, fw_task_t *task);
+void fw_pipe_task_destroy(fw_component_inst *self, fw_task_t *task);
 
 int fw_pipes_init(void);
 
index ba09673..cad8a9d 100644 (file)
@@ -17,8 +17,9 @@ typedef enum fw_task_state {
        FW_IDLE         = 0x80
 } fw_task_state_t;
 
-/* structs for handling the tasks */
-
+/**
+ * The PCB of CoBaS.
+ */
 typedef struct fw_task {
        enum fw_task_state state;
        void *real_task;
index 7bf684c..977b82b 100644 (file)
@@ -9,17 +9,14 @@
 
 typedef struct fw_sched_chain fw_sched_chain_t;
 
-typedef struct fw_module fw_module_inst;
+typedef struct fw_component fw_component_inst;
 
 typedef struct fw_sched_chain {
-       fw_module_inst *inst;
+       fw_component_inst *inst;
        fw_sched_chain_t *next;
 } fw_sched_chain_t;
 
 
-typedef struct fw_affinity_msg {fw_task_t *task; fw_cpumask_t mask;} fw_affinity_msg_t;
-
-
 typedef int (*fw_initcall_t)(void);
 typedef void (*fw_exitcall_t)(void);
 
index a9af768..d76d2d0 100644 (file)
@@ -14,9 +14,6 @@
 #include <os_lock.h>
 #include <os_sched.h>
 
-#include <fw_types.h>
-#include <fw_task.h>
-
 #include <os_kdb.h>
 
 #ifndef os_printf
diff --git a/framework/include/topics/admit.h b/framework/include/topics/admit.h
new file mode 100644 (file)
index 0000000..6e06243
--- /dev/null
@@ -0,0 +1,21 @@
+
+#ifndef FW_TOPIC_ADMIT_H_
+#define FW_TOPIC_ADMIT_H_
+
+#define FW_TOPIC_ADMIT 1
+#define FW_TUUID_ADMIT 971792376
+#define FW_TNAME_ADMIT "ADMIT"
+#define FW_TDESC_ADMIT "Task admission notification."
+
+#define FW_TSTRUCT_ADMIT               \
+"typedef struct fw_admit_msg {\n\
+       fw_task_t *task;\n\
+} fw_admit_msg_t;\n"
+
+typedef struct fw_task fw_task_t;
+
+typedef struct fw_admit_msg {
+       fw_task_t *task;
+} fw_admit_msg_t;
+
+#endif /* FW_TOPIC_ADMIT_H_ */
diff --git a/framework/include/topics/block.h b/framework/include/topics/block.h
new file mode 100644 (file)
index 0000000..8896200
--- /dev/null
@@ -0,0 +1,21 @@
+
+#ifndef FW_TOPIC_BLOCK_H_
+#define FW_TOPIC_BLOCK_H_
+
+#define FW_TOPIC_BLOCK 6
+#define FW_TUUID_BLOCK 971792376
+#define FW_TNAME_BLOCK "BLOCK"
+#define FW_TDESC_BLOCK "Task admission notification."
+
+#define FW_TSTRUCT_BLOCK               \
+"typedef struct fw_block_msg {\n\
+       fw_task_t *task;\n\
+} fw_block_msg_t;\n"
+
+typedef struct fw_task fw_task_t;
+
+typedef struct fw_block_msg {
+       fw_task_t *task;
+} fw_block_msg_t;
+
+#endif /* FW_TOPIC_BLOCK_H_ */
diff --git a/framework/include/topics/cpu_status.h b/framework/include/topics/cpu_status.h
new file mode 100644 (file)
index 0000000..ae03a20
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * fw_topic_cpu_status.h
+ *
+ *  Created on: 25.01.2016
+ *      Author: abusse
+ */
+
+#ifndef FW_TOPIC_CPU_STATUS_H_
+#define FW_TOPIC_CPU_STATUS_H_
+
+#define FW_TOPIC_CPU_STATUS    14
+#define FW_TUUID_CPU_STATUS    971792376
+#define FW_TNAME_CPU_STATUS    "CPU_STATUS"
+#define FW_TDESC_CPU_STATUS    "CPU status information"
+
+#define FW_TSTRUCT_CPU_STATUS          \
+"typedef struct fw_cpu_status_msg {\n\
+       unsigned int cpu;\n\
+       fw_cpu_status_t status;\n\
+} fw_cpu_status_msg_t;\n"
+
+typedef enum fw_cpu_status {
+       ONLINE = 1,
+       OFFLINE = 2,
+} fw_cpu_status_t;
+
+typedef struct fw_cpu_status_msg {
+       unsigned int cpu;
+       fw_cpu_status_t status;
+} fw_cpu_status_msg_t;
+
+#endif /* FW_TOPIC_CPU_STATUS_H_ */
diff --git a/framework/include/topics/release.h b/framework/include/topics/release.h
new file mode 100644 (file)
index 0000000..07da941
--- /dev/null
@@ -0,0 +1,21 @@
+
+#ifndef FW_TOPIC_RELEASE_H_
+#define FW_TOPIC_RELEASE_H_
+
+#define FW_TOPIC_RELEASE       3
+#define FW_TUUID_RELEASE       971792376
+#define FW_TNAME_RELEASE       "RELEASE"
+#define FW_TDESC_RELEASE       "Task admission notification."
+
+#define FW_TSTRUCT_RELEASE             \
+"typedef struct fw_release_msg {\n\
+       fw_task_t *task;\n\
+} fw_release_msg_t;\n"
+
+typedef struct fw_task fw_task_t;
+
+typedef struct fw_release_msg {
+       fw_task_t *task;
+} fw_release_msg_t;
+
+#endif /* FW_TOPIC_RELEASE_H_ */
diff --git a/framework/include/topics/relinquish.h b/framework/include/topics/relinquish.h
new file mode 100644 (file)
index 0000000..92a6dee
--- /dev/null
@@ -0,0 +1,21 @@
+
+#ifndef FW_TOPIC_RELINQUISH_H_
+#define FW_TOPIC_RELINQUISH_H_
+
+#define FW_TOPIC_RELINQUISH    5
+#define FW_TUUID_RELINQUISH    971792376
+#define FW_TNAME_RELINQUISH    "RELINQUISH"
+#define FW_TDESC_RELINQUISH    "Task admission notification."
+
+#define FW_TSTRUCT_RELINQUISH          \
+"typedef struct fw_relinquish_msg {\n\
+       fw_task_t *task;\n\
+} fw_relinquish_msg_t;\n"
+
+typedef struct fw_task fw_task_t;
+
+typedef struct fw_relinquish_msg {
+       fw_task_t *task;
+} fw_relinquish_msg_t;
+
+#endif /* FW_TOPIC_RELINQUISH_H_ */
diff --git a/framework/include/topics/unblock.h b/framework/include/topics/unblock.h
new file mode 100644 (file)
index 0000000..a3ee3cd
--- /dev/null
@@ -0,0 +1,20 @@
+#ifndef FW_TOPIC_UNBLOCK_H_
+#define FW_TOPIC_UNBLOCK_H_
+
+#define FW_TOPIC_UNBLOCK       7
+#define FW_TUUID_UNBLOCK       971792376
+#define FW_TNAME_UNBLOCK               "UNBLOCK"
+#define FW_TDESC_UNBLOCK       "Task unblock notification"
+
+#define FW_TSTRUCT_UNBLOCK             \
+"typedef struct fw_unblock_msg {\n\
+       fw_task_t *task;\n\
+} fw_unblock_msg_t;\n"
+
+typedef struct fw_task fw_task_t;
+
+typedef struct fw_unblock_msg {
+       fw_task_t *task;
+} fw_unblock_msg_t;
+
+#endif /* FW_TOPIC_UNBLOCK_H_ */
index cda2622..d28b5da 100644 (file)
@@ -3,7 +3,7 @@
 extern int fw_build_topo(void);
 extern void __fw_schedule(int);
 
-fw_module_inst **fw_component_instances;
+fw_component_inst **fw_component_instances;
 unsigned int fw_num_instances;
 
 void fw_schedule(int cpu)
index 167ffb0..6bf0d21 100644 (file)
@@ -1,26 +1,67 @@
-
+/**
+ * @file fw_comm.c
+ * @author Anselm Busse
+ * @date 25 Jan 2015
+ * @brief File containing CoBaS communication functions.
+ *
+ * CoBaS uses a publish subscribe based communication pattern. This file
+ * contains all the functionality to realize that.
+ */
 #include <fw.h>
 
-struct fw_topic_element {
-       fw_list_head_t list;
-       void *callback;
-       fw_module_inst *inst;
+#include <topics/admit.h>
+#include <topics/block.h>
+#include <topics/cpu_status.h>
+#include <topics/release.h>
+#include <topics/relinquish.h>
+#include <topics/unblock.h>
+
+/**
+ * @brief Internal structure to store the callback for every subscription.
+ *
+ * When a component subscribes to a certain topic, an instance of this structure
+ * is created and added to the list of subscriptions.
+ */
+struct fw_subscription_element {
+       fw_list_head_t list;    /**< The list head to link the element into a list. */
+       void *callback;                 /**< Reference to the callback function. */
+       fw_component_inst *inst;        /**< The component instance to which this subscription belongs. */
 };
 
-struct fw_responder_element {
-       int (*callback)(void *, void*);
-       fw_module_inst *inst;
+/**
+ * @brief Internal structure to manage topic registrations.
+ *
+ * Components must register the used messages during runtime. Those
+ * registrations are managed by this data structure.
+ */
+struct fw_topic_registration {
+       unsigned int topic;             /**< The numerical representation of the topic. */
+       unsigned long uuid;             /**< An ID to avoid collisions. */
+       char *description;              /**< A short description of the topic. */
+       char *topic_struct;             /**< The structure used for topic messages */
+
+       int counter;                    /**< The number of components that registered this topic. */
+       int subscriptions;              /**< The number of subscriptions for that topic. */
+       int responder;                  /**< The number of responder for that topic. Currently at most 1 (one)! */
+       fw_component_inst *responder_inst;
+                                                       /**< The component instance to which this subscription belongs. */
+       int (*resonder_callback)(void *, void*);
+                                                       /**< Reference to the responder callback function. */
 };
 
-unsigned int fw_registered_topics[FW_MAX_TOPICS];
+/**
+ * The array of all resisted topics.
+ */
+static struct fw_topic_registration fw_registered_topics[FW_MAX_TOPICS];
 
-fw_list_head_t fw_topics[FW_MAX_TOPICS];
-struct fw_responder_element responders[FW_MAX_TOPICS];
+/**
+ * The list of all subscriptions.
+ */
+static fw_list_head_t fw_topics[FW_MAX_TOPICS];
 
-void fw_subscribe(unsigned int topic, void *callback, fw_module_inst *inst)
+void fw_subscribe(fw_topic_t topic, void *callback, fw_component_inst *inst)
 {
-       struct fw_topic_element *subscriber = fw_malloc(sizeof(struct fw_topic_element));
-
+       struct fw_subscription_element *subscriber = fw_malloc(sizeof(struct fw_subscription_element));
 
        subscriber->callback = callback;
        subscriber->inst = inst;
@@ -28,81 +69,128 @@ void fw_subscribe(unsigned int topic, void *callback, fw_module_inst *inst)
        fw_list_add_tail(&subscriber->list, &fw_topics[topic]);
 }
 
-void fw_notify(unsigned int topic, void *info)
+void fw_notify(fw_topic_t topic, void *info)
 {
-       struct fw_topic_element *iter;
-       fw_irq_flags flags = 0;
+       struct fw_subscription_element *iter;
 
-       //fw_local_irq_save(flags);
+       if (fw_registered_topics[topic].topic != topic) {
+               fw_error("Topic %x was not properly registered (%x!=%x).\n",
+                               topic, fw_registered_topics[topic].topic, topic);
+               return;
+       }
 
        fw_list_for_each_entry(iter, &fw_topics[topic], list) {
                ((void (*)(void *, void*))iter->callback)(iter->inst, info);
        }
-
-       //fw_local_irq_restore(flags);
 }
 
-int fw_register_topic(unsigned int topic)
+int fw_register_topic(fw_topic_t topic, unsigned long uuid, const char* name, const char* description, const char* topic_struct)
 {
+       char *mem_name;
+       char *mem_description;
+       char *mem_topic_struct;
+
        if (topic >= FW_MAX_TOPICS) {
                fw_panic("Error: Topic %d: Registration failed. Topic number is out of bounds.\n", topic);
                /* never reached */
        }
 
-       if (fw_registered_topics[topic]) {
-               fw_panic("Error: Topic %d: Registration failed. Topic number is already defined.\n", topic);
-               /* never reached */
+       if (fw_registered_topics[topic].uuid != 0) {
+               if (fw_registered_topics[topic].uuid != uuid) {
+                       fw_error("Topic %x: Registration failed for '%s'.  "
+                                        "Topic number is already defined for '%s'.\n",
+                                        topic, description, fw_registered_topics[topic].description);
+                       /* never reached */
+               }
+
+               fw_registered_topics[topic].counter++;
+               return fw_registered_topics[topic].counter;
+       }
+
+       mem_name = fw_malloc((strlen(name) + 1) * sizeof(char));
+       if (mem_name == NULL) {
+               fw_error("Topic registration OOM.\n");
+               return -1;
        }
+       strcpy(mem_name, name);
 
-       fw_registered_topics[topic] = topic;
+       mem_description = fw_malloc((strlen(description) + 1) * sizeof(char));
+       if (mem_description == NULL) {
+               fw_error("Topic registration OOM.\n");
+               fw_free(mem_name);
+               return -1;
+       }
+       strcpy(mem_description, description);
+
+       mem_topic_struct = fw_malloc((strlen(topic_struct) + 1) * sizeof(char));
+       if (mem_topic_struct == NULL) {
+               fw_error("Topic registration OOM.\n");
+               fw_free(mem_description);
+               fw_free(mem_name);
+               return -1;
+       }
+       strcpy(mem_topic_struct, topic_struct);
 
-       return topic;
+       fw_registered_topics[topic].topic = topic;
+       fw_registered_topics[topic].uuid = uuid;
+       fw_registered_topics[topic].counter = 1;
+       fw_registered_topics[topic].subscriptions = 0;
+       fw_registered_topics[topic].responder = 0;
+       fw_registered_topics[topic].description = mem_description;
+       fw_registered_topics[topic].topic_struct = mem_topic_struct;
+
+       return fw_registered_topics[topic].counter;
 }
 
-int fw_request(unsigned int topic, void *result)
+int fw_request(fw_topic_t topic, void *result)
 {
-       return responders[topic].callback ? responders[topic].callback(responders[topic].inst, result) : -0xFF;
+       return fw_registered_topics[topic].responder > 0 ?
+                  fw_registered_topics[topic].resonder_callback(fw_registered_topics[topic].responder_inst, result) :
+                  -0xFF;
 }
 
-void fw_register_responder(unsigned int topic, void *callback, fw_module_inst *inst)
+int fw_register_responder(fw_topic_t topic, void *callback, fw_component_inst *inst)
 {
-       if(responders[topic].callback != NULL){
-               fw_panic("Error: Responder for topic %d already registered.\n", topic);
-               /* never reached */
+       if(fw_registered_topics[topic].responder > 0){
+               fw_error("Responder for topic %d already registered.\n", topic);
+               return -1;
        }
 
-       responders[topic].callback = callback;
-       responders[topic].inst = inst;
+       fw_registered_topics[topic].responder = 1;
+       fw_registered_topics[topic].resonder_callback = callback;
+       fw_registered_topics[topic].responder_inst = inst;
+
+       return 0;
 }
 
-static inline void fw_comm_register_global(void)
+/**
+ * This function registers all topics that are available in CoBaS by default.
+ * It is invoked during the initialization of the communication subsystem.
+ */
+static void fw_comm_register_global(void)
 {
-       fw_register_topic(FW_FORK);
-       fw_register_topic(FW_ADMIT);
-       fw_register_topic(FW_RELEASE);
-       fw_register_topic(FW_DISPATCH);
-       fw_register_topic(FW_RELINQUISH);
-       fw_register_topic(FW_BLOCK);
-       fw_register_topic(FW_UNBLOCK);
-       fw_register_topic(FW_SUSPEND);
-       fw_register_topic(FW_ACTIVATE);
-       fw_register_topic(FW_BALANCE);
-       fw_register_topic(FW_CPU_ONLINE);
-       fw_register_topic(FW_AFFINITY);
+       FW_REGISTER_TOPIC(ADMIT);
+       FW_REGISTER_TOPIC(BLOCK);
+       FW_REGISTER_TOPIC(CPU_STATUS);
+       FW_REGISTER_TOPIC(RELEASE);
+       FW_REGISTER_TOPIC(RELINQUISH);
+       FW_REGISTER_TOPIC(UNBLOCK);
 }
 
 void fw_comm_init(void)
 {
        int i;
 
-
-       fw_comm_register_global();
-       fw_comm_register_generated();
-
        for(i=0; i<FW_MAX_TOPICS; i++) {
-               if (fw_registered_topics[i])
-                       FW_LIST_INIT(fw_topics[i]);
+               fw_registered_topics[i].topic = 0;
+               fw_registered_topics[i].uuid = 0;
+               fw_registered_topics[i].counter = 0;
+               fw_registered_topics[i].description = NULL;
+               fw_registered_topics[i].topic_struct = NULL;
 
-               responders[i].callback = NULL;
+               FW_LIST_INIT(fw_topics[i]);
        }
+
+       fw_comm_register_global();
+       fw_comm_register_generated();
 }
index 1815cb4..ae9cef2 100644 (file)
@@ -52,21 +52,21 @@ int fw_module_available(int uuid)
        return fw_modules_operations[uuid] != NULL;
 }
 
-fw_module_inst *fw_module_clone(fw_module_inst *other)
+fw_component_inst *fw_module_clone(fw_component_inst *other)
 {
-       fw_module_inst *inst;
+       fw_component_inst *inst;
 
        if(other == NULL) {
                return other;
        }
 
-       inst = fw_malloc(sizeof(fw_module_inst));
+       inst = fw_malloc(sizeof(fw_component_inst));
        if (inst == NULL) {
                fw_printf("Error: cloning module '%s (%d)' failed with OOM\n", other->name, other->uuid);
                return NULL;
        }
 
-       memcpy(inst, other, sizeof(fw_module_inst));
+       memcpy(inst, other, sizeof(fw_component_inst));
        inst->id = -1;
 
        return inst;
index 32bde34..0fd3087 100644 (file)
@@ -8,7 +8,7 @@
 #include <fw.h>
 #include <fw_pipe.h>
 
-static fw_module_inst fw_pipe_termination;
+static fw_component_inst fw_pipe_termination;
 
 fw_pipe_t *fw_pipe_alloc(void)
 {
@@ -44,17 +44,17 @@ void fw_pipe_free(fw_pipe_t *pipe)
        fw_free(pipe);
 }
 
-int fw_pipe_task_init(fw_module_inst *self, fw_task_t *task)
+int fw_pipe_task_init(fw_component_inst *self, fw_task_t *task)
 {
        return 0;
 }
 
-void fw_pipe_task_destroy(fw_module_inst *self, fw_task_t *task)
+void fw_pipe_task_destroy(fw_component_inst *self, fw_task_t *task)
 {
 
 }
 
-static void fw_pipe_termination_update(fw_module_inst *self, fw_pipe_t *pipe)
+static void fw_pipe_termination_update(fw_component_inst *self, fw_pipe_t *pipe)
 {
        fw_task_t *pos, *n;
 
index 263450f..414ad50 100644 (file)
@@ -6,17 +6,25 @@
 
 #include <fw.h>
 
+#include <topics/admit.h>
+#include <topics/block.h>
+#include <topics/release.h>
+#include <topics/relinquish.h>
+#include <topics/unblock.h>
+
 fw_pipe_t *fw_fw_ready_pipe;
 fw_pipe_t **fw_fw_dispatch_pipe;
 
-fw_module_inst **fw_fw_dispatch_inst;
+fw_component_inst **fw_fw_dispatch_inst;
 
 char fw_sched_buf[127] = {0};
 FW_SPINLOCK_CREATE(fw_lock);
 
-static void __fw_admit(fw_module_inst *self, fw_task_t *task)
+static void __fw_admit(fw_component_inst *self, fw_admit_msg_t *admit)
 {
-       FW_ASSERT_H(task != NULL, "Admitted task has to be specified!");
+       fw_task_t *task = admit->task;
+
+       FW_ASSERT_H(admit != NULL, "Admitted task has to be specified!");
 
 //     FW_DEBUG_PRINT("__fw_admit: %s state:%i (%p->%p) on CPU(%i)\n", FW_TASK_NAME(task), task->state, task, task->real_task, FW_CPU_ID());
 
@@ -34,8 +42,10 @@ static void __fw_admit(fw_module_inst *self, fw_task_t *task)
        fw_fw_ready_pipe->out->ops.pipe_update(fw_fw_ready_pipe->out, fw_fw_ready_pipe);
 }
 
-static void __fw_release(fw_module_inst *self, fw_task_t *task)
+static void __fw_release(fw_component_inst *self, fw_release_msg_t *release)
 {
+       fw_task_t *task = release->task;
+
        FW_ASSERT_H(task != NULL, "Released task has to be specified!");
 
 //     FW_DEBUG_PRINT("__fw_release: %s on CPU(%i) state:%i (%p->%p)\n", FW_TASK_NAME(task), FW_CPU_ID(), task->state, task, task->real_task);
@@ -67,8 +77,10 @@ void __fw_schedule(int cpu)
        os_dispatch(next_task);
 }
 
-static void __fw_relinquish(fw_module_inst *self, fw_task_t *task)
+static void __fw_relinquish(fw_component_inst *self, fw_relinquish_msg_t *relinquish)
 {
+       fw_task_t *task = relinquish->task;
+
        FW_ASSERT_H(task != NULL, "Relinquished task has to be specified!");
 //     FW_DEBUG_PRINT("__fw_relinquish: %s on CPU(%i) state:%i (%p->%p)\n", FW_TASK_NAME(task), FW_CPU_ID(), task->state, task, task->real_task);
 
@@ -87,8 +99,10 @@ static void __fw_relinquish(fw_module_inst *self, fw_task_t *task)
        fw_fw_ready_pipe->out->ops.pipe_update(fw_fw_ready_pipe->out, fw_fw_ready_pipe);
 }
 
-static void __fw_block(fw_module_inst *self, fw_task_t *task)
+static void __fw_block(fw_component_inst *self, fw_block_msg_t *block)
 {
+       fw_task_t *task = block->task;
+
        FW_ASSERT_H(task != NULL, "Blocked task has to be specified!");
 //     FW_DEBUG_PRINT("__fw_block: %s on CPU(%i) state:%i (%p->%p)\n", FW_TASK_NAME(task), FW_CPU_ID(), task->state, task, task->real_task);
 
@@ -97,8 +111,10 @@ static void __fw_block(fw_module_inst *self, fw_task_t *task)
        task->state = FW_BLOCKED;
 }
 
-static void __fw_unblock(fw_module_inst *self, fw_task_t *task)
+static void __fw_unblock(fw_component_inst *self, fw_unblock_msg_t *unblock)
 {
+       fw_task_t *task = unblock->task;
+
        FW_ASSERT_H(task != NULL, "Unblocked task has to be specified!");
 //     FW_DEBUG_PRINT("__fw_unblock: %s on CPU(%i) state:%i (%p->%p)\n", FW_TASK_NAME(task), FW_CPU_ID(), task->state, task, task->real_task);
 
@@ -120,11 +136,11 @@ void fw_sched_init(void)
 {
        fw_fw_ready_pipe = fw_pipe_alloc();
 
-       fw_subscribe(FW_ADMIT, __fw_admit, NULL);
-       fw_subscribe(FW_RELINQUISH, __fw_relinquish, NULL);
-       fw_subscribe(FW_UNBLOCK, __fw_unblock, NULL);
-       fw_subscribe(FW_BLOCK, __fw_block, NULL);
-       fw_subscribe(FW_RELEASE, __fw_release, NULL);
+       fw_subscribe(FW_TOPIC_ADMIT, __fw_admit, NULL);
+       fw_subscribe(FW_TOPIC_RELINQUISH, __fw_relinquish, NULL);
+       fw_subscribe(FW_TOPIC_UNBLOCK, __fw_unblock, NULL);
+       fw_subscribe(FW_TOPIC_BLOCK, __fw_block, NULL);
+       fw_subscribe(FW_TOPIC_RELEASE, __fw_release, NULL);
 }
 
 struct fw_task* fw_current_task(int cpu)
index 4ce4711..dd22848 100644 (file)
@@ -3,16 +3,18 @@
 
 #include <fw.h>
 
+#include <topics/affinity.h>
+
 #define AF_COMPONENT_NAME      "CPU Affinity Component"
 #define AF_COMPONENT_UUID      0x0D
 
-fw_module_inst af_proto;
+fw_component_inst af_proto;
 
 struct af_pcb {
        fw_cpumask_t    cpus_allowed;
 };
 
-static void af_task_init(fw_module_inst *self, fw_task_t *task)
+static void af_task_init(fw_component_inst *self, fw_task_t *task)
 {
        struct af_pcb *pcb = fw_malloc(sizeof(struct af_pcb));
 
@@ -20,12 +22,12 @@ static void af_task_init(fw_module_inst *self, fw_task_t *task)
        fw_cpumask_setall(&pcb->cpus_allowed);
 }
 
-static void af_task_destroy(fw_module_inst *self, fw_task_t *task)
+static void af_task_destroy(fw_component_inst *self, fw_task_t *task)
 {
        fw_free(task->component_pcb[self->id]);
 }
 
-static void af_set_affinity(fw_module_inst *self, fw_affinity_msg_t *affinity)
+static void af_set_affinity(fw_component_inst *self, fw_affinity_msg_t *affinity)
 {
        struct af_pcb *pcb = affinity->task->component_pcb[self->id];
        pcb->cpus_allowed = affinity->mask;
@@ -33,7 +35,7 @@ static void af_set_affinity(fw_module_inst *self, fw_affinity_msg_t *affinity)
 //     fw_printf("set affinity for %d to %d\n", FW_TASK_ID(affinity->task), affinity->mask);
 }
 
-static void af_get_affinity(fw_module_inst *self, fw_affinity_msg_t *affinity)
+static void af_get_affinity(fw_component_inst *self, fw_affinity_msg_t *affinity)
 {
        struct af_pcb *pcb = affinity->task->component_pcb[self->id];
        affinity->mask = pcb->cpus_allowed;
@@ -50,10 +52,10 @@ static void af_get_affinity(fw_module_inst *self, fw_affinity_msg_t *affinity)
  * @param links   The number of links of the new instance.
  * @return An instance of this component.
  */
-static fw_module_inst *af_new(inst_uuid_t inst_id, int link_count, fw_pipe_t **links)
+static fw_component_inst *af_new(inst_uuid_t inst_id, int link_count, fw_pipe_t **links)
 {
        // the newly created instance
-       fw_module_inst *inst;
+       fw_component_inst *inst;
 
        // creates a new instance from an template
        inst = fw_module_clone(&af_proto);
@@ -69,8 +71,8 @@ static fw_module_inst *af_new(inst_uuid_t inst_id, int link_count, fw_pipe_t **l
                /* never reached */
        }
 
-       fw_subscribe(FW_AFFINITY, af_set_affinity, inst);
-       fw_register_responder(FW_AFFINITY, af_get_affinity, inst);
+       fw_subscribe(FW_TOPIC_AFFINITY, af_set_affinity, inst);
+       fw_register_responder(FW_TOPIC_AFFINITY, af_get_affinity, inst);
 
        return inst;
 }
@@ -80,7 +82,7 @@ static fw_module_inst *af_new(inst_uuid_t inst_id, int link_count, fw_pipe_t **l
  *
  * @param self The comonent instance.
  */
-static void af_destroy(fw_module_inst *self)
+static void af_destroy(fw_component_inst *self)
 {
        fw_free(self->inst_data);
        fw_free(self);
@@ -94,7 +96,7 @@ fw_module_operations_t af_ops = {
        .task_init      = af_task_init,
 };
 
-fw_module_inst af_proto = {
+fw_component_inst af_proto = {
        .uuid   = AF_COMPONENT_UUID,
        .name   = AF_COMPONENT_NAME,
        .id             = -1,
@@ -107,6 +109,8 @@ fw_module_inst af_proto = {
 
 int af_init(void)
 {
+       FW_REGISTER_TOPIC(AFFINITY);
+
        return fw_modules_register(AF_COMPONENT_UUID, AF_COMPONENT_NAME, &af_ops);
 }
 
index 554c3c8..f049066 100644 (file)
@@ -10,7 +10,7 @@ int fcfs_init(void);
 #define FCFS_MODULE_NAME       "First Come First Served Component"
 #define FCFS_MODULE_UUID       0x03
 
-static fw_module_inst fcfs_proto;
+static fw_component_inst fcfs_proto;
 
 typedef struct fcfs_private_data {
        int inst_id;
@@ -27,7 +27,7 @@ typedef struct fcfs_pcb {
 } fcfs_pcb_t;
 
 
-static void fcfs_task_init(fw_module_inst *self, fw_task_t *task)
+static void fcfs_task_init(fw_component_inst *self, fw_task_t *task)
 {
        int time;
        fcfs_pcb_t *pcb = fw_malloc(sizeof(fcfs_pcb_t));
@@ -41,12 +41,12 @@ static void fcfs_task_init(fw_module_inst *self, fw_task_t *task)
        pcb->lamport = time;
 }
 
-static void fcfs_task_destroy(fw_module_inst *self, fw_task_t *task)
+static void fcfs_task_destroy(fw_component_inst *self, fw_task_t *task)
 {
        fw_free(task->component_pcb[self->id]);
 }
 
-static void fcfs_pipe_update(fw_module_inst *self, fw_pipe_t *pipe)
+static void fcfs_pipe_update(fw_component_inst *self, fw_pipe_t *pipe)
 {
        fw_task_t *pos, *iter, *n;
        fcfs_pcb_t *tmp1, *tmp2;
@@ -83,9 +83,9 @@ static void fcfs_pipe_update(fw_module_inst *self, fw_pipe_t *pipe)
        pd->out_pipe->out->ops.pipe_update(pd->out_pipe->out, pd->out_pipe);
 }
 
-static fw_module_inst *fcfs_new(inst_uuid_t inst_id, int link_count, fw_pipe_t **links)
+static fw_component_inst *fcfs_new(inst_uuid_t inst_id, int link_count, fw_pipe_t **links)
 {
-       fw_module_inst *inst;
+       fw_component_inst *inst;
        struct fcfs_private_data *pd;
 
        inst = fw_module_clone(&fcfs_proto);
@@ -121,12 +121,12 @@ static fw_module_inst *fcfs_new(inst_uuid_t inst_id, int link_count, fw_pipe_t *
        return inst;
 }
 
-static void fcfs_destroy(fw_module_inst *self)
+static void fcfs_destroy(fw_component_inst *self)
 {
 
 }
 
-static fw_module_inst fcfs_proto = {
+static fw_component_inst fcfs_proto = {
        .uuid = FCFS_MODULE_UUID,
        .name = FCFS_MODULE_NAME,
        .id = -1,
diff --git a/framework/modules/include/topics/affinity.h b/framework/modules/include/topics/affinity.h
new file mode 100644 (file)
index 0000000..6ab8890
--- /dev/null
@@ -0,0 +1,24 @@
+#ifndef TOPIC_AFFINITY_H_
+#define TOPIC_AFFINITY_H_
+
+#include <os.h>        // this is only here because we use os cpumask
+
+#define FW_TOPIC_AFFINITY      16
+#define FW_TUUID_AFFINITY      468608183
+#define FW_TNAME_AFFINITY      "AFFINITY"
+#define FW_TDESC_AFFINITY      "Task Affinities"
+
+#define FW_TSTRUCT_AFFINITY            \
+"typedef struct fw_affinity_msg {\n\
+       fw_task_t *task;\n\
+       fw_cpumask_t mask;\n\
+} fw_affinity_msg_t;\n"
+
+typedef struct fw_task fw_task_t;
+
+typedef struct fw_affinity_msg {
+       fw_task_t *task;
+       fw_cpumask_t mask;
+} fw_affinity_msg_t;
+
+#endif /* TOPIC_AFFINITY_H_ */
index 9c994e5..d3104fe 100644 (file)
@@ -7,7 +7,8 @@
 
 #include <fw.h>
 
-
+#include <topics/affinity.h>
+#include <topics/cpu_status.h>
 
 #define LB_MODULE_NAME "Load Balancer"
 #define LB_MODULE_UUID         0x02
@@ -18,7 +19,7 @@
 
 FW_SPINLOCK_CREATE(lb_lock);
 
-static fw_module_inst lb_proto;
+static fw_component_inst lb_proto;
 
 struct lb_pool_entry {
        struct lb_pool_entry *next;
@@ -47,7 +48,7 @@ typedef struct lb_pcb {
 
 static fw_affinity_msg_t affinity_req;
 
-static void lb_task_init(fw_module_inst *self, fw_task_t *task)
+static void lb_task_init(fw_component_inst *self, fw_task_t *task)
 {
        lb_pcb_t *pcb = fw_malloc(sizeof(struct lb_pcb));
        pcb->pipe = NULL;
@@ -55,12 +56,12 @@ static void lb_task_init(fw_module_inst *self, fw_task_t *task)
        task->component_pcb[self->id] = pcb;
 }
 
-static void lb_task_destroy(fw_module_inst *self, fw_task_t *task)
+static void lb_task_destroy(fw_component_inst *self, fw_task_t *task)
 {
        fw_free(task->component_pcb[self->id]);
 }
 
-static void lb_pipe_update(fw_module_inst *self, fw_pipe_t *pipe)
+static void lb_pipe_update(fw_component_inst *self, fw_pipe_t *pipe)
 {
        fw_task_t *pos, *n;
        static int next_cpu = -1;
@@ -72,7 +73,7 @@ static void lb_pipe_update(fw_module_inst *self, fw_pipe_t *pipe)
 
        fw_list_for_each_entry_safe(pos,n,(&pipe->tasks_added),pipe_pcb[pipe->id].added) {
                affinity_req.task = pos;
-               fw_request(FW_AFFINITY,&affinity_req);
+               fw_request(FW_TOPIC_AFFINITY,&affinity_req);
                next_cpu = fw_cpumask_next_and(-1,&affinity_req.mask,&pd->pe_online);
                if(next_cpu >= pd->size){
                        //fw_printf("task %s left in queue because %ld not satisfiable\n", OS_TASK_NAME(pos), affinity_req.mask.bits[0]);
@@ -105,22 +106,25 @@ static void lb_pipe_update(fw_module_inst *self, fw_pipe_t *pipe)
                pd->out_pipe[i]->out->ops.pipe_update(pd->out_pipe[i]->out, pd->out_pipe[i]);
 }
 
-static void lb_cpu_online(fw_module_inst *self, unsigned int *pe)
+static void lb_cpu_online(fw_component_inst *self, fw_cpu_status_msg_t *msg)
 {
        lb_private_data_t *pd = inst_data(lb_private_data_t);
 
+       if(msg->status != ONLINE)
+               return;
+
        fw_spinlock(&pd->lock);
 
-       fw_printf("PE %d went online\n", *pe);
-       cpumask_set_cpu(*pe, &pd->pe_online);
+       fw_printf("PE %d went online\n", msg->cpu);
+       cpumask_set_cpu(msg->cpu, &pd->pe_online);
        fw_printf("New online map is 0x%lx", pd->pe_online.bits[0]);
 
        fw_spinunlock(&pd->lock);
 }
 
-static fw_module_inst *lb_new(inst_uuid_t inst_id, int link_count, fw_pipe_t **links)
+static fw_component_inst *lb_new(inst_uuid_t inst_id, int link_count, fw_pipe_t **links)
 {
-       fw_module_inst *inst;
+       fw_component_inst *inst;
        struct lb_private_data *pd;
        int i;
 
@@ -155,19 +159,19 @@ static fw_module_inst *lb_new(inst_uuid_t inst_id, int link_count, fw_pipe_t **l
        pd->pe_online.bits[0] = 1UL;
        pd->size = link_count-1;
 
-       fw_subscribe(FW_CPU_ONLINE, lb_cpu_online, inst);
+       fw_subscribe(FW_TOPIC_CPU_STATUS, lb_cpu_online, inst);
 
        return inst;
 }
 
 
 
-static void lb_destroy(fw_module_inst *self)
+static void lb_destroy(fw_component_inst *self)
 {
 
 }
 
-static fw_module_inst lb_proto = {
+static fw_component_inst lb_proto = {
        .uuid = LB_MODULE_UUID,
        .name = LB_MODULE_NAME,
        .id = -1,
diff --git a/framework/modules/load_balance_old.c b/framework/modules/load_balance_old.c
deleted file mode 100644 (file)
index 1da0e3a..0000000
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * load_balance.c
- *
- *  Created on: 08.04.2014
- *      Author: jkrieg
- */
-
-#include <fw.h>
-#include <generated/topo_rr_quad.h>
-
-
-
-int lb_init(void);
-int lb_new(int inst_id, int links, ...);
-
-#define LB_MODULE_NAME "Load Balancer"
-#define LB_MODULE_UUID         0x02
-
-
-FW_SPINLOCK_CREATE(lb_lock);
-
-struct lb_private_data {
-       fw_list_t *tasklist_in;
-       fw_list_t *tasklist_out[FW_NR_CPUS];
-       int inst_id;
-};
-
-
-static void lb_admit(struct fw_task *task, struct lb_private_data *pd)
-{
-       fw_list_elem_t *new_entry;
-       fw_irq_flags flags;
-       int i = 0;
-
-
-       FW_ASSERT(task != NULL);
-
-       new_entry = fw_malloc((fw_size_t) sizeof(fw_list_elem_t));
-       FW_ASSERT(new_entry != NULL);
-
-       new_entry->task = task;
-       task->module_data[LB_MODULE_UUID] = new_entry;
-
-//     fw_spinlock_irqsave(&lb_lock, &flags);
-       fw_list_add_tail(new_entry, pd->tasklist_out[i++%FW_NR_CPUS]);
-//     fw_spinunlock_irqrestore(&lb_lock, &flags);
-}
-
-static void lb_release(struct fw_task *task, struct lb_private_data *pd)
-{
-       FW_ASSERT(task != NULL);
-
-       fw_free(task->module_data[LB_MODULE_UUID]);
-}
-
-static void lb_dispatch(void *info, struct lb_private_data *pd)
-{
-       struct fw_list_elem *new_entry;
-       fw_irq_flags flags;
-
-
-       if (!fw_list_empty(pd->tasklist_in)) {
-//             fw_spinlock_irqsave(&lb_lock, &flags);
-               new_entry = fw_list_entry(pd->tasklist_in)->module_data[LB_MODULE_UUID];
-//             new_entry = fw_list_entry(fw_fw_schedule_in[0]->head->next)->module_data[LB_MODULE_UUID];
-               fw_list_remove(new_entry,pd->tasklist_in);
-//             fw_spinunlock_irqrestore(&lb_lock, &flags);
-       }
-}
-
-static void lb_enqueue(struct fw_task *task, struct lb_private_data *pd)
-{
-       fw_list_elem_t *new_entry;
-       fw_irq_flags flags;
-
-
-       FW_ASSERT(task != NULL);
-
-       new_entry = task->module_data[LB_MODULE_UUID];
-
-       /* Bootstrap process exception */
-       if (!new_entry) {
-               new_entry = fw_malloc((fw_size_t) sizeof(fw_list_elem_t));
-               FW_ASSERT(new_entry != NULL);
-
-               new_entry->task = task;
-               task->module_data[LB_MODULE_UUID] = new_entry;
-       }
-
-       fw_spinlock_irqsave(&lb_lock, &flags);
-       fw_list_add_tail(new_entry, pd->tasklist_out[0]);
-       fw_spinunlock_irqrestore(&lb_lock, &flags);
-}
-
-//static void lb_divider(struct fw_task *task, struct lb_private_data *pd)
-//{
-//     struct fw_task_list *new_entry;
-//     fw_irq_flags flags;
-//     int i = 0;
-//
-//
-//     new_entry = fw_malloc((fw_size_t) sizeof(struct fw_task_list));
-//     FW_ASSERT(new_entry != NULL);
-////   task = fw_list_entry(pd->tasklist_in->next, struct fw_task_list, list)->task;
-//     new_entry->task = task;
-//     task->module_data[LB_MODULE_UUID] = new_entry;
-//
-//     fw_spinlock_irqsave(&lb_lock, &flags);
-//     fw_list_add_tail(&new_entry->list, pd->tasklist_out[i++%FW_NR_CPUS]);
-//     fw_spinunlock_irqrestore(&lb_lock, &flags);
-//}
-
-int lb_new(int inst_id, int links, ...)
-{
-       struct lb_private_data *pd;
-       va_list ap;
-
-
-       if (links != 2) {
-               fw_printf("Error: Module %s: Wrong number of links (%d instead of 2)\n", LB_MODULE_NAME, links);
-               return -1;
-       }
-
-       if (!(pd = fw_malloc((fw_size_t) sizeof(struct lb_private_data)))) {
-               fw_printf("Error: Module %s: Memory allocation for private data failed\n", LB_MODULE_NAME);
-               return -1;
-       }
-
-       pd->inst_id = inst_id;
-
-//     if (!(pd->messenger = fw_malloc((fw_size_t) sizeof(struct fw_task_list)))) {
-//             fw_printf("Error: Module %s: Memory allocation for list messanger failed\n", LB_MODULE_NAME);
-//             return -1;
-//     }
-
-       va_start(ap, links);
-       pd->tasklist_in = va_arg(ap, fw_list_t *);
-       pd->tasklist_out[0] = va_arg(ap, fw_list_t *);
-//     pd->tasklist_out[1] = va_arg(ap, fw_list_t *);
-//     pd->tasklist_out[2] = va_arg(ap, fw_list_t *);
-//     pd->tasklist_out[3] = va_arg(ap, fw_list_t *);
-       va_end(ap);
-
-       fw_subscribe(FW_ADMIT, &lb_admit, pd);
-       fw_subscribe(FW_RELEASE, &lb_release, pd);
-       fw_subscribe(FW_DISPATCH, &lb_dispatch, pd);
-       fw_subscribe(FW_RELINQUISH, &lb_enqueue, pd);
-       fw_subscribe(FW_UNBLOCK, &lb_enqueue, pd);
-
-       return 0;
-}
-
-fw_module_operations_t lb_ops = {
-       ._new = lb_new,
-};
-
-int lb_init(void)
-{
-       return fw_modules_register(LB_MODULE_UUID, LB_MODULE_NAME, &lb_ops);
-}
-
-fw_module_init(lb_init);
diff --git a/framework/modules/load_balance_old2.c b/framework/modules/load_balance_old2.c
deleted file mode 100644 (file)
index 6df4983..0000000
+++ /dev/null
@@ -1,290 +0,0 @@
-/*
- * load_balance.c
- *
- *  Created on: 08.04.2014
- *      Author: jkrieg
- */
-
-#include <fw.h>
-
-
-
-#define LB_MODULE_NAME "Load Balancer"
-#define LB_MODULE_UUID         0x02
-
-#define LB_BALANCE_SLICE 32
-
-#define LB_CPU_VALID(cpu) (cpu >= 0 && cpu < FW_NR_CPUS)
-
-FW_SPINLOCK_CREATE(lb_lock);
-
-struct lb_pool_entry {
-       struct lb_pool_entry *next;
-       fw_tlist_elem_t elem;
-};
-
-struct lb_load {
-       int tlist_length;
-       int tlist_balanced;
-};
-
-struct lb_private_data {
-       fw_tlist_t *tasklist_in;
-       fw_tlist_t *tasklist_out[FW_NR_CPUS];
-       int inst_id;
-
-       struct lb_pool_entry pool[FW_NR_CPUS];
-
-       struct lb_load load[FW_NR_CPUS];
-       long balance_slice;
-};
-
-
-int lb_init(void);
-int lb_new(int inst_id, int links, ...);
-
-#ifdef FW_SMP
-static int lb_get_highest(struct lb_load *load);
-static int lb_get_lowest(struct lb_load *load);
-
-
-
-static int lb_get_highest(struct lb_load *load)
-{
-       int hload = 0;
-       int cpu = -1;
-       int i;
-
-
-       for (i=0; i<FW_NR_CPUS; i++) {
-               if (load[i].tlist_balanced)
-                       continue;
-
-               if (load[i].tlist_length > hload) {
-                       hload = load[i].tlist_length;
-                       cpu = i;
-               }
-       }
-
-       return cpu;
-}
-
-static int lb_get_lowest(struct lb_load *load)
-{
-       int lload = 1000000;
-       int cpu = -1;
-       int i;
-
-
-       for (i=0; i<FW_NR_CPUS; i++) {
-               if (load[i].tlist_balanced)
-                       continue;
-
-               if (load[i].tlist_length < lload) {
-                       lload = load[i].tlist_length;
-                       cpu = i;
-               }
-       }
-
-       return cpu;
-}
-
-static void lb_pull_migration(struct lb_private_data *pd, int from, int to)
-{
-       fw_tlist_elem_t *tmp;
-       fw_irq_flags flags;
-
-
-       fw_spinlock_irqsave(&pd->tasklist_out[from]->lock, &flags);
-       fw_spinlock(&pd->tasklist_out[to]->lock);
-
-       fw_tlist_for_each_entry(tmp, pd->tasklist_out[from]) {
-               /* Check if thread is allowed to run on the given CPU.*/
-               if ((!FW_CPU_ISSET(tmp->task, to)) || tmp->task->state == FW_RUNNING)
-                       continue;
-
-               fw_tlist_remove(tmp, pd->tasklist_out[from]);
-               fw_set_task_cpu(tmp->task, to);
-               fw_tlist_add_tail(tmp, pd->tasklist_out[to]);
-
-               pd->load[from].tlist_length--;
-               pd->load[to].tlist_length++;
-
-               fw_spinunlock(&pd->tasklist_out[to]->lock);
-               fw_spinunlock_irqrestore(&pd->tasklist_out[from]->lock, &flags);
-
-               return;
-       }
-
-       pd->load[from].tlist_balanced = 1;
-
-       fw_spinunlock(&pd->tasklist_out[to]->lock);
-       fw_spinunlock_irqrestore(&pd->tasklist_out[from]->lock, &flags);
-}
-
-static int lb_balance_pair(struct lb_private_data *pd, int from, int to)
-{
-       int tasks_migrated = 0;
-
-
-       while ((pd->load[from].tlist_length > (pd->load[to].tlist_length + 1)) &&
-                       !pd->load[from].tlist_balanced) {
-               lb_pull_migration(pd, from, to);
-
-               tasks_migrated++;
-
-               if (to != FW_CPU_ID())
-                       fw_send_ipi(to);
-       }
-
-       return tasks_migrated;
-}
-
-static void lb_tick(void *info, struct lb_private_data *pd)
-{
-       (void) info;
-
-
-       if (pd->inst_id != FW_CPU_ID()) {
-               return;
-       }
-
-       if (FW_SMP_STARTED == 0)
-               return;
-
-       if (--pd->balance_slice <= 0)
-               fw_notify(FW_BALANCE, NULL);
-}
-
-static void lb_balance(void *info, struct lb_private_data *pd)
-{
-       (void) info;
-       int from, to;
-
-
-       pd->balance_slice = LB_BALANCE_SLICE;
-
-       for (;;) {
-               from = lb_get_highest(pd->load);
-               to = lb_get_lowest(pd->load);
-
-               if (!LB_CPU_VALID(from) || !LB_CPU_VALID(to))
-                       break;
-
-               if(!lb_balance_pair(pd, from, to))
-                       break;
-       }
-//     fw_printf("load0:%d | load1:%d | load2:%d | load3:%d \n",pd->load[0].tlist_length,pd->load[1].tlist_length,pd->load[2].tlist_length,pd->load[3].tlist_length);
-}
-#endif
-
-static struct lb_pool_entry* lb_get_entry(struct lb_pool_entry *last)
-{
-       struct lb_pool_entry *ret = NULL;
-
-
-       FW_ASSERT_H(last != NULL, "Need seed for pool!");
-
-       ret = last->next;
-
-       if (ret == NULL) {
-               last->next = ret = fw_malloc((fw_size_t) sizeof(struct lb_pool_entry));
-               ret->next = NULL;
-               FW_ASSERT_H(ret != NULL, "Out of Memory!");
-       }
-
-       return ret;
-}
-
-static void lb_schedule(void *info, struct lb_private_data *pd)
-{
-       struct lb_pool_entry *entry;
-       fw_tlist_elem_t *tmp;
-       struct fw_task *task;
-       fw_irq_flags flags;
-       int cpu;
-
-
-       cpu = FW_CPU_ID();
-       entry = &pd->pool[cpu];
-
-       fw_spinlock_irqsave(&pd->tasklist_out[cpu]->lock, &flags);
-       fw_spinlock(&pd->tasklist_in->lock);
-
-       /* Reset task list and balance information */
-       fw_tlist_init(pd->tasklist_out[cpu]);
-       pd->load[cpu].tlist_length = 0;
-       pd->load[cpu].tlist_balanced = 0;
-
-//     FW_ASSERT_H(&pd->tasklist_out[cpu]->lock, "lb_schedule: tasklist->out lock not set!");
-
-       /* Add only task to task list which are suppose to run on this CPU. */
-       fw_tlist_for_each_entry(tmp, pd->tasklist_in) {
-               task = tmp->task;
-
-               if (task->state == FW_RUNNING)
-                       continue;
-
-               if (task->cpu == cpu) {
-                       entry = lb_get_entry(entry);
-                       entry->elem.task = task;
-
-                       fw_tlist_add_tail(&entry->elem, pd->tasklist_out[cpu]);
-
-                       pd->load[cpu].tlist_length++;
-               }
-       }
-
-       fw_spinunlock(&pd->tasklist_in->lock);
-       fw_spinunlock_irqrestore(&pd->tasklist_out[cpu]->lock, &flags);
-}
-
-int lb_new(int inst_id, int links, ...)
-{
-       struct lb_private_data *pd;
-       va_list ap;
-       int i;
-
-
-       if (links != (FW_NR_CPUS+1)) {
-               fw_printf("Error: Module %s: Wrong number of links (%d instead of %d)\n", LB_MODULE_NAME, links, (FW_NR_CPUS+1));
-               return -1;
-       }
-
-       if (!(pd = fw_malloc((fw_size_t) sizeof(struct lb_private_data)))) {
-               fw_printf("Error: Module %s: Memory allocation for private data failed\n", LB_MODULE_NAME);
-               return -1;
-       }
-
-       pd->inst_id = inst_id;
-       for (i=0; i<FW_NR_CPUS; i++) {
-               pd->pool[i].next = NULL;
-       }
-
-       va_start(ap, links);
-       pd->tasklist_in = va_arg(ap, fw_tlist_t *);
-       for (i=0; i<FW_NR_CPUS; i++) {
-               pd->tasklist_out[i] = va_arg(ap, fw_tlist_t *);
-       }
-       va_end(ap);
-
-#ifdef FW_SMP
-       fw_subscribe(FW_TICK, &lb_tick, pd);
-       fw_subscribe(FW_BALANCE, &lb_balance, pd);
-#endif
-
-       fw_subscribe(FW_SCHEDULE, &lb_schedule, pd);
-
-       return 0;
-}
-
-fw_module_operations_t lb_ops = {
-       ._new = lb_new,
-};
-
-int lb_init(void)
-{
-       return fw_modules_register(LB_MODULE_UUID, LB_MODULE_NAME, &lb_ops);
-}
-
-fw_module_init(lb_init);
index 6354cd0..eeafeb9 100644 (file)
@@ -10,7 +10,7 @@ int rr_init(void);
 #define RR_MODULE_NAME         "Round Robin"
 #define RR_MODULE_UUID         0x01
 
-static fw_module_inst rr_proto;
+static fw_component_inst rr_proto;
 
 typedef struct rr_private_data {
        int inst_id;
@@ -20,17 +20,17 @@ typedef struct rr_private_data {
 } rr_private_data_t;
 
 
-static void rr_task_init(fw_module_inst *self, fw_task_t *task)
+static void rr_task_init(fw_component_inst *self, fw_task_t *task)
 {
 
 }
 
-static void rr_task_destroy(fw_module_inst *self, fw_task_t *task)
+static void rr_task_destroy(fw_component_inst *self, fw_task_t *task)
 {
 
 }
 
-static void rr_pipe_update(fw_module_inst *self, fw_pipe_t *pipe)
+static void rr_pipe_update(fw_component_inst *self, fw_pipe_t *pipe)
 {
        fw_task_t *pos, *n;
        rr_private_data_t *pd = inst_data(rr_private_data_t);
@@ -56,9 +56,9 @@ static void rr_pipe_update(fw_module_inst *self, fw_pipe_t *pipe)
        pd->out_pipe->out->ops.pipe_update(pd->out_pipe->out, pd->out_pipe);
 }
 
-static fw_module_inst *rr_new(inst_uuid_t inst_id, int link_count, fw_pipe_t **links)
+static fw_component_inst *rr_new(inst_uuid_t inst_id, int link_count, fw_pipe_t **links)
 {
-       fw_module_inst *inst;
+       fw_component_inst *inst;
        struct rr_private_data *pd;
 
        inst = fw_module_clone(&rr_proto);
@@ -92,12 +92,12 @@ static fw_module_inst *rr_new(inst_uuid_t inst_id, int link_count, fw_pipe_t **l
        return inst;
 }
 
-static void rr_destroy(fw_module_inst *self)
+static void rr_destroy(fw_component_inst *self)
 {
 
 }
 
-static fw_module_inst rr_proto = {
+static fw_component_inst rr_proto = {
        .uuid = RR_MODULE_UUID,
        .name = RR_MODULE_NAME,
        .id = -1,
index 965beb1..6949151 100644 (file)
@@ -6,7 +6,7 @@
 #define TMPL_COMPONENT_NAME    "Template Module"
 #define TMPL_COMPONENT_UUID    0x0F
 
-fw_module_inst tmpl_proto;
+fw_component_inst tmpl_proto;
 
 struct tmpl_private_data {
        int inst_id;
@@ -24,7 +24,7 @@ struct tmpl_private_data {
  * @param self The current instance of this component.
  * @param cpu  The CPU number the schedul request was issued for.
  */
-static void tmpl_schedule(fw_module_inst *self, int cpu)
+static void tmpl_schedule(fw_component_inst *self, int cpu)
 {
        struct tmpl_private_data *pd = inst_data(struct tmpl_private_data);
 
@@ -44,7 +44,7 @@ static void tmpl_schedule(fw_module_inst *self, int cpu)
  * @param cpu  The CPU number the task got dispatched to.
  * @param next The dispatched task
  */
-static void tmpl_dispatch(fw_module_inst *self, int cpu, fw_task_t *next)
+static void tmpl_dispatch(fw_component_inst *self, int cpu, fw_task_t *next)
 {
        struct tmpl_private_data *pd = inst_data(struct tmpl_private_data);
 
@@ -64,10 +64,10 @@ static void tmpl_dispatch(fw_module_inst *self, int cpu, fw_task_t *next)
  * @param links   The number of links of the new instance.
  * @return An instance of this component.
  */
-static fw_module_inst *tmpl_new(inst_uuid_t inst_id, int links, ...)
+static fw_component_inst *tmpl_new(inst_uuid_t inst_id, int links, ...)
 {
        // the newly created instance
-       fw_module_inst *inst;
+       fw_component_inst *inst;
        // private data for the new instance
        struct tmpl_private_data *pd;
 
@@ -100,7 +100,7 @@ static fw_module_inst *tmpl_new(inst_uuid_t inst_id, int links, ...)
  *
  * @param self The comonent instance.
  */
-static void tmpl_destroy(fw_module_inst *self)
+static void tmpl_destroy(fw_component_inst *self)
 {
        fw_free(self->inst_data);
        fw_free(self);
@@ -113,7 +113,7 @@ fw_module_operations_t tmpl_ops = {
        .dispatch       = tmpl_dispatch,
 };
 
-fw_module_inst tmpl_proto = {
+fw_component_inst tmpl_proto = {
        .uuid   = TMPL_COMPONENT_UUID,
        .name   = TMPL_COMPONENT_NAME,
        .id             = -1,
index 896c812..5f96d93 100644 (file)
@@ -1,5 +1,12 @@
 #include <fw.h>
 
+#include <topics/admit.h>
+#include <topics/affinity.h>
+#include <topics/block.h>
+#include <topics/release.h>
+#include <topics/relinquish.h>
+#include <topics/unblock.h>
+
 unsigned int smp_started;
 
 /*
@@ -561,7 +568,7 @@ long sched_getaffinity(pid_t pid, struct cpumask *mask)
 
        raw_spin_lock_irqsave(&p->pi_lock, flags);
        msg.task = &p->fw_task;
-       fw_request(FW_AFFINITY,&msg);
+       fw_request(FW_TOPIC_AFFINITY,&msg);
        read_mask.bits[0] = msg.mask.bits[0];
        cpumask_and(mask, &read_mask, cpu_online_mask);
        raw_spin_unlock_irqrestore(&p->pi_lock, flags);
@@ -637,7 +644,7 @@ long sched_setaffinity(pid_t pid, const struct cpumask *in_mask)
 
        msg.task = &p->fw_task;
        msg.mask.bits[0] = in_mask->bits[0];
-       fw_notify(FW_AFFINITY, &msg);
+       fw_notify(FW_TOPIC_AFFINITY, &msg);
 //again:
 //     retval = set_cpus_allowed_ptr(p, new_mask);
 //
@@ -1172,11 +1179,14 @@ int select_task_rq(struct task_struct *p, int cpu, int sd_flags, int wake_flags)
  */
 void activate_task(struct rq *rq, struct task_struct *p, int flags)
 {
+       fw_admit_msg_t admit = {&p->fw_task};
+       fw_unblock_msg_t unblock = {&p->fw_task};
+
        if (flags == 0) {
-               fw_notify(FW_ADMIT, &p->fw_task);
+               fw_notify(FW_TOPIC_ADMIT, &admit);
        }
        else {
-               fw_notify(FW_UNBLOCK, &p->fw_task);
+               fw_notify(FW_TOPIC_UNBLOCK, &unblock);
        }
 }
 
@@ -1594,6 +1604,9 @@ static void /*__sched*/ __schedule(bool preempt)
        struct task_struct *prev;//, *next, *fw_next;
        struct rq *rq;
        int cpu;
+       fw_release_msg_t release;
+       fw_block_msg_t block;
+       fw_relinquish_msg_t relinquish;
 
        cpu = smp_processor_id();
        rq = cpu_rq(cpu);
@@ -1633,11 +1646,13 @@ static void /*__sched*/ __schedule(bool preempt)
                        prev->state = TASK_RUNNING;
                }
                else if (prev->state == TASK_DEAD) {
-                       fw_notify(FW_RELEASE, &prev->fw_task);
+                       release.task = &prev->fw_task;
+                       fw_notify(FW_TOPIC_RELEASE, &release);
 //                     prev->on_rq = 0;
                }
                else {
-                       fw_notify(FW_BLOCK, &prev->fw_task);
+                       block.task = &prev->fw_task;
+                       fw_notify(FW_TOPIC_BLOCK, &block);
 //                     prev->on_rq = 0;
 
                        /*
@@ -1656,7 +1671,8 @@ static void /*__sched*/ __schedule(bool preempt)
        }
 
        if ((prev != rq->idle) && ((prev->fw_task.state == FW_READY)||(prev->fw_task.state == FW_RUNNING))) {
-               fw_notify(FW_RELINQUISH, &prev->fw_task);
+               relinquish.task = &prev->fw_task;
+               fw_notify(FW_TOPIC_RELINQUISH, &relinquish);
        }
 
        clear_tsk_need_resched(prev);
@@ -2487,7 +2503,7 @@ void set_task_cpu(struct task_struct *p, unsigned int new_cpu)
 
        msg.task = &p->fw_task;
        msg.mask.bits[0] = p->cpus_allowed.bits[0];
-       fw_notify(FW_AFFINITY, &msg);
+       fw_notify(FW_TOPIC_AFFINITY, &msg);
 
 }