Document and refactor component subsystem
authorAnselm Busse <anselm.busse@tu-berlin.de>
Fri, 29 Jan 2016 17:19:24 +0000 (18:19 +0100)
committerAnselm Busse <anselm.busse@tu-berlin.de>
Fri, 29 Jan 2016 17:19:24 +0000 (18:19 +0100)
22 files changed:
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_components.h
framework/include/fw_pipe.h
framework/include/fw_types.h
framework/lib/fw.c
framework/lib/fw_comm.c
framework/lib/fw_components.c
framework/lib/fw_pipe.c
framework/lib/fw_sched.c
framework/lib/fw_task.c [deleted file]
framework/modules/affinities.c
framework/modules/fcfs.c
framework/modules/load_balance.c
framework/modules/round_robin.c
framework/modules/template.c

index c9ebed5..97307cd 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_component_inst*))) == NULL) {
+       if ((fw_component_instances = fw_malloc(fw_num_instances * sizeof(fw_component_inst_t*))) == NULL) {
                        fw_panic("failed to allocate memory for instance references\n");
                        /* never reached */;
        }
index 1b43979..8d9d486 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_component_inst*))) == NULL) {
+       if ((fw_component_instances = fw_malloc(fw_num_instances * sizeof(fw_component_inst_t*))) == NULL) {
                        fw_panic("failed to allocate memory for instance references\n");
                        /* never reached */;
        }
index 2eb541f..a1fa74a 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_component_inst*))) == NULL) {
+       if ((fw_component_instances = fw_malloc(fw_num_instances * sizeof(fw_component_inst_t*))) == NULL) {
                        fw_panic("failed to allocate memory for instance references\n");
                        /* never reached */;
        }
@@ -72,30 +72,30 @@ int fw_build_topo(void)
        /* link modules */
        temp = fw_malloc((fw_num_cpus+1) * sizeof(fw_pipe_t*));
 
-       fw_printf("Creating a new Instance of %s...", fw_component_names[0x02]);
+       fw_printf("Creating a new Instance of %s...", fw_component_name(0x02));
        temp[0] = fw_fw_ready_pipe;
        for (i=0; i<fw_num_cpus; i++)
                temp[i+1] = topo_pipes[fw_num_cpus+i];
 
-       if ((fw_component_instances[0] = fw_component_operations[0x02]->_new(0, fw_num_cpus+1, temp)) == NULL) {
+       if ((fw_component_instances[0] = fw_component_new(0x02, 0, fw_num_cpus+1, temp)) == NULL) {
                fw_panic("failed to allocate component\n");
                /* never reached */;
        }
        fw_printf("done!\n");
 
        for (i=0;i<fw_num_cpus;i++) {
-               fw_printf("Creating a new Instance of %s...", fw_component_names[0x01]);
+               fw_printf("Creating a new Instance of %s...", fw_component_name(0x01));
                temp[0] = topo_pipes[fw_num_cpus+i];
                temp[1] = topo_pipes[i];
-               if ((fw_component_instances[i+1] = fw_component_operations[0x01]->_new(i+1, 2, temp)) == NULL) {
+               if ((fw_component_instances[i+1] = fw_component_new(0x01, i+1, 2, temp)) == NULL) {
                        fw_panic("failed to allocate component\n");
                        /* never reached */;
                };
                fw_printf("done!\n");
        }
 
-       fw_printf("Creating a new Instance of %s...", fw_component_names[0x0D]);
-       if ((fw_component_instances[i+1] = fw_component_operations[0x0D]->_new(i, 0, NULL)) == NULL) {
+       fw_printf("Creating a new Instance of %s...", fw_component_name(0x0D));
+       if ((fw_component_instances[i+1] = fw_component_new(0x0D, i+1, 0, NULL)) == NULL) {
                fw_panic("failed to allocate component\n");
                /* never reached */;
        };
index d3898b2..656c22c 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_component_inst*))) == NULL) {
+       if ((fw_component_instances = fw_malloc(fw_num_instances * sizeof(fw_component_inst_t*))) == NULL) {
                        fw_panic("failed to allocate memory for instance references\n");
                        /* never reached */;
        }
index ceaad26..bb8a960 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_component_inst*))) == NULL) {
+       if ((fw_component_instances = fw_malloc(fw_num_instances * sizeof(fw_component_inst_t*))) == NULL) {
                        fw_panic("failed to allocate memory for instance references\n");
                        /* never reached */;
        }
index 6440868..6cc1054 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_component_inst*))) == NULL) {
+       if ((fw_component_instances = fw_malloc(fw_num_instances * sizeof(fw_component_inst_t*))) == NULL) {
                        fw_panic("failed to allocate memory for instance references\n");
                        /* never reached */;
        }
index 59da3d6..ec9d426 100644 (file)
@@ -64,7 +64,7 @@
 
 #define FW_SMP_STARTED OS_SMP_STARTED
 
-extern fw_component_inst **fw_component_instances;
+extern fw_component_inst_t **fw_component_instances;
 extern unsigned int fw_num_instances;
 
 // TODO move to helper .h
index e5ad0b3..4479bd3 100644 (file)
@@ -11,7 +11,7 @@
 #define FW_COMM_H_
 
 typedef struct fw_task fw_task_t;
-typedef struct fw_component fw_component_inst;
+typedef struct fw_component_inst fw_component_inst_t;
 
 /**
  * The type of topics in CoBaS.
@@ -39,7 +39,7 @@ typedef struct fw_component fw_component_inst;
  *                 time a notification arrives.
  * @param inst A reference to the instance that is notified.
  */
-void fw_subscribe(fw_topic_t topic, void *callback, fw_component_inst *inst);
+void fw_subscribe(fw_topic_t topic, void *callback, fw_component_inst_t *inst);
 
 /**
  * \brief Publishes a notification in the framework.
@@ -112,7 +112,7 @@ int fw_request(fw_topic_t topic, void *result);
  * @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);
+int fw_register_responder(fw_topic_t topic, void *callback, fw_component_inst_t *inst);
 
 /**
  * \brief The main initialization function for the communication subsystem.
index 329dc88..16ded83 100644 (file)
  * This file contains the interface description for the CoBaS component system.
  */
 
-#ifndef FW_MODULES_H_
-#define FW_MODULES_H_
+#ifndef FW_COMPONENTS_H_
+#define FW_COMPONENTS_H_
 
 #include <fw_types.h>
 #include <fw_limits.h>
 
-typedef struct fw_task fw_task_t;
-
-typedef int mod_uuid_t;
+/**
+ * Type for component identifiers.
+ */
+typedef int component_uuid_t;
+/**
+ * Type for component instance identifiers.
+ */
 typedef int inst_uuid_t;
 
-typedef struct fw_component fw_component_inst;
-typedef struct fw_pipe fw_pipe_t;
-
+/**
+ * This structures aggregates all operations of an component (instance).
+ */
 typedef struct fw_component_operations {
-       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);
+       void (*schedule) (fw_component_inst_t *self, int cpu);                                  /**< Informs the instance about a rescheduling for the provided PE */
+       void (*dispatch) (fw_component_inst_t *self, int cpu, fw_task_t *next); /**< Informs the instance about the dispatching of the given task on the given PE */
+       void (*task_init) (fw_component_inst_t *self, fw_task_t *task);                 /**< Initiates resources necessary for this instance per task */
+       void (*task_destroy) (fw_component_inst_t *self, fw_task_t *task);              /**< Frees the resources necessary for this instance per task */
+       void (*pipe_update) (fw_component_inst_t *self, fw_pipe_t *pipe);               /**< Notifies the instance about changes in the pipe */
 } fw_component_operations_t;
 
 /**
  * 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_component_operations_t ops;
-       void *inst_data;
-} fw_component_inst;
+typedef struct fw_component_inst {
+       component_uuid_t comp_id;               /**< The identifier of the component */
+       inst_uuid_t inst_id;                                    /**< The identifier of the component instance */
+       fw_component_operations_t ops;  /**< The component's operations */
+       void *inst_data;                                /**< The private data of this comonent instance */
+} fw_component_inst_t;
 
+/**
+ * Retrieves the private data of the instance.
+ */
 #define inst_data(type) ((type*) self->inst_data)
 
+/**
+ * Retrieves the PCB data of the instance.
+ */
 #define inst_pcb(type, task) ((type*) task->module_data[self->id])
 
+
+/**
+ * \brief Registers a new component.
+ *
+ * @param uuid The identifier for the new component.
+ * @param name A human readable name for the new component.
+ * @param description A short description for the new component.
+ * @param _new Reference to the constructor function of the new component.
+ * @param _destroy Reference to the destructor function of the new component.
+ * @return Return 0 if successful.
+ */
+int fw_component_register(component_uuid_t uuid, const char *name, const char *description,
+               fw_component_inst_t* (*_new) (inst_uuid_t inst_id, int link_count, fw_pipe_t **links),
+               void (*_destroy) (fw_component_inst_t *self));
+
+/**
+ * \brief Instantiates a new component.
+ *
+ * The function calls the constructor of the requested component and returns
+ * the new instance. It also registers the new instance for future references.
+ *
+ * @param uuid The component ID to create the new instance of.
+ * @param inst_id The identifier for the new instance itself
+ * @param link_count The number of pipes connected to the new instance.
+ * @param links The pipes that are connected to the new instance.
+ * @return A reference to the newly created component instance.
+ */
+fw_component_inst_t *fw_component_new(component_uuid_t uuid, inst_uuid_t inst_id, int link_count, fw_pipe_t **links);
+
+/**
+ * \brief Deallocates a component instance.
+ *
+ * @param inst The instance that will be dealocated
+ */
+void fw_component_destroy(fw_component_inst_t *inst);
+
+/**
+ * \brief Checks whether a component was registered in CoBas and is available or
+ * not.
+ *
+ * @param uuid Identifier of the component
+ * @return Returns != 0 if the component is available.
+ */
+int fw_component_available(component_uuid_t uuid);
+
+/**
+ * \brief Retrieves the human readable name for a component identifier.
+ *
+ * @param uuid Identifier
+ * @return The corosponding human readable name for the given identifier.
+ */
+char *fw_component_name(component_uuid_t uuid);
+
+/**
+ * This macro puts the given function in an array with the help of an linker
+ * script. The functions are called by the init function of the communication
+ * subsystem.
+ */
 #define fw_component_init(x) __fw_initcall(x)
 #define __fw_initcall(fn) static fw_initcall_t __fw_initcall_##fn \
                __attribute__ ((__used__)) \
                __attribute__ ((__section__(".cobas.components.init"))) = fn
-
-extern const char *fw_component_names[FW_MAX_COMPONENT_ID];
-extern fw_component_operations_t *fw_component_operations[FW_MAX_COMPONENT_ID];
-extern void *fw_component_private_data[FW_MAX_COMPONENT];
-
+/**
+ * \brief Initiates the component subsystem.
+ *
+ * The function initiates all constructs to manage components. Furthermore, it
+ * calls the init function of every build in component.
+ */
 void fw_components_init(void);
 
-int fw_component_register(int uuid, const char *component_name, fw_component_operations_t *operations);
-int fw_component_available(int uuid);
-
-fw_component_inst *fw_component_clone(fw_component_inst *other);
-
-#endif /* FW_MODULES_H_ */
+#endif /* FW_COMPONENTS_H_ */
index 613f4d5..3865d60 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_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_component_inst_t *in;                        /**< Reference to the source component instance connected to the pipe. */
+       fw_component_inst_t *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_component_inst *self, fw_task_t *task);
+int fw_pipe_task_init(fw_component_inst_t *self, fw_task_t *task);
 
-void fw_pipe_task_destroy(fw_component_inst *self, fw_task_t *task);
+void fw_pipe_task_destroy(fw_component_inst_t *self, fw_task_t *task);
 
 int fw_pipes_init(void);
 
index 977b82b..21d68b1 100644 (file)
@@ -9,10 +9,12 @@
 
 typedef struct fw_sched_chain fw_sched_chain_t;
 
-typedef struct fw_component fw_component_inst;
+typedef struct fw_task fw_task_t;
+typedef struct fw_pipe fw_pipe_t;
+typedef struct fw_component_inst fw_component_inst_t;
 
 typedef struct fw_sched_chain {
-       fw_component_inst *inst;
+       fw_component_inst_t *inst;
        fw_sched_chain_t *next;
 } fw_sched_chain_t;
 
index 98d9424..1e4e083 100644 (file)
@@ -3,7 +3,7 @@
 extern int fw_build_topo(void);
 extern void __fw_schedule(int);
 
-fw_component_inst **fw_component_instances;
+fw_component_inst_t **fw_component_instances;
 unsigned int fw_num_instances;
 
 void fw_schedule(int cpu)
index 557e322..0b59a79 100644 (file)
@@ -24,7 +24,7 @@
 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. */
+       fw_component_inst_t *inst;      /**< The component instance to which this subscription belongs. */
 };
 
 /**
@@ -42,7 +42,7 @@ struct fw_topic_registration {
        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;
+       fw_component_inst_t *responder_inst;
                                                        /**< The component instance to which this subscription belongs. */
        int (*resonder_callback)(void *, void*);
                                                        /**< Reference to the responder callback function. */
@@ -58,7 +58,7 @@ static struct fw_topic_registration fw_registered_topics[FW_MAX_TOPICS];
  */
 static fw_list_head_t fw_topics[FW_MAX_TOPICS];
 
-void fw_subscribe(fw_topic_t topic, void *callback, fw_component_inst *inst)
+void fw_subscribe(fw_topic_t topic, void *callback, fw_component_inst_t *inst)
 {
        struct fw_subscription_element *subscriber = fw_malloc(sizeof(struct fw_subscription_element));
 
@@ -148,7 +148,7 @@ int fw_request(fw_topic_t topic, void *result)
                   -0xFF;
 }
 
