librtems++: Remove from RTEMS.

This is old and there are better design patterns for threading and C++.
We recommend you use the new C++ standards based support.

Closes #2777.
This commit is contained in:
Chris Johns
2016-08-10 13:28:50 +10:00
parent 9a4eca5843
commit 03c1038edb
30 changed files with 1 additions and 3662 deletions

View File

@@ -140,12 +140,6 @@ AC_SUBST(libbsp_cpu_subdir,$RTEMS_CPU)
BSP_SUBDIRS="$BSP_SUBDIRS lib"
BSP_SUBDIRS="$BSP_SUBDIRS libchip"
AS_IF([test "$RTEMS_HAS_CPLUSPLUS" = "yes"],[
AC_CONFIG_SUBDIRS([librtems++])
BSP_SUBDIRS="$BSP_SUBDIRS librtems++"
])
BSP_SUBDIRS="$BSP_SUBDIRS support"
BSP_SUBDIRS="$BSP_SUBDIRS ada"
BSP_SUBDIRS="$BSP_SUBDIRS wrapup"

View File

@@ -1,23 +0,0 @@
ACLOCAL_AMFLAGS = -I ../aclocal
include $(top_srcdir)/../automake/compile.am
if HAS_CXX
include_rtems__dir = $(includedir)/rtems++
include_rtems___HEADERS = include/rtems++/rtemsEvent.h \
include/rtems++/rtemsInterrupt.h include/rtems++/rtemsMessageQueue.h \
include/rtems++/rtemsSemaphore.h include/rtems++/rtemsStatusCode.h \
include/rtems++/rtemsTask.h include/rtems++/rtemsTaskMode.h \
include/rtems++/rtemsTimer.h
project_lib_LIBRARIES = librtems++.a
librtems___a_SOURCES = src/rtemsEvent.cc src/rtemsInterrupt.cc \
src/rtemsMessageQueue.cc src/rtemsSemaphore.cc src/rtemsStatusCode.cc \
src/rtemsTask.cc src/rtemsTimer.cc
librtems___a_CPPFLAGS = $(AM_CPPFLAGS)
endif
include $(srcdir)/preinstall.am
include $(top_srcdir)/../automake/local.am

View File

@@ -1,262 +0,0 @@
RTEMS C++ Library
=================
The RTEMS C++ Library or librtems++ is a wrapper for the RTEMS API.
The classes provide as close a match to the RTEMS C API, for
performance, to share the existing C documentation as much as
possible, and to allow easy tracking of any changes to the RTEMS C
API.
The C++ interface only uses RTEMS API calls. No external references
or internal interfaces are used. This allows the classes to be used
in separately compiled modules or applications which link to the RTEMS
trap interface.
(This is the goal, which has not quite been reached. The TOD macro for
micro-seconds to ticks is used, and this uses an internal global RTEMS
variable)
The C++ interface does not deal with RTEMS initialisation or the
device driver interface. The current view is these parts of a system
are best handled in the current manner. This means BSP for
initialisation and the C API for drivers.
RTEMS C++ Classes
=================
The classes map to the managers of RTEMS.
The methods have default values selected which try to fit most cases
or follow the documented RTEMS default values. Moving from left to
right the parameters become less used, allowing the defaults to be
selected. An example is the scope parameter for most classes. This
can be local or global. I assume that most RTEMS objects are local,
therefore it has been made the last parameter.
Inline methods have been used for methods which are commonly used in
applications. This tries to add the minimum of overhead. For
example, the methods to send or receive events are inline, while all
methods for control of a task are not.
The RTEMS types, enumerations, and defines are used. If a new type,
enumeration or define is made it will map directly to the RTEMS
equivalent. For example the enumeration Scope is defined for various
classes which can be local or global. The elements of the enumeration
are forced to the same value as the RTEMS values. An enumeration is
used in this case to allow the compiler to type check a little
better. It saves having to check only RTEMS_LOCAL or RTEMS_GLOBAL is
passed as a parameter (I am not convinced this is really needed as the
goal was to not define anything and to only use what RTEMS provided).
Where possible the various parts of an option bit set, or mode can be
controlled separately or controlled as a group. An example is the
task mode. The RTEMS C API allows a set of modes to be modified at
once. The TaskMode class allows this to occur, while also providing
methods to control a single mode item.
The name of an object is always passed as a string. The classes turn
the string into a rtems_name variable. The string does not have to be
nul character terminated.
The RTEMS C API uses 'delete' to remove or kill an RTEMS object. This
is a reserved word in C++, so the word 'destroy' is used instead.
Calling the classes from interrupts follows the rules of RTEMS. An
exception introduced by the class library is the last status code.
There is only one last status code for each instance of the library's
classes and it is not protected. This needs to be watched for. Maybe
a better solution needs to be found, such as interrupt calls do not set
the last status code.
RTEMS objects created by the C++ library can be operated on by C code
just as any other RTEMS object. If limitations exist they should be
documented in under the class.
RTEMS Object Ownership
======================
The concept of ownership of an object is not defined as part of the
RTEMS C API. A piece of code executing as part a task can create a
message queue. Another piece of code running as part of a different
task can destroy the message queue. Correct behavior between the code
that creates the message queue and the code which destroy's the
message queue must be provided by the programmer.
The librtems++ supports the concept of ownership of an RTEMS object.
Only the C++ object that creates the RTEMS object can destroy it. A
C++ object can connect to an existing RTEMS object and control it,
how-ever it can not destroy it.
Copy constructors and assignment operators are provided to in-force
this rule.
Ownership only applies to classes that create RTEMS objects. These
classes contain a flag which signals ownership of the id.
Timeouts
========
The timeout value is specified in micro-seconds. The classes turn the
micro-second timeout value into ticks required by the RTEMS C API.
This causes a problem for timeout values which are less than one tick.
This case is tested for and the timeout value is set to one tick. All
other cases round down to the nearest tick.
Status Codes
============
All classes which form the C++ API are derived from the StatusCode
class. This class provides a common method for handling the status
code returned by RTEMS.
The last returned status code is held in the StatusCode object. It
can be queried directly, or as a boolean. You can also obtain an
error string for the status code.
The setting of a status code is restricted to derived classes.
The last status code attribute of the class is only ever set to an
RTEMS defined status code.
Event Class
===========
The event class allows users to send and receive events to and from
tasks.
Events objects are by default connected the RTEMS_SELF task. A send
or receive will operate on the task currently executing.
An Event object can be connected to a task using the connect method.
The name is the name of the task. Connection can also be achieved by
using the copy constructor or assignment operator.
Events can be sent to a task by specifying an RTEMS task id, or by
passing a reference to a Task object.
Interrupt Class
===============
The interrupt class allows a protected virtual method of a derived
class to be an interrupt handler.
You derive from this class and provide the handler method. The next
interrupt after the vector is caught will cause the handler method to
be entered.
You can chain the interrupt by calling the chain method. If the old
handler is not an instance of this class the chain is passed as "void
(*)(void)". If it is an instance of this class, the handler method is
directly called. (Chaining has not been tested)
This class implements a table of pointers to the last instance to
catch the interrupt. A static method of the class catches the
interrupt and re-directs the interrupt to the instance in the table.
The re-direct adds a additional virtual function call and return to
the overhead of the interrupt. For a i386 type processor this is
about 12 instructions including the function call entry.
Message Queue Class
===================
The MessageQueue class allows message queue's to be created, or
connected too. Only the creator can destroy a message queue.
The class implements, sending, urgent sending, broadcast, flushing,
and receiving.
Semaphore Class
===============
The Semaphore class allows semaphores to be created, or connected
too. Only the creator can destroy a semaphore.
All types of semaphores can be created.
(Not tested in the test code)
Task Class
==========
The Task class allows tasks to be created, or connected too. Only the
creator can destroy a task.
If creating a task, derive from the Task class and provide the body
method. The body method is the entry point for a task. When
connecting to an existing task, no body method is required to be
provided. It is how-ever required if you create a task. This is not
enforced by the compiler, how-ever the default body will be entered,
and it contains no code. The RTEMS default behaviour for a task that
returns occurs.
The mode of a task is controlled using the TaskMode class.
The Task class allows you to start, restart, suspend, and resume a
task. You can control the priority, and access the note-pad
registers. The task can also be slept using the wake_after and
wake_when methods.
Currently the task argument is used to pass the 'this' pointer to the
libraries default task body. The actual argument is held in the class
instance and passed to the virtual body method. This means of passing
the 'this' pointer through RTEMS to the default task body requires the
actual task object to perform a restart call. This is not really the
best solution to the problem. Another solution is to remove a notpad
register, say 31 from the task and use it. This would mean any Task
object could stop and restart a task how-ever a notpad register is
lost. Any other ideas are welcome.
Task Mode Class
===============
The TaskMode class allows you to query or change the mode of a task.
The object only operates on the currently executing task.
The standard flags defined in RTEMS are used.
Methods are provided to operate on a group of modes which are required
to be changed in a single operation. The mode and mask is specified
by ORing the required flags as documented in the RTEMS manual.
Methods are provided for accessing and controlling a specific mode.
The returned value will only contain the requested mode's flags, and
only the that mode will be changed when setting a mode.
Timer Class
===========
The Timer class allows timers to be created. You cannot connect to an
existing timer.
You derive from the Timer class and provide the trigger method. This
method is called when the timer triggers or times out.
You can request a single shot timer using the fire_after or fire_when
methods, or a periodic timer by calling the repeat_file_at method.
You cannot copy timer objects.
Contact
=======
Send any question to me Chris Johns at cjohns@plessey.com.au, or the RTEMS
mailing list.
To Do
=====
1) Develop a complete test suite (under way, cjohns@plessey.com.au).
2) Complete wrapping the remaining RTEMS C API.
3) Provide light weight cout/cerr/clog classes based on printf for
embedded systems.
4) Provide a memory serial class which maps the <</>> operators onto
raw memory in network byte order independent of CPU byte order.
5) Fix the Task class so any Task object can restart a task.
6) Provide some frame work classes which allow actor type objects that
start in an ordered manner.

View File

