diff --git a/arch/sparc/include/irq.h b/arch/sparc/include/irq.h new file mode 100644 index 0000000000000000000000000000000000000000..d7012f645a389132c73152ddad08e3ef67d0533a --- /dev/null +++ b/arch/sparc/include/irq.h @@ -0,0 +1,28 @@ +/** + * @file arch/sparc/include/irq.h + * @ingroup timing + * @author Armin Luntzer (armin.luntzer@univie.ac.at), + * @date July, 2016 + * + * @copyright GPLv2 + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + */ + +#ifndef _SPARC_IRQ_H_ +#define _SPARC_IRQ_H_ + + +void leon_enable_irq(unsigned int irq, int cpu); +void leon_disable_irq(unsigned int irq, int cpu); +void leon_force_irq(unsigned int irq, int cpu); + +#endif /* _SPARC_IRQ_H_ */ + diff --git a/include/kernel/smp.h b/include/kernel/smp.h new file mode 100644 index 0000000000000000000000000000000000000000..4ea17a8b8a3ed98c7ba9d09fe937f13762d40891 --- /dev/null +++ b/include/kernel/smp.h @@ -0,0 +1,32 @@ +/** + * @file include/kernel/smp.h + * + * @copyright GPLv2 + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * +* @brief kernel-level SMP support functions + * + */ + + +#ifndef _KERNEL_SMP_H_ +#define _KERNEL_SMP_H_ + + +extern void smp_init(void); + +extern int smp_cpu_id(void); + +extern void smp_send_reschedule(int cpu); + + + +#endif /* _KERNEL_SMP_H_ */ diff --git a/tools/testing/hwtests/application/Makefile b/tools/testing/hwtests/application/Makefile index 96e88ca4e78aaaca8032f33f6616a7165bda9fdd..f29ce30b3214b088935aa09d8e66f8863351eea5 100644 --- a/tools/testing/hwtests/application/Makefile +++ b/tools/testing/hwtests/application/Makefile @@ -1,13 +1,15 @@ -CC = sparc-elf-gcc +#CC = sparc-elf-gcc +CC = sparc-gaisler-elf-gcc SOURCEDIR = ./ INCLUDEDIR = ./ BUILDDIR = ./ PATH += CPPFLAGS := -CFLAGS := -r -mv8 -mhard-float -mfix-gr712rc -O2 -std=gnu89 -W -Wall \ +#CFLAGS := -r -mv8 -mhard-float -mfix-gr712rc -O2 -std=gnu89 -W -Wall +CFLAGS := -r -mhard-float -mcpu=leon3 -std=gnu89 -W -Wall \ -Wextra -Werror -pedantic -Wshadow -Wuninitialized \ -fdiagnostics-show-option -Wcast-qual -Wformat=2 \ - -nostartfiles -nostdlib + -nostartfiles LDFLAGS := SOURCES := $(wildcard *.c) OBJECTS := $(patsubst %.c, $(BUILDDIR)/%.o, $(subst $(SOURCEDIR)/,, $(SOURCES))) diff --git a/tools/testing/hwtests/application/config-gr740 b/tools/testing/hwtests/application/config-gr740 new file mode 100644 index 0000000000000000000000000000000000000000..f93fa6c833095517305bbabca32586aa3c153e88 --- /dev/null +++ b/tools/testing/hwtests/application/config-gr740 @@ -0,0 +1,78 @@ +# +# Automatically generated file; DO NOT EDIT. +# LeanOS 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=y +# 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=6 +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 diff --git a/tools/testing/hwtests/application/executable_demo.c b/tools/testing/hwtests/application/executable_demo.c index 6ac004039967c5dde46472d2c9d7ae8fc2ec4bab..4f35838cd2825cd83cc1ad058f801a410f805edf 100644 --- a/tools/testing/hwtests/application/executable_demo.c +++ b/tools/testing/hwtests/application/executable_demo.c @@ -2,12 +2,53 @@ * * Note that at this point, we do not distinguish between an application * payload and a module, this will be changed in the future. + * + * NOTE: this is configured for the GR740 */ #include "glue.h" +__attribute__((unused)) +static int show_timer_irq(void) +{ + char buf0[64]; + char buf1[64]; + char buf2[64]; + char buf3[64]; + char buf4[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", buf0); + sysobj_show_attr(sys_irq, "1", buf1); + sysobj_show_attr(sys_irq, "2", buf2); + sysobj_show_attr(sys_irq, "3", buf3); + sysobj_show_attr(sys_irq, "4", buf4); + + printk("IRQ total: %s\n" + "CPU timers: \n" + " [0]: %s\n" + " [1]: %s\n" + " [2]: %s\n" + " [3]: %s\n", + buf0, buf1, buf2, buf3, buf4); + + sched_yield(); + } + return 0; +} /* some random function we use in our executable */ @@ -36,7 +77,7 @@ static int iasw(void *data) */ while (1) { - printk("z"); + printk("%d\n", i++); sched_yield(); } @@ -55,8 +96,11 @@ int init_iasw(void) { struct task_struct *t; - t = kthread_create(iasw, (void *) 0, KTHREAD_CPU_AFFINITY_NONE, "IASW"); - kthread_wake_up(t); + t = kthread_create(iasw, NULL, KTHREAD_CPU_AFFINITY_NONE, "IASW"); + /* allocate 98% of the cpu */ + kthread_set_sched_edf(t, 100*1000, 99*1000, 98*1000); + if (kthread_wake_up(t) < 0) + printk("---- IASW NOT SCHEDULABLE---\n"); return 0; } @@ -69,7 +113,7 @@ int init_iasw(void) int exit_iasw(void) { - printk("%s leaving\n", __func__); + printk("program leaving\n"); /* kthread_destroy() */ return 0; } diff --git a/tools/testing/hwtests/application/glue.h b/tools/testing/hwtests/application/glue.h index 8022d37ebc38cfee17eb5c0f1bc9adde5de9bdb8..bf0dacad3eab127e43bf4c4328578b37292af426 100644 --- a/tools/testing/hwtests/application/glue.h +++ b/tools/testing/hwtests/application/glue.h @@ -2,6 +2,9 @@ #define GLUE_H +#include <stddef.h> +#include <stdint.h> + /* * prototypes and declarations needed to build this demo */ @@ -20,10 +23,20 @@ struct task_struct *kthread_create(int (*thread_fn)(void *data), void *data, int cpu, const char *namefmt, ...); -void kthread_wake_up(struct task_struct *task); +int kthread_wake_up(struct task_struct *task); void sched_yield(void); +int smp_cpu_id(void); + +void kthread_set_sched_edf(struct task_struct *task, + unsigned long period_us, + unsigned long wcet_us, + unsigned long deadline_rel_us); + +extern struct sysset *sys_set; +struct sysobj *sysset_find_obj(struct sysset *sysset, const char *path); +void sysobj_show_attr(struct sysobj *sobj, const char *name, char *buf); #endif /* GLUE_H */ diff --git a/tools/testing/hwtests/application/run_test.sh b/tools/testing/hwtests/application/run_test.sh index 9f4f0f44e5aba9b882ce61d27f94fbdc99dd6c32..0eb7f458563c25f268f661454c80088a61f82f0f 100755 --- a/tools/testing/hwtests/application/run_test.sh +++ b/tools/testing/hwtests/application/run_test.sh @@ -9,14 +9,15 @@ make || exit 1 mydir=$PWD srcdir=../../../../ -cp config ${srcdir}/.config || exit 1 +#cp config ${srcdir}/.config || exit 1 +cp config-gr740 ${srcdir}/.config || exit 1 echo -e "CONFIG_EMBED_APPLICATION=\"$PWD/executable_demo\"" >> ${srcdir}/.config cd ${srcdir} || exit 1 -make clean || exit 1 +#make clean || exit 1 make || exit 1 -grmon -ftdi -u -ftdifreq 0 -jtagcable 3 -nb -c $mydir/grmon_cmds +#grmon -ftdi -u -ftdifreq 0 -jtagcable 3 -nb -c $mydir/grmon_cmds