-int fw_register_responder(fw_topic_t topic, void *callback, fw_component_inst *inst)
+int fw_register_responder(fw_topic_t topic, void *callback, fw_component_inst_t *inst)
 {
        if(fw_registered_topics[topic].responder > 0){
                fw_error("Responder for topic %d already registered.\n", topic);
index 66da1db..03865d2 100644 (file)
 #include "fw.h"
 
+/**
+ * Holds all the property of necessary to describe a CoBaS component.
+ */
+typedef struct fw_component {
+       component_uuid_t id;                                                    /**< Unique identifier of the comonent */
+       char *name;                                                                             /**< A human readable name of the component */
+       char *description;                                                              /**< A short description of the component */
+
+       fw_component_inst_t* (*_new) (inst_uuid_t inst_id, int link_count, fw_pipe_t **links);
+               /**< Creates a new instances of this component with <code>inst_id</code as component id and connects the pipes provided by <code>links</code>*/
+       void (*_destroy) (fw_component_inst_t *self);   /**< Frees all resources of the provided component */
+} fw_component_t;
+
+/**
+ * Descriptions of all registered components.
+ */
+static fw_component_t components[FW_MAX_COMPONENT];
+/**
+ * The number of registered components.
+ */
+static unsigned int registered_components = 0;
+
+/**
+ * References to all component instances.
+ */
+static fw_component_inst_t *components_instances[FW_MAX_COMPONENT_INST];
+/**
+ * The number of component instances.
+ */
+static unsigned int instantiated_components = 0;
+
+int fw_component_register(component_uuid_t uuid, const char *name, const char *description,
+               fw_component_inst_t* (*_new) (inst_uuid_t inst_id, int link_count, fw_pipe_t **links),
+               void (*_destroy) (fw_component_inst_t *self))
+{
+       FW_ASSERT(uuid <= FW_MAX_COMPONENT_ID);
+       FW_ASSERT(name != NULL );
+       FW_ASSERT(description != NULL);
+       FW_ASSERT(_new != NULL);
+       FW_ASSERT(_destroy != NULL);
 
+       if(fw_component_available(uuid)) {
+               fw_error("Component with UUID 0x%02x already registered: %s\n", uuid, components[uuid].name);
+               return -1;
+       }
 
-const char *fw_component_names[FW_MAX_COMPONENT];
-fw_component_operations_t *fw_component_operations[FW_MAX_COMPONENT];
-void *fw_component_private_data[FW_MAX_COMPONENT];
+       components[uuid].name = fw_malloc((strlen(name)+1) * sizeof(char));
+       if(components[uuid].name == NULL){
+               fw_error("OOM when registering %s(0x%02x)\n", name, uuid);
+               return -1;
+       }
 
-unsigned int registered_components = 0;
+       components[uuid].description = fw_malloc((strlen(description)+1) * sizeof(char));
+       if(components[uuid].description == NULL){
+               fw_free(components[uuid].name);
+               fw_error("OOM when registering %s(0x%02x)\n", name, uuid);
+               return -1;
+       }
 
-extern fw_initcall_t __cobas_components_init_start[];
-extern fw_initcall_t __cobas_components_init_end[];
+       memcpy(components[uuid].name, name, strlen(name));
+       memcpy(components[uuid].description, description, strlen(description));
+       components[uuid].id = uuid;
+       components[uuid]._new = _new;
+       components[uuid]._destroy = _destroy;
 
-void fw_components_init(void)
-{
-       int i;
-       fw_initcall_t *call;
+       registered_components++;
 
+       fw_printf("Registered component with UUID 0x%02x: %s\n", uuid, name);
+       return 0;
+}
 
-       for (i=0; i<FW_MAX_COMPONENT_ID; i++) {
-               fw_component_operations[i] = NULL;
-               fw_component_names[i] = "N/A";
+fw_component_inst_t *fw_component_new(component_uuid_t uuid, inst_uuid_t inst_id, int link_count, fw_pipe_t **links)
+{
+       if (components[uuid].id == 0) {
+               fw_error("No component registered for 0x%02x.\n", uuid);
+               return NULL;
        }
 
-       for (call=__cobas_components_init_start, i=0; call<__cobas_components_init_end; call++, i++) {
-               if ((*call)() < 0) {
-                       fw_printf("Error: Component %s: Could not be initialized\n", fw_component_names[i]);
-               }
+       if (components_instances[inst_id] != NULL) {
+               fw_error("There is already an instance with ID %x \n", inst_id);
+               return NULL;
        }
-}
 
-int fw_component_register(int uuid, const char *component_name, fw_component_operations_t *operations)
-{
-       if (!component_name || uuid > FW_MAX_COMPONENT_ID) {
-               return -1;
-       }
+       components_instances[inst_id] = components[uuid]._new(inst_id, link_count, links);
 
-       if(fw_component_available(uuid)) {
-               fw_printf("Component with UUID 0x%02x already registered: %s\n", uuid, component_name);
-               return -1;
+       if (components_instances[inst_id] == NULL) {
+               fw_error("Failed to create a new instance of %s(0x%02x) with ID %x.\n", fw_component_name(uuid), uuid, inst_id);
+               return NULL;
        }
 
-       fw_component_operations[uuid]  = operations;
-       fw_component_names[uuid] = component_name;
+       instantiated_components++;
 
-       fw_printf("Registered component with UUID 0x%02x: %s\n", uuid, component_name);
-       return 0;
+       return components_instances[inst_id];
 }
 
-int fw_component_available(int uuid)
+void fw_component_destroy(fw_component_inst_t *inst)
 {
-       return fw_component_operations[uuid] != NULL;
+       components_instances[inst->inst_id] = NULL;
+       components[inst->comp_id]._destroy(inst);
 }
 
-fw_component_inst *fw_component_clone(fw_component_inst *other)
+char *fw_component_name(component_uuid_t uuid)
 {
-       fw_component_inst *inst;
+       return components[uuid].name;
+}
 
-       if(other == NULL) {
-               return other;
-       }
+int fw_component_available(component_uuid_t uuid)
+{
+       return components[uuid].id != 0;
+}
 
-       inst = fw_malloc(sizeof(fw_component_inst));
-       if (inst == NULL) {
-               fw_printf("Error: cloning component '%s (%d)' failed with OOM\n", other->name, other->uuid);
-               return NULL;
+extern fw_initcall_t __cobas_components_init_start[];
+extern fw_initcall_t __cobas_components_init_end[];
+
+void fw_components_init(void)
+{
+       int i;
+       fw_initcall_t *call;
+
+
+       for (i=0; i<FW_MAX_COMPONENT_ID; i++) {
+               components[i].id = 0;
        }
 
-       memcpy(inst, other, sizeof(fw_component_inst));
-       inst->id = -1;
+       for (i=0; i<FW_MAX_COMPONENT_INST; i++) {
+               components_instances[i]= NULL;
+       }
 
-       return inst;
+       for (call=__cobas_components_init_start, i=0; call<__cobas_components_init_end; call++, i++) {
+               if ((*call)() < 0) {
+                       fw_panic("Component call %d failed with function %p\n", i, *call);
+                       /* never reached */
+               }
+       }
 }
index 3201bf6..58ed27d 100644 (file)
@@ -8,7 +8,7 @@
 #include <fw.h>
 #include <fw_pipe.h>
 
-static fw_component_inst fw_pipe_termination;
+static fw_component_inst_t 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_component_inst *self, fw_task_t *task)
+int fw_pipe_task_init(fw_component_inst_t *self, fw_task_t *task)
 {
        return 0;
 }
 
-void fw_pipe_task_destroy(fw_component_inst *self, fw_task_t *task)
+void fw_pipe_task_destroy(fw_component_inst_t *self, fw_task_t *task)
 {
 
 }
 
-static void fw_pipe_termination_update(fw_component_inst *self, fw_pipe_t *pipe)
+static void fw_pipe_termination_update(fw_component_inst_t *self, fw_pipe_t *pipe)
 {
        fw_task_t *pos, *n;
 
index 46173b0..cbff562 100644 (file)
 fw_pipe_t *fw_fw_ready_pipe;
 fw_pipe_t **fw_fw_dispatch_pipe;
 
-fw_component_inst **fw_fw_dispatch_inst;
+fw_component_inst_t **fw_fw_dispatch_inst;
 
 char fw_sched_buf[127] = {0};
 FW_DEFINE_SPINLOCK(fw_lock);
 
-static void __fw_admit(fw_component_inst *self, fw_admit_msg_t *admit)
+static void __fw_admit(fw_component_inst_t *self, fw_admit_msg_t *admit)
 {
        fw_task_t *task = admit->task;
 
@@ -42,7 +42,7 @@ static void __fw_admit(fw_component_inst *self, fw_admit_msg_t *admit)
        fw_fw_ready_pipe->out->ops.pipe_update(fw_fw_ready_pipe->out, fw_fw_ready_pipe);
 }
 
-static void __fw_release(fw_component_inst *self, fw_release_msg_t *release)
+static void __fw_release(fw_component_inst_t *self, fw_release_msg_t *release)
 {
        fw_task_t *task = release->task;
 
@@ -77,7 +77,7 @@ void __fw_schedule(int cpu)
        os_dispatch(next_task);
 }
 
-static void __fw_relinquish(fw_component_inst *self, fw_relinquish_msg_t *relinquish)
+static void __fw_relinquish(fw_component_inst_t *self, fw_relinquish_msg_t *relinquish)
 {
        fw_task_t *task = relinquish->task;
 
@@ -99,7 +99,7 @@ static void __fw_relinquish(fw_component_inst *self, fw_relinquish_msg_t *relinq
        fw_fw_ready_pipe->out->ops.pipe_update(fw_fw_ready_pipe->out, fw_fw_ready_pipe);
 }
 
-static void __fw_block(fw_component_inst *self, fw_block_msg_t *block)
+static void __fw_block(fw_component_inst_t *self, fw_block_msg_t *block)
 {
        fw_task_t *task = block->task;
 
@@ -111,7 +111,7 @@ static void __fw_block(fw_component_inst *self, fw_block_msg_t *block)
        task->state = FW_BLOCKED;
 }
 
-static void __fw_unblock(fw_component_inst *self, fw_unblock_msg_t *unblock)
+static void __fw_unblock(fw_component_inst_t *self, fw_unblock_msg_t *unblock)
 {
        fw_task_t *task = unblock->task;
 
diff --git a/framework/lib/fw_task.c b/framework/lib/fw_task.c
deleted file mode 100644 (file)
index e69de29..0000000
index b5de01a..36177cc 100644 (file)
@@ -5,44 +5,51 @@
 
 #include <topics/affinity.h>
 
-#define AF_COMPONENT_NAME      "CPU Affinity Component"
 #define AF_COMPONENT_UUID      0x0D
-
-fw_component_inst af_proto;
+#define AF_COMPONENT_NAME      "CPU Affinity Component"
+#define AF_COMPONENT_DESC      "TODO"
 
 struct af_pcb {
        fw_cpumask_t    cpus_allowed;
 };
 
-static void af_task_init(fw_component_inst *self, fw_task_t *task)
+static void af_task_init(fw_component_inst_t *self, fw_task_t *task)
 {
        struct af_pcb *pcb = fw_malloc(sizeof(struct af_pcb));
 
-       task->component_pcb[self->id] = pcb;
+       task->component_pcb[self->inst_id] = pcb;
        fw_cpumask_setall(&pcb->cpus_allowed);
 }
 
-static void af_task_destroy(fw_component_inst *self, fw_task_t *task)
+static void af_task_destroy(fw_component_inst_t *self, fw_task_t *task)
 {
-       fw_free(task->component_pcb[self->id]);
+       fw_free(task->component_pcb[self->inst_id]);
 }
 
-static void af_set_affinity(fw_component_inst *self, fw_affinity_msg_t *affinity)
+static void af_set_affinity(fw_component_inst_t *self, fw_affinity_msg_t *affinity)
 {
-       struct af_pcb *pcb = affinity->task->component_pcb[self->id];
+       struct af_pcb *pcb = affinity->task->component_pcb[self->inst_id];
        pcb->cpus_allowed = affinity->mask;
 
 //     fw_printf("set affinity for %d to %d\n", FW_TASK_ID(affinity->task), affinity->mask);
 }
 
-static void af_get_affinity(fw_component_inst *self, fw_affinity_msg_t *affinity)
+static void af_get_affinity(fw_component_inst_t *self, fw_affinity_msg_t *affinity)
 {
-       struct af_pcb *pcb = affinity->task->component_pcb[self->id];
+       struct af_pcb *pcb = affinity->task->component_pcb[self->inst_id];
        affinity->mask = pcb->cpus_allowed;
 
 //     fw_printf("retrieve affinity for %d: %d\n", FW_TASK_ID(affinity->task), affinity->mask);
 }
 
+static fw_component_operations_t af_ops = {
+       .schedule               = NULL,
+       .dispatch               = NULL,
+       .task_init              = af_task_init,
+       .task_destroy   = af_task_destroy,
+       .pipe_update    = NULL,
+};
+
 /**
  * \brief Creates a new component instance
  *
@@ -52,25 +59,27 @@ static void af_get_affinity(fw_component_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_component_inst *af_new(inst_uuid_t inst_id, int link_count, fw_pipe_t **links)
+static fw_component_inst_t *af_new(inst_uuid_t inst_id, int link_count, fw_pipe_t **links)
 {
        // the newly created instance
-       fw_component_inst *inst;
+       fw_component_inst_t *inst;
 
-       // creates a new instance from an template
-       inst = fw_component_clone(&af_proto);
-       if (inst == NULL) {
-               fw_panic("Error: Module %s: OOM for new instance\n", AF_COMPONENT_NAME);
+       if (link_count != 0) {
+               fw_panic("Error: Module %s: Wrong number of link_count (%d instead of %i)\n", AF_COMPONENT_NAME, link_count, 0);
                /* never reached */
        }
 
-       inst->id = inst_id;
-
-       if (link_count != 0) {
-               fw_panic("Error: Module %s: Wrong number of link_count (%d instead of %i)\n", AF_COMPONENT_NAME, link_count, 0);
+       inst = fw_malloc(sizeof(fw_component_inst_t));
+       if (inst == NULL) {
+               fw_error("Error: Module %s: OOM for new instance\n", AF_COMPONENT_NAME);
                /* never reached */
        }
 
+       inst->comp_id = AF_COMPONENT_UUID;
+       inst->inst_id = inst_id;
+       inst->ops = af_ops;
+       inst->inst_data = NULL;
+
        fw_subscribe(FW_TOPIC_AFFINITY, af_set_affinity, inst);
        fw_register_responder(FW_TOPIC_AFFINITY, af_get_affinity, inst);
 
@@ -82,36 +91,17 @@ static fw_component_inst *af_new(inst_uuid_t inst_id, int link_count, fw_pipe_t
  *
  * @param self The comonent instance.
  */
-static void af_destroy(fw_component_inst *self)
+static void af_destroy(fw_component_inst_t *self)
 {
        fw_free(self->inst_data);
        fw_free(self);
 }
 
-fw_component_operations_t af_ops = {
-       ._new           = af_new,
-       ._destroy       = af_destroy,
-       .schedule       = NULL,
-       .dispatch       = NULL,
-       .task_init      = af_task_init,
-};
-
-fw_component_inst af_proto = {
-       .uuid   = AF_COMPONENT_UUID,
-       .name   = AF_COMPONENT_NAME,
-       .id             = -1,
-       .ops = {._new = af_new,
-                       ._destroy = af_destroy,
-                       .task_init = af_task_init,
-                       .task_destroy = af_task_destroy},
-       .inst_data = NULL,
-};
-
 int af_init(void)
 {
        FW_REGISTER_TOPIC(AFFINITY);
 
-       return fw_component_register(AF_COMPONENT_UUID, AF_COMPONENT_NAME, &af_ops);
+       return fw_component_register(AF_COMPONENT_UUID, AF_COMPONENT_NAME, AF_COMPONENT_DESC, af_new, af_destroy);
 }
 
 fw_component_init(af_init);
index bdd5866..28fcd3a 100644 (file)
@@ -7,10 +7,11 @@
 
 int fcfs_init(void);
 
-#define FCFS_MODULE_NAME       "First Come First Served Component"
 #define FCFS_MODULE_UUID       0x03
+#define FCFS_MODULE_NAME       "First Come First Served Component"
+#define FCFS_MODULE_DESC       "TODO"
 
-static fw_component_inst fcfs_proto;
+static fw_component_inst_t fcfs_proto;
 
 typedef struct fcfs_private_data {
        int inst_id;
@@ -27,7 +28,7 @@ typedef struct fcfs_pcb {
 } fcfs_pcb_t;
 
 
-static void fcfs_task_init(fw_component_inst *self, fw_task_t *task)
+static void fcfs_task_init(fw_component_inst_t *self, fw_task_t *task)
 {
        int time;
        fcfs_pcb_t *pcb = fw_malloc(sizeof(fcfs_pcb_t));
@@ -41,12 +42,12 @@ static void fcfs_task_init(fw_component_inst *self, fw_task_t *task)
        pcb->lamport = time;
 }
 
-static void fcfs_task_destroy(fw_component_inst *self, fw_task_t *task)
+static void fcfs_task_destroy(fw_component_inst_t *self, fw_task_t *task)
 {
        fw_free(task->component_pcb[self->id]);
 }
 
-static void fcfs_pipe_update(fw_component_inst *self, fw_pipe_t *pipe)
+static void fcfs_pipe_update(fw_component_inst_t *self, fw_pipe_t *pipe)
 {
        fw_task_t *pos, *iter, *n;
        fcfs_pcb_t *tmp1, *tmp2;
@@ -83,9 +84,9 @@ static void fcfs_pipe_update(fw_component_inst *self, fw_pipe_t *pipe)
        pd->out_pipe->out->ops.pipe_update(pd->out_pipe->out, pd->out_pipe);
 }
 
-static fw_component_inst *fcfs_new(inst_uuid_t inst_id, int link_count, fw_pipe_t **links)
+static fw_component_inst_t *fcfs_new(inst_uuid_t inst_id, int link_count, fw_pipe_t **links)
 {
-       fw_component_inst *inst;
+       fw_component_inst_t *inst;
        struct fcfs_private_data *pd;
 
        inst = fw_component_clone(&fcfs_proto);
@@ -121,18 +122,16 @@ static fw_component_inst *fcfs_new(inst_uuid_t inst_id, int link_count, fw_pipe_
        return inst;
 }
 
-static void fcfs_destroy(fw_component_inst *self)
+static void fcfs_destroy(fw_component_inst_t *self)
 {
 
 }
 
-static fw_component_inst fcfs_proto = {
+static fw_component_inst_t fcfs_proto = {
        .uuid = FCFS_MODULE_UUID,
        .name = FCFS_MODULE_NAME,
        .id = -1,
-       .ops = {._new = fcfs_new,
-                       ._destroy = fcfs_destroy,
-                       .task_init = fcfs_task_init,
+       .ops = {.task_init = fcfs_task_init,
                        .task_destroy = fcfs_task_destroy,
                        .pipe_update = fcfs_pipe_update},
        .inst_data = NULL
@@ -140,7 +139,7 @@ static fw_component_inst fcfs_proto = {
 
 int fcfs_init(void)
 {
-       return fw_component_register(FCFS_MODULE_UUID, FCFS_MODULE_NAME, &fcfs_proto.ops);
+       return fw_component_register(FCFS_MODULE_UUID, FCFS_MODULE_NAME, FCFS_MODULE_DESC, fcfs_new, fcfs_destroy);
 }
 
 fw_component_init(fcfs_init);
index 799b24e..36b70c6 100644 (file)
@@ -1,17 +1,11 @@
-/*
- * load_balance.c
- *
- *  Created on: 08.04.2014
- *      Author: jkrieg
- */
-
 #include <fw.h>
 
 #include <topics/affinity.h>
 #include <topics/cpu_status.h>
 
+#define LB_MODULE_UUID 0x02
 #define LB_MODULE_NAME "Load Balancer"
-#define LB_MODULE_UUID         0x02
+#define LB_MODULE_DESC "TODO"
 
 #define LB_BALANCE_SLICE 32
 
@@ -19,8 +13,6 @@
 
 FW_DEFINE_SPINLOCK(lb_lock);
 
-static fw_component_inst lb_proto;
-
 struct lb_pool_entry {
        struct lb_pool_entry *next;
        fw_tlist_elem_t elem;
@@ -48,20 +40,20 @@ typedef struct lb_pcb {
 
 static fw_affinity_msg_t affinity_req;
 
-static void lb_task_init(fw_component_inst *self, fw_task_t *task)
+static void lb_task_init(fw_component_inst_t *self, fw_task_t *task)
 {
        lb_pcb_t *pcb = fw_malloc(sizeof(struct lb_pcb));
        pcb->pipe = NULL;
 
-       task->component_pcb[self->id] = pcb;
+       task->component_pcb[self->inst_id] = pcb;
 }
 
-static void lb_task_destroy(fw_component_inst *self, fw_task_t *task)
+static void lb_task_destroy(fw_component_inst_t *self, fw_task_t *task)
 {
-       fw_free(task->component_pcb[self->id]);
+       fw_free(task->component_pcb[self->inst_id]);
 }
 
-static void lb_pipe_update(fw_component_inst *self, fw_pipe_t *pipe)
+static void lb_pipe_update(fw_component_inst_t *self, fw_pipe_t *pipe)
 {
        fw_task_t *pos, *n;
        static int next_cpu = -1;
@@ -80,7 +72,7 @@ static void lb_pipe_update(fw_component_inst *self, fw_pipe_t *pipe)
                        continue;
                }
 
-               pcb = pos->component_pcb[self->id];
+               pcb = pos->component_pcb[self->inst_id];
                pcb->pipe = pd->out_pipe[next_cpu];
 
                fw_spin_lock(&pd->out_pipe[next_cpu]->lock);
@@ -92,7 +84,7 @@ static void lb_pipe_update(fw_component_inst *self, fw_pipe_t *pipe)
        }
 
        fw_list_for_each_entry_safe(pos,n,(&pipe->tasks_removed),pipe_pcb[pipe->id].removed) {
-               pcb = pos->component_pcb[self->id];
+               pcb = pos->component_pcb[self->inst_id];
 
                fw_list_del(&pos->pipe_pcb[pcb->pipe->id].list);
                fw_list_add_tail(&pos->pipe_pcb[pcb->pipe->id].removed, &pcb->pipe->tasks_removed);
@@ -106,7 +98,7 @@ static void lb_pipe_update(fw_component_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_component_inst *self, fw_cpu_status_msg_t *msg)
+static void lb_cpu_online(fw_component_inst_t *self, fw_cpu_status_msg_t *msg)
 {
        lb_private_data_t *pd = inst_data(lb_private_data_t);
 
@@ -122,31 +114,45 @@ static void lb_cpu_online(fw_component_inst *self, fw_cpu_status_msg_t *msg)
        fw_spin_unlock(&pd->lock);
 }
 
-static fw_component_inst *lb_new(inst_uuid_t inst_id, int link_count, fw_pipe_t **links)
+static fw_component_operations_t lb_ops = {
+       .schedule               = NULL,
+       .dispatch               = NULL,
+       .task_init              = lb_task_init,
+       .task_destroy   = lb_task_destroy,
+       .pipe_update    = lb_pipe_update
+};
+
+static fw_component_inst_t *lb_new(inst_uuid_t inst_id, int link_count, fw_pipe_t **links)
 {
-       fw_component_inst *inst;
+       fw_component_inst_t *inst;
        struct lb_private_data *pd;
        int i;
 
-       inst = fw_component_clone(&lb_proto);
+       inst = fw_malloc(sizeof(fw_component_inst_t));
        if (inst == NULL) {
-               fw_printf("Error: Module %s: OOM for new instance\n", LB_MODULE_NAME);
+               fw_error("Module %s: OOM for new instance\n", LB_MODULE_NAME);
                return NULL;
        }
 
-       inst->id = inst_id;
-
        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);
+               fw_error("Module %s: Memory allocation for private data failed\n", LB_MODULE_NAME);
+               fw_free(inst);
                return NULL;
        }
-       inst->inst_data = pd;
 
        if (!(pd->out_pipe = fw_malloc((fw_size_t) (link_count-1) * sizeof(fw_pipe_t *)))) {
                fw_printf("Error: Module %s: Memory allocation for private data failed\n", LB_MODULE_NAME);
+               fw_free(pd);
+               fw_free(inst);
                return NULL;
        }
 
+
+       inst->comp_id = LB_MODULE_UUID;
+       inst->inst_id = inst_id;
+       inst->ops = lb_ops;
+       inst->inst_data = pd;
+
        pd->in_pipe = links[0];
        pd->in_pipe->out = inst;
 
@@ -164,28 +170,19 @@ static fw_component_inst *lb_new(inst_uuid_t inst_id, int link_count, fw_pipe_t
        return inst;
 }
 
-
-
-static void lb_destroy(fw_component_inst *self)
+static void lb_destroy(fw_component_inst_t *self)
 {
+       lb_private_data_t *pd = inst_data(lb_private_data_t);
 
+       fw_free(pd->out_pipe);
+       fw_free(pd);
+       fw_free(self);
 }
 
-static fw_component_inst lb_proto = {
-       .uuid = LB_MODULE_UUID,
-       .name = LB_MODULE_NAME,
-       .id = -1,
-       .ops = {._new =lb_new,
-                       ._destroy = lb_destroy,
-                       .task_init = lb_task_init,
-                       .task_destroy = lb_task_destroy,
-                       .pipe_update = lb_pipe_update},
-       .inst_data = NULL
-};
 
 int lb_init(void)
 {
-       return fw_component_register(LB_MODULE_UUID, LB_MODULE_NAME, &lb_proto.ops);
+       return fw_component_register(LB_MODULE_UUID, LB_MODULE_NAME, LB_MODULE_DESC, lb_new, lb_destroy);
 }
 
 fw_component_init(lb_init);
index c01325f..a8452ad 100644 (file)
@@ -5,12 +5,10 @@
 
 #include <fw.h>
 
-int rr_init(void);
-
-#define RR_MODULE_NAME         "Round Robin"
 #define RR_MODULE_UUID         0x01
+#define RR_MODULE_NAME         "Round Robin"
+#define RR_MODULE_DESC "TODO"
 
-static fw_component_inst rr_proto;
 
 typedef struct rr_private_data {
        int inst_id;
@@ -20,17 +18,17 @@ typedef struct rr_private_data {
 } rr_private_data_t;
 
 
-static void rr_task_init(fw_component_inst *self, fw_task_t *task)
+static void rr_task_init(fw_component_inst_t *self, fw_task_t *task)
 {
 
 }
 
-static void rr_task_destroy(fw_component_inst *self, fw_task_t *task)
+static void rr_task_destroy(fw_component_inst_t *self, fw_task_t *task)
 {
 
 }
 
-static void rr_pipe_update(fw_component_inst *self, fw_pipe_t *pipe)
+static void rr_pipe_update(fw_component_inst_t *self, fw_pipe_t *pipe)
 {
        fw_task_t *pos, *n;
        rr_private_data_t *pd = inst_data(rr_private_data_t);
@@ -56,22 +54,27 @@ static void rr_pipe_update(fw_component_inst *self, fw_pipe_t *pipe)
        pd->out_pipe->out->ops.pipe_update(pd->out_pipe->out, pd->out_pipe);
 }
 
-static fw_component_inst *rr_new(inst_uuid_t inst_id, int link_count, fw_pipe_t **links)
+static fw_component_operations_t rr_ops = {
+       .schedule               = NULL,
+       .dispatch               = NULL,
+       .task_init              = rr_task_init,
+       .task_destroy   = rr_task_destroy,
+       .pipe_update    = rr_pipe_update
+};
+
+static fw_component_inst_t *rr_new(inst_uuid_t inst_id, int link_count, fw_pipe_t **links)
 {
-       fw_component_inst *inst;
+       fw_component_inst_t *inst;
        struct rr_private_data *pd;
 
-       inst = fw_component_clone(&rr_proto);
-       if (inst == NULL) {
-               fw_printf("Error: Module %s: OOM for new instance\n", RR_MODULE_NAME);
-               return NULL;
+       if (link_count != 2) {
+                       fw_error("Module %s: Wrong number of link_count (%d instead of %i)\n", RR_MODULE_NAME, link_count, 2);
+                       return NULL;
        }
 
-       inst->id = inst_id;
-
-       if (link_count != 2) {
-               fw_printf("Error: Module %s: Wrong number of link_count (%d instead of %i)\n", RR_MODULE_NAME, link_count, 2);
-               fw_free(inst);
+       inst = fw_malloc(sizeof(fw_component_inst_t));
+       if (inst == NULL) {
+               fw_printf("Error: Module %s: OOM for new instance\n", RR_MODULE_NAME);
                return NULL;
        }
 
@@ -81,6 +84,9 @@ static fw_component_inst *rr_new(inst_uuid_t inst_id, int link_count, fw_pipe_t
                return NULL;
        }
 
+       inst->comp_id = RR_MODULE_UUID;
+       inst->inst_id = inst_id;
+       inst->ops = rr_ops;
        inst->inst_data = pd;
 
        pd->in_pipe = links[0];
@@ -92,26 +98,15 @@ static fw_component_inst *rr_new(inst_uuid_t inst_id, int link_count, fw_pipe_t
        return inst;
 }
 
-static void rr_destroy(fw_component_inst *self)
+static void rr_destroy(fw_component_inst_t *inst)
 {
-
+       fw_free(inst->inst_data);
+       fw_free(inst);
 }
 
-static fw_component_inst rr_proto = {
-       .uuid = RR_MODULE_UUID,
-       .name = RR_MODULE_NAME,
-       .id = -1,
-       .ops = {._new = rr_new,
-                       ._destroy = rr_destroy,
-                       .task_init = rr_task_init,
-                       .task_destroy = rr_task_destroy,
-                       .pipe_update = rr_pipe_update},
-       .inst_data = NULL
-};
-
 int rr_init(void)
 {
-       return fw_component_register(RR_MODULE_UUID, RR_MODULE_NAME, &rr_proto.ops);
+       return fw_component_register(RR_MODULE_UUID, RR_MODULE_NAME, RR_MODULE_DESC, rr_new, rr_destroy);
 }
 
 fw_component_init(rr_init);
index 63f602e..33a9e60 100644 (file)
@@ -6,7 +6,7 @@
 #define TMPL_COMPONENT_NAME    "Template Module"
 #define TMPL_COMPONENT_UUID    0x0F
 
-fw_component_inst tmpl_proto;
+fw_component_inst_t 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_component_inst *self, int cpu)
+static void tmpl_schedule(fw_component_inst_t *self, int cpu)
 {
        struct tmpl_private_data *pd = inst_data(struct tmpl_private_data);
 
@@ -44,7 +44,7 @@ static void tmpl_schedule(fw_component_inst *self, int cpu)
  * @param cpu  The CPU number the task got dispatched to.
  * @param next The dispatched task
  */
-static void tmpl_dispatch(fw_component_inst *self, int cpu, fw_task_t *next)
+static void tmpl_dispatch(fw_component_inst_t *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_component_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_component_inst *tmpl_new(inst_uuid_t inst_id, int links, ...)
+static fw_component_inst_t *tmpl_new(inst_uuid_t inst_id, int links, ...)
 {
        // the newly created instance
-       fw_component_inst *inst;
+       fw_component_inst_t *inst;
        // private data for the new instance
        struct tmpl_private_data *pd;
 
@@ -100,7 +100,7 @@ static fw_component_inst *tmpl_new(inst_uuid_t inst_id, int links, ...)
  *
  * @param self The comonent instance.
  */
-static void tmpl_destroy(fw_component_inst *self)
+static void tmpl_destroy(fw_component_inst_t *self)
 {
        fw_free(self->inst_data);
        fw_free(self);
@@ -113,7 +113,7 @@ fw_component_operations_t tmpl_ops = {
        .dispatch       = tmpl_dispatch,
 };
 
-fw_component_inst tmpl_proto = {
+fw_component_inst_t tmpl_proto = {
        .uuid   = TMPL_COMPONENT_UUID,
        .name   = TMPL_COMPONENT_NAME,
        .id             = -1,