From a71938283c65531e49a6398905be59705c36b748 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Mon, 30 Aug 1999 18:38:26 +0000 Subject: Patch from Ralf Corsepius to move c/src/lib/librtems++ and c/src/lib/include/rtems++ to their own package librtems++ at the top of the tree. To apply: mkdir c/src/librtems++ cp c/src/lib/librtems++/README c/src/librtems++ mkdir c/src/librtems++/src cp c/src/lib/librtems++/*.cc c/src/librtems++/src cp c/src/lib/librtems++/Makefile.in c/src/librtems++/src mkdir c/src/librtems++/include mkdir c/src/librtems++/include/rtems++ cp c/src/lib/include/rtems++/*.h c/src/librtems++/include/rtems++ patch -p1 -#include - -/* ---- - 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, rtems_unsigned32 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 rtems_unsigned32 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 < _TOD_Microseconds_per_tick) ? - _TOD_Microseconds_per_tick : micro_secs; - set_status_code(rtems_event_receive(event_in, - wait | condition, - TOD_MICROSECONDS_TO_TICKS(usecs), - &event_out)); - return last_status_code(); -} - -#endif // _rtemsEvent_h_ - - - - - diff --git a/c/src/lib/include/rtems++/rtemsInterrupt.h b/c/src/lib/include/rtems++/rtemsInterrupt.h deleted file mode 100644 index f722eb7683..0000000000 --- a/c/src/lib/include/rtems++/rtemsInterrupt.h +++ /dev/null @@ -1,105 +0,0 @@ -/* - ------------------------------------------------------------------------ - $Id$ - ------------------------------------------------------------------------ - - 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.OARcorp.com/rtems/license.html. - - ------------------------------------------------------------------------ - - 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 - -/* ---- - 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_ - - - - - diff --git a/c/src/lib/include/rtems++/rtemsMessageQueue.h b/c/src/lib/include/rtems++/rtemsMessageQueue.h deleted file mode 100644 index 910c7279f7..0000000000 --- a/c/src/lib/include/rtems++/rtemsMessageQueue.h +++ /dev/null @@ -1,176 +0,0 @@ -/* - ------------------------------------------------------------------------ - $Id$ - ------------------------------------------------------------------------ - - 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.OARcorp.com/rtems/license.html. - - ------------------------------------------------------------------------ - - 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 - -/* ---- - 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 rtems_unsigned32 count, - const rtems_unsigned32 max_message_size, - const WaitMode wait_mode = wait_by_fifo, - const Scope scope = local); - - // connects to a message queue - rtemsMessageQueue(const char *name, const rtems_unsigned32 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 rtems_unsigned32 count, - const rtems_unsigned32 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 rtems_unsigned32 node = RTEMS_SEARCH_ALL_NODES); - - // send a message of size from the buffer - inline const rtems_status_code send(const void *buffer, - const rtems_unsigned32 size); - inline const rtems_status_code urgent(const void *buffer, - const rtems_unsigned32 size); - inline const rtems_status_code broadcast(const void *buffer, - const rtems_unsigned32 size, - rtems_unsigned32& count); - - // receive a message of size, the timeout is in micro-secs - inline const rtems_status_code receive(const void *buffer, - rtems_unsigned32& 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(rtems_unsigned32& 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 rtems_unsigned32 size) -{ - return set_status_code(rtems_message_queue_send(id, (void*) buffer, size)); -} - -const rtems_status_code rtemsMessageQueue::urgent(const void *buffer, - const rtems_unsigned32 size) -{ - return set_status_code(rtems_message_queue_urgent(id, (void*) buffer, size)); -} - -const rtems_status_code rtemsMessageQueue::broadcast(const void *buffer, - const rtems_unsigned32 size, - rtems_unsigned32& count) -{ - return set_status_code(rtems_message_queue_broadcast(id, - (void*) buffer, - size, - &count)); -} - -const rtems_status_code rtemsMessageQueue::receive(const void *buffer, - rtems_unsigned32& size, - rtems_interval micro_secs, - bool wait) -{ - rtems_interval usecs = - micro_secs && (micro_secs < _TOD_Microseconds_per_tick) ? - _TOD_Microseconds_per_tick : micro_secs; - return set_status_code(rtems_message_queue_receive(id, - (void*) buffer, - &size, - wait ? RTEMS_WAIT : RTEMS_NO_WAIT, - TOD_MICROSECONDS_TO_TICKS(usecs))); -} - -const rtems_status_code rtemsMessageQueue::flush(rtems_unsigned32& count) -{ - return set_status_code(rtems_message_queue_flush(id, &count)); -} - -#endif // _rtemsMessageQueue_h_ - - - - diff --git a/c/src/lib/include/rtems++/rtemsSemaphore.h b/c/src/lib/include/rtems++/rtemsSemaphore.h deleted file mode 100644 index 9d4fdbeb58..0000000000 --- a/c/src/lib/include/rtems++/rtemsSemaphore.h +++ /dev/null @@ -1,145 +0,0 @@ -/* - ------------------------------------------------------------------------ - $Id$ - ------------------------------------------------------------------------ - - 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.OARcorp.com/rtems/license.html. - - ------------------------------------------------------------------------ - - 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 - -/* ---- - 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 rtems_unsigned32 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 rtems_unsigned32 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 rtems_unsigned32 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, rtems_unsigned32 node); - - // obtain the semaphore, timeout is in micro-seconds - inline const rtems_status_code obtain(bool wait = true, - const rtems_unsigned32 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 rtems_unsigned32 micro_secs) -{ - rtems_interval usecs = - micro_secs && (micro_secs < _TOD_Microseconds_per_tick) ? - _TOD_Microseconds_per_tick : micro_secs; - return - set_status_code(rtems_semaphore_obtain(id, - wait ? RTEMS_WAIT : RTEMS_NO_WAIT, - TOD_MICROSECONDS_TO_TICKS(usecs))); -} - -const rtems_status_code rtemsSemaphore::release(void) -{ - return set_status_code(rtems_semaphore_release(id)); -} - -#endif // _rtemsSemaphore_h_ diff --git a/c/src/lib/include/rtems++/rtemsStatusCode.h b/c/src/lib/include/rtems++/rtemsStatusCode.h deleted file mode 100644 index fee230868b..0000000000 --- a/c/src/lib/include/rtems++/rtemsStatusCode.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - ------------------------------------------------------------------------ - $Id$ - ------------------------------------------------------------------------ - - 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.OARcorp.com/rtems/license.html. - - ------------------------------------------------------------------------ - - rtemsStatusCode controls and manages status codes from the RTEMS kernel. - - ------------------------------------------------------------------------ -*/ - -#if !defined(_rtemsStatusCode_h_) -#define _rtemsStatusCode_h_ - -#include - -/* ---- - 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_ diff --git a/c/src/lib/include/rtems++/rtemsTask.h b/c/src/lib/include/rtems++/rtemsTask.h deleted file mode 100644 index 08156428fb..0000000000 --- a/c/src/lib/include/rtems++/rtemsTask.h +++ /dev/null @@ -1,171 +0,0 @@ -/* - ------------------------------------------------------------------------ - $Id$ - ------------------------------------------------------------------------ - - 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.OARcorp.com/rtems/license.html. - - ------------------------------------------------------------------------ - - 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. - - The rtemsTask class reserved notepad register 31. - - ------------------------------------------------------------------------ */ - -#if !defined(_rtemsTask_h_) -#define _rtemsTask_h_ - -#include - -/* ---- - 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 rtems_unsigned32 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 rtems_unsigned32 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 rtems_unsigned32 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 rtems_unsigned32 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); - - // notepad control - const rtems_status_code get_note(const rtems_unsigned32 notepad, - rtems_unsigned32& note); - const rtems_status_code set_note(const rtems_unsigned32 notepad, - const rtems_unsigned32 note); - - // 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_ - diff --git a/c/src/lib/include/rtems++/rtemsTaskMode.h b/c/src/lib/include/rtems++/rtemsTaskMode.h deleted file mode 100644 index 6d32897cc0..0000000000 --- a/c/src/lib/include/rtems++/rtemsTaskMode.h +++ /dev/null @@ -1,210 +0,0 @@ -/* - ------------------------------------------------------------------------ - $Id$ - ------------------------------------------------------------------------ - - 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.OARcorp.com/rtems/license.html. - - ------------------------------------------------------------------------ - - 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 - -/* ---- - 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 boolean 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 boolean 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 boolean 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 boolean 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, ×lice)); - 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 boolean 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 boolean 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_ - - - - diff --git a/c/src/lib/include/rtems++/rtemsTimer.h b/c/src/lib/include/rtems++/rtemsTimer.h deleted file mode 100644 index 43401bab73..0000000000 --- a/c/src/lib/include/rtems++/rtemsTimer.h +++ /dev/null @@ -1,145 +0,0 @@ -/* - ------------------------------------------------------------------------ - $Id$ - ------------------------------------------------------------------------ - - 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.OARcorp.com/rtems/license.html. - - ------------------------------------------------------------------------ - - 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 - -/* ---- - 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 < _TOD_Microseconds_per_tick) ? - _TOD_Microseconds_per_tick : micro_secs; - return set_status_code(rtems_timer_fire_after(id, - TOD_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 < _TOD_Microseconds_per_tick) ? - _TOD_Microseconds_per_tick : micro_secs; - return set_status_code(rtems_timer_fire_after(id, - TOD_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_ - - - - - - - - -- cgit v1.2.3