Finish restructuring of the CoBaS code base.
authorAnselm Busse <anselm.busse@tu-berlin.de>
Sun, 21 Feb 2016 17:05:57 +0000 (18:05 +0100)
committerAnselm Busse <anselm.busse@tu-berlin.de>
Sun, 21 Feb 2016 17:05:57 +0000 (18:05 +0100)
57 files changed:
framework/fw/fw_comm.c [moved from framework/lib/fw_comm.c with 100% similarity]
framework/fw/fw_components.c [moved from framework/lib/fw_components.c with 100% similarity]
framework/fw/fw_init.c [moved from framework/lib/fw_init.c with 94% similarity]
framework/fw/fw_pipe.c [moved from framework/lib/fw_sched.c with 64% similarity]
framework/fw/fw_platform.c [moved from framework/lib/fw_platform.c with 85% similarity]
framework/fw/fw_sched.c [new file with mode: 0644]
framework/fw/fw_task.c [moved from framework/lib/fw_task.c with 100% similarity]
framework/fw/include/fw.h [moved from framework/include/fw.h with 100% similarity]
framework/fw/include/fw_comm.h [moved from framework/include/fw_comm.h with 100% similarity]
framework/fw/include/fw_components.h [moved from framework/include/fw_components.h with 100% similarity]
framework/fw/include/fw_debug.h [moved from framework/include/fw_debug.h with 89% similarity]
framework/fw/include/fw_helper.h [moved from framework/include/fw_helper.h with 100% similarity]
framework/fw/include/fw_init.h [moved from framework/include/fw_init.h with 100% similarity]
framework/fw/include/fw_limits.h [moved from framework/include/fw_limits.h with 100% similarity]
framework/fw/include/fw_pipe.h [moved from framework/include/fw_pipe.h with 91% similarity]
framework/fw/include/fw_pipe_pcb.h [moved from framework/include/fw_pipe_pcb.h with 100% similarity]
framework/fw/include/fw_platform.h [moved from framework/include/fw_platform.h with 70% similarity]
framework/fw/include/fw_sched.h [new file with mode: 0644]
framework/fw/include/fw_target.h [new file with mode: 0644]
framework/fw/include/fw_task.h [moved from framework/include/fw_task.h with 94% similarity]
framework/fw/include/fw_types.h [moved from framework/include/fw_types.h with 58% similarity]
framework/fw/include/generated/fw_target_helper.h [new file with mode: 0644]
framework/fw/include/os.h [moved from framework/include/os.h with 77% similarity]
framework/fw/include/topics/admit.h [moved from framework/include/topics/admit.h with 100% similarity]
framework/fw/include/topics/block.h [moved from framework/include/topics/block.h with 100% similarity]
framework/fw/include/topics/cpu_status.h [moved from framework/include/topics/cpu_status.h with 100% similarity]
framework/fw/include/topics/release.h [moved from framework/include/topics/release.h with 100% similarity]
framework/fw/include/topics/relinquish.h [moved from framework/include/topics/relinquish.h with 100% similarity]
framework/fw/include/topics/unblock.h [moved from framework/include/topics/unblock.h with 100% similarity]
framework/include/fw_sched.h [deleted file]
framework/include/os/helper.h
framework/include/os/irq.h [deleted file]
framework/include/os/lock.h [deleted file]
framework/include/os/mem.h [deleted file]
framework/include/os/platform.h [deleted file]
framework/include/os/sched.h
framework/include/os/target.h [deleted file]
framework/lib/fw_irq.c
framework/lib/fw_lock.c [new file with mode: 0644]
framework/lib/fw_mem.c
framework/lib/fw_pipe.c [deleted file]
framework/lib/include/fw_irq.h [moved from framework/include/fw_irq.h with 62% similarity]
framework/lib/include/fw_list.h [moved from framework/include/fw_list.h with 100% similarity]
framework/lib/include/fw_lock.h [moved from framework/include/fw_lock.h with 56% similarity]
framework/lib/include/fw_mem.h [moved from framework/include/fw_mem.h with 70% similarity]
framework/lib/include/fw_target_types.h [new file with mode: 0644]
framework/os/linux/Makefile
framework/os/linux/linux_sched.c
framework/os/linux/os_sched.c [deleted file]
framework/os/linux/os_target.h [moved from framework/include/os/targets/linux.h with 88% similarity]
framework/scripts/fw_target.sh [new file with mode: 0755]
framework/topos/topo_lb_rr_dual.c [moved from framework/generated/topo_lb_rr_dual.c with 100% similarity]
framework/topos/topo_lb_rr_fcfs.c [moved from framework/generated/topo_lb_rr_fcfs.c with 100% similarity]
framework/topos/topo_lb_rr_multi.c [moved from framework/generated/topo_lb_rr_multi.c with 100% similarity]
framework/topos/topo_lb_rr_quad.c [moved from framework/generated/topo_lb_rr_quad.c with 100% similarity]
framework/topos/topo_lb_rr_single.c [moved from framework/generated/topo_lb_rr_single.c with 100% similarity]
framework/topos/topo_rr_single.c [moved from framework/generated/topo_rr_single.c with 100% similarity]

similarity index 94%
rename from framework/lib/fw_init.c
rename to framework/fw/fw_init.c
index a6a950a..45a5622 100644 (file)
@@ -17,7 +17,6 @@ void fw_init()
 
        fw_comm_init();
        fw_pipes_init();
-       fw_sched_init();
        fw_components_init();
        fw_build_topo();
 }
similarity index 64%
rename from framework/lib/fw_sched.c
rename to framework/fw/fw_pipe.c
index 57caacf..a1e770c 100644 (file)
@@ -1,22 +1,25 @@
 /**
- * @file fw_sched.c
+ * @file fw_pipe.h
  * @author Anselm Busse
- * @date 25 Jan 2015
+ * @date 9 Sep 2015
+ * @brief Implementation of the CoBaS pipe subsystem.
  *
- * This file contains the implementation for task management and rescheduling
- * in CoBaS.
+ * This is the interface definition for pipes in CoBaS. Pipes are connecting
+ * component instances with each other and are the main means to propagate task
+ * sets and orders inside the framework.
  */
 
-#include <fw_types.h>
-#include <fw_lock.h>
-#include <fw_sched.h>
 #include <fw_pipe.h>
-#include <fw_comm.h>
+#include <fw_pipe_pcb.h>
+#include <fw_limits.h>
+#include <fw_lock.h>
+#include <fw_list.h>
 #include <fw_components.h>
+#include <fw_helper.h>
+#include <fw_mem.h>
 #include <fw_task.h>
-
 #include <fw_debug.h>
-
+#include <fw_comm.h>
 
 #include <topics/admit.h>
 #include <topics/block.h>
 #include <topics/relinquish.h>
 #include <topics/unblock.h>
 
+/**
+ * The pipe subsystem is partially presented as a component to the rest of
+ * the system
+ */
+static fw_component_inst_t fw_pipe_termination;
+
+fw_pipe_t *fw_pipe_alloc(void)
+{
+       static int i=1;
+
+       fw_pipe_t *_new;
+
+       if(i>=FW_MAX_PIPES)
+               return NULL;
+
+       _new = fw_malloc(sizeof(fw_pipe_t));
+
+       if(_new == NULL)
+               return NULL;
+
+       _new->id = i++;
+
+       FW_LIST_INIT(_new->tasks_list);
+       FW_LIST_INIT(_new->tasks_added);
+       FW_LIST_INIT(_new->tasks_removed);
+       FW_LIST_INIT(_new->tasks_moved);
+
+       fw_spin_lock_init(&_new->lock);
+
+       _new->out = &fw_pipe_termination;
+       _new->in = &fw_pipe_termination;
+
+       return _new;
+}
+
+void fw_pipe_free(fw_pipe_t *pipe)
+{
+       fw_free(pipe);
+}
+
+int fw_pipe_task_init(fw_component_inst_t *self, fw_task_t *task)
+{
+       // self is not needed here, because we have only one pipe subsystem
+       UNUSED(self);
+
+       // The pipe subsystem does not need the PCB so far.
+       UNUSED(task);
+
+       return 0;
+}
+
+void fw_pipe_task_destroy(fw_component_inst_t *self, fw_task_t *task)
+{
+       // self is not needed here, because we have only one pipe subsystem
+       UNUSED(self);
+
+       // The pipe subsystem does not need the PCB so far.
+       UNUSED(task);
+}
+
+/**
+ * \brief Termination of a pipe.
+ *
+ * If a pipe is the last in the pipeline, information is and cannot be further
+ * forwarded. This function ensures that the end of the pipeline stays clean.
+ * It empties the pipe and frees the last lock.
+ *
+ * @param self Not considered and only for compatibility. Ther is only one pipe
+ * subsystem
+ * @param pipe The pipe that should be terminated.
+ */
+static void fw_pipe_termination_update(fw_component_inst_t *self, fw_pipe_t *pipe)
+{
+       fw_task_t *pos, *n;
+
+       // self is not needed here, because we have only one pipe subsystem
+       UNUSED(self);
+
+       fw_spin_lock(&pipe->lock);
+
+       fw_list_for_each_entry_safe(pos,n,(&pipe->tasks_added),pipe_pcb[pipe->id].added) {
+               fw_list_del(&pos->pipe_pcb[pipe->id].added);
+       }
+
+       fw_list_for_each_entry_safe(pos,n,(&pipe->tasks_removed),pipe_pcb[pipe->id].removed) {
+               fw_list_del(&pos->pipe_pcb[pipe->id].removed);
+       }
+
+       fw_list_for_each_entry_safe(pos,n,(&pipe->tasks_moved),pipe_pcb[pipe->id].moved) {
+               fw_list_del(&pos->pipe_pcb[pipe->id].moved);
+       }
+
+       fw_spin_unlock(&pipe->lock);
+}
 
 /**
  * The pipe for all available tasks that are ready for scheduling.
@@ -154,29 +251,8 @@ static void __fw_unblock(fw_component_inst_t *self, fw_unblock_msg_t *unblock)
        fw_fw_ready_pipe->out->ops.pipe_update(fw_fw_ready_pipe->out, fw_fw_ready_pipe);
 }
 
-void fw_schedule(int pe)
-{
-       struct fw_task *next_task = NULL;
-
-       if (!fw_list_empty(&fw_fw_dispatch_pipe[pe]->tasks_list)) {
-               next_task = fw_list_first_entry(&fw_fw_dispatch_pipe[pe]->tasks_list,fw_task_t,pipe_pcb[fw_fw_dispatch_pipe[pe]->id].list);
-               next_task->state = FW_RUNNING;
+int fw_pipes_init() {
 
-               fw_spin_lock(&fw_fw_ready_pipe->lock);
-               fw_list_del(&next_task->pipe_pcb[fw_fw_ready_pipe->id].list);
-               fw_list_add_tail(&next_task->pipe_pcb[fw_fw_ready_pipe->id].removed, &fw_fw_ready_pipe->tasks_removed);
-               fw_spin_unlock(&fw_fw_ready_pipe->lock);
-
-               fw_fw_ready_pipe->out->ops.pipe_update(fw_fw_ready_pipe->out, fw_fw_ready_pipe);
-
-               //FW_DEBUG_PRINT("__fw_schedule: %s on CPU(%i) state:%i (%p->%p)\n", FW_TASK_NAME(next_task), FW_CPU_ID(), next_task->state, next_task, next_task->real_task);
-       }
-
-       os_schedule(next_task, pe);
-}
-
-void fw_sched_init(void)
-{
        fw_fw_ready_pipe = fw_pipe_alloc();
 
        fw_subscribe(FW_TOPIC_ADMIT, __fw_admit, NULL);
@@ -184,27 +260,8 @@ void fw_sched_init(void)
        fw_subscribe(FW_TOPIC_UNBLOCK, __fw_unblock, NULL);
        fw_subscribe(FW_TOPIC_BLOCK, __fw_block, NULL);
        fw_subscribe(FW_TOPIC_RELEASE, __fw_release, NULL);
-}
 
-fw_task_t* fw_current_task(int pe)
-{
-       return os_current_task(pe);
-}
-
-void fw_need_resched(struct fw_task *task)
-{
-       os_need_resched(task);
-}
+       fw_pipe_termination.ops.pipe_update = fw_pipe_termination_update;
 
-#ifdef FW_SMP
-void fw_set_task_cpu(struct fw_task *task, int cpu)
-{
-       task->cpu = cpu;
-       os_set_task_cpu(task, cpu);
-}
-
-void fw_send_ipi(int cpu)
-{
-       os_send_ipi(cpu);
+       return 0;
 }
-#endif
similarity index 85%
rename from framework/lib/fw_platform.c
rename to framework/fw/fw_platform.c
index b5afb87..518fade 100644 (file)
@@ -7,7 +7,9 @@
  * current platform. For now it only gives very basic information.
  */
 
