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

add application demo

parent 21360cad
Branches
No related tags found
No related merge requests found
...@@ -94,10 +94,6 @@ int kernel_main(void) ...@@ -94,10 +94,6 @@ int kernel_main(void)
{ {
struct task_struct *t; struct task_struct *t;
#if 0
void *addr;
struct elf_module m;
#endif
printk(MSG "Loading module image\n"); printk(MSG "Loading module image\n");
...@@ -113,6 +109,10 @@ int kernel_main(void) ...@@ -113,6 +109,10 @@ int kernel_main(void)
module_lookup_embedded("noc_dma.ko")); module_lookup_embedded("noc_dma.ko"));
#if 0 #if 0
{
void *addr;
struct elf_module m;
/* If you have kernel modules embedded in your modules.images, this /* If you have kernel modules embedded in your modules.images, this
* is how you can access them: * is how you can access them:
* lookup the module containing <symbol> * lookup the module containing <symbol>
...@@ -128,8 +128,30 @@ int kernel_main(void) ...@@ -128,8 +128,30 @@ int kernel_main(void)
module_load(&m, addr); module_load(&m, addr);
modules_list_loaded(); modules_list_loaded();
}
#endif #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 #ifdef CONFIG_MPPB
/* The mppbv2 LEON's cache would really benefit from cache sniffing... /* The mppbv2 LEON's cache would really benefit from cache sniffing...
* Interactions with DMA or Xentiums are a pain when using the lower * Interactions with DMA or Xentiums are a pain when using the lower
...@@ -152,8 +174,7 @@ int kernel_main(void) ...@@ -152,8 +174,7 @@ int kernel_main(void)
kernel = kthread_init_main(); kernel = kthread_init_main();
#if 0
t = kthread_create(task1, NULL, KTHREAD_CPU_AFFINITY_NONE, "print"); t = kthread_create(task1, NULL, KTHREAD_CPU_AFFINITY_NONE, "print");
//kthread_set_sched_edf(t, 1000000, 50000, 90000); //kthread_set_sched_edf(t, 1000000, 50000, 90000);
t->priority = 4; t->priority = 4;
...@@ -163,7 +184,7 @@ int kernel_main(void) ...@@ -163,7 +184,7 @@ int kernel_main(void)
//kthread_set_sched_edf(t, 1000000, 50000, 90000); //kthread_set_sched_edf(t, 1000000, 50000, 90000);
t->priority = 8; t->priority = 8;
kthread_wake_up(t); kthread_wake_up(t);
#endif
while(1) { while(1) {
......
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)
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.
#
# 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
/* 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)
#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 */
load leanos
run
quit
#!/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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment