diff --git a/init/main.c b/init/main.c index 61dbe82b43fad66140595aa79a3f95c535f78fe0..46027e680253d9c5c1235d807c40c71adc076dff 100644 --- a/init/main.c +++ b/init/main.c @@ -94,10 +94,6 @@ int kernel_main(void) { struct task_struct *t; -#if 0 - void *addr; - struct elf_module m; -#endif printk(MSG "Loading module image\n"); @@ -113,6 +109,10 @@ int kernel_main(void) module_lookup_embedded("noc_dma.ko")); #if 0 +{ + void *addr; + struct elf_module m; + /* If you have kernel modules embedded in your modules.images, this * is how you can access them: * lookup the module containing <symbol> @@ -128,8 +128,30 @@ int kernel_main(void) module_load(&m, addr); modules_list_loaded(); +} #endif + +#ifdef CONFIG_EMBED_APPLICATION + /* dummy demonstrator */ +{ + void *addr; + struct elf_module m; + + addr = module_read_embedded("executable_demo"); + + 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 @@ -152,8 +174,7 @@ int kernel_main(void) kernel = kthread_init_main(); - - +#if 0 t = kthread_create(task1, NULL, KTHREAD_CPU_AFFINITY_NONE, "print"); //kthread_set_sched_edf(t, 1000000, 50000, 90000); t->priority = 4; @@ -163,7 +184,7 @@ int kernel_main(void) //kthread_set_sched_edf(t, 1000000, 50000, 90000); t->priority = 8; kthread_wake_up(t); - +#endif while(1) { diff --git a/tools/testing/hwtests/application/Makefile b/tools/testing/hwtests/application/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..96e88ca4e78aaaca8032f33f6616a7165bda9fdd --- /dev/null +++ b/tools/testing/hwtests/application/Makefile @@ -0,0 +1,27 @@ +CC = sparc-elf-gcc +SOURCEDIR = ./ +INCLUDEDIR = ./ +BUILDDIR = ./ +PATH += +CPPFLAGS := +CFLAGS := -r -mv8 -mhard-float -mfix-gr712rc -O2 -std=gnu89 -W -Wall \ + -Wextra -Werror -pedantic -Wshadow -Wuninitialized \ + -fdiagnostics-show-option -Wcast-qual -Wformat=2 \ + -nostartfiles -nostdlib +LDFLAGS := +SOURCES := $(wildcard *.c) +OBJECTS := $(patsubst %.c, $(BUILDDIR)/%.o, $(subst $(SOURCEDIR)/,, $(SOURCES))) +TARGET := executable_demo + +DEBUG?=1 +ifeq "$(shell expr $(DEBUG) \> 1)" "1" + CFLAGS += -DDEBUGLEVEL=$(DEBUG) +else + CFLAGS += -DDEBUGLEVEL=1 +endif + + +all: $(SOURCES) + $(CC) $(CPPFLAGS) $(CFLAGS) $^ -o $(TARGET) + + diff --git a/tools/testing/hwtests/application/README b/tools/testing/hwtests/application/README new file mode 100644 index 0000000000000000000000000000000000000000..3e3fe3cdac1b43b70b999dcae01828d214d8706a --- /dev/null +++ b/tools/testing/hwtests/application/README @@ -0,0 +1,26 @@ + +Description: +============ + +This test configures and executes an embedded application demonstrator. + +Press Ctrl+C to quit the demonstration. + +Pass/Fail Criterea: +=================== + + None + +Prerequisites: +============== + + * connected GR712 board + * grmon v2.x + + +Notes: +====== + +The current .config of LeanOS will be overwritten and the image will +be rebuilt. + diff --git a/tools/testing/hwtests/application/config b/tools/testing/hwtests/application/config new file mode 100644 index 0000000000000000000000000000000000000000..7dbd6f625f610046fd1b8997b3e50e8bd792da0d --- /dev/null +++ b/tools/testing/hwtests/application/config @@ -0,0 +1,72 @@ +# +# Automatically generated file; DO NOT EDIT. +# LeanOS Configuration +# + +# +# SPARC Configuration +# +# CONFIG_LEON2 is not set +CONFIG_LEON3=y +# 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_KALLSYMS=y +CONFIG_CROSS_PLATFORM_TARGET=y +CONFIG_CROSS_COMPILE="sparc-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=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 diff --git a/tools/testing/hwtests/application/executable_demo.c b/tools/testing/hwtests/application/executable_demo.c new file mode 100644 index 0000000000000000000000000000000000000000..6ac004039967c5dde46472d2c9d7ae8fc2ec4bab --- /dev/null +++ b/tools/testing/hwtests/application/executable_demo.c @@ -0,0 +1,79 @@ +/* This demonstrates a basic configuration for and "embedded application" + * + * Note that at this point, we do not distinguish between an application + * payload and a module, this will be changed in the future. + */ + + +#include "glue.h" + + + + +/* some random function we use in our executable */ + +static void print0r(int i) +{ + printk("print0r %d\n", i); +} + +/* this is the equivalent of "main()" in our application + * (can actually be main I guess) + */ + +static int iasw(void *data) +{ + int i; + + (void) data; + + /* print a little */ + for (i = 0; i < 10; i++) + print0r(i); + + /* then print a single "z" in a loop and "pause" until the function + * is re-scheduled by issuing sched_yield() + */ + + while (1) { + printk("z"); + sched_yield(); + } + + return 0; +} + + + +/* + * This is our startup call, it will be executed once when the application is + * loaded. Here we create at thread in which our actual application code + * will run in. + */ + +int init_iasw(void) +{ + struct task_struct *t; + + t = kthread_create(iasw, (void *) 0, KTHREAD_CPU_AFFINITY_NONE, "IASW"); + kthread_wake_up(t); + + return 0; +} + + +/** + * this is our optional exit call, it will be called when the module/application + * is removed by the kernel + */ + +int exit_iasw(void) +{ + printk("%s leaving\n", __func__); + /* kthread_destroy() */ + return 0; +} + +/* here we declare our init and exit functions */ +module_init(init_iasw) +module_exit(exit_iasw) diff --git a/tools/testing/hwtests/application/glue.h b/tools/testing/hwtests/application/glue.h new file mode 100644 index 0000000000000000000000000000000000000000..8022d37ebc38cfee17eb5c0f1bc9adde5de9bdb8 --- /dev/null +++ b/tools/testing/hwtests/application/glue.h @@ -0,0 +1,29 @@ +#ifndef GLUE_H +#define GLUE_H + + +/* + * prototypes and declarations needed to build this demo + */ + +#define module_init(initfunc) \ + int _module_init(void) __attribute__((alias(#initfunc))); + +#define module_exit(exitfunc) \ + int _module_exit(void) __attribute__((alias(#exitfunc))); + +#define KTHREAD_CPU_AFFINITY_NONE (-1) + +int printk(const char *format, ...); + +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); + +void sched_yield(void); + + + +#endif /* GLUE_H */ diff --git a/tools/testing/hwtests/application/grmon_cmds b/tools/testing/hwtests/application/grmon_cmds new file mode 100644 index 0000000000000000000000000000000000000000..05f292df204472001cf6c0004ecce992d33dede4 --- /dev/null +++ b/tools/testing/hwtests/application/grmon_cmds @@ -0,0 +1,3 @@ +load leanos +run +quit diff --git a/tools/testing/hwtests/application/run_test.sh b/tools/testing/hwtests/application/run_test.sh new file mode 100755 index 0000000000000000000000000000000000000000..9f4f0f44e5aba9b882ce61d27f94fbdc99dd6c32 --- /dev/null +++ b/tools/testing/hwtests/application/run_test.sh @@ -0,0 +1,22 @@ +#!/bin/bash +# grmon must be in path! + + +#build application +make || exit 1 + + +mydir=$PWD +srcdir=../../../../ + +cp config ${srcdir}/.config || exit 1 + +echo -e "CONFIG_EMBED_APPLICATION=\"$PWD/executable_demo\"" >> ${srcdir}/.config + +cd ${srcdir} || exit 1 + +make clean || exit 1 + +make || exit 1 + +grmon -ftdi -u -ftdifreq 0 -jtagcable 3 -nb -c $mydir/grmon_cmds