-#include <os.h>
+#include <fw_platform.h>
+
+#ifdef COBAS_DEBUG
 
 int fw_num_cpus(void){
        return os_num_cpus();
@@ -16,3 +18,5 @@ int fw_num_cpus(void){
 int fw_cpu_id(void){
        return os_cpu_id();
 }
+
+#endif
diff --git a/framework/fw/fw_sched.c b/framework/fw/fw_sched.c
new file mode 100644 (file)
index 0000000..f22d980
--- /dev/null
@@ -0,0 +1,41 @@
+/**
+ * @file fw_sched.c
+ * @author Anselm Busse
+ * @date 25 Jan 2015
+ *
+ * This file contains the implementation for task management and rescheduling
+ * in CoBaS.
+ */
+
+#include <fw_types.h>
+#include <fw_lock.h>
+#include <fw_sched.h>
+#include <fw_pipe.h>
+#include <fw_comm.h>
+#include <fw_components.h>
+#include <fw_task.h>
+
+#include <fw_debug.h>
+
+fw_target_task_t *fw_schedule(int pe)
+{
+       struct fw_task *next_task = NULL;
+
+       if (!fw_list_empty(&fw_fw_dispatch_pipe[pe]->tasks_list)) {
+               next_task = fw_list_first_entry(&fw_fw_dispatch_pipe[pe]->tasks_list,fw_task_t,pipe_pcb[fw_fw_dispatch_pipe[pe]->id].list);
+               next_task->state = FW_RUNNING;
+
+               fw_spin_lock(&fw_fw_ready_pipe->lock);
+               fw_list_del(&next_task->pipe_pcb[fw_fw_ready_pipe->id].list);
+               fw_list_add_tail(&next_task->pipe_pcb[fw_fw_ready_pipe->id].removed, &fw_fw_ready_pipe->tasks_removed);
+               fw_spin_unlock(&fw_fw_ready_pipe->lock);
+
+               fw_fw_ready_pipe->out->ops.pipe_update(fw_fw_ready_pipe->out, fw_fw_ready_pipe);
+
+               //FW_DEBUG_PRINT("__fw_schedule: %s on CPU(%i) state:%i (%p->%p)\n", FW_TASK_NAME(next_task), FW_CPU_ID(), next_task->state, next_task, next_task->real_task);
+       }
+
+       return next_task == NULL ? NULL : next_task->os_task;
+}
+
+
similarity index 89%
rename from framework/include/fw_debug.h
rename to framework/fw/include/fw_debug.h
index 5df0d17..efec0c1 100644 (file)
@@ -11,9 +11,7 @@
 
 #include <fw_helper.h>
 
-#define FW_DEBUG 1
-
-#ifdef FW_DEBUG
+#ifdef COBAS_DEBUG
        #define __fw_assert(cond, file, line) fw_error("%s:%d - Assertion failed: %s\n", file, line, cond)
 
        #define FW_DEBUG_PRINT(fmt, ...) fw_printf(fmt, ## __VA_ARGS__)
        #define FW_ASSERT(x)         ((void)((x) ? 0 : __fw_assert(#x, __FILE__, __LINE__)))
        #define FW_ASSERT_H(x, help) ((void)((x) ? 0 : __fw_assert(help " (" #x ")", __FILE__, __LINE__)))
 
-#else /* FW_DEBUG */
+#else /* COBAS_DEBUG */
        #define FW_DEBUG_PRINT(fmt, ...)
 
        #define FW_ASSERT(x)
        #define FW_ASSERT_H(x, help)
-#endif /* FW_DEBUG */
+#endif /* COBAS_DEBUG */
 
 #endif /* FW_DEBUG_H_ */
similarity index 91%
rename from framework/include/fw_pipe.h
rename to framework/fw/include/fw_pipe.h
index e7386f8..5b9bbbf 100644 (file)
@@ -31,6 +31,15 @@ typedef struct fw_pipe {
        fw_component_inst_t *out;               /**< Reference to the target component instance connected to the pipe. */
 } fw_pipe_t;
 
+/**
+ * The pipe for all available tasks that are ready for scheduling.
+ */
+extern fw_pipe_t *fw_fw_ready_pipe;
+/**
+ * The pipes that are considered during dispatching.
+ */
+extern fw_pipe_t **fw_fw_dispatch_pipe;
+
 /**
  TODO
  */
similarity index 70%
rename from framework/include/fw_platform.h
rename to framework/fw/include/fw_platform.h
index c5af51e..e3cf2cc 100644 (file)
@@ -9,6 +9,8 @@
 #ifndef FW_PLAFORM_H_
 #define FW_PLAFORM_H_
 
+#include "generated/fw_target_helper.h"
+
 /*
  * CPU information.
  */
  *
  * @return Current number of processing elements.
  */
-int fw_num_cpus(void);
+#ifndef COBAS_DEBUG
+       #define fw_num_cpus() os_num_cpus()
+#else
+       int fw_num_cpus(void);
+#endif
 
 /**
  * \brief Obtains the id of the current PE.
  *
  * @return The id of the current PE.
  */
-int fw_cpu_id(void);
+#ifndef COBAS_DEBUG
+       #define fw_cpu_id() os_cpu_id()
+#else
+       int fw_cpu_id(void);
+#endif
 
 #endif /* FW_PLAFORM_H_ */
diff --git a/framework/fw/include/fw_sched.h b/framework/fw/include/fw_sched.h
new file mode 100644 (file)
index 0000000..0788d0a
--- /dev/null
@@ -0,0 +1,27 @@
+/**
+ * @file fw_sched.h
+ * @author Anselm Busse
+ * @date 25 Jan 2015
+ *
+ * This file contains the interface description for CoBaS function that are
+ * related to the rescheduling of tasks.
+ */
+
+#ifndef FW_SCHED_H_
+#define FW_SCHED_H_
+
+#include <fw_types.h>
+
+/**
+ * \brief Dispatches the next task on the requested processing element.
+ *
+ * This function selects a new task for the given processing element and calls
+ * the runtime system via the os_dispatch(fw_task_t*) function. The execution
+ * path will, in general, leave the framework at this point.
+ *
+ * @param pe The processing element that needs a new task assigned.
+ */
+fw_target_task_t *fw_schedule(int pe);
+
+
+#endif /* FW_SCHED_H_ */
diff --git a/framework/fw/include/fw_target.h b/framework/fw/include/fw_target.h
new file mode 100644 (file)
index 0000000..8800b1d
--- /dev/null
@@ -0,0 +1,18 @@
+/*
+ * fw_target.h
+ *
+ *  Created on: 21.02.2016
+ *      Author: abusse
+ */
+
+#ifndef FW_TARGET_H_
+#define FW_TARGET_H_
+
+#include <os_target.h>
+
+#ifdef COBAS_DEBUG
+
+
+#endif
+
+#endif /* FW_TARGET_H_ */
similarity index 94%
rename from framework/include/fw_task.h
rename to framework/fw/include/fw_task.h
index a133e5a..0a4444c 100644 (file)
@@ -28,7 +28,7 @@ typedef enum fw_task_state {
  */
 typedef struct fw_task {
        enum fw_task_state state;                       /**< The state of the current task. */
-       os_task_t *os_task;                                     /**< A reference to the legacy PCB in the runtime environment */
+       fw_target_task_t *os_task;                                      /**< A reference to the legacy PCB in the runtime environment */
        unsigned int cpu;
        fw_task_context_t *task_context;
        fw_pipe_pcb_t pipe_pcb[FW_MAX_PIPES];
similarity index 58%
rename from framework/include/fw_types.h
rename to framework/fw/include/fw_types.h
index ff8f483..6f03fd0 100644 (file)
@@ -1,8 +1,7 @@
 #ifndef FW_TYPES_H_
 #define FW_TYPES_H_
 
-#include <os.h>
-
+#include <fw_target_types.h>
 #include <fw_limits.h>
 #include <fw_pipe_pcb.h>
 
        #define NULL (void *)0
 #endif
 
-#define fw_size_t os_size_t
-
 
 typedef struct fw_list_head fw_list_head_t;
 
 typedef struct fw_sched_chain fw_sched_chain_t;
 
-/**
- * The type of the legacy PCB of the runtime system. Defaults to <code>void</code>
- * if not defined by the target runtime system.
- */
-#define os_task_t __os_task_t
-/**
- * The type of the process context that is saved when a process is evaded from
- * the processing element.
- */
-#define fw_task_context_t os_task_context_t
-
-
 typedef struct fw_pipe fw_pipe_t;
 typedef struct fw_component_inst fw_component_inst_t;
 
diff --git a/framework/fw/include/generated/fw_target_helper.h b/framework/fw/include/generated/fw_target_helper.h
new file mode 100644 (file)
index 0000000..bcb64f8
--- /dev/null
@@ -0,0 +1,91 @@
+// This file is generated by scripts/fw_target.h, do not edit!!!
+
+#ifndef GENERATED_FW_TARGET_HELPER_H_
+#define GENERATED_FW_TARGET_HELPER_H_
+
+#include <os_target.h>
+
+
+// symbols defined in lib/include/fw_irq.h
+
+#ifndef os_irq_flags
+       #error os_irq_flags not defined, see lib/include/fw_irq.h
+#endif
+
+#ifndef os_local_irq_disable
+       #error os_local_irq_disable not defined, see lib/include/fw_irq.h
+#endif
+
+#ifndef os_local_irq_enable
+       #error os_local_irq_enable not defined, see lib/include/fw_irq.h
+#endif
+
+#ifndef os_local_irq_save
+       #error os_local_irq_save not defined, see lib/include/fw_irq.h
+#endif
+
+#ifndef os_local_irq_restore
+       #error os_local_irq_restore not defined, see lib/include/fw_irq.h
+#endif
+
+// symbols defined in lib/include/fw_list.h
+
+// symbols defined in lib/include/fw_lock.h
+
+#ifndef os_spinlock_t
+       #error os_spinlock_t not defined, see lib/include/fw_lock.h
+#endif
+
+#ifndef os_spin_lock_init
+       #error os_spin_lock_init not defined, see lib/include/fw_lock.h
+#endif
+
+#ifndef os_spin_lock
+       #error os_spin_lock not defined, see lib/include/fw_lock.h
+#endif
+
+#ifndef os_spin_unlock
+       #error os_spin_unlock not defined, see lib/include/fw_lock.h
+#endif
+
+#ifndef os_spin_lock_irq
+       #error os_spin_lock_irq not defined, see lib/include/fw_lock.h
+#endif
+
+#ifndef os_spin_unlock_irq
+       #error os_spin_unlock_irq not defined, see lib/include/fw_lock.h
+#endif
+
+#ifndef os_spin_lock_irqsave
+       #error os_spin_lock_irqsave not defined, see lib/include/fw_lock.h
+#endif
+
+#ifndef os_spin_unlock_irqrestore
+       #error os_spin_unlock_irqrestore not defined, see lib/include/fw_lock.h
+#endif
+
+// symbols defined in lib/include/fw_mem.h
+
+#ifndef os_malloc
+       #error os_malloc not defined, see lib/include/fw_mem.h
+#endif
+
+#ifndef os_free
+       #error os_free not defined, see lib/include/fw_mem.h
+#endif
+
+// symbols defined in lib/include/fw_target_types.h
+
+#ifndef os_size_t
+       #error os_size_t not defined, see lib/include/fw_target_types.h
+#endif
+
+#ifndef os_task_t
+       #error os_task_t not defined, see lib/include/fw_target_types.h
+#endif
+
+#ifndef os_task_context_t
+       #error os_task_context_t not defined, see lib/include/fw_target_types.h
+#endif
+
+#endif /* GENERATED_FW_TARGET_HELPER_H_ */
similarity index 77%
rename from framework/include/os.h
rename to framework/fw/include/os.h
index f2512f1..5cdba27 100644 (file)
 #define OS_H_
 
 #include <os/helper.h>
-#include <os/irq.h>
-#include <os/lock.h>
-#include <os/mem.h>
-#include <os/platform.h>
 #include <os/sched.h>
-#include <os/target.h>
-#include <os/types.h>
 
 
 /**
diff --git a/framework/include/fw_sched.h b/framework/include/fw_sched.h
deleted file mode 100644 (file)
index 7a96447..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-/**
- * @file fw_sched.h
- * @author Anselm Busse
- * @date 25 Jan 2015
- *
- * This file contains the interface description for CoBaS function that are
- * related to the rescheduling of tasks.
- */
-
-#ifndef FW_SCHED_H_
-#define FW_SCHED_H_
-
-#include <fw_types.h>
-
-/**
- * The pipe for all available tasks that are ready for scheduling.
- */
-extern fw_pipe_t *fw_fw_ready_pipe;
-/**
- * The pipes that are considered during dispatching.
- */
-extern fw_pipe_t **fw_fw_dispatch_pipe;
-
-/**
- * \brief Initializes the CoBaS scheduling subsystem.
- */
-void fw_sched_init(void);
-
-
-/**
- * \brief Dispatches the next task on the requested processing element.
- *
- * This function selects a new task for the given processing element and calls
- * the runtime system via the os_dispatch(fw_task_t*) function. The execution
- * path will, in general, leave the framework at this point.
- *
- * @param pe The processing element that needs a new task assigned.
- */
-void fw_schedule(int pe);
-
-/**
- * \brief      Returns the currently running task on the given processing unit.
- *
- * @param      pe      PE to look on.
- * @return     The currently running task.
- */
-struct fw_task *fw_current_task(int pe);
-
-/**
- * \brief      Sets the CPU value of the given task.
- *
- * @param      task    Task that needs to be modified.
- * @param      cpu     Remote CPU.
- */
-void fw_set_task_cpu(struct fw_task *task, int cpu);
-
-/**
- * \brief      Prints task specific information to a given buffer.
- *
- * @param      task    Task of desire.
- * @param      buf             Space where the task information will be written to.
- * @param      length  The maximum number of writable characters.
- * @return     Number of written characters.
- */
-int fw_task_info(struct fw_task *task, char *buf, int length);
-
-/**
- * \brief      Send an interrupt to remote CPU.
- *
- * @param      cpu     Remote CPU.
- */
-void fw_send_ipi(int cpu);
-
-
-#endif /* FW_SCHED_H_ */
index 07970d4..5475d8d 100644 (file)
@@ -8,7 +8,7 @@
 #ifndef OS_HELPER_H_
 #define OS_HELPER_H_
 
-#include <os/target.h>
+#include <os_target.h>
 
 #ifndef os_printf
        #warning 'os_printf' not defined, debug output not available
diff --git a/framework/include/os/irq.h b/framework/include/os/irq.h
deleted file mode 100644 (file)
index 38e6d27..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * os_irq.h
- *
- *  Created on: 14.09.2015
- *      Author: abusse
- */
-
-#ifndef _OS_IRQ_H_
-#define _OS_IRQ_H_
-
-#include <os/target.h>
-#include <os/types.h>
-
-#ifndef os_irq_flags
-#error os_irq_flags not defined
-#endif
-
-#ifndef os_local_irq_disable
-inline void os_local_irq_disable();
-#endif
-
-#ifndef os_local_irq_enable
-inline void os_local_irq_enable();
-#endif
-
-#ifndef os_local_irq_save
-inline void os_local_irq_save(os_irq_flags flags);
-#endif
-
-#ifndef os_local_irq_restore
-inline void os_local_irq_restore(os_irq_flags flags);
-#endif
-
-
-#endif /* _OS_IRQ_H_ */
diff --git a/framework/include/os/lock.h b/framework/include/os/lock.h
deleted file mode 100644 (file)
index a93d640..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * os_lock.h
- *
- *  Created on: 10.12.2013
- *      Author: jkrieg
- */
-
-#ifndef OS_LOCK_H_
-#define OS_LOCK_H_
-
-#include <os/target.h>
-#include <os/irq.h>
-
-
-#ifndef OS_DEFINE_SPINLOCK
-       #error 'OS_DEFINE_SPINLOCK' not defined for the current platform
-#endif
-
-#ifndef os_spin_lock
-       #error 'os_spinlock' not defined for the current platform
-#endif
-
-#ifndef os_spin_unlock
-       #error 'os_spinunlock' not defined for the current platform
-#endif
-
-#ifndef os_spin_lock_irq
-       #error 'os_spinlock_irq' not defined for the current platform
-#endif
-
-#ifndef os_spin_unlock_irq
-       #error 'os_spinunlock_irq' not defined for the current platform
-#endif
-
-#ifndef os_spin_lock_irqsave
-       #error 'os_spinlock_irqsave' not defined for the current platform
-#endif
-
-#ifndef os_spin_unlock_irqrestore
-       #error 'os_spinunlock_irqrestore' not defined for the current platform
-#endif
-
-#ifndef os_spin_lock_init
-       #error 'os_spin_lock_init' not defined for the current platform
-#endif
-
-#endif /* OS_LOCK_H_ */
diff --git a/framework/include/os/mem.h b/framework/include/os/mem.h
deleted file mode 100644 (file)
index 4a82015..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * mem.h
- *
- *  Created on: 16.02.2016
- *      Author: abusse
- */
-
-#ifndef OS_MEM_H_
-#define OS_MEM_H_
-
-#include <os/target.h>
-#include <os/types.h>
-
-/**
- * \brief Dynamic allocation of memory.
- *
- * @param size The amount of memory to allocate.
- * @return A pointer to the allocated memory.
- */
-#ifndef os_malloc
-void *os_malloc(os_size_t size);
-#endif
-
-/**
- * \brief Releases a dynamically allocated chunk of memory.
- *
- * @param ptr Memory region to release.
- */
-#ifndef os_free
-void os_free(void* addr);
-#endif
-
-
-#endif /* OS_MEM_H_ */
diff --git a/framework/include/os/platform.h b/framework/include/os/platform.h
deleted file mode 100644 (file)
index ebc0d2c..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * platform.h
- *
- *  Created on: 16.02.2016
- *      Author: abusse
- */
-
-#ifndef OS_PLATFORM_H_
-#define OS_PLATFORM_H_
-
-#include <os/target.h>
-
-/*
- * CPU information.
- */
-#ifndef os_num_cpus
-       #warning 'os_num_cpus' not defined, assuming 1 (one!) core
-       #define os_num_cpus 1
-#endif
-#ifndef os_cpu_id
-       #define os_cpu_id() 0
-#endif
-
-#endif /* OS_PLATFORM_H_ */
index f4beaeb..6eb2195 100644 (file)
@@ -8,7 +8,7 @@
 #ifndef SCHED_H_
 #define SCHED_H_
 
-#include <os/target.h>
+#include <fw_target.h>
 
 typedef struct fw_task fw_task_t;
 
@@ -52,18 +52,4 @@ void os_set_task_cpu(fw_task_t *task, int cpu);
  */
 struct fw_task* os_idle_task(int cpu);
 
-/**
- * \brief Task needs to be rescheduled.
- *
- * @param task Task which is out of timeslice.
- */
-void os_need_resched(fw_task_t *task);
-
-/**
- * \brief      Send an interrupt to remote CPU.
- *
- * @param      cpu     Remote CPU.
- */
-void os_send_ipi(int cpu);
-
 #endif /* SCHED_H_ */
diff --git a/framework/include/os/target.h b/framework/include/os/target.h
deleted file mode 100644 (file)
index ba56b58..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * os_target.h
- *
- *  Created on: 14.09.2015
- *      Author: abusse
- */
-
-#ifndef _OS_TARGET_H_
-#define _OS_TARGET_H_
-
-#if defined (FW_OS_LINUX)
-       #include <os/targets/linux.h>
-       #define FW_OS_TARGET_STRING "Linux"
-#elif defined (FW_OS_FREEBSD)
-       #include <os/targets/fbsd.h>
-       #define FW_OS_TARGET_STRING "Free BSD"
-#elif defined (FW_OS_BERTOS)
-       #include <os/targets/bertos.h>
-       #define FW_OS_TARGET_STRING "BERTOS"
-#else
-       #error No operating system specified.
-#endif
-
-#endif /* _OS_TARGET_H_ */
index 3ca504a..3628583 100644 (file)
@@ -8,22 +8,26 @@
 
 #include <fw_irq.h>
 
-inline void fw_local_irq_disable(void)
+#ifdef COBAS_DEBUG
+
+void fw_local_irq_disable(void)
 {
        os_local_irq_disable();
 }
 
-inline void fw_local_irq_enable(void)
+void fw_local_irq_enable(void)
 {
        os_local_irq_enable();
 }
 
-inline void fw_local_irq_save(fw_irq_flags flags)
+void fw_local_irq_save(fw_irq_flags flags)
 {
        os_local_irq_save(flags);
 }
 
-inline void fw_local_irq_restore(fw_irq_flags flags)
+void fw_local_irq_restore(fw_irq_flags flags)
 {
        os_local_irq_restore(flags);
 }
+
+#endif
diff --git a/framework/lib/fw_lock.c b/framework/lib/fw_lock.c
new file mode 100644 (file)
index 0000000..0a4c704
--- /dev/null
@@ -0,0 +1,41 @@
+#include <fw_lock.h>
+
+#ifdef COBAS_DEBUG
+
+void fw_spin_lock_init(fw_spinlock_t *lock)
+{
+       os_spin_lock_init(lock);
+}
+
+
+void fw_spin_lock(fw_spinlock_t *lock)
+{
+       os_spin_lock(lock);
+}
+
+void fw_spin_unlock(fw_spinlock_t *lock)
+{
+       os_spin_unlock(lock);
+}
+
+void fw_spin_lock_irq(fw_spinlock_t *lock)
+{
+       os_spin_lock_irq(lock);
+}
+
+void fw_spin_unlock_irq(fw_spinlock_t *lock)
+{
+       os_spin_unlock_irq(lock);
+}
+
+void fw_spin_lock_irqsave(fw_spinlock_t *lock, fw_irq_flags *flags)
+{
+       os_spin_lock_irqsave(lock, flags);
+}
+
+void fw_spin_unlock_irqrestore(fw_spinlock_t *lock, fw_irq_flags *flags)
+{
+       os_spin_unlock_irqrestore(lock, flags);
+}
+
+#endif
index 3f41c4d..24ab118 100644 (file)
@@ -6,9 +6,9 @@
  * This file implements the OS independent memory management functions for CoBaS.
  */
 
-#include <fw_mem.h>
+#include <fw_types.h>
 
-#include <os.h>
+#include "../fw/include/generated/fw_target_helper.h"
 
 void *fw_malloc(fw_size_t size)
 {
diff --git a/framework/lib/fw_pipe.c b/framework/lib/fw_pipe.c
deleted file mode 100644 (file)
index cfe428c..0000000
+++ /dev/null
@@ -1,123 +0,0 @@
-/**
- * @file fw_pipe.h
- * @author Anselm Busse
- * @date 9 Sep 2015
- * @brief Implementation of the CoBaS pipe subsystem.
- *
- * This is the interface definition for pipes in CoBaS. Pipes are connecting
- * component instances with each other and are the main means to propagate task
- * sets and orders inside the framework.
- */
-
-#include <fw_pipe.h>
-#include <fw_pipe_pcb.h>
-#include <fw_limits.h>
-#include <fw_lock.h>
-#include <fw_list.h>
-#include <fw_components.h>
-#include <fw_helper.h>
-#include <fw_mem.h>
-#include <fw_task.h>
-
-
-/**
- * The pipe subsystem is partially presented as a component to the rest of
- * the system
- */
-static fw_component_inst_t fw_pipe_termination;
-
-fw_pipe_t *fw_pipe_alloc(void)
-{
-       static int i=1;
-
-       fw_pipe_t *_new;
-
-       if(i>=FW_MAX_PIPES)
-               return NULL;
-
-       _new = fw_malloc(sizeof(fw_pipe_t));
-
-       if(_new == NULL)
-               return NULL;
-
-       _new->id = i++;
-
-       FW_LIST_INIT(_new->tasks_list);
-       FW_LIST_INIT(_new->tasks_added);
-       FW_LIST_INIT(_new->tasks_removed);
-       FW_LIST_INIT(_new->tasks_moved);
-
-       fw_spin_lock_init(&_new->lock);
-
-       _new->out = &fw_pipe_termination;
-       _new->in = &fw_pipe_termination;
-
-       return _new;
-}
-
-void fw_pipe_free(fw_pipe_t *pipe)
-{
-       fw_free(pipe);
-}
-
-int fw_pipe_task_init(fw_component_inst_t *self, fw_task_t *task)
-{
-       // self is not needed here, because we have only one pipe subsystem
-       UNUSED(self);
-
-       // The pipe subsystem does not need the PCB so far.
-       UNUSED(task);
-
-       return 0;
-}
-
-void fw_pipe_task_destroy(fw_component_inst_t *self, fw_task_t *task)
-{
-       // self is not needed here, because we have only one pipe subsystem
-       UNUSED(self);
-
-       // The pipe subsystem does not need the PCB so far.
-       UNUSED(task);
-}
-
-/**
- * \brief Termination of a pipe.
- *
- * If a pipe is the last in the pipeline, information is and cannot be further
- * forwarded. This function ensures that the end of the pipeline stays clean.
- * It empties the pipe and frees the last lock.
- *
- * @param self Not considered and only for compatibility. Ther is only one pipe
- * subsystem
- * @param pipe The pipe that should be terminated.
- */
-static void fw_pipe_termination_update(fw_component_inst_t *self, fw_pipe_t *pipe)
-{
-       fw_task_t *pos, *n;
-
-       // self is not needed here, because we have only one pipe subsystem
-       UNUSED(self);
-
-       fw_spin_lock(&pipe->lock);
-
-       fw_list_for_each_entry_safe(pos,n,(&pipe->tasks_added),pipe_pcb[pipe->id].added) {
-               fw_list_del(&pos->pipe_pcb[pipe->id].added);
-       }
-
-       fw_list_for_each_entry_safe(pos,n,(&pipe->tasks_removed),pipe_pcb[pipe->id].removed) {
-               fw_list_del(&pos->pipe_pcb[pipe->id].removed);
-       }
-
-       fw_list_for_each_entry_safe(pos,n,(&pipe->tasks_moved),pipe_pcb[pipe->id].moved) {
-               fw_list_del(&pos->pipe_pcb[pipe->id].moved);
-       }
-
-       fw_spin_unlock(&pipe->lock);
-}
-
-int fw_pipes_init() {
-
-       fw_pipe_termination.ops.pipe_update = fw_pipe_termination_update;
-
-       return 0;
-}
similarity index 62%
rename from framework/include/fw_irq.h
rename to framework/lib/include/fw_irq.h
index 6ba4a0b..e85cb64 100644 (file)
@@ -10,7 +10,7 @@
 #ifndef _FW_IRQ_H_
 #define _FW_IRQ_H_
 
-#include <os/irq.h>
+#include "../../fw/include/generated/fw_target_helper.h"
 
 /**
  * This type maps the generic CoBaS interrupt flags to the operating system
 /**
  * Disables the interrupts of the current processing element.
  */
-inline void fw_local_irq_disable(void);
+#ifndef COBAS_DEBUG
+       #define fw_local_irq_disable() os_local_irq_disable()
+#else
+       void fw_local_irq_disable(void);
+#endif
 
 /**
  * Enables the interrupts of the current processing element.
  */
-inline void fw_local_irq_enable(void);
+#ifndef COBAS_DEBUG
+       #define fw_local_irq_enable() os_local_irq_enable()
+#else
+       void fw_local_irq_enable(void);
+#endif
 
 /**
  * Disables the interrupts of the current processing element and safes the
@@ -35,7 +43,11 @@ inline void fw_local_irq_enable(void);
  *
  * @param flags The variable to write the interrupt flags to.
  */
-inline void fw_local_irq_save(fw_irq_flags flags);
+#ifndef COBAS_DEBUG
+       #define fw_local_irq_save(flags) os_local_irq_save(flags)
+#else
+       void fw_local_irq_save(fw_irq_flags flags);
+#endif
 
 /**
  * Eneables the interupts of the current processing element and restores the
@@ -43,7 +55,11 @@ inline void fw_local_irq_save(fw_irq_flags flags);
  *
  * @param flags The intrrupt flags that should be restored.
  */
-inline void fw_local_irq_restore(fw_irq_flags flags);
+#ifndef COBAS_DEBUG
+       #define fw_local_irq_restore(flags) os_local_irq_restore(flags)
+#else
+       void fw_local_irq_restore(fw_irq_flags flags);
+#endif
 
 
 #endif /* _FW_IRQ_H_ */
similarity index 56%
rename from framework/include/fw_lock.h
rename to framework/lib/include/fw_lock.h
index 911835e..2f98933 100644 (file)
 #ifndef FW_LOCK_H_
 #define FW_LOCK_H_
 
-#include <os.h>
+#include <fw_irq.h>
+#include "../../fw/include/generated/fw_target_helper.h"
 
 #define fw_spinlock_t os_spinlock_t
 
-
 /**
  * Defines an unlocked spinlock with the given name.
  */
 #define FW_DEFINE_SPINLOCK(name) OS_DEFINE_SPINLOCK(name)
 
+/**
+ * \brief Initializes a spinlock.
+ *
+ * \@param lock The spinlock that is initialized.
+ */
+#ifndef COBAS_DEBUG
+       #define fw_spin_lock_init(lock) os_spin_lock_init(lock)
+#else
+       void fw_spin_lock_init(fw_spinlock_t *lock);
+#endif
 
 /**
  * \brief Locks the given spinlock.
  *
  * @param lock The lock to operate on.
  */
-#define fw_spin_lock(lock) os_spin_lock(lock)
+#ifndef COBAS_DEBUG
+       #define fw_spin_lock(lock) os_spin_lock(lock)
+#else
+       void fw_spin_lock(fw_spinlock_t *lock);
+#endif
 
 /**
  * \brief Unlocks the given spinlock.
  *
  * @param lock The lock to operate on.
  */
-#define fw_spin_unlock(lock) os_spin_unlock(lock)
+#ifndef COBAS_DEBUG
+       #define fw_spin_unlock(lock) os_spin_unlock(lock)
+#else
+       void fw_spin_unlock(fw_spinlock_t *lock);
+#endif
 
 /**
  * \brief Locks the given spinlock and disables interrupts.
  *
  * @param lock The lock to operate on.
  */
-#define fw_spin_lock_irq(lock) os_spin_lock_irq(lock)
+#ifndef COBAS_DEBUG
+       #define fw_spin_lock_irq(lock) os_spin_lock_irq(lock)
+#else
+       void fw_spin_lock_irq(fw_spinlock_t *lock);
+#endif
 
 /**
  * \brief Unlocks the given spinlock and enables the interrupts
  *
  * @param lock The lock to operate on.
  */
-#define fw_spin_unlock_irq(lock) os_unlock_irq(lock)
+#ifndef COBAS_DEBUG
+       #define fw_spin_unlock_irq(lock) os_spin_unlock_irq(lock)
+#else
+       void fw_spin_unlock_irq(fw_spinlock_t *lock);
+#endif
 
 /**
  * \brief Locks the given spinlock, disables interrupts and save the interrupt
  * state
  *
  * This function locks the given spinlock, disables the interrupts and safe the
- * interrupt states. It willbspin until capable to do so.
+ * interrupt states. It will spin until capable to do so.
  *
  * @param lock The lock to operate on.
  * @param flags The flags to save.
  */
-#define fw_spin_lock_irqsave(lock, flags) os_spin_lock_irqsave(lock, flags)
+#ifndef COBAS_DEBUG
+       #define fw_spin_lock_irqsave(lock, flags) os_spin_lock_irqsave(lock, flags)
+#else
+       void fw_spin_lock_irqsave(fw_spinlock_t *lock, fw_irq_flags *flags);
+#endif
 
 /**
  * \brief Unlocks the given spinlock, enables the interrupts and restores the
  * @param lock The lock to operate on.
  * @param flags The flags to restore.
  */
-#define fw_spin_unlock_irqrestore(lock, flags) os_spin_unlock_irqrestore(lock, flags)
-
-#define fw_spin_lock_init(lock) os_spin_lock_init(lock)
+#ifndef COBAS_DEBUG
+       #define fw_spin_unlock_irqrestore(lock, flags) os_spin_unlock_irqrestore(lock, flags)
+#else
+       void fw_spin_unlock_irqrestore(fw_spinlock_t *lock, fw_irq_flags *flags);
+#endif
 
 #endif /* FW_LOCK_H_ */
similarity index 70%
rename from framework/include/fw_mem.h
rename to framework/lib/include/fw_mem.h
index 3126235..27ef215 100644 (file)
  * @param size The amount of memory to allocate.
  * @return A pointer to the allocated memory.
  */
-void *fw_malloc(fw_size_t size);
+#ifndef COBAS_DEBUG
+       #define fw_malloc(size) os_malloc(size)
+#else
+       void *fw_malloc(fw_size_t size);
+#endif
 
 /**
  * \brief Releases a dynamically allocated chunk of memory.
  *
  * @param addr Memory region to release.
  */
-void fw_free(void* addr);
+#ifndef COBAS_DEBUG
+       #define fw_free(addr) os_free(addr)
+#else
+       void fw_free(void* addr);
+#endif
 
 #endif /* FW_MEM_H_ */
diff --git a/framework/lib/include/fw_target_types.h b/framework/lib/include/fw_target_types.h
new file mode 100644 (file)
index 0000000..c432e84
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * fw_target_types.h
+ *
+ *  Created on: 21.02.2016
+ *      Author: abusse
+ */
+
+#ifndef FW_TARGET_TYPES_H_
+#define FW_TARGET_TYPES_H_
+
+#include <fw_target.h>
+
+/**
+ * The type indicates the size of a memory region.
+ */
+#define fw_size_t os_size_t
+
+/**
+ * The type of the legacy PCB of the runtime system. Defaults to <code>void</code>
+ * if not defined by the target runtime system.
+ */
+#define fw_target_task_t os_task_t
+
+/**
+ * The type of the process context that is saved when a process is evaded from
+ * the processing element.
+ */
+#define fw_task_context_t os_task_context_t
+
+#endif /* FW_TARGET_TYPES_H_ */
index f6604a6..7f8ba21 100644 (file)
@@ -1,28 +1,30 @@
 KBUILD_CFLAGS += -DFW_OS_LINUX
-KBUILD_CFLAGS += -Ikernel/sched/modsched/framework/include \
-                                -Ikernel/sched/modsched/framework/include/generated \
-                                -Ikernel/sched/modsched/framework/components/include
+KBUILD_CFLAGS += -Ikernel/sched/cobas/fw/include \
+                                -Ikernel/sched/cobas/fw/include/generated \
+                                -Ikernel/sched/cobas/fw/lib/include \
+                                -Ikernel/sched/cobas/fw/fw/include \
+                                -Ikernel/sched/cobas/fw/components/include
 
-obj-y += linux_sched.o os.o os_kdb.o os_sched.o os_syscall.o
-obj-y += ../../lib/fw_comm.o \
-                ../../lib/fw_components.o \
+obj-y += linux_sched.o os.o os_syscall.o
+obj-y += ../../fw/fw_comm.o \
+                ../../fw/fw_components.o \
+                ../../fw/fw_init.o \
+                ../../fw/fw_platform.o \
+                ../../fw/fw_sched.o \
+                ../../fw/fw_task.o \
                 ../../lib/fw_list.o \
-                ../../lib/fw_init.o \
                 ../../lib/fw_irq.o \
                 ../../lib/fw_mem.o \
-                ../../lib/fw_pipe.o \
-                ../../lib/fw_platform.o \
-                ../../lib/fw_sched.o \
-                ../../lib/fw_task.o 
+                ../../fw/fw_pipe.o \
+                ../../lib/fw_lock.o
+                
 
-obj-y += ../../generated/fw_comm_generated.o
-
-obj-$(CONFIG_TOPO_RR_SINGLE)   += ../../generated/topo_rr_single.o
-obj-$(CONFIG_TOPO_LB_RR_SINGLE) += ../../generated/topo_lb_rr_single.o
-obj-$(CONFIG_TOPO_LB_RR_DUAL)  += ../../generated/topo_lb_rr_dual.o
-obj-$(CONFIG_TOPO_LB_RR_FCFS)  += ../../generated/topo_lb_rr_fcfs.o
-obj-$(CONFIG_TOPO_LB_RR_QUAD)  += ../../generated/topo_lb_rr_quad.o
-obj-$(CONFIG_TOPO_LB_RR_MULTI) += ../../generated/topo_lb_rr_multi.o
+obj-$(CONFIG_TOPO_RR_SINGLE)   += ../../topos/topo_rr_single.o
+obj-$(CONFIG_TOPO_LB_RR_SINGLE) += ../../topos/topo_lb_rr_single.o
+obj-$(CONFIG_TOPO_LB_RR_DUAL)  += ../../topos/topo_lb_rr_dual.o
+obj-$(CONFIG_TOPO_LB_RR_FCFS)  += ../../topos/topo_lb_rr_fcfs.o
+obj-$(CONFIG_TOPO_LB_RR_QUAD)  += ../../topos/topo_lb_rr_quad.o
+obj-$(CONFIG_TOPO_LB_RR_MULTI) += ../../topos/topo_lb_rr_multi.o
 
 obj-$(CONFIG_MOD_TEMPLATE)                     += ../../components/template.o
 obj-$(CONFIG_MOD_ROUND_ROBIN)          += ../../components/round_robin.o
index 8b1d163..25e5162 100644 (file)
@@ -1644,7 +1644,7 @@ void rq_list_print(void)
  */
 static void /*__sched*/ __schedule(bool preempt)
 {
-       struct task_struct *prev;//, *next, *fw_next;
+       struct task_struct *prev, *next;//, *fw_next;
        struct rq *rq;
        int cpu;
        fw_release_msg_t release;
@@ -1718,12 +1718,31 @@ static void /*__sched*/ __schedule(bool preempt)
                fw_notify(FW_TOPIC_RELINQUISH, &relinquish);
        }
 
+       next = fw_schedule(cpu);
+
+       if (next == NULL) {
+               next = rq->idle;
+       }
+
        clear_tsk_need_resched(prev);
-       rq->skip_clock_update = 0;
+       clear_preempt_need_resched();
 
-       fw_schedule(cpu);
+       if (likely(prev != next)) {
+               rq->nr_switches++;
+               rq->curr = next;
 
-       arch_local_irq_enable();
+#ifdef CONFIG_SMP
+               next->on_cpu = 1;
+               prev->on_cpu = 0;
+#endif
+
+               //trace_sched_switch(preempt, prev, next);
+               rq = context_switch(rq, prev, next); /* unlocks the rq */
+               cpu = cpu_of(rq);
+       } else {
+               lockdep_unpin_lock(&rq->lock);
+               raw_spin_unlock_irq(&rq->lock);
+       }
 
 }
 
diff --git a/framework/os/linux/os_sched.c b/framework/os/linux/os_sched.c
deleted file mode 100644 (file)
index a776a03..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * sched.c
- *
- *  Created on: 10.12.2013
- *      Author: jkrieg
- */
-
-#include <fw.h>
-#include <fw_debug.h>
-#include <linux_sched.h>
-
-void os_schedule(struct fw_task *task, int pe)
-{
-       struct task_struct *prev, *next;
-       struct rq *rq;
-       int cpu;
-
-       cpu = smp_processor_id();
-
-       FW_ASSERT(pe == cpu);
-
-       rq = cpu_rq(cpu);
-
-       prev = rq->curr;
-
-       if ( task == NULL ) {
-               next = rq->idle;
-       }
-       else {
-               next = task->os_task;
-       }
-       rq->curr = next;
-       if(next == prev){
-               lockdep_unpin_lock(&rq->lock);
-               raw_spin_unlock(&rq->lock);
-               return;
-       }
-#ifdef CONFIG_SMP
-       next->on_cpu = 1;
-       prev->on_cpu = 0;
-#endif
-       rq->nr_switches++;
-       context_switch(rq, prev, next); /* unlocks the rq */
-}
-
-struct fw_task *os_current_task(int cpu)
-{
-       return current->fw_task;
-}
-
-void os_set_current_task(struct fw_task *task)
-{
-}
-
-void os_need_resched(struct fw_task *task)
-{
-       set_tsk_need_resched(task->os_task);
-}
-
-#ifdef FW_SMP
-void os_set_task_cpu(struct fw_task *task, int cpu)
-{
-       struct task_struct *p = task->os_task;
-
-       raw_spin_lock(&p->pi_lock);
-       task_thread_info(p)->cpu = cpu;
-       raw_spin_unlock(&p->pi_lock);
-}
-
-void os_send_ipi(int cpu)
-{
-       smp_send_reschedule(cpu);
-}
-#endif
similarity index 88%
rename from framework/include/os/targets/linux.h
rename to framework/os/linux/os_target.h
index 63af30a..faed993 100644 (file)
@@ -1,7 +1,12 @@
-#ifndef LINUX_H_
-#define LINUX_H_
+/*
+ * os_target.h
+ *
+ *  Created on: 21.02.2016
+ *      Author: abusse
+ */
 
-#define FW_DEBUG 1
+#ifndef OS_TARGET_H_
+#define OS_TARGET_H_
 
 #include <linux/sched.h>
 
 
 #define FW_SMP CONFIG_SMP
 
+#define OS_OS_TARGET_STRING "Linux"
+
 /*
  * Number of existing CPUs.
  */
 #define os_num_cpus() (nr_cpu_ids)
-#define os_cpu_id smp_processor_id
+#define os_cpu_id() smp_processor_id()
 
 
 
@@ -34,7 +41,7 @@
 #define os_local_irq_restore local_irq_restore
 
 #define os_size_t unsigned long
-#define __os_task_t struct task_struct
+#define os_task_t struct task_struct
 #define os_task_context_t void
 
 #define os_spinlock_t spinlock_t
@@ -43,8 +50,8 @@
 #define os_spin_unlock(lock) spin_unlock(lock)
 #define os_spin_lock_irq(lock) spin_lock_irq(lock)
 #define os_spin_unlock_irq(lock) spin_unlock_irq(lock)
-#define os_spin_lock_irqsave(lock, flags) spin_lock_irqsave(lock, flags)
-#define os_spin_unlock_irqrestore(lock, flags) spin_unlock_irqrestore(lock, flags)
+#define os_spin_lock_irqsave(lock, flags) spin_lock_irqsave(lock, (*flags))
+#define os_spin_unlock_irqrestore(lock, flags) spin_unlock_irqrestore(lock, (*flags))
 
 #define os_spin_lock_init(lock) raw_spin_lock_init(&(lock)->rlock)
 
@@ -63,8 +70,7 @@
 #define fw_cpumask_set_cpu cpumask_set_cpu
 #define fw_cpumask_clear_cpu cpumask_clear_cpu
 
-
-#endif /* LINUX_H_ */
+#endif /* OS_TARGET_H_ */
 
 
 ///*
diff --git a/framework/scripts/fw_target.sh b/framework/scripts/fw_target.sh
new file mode 100755 (executable)
index 0000000..ed6a8fe
--- /dev/null
@@ -0,0 +1,28 @@
+#! /bin/bash
+
+if [[ ! $# -eq 2 ]] ; then
+    echo "Use: fw_target.sh lib_path out_file"
+    exit 1
+fi
+
+printf \
+"// This file is generated by scripts/fw_target.h, do not edit!!!
+
+#ifndef GENERATED_FW_TARGET_HELPER_H_
+#define GENERATED_FW_TARGET_HELPER_H_
+
+#include <os_target.h>
+
+
+" > $2
+
+for file in $1/*.h; do
+       printf "// symbols defined in $file\n\n" >> $2
+       grep -e "#define fw_.*os_" $file | sed 's/.*\(os_.*\)/\1/' | \
+       while read -r line; do
+               symbol=`echo $line | sed 's/(.*)//g'`
+               printf "#ifndef $symbol\n\t#error $symbol not defined, see $file\n#endif\n\n" >> $2
+       done 
+done
+
+printf "#endif /* GENERATED_FW_TARGET_HELPER_H_ */\n" >> $2
\ No newline at end of file