Commit 5705e24a authored by Thanassis Tsiodras's avatar Thanassis Tsiodras

Preparing for EUCLID/MicroPython

parent 204a0433
......@@ -4,7 +4,7 @@
# If not explicitely selected (with 'make FPU=1'), compile for FPU emulation
ifeq ($(FPU),)
FPU=0
FPU=1
endif
# To be able to properly handle any combination of (FPU, LEON, release)
......@@ -16,7 +16,7 @@ FPU_SUFFIX=NONFPU
endif
# Build up our settings from our inputs and our environment
LEON ?= leon3
LEON ?= leon2
RTEMS ?= /opt/rtems-4.8
RTEMS_MAKEFILE_PATH = ${RTEMS}/sparc-rtems4.8/${LEON}
RTEMS_LIB=${RTEMS_MAKEFILE_PATH}/lib
......@@ -24,9 +24,9 @@ EDISOFT_SUPPORT_PATH ?= ${RTEMS}/support
CROSS_PREFIX=sparc-rtems4.8
# If not selected, compile debug version of binary (no optimizations)
#ifeq ($(CFG),)
#CFG=debug
#endif
ifeq ($(CFG),)
CFG=debug
endif
# The directories containing the source files, separated by ':'
#
......@@ -54,8 +54,10 @@ EDISOFT_SRC += ${LEON}.c
# DEAR USER, YOU MUST EDIT THIS
NONFPU_SRC= \
init.c \
task2.c \
${EDISOFT_SRC}
common.c \
task2.c
NONFPU_SRC+=${EDISOFT_SRC}
FPU_SRC= \
task1.c \
......@@ -88,9 +90,9 @@ COMMON += -B${RTEMS_LIB} -specs bsp_specs -qrtems -nodefaultlibs \
# Separate compile options per configuration
ifeq ($(CFG),debug)
CFLAGS += ${COMMON} -g -Wall -D_DEBUG ${INCLUDEFLAGS}
CFLAGS += ${COMMON} -g -Wall -Wextra -D_DEBUG ${INCLUDEFLAGS}
else
CFLAGS += ${COMMON} -g -O2 -Wall ${INCLUDEFLAGS}
CFLAGS += ${COMMON} -g -O2 -Wall -Wextra ${INCLUDEFLAGS}
endif
# FPU section
......@@ -106,10 +108,10 @@ 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 \
-Wl,--start-group -lrtemscpu -lio -lno_event -lmsg -lno_sem \
-lno_timer -lno_rtmon -lno_ext -lrtemsbsp -llibc -lrtemscpu \
-Wl,--end-group -Wl,--script=linkcmds \
-B${RTEMS}/edilib/library -lgcc
-B${RTEMS}/support/edilib/library -lm -lgcc -lc
all: inform bin.$(SUFFIX)/${TARGET}
......
/*
* Example initialization file - spawns 2 native FPU tasks
* Example initialization file - spawns 2 tasks
*
*/
#define CONFIGURE_INIT
#define TASKS 2
#define DEFINE_VARS
#include "system.h"
#include "printk.h"
rtems_task shepherd_EntryPoint(rtems_task_argument argument)
{
int tasks_completed = 0;
rtems_interval ticks_per_second;
(void) argument;
printk("[SHEPHERD] Waiting for testing tasks to complete...\n");
(void) rtems_clock_get(RTEMS_CLOCK_GET_TICKS_PER_SECOND, &ticks_per_second);
while(1) {
unsigned buffer;
size_t size;
rtems_status_code status = rtems_message_queue_receive(
Q_id, (void*)&buffer, &size, RTEMS_WAIT, ticks_per_second);
if ( status == RTEMS_SUCCESSFUL ) {
if (size != 4) {
printk("[SHEPHERD] More than 4 bytes sent over Q! (%d)\n", size);
rtems_task_delete(RTEMS_SELF);
}
printk("[SHEPHERD] Task %d completed with exit code %d.\n", buffer&1, buffer>>31);
tasks_completed ++;
if (tasks_completed == 2)
break;
} else if ( status != RTEMS_TIMEOUT ) {
printk("[SHEPHERD] rtems_message_queue_receive failed, status: %d\n", status);
rtems_task_delete(RTEMS_SELF);
}
}
printk("[SHEPHERD] All testing tasks completed.\n");
if (!all_OK)
printk("[SHEPHERD] Some tests failed... :-(\n");
else
printk("[SHEPHERD] All tests passed! :-)\n");
}
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;
rtems_name Task_name[TASKS+1]; /* task names */
rtems_id Task_id[TASKS+1]; /* task ids */
(void) argument;
// Create the synchronization msg Q first
rtems_status_code status = rtems_message_queue_create(
rtems_build_name('Q', '1', ' ', ' '),
TASKS, /* 1 message per task should suffice */
4, /* each message carries the task no (32-bit int) */
RTEMS_DEFAULT_ATTRIBUTES,
&Q_id);
if (status != RTEMS_SUCCESSFUL) {
printk("Failed to rtems_message_queue_create... status:%0x\n", status);
rtems_task_delete(RTEMS_SELF);
}
all_OK = 1;
for(i = 0; i < TASKS; i++)
{
// Initialize Task name
......@@ -25,12 +74,12 @@ rtems_task Init(rtems_task_argument argument)
Task_name[i],
(rtems_task_priority) 2,
RTEMS_MINIMUM_STACK_SIZE,
RTEMS_DEFAULT_MODES, // use RTEMS_DEFAULT_MODES | RTEMS_TIMESLICE for Linux/Windows like
// handling of tasks with same priority (i.e. pre-emption)
i == 1 ? RTEMS_FLOATING_POINT : RTEMS_DEFAULT_ATTRIBUTES,
RTEMS_DEFAULT_MODES | RTEMS_TIMESLICE, // Force pre-emption
i == 1 ? RTEMS_FLOATING_POINT // 2nd task does FPU
: RTEMS_DEFAULT_ATTRIBUTES,
&Task_id[i]);
if (status != RTEMS_SUCCESSFUL) {
printk("Failed to rtems_task_create... status:%0x\n", status);
printk("Failed to rtems_task_create, status: %d\n", status);
rtems_task_delete(RTEMS_SELF);
}
......@@ -38,10 +87,24 @@ rtems_task Init(rtems_task_argument argument)
status = rtems_task_start(
Task_id[i],
i == 1 ? Task1_EntryPoint : Task2_EntryPoint,
i);
i); // task argument passed in the function pointer (the task no)
}
printk("Parent task sleeps for a second...\n");
rtems_task_wake_after(100);
printk("Parent task bids adieu...\n");
// Launch the last task - the "shepherd"
Task_name[i] = rtems_build_name('T', 'T', "0" + i / 10, "0" + i % 10);
status = rtems_task_create(
Task_name[i],
(rtems_task_priority) 2,
RTEMS_MINIMUM_STACK_SIZE,
RTEMS_DEFAULT_MODES | RTEMS_TIMESLICE,
RTEMS_DEFAULT_ATTRIBUTES,
&Task_id[i]);
if (status != RTEMS_SUCCESSFUL) {
printk("Failed to rtems_task_create... status:%0x\n", status);
rtems_task_delete(RTEMS_SELF);
}
status = rtems_task_start(Task_id[i], shepherd_EntryPoint, i);
// Now die and let the shepherd take care of the flock :-)
rtems_task_delete(RTEMS_SELF);
}
#include <rtems/system.h>
#include <rtems/score/types.h>
#include <rtems/rtems/types.h>
#include <rtems/rtems/tasks.h>
......@@ -5,10 +6,22 @@
rtems_task Init(rtems_task_argument argument);
rtems_task Task1_EntryPoint(rtems_task_argument argument);
rtems_task Task2_EntryPoint(rtems_task_argument argument);
void die(int task_no, unsigned exitCode);
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
#define CONFIGURE_MAXIMUM_TASKS 64
#define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 20
#define CONFIGURE_TICKS_PER_TIMESLICE 100
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
#ifndef DEFINE_VARS
#define GLOBAL
#else
#define GLOBAL extern
#endif
GLOBAL int all_OK;
GLOBAL rtems_id Q_id;
#include <rtems/confdefs.h>
#include <math.h>
#include "system.h"
#include "printk.h"
rtems_task Task1_EntryPoint(rtems_task_argument argument)
{
int j = 0;
int task_no = (int) argument;
printk("Inside task %d...\n", task_no);
double d = task_no;
int j;
double d=task_no;
printk("Inside task %d...\n", task_no);
for(j=0; j<10000; j++) {
int k;
for(k=0; k<10000; 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);
{
long result = (long) d;
long target = 172003608;
if (target != result) {
printk(
"[TASK %d] Failed! Computed value was %ld instead of %ld\n",
task_no, result, target);
all_OK = 0;
die(task_no, 1);
rtems_task_delete(RTEMS_SELF);
return;
}
}
printk("[TASK %d] Computed the correct floating point result.\n", task_no);
die(task_no, 0);
}
......@@ -3,17 +3,24 @@
rtems_task Task2_EntryPoint(rtems_task_argument argument)
{
int j = 0;
int task_no = (int) argument;
printk("Inside task %d...\n", task_no);
int j;
long long int dummy = 0;
for(j=0; j<100000; j++) {
printk("Inside task %d...\n", task_no);
for(j=0; j<500000; j++) {
int k;
for(k=0; k<100; k++)
dummy ^= k;
dummy++;
}
printk("Computed value by task %d was %d,%d\n", task_no, dummy&0xffffffff, dummy>>32);
rtems_task_delete(RTEMS_SELF);
if (dummy != 500000) {
printk(
"[TASK %d] Failed! Computed value was %lld instead of 500000\n",
task_no, dummy);
all_OK = 0;
die(task_no, 1);
}
printk("[TASK %d] Computed the correct integer result.\n", task_no);
die(task_no, 0);
}
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