@@ -1,35 +0,0 @@
## Process this file with autoconf to produce a configure script.
##
AC_PREREQ([2.69])
AC_INIT([rtems-c-src-librtems++],[_RTEMS_VERSION],[https://devel.rtems.org/newticket],[rtems-c-src-librtems++])
AC_CONFIG_SRCDIR([include/rtems++])
RTEMS_TOP(../../..)
RTEMS_CANONICAL_TARGET_CPU
AM_INIT_AUTOMAKE([no-define foreign subdir-objects 1.12.2])
AM_MAINTAINER_MODE
RTEMS_ENABLE_CXX
RTEMS_ENV_RTEMSBSP
RTEMS_CHECK_CXX(RTEMS_BSP)
## check for g++
RTEMS_PROG_CXX_FOR_TARGET
RTEMS_CANONICALIZE_TOOLS
AM_CONDITIONAL(HAS_CXX,test "$HAS_CPLUSPLUS" = "yes")
AC_LANG_PUSH(C++)
AC_CHECK_HEADER([cstring],[],[AC_MSG_ERROR([Required header cstring not found])])
AC_CHECK_HEADER([cstdlib],[],[AC_MSG_ERROR([Required header cstdlib not found])])
AC_LANG_POP
RTEMS_PROJECT_ROOT
RTEMS_AMPOLISH3
# Explicitly list all Makefiles here
AC_CONFIG_FILES([Makefile])
AC_OUTPUT

View File

@@ -1,120 +0,0 @@
/*
------------------------------------------------------------------------
COPYRIGHT (c) 1997
Objective Design Systems Ltd Pty (ODS)
All rights reserved (R) Objective Design Systems Ltd Pty
The license and distribution terms for this file may be found in the
file LICENSE in this distribution or at
http://www.rtems.org/license/LICENSE.
------------------------------------------------------------------------
rtemsEvent class.
This class allows the user to send and receive RTEMS events to a task.
------------------------------------------------------------------------ */
#if !defined(_rtemsEvent_h_)
#define _rtemsEvent_h_
#include <rtems++/rtemsStatusCode.h>
#include <rtems++/rtemsTask.h>
/* ----
rtemsEvent
*/
class rtemsEvent
: public rtemsStatusCode
{
public:
// attribute a task can have
enum WaitMode { wait = RTEMS_WAIT,
no_wait = RTEMS_NO_WAIT};
enum Condition { any = RTEMS_EVENT_ANY,
all = RTEMS_EVENT_ALL};
// only the first 4 characters of the name are taken
// connect to a task
rtemsEvent(const char* name, uint32_t node = RTEMS_SEARCH_ALL_NODES);
// copy and default constructors
rtemsEvent(const rtemsEvent& event);
rtemsEvent();
virtual ~rtemsEvent();
// connect to an existing task object, will not be the owner
const rtemsEvent& operator=(const rtemsEvent& event);
virtual const rtems_status_code connect(const char *name,
const uint32_t node = RTEMS_SEARCH_ALL_NODES);
// send an event
inline const rtems_status_code send(const rtems_id task,
const rtems_event_set events);
inline const rtems_status_code send(const rtemsTask& task,
const rtems_event_set events) ;
inline const rtems_status_code send(const rtems_event_set events);
// receive an event, can block a task if no events waiting
inline const rtems_status_code receive(const rtems_event_set event_in,
rtems_event_set& event_out,
const rtems_interval micro_secs = 0,
const WaitMode wait = wait,
const Condition condition = any);
// object id, and name
const rtems_id task_id_is() const { return id; }
const rtems_name task_name_is() const { return name; }
private:
// task name
rtems_name name;
// the rtems task id, object handle
rtems_id id;
};
const rtems_status_code rtemsEvent::send(const rtems_id task,
const rtems_event_set events)
{
set_status_code(rtems_event_send(task, events));
return last_status_code();
}
const rtems_status_code rtemsEvent::send(const rtemsTask& task,
const rtems_event_set events)
{
set_status_code(rtems_event_send(task.id_is(), events));
return last_status_code();
}
const rtems_status_code rtemsEvent::send(const rtems_event_set events)
{
set_status_code(rtems_event_send(id, events));
return last_status_code();
}
const rtems_status_code rtemsEvent::receive(const rtems_event_set event_in,
rtems_event_set& event_out,
const rtems_interval micro_secs,
const WaitMode wait,
const Condition condition)
{
rtems_interval usecs = micro_secs &&
(micro_secs < rtems_configuration_get_microseconds_per_tick()) ?
rtems_configuration_get_microseconds_per_tick() : micro_secs;
set_status_code(rtems_event_receive(event_in,
wait | condition,
RTEMS_MICROSECONDS_TO_TICKS(usecs),
&event_out));
return last_status_code();
}
#endif // _rtemsEvent_h_

View File

@@ -1,98 +0,0 @@
/*
------------------------------------------------------------------------
COPYRIGHT (c) 1997
Objective Design Systems Ltd Pty (ODS)
All rights reserved (R) Objective Design Systems Ltd Pty
The license and distribution terms for this file may be found in the
file LICENSE in this distribution or at
http://www.rtems.org/license/LICENSE.
------------------------------------------------------------------------
rtemsInterrupt class.
This class catches an interrupt and passes control to the user's
derived class throught the handler method.
The interrupt is released back to the previous handler when this
object destructs.
The old handler can be chained to after the interrupt is
caught. Watch the stack usage!
More than one instance of this class can catch the same vector. The
application will have to chain to the other objects if required. If
the old handler is not an instance of this class the chain is passed
as "void (*)(void)". If it is an instance of this class, the handler
method is directly called.
The isr catch extends the documented return codes with :
RTEMS_RESOURCE_IN_USE = interrupt already caught
------------------------------------------------------------------------ */
#if !defined(_rtemsInterrupt_h_)
#define _rtemsInterrupt_h_
#include <rtems++/rtemsStatusCode.h>
/* ----
rtemsInterrupt
*/
class rtemsInterrupt
: public rtemsStatusCode
{
public:
rtemsInterrupt();
virtual ~rtemsInterrupt();
// catch the interrupt
virtual const rtems_status_code isr_catch(const rtems_vector_number vector);
// release the interrupt back to the previous handle
virtual const rtems_status_code release();
// the old handler
const rtems_isr_entry old_isr_handler() const { return old_handler; }
protected:
// called after the interrupt is caught and it goes off
virtual void handler() = 0;
// chain to the previous handler,
inline void chain() const;
private:
const rtemsInterrupt& operator=(const rtemsInterrupt& );
rtemsInterrupt(const rtemsInterrupt& );
// the vector caught
rtems_vector_number vector;
// true when the interrupt is caught
bool caught;
// returned when catching the interrupt
rtems_isr_entry old_handler;
// old interrupt table entry
rtemsInterrupt *old_interrupt;
// common handler to redirect the interrupts
static void redirector(rtems_vector_number vector);
};
void rtemsInterrupt::chain() const
{
if (old_interrupt)
old_interrupt->handler();
else if (old_handler)
((void(*)()) old_handler)();
}
#endif // _rtemsInterrupt_h_

View File

@@ -1,170 +0,0 @@
/*
------------------------------------------------------------------------
COPYRIGHT (c) 1997
Objective Design Systems Ltd Pty (ODS)
All rights reserved (R) Objective Design Systems Ltd Pty
The license and distribution terms for this file may be found in the
file LICENSE in this distribution or at
http://www.rtems.org/license/LICENSE.
------------------------------------------------------------------------
rtemsMessageQueue class.
This class allows the user to create a RTEMS message queue, or to
access and manage an already existing message queue.
The first constructor with the message queue parameters creates a
RTEMS message queue object. The destructor of this object also
deletes the message queue object. The last status code should be
checked after construction to see if the create completed
successfully.
The second constructor connects to an existing message queue
object. The last status code should be checked after construction to
see if the message queue existed.
The third constructor is a copy constructor. Connects to an existing
object which is in scope.
The fourth constructor allows for the message queue to be created
after construction, or to connect to a message queue later.
------------------------------------------------------------------------ */
#if !defined(_rtemsMessageQueue_h_)
#define _rtemsMessageQueue_h_
#include <rtems++/rtemsStatusCode.h>
/* ----
rtemsMessageQueue
*/
class rtemsMessageQueue
: public rtemsStatusCode
{
public:
// attribute a message queue can have
enum WaitMode { wait_by_fifo = RTEMS_FIFO,
wait_by_priority = RTEMS_PRIORITY };
enum Scope { local = RTEMS_LOCAL,
global = RTEMS_GLOBAL };
// only the first 4 characters of the name are taken
// creates a message queue
rtemsMessageQueue(const char* name,
const uint32_t count,
const size_t max_message_size,
const WaitMode wait_mode = wait_by_fifo,
const Scope scope = local);
// connects to a message queue
rtemsMessageQueue(const char *name, const uint32_t node = RTEMS_SEARCH_ALL_NODES);
// copy and default constructors
rtemsMessageQueue(const rtemsMessageQueue& message_queue);
rtemsMessageQueue();
// only the creator's destructor will delete the actual object
virtual ~rtemsMessageQueue();
// create or destroy (delete) the message queue
virtual const rtems_status_code create(const char* name,
const uint32_t count,
const size_t max_message_size,
const WaitMode wait_mode = wait_by_fifo,
const Scope scope = local);
virtual const rtems_status_code destroy();
// connect to an existing message queue object, will not be the owner
const rtemsMessageQueue& operator=(const rtemsMessageQueue& message_queue);
virtual const rtems_status_code connect(const char *name,
const uint32_t node = RTEMS_SEARCH_ALL_NODES);
// send a message of size from the buffer
inline const rtems_status_code send(const void *buffer,
const size_t size);
inline const rtems_status_code urgent(const void *buffer,
const size_t size);
inline const rtems_status_code broadcast(const void *buffer,
const size_t size,
uint32_t& count);
// receive a message of size, the timeout is in micro-secs
inline const rtems_status_code receive(const void *buffer,
size_t& size,
rtems_interval micro_secs = RTEMS_NO_TIMEOUT,
bool wait = true);
// flush a message queue, returning the number of messages dropped
inline const rtems_status_code flush(uint32_t& size);
// object id, and name
const rtems_id id_is() const { return id; }
const rtems_name name_is() const { return name; }
const char *name_string() const { return name_str; }
private:
// make this object reference an invalid RTEMS object
void make_invalid();
// message queue name
rtems_name name;
char name_str[5];
// owner, true if this object owns the message queue
// will delete the message queue when it destructs
bool owner;
// the rtems id, object handle
rtems_id id;
};
const rtems_status_code rtemsMessageQueue::send(const void *buffer,
const size_t size)
{
return set_status_code(rtems_message_queue_send(id, (void*) buffer, size));
}
const rtems_status_code rtemsMessageQueue::urgent(const void *buffer,
const size_t size)
{
return set_status_code(rtems_message_queue_urgent(id, (void*) buffer, size));
}
const rtems_status_code rtemsMessageQueue::broadcast(const void *buffer,
const size_t size,
uint32_t& count)
{
return set_status_code(rtems_message_queue_broadcast(id,
(void*) buffer,
size,
&count));
}
const rtems_status_code rtemsMessageQueue::receive(const void *buffer,
size_t& size,
rtems_interval micro_secs,
bool wait)
{
rtems_interval usecs = micro_secs &&
(micro_secs < rtems_configuration_get_microseconds_per_tick()) ?
rtems_configuration_get_microseconds_per_tick() : micro_secs;
return set_status_code(rtems_message_queue_receive(id,
(void*) buffer,
&size,
wait ? RTEMS_WAIT : RTEMS_NO_WAIT,
RTEMS_MICROSECONDS_TO_TICKS(usecs)));
}
const rtems_status_code rtemsMessageQueue::flush(uint32_t& count)
{
return set_status_code(rtems_message_queue_flush(id, &count));
}
#endif // _rtemsMessageQueue_h_

View File

@@ -1,144 +0,0 @@
/*
------------------------------------------------------------------------
COPYRIGHT (c) 1997
Objective Design Systems Ltd Pty (ODS)
All rights reserved (R) Objective Design Systems Ltd Pty
The license and distribution terms for this file may be found in the
file LICENSE in this distribution or at
http://www.rtems.org/license/LICENSE.
------------------------------------------------------------------------
rtemsSemaphore class.
This class allows the user to create a RTEMS semaphore, or to use an
already existing semaphore. The type of semaphore is decitated by
the constructor used.
The first constructor with the semaphore parameters creates a RTEMS
semaphore object. The destructor of this object also deletes the
semaphore object. The last status code should be checked after
construction to see if the semaphore create was successfull.
The second constructor connects to an existing. The last status code
should be checked after construction to see if the semaphore
existed.
The third constructor is a copy constructor. Connects to an existing
object which is in scope.
------------------------------------------------------------------------ */
#if !defined(_rtemsSemaphore_h_)
#define _rtemsSemaphore_h_
#include <rtems++/rtemsStatusCode.h>
/* ----
rtemsSemaphore
*/
class rtemsSemaphore
: public rtemsStatusCode
{
public:
// attribute a semaphore can have
enum WaitMode { wait_by_fifo = RTEMS_FIFO,
wait_by_priority = RTEMS_PRIORITY };
enum Type { binary = RTEMS_BINARY_SEMAPHORE,
counting = RTEMS_COUNTING_SEMAPHORE };
enum Priority { no_priority_inherit = RTEMS_NO_INHERIT_PRIORITY,
inherit_priority = RTEMS_INHERIT_PRIORITY };
enum Ceiling { no_priority_ceiling = RTEMS_NO_PRIORITY_CEILING,
priority_ceiling = RTEMS_PRIORITY_CEILING };
enum Scope { local = RTEMS_LOCAL,
global = RTEMS_GLOBAL };
// only the first 4 characters of the name are taken,
// the counter must be set to 1 for binary semaphores
// create a semaphore object
rtemsSemaphore(const char* name,
const Scope scope = local,
const uint32_t counter = 1,
const WaitMode wait_mode = wait_by_fifo,
const Type type = binary,
const Priority priority = no_priority_inherit,
const Ceiling ceiling = no_priority_ceiling,
const rtems_task_priority priority_ceiling = 0);
// connect to an existing semaphore object by name
rtemsSemaphore(const char *name, const uint32_t node);
// attach this object to an other objects semaphore
rtemsSemaphore(const rtemsSemaphore& semaphore);
rtemsSemaphore();
// only the creator's destructor will delete the actual object
virtual ~rtemsSemaphore();
// create or destroy (delete) a semaphore
virtual const rtems_status_code create(const char* name,
const Scope scope = local,
const uint32_t counter = 1,
const WaitMode wait_mode = wait_by_fifo,
const Type type = binary,
const Priority priority = no_priority_inherit,
const Ceiling ceiling = no_priority_ceiling,
const rtems_task_priority priority_ceiling = 0);
virtual const rtems_status_code destroy();
// connect to an existing semaphore object, will not be the owner
const rtemsSemaphore& operator=(const rtemsSemaphore& semaphore);
virtual const rtems_status_code connect(const char *name, uint32_t node);
// obtain the semaphore, timeout is in micro-seconds
inline const rtems_status_code obtain(bool wait = true,
const uint32_t micro_secs = RTEMS_NO_TIMEOUT);
// release the semaphore, blocks threads eligble
inline const rtems_status_code release();
// object id, and name
const rtems_id id_is() const { return id; }
const rtems_name name_is() const { return name; }
const char *name_string() const { return name_str; }
private:
// make the object reference no valid RTEMS object
void make_invalid();
// semaphore name
rtems_name name;
char name_str[5];
// owner, true if this object owns the semaphore
// will delete the semaphore when it destructs
bool owner;
// the rtems id, object handle
rtems_id id;
};
const rtems_status_code rtemsSemaphore::obtain(const bool wait,
const uint32_t micro_secs)
{
rtems_interval usecs = micro_secs &&
(micro_secs < rtems_configuration_get_microseconds_per_tick()) ?
rtems_configuration_get_microseconds_per_tick() : micro_secs;
return
set_status_code(rtems_semaphore_obtain(id,
wait ? RTEMS_WAIT : RTEMS_NO_WAIT,
RTEMS_MICROSECONDS_TO_TICKS(usecs)));
}
const rtems_status_code rtemsSemaphore::release(void)
{
return set_status_code(rtems_semaphore_release(id));
}
#endif // _rtemsSemaphore_h_

View File

@@ -1,55 +0,0 @@
/*
------------------------------------------------------------------------
COPYRIGHT (c) 1997
Objective Design Systems Ltd Pty (ODS)
All rights reserved (R) Objective Design Systems Ltd Pty
The license and distribution terms for this file may be found in the
file LICENSE in this distribution or at
http://www.rtems.org/license/LICENSE.
------------------------------------------------------------------------
rtemsStatusCode controls and manages status codes from the RTEMS kernel.
------------------------------------------------------------------------
*/
#if !defined(_rtemsStatusCode_h_)
#define _rtemsStatusCode_h_
#include <rtems.h>
/* ----
rtemsStatusCode
*/
class rtemsStatusCode
{
public:
rtemsStatusCode() { last_status = RTEMS_NOT_CONFIGURED; }
const bool successful() { return last_status == RTEMS_SUCCESSFUL; }
const bool unsuccessful() { return last_status != RTEMS_SUCCESSFUL; }
// return the last status code
const rtems_status_code last_status_code() { return last_status; }
// return the last status as a string
const char *last_status_string();
const char *status_string(rtems_status_code status_code);
protected:
const rtems_status_code set_status_code(const rtems_status_code status)
{ return (last_status = status); }
private:
// public at the moment, this might change
rtems_status_code last_status;
};
#endif // _rtemsStatusCode_h_

View File

@@ -1,160 +0,0 @@
/*
------------------------------------------------------------------------
COPYRIGHT (c) 1997
Objective Design Systems Ltd Pty (ODS)
All rights reserved (R) Objective Design Systems Ltd Pty
The license and distribution terms for this file may be found in the
file LICENSE in this distribution or at
http://www.rtems.org/license/LICENSE.
------------------------------------------------------------------------
rtemsTask class.
This class allows the user to create a RTEMS task, or to access and
manage an already existing task.
The first constructor with the task parameters creates a RTEMS task
object. The destructor of this object also deletes the task
object. The last status code should be checked after construction to
see if the create completed successfully.
The second constructor connects to an existing task object. The last
status code should be checked after construction to see if the
task existed.
The third constructor is a copy constructor. Connects to an existing
object which is in scope.
The RTEMS id is set to self in the default construction.
The creation of the task object can be defered until after
construction. This allows for static task objects to be created.
RTEMS should be initialised before static constructors run, how-ever
threads will will not. You need to watch the start-order.
A task object can change state from an owner of a task to being
connected to a task.
Task objects connected to another task do not receive notification
when the task connected to changes state.
The sleep methods operate on the current thread not the task
reference by this object.
Mode control is through the rtemsTaskMode class.
------------------------------------------------------------------------ */
#if !defined(_rtemsTask_h_)
#define _rtemsTask_h_
#include <rtems++/rtemsStatusCode.h>
/* ----
rtemsTask
*/
class rtemsTask
: public rtemsStatusCode
{
public:
enum FloatingPoint { fpoff = RTEMS_NO_FLOATING_POINT,
fpon = RTEMS_FLOATING_POINT };
enum Scope { local = RTEMS_LOCAL,
global = RTEMS_GLOBAL };
// only the first 4 characters of the name are taken
// creates a task
rtemsTask(const char* name,
const rtems_task_priority initial_priority,
const uint32_t stack_size,
const rtems_mode preemption = RTEMS_NO_PREEMPT,
const rtems_mode timeslice = RTEMS_NO_TIMESLICE,
const rtems_mode asr = RTEMS_NO_ASR,
const rtems_interrupt_level interrupt_level = 0,
const FloatingPoint floating_point = fpoff,
const Scope scope = local);
// connects to a task
rtemsTask(const char *name, const uint32_t node = RTEMS_SEARCH_ALL_NODES);
// copy and default constructors
rtemsTask(const rtemsTask& task);
rtemsTask();
// only the creator's destructor will delete the actual object
virtual ~rtemsTask();
// create or destroy (delete) the task
virtual const rtems_status_code create(const char* name,
const rtems_task_priority initial_priority,
const uint32_t stack_size,
const rtems_mode preemption = RTEMS_NO_PREEMPT,
const rtems_mode timeslice = RTEMS_NO_TIMESLICE,
const rtems_mode asr = RTEMS_NO_ASR,
const rtems_interrupt_level interrupt_level = 0,
const FloatingPoint floating_point = fpoff,
const Scope scope = local);
virtual const rtems_status_code destroy();
// connect to an existing task object, will not be the owner
const rtemsTask& operator=(const rtemsTask& task);
virtual const rtems_status_code connect(const char *name,
const uint32_t node = RTEMS_SEARCH_ALL_NODES);
// run control
virtual const rtems_status_code start(const rtems_task_argument argument);
virtual const rtems_status_code restart(const rtems_task_argument argument);
virtual const rtems_status_code suspend();
virtual const rtems_status_code resume();
// sleep control, the timeout is in micro-seconds
virtual const rtems_status_code wake_after(const rtems_interval micro_secs);
virtual const rtems_status_code wake_when(const rtems_time_of_day& tod);
// priority control
const rtems_status_code get_priority(rtems_task_priority& priority);
const rtems_status_code set_priority(const rtems_task_priority priority);
const rtems_status_code set_priority(const rtems_task_priority priority,
rtems_task_priority& old_priority);
// object id, and name
const rtems_id id_is() const { return id; }
const rtems_name name_is() const { return name; }
const char *name_string() const { return name_str; }
protected:
// task entry point
virtual void body(rtems_task_argument argument);
private:
// make the object to point to RTEMS_SELF
void make_self();
// task name
rtems_name name;
char name_str[5];
// owner, true if this object owns the task
// will delete the task when it destructs
bool owner;
// the rtems id, object handle
rtems_id id;
// the argument for the task, this class uses the actual argument
// passed to RTEMS
rtems_task_argument argument;
// common entry point to the task
static rtems_task origin(rtems_task_argument argument);
};
#endif // _rtemsTask_h_

View File

@@ -1,204 +0,0 @@
/*
------------------------------------------------------------------------
COPYRIGHT (c) 1997
Objective Design Systems Ltd Pty (ODS)
All rights reserved (R) Objective Design Systems Ltd Pty
The license and distribution terms for this file may be found in the
file LICENSE in this distribution or at
http://www.rtems.org/license/LICENSE.
------------------------------------------------------------------------
rtemsTaskMode class.
This class allows the user to query or change the mode of an RTEMS
task.
This object only operates on the currently executing task.
The standard flags defined in RTEMS are used.
Methods are provided to operate on a group of modes which are
required to be changed in a single operation. The mode and mask is
specified by ORing the required flags.
Methods are provided for accessing and controlling a specific
mode. The returned value will only contain the requested mode's flags,
and only the that mode will be changed when setting a mode.
------------------------------------------------------------------------ */
#if !defined(_rtemsTaskMode_h_)
#define _rtemsTaskMode_h_
#include <rtems++/rtemsStatusCode.h>
/* ----
rtemsTaskMode
*/
class rtemsTaskMode
: public rtemsStatusCode
{
public:
rtemsTaskMode() {};
// group mode control, OR the values together
inline const rtems_status_code get_mode(rtems_mode& mode);
inline const rtems_status_code set_mode(const rtems_mode mode,
const rtems_mode mask);
inline const rtems_status_code set_mode(const rtems_mode mode,
const rtems_mode mask,
rtems_mode& old_mode);
// preemption control
inline const rtems_status_code get_preemption_state(rtems_mode& preemption);
inline const rtems_status_code set_preemption_state(const rtems_mode preemption);
inline const rtems_status_code set_preemption_state(const rtems_mode preemption,
rtems_mode& old_preemption);
inline const bool preemption_set(const rtems_mode preemption);
// timeslice control
inline const rtems_status_code get_timeslice_state(rtems_mode& timeslice);
inline const rtems_status_code set_timeslice_state(const rtems_mode timeslice);
inline const rtems_status_code set_timeslice_state(const rtems_mode timeslice,
rtems_mode& old_timeslice);
inline const bool timeslice_set(const rtems_mode preemption);
// async-sub-routine control
inline const rtems_status_code get_asr_state(rtems_mode& asr);
inline const rtems_status_code set_asr_state(const rtems_mode asr);
inline const rtems_status_code set_asr_state(const rtems_mode asr,
rtems_mode& old_asr);
inline const bool asr_set(const rtems_mode preemption);
// interrupt mask control
inline const rtems_status_code get_interrupt_level(rtems_interrupt_level& level);
inline const rtems_status_code set_interrupt_level(const rtems_interrupt_level level);
inline const rtems_status_code set_interrupt_level(const rtems_interrupt_level level,
rtems_interrupt_level& old_level);
};
const rtems_status_code rtemsTaskMode::get_mode(rtems_mode& mode)
{
return set_status_code(rtems_task_mode(0, RTEMS_CURRENT_MODE, &mode));
}
const rtems_status_code rtemsTaskMode::set_mode(const rtems_mode mode,
const rtems_mode mask)
{
rtems_mode old_mode;
return set_status_code(rtems_task_mode(mode, mask, &old_mode));
}
const rtems_status_code rtemsTaskMode::set_mode(const rtems_mode mode,
const rtems_mode mask,
rtems_mode& old_mode)
{
return set_status_code(rtems_task_mode(mode, mask, &old_mode));
}
const rtems_status_code rtemsTaskMode::get_preemption_state(rtems_mode& preemption)
{
set_status_code(rtems_task_mode(0, RTEMS_CURRENT_MODE, &preemption));
preemption &= RTEMS_PREEMPT_MASK;
return last_status_code();
}
const rtems_status_code rtemsTaskMode::set_preemption_state(const rtems_mode preemption)
{
rtems_mode old_mode;
return set_status_code(rtems_task_mode(preemption, RTEMS_PREEMPT_MASK, &old_mode));
}
const rtems_status_code rtemsTaskMode::set_preemption_state(const rtems_mode preemption,
rtems_mode& old_preemption)
{
set_status_code(rtems_task_mode(preemption, RTEMS_PREEMPT_MASK, &old_preemption));
old_preemption &= RTEMS_PREEMPT_MASK;
return last_status_code();
}
const bool rtemsTaskMode::preemption_set(const rtems_mode preemption)
{
return (preemption & RTEMS_PREEMPT_MASK) ? false : true;
}
const rtems_status_code rtemsTaskMode::get_timeslice_state(rtems_mode& timeslice)
{
set_status_code(rtems_task_mode(0, RTEMS_CURRENT_MODE, &timeslice));
timeslice &= RTEMS_TIMESLICE_MASK;
return last_status_code();
}
const rtems_status_code rtemsTaskMode::set_timeslice_state(const rtems_mode timeslice)
{
rtems_mode old_mode;
return set_status_code(rtems_task_mode(timeslice, RTEMS_TIMESLICE_MASK, &old_mode));
}
const rtems_status_code rtemsTaskMode::set_timeslice_state(const rtems_mode timeslice,
rtems_mode& old_timeslice)
{
set_status_code(rtems_task_mode(timeslice, RTEMS_TIMESLICE_MASK, &old_timeslice));
old_timeslice &= RTEMS_TIMESLICE_MASK;
return last_status_code();
}
const bool rtemsTaskMode::timeslice_set(const rtems_mode timeslice)
{
return (timeslice & RTEMS_TIMESLICE_MASK) ? true : false;
}
const rtems_status_code rtemsTaskMode::get_asr_state(rtems_mode& asr)
{
set_status_code(rtems_task_mode(0, RTEMS_CURRENT_MODE, &asr));
asr &= RTEMS_ASR_MASK;
return last_status_code();
}
const rtems_status_code rtemsTaskMode::set_asr_state(const rtems_mode asr)
{
rtems_mode old_mode;
return set_status_code(rtems_task_mode(asr, RTEMS_ASR_MASK, &old_mode));
}
const rtems_status_code rtemsTaskMode::set_asr_state(const rtems_mode asr,
rtems_mode& old_asr)
{
set_status_code(rtems_task_mode(asr, RTEMS_ASR_MASK, &old_asr));
old_asr &= RTEMS_ASR_MASK;
return last_status_code();
}
const bool rtemsTaskMode::asr_set(const rtems_mode asr)
{
return (asr & RTEMS_ASR_MASK) ? true : false;
}
const rtems_status_code rtemsTaskMode::get_interrupt_level(rtems_interrupt_level& level)
{
rtems_mode mode;
set_status_code(rtems_task_mode(0, RTEMS_CURRENT_MODE, &mode));
level = mode & RTEMS_INTERRUPT_MASK;
return last_status_code();
}
const rtems_status_code rtemsTaskMode::set_interrupt_level(const rtems_interrupt_level level)
{
rtems_mode old_mode;
return set_status_code(rtems_task_mode(level, RTEMS_INTERRUPT_MASK, &old_mode));
}
const rtems_status_code rtemsTaskMode::set_interrupt_level(rtems_interrupt_level level,
rtems_interrupt_level& old_level)
{
set_status_code(rtems_task_mode(level, RTEMS_INTERRUPT_MASK, &old_level));
old_level = old_level & RTEMS_INTERRUPT_MASK;
return last_status_code();
}
#endif // _rtemsTaskMode_h_

View File

@@ -1,135 +0,0 @@
/*
------------------------------------------------------------------------
COPYRIGHT (c) 1997
Objective Design Systems Ltd Pty (ODS)
All rights reserved (R) Objective Design Systems Ltd Pty
The license and distribution terms for this file may be found in the
file LICENSE in this distribution or at
http://www.rtems.org/license/LICENSE.
------------------------------------------------------------------------
rtemsTimer class.
This class allows the user to create a RTEMS timer.
The trigger method is called when the timer expires. The method is
called using the thread which calls the RTEMS 'rtems_clock_tick'
method.
Timers are always local to a node.
------------------------------------------------------------------------ */
#if !defined(_rtemsTimer_h_)
#define _rtemsTimer_h_
#include <rtems++/rtemsStatusCode.h>
/* ----
rtemsTimer
*/
class rtemsTimer
: public rtemsStatusCode
{
public:
// only the first 4 characters of the name are taken,
// create a timer object
rtemsTimer(const char* name);
rtemsTimer();
// destroies the actual object
virtual ~rtemsTimer();
// create or destroy (delete) the timer
virtual const rtems_status_code create(const char* name);
virtual const rtems_status_code destroy();
// timer control
inline const rtems_status_code fire_after(const rtems_interval micro_secs);
inline const rtems_status_code repeat_fire_at(const rtems_interval micro_secs);
inline const rtems_status_code fire_when(const rtems_time_of_day& when);
inline const rtems_status_code cancel();
inline const rtems_status_code reset();
// object id, and name
const rtems_id id_is() const { return id; }
const rtems_name name_is() const { return name; }
const char *name_string() const { return name_str; }
protected:
// triggered method is called when the timer fires
virtual void triggered() = 0;
private:
// not permitted
rtemsTimer(const rtemsTimer& timer);
rtemsTimer& operator=(const rtemsTimer& timer);
// make this object reference an invalid RTEMS object
void make_invalid();
// semaphore name
rtems_name name;
char name_str[5];
// repeat true restart the timer when it fires
bool repeat;
// the rtems id, object handle
rtems_id id;
// common timer handler
static void common_handler(rtems_id id, void *user_data);
};
const rtems_status_code rtemsTimer::fire_after(const rtems_interval micro_secs)
{
repeat = false;
rtems_interval usecs = micro_secs &&
(micro_secs < rtems_configuration_get_microseconds_per_tick()) ?
rtems_configuration_get_microseconds_per_tick() : micro_secs;
return set_status_code(rtems_timer_fire_after(id,
RTEMS_MICROSECONDS_TO_TICKS(usecs),
common_handler,
this));
}
const rtems_status_code rtemsTimer::repeat_fire_at(const rtems_interval micro_secs)
{
repeat = true;
rtems_interval usecs = micro_secs &&
(micro_secs < rtems_configuration_get_microseconds_per_tick()) ?
rtems_configuration_get_microseconds_per_tick() : micro_secs;
return set_status_code(rtems_timer_fire_after(id,
RTEMS_MICROSECONDS_TO_TICKS(usecs),
common_handler,
this));
}
const rtems_status_code rtemsTimer::fire_when(const rtems_time_of_day& when)
{
return set_status_code(rtems_timer_fire_when(id,
(rtems_time_of_day*) &when,
common_handler,
this));
}
const rtems_status_code rtemsTimer::cancel()
{
repeat = false;
return set_status_code(rtems_timer_cancel(id));
}
const rtems_status_code rtemsTimer::reset()
{
return set_status_code(rtems_timer_reset(id));
}
#endif // _rtemsTimer_h_

View File

@@ -1,67 +0,0 @@
## Automatically generated by ampolish3 - Do not edit
if AMPOLISH3
$(srcdir)/preinstall.am: Makefile.am
$(AMPOLISH3) $(srcdir)/Makefile.am > $(srcdir)/preinstall.am
endif
PREINSTALL_DIRS =
DISTCLEANFILES = $(PREINSTALL_DIRS)
all-am: $(PREINSTALL_FILES)
PREINSTALL_FILES =
CLEANFILES = $(PREINSTALL_FILES)
all-local: $(TMPINSTALL_FILES)
TMPINSTALL_FILES =
CLEANFILES += $(TMPINSTALL_FILES)
$(PROJECT_LIB)/$(dirstamp):
@$(MKDIR_P) $(PROJECT_LIB)
@: > $(PROJECT_LIB)/$(dirstamp)
PREINSTALL_DIRS += $(PROJECT_LIB)/$(dirstamp)
if HAS_CXX
$(PROJECT_INCLUDE)/rtems++/$(dirstamp):
@$(MKDIR_P) $(PROJECT_INCLUDE)/rtems++
@: > $(PROJECT_INCLUDE)/rtems++/$(dirstamp)
PREINSTALL_DIRS += $(PROJECT_INCLUDE)/rtems++/$(dirstamp)
$(PROJECT_INCLUDE)/rtems++/rtemsEvent.h: include/rtems++/rtemsEvent.h $(PROJECT_INCLUDE)/rtems++/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems++/rtemsEvent.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems++/rtemsEvent.h
$(PROJECT_INCLUDE)/rtems++/rtemsInterrupt.h: include/rtems++/rtemsInterrupt.h $(PROJECT_INCLUDE)/rtems++/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems++/rtemsInterrupt.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems++/rtemsInterrupt.h
$(PROJECT_INCLUDE)/rtems++/rtemsMessageQueue.h: include/rtems++/rtemsMessageQueue.h $(PROJECT_INCLUDE)/rtems++/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems++/rtemsMessageQueue.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems++/rtemsMessageQueue.h
$(PROJECT_INCLUDE)/rtems++/rtemsSemaphore.h: include/rtems++/rtemsSemaphore.h $(PROJECT_INCLUDE)/rtems++/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems++/rtemsSemaphore.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems++/rtemsSemaphore.h
$(PROJECT_INCLUDE)/rtems++/rtemsStatusCode.h: include/rtems++/rtemsStatusCode.h $(PROJECT_INCLUDE)/rtems++/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems++/rtemsStatusCode.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems++/rtemsStatusCode.h
$(PROJECT_INCLUDE)/rtems++/rtemsTask.h: include/rtems++/rtemsTask.h $(PROJECT_INCLUDE)/rtems++/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems++/rtemsTask.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems++/rtemsTask.h
$(PROJECT_INCLUDE)/rtems++/rtemsTaskMode.h: include/rtems++/rtemsTaskMode.h $(PROJECT_INCLUDE)/rtems++/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems++/rtemsTaskMode.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems++/rtemsTaskMode.h
$(PROJECT_INCLUDE)/rtems++/rtemsTimer.h: include/rtems++/rtemsTimer.h $(PROJECT_INCLUDE)/rtems++/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems++/rtemsTimer.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems++/rtemsTimer.h
$(PROJECT_LIB)/librtems++.a: librtems++.a $(PROJECT_LIB)/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_LIB)/librtems++.a
TMPINSTALL_FILES += $(PROJECT_LIB)/librtems++.a
endif

View File

@@ -1,73 +0,0 @@
/*
------------------------------------------------------------------------
COPYRIGHT (c) 1997
Objective Design Systems Ltd Pty (ODS)
All rights reserved (R) Objective Design Systems Ltd Pty
The license and distribution terms for this file may be found in the
file LICENSE in this distribution or at
http://www.rtems.org/license/LICENSE.
------------------------------------------------------------------------
See header file.
------------------------------------------------------------------------
*/
#include <rtems++/rtemsEvent.h>
/* ----
rtemsEvent
*/
rtemsEvent::rtemsEvent(const char *name_str, uint32_t node)
: name(rtems_build_name('S', 'E', 'L', 'F')),
id(RTEMS_SELF)
{
connect(name_str, node);
}
rtemsEvent::rtemsEvent(const rtemsEvent& event)
{
name = event.name;
id = event.id;
}
rtemsEvent::rtemsEvent()
: name(rtems_build_name('S', 'E', 'L', 'F')),
id(RTEMS_SELF)
{
}
rtemsEvent::~rtemsEvent()
{
}
const rtemsEvent& rtemsEvent::operator=(const rtemsEvent& event)
{
name = event.name;
id = event.id;
return *this;
}
const rtems_status_code rtemsEvent::connect(const char *name_str,
const uint32_t node)
{
name = rtems_build_name(name_str[0],
name_str[1],
name_str[2],
name_str[3]);
set_status_code(rtems_task_ident(name, node, &id));
if (unsuccessful())
{
name = rtems_build_name('S', 'E', 'L', 'F');
id = RTEMS_SELF;
}
return last_status_code();
}

View File

@@ -1,126 +0,0 @@
/*
------------------------------------------------------------------------
COPYRIGHT (c) 1997
Objective Design Systems Ltd Pty (ODS)
All rights reserved (R) Objective Design Systems Ltd Pty
The license and distribution terms for this file may be found in the
file LICENSE in this distribution or at
http://www.rtems.org/license/LICENSE.
------------------------------------------------------------------------
See header file.
------------------------------------------------------------------------
*/
#include <rtems++/rtemsInterrupt.h>
#if (CPU_SIMPLE_VECTORED_INTERRUPTS == TRUE)
/* ----
Interrupt Table
This table is used to re-direct the call from RTEMS to a user
object
*/
static rtemsInterrupt **interrupt_table;
// has the table been initialised
static bool initialised = false;
/* ----
rtemsInterrupt
*/
#include <cstdlib>
rtemsInterrupt::rtemsInterrupt()
: vector(0),
caught(false),
old_handler(0),
old_interrupt(0)
{
if (!initialised)
{
interrupt_table = (rtemsInterrupt **)
malloc(sizeof(rtemsInterrupt *) * CPU_INTERRUPT_NUMBER_OF_VECTORS);
for (rtems_vector_number vec = 0;
vec < CPU_INTERRUPT_NUMBER_OF_VECTORS;
vec++)
{
interrupt_table[vec] = 0;
}
initialised = true;
}
}
rtemsInterrupt::~rtemsInterrupt()
{
release();
}
const rtems_status_code rtemsInterrupt::isr_catch(const rtems_vector_number vec)
{
if (vec >= CPU_INTERRUPT_NUMBER_OF_VECTORS)
return set_status_code(RTEMS_INVALID_NUMBER);
if (caught)
return set_status_code(RTEMS_RESOURCE_IN_USE);
old_interrupt = interrupt_table[vec];
interrupt_table[vec] = this;
vector = vec;
#if (CPU_SIMPLE_VECTORED_INTERRUPTS == TRUE)
set_status_code(rtems_interrupt_catch(redirector,
vector,
&old_handler));
#else
set_status_code(RTEMS_NOT_DEFINED);
#endif
if (successful())
caught = true;
else
{
interrupt_table[vector] = old_interrupt;
old_interrupt = 0;
old_handler = 0;
vector = 0;
}
return last_status_code();
}
const rtems_status_code rtemsInterrupt::release(void)
{
if (caught)
{
#if (CPU_SIMPLE_VECTORED_INTERRUPTS == TRUE)
set_status_code(rtems_interrupt_catch(old_handler,
vector,
&old_handler));
#else
set_status_code(RTEMS_NOT_DEFINED);
#endif
interrupt_table[vector] = old_interrupt;
old_interrupt = 0;
old_handler = 0;
vector = 0;
caught = false;
}
else
set_status_code(RTEMS_SUCCESSFUL);
return last_status_code();
}
void rtemsInterrupt::redirector(rtems_vector_number vector)
{
if (interrupt_table[vector])
interrupt_table[vector]->handler();
}
#endif

View File

@@ -1,163 +0,0 @@
/*
------------------------------------------------------------------------
COPYRIGHT (c) 1997
Objective Design Systems Ltd Pty (ODS)
All rights reserved (R) Objective Design Systems Ltd Pty
The license and distribution terms for this file may be found in the
file LICENSE in this distribution or at
http://www.rtems.org/license/LICENSE.
------------------------------------------------------------------------
See header file.
------------------------------------------------------------------------
*/
#include <cstring>
#include <rtems++/rtemsMessageQueue.h>
/* ----
rtemsMessageQueue
*/
rtemsMessageQueue::rtemsMessageQueue(const char* mqname,
const uint32_t count,
const size_t max_message_size,
const WaitMode wait_mode,
const Scope scope)
: name(0),
owner(true),
id(0)
{
strcpy(name_str, "NOID");
create(mqname, count, max_message_size, wait_mode, scope);
}
rtemsMessageQueue::rtemsMessageQueue(const char *mqname,
const uint32_t node)
: name(0),
owner(false),
id(0)
{
strcpy(name_str, "NOID");
connect(mqname, node);
}
rtemsMessageQueue::rtemsMessageQueue(const rtemsMessageQueue& message_queue)
: name(0),
owner(false),
id(0)
{
name = message_queue.name;
strcpy(name_str, message_queue.name_str);
id = message_queue.id;
}
rtemsMessageQueue::rtemsMessageQueue()
: name(0),
owner(false),
id(0)
{
strcpy(name_str, "NOID");
}
rtemsMessageQueue::~rtemsMessageQueue()
{
destroy();
}
void rtemsMessageQueue::make_invalid()
{
strcpy(name_str, "NOID");
name = 0;
id = 0;
owner = false;
}
const rtems_status_code rtemsMessageQueue::create(const char* mqname,
const uint32_t count,
const size_t max_message_size,
const WaitMode wait_mode,
const Scope scope)
{
if (id)
return set_status_code(RTEMS_ILLEGAL_ON_SELF);
owner = true;
strcpy(name_str, " ");
for (int c = 0; (c < 4) && (mqname[c] != '\0'); c++)
name_str[c] = mqname[c];
name = rtems_build_name(name_str[0],
name_str[1],
name_str[2],
name_str[3]);
set_status_code(rtems_message_queue_create(name,
count,
max_message_size,
scope | wait_mode,
&id));
if (unsuccessful())
{
make_invalid();
}
return last_status_code();
}
const rtems_status_code rtemsMessageQueue::destroy()
{
if (id && owner)
{
set_status_code(rtems_message_queue_delete(id));
make_invalid();
}
else
set_status_code(RTEMS_NOT_OWNER_OF_RESOURCE);
return last_status_code();
}
const rtemsMessageQueue& rtemsMessageQueue::operator=(const rtemsMessageQueue& message_queue)
{
if (!owner)
{
name = message_queue.name;
strcpy(name_str, message_queue.name_str);
id = message_queue.id;
}
return *this;
}
const rtems_status_code rtemsMessageQueue::connect(const char *mqname,
const uint32_t node)
{
if (id && owner)
return set_status_code(RTEMS_UNSATISFIED);
// change state to not owner
owner = false;
strcpy(name_str, " ");
for (int c = 0; (c < 4) && (mqname[c] != '\0'); c++)
name_str[c] = mqname[c];
name = rtems_build_name(name_str[0],
name_str[1],
name_str[2],
name_str[3]);
set_status_code(rtems_message_queue_ident(name, node, &id));
if (unsuccessful())
{
make_invalid();
}
return last_status_code();
}

View File

@@ -1,173 +0,0 @@
/*
------------------------------------------------------------------------
COPYRIGHT (c) 1997
Objective Design Systems Ltd Pty (ODS)
All rights reserved (R) Objective Design Systems Ltd Pty
The license and distribution terms for this file may be found in the
file LICENSE in this distribution or at
http://www.rtems.org/license/LICENSE.
------------------------------------------------------------------------
See header file.
------------------------------------------------------------------------
*/
#include <cstring>
#include <rtems++/rtemsSemaphore.h>
/* ----
rtemsSemaphore
*/
rtemsSemaphore::rtemsSemaphore(const char* sname,
const Scope scope,
const uint32_t counter,
const WaitMode wait_mode,
const Type type,
const Priority priority,
const Ceiling ceiling,
const rtems_task_priority priority_ceiling)
: name(0),
owner(true),
id(0)
{
strcpy(name_str, "NOID");
create(sname,
scope,
counter,
wait_mode,
type,
priority,
ceiling,
priority_ceiling);
}
rtemsSemaphore::rtemsSemaphore(const char *sname, const uint32_t node)
: name(0),
owner(false),
id(0)
{
strcpy(name_str, "NOID");
connect(sname, node);
}
rtemsSemaphore::rtemsSemaphore(const rtemsSemaphore& semaphore)
: name(0),
owner(false),
id(0)
{
name = semaphore.name;
strcpy(name_str, semaphore.name_str);
id = semaphore.id;
}
rtemsSemaphore::rtemsSemaphore()
: name(0),
owner(false),
id(0)
{
strcpy(name_str, "NOID");
}
rtemsSemaphore::~rtemsSemaphore()
{
destroy();
}
void rtemsSemaphore::make_invalid()
{
strcpy(name_str, "NOID");
name = 0;
id = 0;
owner = false;
}
const rtems_status_code rtemsSemaphore::create(const char* sname,
const Scope scope,
const uint32_t counter,
const WaitMode wait_mode,
const Type type,
const Priority priority,
const Ceiling ceiling,
const rtems_task_priority priority_ceiling)
{
if (id)
return set_status_code(RTEMS_ILLEGAL_ON_SELF);
owner = true;
strcpy(name_str, " ");
for (int c = 0; (c < 4) && (sname[c] != '\0'); c++)
name_str[c] = sname[c];
name = rtems_build_name(name_str[0],
name_str[1],
name_str[2],
name_str[3]);
set_status_code(rtems_semaphore_create(name,
counter,
scope | wait_mode | type | priority | ceiling,
priority_ceiling,
&id));
if (unsuccessful())
{
make_invalid();
}
return last_status_code();
}
const rtems_status_code rtemsSemaphore::destroy()
{
if (id && owner)
{
set_status_code(rtems_semaphore_delete(id));
make_invalid();
}
else
set_status_code(RTEMS_NOT_OWNER_OF_RESOURCE);
return last_status_code();
}
const rtemsSemaphore& rtemsSemaphore::operator=(const rtemsSemaphore& semaphore)
{
if (!owner)
{
name = semaphore.name;
id = semaphore.id;
}
return *this;
}
const rtems_status_code rtemsSemaphore::connect(const char *sname,
const uint32_t node)
{
if (id && owner)
return set_status_code(RTEMS_UNSATISFIED);
// change state to not owner
owner = false;
strcpy(name_str, " ");
for (int c = 0; (c < 4) && (sname[c] != '\0'); c++)
name_str[c] = sname[c];
name = rtems_build_name(name_str[0],
name_str[1],
name_str[2],
name_str[3]);
set_status_code(rtems_semaphore_ident(name, node, &id));
if (unsuccessful())
{
make_invalid();
}
return last_status_code();
}

View File

@@ -1,75 +0,0 @@
/*
------------------------------------------------------------------------
COPYRIGHT (c) 1997
Objective Design Systems Ltd Pty (ODS)
All rights reserved (R) Objective Design Systems Ltd Pty
The license and distribution terms for this file may be found in the
file LICENSE in this distribution or at
http://www.rtems.org/license/LICENSE.
------------------------------------------------------------------------
See header file.
------------------------------------------------------------------------
*/
#include <rtems++/rtemsStatusCode.h>
/* ----
Status Code string table
*/
static const char *status_strings[RTEMS_STATUS_CODES_LAST + 1] =
{
"RTEMS[00] successful completion",
"RTEMS[01] task exitted, returned from a thread",
"RTEMS[02] multiprocessing not configured",
"RTEMS[03] invalid object name",
"RTEMS[04] invalid object id",
"RTEMS[05] too many",
"RTEMS[06] timed out waiting",
"RTEMS[07] object deleted while waiting",
"RTEMS[08] specified size was invalid",
"RTEMS[09] address specified is invalid",
"RTEMS[10] number was invalid",
"RTEMS[11] item has not been initialized",
"RTEMS[12] resources still outstanding",
"RTEMS[13] request not satisfied",
"RTEMS[14] thread is in wrong state",
"RTEMS[15] thread already in state",
"RTEMS[16] illegal on calling thread",
"RTEMS[17] illegal for remote object",
"RTEMS[18] called from wrong environment",
"RTEMS[19] invalid thread priority",
"RTEMS[20] invalid date/time",
"RTEMS[21] invalid node id",
"RTEMS[22] directive not configured",
"RTEMS[23] not owner of resource",
"RTEMS[24] directive not implemented",
"RTEMS[25] RTEMS inconsistency detected",
"RTEMS[26] could not get enough memory"
};
/* ----
StatusCode
*/
const char *rtemsStatusCode::last_status_string()
{
return status_string(last_status);
}
const char *rtemsStatusCode::status_string(rtems_status_code status_code)
{
// mapped from "rtems/rtems/status.h"
if (status_code <= RTEMS_STATUS_CODES_LAST)
{
return status_strings[status_code];
}
return "unknown status code";
}

View File

@@ -1,274 +0,0 @@
/*
------------------------------------------------------------------------
COPYRIGHT (c) 1997
Objective Design Systems Ltd Pty (ODS)
All rights reserved (R) Objective Design Systems Ltd Pty
The license and distribution terms for this file may be found in the
file LICENSE in this distribution or at
http://www.rtems.org/license/LICENSE.
------------------------------------------------------------------------
See header file.
------------------------------------------------------------------------
*/
#include <cstring>
#include <rtems++/rtemsTask.h>
// include to allow it to be compiled
#include <rtems++/rtemsTaskMode.h>
/* ----
rtemsTask
*/
rtemsTask::rtemsTask(const char* tname,
const rtems_task_priority initial_priority,
const uint32_t stack_size,
const rtems_mode preemption,
const rtems_mode timeslice,
const rtems_mode asr,
const rtems_interrupt_level interrupt_level,
const FloatingPoint floating_point,
const Scope scope)
: name(rtems_build_name('S', 'E', 'L', 'F')),
owner(true),
id(RTEMS_SELF),
argument(0)
{
strcpy(name_str, "SELF");
create(tname,
initial_priority,
stack_size,
preemption,
timeslice,
asr,
interrupt_level,
floating_point,
scope);
}
rtemsTask::rtemsTask(const char *tname, uint32_t node)
: name(rtems_build_name('S', 'E', 'L', 'F')),
owner(false),
id(RTEMS_SELF),
argument(0)
{
strcpy(name_str, "SELF");
connect(tname, node);
}
rtemsTask::rtemsTask(const rtemsTask& task)
: name(rtems_build_name('S', 'E', 'L', 'F')),
owner(false),
id(RTEMS_SELF),
argument(0)
{
name = task.name;
strcpy(name_str, task.name_str);
argument = task.argument;
id = task.id;
}
rtemsTask::rtemsTask()
: name(rtems_build_name('S', 'E', 'L', 'F')),
owner(false),
id(RTEMS_SELF),
argument(0)
{
strcpy(name_str, "SELF");
}
rtemsTask::~rtemsTask()
{
destroy();
}
void rtemsTask::make_self()
{
strcpy(name_str, "SELF");
name = rtems_build_name('S', 'E', 'L', 'F');
id = RTEMS_SELF;
owner = false;
}
const rtems_status_code rtemsTask::create(const char* tname,
const rtems_task_priority initial_priority,
const uint32_t stack_size,
const rtems_mode preemption,
const rtems_mode timeslice,
const rtems_mode asr,
const rtems_interrupt_level interrupt_level,
const FloatingPoint floating_point,
const Scope scope)
{
if (id)
return set_status_code(RTEMS_ILLEGAL_ON_SELF);
owner = true;
strcpy(name_str, " ");
for (int c = 0; (c < 4) && (tname[c] != '\0'); c++)
name_str[c] = tname[c];
name = rtems_build_name(name_str[0],
name_str[1],
name_str[2],
name_str[3]);
// protect the values that be set as the parameters are not enums
set_status_code(rtems_task_create(name,
initial_priority,
stack_size,
(preemption & RTEMS_PREEMPT_MASK) |
(timeslice & RTEMS_TIMESLICE_MASK) |
(asr & RTEMS_ASR_MASK) |
(interrupt_level & RTEMS_INTERRUPT_MASK),
floating_point | scope,
&id));
if (unsuccessful())
{
make_self();
}
return last_status_code();
}
const rtems_status_code rtemsTask::destroy()
{
if (id && owner)
{
set_status_code(rtems_task_delete(id));
make_self();
}
else
set_status_code(RTEMS_NOT_OWNER_OF_RESOURCE);
return last_status_code();
}
const rtemsTask& rtemsTask::operator=(const rtemsTask& task)
{
if (!owner)
{
name = task.name;
strcpy(name_str, task.name_str);
argument = task.argument;
id = task.id;
}
return *this;
}
const rtems_status_code rtemsTask::connect(const char *sname,
const uint32_t node)
{
if (id && owner)
return set_status_code(RTEMS_UNSATISFIED);
// change state to not owner
owner = false;
strcpy(name_str, " ");
for (int c = 0; (c < 4) && (sname[c] != '\0'); c++)
name_str[c] = sname[c];
name = rtems_build_name(name_str[0],
name_str[1],
name_str[2],
name_str[3]);
set_status_code(rtems_task_ident(name, node, &id));
if (unsuccessful())
{
make_self();
}
return last_status_code();
}
const rtems_status_code rtemsTask::start(const rtems_task_argument arg)
{
if (owner)
{
argument = arg;
// pass the this pointer as the argument
set_status_code(rtems_task_start(id,
origin,
(rtems_task_argument) this));
}
else
set_status_code(RTEMS_NOT_OWNER_OF_RESOURCE);
return last_status_code();
}
const rtems_status_code rtemsTask::restart(const rtems_task_argument arg)
{
if (owner)
{
argument = arg;
set_status_code(rtems_task_restart(id, (rtems_task_argument) this));
}
else
set_status_code(RTEMS_NOT_OWNER_OF_RESOURCE);
return last_status_code();
}
const rtems_status_code rtemsTask::suspend()
{
return set_status_code(rtems_task_suspend(id));
}
const rtems_status_code rtemsTask::resume()
{
return set_status_code(rtems_task_resume(id));
}
const rtems_status_code rtemsTask::wake_after(const rtems_interval micro_secs)
{
rtems_interval usecs =
(micro_secs < rtems_configuration_get_microseconds_per_tick()) ?
rtems_configuration_get_microseconds_per_tick() : micro_secs;
return set_status_code(rtems_task_wake_after(RTEMS_MICROSECONDS_TO_TICKS(usecs)));
}
const rtems_status_code rtemsTask::wake_when(const rtems_time_of_day& tod)
{
return set_status_code(rtems_task_wake_when((rtems_time_of_day*) &tod));
}
const rtems_status_code rtemsTask::get_priority(rtems_task_priority& priority)
{
return set_status_code(rtems_task_set_priority(id,
RTEMS_CURRENT_PRIORITY,
&priority));
}
const rtems_status_code rtemsTask::set_priority(const rtems_task_priority priority)
{
rtems_task_priority old_priority;
return set_status_code(rtems_task_set_priority(id,
priority,
&old_priority));
}
const rtems_status_code rtemsTask::set_priority(const rtems_task_priority priority,
rtems_task_priority& old_priority)
{
return set_status_code(rtems_task_set_priority(id,
priority,
&old_priority));
}
void rtemsTask::body(rtems_task_argument )
{
}
rtems_task rtemsTask::origin(rtems_task_argument argument)
{
rtemsTask *task = (rtemsTask*) argument;
task->body(task->argument);
}

View File

@@ -1,99 +0,0 @@
/*
------------------------------------------------------------------------
COPYRIGHT (c) 1997
Objective Design Systems Ltd Pty (ODS)
All rights reserved (R) Objective Design Systems Ltd Pty
The license and distribution terms for this file may be found in the
file LICENSE in this distribution or at
http://www.rtems.org/license/LICENSE.
------------------------------------------------------------------------
See header file.
------------------------------------------------------------------------
*/
#include <cstring>
#include <rtems++/rtemsTimer.h>
/* ----
rtemsTimer
*/
rtemsTimer::rtemsTimer(const char* tname)
: name(0),
repeat(false),
id(0)
{
strcpy(name_str, " ");
create(tname);
}
rtemsTimer::rtemsTimer()
: name(0),
repeat(false),
id(0)
{
strcpy(name_str, " ");
}
rtemsTimer::~rtemsTimer()
{
destroy();
}
void rtemsTimer::make_invalid()
{
strcpy(name_str, " ");
name = 0;
id = 0;
repeat = false;
}
const rtems_status_code rtemsTimer::create(const char* tname)
{
if (id)
return set_status_code(RTEMS_ILLEGAL_ON_SELF);
strcpy(name_str, " ");
for (int c = 0; (c < 4) && (tname[c] != '\0'); c++)
name_str[c] = tname[c];
name = rtems_build_name(name_str[0],
name_str[1],
name_str[2],
name_str[3]);
set_status_code(rtems_timer_create(name, &id));
if (unsuccessful())
{
make_invalid();
}
return last_status_code();
}
const rtems_status_code rtemsTimer::destroy()
{
if (id)
{
set_status_code(rtems_timer_delete(id));
make_invalid();
}
else
set_status_code(RTEMS_NOT_OWNER_OF_RESOURCE);
return last_status_code();
}
void rtemsTimer::common_handler(rtems_id , void *user_data)
{
rtemsTimer *timer = (rtemsTimer*) user_data;
if (timer->repeat)
timer->reset();
timer->triggered();
}

View File

@@ -30,7 +30,7 @@ _SUBDIRS += bspcmdline01 cpuuse devfs01 devfs02 devfs03 devfs04 \
putenvtest monitor monitor02 rtmonuse stackchk stackchk01 \
termios termios01 termios02 termios03 termios04 termios05 \
termios06 termios07 termios08 \
rtems++ tztest block01 block02 block03 block04 block05 block06 block07 \
tztest block01 block02 block03 block04 block05 block06 block07 \
block08 block09 block10 block11 block12 stringto01 \
tar01 tar02 tar03 \
math mathf mathl complex \

View File

@@ -139,7 +139,6 @@ monitor02/Makefile
mouse01/Makefile
uid01/Makefile
putenvtest/Makefile
rtems++/Makefile
rtmonuse/Makefile
stackchk/Makefile
stackchk01/Makefile

View File

@@ -1,66 +0,0 @@
/* Init
*
* This routine is the initialization task for this test program.
*
* Input parameters:
* argument - task argument
*
* Output parameters: NONE
*
* COPYRIGHT (c) 1997
* Objective Design Systems Ltd Pty (ODS)
* All rights reserved (R) Objective Design Systems Ltd Pty
*
* COPYRIGHT (c) 1989-1999.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.org/license/LICENSE.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#define CONFIGURE_INIT
#include "System.h"
const char rtems_test_name[] = "RTEMS++";
// make global so it lasts past the Init task's stack's life time
Task1 task_1;
rtems_task Init(rtems_task_argument )
{
TEST_BEGIN();
printf( "INIT - Task.create() - " );
task_1.create("TA1 ", 0, RTEMS_MINIMUM_STACK_SIZE);
printf("%s\n", task_1.last_status_string());
printf( "INIT - Task.create() - " );
task_1.create("TA1 ", 10, RTEMS_MINIMUM_STACK_SIZE * 6);
printf("%s\n", task_1.last_status_string());
printf( "INIT - Task.create() - " );
task_1.create("TA1 ", 10, RTEMS_MINIMUM_STACK_SIZE * 6);
printf("%s\n", task_1.last_status_string());
printf( "INIT - Task.restart() - " );
task_1.restart(0);
printf("%s\n", task_1.last_status_string());
printf( "INIT - Task.start(0xDEADDEAD) - " );
task_1.start(0xDEADDEAD);
printf("%s\n", task_1.last_status_string());
printf("INIT - Destroy it's self\n");
// needs to be in C, no C++ object owns the Init task
rtems_status_code status = rtems_task_delete( RTEMS_SELF );
directive_failed( status, "rtems_task_delete of RTEMS_SELF" );
}

View File

@@ -1,27 +0,0 @@
if HAS_CXX
rtems_tests_PROGRAMS = rtems++
rtems___SOURCES = Init.cc Task1.cc Task2.cc Task3.cc System.h
endif
dist_rtems_tests_DATA = rtems++.scn
dist_rtems_tests_DATA += rtems++.doc
include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
include $(top_srcdir)/../automake/compile.am
include $(top_srcdir)/../automake/leaf.am
if HAS_CXX
rtems___LDLIBS = -lrtems++
AM_CPPFLAGS += -I$(top_srcdir)/../support/include
LINK_OBJS = $(rtems___OBJECTS)
LINK_LIBS = $(rtems___LDLIBS)
rtems++$(EXEEXT): $(rtems___OBJECTS) $(rtems___DEPENDENCIES)
@rm -f rtems++$(EXEEXT)
$(make-cxx-exe)
endif
include $(top_srcdir)/../automake/local.am

View File

@@ -1,135 +0,0 @@
/* system.h
*
* This include file contains information that is included in every
* function in the test set.
*
* COPYRIGHT (c) 1989-2008.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.org/license/LICENSE.
*/
#include <tmacros.h>
#include <rtems++/rtemsEvent.h>
#include <rtems++/rtemsMessageQueue.h>
#include <rtems++/rtemsTask.h>
#include <rtems++/rtemsTaskMode.h>
/* functions */
extern "C"
{
rtems_task Init(
rtems_task_argument argument
);
}
rtems_timer_service_routine Delayed_routine(
rtems_id ignored_id,
void *ignored_address
);
class Task1
: public rtemsTask
{
void print_mode(rtems_mode mode, rtems_mode mask);
void screen1(void);
void screen2(void);
void screen3(void);
void screen4(void);
void screen5(void);
void screen6(void);
protected:
virtual void body(rtems_task_argument argument);
public:
};
class Task2
: public rtemsTask
{
void screen4(void);
protected:
virtual void body(rtems_task_argument argument);
public:
Task2(const char* name,
const rtems_task_priority initial_priority,
const uint32_t stack_size);
};
class Task3
: public rtemsTask
{
void screen6(void);
protected:
virtual void body(rtems_task_argument argument);
public:
Task3(const char* name,
const rtems_task_priority initial_priority,
const uint32_t stack_size);
};
class EndTask
: public rtemsTask
{
protected:
virtual void body(rtems_task_argument argument);
public:
EndTask(const char* name,
const rtems_task_priority initial_priority,
const uint32_t stack_size);
};
#if 0
//
// Not sure this can be tested in a generic manner, any ideas anyone !!
//
class Service_routine
: public rtemsInterrupt
{
};
class Io_during_interrupt
: pubic rtemsTimer
{
};
#endif
/* configuration information */
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
#define CONFIGURE_MAXIMUM_TASKS 8
#define CONFIGURE_MAXIMUM_TIMERS 1
#define CONFIGURE_MAXIMUM_SEMAPHORES 2
#define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 1
#define CONFIGURE_MAXIMUM_PARTITIONS 1
#define CONFIGURE_MAXIMUM_REGIONS 1
#define CONFIGURE_MAXIMUM_PERIODS 1
#define CONFIGURE_MAXIMUM_USER_EXTENSIONS 0
#define CONFIGURE_TICKS_PER_TIMESLICE 100
#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
#define CONFIGURE_INIT_TASK_STACK_SIZE (4 * RTEMS_MINIMUM_STACK_SIZE)
#define CONFIGURE_EXTRA_TASK_STACKS (13 * RTEMS_MINIMUM_STACK_SIZE)
#include <rtems/confdefs.h>
/* end of include file */

View File

@@ -1,631 +0,0 @@
/* Task1
*
* This task is the main line for the test. It creates other
* tasks which can create
*
* Input parameters:
* argument - task argument
*
* Output parameters: NONE
*
* COPYRIGHT (c) 1997
* Objective Design Systems Ltd Pty (ODS)
* All rights reserved (R) Objective Design Systems Ltd Pty
*
* COPYRIGHT (c) 1989-2007.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.org/license/LICENSE.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdlib.h>
#include <string.h>
#include "System.h"
/* c.f. cpukit/score/include/rtems/score/priority.h */
#define PRIiPriority_Control PRIi32
/* rtems_task_priority is a typedef to Priority_Control */
#define PRIirtems_task_priority PRIiPriority_Control
/* c.f. cpukit/rtems/include/rtems/rtems/modes.h */
#define PRIXModes_Control PRIX32
#define PRIiModes_Control PRIi32
/* rtems_mode is a typedef to Modes_Control */
#define PRIXrtems_mode PRIXModes_Control
#define PRIirtems_mode PRIiModes_Control
/* c.f. cpukit/score/include/rtems/score/isr.h */
#define PRIiISR_Level PRIi32
/* rtems_interrupt_level is a typedef to ISR_Level */
#define PRIirtems_interrupt_level PRIiISR_Level
void Task1::body(rtems_task_argument argument)
{
rtems_test_pause_and_screen_number(1);
printf(" START Task Class test\n");
printf("%s - test argument - ", name_string());
if (argument != 0xDEADDEAD)
printf("argument is not 0xDEADDEAD\n");
else
printf("argument matched\n");
screen1();
rtems_test_pause_and_screen_number(2);
screen2();
rtems_test_pause_and_screen_number(3);
screen3();
rtems_test_pause_and_screen_number(4);
screen4();
rtems_test_pause_and_screen_number(5);
screen5();
rtems_test_pause_and_screen_number(6);
screen6();
// do not call exit(0) from this thread as this object is static
// the static destructor call delete the task which is calling exit
// so exit never completes
EndTask end_task("ENDT", (rtems_task_priority) 1, RTEMS_MINIMUM_STACK_SIZE * 6);
end_task.start(0);
rtemsEvent block_me;
rtems_event_set out;
block_me.receive(RTEMS_SIGNAL_0, out);
printf("**** TASK 1 did not block ????\n");
}
void Task1::screen1(void)
{
// create two local task objects to connect to this task
rtemsTask local_task_1 = *this;
rtemsTask local_task_2;
local_task_2 = *this;
// check the copy constructor works
printf("%s - copy constructor - ", name_string());
if (local_task_1.id_is() == id_is())
printf("local and this id's match\n");
else
printf("local and this id's do not match\n");
printf("%s - copy constructor - ", name_string());
if (local_task_1.name_is() == name_is())
printf("local and this name's match\n");
else
printf("local and this name's do not match\n");
// check the copy operator works
printf("%s - copy operator - ", name_string());
if (local_task_2.id_is() == id_is())
printf("local and this id's match\n");
else
printf("local and this id's do not match\n");
printf("%s - copy operator - ", name_string());
if (local_task_2.name_is() == name_is())
printf("local and this name's match\n");
else
printf("local and this name's do not match\n");
// check that the owner of the id cannot delete this task
printf("%s - not owner destroy's task - ", local_task_1.name_string());
local_task_1.destroy();
printf("%s\n", local_task_1.last_status_string());
// connect to a valid task
printf("%s - connect to a local valid task name - ", local_task_2.name_string());
local_task_2.connect("TA1 ", RTEMS_SEARCH_ALL_NODES);
printf("%s\n", local_task_2.last_status_string());
// connect to an invalid task
printf("%s - connect to an invalid task name - ", local_task_2.name_string());
local_task_2.connect("BADT", RTEMS_SEARCH_ALL_NODES);
printf("%s\n", local_task_2.last_status_string());
// connect to a task an invalid node
printf("%s - connect to a task on an invalid node - ", local_task_2.name_string());
local_task_2.connect("BADT", 10);
printf("%s\n", local_task_2.last_status_string());
// restart this task
printf("%s - restart from a non-owner - ", name_string());
local_task_1.restart(0);
printf("%s\n", local_task_1.last_status_string());
}
void Task1::screen2(void)
{
// wake after using this object
printf("%s - wake after 0 secs - ", name_string());
wake_after(0);
printf("%s\n", last_status_string());
printf("%s - wake after 500 msecs - ", name_string());
wake_after(500000);
printf("%s\n", last_status_string());
printf("%s - wake after 5 secs - ", name_string());
wake_after(5000000);
printf("%s\n", last_status_string());
printf("%s - wake when - to do\n", name_string());
rtemsTask task_1 = *this;
// wake after using a connected object
printf("%s - connected object wake after 0 secs - ", task_1.name_string());
task_1.wake_after(0);
printf("%s\n", task_1.last_status_string());
printf("%s - connected object wake after 500 msecs - ", task_1.name_string());
task_1.wake_after(500000);
printf("%s\n", task_1.last_status_string());
printf("%s - connected object wake after 5 secs - ", task_1.name_string());
task_1.wake_after(5000000);
printf("%s\n", task_1.last_status_string());
printf("%s - connected object wake when - to do\n", task_1.name_string());
rtemsTask task_2;
// wake after using a self object
printf("%s - self object wake after 0 secs - ", task_2.name_string());
task_2.wake_after(0);
printf("%s\n", task_2.last_status_string());
printf("%s - self object wake after 500 msecs - ", task_2.name_string());
task_2.wake_after(500000);
printf("%s\n", task_2.last_status_string());
printf("%s - self object wake after 5 secs - ", task_2.name_string());
task_2.wake_after(5000000);
printf("%s\n", task_2.last_status_string());
printf("%s - self object wake when - to do\n", task_2.name_string());
rtems_task_priority current_priority;
rtems_task_priority priority;
// priorities with this object
printf("%s - get priority - ", name_string());
get_priority(current_priority);
printf("%s, priority is %" PRIirtems_task_priority "\n", last_status_string(), current_priority);
printf("%s - set priority to 512 - ", name_string());
set_priority(512);
printf("%s\n", last_status_string());
printf("%s - set priority to 25 - ", name_string());
set_priority(25);
printf("%s\n", last_status_string());
printf("%s - set priority to original - ", name_string());
set_priority(current_priority, priority);
printf("%s, priority was %" PRIirtems_task_priority "\n", last_status_string(), priority);
// priorities with connected object
printf("%s - connected object get priority - ", task_1.name_string());
task_1.get_priority(current_priority);
printf("%s, priority is %" PRIirtems_task_priority "\n", task_1.last_status_string(), current_priority);
printf("%s - connected object set priority to 512 - ", task_1.name_string());
task_1.set_priority(512);
printf("%s\n", task_1.last_status_string());
printf("%s - connected object set priority to 25 - ", task_1.name_string());
task_1.set_priority(25);
printf("%s\n", task_1.last_status_string());
printf("%s - connected object set priority to original - ", task_1.name_string());
task_1.set_priority(current_priority, priority);
printf("%s, priority was %" PRIirtems_task_priority "\n", task_1.last_status_string(), priority);
// priorities with self object
printf("%s - self object get priority - ", task_2.name_string());
task_2.get_priority(current_priority);
printf("%s, priority is %" PRIirtems_task_priority "\n", task_2.last_status_string(), current_priority);
printf("%s - self object set priority to 512 - ", task_2.name_string());
task_2.set_priority(512);
printf("%s\n", task_2.last_status_string());
printf("%s - self object set priority to 25 - ", task_2.name_string());
task_2.set_priority(25);
printf("%s\n", task_2.last_status_string());
printf("%s - self object set priority to original - ", task_2.name_string());
task_2.set_priority(current_priority, priority);
printf("%s, priority was %" PRIirtems_task_priority "\n", task_2.last_status_string(), priority);
printf(" END Task Class test\n");
}
#define RTEMS_ALL_MODES (RTEMS_PREEMPT_MASK | \
RTEMS_TIMESLICE_MASK | \
RTEMS_ASR_MASK | \
RTEMS_INTERRUPT_MASK)
void Task1::screen3(void)
{
printf(" START TaskMode Class test\n");
rtemsTask self;
rtemsTaskMode task_mode;
rtems_mode current_mode;
rtems_mode mode;
printf("%s - get mode - ", self.name_string());
task_mode.get_mode(current_mode);
printf("%s,\n\t mode is 0x%08" PRIXrtems_mode ", ", task_mode.last_status_string(), current_mode);
print_mode(current_mode, RTEMS_ALL_MODES);
printf("\n");
// PREEMPTION mode control
printf("%s - get preemption state - ", self.name_string());
task_mode.get_preemption_state(mode);
printf("%s,\n\t mode is 0x%08" PRIXrtems_mode ", ", task_mode.last_status_string(), mode);
print_mode(mode, RTEMS_PREEMPT_MASK);
printf("\n");
printf("%s - set preemption state to RTEMS_PREEMPT - ", self.name_string());
task_mode.set_preemption_state(RTEMS_PREEMPT);
task_mode.get_mode(mode);
printf("%s,\n\t mode is 0x%08" PRIXrtems_mode ", ", task_mode.last_status_string(), mode);
print_mode(mode, RTEMS_ALL_MODES);
printf("\n");
printf("%s - set preemption state to RTEMS_NO_PREEMPT - ", self.name_string());
task_mode.set_preemption_state(RTEMS_NO_PREEMPT);
task_mode.get_mode(mode);
printf("%s,\n\t mode is 0x%08" PRIXrtems_mode ", ", task_mode.last_status_string(), mode);
print_mode(mode, RTEMS_ALL_MODES);
printf("\n");
// TIMESLICE mode control
printf("%s - get timeslice state - ", self.name_string());
task_mode.get_timeslice_state(mode);
printf("%s,\n\t mode is 0x%08" PRIXrtems_mode ", ", task_mode.last_status_string(), mode);
print_mode(mode, RTEMS_TIMESLICE_MASK);
printf("\n");
printf("%s - set timeslice state to RTEMS_TIMESLICE - ", self.name_string());
task_mode.set_timeslice_state(RTEMS_TIMESLICE);
task_mode.get_mode(mode);
printf("%s,\n\t mode is 0x%08" PRIXrtems_mode ", ", task_mode.last_status_string(), mode);
print_mode(mode, RTEMS_ALL_MODES);
printf("\n");
printf("%s - set timeslice state to RTEMS_NO_TIMESLICE - ", self.name_string());
task_mode.set_timeslice_state(RTEMS_NO_TIMESLICE);
task_mode.get_mode(mode);
printf("%s,\n\t mode is 0x%08" PRIXrtems_mode ", ", task_mode.last_status_string(), mode);
print_mode(mode, RTEMS_ALL_MODES);
printf("\n");
// ASR mode control
printf("%s - get asr state - ", self.name_string());
task_mode.get_asr_state(mode);
printf("%s,\n\t mode is 0x%08" PRIXrtems_mode ", ", task_mode.last_status_string(), mode);
print_mode(mode, RTEMS_ASR_MASK);
printf("\n");
printf("%s - set asr state to RTEMS_ASR - ", self.name_string());
task_mode.set_asr_state(RTEMS_ASR);
task_mode.get_mode(mode);
printf("%s,\n\t mode is 0x%08" PRIXrtems_mode ", ", task_mode.last_status_string(), mode);
print_mode(mode, RTEMS_ALL_MODES);
printf("\n");
printf("%s - set asr state to RTEMS_NO_ASR - ", self.name_string());
task_mode.set_asr_state(RTEMS_NO_ASR);
task_mode.get_mode(mode);
printf("%s,\n\t mode is 0x%08" PRIXrtems_mode ", ", task_mode.last_status_string(), mode);
print_mode(mode, RTEMS_ALL_MODES);
printf("\n");
// interrupt level control
rtems_interrupt_level current_level;
rtems_interrupt_level level;
printf("%s - get current interrupt level - ", self.name_string());
task_mode.get_interrupt_level(current_level);
printf("%s, level is %" PRIirtems_interrupt_level "\n", task_mode.last_status_string(), current_level);
printf("%s - set interrupt level to 102 - ", self.name_string());
task_mode.set_interrupt_level(102);
printf("%s\n", task_mode.last_status_string());
printf("%s - set interrupt level to original level - ", self.name_string());
task_mode.set_interrupt_level(current_level, level);
printf("%s, level was %" PRIirtems_interrupt_level "\n", task_mode.last_status_string(), level);
printf("%s - set mode to original mode - ", self.name_string());
task_mode.set_mode(current_mode,
RTEMS_PREEMPT_MASK | RTEMS_TIMESLICE_MASK |
RTEMS_ASR_MASK | RTEMS_INTERRUPT_MASK);
task_mode.get_mode(mode);
printf("%s,\n\t mode is 0x%08" PRIXrtems_mode ", ", task_mode.last_status_string(), mode);
print_mode(mode, RTEMS_ALL_MODES);
printf("\n");
printf(" END TaskMode Class test\n");
}
void Task1::screen4(void)
{
printf(" START Event Class test\n");
printf("%s - create task 2 - ", name_string());
Task2 task_2("TA2", (rtems_task_priority) 9, RTEMS_MINIMUM_STACK_SIZE * 6);
printf("%s\n", task_2.last_status_string());
printf("%s - start task 2 - ", name_string());
task_2.start(0);
printf("%s\n", task_2.last_status_string());
printf("%s - construct event connecting to task 2 - ", name_string());
rtemsEvent event_2("TA2 ");
printf("%s\n", event_2.last_status_string());
// wait for task 2 to complete its timeout tests
wake_after(7000000);
printf("%s - send event signal 0 using the task id - ", name_string());
event_2.send(task_2.id_is(), RTEMS_SIGNAL_0);
printf("%s\n", event_2.last_status_string());
wake_after(1000000);
printf("%s - send event signal 0 using the task object reference - ", name_string());
event_2.send(task_2, RTEMS_SIGNAL_0);
printf("%s\n", event_2.last_status_string());
wake_after(1000000);
printf("%s - send event signal 31 using connected id - ", name_string());
event_2.send(RTEMS_SIGNAL_31);
printf("%s\n", event_2.last_status_string());
wake_after(1000000);
rtemsEvent event_2_2;
event_2_2.connect("TA2");
printf("%s - send event signal 0 and 31 - ", name_string());
event_2_2.send(task_2, RTEMS_SIGNAL_0 | RTEMS_SIGNAL_31);
printf("%s\n", event_2_2.last_status_string());
printf("%s - waiting 5 secs for TA2 to finish\n", name_string());
wake_after(500000);
printf(" END Event Class test\n");
}
void Task1::screen5(void)
{
printf(" START Interrupt Class test\n");
printf(" do not know a portable BSP type interrupt test\n");
printf(" END Interrupt Class test\n");
}
void Task1::screen6(void)
{
printf(" START MessageQueue Class test\n");
printf("%s - construct message queue 1 with no memory error - ", name_string());
rtemsMessageQueue mq_1("MQ1", 1000000, 1000);
printf("%s\n", mq_1.last_status_string());
printf("%s - construct/create message queue 2 - ", name_string());
rtemsMessageQueue mq_2("MQ2", 4, 50);
printf("%s\n", mq_2.last_status_string());
const char *u1 = "normal send";
const char *u2 = "urgent send";
char in[100];
size_t size;
uint32_t count;
printf("%s - send u1 to mq_2 - ", name_string());
mq_2.send(u1, strlen(u1) + 1);
printf("%s\n", mq_2.last_status_string());
printf("%s - urgent send u2 to mq_2 - ", name_string());
mq_2.urgent(u2, strlen(u2) + 1);
printf("%s\n", mq_2.last_status_string());
printf("%s - create task 3_1 - ", name_string());
Task3 task_3_1("TA31", 9, RTEMS_MINIMUM_STACK_SIZE * 6);
printf("%s\n", task_3_1.last_status_string());
printf("%s - start task 3_1 - ", name_string());
task_3_1.start(0);
printf("%s\n", task_3_1.last_status_string());
printf("%s - create task 3_2 - ", name_string());
Task3 task_3_2("TA32", 9, RTEMS_MINIMUM_STACK_SIZE * 6);
printf("%s\n", task_3_2.last_status_string());
printf("%s - start task 3_2 - ", name_string());
task_3_2.start(0);
printf("%s\n", task_3_1.last_status_string());
wake_after(1000000);
printf("%s - receive u2 on mq_2 ...\n", name_string()); fflush(stdout);
mq_2.receive(in, size, 5000000);
printf("%s - %s\n", name_string(), mq_2.last_status_string());
if (size == (strlen(u2) + 5))
{
if ((strncmp(in, task_3_1.name_string(), 4) == 0) &&
(strcmp(in + 4, u2) == 0))
{
printf("%s - message u2 received correctly\n", name_string());
}
else
{
printf("%s - message u2 received incorrectly, message='%s', size=%zu\n",
name_string(), in, size);
}
}
else
printf("%s - message u2 size incorrect, size=%zu\n", name_string(), size);
printf("%s - receive u1 on mq_2 ...\n", name_string()); fflush(stdout);
mq_2.receive(in, size, 5000000);
printf("%s - %s\n", name_string(), mq_2.last_status_string());
if (size == (strlen(u1) + 5))
{
if ((strncmp(in, task_3_2.name_string(), 4) == 0) &&
(strcmp(in + 4, u1) == 0))
{
printf("%s - message u1 received correctly\n", name_string());
}
else
{
printf("%s - message u1 received incorrectly, message='%s', size=%zu\n",
name_string(), in, size);
}
}
else
printf("%s - message u1 size incorrect, size=%zu\n", name_string(), size);
wake_after(3000000);
const char *b1 = "broadcast message";
printf("%s - broadcast send b1 ...\n", name_string());
mq_2.broadcast(b1, strlen(b1) + 1, count);
printf("%s - mq_2 broadcast send - %s, count=%" PRIi32 "\n",
name_string(), mq_2.last_status_string(), count);
wake_after(1000000);
printf("%s - receive message b1 on mq_2 from %s...\n",
name_string(), task_3_1.name_string()); fflush(stdout);
mq_2.receive(in, size, 5000000);
printf("%s - %s\n", name_string(), mq_2.last_status_string());
if (size == (strlen(b1) + 5))
{
if ((strncmp(in, task_3_1.name_string(), 4) == 0) &&
(strcmp(in + 4, b1) == 0))
{
printf("%s - message b1 received correctly\n", name_string());
}
else
{
printf("%s - message b1 received incorrectly, message='%s'\n",
name_string(), in);
}
}
else
printf("%s - message b1 size incorrect, size=%zu\n", name_string(), size);
printf("%s - receive message b1 on mq_2 from %s...\n",
name_string(), task_3_1.name_string()); fflush(stdout);
mq_2.receive(in, size, 5000000);
printf("%s - %s\n", name_string(), mq_2.last_status_string());
if (size == (strlen(b1) + 5))
{
if ((strncmp(in, task_3_2.name_string(), 4) == 0) &&
(strcmp(in + 4, b1) == 0))
{
printf("%s - message b1 received correctly\n", name_string());
}
else
{
printf("%s - message b1 received incorrectly, message='%s', size=%zu\n",
name_string(), in, size);
}
}
else
printf("%s - message b1 size incorrect, size=%zu\n", name_string(), size);
// wait for task 3_1, and 3_2 to complete their timeout tests, will
// start these after getting the broadcast message
wake_after(7000000);
const char *f1 = "flush message";
printf("%s - send f1 to mq_2 - ", name_string());
mq_2.send(f1, strlen(f1) + 1);
printf("%s\n", mq_2.last_status_string());
printf("%s - send f1 to mq_2 - ", name_string());
mq_2.send(f1, strlen(f1) + 1);
printf("%s\n", mq_2.last_status_string());
printf("%s - send f1 to mq_2 - ", name_string());
mq_2.send(f1, strlen(f1) + 1);
printf("%s\n", mq_2.last_status_string());
printf("%s - flush mq_2 - ", name_string());
mq_2.flush(count);
printf("%s, flushed=%" PRIi32 "\n", mq_2.last_status_string(), count);
printf(" END MessageQueue Class test\n");
}
void Task1::print_mode(rtems_mode mode, rtems_mode mask)
{
rtemsTaskMode task_mode;
if (mask & RTEMS_PREEMPT_MASK)
printf("RTEMS_%sPREEMPT ",
task_mode.preemption_set(mode) ? "" : "NO_");
if (mask & RTEMS_TIMESLICE_MASK)
printf("RTEMS_%sTIMESLICE ",
task_mode.preemption_set(mode) ? "" : "NO_");
if (mask & RTEMS_ASR_MASK)
printf("RTEMS_%sASR ",
task_mode.asr_set(mode) ? "" : "NO_");
if (mask & RTEMS_INTERRUPT_MASK)
printf("INTMASK=%" PRIirtems_mode,
mode & RTEMS_INTERRUPT_MASK);
}
EndTask::EndTask(const char* name,
const rtems_task_priority initial_priority,
const uint32_t stack_size)
: rtemsTask(name, initial_priority, stack_size, RTEMS_NO_PREEMPT)
{
}
void EndTask::body(rtems_task_argument)
{
TEST_END();
exit(0);
}

View File

@@ -1,82 +0,0 @@
/* Task_2
*
* This routine serves as a test task. Its only purpose is to generate the
* error where a semaphore is deleted while a task is waiting for it.
*
* Input parameters:
* argument - task argument
*
* Output parameters: NONE
*
* COPYRIGHT (c) 1989-1999.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.org/license/LICENSE.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "System.h"
Task2::Task2(const char* name,
const rtems_task_priority initial_priority,
const uint32_t stack_size)
: rtemsTask(name, initial_priority, stack_size, RTEMS_NO_PREEMPT)
{
}
void Task2::body(rtems_task_argument )
{
screen4();
printf("%s - destroy itself\n", name_string());
destroy();
}
void Task2::screen4()
{
rtemsEvent event;
// block waiting for any event
rtems_event_set out;
printf("%s - event no wait - ", name_string());
event.receive(RTEMS_SIGNAL_0, out, 0, rtemsEvent::no_wait);
printf("%s\n", event.last_status_string());
printf("%s - event 5 secs timeout - ", name_string()); fflush(stdout);
event.receive(RTEMS_SIGNAL_0, out, 5000000);
printf("%s\n", event.last_status_string());
// send using task id
printf("%s - event wait forever for signal 0 from TA1 ....\n", name_string());
event.receive(RTEMS_SIGNAL_0, out);
printf("%s - %s, signals out are 0x%08" PRIX32 "\n", name_string(), event.last_status_string(), out);
// send using task object reference
printf("%s - event wait forever for signal 0 from TA1 ....\n", name_string());
event.receive(RTEMS_SIGNAL_0, out);
printf("%s - %s, signals out are 0x%08" PRIX32 "\n", name_string(), event.last_status_string(), out);
printf("%s - event wait forever for signal 31 from TA1 ....\n", name_string());
event.receive(RTEMS_SIGNAL_31, out);
printf("%s - %s, signals out are 0x%08" PRIX32 "\n", name_string(), event.last_status_string(), out);
printf("%s - event wait forever for signal 0 and 31 from TA1 ....\n", name_string());
event.receive(RTEMS_SIGNAL_0 | RTEMS_SIGNAL_31, out, 0, rtemsEvent::wait, rtemsEvent::all);
printf("%s - %s, signals out are 0x%08" PRIX32 "\n", name_string(), event.last_status_string(), out);
printf("%s - send event signal 1 - ", name_string());
event.send(RTEMS_SIGNAL_1);
printf("%s\n", event.last_status_string());
printf("%s - event wait forever for signal 1 from TA2 - ", name_string());
event.receive(RTEMS_SIGNAL_1, out, 0, rtemsEvent::wait, rtemsEvent::all);
printf("%s, signals out are 0x%08" PRIX32 "\n", event.last_status_string(), out);
}

View File

@@ -1,82 +0,0 @@
/* Task_3
*
* This routine serves as a test task. Loopback the messages and test
* timeouts
*
* Input parameters:
* argument - task argument
*
* Output parameters: NONE
*
* COPYRIGHT (c) 1989-2007.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.org/license/LICENSE.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "System.h"
Task3::Task3(const char* name,
const rtems_task_priority initial_priority,
const uint32_t stack_size)
: rtemsTask(name, initial_priority, stack_size, RTEMS_NO_PREEMPT)
{
}
void Task3::body(rtems_task_argument )
{
screen6();
printf("%s - destroy itself\n", name_string());
destroy();
}
void Task3::screen6()
{
rtemsMessageQueue mq_2("MQ2");
printf("%s - construction connect mq_2 - %s\n", name_string(), mq_2.last_status_string());
if (mq_2.successful())
{
char in[100];
char out[100];
size_t size;
bool loopback = true;
while (loopback)
{
printf("%s - loopback from mq_2 to mq_2 ...\n", name_string()); fflush(stdout);
mq_2.receive(in, size);
printf("%s - mq_2 receive - %s, size=%zu, message string size=%zu\n",
name_string(), mq_2.last_status_string(), size, strlen(in));
if (mq_2.successful())
{
if (size > (100 - 5))
printf("%s - size to large\n", name_string());
else
{
strcpy(out, name_string());
strcpy(out + 4, in);
printf("%s - loopback to mq_2 - ", name_string());
mq_2.send(out, strlen(out) + 1);
printf("%s\n", mq_2.last_status_string());
}
if (strcmp(in, "broadcast message") == 0)
loopback = false;
else
wake_after(1500000);
}
}
}
}

View File

@@ -1,26 +0,0 @@
# COPYRIGHT (c) 1997
# Objective Design Systems Ltd Pty (ODS)
# All rights reserved (R) Objective Design Systems Ltd Pty
#
# The license and distribution terms for this file may be found in the
# file LICENSE in this distribution or at
# http://www.rtems.org/license/LICENSE.
#
The file describes the directives and concepts tested by this test set.
test set name: rtems++
classes:
rtemsTask, rtemsTaskMode, rtemsEvent, rtemsMessageQueue
concepts:
a. Verify each class tested can be constructed using each of the constructors.
b. Verify each class can be an owner of an object id if capable.
c. Verify each class can connect to an existing object id if capable.
d. Verify the operation of each method of each class.

View File

@@ -1,149 +0,0 @@
*** RTEMS++ TEST ***
INIT - Task.create() - RTEMS[19] invalid thread priority
INIT - Task.create() - RTEMS[00] successful completion
INIT - Task.create() - RTEMS[16] illegal on calling thread
INIT - Task.restart() - RTEMS[14] thread is in wrong state
INIT - Task.start(0xDEADDEAD) - RTEMS[00] successful completion
INIT - Destroy it's self
<pause - screen 1>
START Task Class test
TA1 - test argument - argument matched
TA1 - copy constructor - local and this id's match
TA1 - copy constructor - local and this name's match
TA1 - copy operator - local and this id's match
TA1 - copy operator - local and this name's match
TA1 - not owner destroy's task - RTEMS[23] not owner of resource
TA1 - connect to a local valid task name - RTEMS[00] successful completion
TA1 - connect to an invalid task name - RTEMS[03] invalid object name
SELF - connect to a task on an invalid node - RTEMS[03] invalid object name
TA1 - restart from a non-owner - RTEMS[23] not owner of resource
<pause - screen 2>
TA1 - wake after 0 secs - RTEMS[00] successful completion
TA1 - wake after 500 msecs - RTEMS[00] successful completion
TA1 - wake after 5 secs - RTEMS[00] successful completion
TA1 - wake when - to do
TA1 - connected object wake after 0 secs - RTEMS[00] successful completion
TA1 - connected object wake after 500 msecs - RTEMS[00] successful completion
TA1 - connected object wake after 5 secs - RTEMS[00] successful completion
TA1 - connected object wake when - to do
SELF - self object wake after 0 secs - RTEMS[00] successful completion
SELF - self object wake after 500 msecs - RTEMS[00] successful completion
SELF - self object wake after 5 secs - RTEMS[00] successful completion
SELF - self object wake when - to do
TA1 - get priority - RTEMS[00] successful completion, priority is 10
TA1 - set priority to 512 - RTEMS[19] invalid thread priority
TA1 - set priority to 25 - RTEMS[00] successful completion
TA1 - set priority to original - RTEMS[00] successful completion, priority was 25
TA1 - connected object get priority - RTEMS[00] successful completion, priority is 10
TA1 - connected object set priority to 512 - RTEMS[19] invalid thread priority
TA1 - connected object set priority to 25 - RTEMS[00] successful completion
TA1 - connected object set priority to original - RTEMS[00] successful completion, priority was 25
SELF - self object get priority - RTEMS[00] successful completion, priority is 10
SELF - self object set priority to 512 - RTEMS[19] invalid thread priority
SELF - self object set priority to 25 - RTEMS[00] successful completion
SELF - self object set priority to original - RTEMS[00] successful completion, priority was 25
END Task Class test
<pause - screen 3>
START TaskMode Class test
SELF - get mode - RTEMS[00] successful completion,
mode is 0x00000500, RTEMS_NO_PREEMPT RTEMS_NO_TIMESLICE RTEMS_ASR INTMASK=0
SELF - get preemption state - RTEMS[00] successful completion,
mode is 0x00000100, RTEMS_NO_PREEMPT
SELF - set preemption state to RTEMS_PREEMPT - RTEMS[00] successful completion,
mode is 0x00000400, RTEMS_PREEMPT RTEMS_TIMESLICE RTEMS_ASR INTMASK=0
SELF - set preemption state to RTEMS_NO_PREEMPT - RTEMS[00] successful completion,
mode is 0x00000500, RTEMS_NO_PREEMPT RTEMS_NO_TIMESLICE RTEMS_ASR INTMASK=0
SELF - get timeslice state - RTEMS[00] successful completion,
mode is 0x00000000, RTEMS_TIMESLICE
SELF - set timeslice state to RTEMS_TIMESLICE - RTEMS[00] successful completion,
mode is 0x00000700, RTEMS_NO_PREEMPT RTEMS_NO_TIMESLICE RTEMS_ASR INTMASK=0
SELF - set timeslice state to RTEMS_NO_TIMESLICE - RTEMS[00] successful completion,
mode is 0x00000500, RTEMS_NO_PREEMPT RTEMS_NO_TIMESLICE RTEMS_ASR INTMASK=0
SELF - get asr state - RTEMS[00] successful completion,
mode is 0x00000400, RTEMS_ASR
SELF - set asr state to RTEMS_ASR - RTEMS[00] successful completion,
mode is 0x00000100, RTEMS_NO_PREEMPT RTEMS_NO_TIMESLICE RTEMS_NO_ASR INTMASK=0
SELF - set asr state to RTEMS_NO_ASR - RTEMS[00] successful completion,
mode is 0x00000500, RTEMS_NO_PREEMPT RTEMS_NO_TIMESLICE RTEMS_ASR INTMASK=0
SELF - get current interrupt level - RTEMS[00] successful completion, level is 0
SELF - set interrupt level to 102 - RTEMS[00] successful completion
SELF - set interrupt level to original level - RTEMS[00] successful completion, level was 6
SELF - set mode to original mode - RTEMS[00] successful completion,
mode is 0x00000500, RTEMS_NO_PREEMPT RTEMS_NO_TIMESLICE RTEMS_ASR INTMASK=0
END TaskMode Class test
<pause - screen 4>
START Event Class test
TA1 - create task 2 - RTEMS[00] successful completion
TA1 - start task 2 - RTEMS[00] successful completion
TA1 - construct event connecting to task 2 - RTEMS[00] successful completion
TA2 - event no wait - RTEMS[13] request not satisfied
TA2 - event 5 secs timeout - RTEMS[06] timed out waiting
TA2 - event wait forever for signal 0 from TA1 ....
TA1 - send event signal 0 using the task id - RTEMS[00] successful completion
TA2 - RTEMS[00] successful completion, signals out are 0x00000001
TA2 - event wait forever for signal 0 from TA1 ....
TA1 - send event signal 0 using the task object reference - RTEMS[00] successful completion
TA2 - RTEMS[00] successful completion, signals out are 0x00000001
TA2 - event wait forever for signal 31 from TA1 ....
TA1 - send event signal 31 using connected id - RTEMS[00] successful completion
TA2 - RTEMS[00] successful completion, signals out are 0x80000000
TA2 - event wait forever for signal 0 and 31 from TA1 ....
TA1 - send event signal 0 and 31 - RTEMS[00] successful completion
TA1 - waiting 5 secs for TA2 to finish
TA2 - RTEMS[00] successful completion, signals out are 0x80000001
TA2 - send event signal 1 - RTEMS[00] successful completion
TA2 - event wait forever for signal 1 from TA2 - RTEMS[00] successful completion, signals out are 0x00000002
TA2 - destroy itself
END Event Class test
<pause - screen 5>
START Interrupt Class test
do not know a portable BSP type interrupt test
END Interrupt Class test
<pause - screen 6>
START MessageQueue Class test
TA1 - construct message queue 1 with no memory error - RTEMS[13] request not satisfied
TA1 - construct/create message queue 2 - RTEMS[00] successful completion
TA1 - send u1 to mq_2 - RTEMS[00] successful completion
TA1 - urgent send u2 to mq_2 - RTEMS[00] successful completion
TA1 - create task 3_1 - RTEMS[00] successful completion
TA1 - start task 3_1 - RTEMS[00] successful completion
TA1 - create task 3_2 - RTEMS[00] successful completion
TA1 - start task 3_2 - RTEMS[00] successful completion
TA31 - construction connect mq_2 - RTEMS[00] successful completion
TA31 - loopback from mq_2 to mq_2 ...
TA31 - mq_2 receive - RTEMS[00] successful completion, size=12, message string size=11
TA31 - loopback to mq_2 - RTEMS[00] successful completion
TA32 - construction connect mq_2 - RTEMS[00] successful completion
TA32 - loopback from mq_2 to mq_2 ...
TA32 - mq_2 receive - RTEMS[00] successful completion, size=12, message string size=11
TA32 - loopback to mq_2 - RTEMS[00] successful completion
TA1 - receive u2 on mq_2 ...
TA1 - RTEMS[00] successful completion
TA1 - message u2 received correctly
TA1 - receive u1 on mq_2 ...
TA1 - RTEMS[00] successful completion
TA1 - message u1 received correctly
TA31 - loopback from mq_2 to mq_2 ...
TA32 - loopback from mq_2 to mq_2 ...
TA1 - broadcast send b1 ...
TA1 - mq_2 broadcast send - RTEMS[00] successful completion, count=2
TA31 - mq_2 receive - RTEMS[00] successful completion, size=18, message string size=17
TA31 - loopback to mq_2 - RTEMS[00] successful completion
TA31 - destroy itself
TA32 - mq_2 receive - RTEMS[00] successful completion, size=18, message string size=17
TA32 - loopback to mq_2 - RTEMS[00] successful completion
TA32 - destroy itself
TA1 - receive message b1 on mq_2 from TA31...
TA1 - RTEMS[00] successful completion
TA1 - message b1 received correctly
TA1 - receive message b1 on mq_2 from TA31...
TA1 - RTEMS[00] successful completion
TA1 - message b1 received correctly
TA1 - send f1 to mq_2 - RTEMS[00] successful completion
TA1 - send f1 to mq_2 - RTEMS[00] successful completion
TA1 - send f1 to mq_2 - RTEMS[00] successful completion
TA1 - flush mq_2 - RTEMS[00] successful completion, flushed=3
END MessageQueue Class test
*** END OF RTEMS++ TEST ***