Commit 9cc191db authored by Thanassis Tsiodras's avatar Thanassis Tsiodras

Complete scaffold for building EDISOFT RTEMS applications including native FPU usage

parents
Pipeline #27 skipped
# Configuration section
#
# Use environment variables if found, otherwise fallback to sane defaults
RTEMS_MAKEFILE_PATH ?= /opt/rtems-4.8/sparc-rtems4.8/leon3
RTEMS_LIB=${RTEMS_MAKEFILE_PATH}/lib
EDISOFT_SUPPORT_PATH ?= /root/development/build/rtems-impr/testsuites/support
CROSS_PREFIX=sparc-rtems4.8
# Detect the platform (last part of the path of RTEMS_MAKEFILE_PATH - e.g. leon3, leon2, etc)
PLATFORM = $(shell sh -c "echo ${RTEMS_MAKEFILE_PATH} | sed 's,^.*/,,'")
# The directories containing the source files, separated by ':'
VPATH=src:${EDISOFT_SUPPORT_PATH}/src
# If not selected, compile debug version of binary (no optimizations)
ifeq ($(CFG),)
CFG=debug
endif
# If not explicitely selected (with 'make FPU=1'), compile for FPU emulation
ifeq ($(FPU),)
FPU=0
endif
# Use EDISOFT's support code for e.g. printing to serial (printk)
EDISOFT_SRC= \
printk.c \
# In case you need them, EDISOFT's tests also include versions of:
# strcat.c \
# strcmp.c \
# strcpy.c \
# strlen.c \
# Remember, there's no C library in this universe - unless you explicitely
# compile with newlib! See EDISOFT's UMDN for details.
#
# This is necessary for printk (serial port registers per specific BSP)
EDISOFT_SRC += ${PLATFORM}.c
# Your source files: regardless of where they reside in the source tree,
# VPATH will locate them...
NONFPU_SRC= \
init.c \
${EDISOFT_SRC}
FPU_SRC= \
task1.c
# Build a Dependency list and an Object list, by replacing the .c
# extension to .d for dependency files, and .o for object files.
NONFPU_DEP = $(patsubst %.c, deps.$(CFG)/NONFPU_%.d, ${NONFPU_SRC})
FPU_DEP = $(patsubst %.c, deps.$(CFG)/FPU_%.d, ${FPU_SRC})
NONFPU_OBJ = $(patsubst %.c, objs.$(CFG)/NONFPU_%.o, ${NONFPU_SRC})
FPU_OBJ = $(patsubst %.c, objs.$(CFG)/FPU_%.o, ${FPU_SRC})
# Your final binary
TARGET=fputest
# What compiler to use for generating dependencies:
# it will be invoked with -MM -MP
CC = ${CROSS_PREFIX}-gcc
CDEP = ${CC}
# What include flags to pass to the compiler
INCLUDEFLAGS= -I${EDISOFT_SUPPORT_PATH}/include -I src
# Compilation flags (common)
COMMON += -B${RTEMS_LIB} -specs bsp_specs -qrtems -nodefaultlibs \
-mcpu=cypress -DBSP_leon3
# Separate compile options per configuration
ifeq ($(CFG),debug)
CFLAGS += ${COMMON} -g -Wall -D_DEBUG ${INCLUDEFLAGS} -msoft-float
else
CFLAGS += ${COMMON} -g -O2 -Wall ${INCLUDEFLAGS} -msoft-float
endif
# Should we generate native FPU instructions for the FPU_SRC?
ifeq ($(FPU),1)
CFLAGS_FPU:=$(shell bash -c "echo ${CFLAGS} | sed 's,-msoft-float,,'")
else
CFLAGS_FPU:=${CFLAGS}
LDFLAGS += -msoft-float
endif
# A common link flag for all configurations
LDFLAGS += ${COMMON} -nodefaultlibs -Wl,--wrap,_IO_Initialize_all_drivers \
${RTEMS_LIB}/libno_event.a ${RTEMS_LIB}/libno_msg.a \
${RTEMS_LIB}/libno_sem.a ${RTEMS_LIB}/libno_timer.a \
${RTEMS_LIB}/libno_rtmon.a ${RTEMS_LIB}/libno_ext.a \
-Wl,--start-group -lrtemscpu -lio -lno_event -lno_msg -lno_sem \
-lno_timer -lno_rtmon -lno_ext -lrtemsbsp -llibc -lrtemscpu \
-Wl,--end-group -Wl,--script=linkcmds \
-B/tmp/edilibtmp/edilib/library -lgcc
all: inform bin.$(CFG)/${TARGET}
inform:
ifneq ($(CFG),release)
ifneq ($(CFG),debug)
@echo "Invalid configuration "$(CFG)" specified."
@echo "You must specify a configuration when running make, e.g."
@echo "make CFG=debug"
@echo
@echo "Possible choices for configuration are 'release' and 'debug'"
@exit 1
endif
endif
bin.$(CFG)/${TARGET}: ${NONFPU_OBJ} ${FPU_OBJ} | inform
@mkdir -p $(dir $@)
ifeq ($(V),1)
$(CC) -g -o $@ $^ ${LDFLAGS}
else
@echo [LD] $@
@$(CC) -g -o $@ $^ ${LDFLAGS}
endif
ifeq ($(CFG),release)
@${CROSS_PREFIX}-objcopy --only-keep-debug $@ ${@}.debug
@${CROSS_PREFIX}-strip $@
endif
@echo Built with RTEMS at ${RTEMS_LIB} for ${PLATFORM}.
objs.$(CFG)/NONFPU_%.o: %.c
@mkdir -p $(dir $@)
ifeq ($(V),1)
$(CC) -c $(CFLAGS) -o $@ $<
else
@echo [CC] $@
@$(CC) -c $(CFLAGS) -o $@ $<
endif
objs.$(CFG)/FPU_%.o: %.c
@mkdir -p $(dir $@)
ifeq ($(V),1)
$(CC) -c $(CFLAGS_FPU) -o $@ $<
else
@echo [CC] $@
@$(CC) -c $(CFLAGS_FPU) -o $@ $<
endif
deps.$(CFG)/NONFPU_%.d: %.c
@mkdir -p $(dir $@)
@echo Generating dependencies for $<
@set -e ; $(CDEP) -MM -MP $(INCLUDEFLAGS) $< > $@.$$$$; \
sed 's,\($*\)\.o[ :]*,objs.$(CFG)\/NONFPU_\1.o $@ : ,g' < $@.$$$$ > $@; \
rm -f $@.$$$$
deps.$(CFG)/FPU_%.d: %.c
@mkdir -p $(dir $@)
@echo Generating dependencies for $<
@set -e ; $(CDEP) -MM -MP $(INCLUDEFLAGS) $< > $@.$$$$; \
sed 's,\($*\)\.o[ :]*,objs.$(CFG)\/NONFPU_\1.o $@ : ,g' < $@.$$$$ > $@; \
rm -f $@.$$$$
clean:
@rm -rf \
deps.debug objs.debug bin.debug \
deps.release objs.release bin.release
# Unless "make clean" is called, include the dependency files
# which are auto-generated. Don't fail if they are missing
# (-include), since they will be missing in the first invocation!
ifneq ($(MAKECMDGOALS),clean)
-include ${NONFPU_DEP}
-include ${FPU_DEP}
endif
/*
* Example initialization file - spawns 2 native FPU tasks
*
*/
#define CONFIGURE_INIT
#define TASKS 2
#include "system.h"
#include "printk.h"
rtems_task Init(rtems_task_argument argument)
{
rtems_status_code status;
rtems_name Task_name[TASKS]; /* task names */
rtems_id Task_id[TASKS]; /* task ids */
int i;
for(i = 0; i < TASKS; i++)
{
// Initialize Task name
Task_name[i] = rtems_build_name('T', 'T', "0" + i / 10, "0" + i % 10);
// Create Task
status = rtems_task_create(
Task_name[i],
(rtems_task_priority) (i + 1),
RTEMS_MINIMUM_STACK_SIZE,
RTEMS_DEFAULT_MODES,
RTEMS_FLOATING_POINT, // use RTEMS_DEFAULT_ATTRIBUTES for non-native FPU tasks
&Task_id[i]);
if (status != RTEMS_SUCCESSFUL) {
printk("Failed to rtems_task_create... status:%0x\n", status);
rtems_task_delete(RTEMS_SELF);
}
// Start Task
status = rtems_task_start(
Task_id[i],
Task_EntryPoint,
i);
}
printk("Parent task sleeps for a second...\n");
rtems_task_wake_after(100);
rtems_task_delete(RTEMS_SELF);
}
#include <rtems/score/types.h>
#include <rtems/rtems/types.h>
#include <rtems/rtems/tasks.h>
rtems_task Init(rtems_task_argument argument);
rtems_task Task_EntryPoint(rtems_task_argument argument);
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
#define CONFIGURE_MAXIMUM_TASKS 64
#define CONFIGURE_TICKS_PER_TIMESLICE 100
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
#include <rtems/confdefs.h>
#include "system.h"
#include "printk.h"
rtems_task Task_EntryPoint(rtems_task_argument argument)
{
int task_no = (int) argument;
printk("Inside task %d...\n", task_no);
int j;
double d=task_no;
for(j=0; j<10000; j++) {
int k;
for(k=0; k<100; k++)
d+=1.001;
d*=1.0001;
}
printk("Computed value by task %d was %ld\n", task_no, (long)d);
rtems_task_delete(RTEMS_SELF);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment