Commit 934a73d6 authored by julien.delange's avatar julien.delange

first implementation of the RTEMS_PURE mode, works with x86 and RMA example



git-svn-id: https://tecsw.estec.esa.int/svn/taste/trunk/po-hi-c@1234 129961e7-ef38-4bb5-a8f7-c9a525a55882
parent e01ec2a0
......@@ -2,12 +2,16 @@
void user_hello_spg_1 (void)
{
#if 1
printf ("FIRST TASK\n");
fflush (stdout);
#endif
}
void user_hello_spg_2 (void)
{
#if 1
printf ("SECOND TASK\n");
fflush (stdout);
#endif
}
......@@ -51,10 +51,6 @@
#endif /* RTEMS_POSIX */
#if defined(RTEMS_PURE)
#include <rtems.h>
#include <inttypes.h>
#define CONFIGURE_INIT
#include <bsp.h>
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_NULL_DRIVER
......@@ -64,12 +60,19 @@
#define CONFIGURE_MAXIMUM_SEMAPHORES 20
#define CONFIGURE_MAXIMUM_TASKS 20
#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 20
#define CONFIGURE_MAXIMUM_PERIODS 40
#define CONFIGURE_TICKS_PER_TIMESLICE 0
int Init ();
#define CONFIGURE_EXTRA_TASK_STACKS (20 * RTEMS_MINIMUM_STACK_SIZE)
#define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
#define CONFIGURE_MAXIMUM_TASKS 20
#define CONFIGURE_INIT
#include <rtems.h>
#include <inttypes.h>
#include <bsp.h>
#include <rtems/confdefs.h>
#endif /* RTEMS_POSIX */
......
......@@ -18,6 +18,7 @@
/* Errors from the API */
#define __PO_HI_ERROR_CREATE_TASK -10
#define __PO_HI_ERROR_TASK_PERIOD -11
#define __PO_HI_ERROR_CLOCK -15
#define __PO_HI_ERROR_QUEUE_FULL -20
......
......@@ -50,11 +50,11 @@
#define __PO_HI_DEFAULT_PRIORITY ((sched_get_priority_min(SCHED_FIFO) + sched_get_priority_max(SCHED_FIFO))/2)
#elif defined(RTEMS_PURE)
#include <rtems.h>
#include <inttypes.h>
#include <po_hi_time.h>
#include <bsp.h>
#define __PO_HI_DEFAULT_PRIORITY 10
#define __PO_HI_DEFAULT_PRIORITY RTEMS_NO_PRIORITY
#endif
#include <po_hi_types.h>
......
......@@ -14,7 +14,7 @@ define bsp-post-link
endef
MANAGERS = all
MANAGERS = all rate_monotonic
CC = i386-rtems4.8-gcc
CPP = i386-rtems4.8-g++
......
......@@ -22,10 +22,8 @@
/* Header files in PolyORB-HI */
#include <deployment.h>
/* Header files from generated code */
#ifdef RTEMS_PURE
#include <bsp.h>
#endif
int nb_tasks; /* number of created tasks */
......@@ -41,7 +39,7 @@ typedef struct
pthread_mutex_t mutex;
pthread_cond_t cond;
#elif defined(RTEMS_PURE)
rtems_time_of_day timer; /* Next period to wait */
rtems_id ratemon_period;
#endif
} __po_hi_task_t;
/*
......@@ -73,6 +71,7 @@ void __po_hi_wait_for_tasks ()
*/
int __po_hi_compute_next_period (__po_hi_task_id task)
{
#if defined(RTEMS_POSIX) || defined(POSIX)
__po_hi_time_t mytime;
......@@ -84,19 +83,21 @@ int __po_hi_compute_next_period (__po_hi_task_id task)
return (__PO_HI_SUCCESS);
#elif defined (RTEMS_PURE)
if (rtems_clock_get (RTEMS_CLOCK_GET_TOD, &tasks[task].timer) != RTEMS_SUCCESSFUL)
{
__DEBUGMSG ("ERROR WHILE TRYING TO GET THE CLOCK\n");
return (__PO_HI_UNAVAILABLE);
}
tasks[task].timer.second += 2;
/*
* TODO
* MUST FIX THAT
*/
rtems_status_code ret;
rtems_name name;
return (__PO_HI_SUCCESS);
if (tasks[task].ratemon_period == RTEMS_INVALID_ID)
{
name = rtems_build_name ('P', 'R', 'D' + (char)task, ' ');
__DEBUGMSG ("Create monotonic server for task %d\n", task);
ret = rtems_rate_monotonic_create (name, &(tasks[task].ratemon_period));
if (ret != RTEMS_SUCCESSFUL)
{
__DEBUGMSG ("Error while creating the monotonic server, task=%d, status=%d\n", task, ret);
}
}
return (__PO_HI_SUCCESS);
#else
return (__PO_HI_UNAVAILABLE);
#endif
......@@ -114,16 +115,25 @@ int __po_hi_wait_for_next_period (__po_hi_task_id task)
return (__PO_HI_SUCCESS);
#elif defined (RTEMS_PURE)
if (rtems_task_wake_when (&tasks[task].timer) != RTEMS_SUCCESSFUL)
{
__DEBUGMSG ("Error rtems_task_wake_when()\n");
// return (__PO_HI_UNAVAILABLE);
}
rtems_status_code ret;
/* ret = rtems_rate_monotonic_period (&tasks[task].ratemon_period, (rtems_interval)tasks[task].period * ); */
ret = rtems_rate_monotonic_period (tasks[task].ratemon_period, tasks[task].period / _TOD_Microseconds_per_tick);
rtems_task_wake_after(RTEMS_YIELD_PROCESSOR);
__po_hi_compute_next_period (task);
switch (ret)
{
case RTEMS_SUCCESSFUL:
return (__PO_HI_SUCCESS);
break;
case RTEMS_TIMEOUT:
__DEBUGMSG ("Error in rtems_rate_monotonic_period (TIMEOUT)\n");
return (__PO_HI_ERROR_TASK_PERIOD);
break;
default:
return (__PO_HI_UNAVAILABLE);
break;
}
return (__PO_HI_SUCCESS);
return (__PO_HI_UNAVAILABLE);
#else
return (__PO_HI_UNAVAILABLE);
#endif
......@@ -137,6 +147,9 @@ int __po_hi_initialize_tasking( )
{
tasks[i].period = 0;
tasks[i].id = invalid_task_id;
#ifdef RTEMS_PURE
tasks[i].ratemon_period = RTEMS_INVALID_ID;
#endif
}
nb_tasks = 0;
......@@ -252,7 +265,7 @@ int __po_hi_rtems_create_thread (__po_hi_priority_t priority,
__DEBUGMSG ("ERROR when creating the task\n");
}
if (rtems_task_start( id, start_routine, 0 ) != RTEMS_SUCCESSFUL)
if (rtems_task_start( id, (rtems_task_entry)start_routine, 0 ) != RTEMS_SUCCESSFUL)
{
__DEBUGMSG ("ERROR when starting the task\n");
}
......@@ -287,7 +300,7 @@ int __po_hi_create_generic_task (__po_hi_task_id id,
my_task = &(tasks[id]);
my_task->period = period;
my_task->id = id;
#if defined (POSIX) || defined (RTEMS_POSIX)
my_task->tid = __po_hi_posix_create_thread (priority, stack_size, start_routine);
__po_hi_posix_initialize_task (my_task);
......@@ -317,11 +330,12 @@ int __po_hi_create_periodic_task (__po_hi_task_id id,
* Compute the next period of the task, using the
*__po_hi_time* functions.
*/
#if defined (RTEMS_POSIX) || defined (POSIX)
if (__po_hi_compute_next_period (id) != __PO_HI_SUCCESS)
{
return (__PO_HI_ERROR_CLOCK);
}
#endif
return (__PO_HI_SUCCESS);
}
......
......@@ -36,8 +36,10 @@ int __po_hi_simulate_wcet (__po_hi_time_t time1, __po_hi_time_t time2)
}
}
return 0;
/*
#else
__DEBUGMSG ("WCET simulation not handled at this time\n");
*/
#endif
return 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