URL
https://opencores.org/ocsvn/openrisc/openrisc/trunk
Subversion Repositories openrisc
[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [librtems++/] [README] - Rev 30
Go to most recent revision | Compare with Previous | Blame | View Log
## $Id: README,v 1.2 2001-09-27 12:02:05 chris Exp $#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, forperformance, to share the existing C documentation as much aspossible, and to allow easy tracking of any changes to the RTEMS CAPI.The C++ interface only uses RTEMS API calls. No external referencesor internal interfaces are used. This allows the classes to be usedin separately compiled modules or applications which link to the RTEMStrap interface.(This is the goal, which has not quite been reached. The TOD macro formicro-seconds to ticks is used, and this uses an internal global RTEMSvariable)The C++ interface does not deal with RTEMS initialisation or thedevice driver interface. The current view is these parts of a systemare best handled in the current manner. This means BSP forinitialisation 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 casesor follow the documented RTEMS default values. Moving from left toright the parameters become less used, allowing the defaults to beselected. An example is the scope parameter for most classes. Thiscan 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 inapplications. This tries to add the minimum of overhead. Forexample, the methods to send or receive events are inline, while allmethods 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 RTEMSequivalent. For example the enumeration Scope is defined for variousclasses which can be local or global. The elements of the enumerationare forced to the same value as the RTEMS values. An enumeration isused in this case to allow the compiler to type check a littlebetter. It saves having to check only RTEMS_LOCAL or RTEMS_GLOBAL ispassed as a parameter (I am not convinced this is really needed as thegoal 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 becontrolled separately or controlled as a group. An example is thetask mode. The RTEMS C API allows a set of modes to be modified atonce. The TaskMode class allows this to occur, while also providingmethods to control a single mode item.The name of an object is always passed as a string. The classes turnthe string into a rtems_name variable. The string does not have to benul character terminated.The RTEMS C API uses 'delete' to remove or kill an RTEMS object. Thisis a reserved word in C++, so the word 'destroy' is used instead.Calling the classes from interrupts follows the rules of RTEMS. Anexception introduced by the class library is the last status code.There is only one last status code for each instance of the library'sclasses and it is not protected. This needs to be watched for. Maybea better solution needs to be found, such as interrupt calls do not setthe last status code.RTEMS objects created by the C++ library can be operated on by C codejust as any other RTEMS object. If limitations exist they should bedocumented in under the class.RTEMS Object Ownership======================The concept of ownership of an object is not defined as part of theRTEMS C API. A piece of code executing as part a task can create amessage queue. Another piece of code running as part of a differenttask can destroy the message queue. Correct behavior between the codethat creates the message queue and the code which destroy's themessage 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. AC++ 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-forcethis rule.Ownership only applies to classes that create RTEMS objects. Theseclasses contain a flag which signals ownership of the id.Timeouts========The timeout value is specified in micro-seconds. The classes turn themicro-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. Allother cases round down to the nearest tick.Status Codes============All classes which form the C++ API are derived from the StatusCodeclass. This class provides a common method for handling the statuscode returned by RTEMS.The last returned status code is held in the StatusCode object. Itcan be queried directly, or as a boolean. You can also obtain anerror 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 anRTEMS defined status code.Event Class===========The event class allows users to send and receive events to and fromtasks.Events objects are by default connected the RTEMS_SELF task. A sendor 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 byusing the copy constructor or assignment operator.Events can be sent to a task by specifying an RTEMS task id, or bypassing a reference to a Task object.Interrupt Class===============The interrupt class allows a protected virtual method of a derivedclass to be an interrupt handler.You derive from this class and provide the handler method. The nextinterrupt after the vector is caught will cause the handler method tobe entered.You can chain the interrupt by calling the chain method. If the oldhandler 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 isdirectly called. (Chaining has not been tested)This class implements a table of pointers to the last instance tocatch the interrupt. A static method of the class catches theinterrupt and re-directs the interrupt to the instance in the table.The re-direct adds a additional virtual function call and return tothe overhead of the interrupt. For a i386 type processor this isabout 12 instructions including the function call entry.Message Queue Class===================The MessageQueue class allows message queue's to be created, orconnected 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 connectedtoo. 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 thecreator can destroy a task.If creating a task, derive from the Task class and provide the bodymethod. The body method is the entry point for a task. Whenconnecting to an existing task, no body method is required to beprovided. It is how-ever required if you create a task. This is notenforced by the compiler, how-ever the default body will be entered,and it contains no code. The RTEMS default behaviour for a task thatreturns occurs.The mode of a task is controlled using the TaskMode class.The Task class allows you to start, restart, suspend, and resume atask. You can control the priority, and access the note-padregisters. The task can also be slept using the wake_after andwake_when methods.Currently the task argument is used to pass the 'this' pointer to thelibraries default task body. The actual argument is held in the classinstance and passed to the virtual body method. This means of passingthe 'this' pointer through RTEMS to the default task body requires theactual task object to perform a restart call. This is not really thebest solution to the problem. Another solution is to remove a notpadregister, say 31 from the task and use it. This would mean any Taskobject could stop and restart a task how-ever a notpad register islost. 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 requiredto be changed in a single operation. The mode and mask is specifiedby 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, andonly the that mode will be changed when setting a mode.Timer Class===========The Timer class allows timers to be created. You cannot connect to anexisting timer.You derive from the Timer class and provide the trigger method. Thismethod is called when the timer triggers or times out.You can request a single shot timer using the fire_after or fire_whenmethods, 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 RTEMSmailing 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 forembedded systems.4) Provide a memory serial class which maps the <</>> operators ontoraw 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 thatstart in an ordered manner.
Go to most recent revision | Compare with Previous | Blame | View Log
