Skip to content
Snippets Groups Projects
Commit 7fc3b8b2 authored by Armin Luntzer's avatar Armin Luntzer
Browse files

consolidate application loader

parent 74081fd8
No related branches found
No related tags found
No related merge requests found
......@@ -6,8 +6,10 @@
#ifndef _KERNEL_SCHED_H_
#define _KERNEL_SCHED_H_
#include <generated/autoconf.h> /*XXX */
#include <list.h>
#include <kernel/time.h>
#include <generated/autoconf.h> /*XXX */
/* scheduler priority levels */
#define SCHED_PRIORITY_RR 0
......@@ -114,8 +116,6 @@ void switch_to(struct task_struct *next);
void schedule(void);
void sched_yield(void);
void sched_print_edf_list(void);
int sched_set_attr(struct task_struct *task, struct sched_attr *attr);
int sched_get_attr(struct task_struct *task, struct sched_attr *attr);
......
......@@ -46,6 +46,8 @@
#endif /* __OPTIMIZE__ */
#endif /* GCC_VERSION */
/** XXX dummy **/
extern int cpu_ready[CONFIG_SMP_CPUS_MAX];
/**
* @brief kernel initialisation routines
......@@ -63,74 +65,16 @@ static int kernel_init(void)
arch_initcall(kernel_init);
/** XXX dummy **/
extern int cpu1_ready;
volatile int xp;
int task1(void *p)
{
while (1) {
xp++;
}
}
volatile int xd;
int task2(void *p)
{
while (1)
xd++;
}
int task(void *p)
{
char buf1[64];
char buf2[64];
char buf3[64];
struct sysobj *sys_irq = NULL;
sys_irq = sysset_find_obj(sys_set, "/sys/irl/primary");
if (!sys_irq) {
printk("Error locating sysctl entry\n");
return -1;
}
while (1) {
sysobj_show_attr(sys_irq, "irl", buf1);
sysobj_show_attr(sys_irq, "8", buf2);
sysobj_show_attr(sys_irq, "9", buf3);
printk("IRQ total: %s timer1: %s timer2: %s, %d %d\n",
buf1, buf2, buf3, ioread32be(&xp), xd);
sched_yield();
}
return 0;
}
/** XXX dummy **/
extern int cpu_ready[CONFIG_SMP_CPUS_MAX];
/**
* @brief kernel main functionputchar( *((char *) data) );
*/
int kernel_main(void)
{
int i;
struct task_struct *t;
struct sched_attr attr;
#if 0
void *addr;
struct elf_module m;
#endif
void *addr __attribute__((unused));
struct elf_module m __attribute__((unused));
printk(MSG "Loading module image\n");
......@@ -164,26 +108,6 @@ int kernel_main(void)
#endif
#ifdef CONFIG_EMBED_APPLICATION
/* dummy demonstrator */
{
void *addr;
struct elf_module m;
addr = module_read_embedded("CrApp1");
pr_debug(MSG "test executable address is %p\n", addr);
if (addr)
module_load(&m, addr);
#if 0
modules_list_loaded();
#endif
}
#endif
#ifdef CONFIG_MPPB
/* The mppbv2 LEON's cache would really benefit from cache sniffing...
* Interactions with DMA or Xentiums are a pain when using the lower
......@@ -217,52 +141,19 @@ int kernel_main(void)
printk(MSG "Boot complete\n");
#ifdef CONFIG_EMBED_APPLICATION
/* dummy demonstrator */
addr = module_read_embedded("executable_demo");
t = kthread_create(task, NULL, KTHREAD_CPU_AFFINITY_NONE, "task");
if (!IS_ERR(t)) {
sched_get_attr(t, &attr);
attr.policy = SCHED_EDF;
attr.period = ms_to_ktime(1000);
attr.deadline_rel = ms_to_ktime(999);
attr.wcet = ms_to_ktime(300);
sched_set_attr(t, &attr);
if (kthread_wake_up(t) < 0)
printk("---- %s NOT SCHEDUL-ABLE---\n", t->name);
} else {
printk("Got an error in kthread_create!");
}
printk("%s runs on CPU %d\n", t->name, t->on_cpu);
t = kthread_create(task1, NULL, KTHREAD_CPU_AFFINITY_NONE, "task1");
if (!IS_ERR(t)) {
sched_get_attr(t, &attr);
attr.policy = SCHED_EDF;
attr.period = us_to_ktime(300);
attr.deadline_rel = us_to_ktime(200);
attr.wcet = us_to_ktime(100);
sched_set_attr(t, &attr);
if (kthread_wake_up(t) < 0)
printk("---- %s NOT SCHEDUL-ABLE---\n", t->name);
} else {
printk("Got an error in kthread_create!");
}
printk("%s runs on CPU %d\n", t->name, t->on_cpu);
t = kthread_create(task2, NULL, KTHREAD_CPU_AFFINITY_NONE, "task2");
if (!IS_ERR(t)) {
sched_get_attr(t, &attr);
attr.policy = SCHED_EDF;
attr.period = us_to_ktime(300);
attr.deadline_rel = us_to_ktime(200);
attr.wcet = us_to_ktime(100);
sched_set_attr(t, &attr);
if (kthread_wake_up(t) < 0)
printk("---- %s NOT SCHEDUL-ABLE---\n", t->name);
} else {
printk("Got an error in kthread_create!");
}
printk("%s runs on CPU %d\n", t->name, t->on_cpu);
pr_debug(MSG "test executable address is %p\n", addr);
if (addr)
module_load(&m, addr);
#if 0
modules_list_loaded();
#endif
#endif
while(1)
......
......@@ -50,6 +50,20 @@ static void kthread_unlock(void)
}
void kthread_set_sched_edf(struct task_struct *task, unsigned long period_us,
unsigned long wcet_us, unsigned long deadline_rel_us)
{
struct sched_attr attr;
sched_get_attr(task, &attr);
attr.policy = SCHED_EDF;
attr.period = us_to_ktime(period_us);
attr.deadline_rel = us_to_ktime(wcet_us);
attr.wcet = us_to_ktime(deadline_rel_us);
sched_set_attr(task, &attr);
}
/* we should have a thread with a semaphore which is unlocked by schedule()
* if dead tasks were added to the "dead" list
*/
......
......@@ -462,8 +462,14 @@ EXPORT_SYMBOL(puts);
int putchar(int c)
{
#define TREADY 4
#if defined(CONFIG_LEON3)
static volatile int *console = (int *)0x80000100;
#endif
#if defined(CONFIG_LEON4)
static volatile int *console = (int *)0xFF900000;
#endif
while (!(console[1] & TREADY));
console[0] = 0x0ff & c;
......@@ -479,6 +485,7 @@ int putchar(int c)
/**
* @brief print a string into a buffer
*
......
......@@ -58,32 +58,6 @@ struct fmt_spec {
#define TREADY 4
#if defined(CONFIG_LEON3)
static volatile int *console = (int *)0x80000100;
#endif
#if defined(CONFIG_LEON4)
static volatile int *console = (int *)0xFF900000;
#endif
static int putchar(int c)
{
while (!(console[1] & TREADY));
console[0] = 0x0ff & c;
if (c == '\n') {
while (!(console[1] & TREADY));
console[0] = (int) '\r';
}
return c;
}
/**
* @brief print a single character
*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment