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

Merge branch 'gr740_demo'

parents 54453a63 1075f599
No related branches found
No related tags found
No related merge requests found
......@@ -120,11 +120,11 @@ static void boot_cpus(void)
for (i = 1; i < CONFIG_SMP_CPUS_MAX; i++) {
printk("booting cpu %d\n", i);
pr_info("booting cpu %d\n", i);
cpu_wake(i);
while (!ioread32be(&cpu_ready[i]));
printk("cpu %d booted\n", i);
pr_info("cpu %d booted\n", i);
}
}
......@@ -141,7 +141,7 @@ void smp_cpu_entry(void)
arch_local_irq_enable();
printk("hi i'm cpu %d\n", leon3_cpuid());
pr_info("hi i'm cpu %d\n", leon3_cpuid());
BUG_ON(!leon3_cpuid());
/* signal ready */
......
#
# Automatically generated file; DO NOT EDIT.
# LeanOS Configuration
#
#
# SPARC Configuration
#
# CONFIG_LEON2 is not set
CONFIG_LEON3=y
# CONFIG_LEON4 is not set
# CONFIG_MMU is not set
CONFIG_CPU_CLOCK_FREQ=80000000
CONFIG_EXTRA_SPARC_PHYS_BANKS=0
CONFIG_SPARC_CPU_REG_WINDOWS=8
CONFIG_SPARC_TEXT_START=0x40000000
CONFIG_SPARC_FP_START=0x40100000
#
# Memory Management Settings
#
CONFIG_SPARC_MM_BLOCK_ORDER_MAX=26
CONFIG_SPARC_MM_BLOCK_ORDER_MIN=12
CONFIG_SPARC_INIT_PAGE_MAP_MAX_ENTRIES=8
CONFIG_SPARC_BOOTMEM_RESERVE_CHUNK_ORDER=20
CONFIG_SPARC_BOOTMEM_REQUEST_NEW_ON_DEMAND=y
CONFIG_SPARC_NESTED_IRQ=y
#
# General Setup
#
CONFIG_SMP_CPUS_MAX=2
CONFIG_STACK_SIZE=4096
CONFIG_KALLSYMS=y
CONFIG_CROSS_PLATFORM_TARGET=y
CONFIG_CROSS_COMPILE="sparc-gaisler-elf-"
# CONFIG_TARGET_COMPILER_BOOT_CODE is not set
CONFIG_ARCH_CUSTOM_BOOT_CODE=y
CONFIG_MODULES=y
# CONFIG_EMBED_MODULES_IMAGE is not set
# CONFIG_BUILD_XEN_KERNELS is not set
#
# Compile-time checks and compiler options
#
CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE=y
# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
# CONFIG_CC_OPTIMIZE_NONE is not set
# CONFIG_DEBUG_INFO is not set
CONFIG_KERNEL_PRINTK=y
CONFIG_KERNEL_LEVEL=7
# CONFIG_IRQ_STATS_COLLECT is not set
# CONFIG_TASK_PREEMPTION_DISABLE is not set
# CONFIG_SOC is not set
#
# Core Components
#
CONFIG_SYSCTL=y
CONFIG_MM=y
#
# Memory Management Debug Options
#
# CONFIG_MM_DEBUG_DUMP is not set
CONFIG_PAGE_MAP=y
#
# Page Map Options
#
# CONFIG_PAGE_MAP_CHECK_PAGE_ALIGNMENT is not set
CONFIG_PAGE_MAP_MOVE_NODE_AVAIL_THRESH=1
CONFIG_CHUNK=y
CONFIG_AR=y
# CONFIG_SAMPLES is not set
#
# Automatically generated file; DO NOT EDIT.
# FlighOS Configuration
#
#
# SPARC Configuration
#
# CONFIG_LEON2 is not set
# CONFIG_LEON3 is not set
CONFIG_LEON4=y
# CONFIG_MMU is not set
CONFIG_CPU_CLOCK_FREQ=250000000
CONFIG_EXTRA_SPARC_PHYS_BANKS=0
CONFIG_SPARC_CPU_REG_WINDOWS=8
CONFIG_SPARC_TEXT_START=0x0
CONFIG_SPARC_FP_START=0x00200000
#
# Memory Management Settings
#
CONFIG_SPARC_MM_BLOCK_ORDER_MAX=29
CONFIG_SPARC_MM_BLOCK_ORDER_MIN=12
CONFIG_SPARC_INIT_PAGE_MAP_MAX_ENTRIES=8
CONFIG_SPARC_BOOTMEM_RESERVE_CHUNK_ORDER=20
CONFIG_SPARC_BOOTMEM_REQUEST_NEW_ON_DEMAND=y
CONFIG_SPARC_NESTED_IRQ=y
#
# General Setup
#
CONFIG_SMP_CPUS_MAX=4
CONFIG_STACK_SIZE=4096
CONFIG_KALLSYMS=y
CONFIG_CROSS_PLATFORM_TARGET=y
CONFIG_CROSS_COMPILE="sparc-gaisler-elf-"
# CONFIG_TARGET_COMPILER_BOOT_CODE is not set
CONFIG_ARCH_CUSTOM_BOOT_CODE=y
CONFIG_MODULES=y
# CONFIG_EMBED_MODULES_IMAGE is not set
# CONFIG_BUILD_XEN_KERNELS is not set
#
# Compile-time checks and compiler options
#
CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE=y
# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
# CONFIG_CC_OPTIMIZE_NONE is not set
# CONFIG_DEBUG_INFO is not set
CONFIG_KERNEL_PRINTK=y
CONFIG_KERNEL_LEVEL=7
CONFIG_IRQ_STATS_COLLECT=y
# CONFIG_TASK_PREEMPTION_DISABLE is not set
# CONFIG_SOC is not set
#
# Core Components
#
CONFIG_SYSCTL=y
CONFIG_MM=y
#
# Memory Management Debug Options
#
CONFIG_MM_DEBUG_DUMP=y
CONFIG_MM_DEBUG_DUMP_ALLOC_BITMAP=y
CONFIG_MM_DEBUG_DUMP_BLOCK_ALLLOC=y
CONFIG_MM_DEBUG_DUMP_BLOCK_STATS=y
CONFIG_PAGE_MAP=y
#
# Page Map Options
#
# CONFIG_PAGE_MAP_CHECK_PAGE_ALIGNMENT is not set
CONFIG_PAGE_MAP_MOVE_NODE_AVAIL_THRESH=1
CONFIG_CHUNK=y
CONFIG_AR=y
# CONFIG_SAMPLES is not set
......@@ -79,7 +79,11 @@ struct task_struct {
ktime wakeup; /* start of next period */
ktime deadline; /* deadline of current period */
ktime create; /* start of next period */
ktime wakeup_first;
ktime exec_start;
ktime exec_stop;
ktime total;
unsigned long slices;
......
obj-y += main.o
obj-y += demo.o
obj-y += demo_net.o
obj-$(CONFIG_XENTIUM_PROC_DEMO) += xentium_demo.o
obj-$(CONFIG_EMBED_MODULES_IMAGE) += modules-image.o
#include <kernel/kernel.h>
#include <kernel/kmem.h>
#include <kernel/kthread.h>
#include <kernel/err.h>
#include <kernel/smp.h>
#include <asm/io.h>
static volatile double per_loop_avg[CONFIG_SMP_CPUS_MAX];
static int copytask(void *data)
{
#define BUFLEN 1024*1024
int i;
int cpu;
int *go;
ktime cnt = 0;
ktime start, stop;
ktime total = 0;
// static uint32_t *common[CONFIG_SMP_CPUS_MAX];
static uint32_t *cpu_buf[CONFIG_SMP_CPUS_MAX];
go = (int *) data;
cpu = smp_cpu_id();
cpu_buf[smp_cpu_id()] = kmalloc(BUFLEN * sizeof(uint32_t));
if (!cpu_buf[cpu])
return 0;
(*go) = 1; /* signal ready */
/* wait for trigger */
while (ioread32be(go) != CONFIG_SMP_CPUS_MAX);
while (ioread32be(go)) {
start = ktime_get();
for (i = 0 ; i < BUFLEN; i++) {
cpu_buf[cpu][i] = cpu_buf[CONFIG_SMP_CPUS_MAX - cpu - 1][i];
}
stop = ktime_get();
total += stop - start;
cnt++;
per_loop_avg[cpu] = ( ((double) total / (double) cnt) / (double) (BUFLEN));
}
return 0;
}
int copy_resprint(void *data)
{
int i;
int *go;
ktime start;
double res[CONFIG_SMP_CPUS_MAX];
go = (int *) data;
/* wait for trigger */
while (ioread32be(go) != CONFIG_SMP_CPUS_MAX);
start = ktime_get();
/* wait for about 60 seconds */
while (ktime_delta(ktime_get(), start) < ms_to_ktime(360 * 1000)) {
for (i = 0; i < CONFIG_SMP_CPUS_MAX; i++)
res[i] = per_loop_avg[i];
printk("%g ", 0.001 * (double) ktime_to_ms(ktime_get()));
for (i = 0; i < CONFIG_SMP_CPUS_MAX; i++)
printk("%g ", res[i]);
printk("\n");
}
(*go) = 0; /* signal stop */
return 0;
}
int copybench_start(void)
{
int i;
int go;
struct task_struct *t;
printk("COPYBENCH STARTING\n");
printk("Creating tasks, please stand by\n");
for (i = 0; i < CONFIG_SMP_CPUS_MAX; i++) {
// for (i = CONFIG_SMP_CPUS_MAX - 1; i >= 0; i--) {
go = 0;
t = kthread_create(copytask, &go, i, "COPYTASK");
if (!IS_ERR(t)) {
/* allocate 95% of the cpu, period = 1s */
kthread_set_sched_edf(t, 1000 * 1000, 980 * 1000, 950 * 1000);
if (kthread_wake_up(t) < 0) {
printk("---- %s NOT SCHEDUL-ABLE---\n", t->name);
BUG();
}
while (!ioread32be(&go)); /* wait for task to become ready */
} else {
printk("Got an error in kthread_create!");
break;
}
printk("Copy task ready on cpu %d\n", i);
}
printk("Creating RR cpu-hopping printout task\n");
t = kthread_create(copy_resprint, &go, KTHREAD_CPU_AFFINITY_NONE, "PRINTTASK");
if (kthread_wake_up(t) < 0) {
printk("---- %s NOT SCHEDUL-ABLE---\n", t->name);
BUG();
}
printk("Triggering...\n");
go = CONFIG_SMP_CPUS_MAX; /* set trigger */
sched_yield();
while (ioread32be(&go)); /* wait for completion */
printk("Average time to cross-copy buffers:\n");
for (i = 0; i < CONFIG_SMP_CPUS_MAX; i++) {
printk("\tCPU %d: %ld ns per sample\n", per_loop_avg[i]);
}
printk("COPYBENCH DONE\n");
return 0;
}
int edftask(void *data)
{
int i;
int loops = (* (int *) data);
for (i = 0; i < loops; i++);
return i;
}
int oneshotedf_start(void)
{
int i;
int loops = 1700000000;
struct task_struct *t[CONFIG_SMP_CPUS_MAX];
// printk("EDF CREATE STARTING\n");
// printk("Creating tasks, please stand by\n");
for (i = 0; i < CONFIG_SMP_CPUS_MAX; i++) {
t[i] = kthread_create(edftask, &loops, i, "EDFTASK");
if (!IS_ERR(t)) {
/* creaate and launch edf thread */
kthread_set_sched_edf(t[i], 0, 100, 50);
if (kthread_wake_up(t[i]) < 0) {
printk("---- %s NOT SCHEDUL-ABLE---\n", t[i]->name);
BUG();
}
} else {
printk("Got an error in kthread_create!");
break;
}
// printk("Copy task ready on cpu %d\n", i);
}
sched_yield();
printk("%lld\n", ktime_to_ms(ktime_get()));
printk("Wakeup, creation, exec_start, exec_stop, deadline:\n");
for (i = 0; i < CONFIG_SMP_CPUS_MAX; i++) {
printk("\tCPU %d: %lld %lld %lld %lld %lld\n",
i,
ktime_to_us(ktime_delta(t[i]->wakeup_first, t[i]->create)),
ktime_to_us(ktime_delta(t[i]->wakeup, t[i]->create)),
ktime_to_us(ktime_delta(t[i]->exec_start, t[i]->create)),
ktime_to_us(ktime_delta(t[i]->exec_stop, t[i]->create)),
ktime_to_us(ktime_delta(t[i]->deadline, t[i]->create)));
}
printk("COPYBENCH DONE\n");
return 0;
}
This diff is collapsed.
......@@ -49,6 +49,11 @@
/** XXX dummy **/
extern int cpu_ready[CONFIG_SMP_CPUS_MAX];
void demo_start(void);
int copybench_start(void);
int oneshotedf_start(void);
/**
* @brief kernel initialisation routines
*/
......@@ -76,6 +81,8 @@ int kernel_main(void)
struct elf_module m __attribute__((unused));
#ifdef CONFIG_EMBED_MODULES_IMAGE
printk(MSG "Loading module image\n");
/* load the embedded AR image */
......@@ -106,6 +113,7 @@ int kernel_main(void)
modules_list_loaded();
#endif
#endif
#ifdef CONFIG_MPPB
......@@ -139,7 +147,7 @@ int kernel_main(void)
}
printk(MSG "Boot complete\n");
// printk(MSG "Boot complete\n");
#ifdef CONFIG_EMBED_APPLICATION
/* dummy demonstrator */
......@@ -155,6 +163,13 @@ int kernel_main(void)
#endif
#endif
#if 0
copybench_start();
#else
//demo_start();
oneshotedf_start();
#endif
while(1)
cpu_relax();
......
......@@ -51,14 +51,14 @@ 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)
unsigned long deadline_rel_us, unsigned long wcet_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);
attr.deadline_rel = us_to_ktime(deadline_rel_us);
attr.wcet = us_to_ktime(wcet_us);
sched_set_attr(task, &attr);
}
......@@ -70,6 +70,7 @@ void kthread_set_sched_edf(struct task_struct *task, unsigned long period_us,
void kthread_free(struct task_struct *task)
{
return;
if (task->flags & TASK_NO_CLEAN) /* delete from list as well */
return;
......@@ -107,7 +108,9 @@ int kthread_wake_up(struct task_struct *task)
kthread_lock();
now = ktime_get();
sched_wake(task, ktime_get());
sched_wake(task, now);
task->wakeup_first = now;
/* this may be a critical task, send reschedule */
if (task->on_cpu != KTHREAD_CPU_AFFINITY_NONE)
......@@ -213,6 +216,7 @@ static struct task_struct *kthread_create_internal(int (*thread_fn)(void *data),
return NULL;
}
task->create = ktime_get();
task->total = 0;
task->slices = 0;
task->on_cpu = cpu;
......
......@@ -41,6 +41,7 @@ static void sched_update_runtime(struct task_struct *task, ktime now)
rt = ktime_sub(now, task->exec_start);
task->exec_stop = now;
task->runtime = ktime_sub(task->runtime, rt);
task->total = ktime_add(task->total, rt);
......@@ -348,7 +349,7 @@ int sched_get_attr(struct task_struct *task, struct sched_attr *attr)
int sched_set_policy_default(struct task_struct *task)
{
struct sched_attr attr = {.policy = SCHED_RR,
.priority = 1};
.priority = 100};
return sched_set_attr(task, &attr);
......
......@@ -288,14 +288,14 @@ fi
# this is a 3rd pass option, we need modules.order beforehand
if [ "$1" = "embed" ]; then
# if [ ! -s ${srctree}/modules.order ]; then
# echo >&2
# echo >&2 modules.order empty or nonexistant, cannot embed image.
# echo >&2 Maybe you have no loadable modules configured?
# echo >&2 Kernel image unchanged.
# echo >&2
# exit
# fi
if [ ! -s ${srctree}/modules.order ] || [! -s ${CONFIG_EMBED_APPLICATION} ]; then
echo >&2
echo >&2 modules.order or application path empty or nonexistant, cannot embed image.
echo >&2 Maybe you have no loadable modules configured or no executable path specified?
echo >&2 Kernel image unchanged.
echo >&2
exit
fi
if [ -n "${CONFIG_TARGET_COMPILER_BOOT_CODE}" ]; then
embedflags="-Wl,--format=binary -Wl,modules.image -Wl,--format=default"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment