diff options
Diffstat (limited to 'cpukit/rtems/include/rtems/rtems')
34 files changed, 6721 insertions, 0 deletions
diff --git a/cpukit/rtems/include/rtems/rtems/asr.h b/cpukit/rtems/include/rtems/rtems/asr.h new file mode 100644 index 0000000000..d733bd0626 --- /dev/null +++ b/cpukit/rtems/include/rtems/rtems/asr.h @@ -0,0 +1,156 @@ +/** + * @file rtems/rtems/asr.h + * + * This include file contains all the constants and structures associated + * with the Asynchronous Signal Handler. This Handler provides the low-level + * support required by the Signal Manager. + */ + +/* 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.com/license/LICENSE. + * + * $Id$ + */ + +#ifndef _RTEMS_RTEMS_ASR_H +#define _RTEMS_RTEMS_ASR_H + +#include <rtems/rtems/modes.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup ClassicASR ASR Support + * + * @ingroup ClassicRTEMS + * + * This encapsulates functionality which XXX + */ +/**@{*/ + +/** + * The following type defines the control block used to manage + * each signal set. + */ +typedef uint32_t rtems_signal_set; + +/** + * Return type for ASR Handler + */ +typedef void rtems_asr; + +/** + * The following type corresponds to the applications asynchronous + * signal processing routine. + */ +typedef rtems_asr ( *rtems_asr_entry )( + rtems_signal_set + ); + +/** + * The following defines the control structure used to manage + * signals. Each thread has a copy of this record. + */ +typedef struct { + /** This field indicates if are ASRs enabled currently. */ + bool is_enabled; + /** This field indicates if address of the signal handler function. */ + rtems_asr_entry handler; + /** This field indicates if the task mode the signal will run with. */ + Modes_Control mode_set; + /** This field indicates the signal set that is posted. */ + rtems_signal_set signals_posted; + /** This field indicates the signal set that is pending. */ + rtems_signal_set signals_pending; + /** This field indicates if nest level of signals being processed */ + uint32_t nest_level; +} ASR_Information; + +/* + * The following constants define the individual signals which may + * be used to compose a signal set. + */ + +/** This defines the bit in the signal set associated with signal 0. */ +#define RTEMS_SIGNAL_0 0x00000001 +/** This defines the bit in the signal set associated with signal 1. */ +#define RTEMS_SIGNAL_1 0x00000002 +/** This defines the bit in the signal set associated with signal 2. */ +#define RTEMS_SIGNAL_2 0x00000004 +/** This defines the bit in the signal set associated with signal 3. */ +#define RTEMS_SIGNAL_3 0x00000008 +/** This defines the bit in the signal set associated with signal 4. */ +#define RTEMS_SIGNAL_4 0x00000010 +/** This defines the bit in the signal set associated with signal 5. */ +#define RTEMS_SIGNAL_5 0x00000020 +/** This defines the bit in the signal set associated with signal 6. */ +#define RTEMS_SIGNAL_6 0x00000040 +/** This defines the bit in the signal set associated with signal 7. */ +#define RTEMS_SIGNAL_7 0x00000080 +/** This defines the bit in the signal set associated with signal 8. */ +#define RTEMS_SIGNAL_8 0x00000100 +/** This defines the bit in the signal set associated with signal 9. */ +#define RTEMS_SIGNAL_9 0x00000200 +/** This defines the bit in the signal set associated with signal 10. */ +#define RTEMS_SIGNAL_10 0x00000400 +/** This defines the bit in the signal set associated with signal 11. */ +#define RTEMS_SIGNAL_11 0x00000800 +/** This defines the bit in the signal set associated with signal 12. */ +#define RTEMS_SIGNAL_12 0x00001000 +/** This defines the bit in the signal set associated with signal 13. */ +#define RTEMS_SIGNAL_13 0x00002000 +/** This defines the bit in the signal set associated with signal 14. */ +#define RTEMS_SIGNAL_14 0x00004000 +/** This defines the bit in the signal set associated with signal 15. */ +#define RTEMS_SIGNAL_15 0x00008000 +/** This defines the bit in the signal set associated with signal 16. */ +#define RTEMS_SIGNAL_16 0x00010000 +/** This defines the bit in the signal set associated with signal 17. */ +#define RTEMS_SIGNAL_17 0x00020000 +/** This defines the bit in the signal set associated with signal 18. */ +#define RTEMS_SIGNAL_18 0x00040000 +/** This defines the bit in the signal set associated with signal 19. */ +#define RTEMS_SIGNAL_19 0x00080000 +/** This defines the bit in the signal set associated with signal 20. */ +#define RTEMS_SIGNAL_20 0x00100000 +/** This defines the bit in the signal set associated with signal 21. */ +#define RTEMS_SIGNAL_21 0x00200000 +/** This defines the bit in the signal set associated with signal 22. */ +#define RTEMS_SIGNAL_22 0x00400000 +/** This defines the bit in the signal set associated with signal 23. */ +#define RTEMS_SIGNAL_23 0x00800000 +/** This defines the bit in the signal set associated with signal 24. */ +#define RTEMS_SIGNAL_24 0x01000000 +/** This defines the bit in the signal set associated with signal 25. */ +#define RTEMS_SIGNAL_25 0x02000000 +/** This defines the bit in the signal set associated with signal 26. */ +#define RTEMS_SIGNAL_26 0x04000000 +/** This defines the bit in the signal set associated with signal 27. */ +#define RTEMS_SIGNAL_27 0x08000000 +/** This defines the bit in the signal set associated with signal 28. */ +#define RTEMS_SIGNAL_28 0x10000000 +/** This defines the bit in the signal set associated with signal 29. */ +#define RTEMS_SIGNAL_29 0x20000000 +/** This defines the bit in the signal set associated with signal 30. */ +#define RTEMS_SIGNAL_30 0x40000000 +/** This defines the bit in the signal set associated with signal 31. */ +#define RTEMS_SIGNAL_31 0x80000000 + +#ifndef __RTEMS_APPLICATION__ +#include <rtems/rtems/asr.inl> +#endif + +#ifdef __cplusplus +} +#endif + +/**@}*/ + +#endif +/* end of include file */ diff --git a/cpukit/rtems/include/rtems/rtems/attr.h b/cpukit/rtems/include/rtems/rtems/attr.h new file mode 100644 index 0000000000..0206ad5cc6 --- /dev/null +++ b/cpukit/rtems/include/rtems/rtems/attr.h @@ -0,0 +1,198 @@ +/** + * @file rtems/rtems/attr.h + * + * This include file contains all information about the Object Attributes + * Handler. + */ + +/* 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.com/license/LICENSE. + * + * $Id$ + */ + +#ifndef _RTEMS_RTEMS_ATTR_H +#define _RTEMS_RTEMS_ATTR_H + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup ClassicAttributes Attributes + * + * @ingroup ClassicRTEMS + * + * This encapsulates functionality which defines and manages the + * set of Classic API object attributes. + */ +/**@{*/ + +/** + * This defines the type used to contain Classic API attributes. These + * are primarily used when creating objects. + */ +typedef uint32_t rtems_attribute; + +/** This is the default value for an attribute set. */ + +#define RTEMS_DEFAULT_ATTRIBUTES 0x00000000 + +/** + * This is the attribute constant to indicate local resource. + */ +#define RTEMS_LOCAL 0x00000000 + +/** + * This is the attribute constant to indicate global resource. + */ +#define RTEMS_GLOBAL 0x00000002 + +/** + * This is the attribute constant which reflects that blocking + * tasks will be managed using FIFO discipline. + */ +#define RTEMS_FIFO 0x00000000 + +/** + * This is the attribute constant which reflects that blocking + * tasks will be managed using task priority discipline. + */ +#define RTEMS_PRIORITY 0x00000004 + +/******************** RTEMS Task Specific Attributes *********************/ + +/** + * This attribute constant indicates that the task will not use the + * floating point hardware. If the architecture permits it, then + * the FPU will be disabled when the task is executing. + */ +#define RTEMS_NO_FLOATING_POINT 0x00000000 + +/** + * This attribute constant indicates that the task will use the + * floating point hardware. There will be a floating point + * context associated with this task. + */ +#define RTEMS_FLOATING_POINT 0x00000001 + +/***************** RTEMS Semaphore Specific Attributes ********************/ + +/** + * This is the mask for the attribute bits associated with the + * Classic API Semaphore Manager. + */ +#define RTEMS_SEMAPHORE_CLASS 0x00000030 + +/** + * This attribute constant indicates that the Classic API Semaphore + * instance created will be a counting semaphore. + */ +#define RTEMS_COUNTING_SEMAPHORE 0x00000000 + +/** + * This attribute constant indicates that the Classic API Semaphore + * instance created will be a proper binary semaphore or mutex. + */ +#define RTEMS_BINARY_SEMAPHORE 0x00000010 + +/** + * This attribute constant indicates that the Classic API Semaphore + * instance created will be a simple binary semaphore. + */ +#define RTEMS_SIMPLE_BINARY_SEMAPHORE 0x00000020 + +/** + * This attribute constant indicates that the Classic API Semaphore + * instance created will NOT use the Priority Inheritance Protocol. + */ +#define RTEMS_NO_INHERIT_PRIORITY 0x00000000 + +/** + * This attribute constant indicates that the Classic API Semaphore + * instance created will use the Priority Inheritance Protocol. + * + * @note The semaphore instance must be a binary semaphore. + */ +#define RTEMS_INHERIT_PRIORITY 0x00000040 + +/** + * This attribute constant indicates that the Classic API Semaphore + * instance created will NOT use the Priority Ceiling Protocol. + */ +#define RTEMS_NO_PRIORITY_CEILING 0x00000000 + +/** + * This attribute constant indicates that the Classic API Semaphore + * instance created will use the Priority Ceiling Protocol. + * + * @note The semaphore instance must be a binary semaphore. + */ +#define RTEMS_PRIORITY_CEILING 0x00000080 + +/******************** RTEMS Barrier Specific Attributes ********************/ + +/** + * This attribute constant indicates that the Classic API Barrier + * instance created will use an automatic release protocol. + */ +#define RTEMS_BARRIER_AUTOMATIC_RELEASE 0x00000010 + +/** + * This attribute constant indicates that the Classic API Barrier + * instance created will use the manual release protocol. + */ +#define RTEMS_BARRIER_MANUAL_RELEASE 0x00000000 + +/**************** RTEMS Internal Task Specific Attributes ****************/ + +/** + * This attribute constant indicates that the task was created + * by the application using normal Classic API methods. + */ +#define RTEMS_APPLICATION_TASK 0x00000000 + +/** + * This attribute constant indicates that the task was created + * by RTEMS as a support task. + */ +#define RTEMS_SYSTEM_TASK 0x00008000 + +/****************** Forced Attributes in Configuration ****************/ + +/** + * This attribute constant indicates the attributes that are not + * supportable given the hardware configuration. + */ +#if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE ) +#define ATTRIBUTES_NOT_SUPPORTED 0 +#else +#define ATTRIBUTES_NOT_SUPPORTED RTEMS_FLOATING_POINT +#endif + +/** + * This attribute constant indicates the attributes that are + * required given the hardware configuration. + */ +#if ( CPU_ALL_TASKS_ARE_FP == TRUE ) +#define ATTRIBUTES_REQUIRED RTEMS_FLOATING_POINT +#else +#define ATTRIBUTES_REQUIRED 0 +#endif + +#ifndef __RTEMS_APPLICATION__ +#include <rtems/rtems/attr.inl> +#endif + +#ifdef __cplusplus +} +#endif + +/**@}*/ + +#endif +/* end of include file */ diff --git a/cpukit/rtems/include/rtems/rtems/barrier.h b/cpukit/rtems/include/rtems/rtems/barrier.h new file mode 100644 index 0000000000..566d0299e5 --- /dev/null +++ b/cpukit/rtems/include/rtems/rtems/barrier.h @@ -0,0 +1,205 @@ +/** + * @file rtems/rtems/barrier.h + * + * This include file contains all the constants and structures associated + * with the Barrier Manager. + * + * Directives provided are: + * + * - create a barrier + * - get an ID of a barrier + * - delete a barrier + * - wait for a barrier + * - signal a barrier + */ + +/* 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.com/license/LICENSE. + * + * $Id$ + */ + +#ifndef _RTEMS_RTEMS_BARRIER_H +#define _RTEMS_RTEMS_BARRIER_H + +/** + * @defgroup ClassicBarrier Barriers + * + * @ingroup ClassicRTEMS + * + * This encapsulates functionality which XXX + */ +/**@{*/ + +/** + * This constant is defined to extern most of the time when using + * this header file. However by defining it to nothing, the data + * declared in this header file can be instantiated. This is done + * in a single per manager file. + */ +#ifndef RTEMS_BARRIER_EXTERN +#define RTEMS_BARRIER_EXTERN extern +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#include <rtems/rtems/types.h> +#include <rtems/rtems/support.h> +#include <rtems/rtems/attr.h> +#include <rtems/rtems/status.h> +#include <rtems/score/object.h> +#include <rtems/score/corebarrier.h> + +/** + * This type defines the control block used to manage each barrier. + */ +typedef struct { + /** This is used to manage a barrier as an object. */ + Objects_Control Object; + /** This is used to specify the attributes of a barrier. */ + rtems_attribute attribute_set; + /** This is used to implement the barrier. */ + CORE_barrier_Control Barrier; +} Barrier_Control; + +/** + * The following defines the information control block used to manage + * this class of objects. + */ +RTEMS_BARRIER_EXTERN Objects_Information _Barrier_Information; + +/** + * @brief _Barrier_Manager_initialization + * + * This routine performs the initialization necessary for this manager. + */ +void _Barrier_Manager_initialization(void); + +/** + * @brief rtems_barrier_create + * + * This routine implements the rtems_barrier_create directive. The + * barrier will have the name name. The starting count for + * the barrier is count. The attribute_set determines if + * the barrier is global or local and the thread queue + * discipline. It returns the id of the created barrier in ID. + * + * @param[in] name is the name of this barrier instance. + * @param[in] attribute_set specifies the attributes of this barrier instance. + * @param[in] maximum_waiters is the maximum number of threads which will + * be allowed to concurrently wait at the barrier. + * @param[out] id will contain the id of this barrier. + * + * @return a status code indicating success or the reason for failure. + */ +rtems_status_code rtems_barrier_create( + rtems_name name, + rtems_attribute attribute_set, + uint32_t maximum_waiters, + rtems_id *id +); + +/** + * @brief rtems_barrier_ident + * + * This routine implements the rtems_barrier_ident directive. + * This directive returns the barrier ID associated with name. + * If more than one barrier is named name, then the barrier + * to which the ID belongs is arbitrary. node indicates the + * extent of the search for the ID of the barrier named name. + * The search can be limited to a particular node or allowed to + * encompass all nodes. + * + * @param[in] name is the name of this barrier instance. + * @param[out] id will contain the id of this barrier. + * + * @return a status code indicating success or the reason for failure. + */ +rtems_status_code rtems_barrier_ident( + rtems_name name, + rtems_id *id +); + +/** + * @brief rtems_barrier_delete + * + * This routine implements the rtems_barrier_delete directive. The + * barrier indicated by @a id is deleted. + * + * @param[in] id indicates the barrier to delete + * + * @return a status code indicating success or the reason for failure. + */ +rtems_status_code rtems_barrier_delete( + rtems_id id +); + +/** + * @brief rtems_barrier_wait + * + * This routine implements the rtems_barrier_wait directive. It + * attempts to wait at the barrier associated with @a id. The calling task + * may block waiting for the barrier with an optional timeout of @a timeout + * clock ticks. + * + * @param[in] id indicates the barrier to wait at. + * @param[in] timeout is the maximum length of time in ticks the calling + * thread is willing to block. + * + * @return a status code indicating success or the reason for failure. + */ +rtems_status_code rtems_barrier_wait( + rtems_id id, + rtems_interval timeout +); + +/** + * @brief rtems_barrier_release + * + * This routine implements the rtems_barrier_release directive. It + * unblocks all of the threads waiting on the barrier associated with + * @a id. The number of threads unblocked is returned in @a released. + * + * + * @param[in] id indicates the barrier to wait at. + * @param[out] released will contain the number of threads unblocked. + * + * @return a status code indicating success or the reason for failure. + */ +rtems_status_code rtems_barrier_release( + rtems_id id, + uint32_t *released +); + +/** + * @brief Translate SuperCore Barrier Status Code to RTEMS Status Code + * + * This function returns a RTEMS status code based on the barrier + * status code specified. + * + * @param[in] the_status is the SuperCore Barrier status to translate. + * + * @return a status code indicating success or the reason for failure. + */ +rtems_status_code _Barrier_Translate_core_barrier_return_code ( + CORE_barrier_Status the_status +); + +#ifndef __RTEMS_APPLICATION__ +#include <rtems/rtems/barrier.inl> +#endif + +#ifdef __cplusplus +} +#endif + +/**@}*/ + +#endif +/* end of include file */ diff --git a/cpukit/rtems/include/rtems/rtems/barriermp.h b/cpukit/rtems/include/rtems/rtems/barriermp.h new file mode 100644 index 0000000000..1a20680665 --- /dev/null +++ b/cpukit/rtems/include/rtems/rtems/barriermp.h @@ -0,0 +1,151 @@ +/** + * @file rtems/rtems/barriermp.h + * + * This include file contains all the constants and structures associated + * with the Multiprocessing Support in the Barrier Manager. + */ + +/* 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.com/license/LICENSE. + * + * $Id$ + */ + +#ifndef _RTEMS_RTEMS_SEMMP_H +#define _RTEMS_RTEMS_SEMMP_H + +/** + * @defgroup ClassicBarrierMP Barrier MP Support + * + * @ingroup ClassicMP + * + * This encapsulates functionality which XXX + */ +/**{*/ + +#ifdef __cplusplus +extern "C" { +#endif + +#include <rtems/score/mppkt.h> +#include <rtems/score/object.h> +#include <rtems/rtems/options.h> +#include <rtems/rtems/barrier.h> +#include <rtems/score/thread.h> +#include <rtems/score/watchdog.h> + +/** + * The following enumerated type defines the list of + * remote barrier operations. + */ +typedef enum { + BARRIER_MP_ANNOUNCE_CREATE = 0, + BARRIER_MP_ANNOUNCE_DELETE = 1, + BARRIER_MP_EXTRACT_PROXY = 2, + BARRIER_MP_WAIT_REQUEST = 3, + BARRIER_MP_WAIT_RESPONSE = 4, + BARRIER_MP_RELEASE_REQUEST = 5, + BARRIER_MP_RELEASE_RESPONSE = 6 +} Barrier_MP_Remote_operations; + +/** + * The following data structure defines the packet used to perform + * remote barrier operations. + */ +typedef struct { + rtems_packet_prefix Prefix; + Barrier_MP_Remote_operations operation; + rtems_name name; + rtems_option option_set; + Objects_Id proxy_id; +} Barrier_MP_Packet; + +/** + * @brief _Barrier_MP_Send_process_packet + * + * This routine performs a remote procedure call so that a + * process operation can be performed on another node. + */ +void _Barrier_MP_Send_process_packet ( + Barrier_MP_Remote_operations operation, + Objects_Id barrier_id, + rtems_name name, + Objects_Id proxy_id +); + +/** + * @brief _Barrier_MP_Send_request_packet + * + * This routine performs a remote procedure call so that a + * directive operation can be initiated on another node. + */ +rtems_status_code _Barrier_MP_Send_request_packet ( + Barrier_MP_Remote_operations operation, + Objects_Id barrier_id, + rtems_interval timeout +); + +/** + * @brief _Barrier_MP_Send_response_packet + * + * This routine performs a remote procedure call so that a + * directive can be performed on another node. + */ + +void _Barrier_MP_Send_response_packet ( + Barrier_MP_Remote_operations operation, + Objects_Id barrier_id, + Thread_Control *the_thread +); + +/** + * @brief _Barrier_MP_Process_packet + * + * This routine performs the actions specific to this package for + * the request from another node. + */ +void _Barrier_MP_Process_packet ( + rtems_packet_prefix *the_packet_prefix +); + +/** + * @brief _Barrier_MP_Send_object_was_deleted + * + * This routine is invoked indirectly by the thread queue + * when a proxy has been removed from the thread queue and + * the remote node must be informed of this. + */ +void _Barrier_MP_Send_object_was_deleted ( + Thread_Control *the_proxy +); + +/** + * @brief _Barrier_MP_Send_extract_proxy + * + * This routine is invoked when a task is deleted and it + * has a proxy which must be removed from a thread queue and + * the remote node must be informed of this. + */ +void _Barrier_MP_Send_extract_proxy ( + void *argument +); + +/** + * @brief _Barrier_MP_Get_packet + * + * This function is used to obtain a barrier mp packet. + */ +Barrier_MP_Packet *_Barrier_MP_Get_packet ( void ); + +#ifdef __cplusplus +} +#endif + +/**@}*/ + +#endif +/* end of file */ diff --git a/cpukit/rtems/include/rtems/rtems/cache.h b/cpukit/rtems/include/rtems/rtems/cache.h new file mode 100644 index 0000000000..72aab56cea --- /dev/null +++ b/cpukit/rtems/include/rtems/rtems/cache.h @@ -0,0 +1,158 @@ +/** + * @file rtems/rtems/cache.h + * + * Cache Manager + */ + +/* 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.com/license/LICENSE. + * + * + * The functions in this file define the API to the RTEMS Cache Manager and + * are divided into data cache and instruction cache functions. Data cache + * functions are only meaningful if a data cache is supported. Instruction + * cache functions are only meaningful if an instruction cache is supported. + * + * The functions below are implemented with CPU dependent support routines + * implemented as part of libcpu. In the event that a CPU does not support a + * specific function, the CPU dependent routine does nothing (but does exist). + * + * At this point, the Cache Manager makes no considerations, and provides no + * support for BSP specific issues such as a secondary cache. In such a system, + * the CPU dependent routines would have to be modified, or a BSP layer added + * to this Manager. + */ + +#ifndef _RTEMS_RTEMS_CACHE_H +#define _RTEMS_RTEMS_CACHE_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include <rtems/system.h> +#include <sys/types.h> + +/** + * @defgroup ClassicCache Cache + * + * @ingroup ClassicRTEMS + * + * This encapsulates functionality which XXX + */ +/**@{*/ + +/* + * These functions will ONLY do something if the + * libcpu support includes data cache routines AND + * the CPU model supports data caching. + */ + +/** + * This function is called to flush the data cache by performing cache + * copybacks. It must determine how many cache lines need to be copied + * back and then perform the copybacks. + */ +void rtems_cache_flush_multiple_data_lines( const void *, size_t ); + +/** + * This function is responsible for performing a data cache invalidate. + * It must determine how many cache lines need to be invalidated and then + * perform the invalidations. + */ +void rtems_cache_invalidate_multiple_data_lines( const void *, size_t ); + +/** + * This function is responsible for performing a data cache flush. + * It flushes the entire cache. + */ +void rtems_cache_flush_entire_data( void ); + +/** + * This function is responsible for performing a data cache + * invalidate. It invalidates the entire cache. + */ +void rtems_cache_invalidate_entire_data( void ); + +/** + * This function returns the data cache granularity. + */ +int rtems_cache_get_data_line_size( void ); + +/** + * This function freezes the data cache. + */ +void rtems_cache_freeze_data( void ); + +/** + * This function unfreezes the data cache. + */ +void rtems_cache_unfreeze_data( void ); + +/** + * This function enables the data cache. + */ +void rtems_cache_enable_data( void ); + +/** + * This function disables the data cache. + */ +void rtems_cache_disable_data( void ); + +/** + * These functions will ONLY do something if the + * libcpu support includes instruction cache routines AND + * the CPU model supports instruction caching. + */ + +/** + * This function is responsible for performing an instruction cache + * invalidate. It must determine how many cache lines need to be invalidated + * and then perform the invalidations. + */ +void rtems_cache_invalidate_multiple_instruction_lines( const void *, size_t ); + +/** + * This function is responsible for performing an instruction cache + * invalidate. It invalidates the entire cache. + */ +void rtems_cache_invalidate_entire_instruction( void ); + +/** + * This function returns the instruction cache granularity. + */ +int rtems_cache_get_instruction_line_size( void ); + +/** + * This function freezes the instruction cache. + */ +void rtems_cache_freeze_instruction( void ); + +/** + * This function unfreezes the instruction cache. + */ +void rtems_cache_unfreeze_instruction( void ); + +/** + * This function enables the instruction cache. + */ +void rtems_cache_enable_instruction( void ); + +/** + * This function disables the instruction cache. + */ +void rtems_cache_disable_instruction( void ); + + +#ifdef __cplusplus +} +#endif + +/**@}*/ + +#endif +/* end of include file */ diff --git a/cpukit/rtems/include/rtems/rtems/clock.h b/cpukit/rtems/include/rtems/rtems/clock.h new file mode 100644 index 0000000000..7e2d776fe6 --- /dev/null +++ b/cpukit/rtems/include/rtems/rtems/clock.h @@ -0,0 +1,267 @@ +/** + * @file rtems/rtems/clock.h + * + * This include file contains all the constants and structures associated + * with the Clock Manager. This manager provides facilities to set, obtain, + * and continually update the current date and time. + * + * This manager provides directives to: + * + * - set the current date and time + * - obtain the current date and time + * - set the nanoseconds since last clock tick handler + * - announce a clock tick + * - obtain the system uptime + */ + +/* 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.com/license/LICENSE. + * + * $Id$ + */ + +#ifndef _RTEMS_RTEMS_CLOCK_H +#define _RTEMS_RTEMS_CLOCK_H + +#include <rtems/score/tod.h> +#include <rtems/score/watchdog.h> +#include <rtems/rtems/status.h> +#include <rtems/rtems/types.h> + +#include <sys/time.h> /* struct timeval */ + +/** + * @defgroup ClassicClock Clocks + * + * @ingroup ClassicRTEMS + * + * This encapsulates functionality which XXX + */ +/**@{*/ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * List of things which can be returned by the rtems_clock_get directive. + */ +typedef enum { + /** This value indicates obtain TOD in Classic API format. */ + RTEMS_CLOCK_GET_TOD, + /** This value indicates obtain the number of seconds since the epoch. */ + RTEMS_CLOCK_GET_SECONDS_SINCE_EPOCH, + /** This value indicates obtain the number of ticks since system boot. */ + RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, + /** This value indicates obtain the number of ticks per second. */ + RTEMS_CLOCK_GET_TICKS_PER_SECOND, + /** This value indicates obtain the TOD in struct timeval format. */ + RTEMS_CLOCK_GET_TIME_VALUE +} rtems_clock_get_options; + +/** + * Type for the nanoseconds since last tick BSP extension. + */ +typedef Watchdog_Nanoseconds_since_last_tick_routine + rtems_nanoseconds_extension_routine; + +/** + * @brief Obtain Current Time of Day + * + * This routine implements the rtems_clock_get directive. It returns + * one of the following: + * + current time of day + * + seconds since epoch + * + ticks since boot + * + ticks per second + * + * @param[in] option is the format of time to return + * @param[in] time_buffer points to the output area + * + * @return This method returns RTEMS_SUCCESSFUL if there was not an + * error. Otherwise, a status code is returned indicating the + * source of the error. + */ +rtems_status_code rtems_clock_get( + rtems_clock_get_options option, + void *time_buffer +); + +/** + * @brief Obtain Current Time of Day (Classic TOD) + * + * This routine implements the rtems_clock_get_tod directive. It returns + * the current time of day in the format defined by RTEID. + * + * @param[in] time_buffer points to the time of day structure + * + * @return This method returns RTEMS_SUCCESSFUL if there was not an + * error. Otherwise, a status code is returned indicating the + * source of the error. If successful, the time_buffer will + * be filled in with the current time of day. + */ +rtems_status_code rtems_clock_get_tod( + rtems_time_of_day *time_buffer +); + +/** + * @brief Obtain TOD in struct timeval Format + * + * This routine implements the rtems_clock_get_tod_timeval + * directive. + * + * @param[in] time points to the struct timeval variable to fill in + * + * @return This method returns RTEMS_SUCCESSFUL if there was not an + * error. Otherwise, a status code is returned indicating the + * source of the error. If successful, the time will + * be filled in with the current time of day. + */ +rtems_status_code rtems_clock_get_tod_timeval( + struct timeval *time +); + +/** + * @brief Obtain Seconds Since Epoch + * + * This routine implements the rtems_clock_get_seconds_since_epoch + * directive. + * + * @param[in] the_interval points to the interval variable to fill in + * + * @return This method returns RTEMS_SUCCESSFUL if there was not an + * error. Otherwise, a status code is returned indicating the + * source of the error. If successful, the time_buffer will + * be filled in with the current time of day. + */ +rtems_status_code rtems_clock_get_seconds_since_epoch( + rtems_interval *the_interval +); + +/** + * @brief Obtain Ticks Since Boot + * + * This routine implements the rtems_clock_get_ticks_since_boot + * directive. + * + * @return This method returns the number of ticks since boot. It cannot + * fail since RTEMS always keeps a running count of ticks since boot. + */ +rtems_interval rtems_clock_get_ticks_since_boot(void); + +/** + * @brief Obtain Ticks Per Seconds + * + * This routine implements the rtems_clock_get_ticks_per_second + * directive. + * + * @return This method returns the number of ticks since boot. It cannot + * fail since RTEMS is always configured to know the number of + * ticks per second. + */ +rtems_interval rtems_clock_get_ticks_per_second(void); + +/** + * @brief Set the Current TOD + * + * This routine implements the rtems_clock_set directive. It sets + * the current time of day to that in the time_buffer record. + * + * @param[in] time_buffer points to the new TOD + * + * @return This method returns RTEMS_SUCCESSFUL if there was not an + * error. Otherwise, a status code is returned indicating the + * source of the error. + * + * @note Activities scheduled based upon the current time of day + * may be executed immediately if the time is moved forward. + */ +rtems_status_code rtems_clock_set( + rtems_time_of_day *time_buffer +); + +/** + * @brief Announce a Clock Tick + * + * This routine implements the rtems_clock_tick directive. It is invoked + * to inform RTEMS of the occurrence of a clock tick. + * + * @return This directive always returns RTEMS_SUCCESSFUL. + * + * @note This method is typically called from an ISR and is the basis + * for all timeouts and delays. + */ +rtems_status_code rtems_clock_tick( void ); + +/** + * @brief Set the BSP specific Nanoseconds Extension + * + * This directive sets the BSP provided nanoseconds since last tick + * extension. + * + * @param[in] routine is a pointer to the extension routine + * + * @return This method returns RTEMS_SUCCESSFUL if there was not an + * error. Otherwise, a status code is returned indicating the + * source of the error. + */ +rtems_status_code rtems_clock_set_nanoseconds_extension( + rtems_nanoseconds_extension_routine routine +); + +/** + * @brief Obtain the System Uptime + * + * This directive returns the system uptime. + * + * @param[in] uptime is a pointer to the time structure + * + * @return This method returns RTEMS_SUCCESSFUL if there was not an + * error. Otherwise, a status code is returned indicating the + * source of the error. If successful, the uptime will be + * filled in. + */ +rtems_status_code rtems_clock_get_uptime( + struct timespec *uptime +); + +/** + * @brief _TOD_Validate + * + * This support function returns true if @a the_tod contains + * a valid time of day, and false otherwise. + * + * @param[in] the_tod is the TOD structure to validate + * + * @return This method returns true if the TOD is valid and false otherwise. + */ +bool _TOD_Validate( + const rtems_time_of_day *the_tod +); + +/** + * @brief _TOD_To_seconds + * + * This function returns the number seconds between the epoch and @a the_tod. + * + * @param[in] the_tod is the TOD structure to convert to seconds + * + * @return This method returns the number of seconds since epoch represented + * by @a the_tod + */ +Watchdog_Interval _TOD_To_seconds( + const rtems_time_of_day *the_tod +); + +#ifdef __cplusplus +} +#endif + +/**@}*/ + +#endif +/* end of include file */ diff --git a/cpukit/rtems/include/rtems/rtems/config.h b/cpukit/rtems/include/rtems/rtems/config.h new file mode 100644 index 0000000000..2217463d5a --- /dev/null +++ b/cpukit/rtems/include/rtems/rtems/config.h @@ -0,0 +1,151 @@ +/** + * @file rtems/rtems/config.h + * + * This include file contains the table of user defined configuration + * parameters specific for the RTEMS API. + */ + +/* 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.com/license/LICENSE. + * + * $Id$ + */ + +#ifndef _RTEMS_RTEMS_CONFIG_H +#define _RTEMS_RTEMS_CONFIG_H + +#include <rtems/rtems/types.h> +#include <rtems/rtems/tasks.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup ClassicConfig Configuration + * + * @ingroup ClassicRTEMS + * + * This encapsulates functionality which XXX + */ +/**@{*/ + +/** + * The following records define the Configuration Table. The + * information contained in this table is required in all + * RTEMS systems, whether single or multiprocessor. This + * table primarily defines the following: + * + * + required number of each object type + */ +typedef struct { + /** + * This field contains the maximum number of Classic API + * Tasks which are configured for this application. + */ + uint32_t maximum_tasks; + + /** + * This field indicates whether Classic API notepads are + * enabled or disabled. + */ + bool notepads_enabled; + + /** + * This field contains the maximum number of Classic API + * Timers which are configured for this application. + */ + uint32_t maximum_timers; + + /** + * This field contains the maximum number of Classic API + * Semaphores which are configured for this application. + */ + uint32_t maximum_semaphores; + + /** + * This field contains the maximum number of Classic API + * Message Queues which are configured for this application. + */ + uint32_t maximum_message_queues; + + /** + * This field contains the maximum number of Classic API + * Partitions which are configured for this application. + */ + uint32_t maximum_partitions; + + /** + * This field contains the maximum number of Classic API + * Regions which are configured for this application. + */ + uint32_t maximum_regions; + + /** + * This field contains the maximum number of Classic API + * Dual Ported Memory Areas which are configured for this + * application. + */ + uint32_t maximum_ports; + + /** + * This field contains the maximum number of Classic API + * Rate Monotonic Periods which are configured for this + * application. + */ + uint32_t maximum_periods; + + /** + * This field contains the maximum number of Classic API + * Barriers which are configured for this application. + */ + uint32_t maximum_barriers; + + /** + * This field contains the number of Classic API Initialization + * Tasks which are configured for this application. + */ + uint32_t number_of_initialization_tasks; + + /** + * This field is the set of Classic API Initialization + * Tasks which are configured for this application. + */ + rtems_initialization_tasks_table *User_initialization_tasks_table; +} rtems_api_configuration_table; + +/** + * @brief RTEMS API Configuration Table + * + * This is the RTEMS API Configuration Table expected to be generated + * by confdefs.h. + */ +extern rtems_api_configuration_table Configuration_RTEMS_API; + +/**@}*/ + +/** + * This macro returns the value of the notepads enabled field + * in the Classic API configuration table. + */ +#define rtems_configuration_get_notepads_enabled() \ + rtems_configuration_get_rtems_api_configuration()->notepads_enabled + +/** + * This macro returns the number of Classic API semaphores configured. + */ +#define rtems_configuration_get_maximum_semaphores() \ + rtems_configuration_get_rtems_api_configuration()->maximum_semaphores + +#ifdef __cplusplus +} +#endif + +/**@}*/ + +#endif +/* end of include file */ diff --git a/cpukit/rtems/include/rtems/rtems/dpmem.h b/cpukit/rtems/include/rtems/rtems/dpmem.h new file mode 100644 index 0000000000..86885143b5 --- /dev/null +++ b/cpukit/rtems/include/rtems/rtems/dpmem.h @@ -0,0 +1,164 @@ +/** + * @file rtems/rtems/dpmem.h + * + * This include file contains all the constants and structures associated + * with the Dual Ported Memory Manager. This manager provides a mechanism + * for converting addresses between internal and external representations + * for multiple dual-ported memory areas. + * + * Directives provided are: + * + * - create a port + * - get ID of a port + * - delete a port + * - convert external to internal address + * - convert internal to external address + * + */ + +/* 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.com/license/LICENSE. + * + * $Id$ + */ + +#ifndef _RTEMS_RTEMS_DPMEM_H +#define _RTEMS_RTEMS_DPMEM_H + +/** + * This constant is defined to extern most of the time when using + * this header file. However by defining it to nothing, the data + * declared in this header file can be instantiated. This is done + * in a single per manager file. + */ +#ifndef RTEMS_DPMEM_EXTERN +#define RTEMS_DPMEM_EXTERN extern +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#include <rtems/score/object.h> +#include <rtems/rtems/support.h> +#include <rtems/rtems/status.h> + +/** + * @defgroup ClassicDPMEM Dual Ported Memory + * + * @ingroup ClassicRTEMS + * + * This encapsulates functionality related to the + * Classic API Dual Ported Memory Manager. + */ +/**@{*/ + +/** + * The following structure defines the port control block. Each port + * has a control block associated with it. This control block contains + * all information required to support the port related operations. + */ +typedef struct { + /** This field is the object management portion of a Port instance. */ + Objects_Control Object; + /** This field is the base internal address of the port. */ + void *internal_base; + /** This field is the base external address of the port. */ + void *external_base; + /** This field is the length of dual-ported area of the port. */ + uint32_t length; +} Dual_ported_memory_Control; + +/** + * The following define the internal Dual Ported Memory information. + */ +RTEMS_DPMEM_EXTERN Objects_Information _Dual_ported_memory_Information; + +/** + * @brief _Dual_ported_memory_Manager_initialization + * + * This routine performs the initialization necessary for this manager. + */ +void _Dual_ported_memory_Manager_initialization(void); + +/** + * @brief rtems_port_create + * + * This routine implements the rtems_port_create directive. The port + * will have the name name. The port maps onto an area of dual ported + * memory of length bytes which has internal_start and external_start + * as the internal and external starting addresses, respectively. + * It returns the id of the created port in ID. + */ +rtems_status_code rtems_port_create( + rtems_name name, + void *internal_start, + void *external_start, + uint32_t length, + rtems_id *id +); + +/** + * @brief rtems_port_ident + * + * This routine implements the rtems_port_ident directive. This directive + * returns the port ID associated with name. If more than one port is + * named name, then the port to which the ID belongs is arbitrary. + */ +rtems_status_code rtems_port_ident( + rtems_name name, + rtems_id *id +); + +/** + * @brief rtems_port_delete + * + * This routine implements the rtems_port_delete directive. It deletes + * the port associated with ID. + */ +rtems_status_code rtems_port_delete( + rtems_id id +); + +/** + * @brief rtems_port_external_to_internal + * + * This routine implements the rtems_port_external_to_internal directive. + * It returns the internal port address which maps to the provided + * external port address for the specified port ID. + */ +rtems_status_code rtems_port_external_to_internal( + rtems_id id, + void *external, + void **internal +); + +/** + * @brief rtems_port_internal_to_external + * + * This routine implements the Port_internal_to_external directive. + * It returns the external port address which maps to the provided + * internal port address for the specified port ID. + */ +rtems_status_code rtems_port_internal_to_external( + rtems_id id, + void *internal, + void **external +); + +#ifndef __RTEMS_APPLICATION__ +#include <rtems/rtems/dpmem.inl> +#endif + +#ifdef __cplusplus +} +#endif + +/**@}*/ + +#endif +/* end of include file */ diff --git a/cpukit/rtems/include/rtems/rtems/event.h b/cpukit/rtems/include/rtems/rtems/event.h new file mode 100644 index 0000000000..05f66d64cd --- /dev/null +++ b/cpukit/rtems/include/rtems/rtems/event.h @@ -0,0 +1,166 @@ +/** + * @file rtems/rtems/event.h + * + * This include file contains the information pertaining to the Event + * Manager. This manager provides a high performance method of communication + * and synchronization. + * + * Directives provided are: + * + * - send an event set to a task + * - receive event condition + * + */ + +/* 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.com/license/LICENSE. + * + * $Id$ + */ + +#ifndef _RTEMS_RTEMS_EVENT_H +#define _RTEMS_RTEMS_EVENT_H + +/** + * This constant is defined to extern most of the time when using + * this header file. However by defining it to nothing, the data + * declared in this header file can be instantiated. This is done + * in a single per manager file. + */ +#ifndef RTEMS_EVENT_EXTERN +#define RTEMS_EVENT_EXTERN extern +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#include <rtems/score/object.h> +#include <rtems/rtems/status.h> +#include <rtems/rtems/types.h> +#include <rtems/rtems/options.h> +#include <rtems/score/thread.h> +#include <rtems/score/threadsync.h> +#include <rtems/score/watchdog.h> +#include <rtems/rtems/eventset.h> + +/** + * @defgroup ClassicEvent Events + * + * @ingroup ClassicRTEMS + * + * This encapsulates functionality which XXX + */ +/**@{*/ + +/** + * This constant is passed as the event_in to the + * rtems_event_receive directive to determine which events are pending. + */ +#define EVENT_CURRENT 0 + +/** + * @brief Event_Manager_initialization + * + * This routine performs the initialization necessary for this manager. + */ +void _Event_Manager_initialization( void ); + +/** + * @brief rtems_event_send + * + * This routine implements the rtems_event_send directive. It sends + * event_in to the task specified by ID. If the task is blocked + * waiting to receive events and the posting of event_in satisfies + * the task's event condition, then it is unblocked. + */ +rtems_status_code rtems_event_send ( + rtems_id id, + rtems_event_set event_in +); + +/** + * @brief rtems_event_receive + * + * This routine implements the rtems_event_receive directive. This + * directive is invoked when the calling task wishes to receive + * the event_in event condition. One of the fields in the option_set + * parameter determines whether the receive request is satisfied if + * any or all of the events are pending. If the event condition + * is not satisfied immediately, then the task may block with an + * optional timeout of TICKS clock ticks or return immediately. + * This determination is based on another field in the option_set + * parameter. This directive returns the events received in the + * event_out parameter. + */ +rtems_status_code rtems_event_receive ( + rtems_event_set event_in, + rtems_option option_set, + rtems_interval ticks, + rtems_event_set *event_out +); + +/** + * @brief Event_Seize + * + * This routine determines if the event condition event_in is + * satisfied. If so or if the no_wait option is enabled in option_set, + * then the procedure returns immediately. If neither of these + * conditions is true, then the calling task is blocked with an + * optional timeout of ticks clock ticks. + */ +void _Event_Seize ( + rtems_event_set event_in, + rtems_option option_set, + rtems_interval ticks, + rtems_event_set *event_out +); + +/** + * @brief Event_Surrender + * + * This routine determines if the event condition of the_thread + * has been satisfied. If so, it unblocks the_thread. + */ +void _Event_Surrender ( + Thread_Control *the_thread +); + +/** + * @brief Event_Timeout + * + * This routine is invoked when a task's event receive request + * has not been satisfied after the specified timeout interval. + * The task represented by ID will be unblocked and its status + * code will be set in it's control block to indicate that a timeout + * has occurred. + */ +void _Event_Timeout ( + Objects_Id id, + void *ignored +); + +/** + * @brief he following defines the synchronization flag used by the + */ +RTEMS_EVENT_EXTERN volatile Thread_blocking_operation_States _Event_Sync_state; + +#if defined(RTEMS_MULTIPROCESSING) +#include <rtems/rtems/eventmp.h> +#endif +#ifndef __RTEMS_APPLICATION__ +#include <rtems/rtems/event.inl> +#endif + +#ifdef __cplusplus +} +#endif + +/**@}*/ + +#endif +/* end of include file */ diff --git a/cpukit/rtems/include/rtems/rtems/eventmp.h b/cpukit/rtems/include/rtems/rtems/eventmp.h new file mode 100644 index 0000000000..bc44fe6aab --- /dev/null +++ b/cpukit/rtems/include/rtems/rtems/eventmp.h @@ -0,0 +1,138 @@ +/** + * @file rtems/rtems/eventmp.h + * + * This include file contains all the constants and structures associated + * with the Multiprocessing Support in the Event Manager. + */ + +/* 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.com/license/LICENSE. + * + * $Id$ + */ + +#ifndef _RTEMS_RTEMS_EVENTMP_H +#define _RTEMS_RTEMS_EVENTMP_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include <rtems/rtems/event.h> +#include <rtems/score/mppkt.h> +#include <rtems/score/object.h> +#include <rtems/score/thread.h> +#include <rtems/score/watchdog.h> + +/** + * @defgroup ClassicEventMP Event MP Support + * + * @ingroup ClassicMP + * + * This encapsulates functionality which XXX + */ +/**@{*/ + +/** + * The following enumerated type defines the list of + * remote event operations. + */ +typedef enum { + EVENT_MP_SEND_REQUEST = 0, + EVENT_MP_SEND_RESPONSE = 1 +} Event_MP_Remote_operations; + +/** + * The following data structure defines the packet used to perform + * remote event operations. + */ +typedef struct { + rtems_packet_prefix Prefix; + Event_MP_Remote_operations operation; + rtems_event_set event_in; +} Event_MP_Packet; + +/* + * @brief Event_MP_Send_process_packet + * + * This routine performs a remote procedure call so that a + * process operation can be performed on another node. + * + * @note This routine is not needed since there are no process + * packets to be sent by this manager. + */ + +/** + * @brief Event_MP_Send_request_packet + * + * This routine performs a remote procedure call so that a + * directive operation can be initiated on another node. + */ +rtems_status_code _Event_MP_Send_request_packet ( + Event_MP_Remote_operations operation, + Objects_Id event_id, + rtems_event_set event_in +); + +/** + * @brief Event_MP_Send_response_packet + * + * This routine performs a remote procedure call so that a + * directive can be performed on another node. + */ +void _Event_MP_Send_response_packet ( + Event_MP_Remote_operations operation, + Thread_Control *the_thread +); + +/** + * @brief Event_MP_Process_packet + * + * This routine performs the actions specific to this package for + * the request from another node. + */ +void _Event_MP_Process_packet ( + rtems_packet_prefix *the_packet_prefix +); + +/* + * @brief Event_MP_Send_object_was_deleted + * + * This routine is invoked indirectly by the thread queue + * when a proxy has been removed from the thread queue and + * the remote node must be informed of this. + * + * This routine is not needed since there are no objects + * deleted by this manager. + */ + +/* + * @brief Event_MP_Send_extract_proxy + * + * This routine is invoked when a task is deleted and it + * has a proxy which must be removed from a thread queue and + * the remote node must be informed of this. + * + * This routine is not needed since there are no objects + * deleted by this manager. + */ + +/** + * @brief Event_MP_Get_packet + * + * This function is used to obtain a event mp packet. + */ +Event_MP_Packet *_Event_MP_Get_packet ( void ); + +#ifdef __cplusplus +} +#endif + +/**@}*/ + +#endif +/* end of file */ diff --git a/cpukit/rtems/include/rtems/rtems/eventset.h b/cpukit/rtems/include/rtems/rtems/eventset.h new file mode 100644 index 0000000000..679934f22b --- /dev/null +++ b/cpukit/rtems/include/rtems/rtems/eventset.h @@ -0,0 +1,135 @@ +/** + * @file rtems/rtems/eventset.h + * + * This include file contains the information pertaining to the + * Event Sets Handler. This handler provides methods for the manipulation + * of event sets which will be sent and received by tasks. + */ + +/* 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.com/license/LICENSE. + * + * $Id$ + */ + +#ifndef _RTEMS_RTEMS_EVENTSET_H +#define _RTEMS_RTEMS_EVENTSET_H + +/** + * @defgroup ClassicEventSet Event Sets + * + * @ingroup ClassicRTEMS + * + * This encapsulates functionality related to Classic API + * Event Sets. These are used by the Classic API Event Manager. + */ +/**@{*/ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * The following defines the type used to control event sets. + */ +typedef uint32_t rtems_event_set; + +/** + * The following constant is used to receive the set of currently pending + * events. + */ +#define RTEMS_PENDING_EVENTS 0 + +/** + * The following constant is used when you wish to send or receive all + * events. + */ +#define RTEMS_ALL_EVENTS 0xFFFFFFFF + +/** This defines the bit in the event set associated with event 0. */ +#define RTEMS_EVENT_0 0x00000001 +/** This defines the bit in the event set associated with event 1. */ +#define RTEMS_EVENT_1 0x00000002 +/** This defines the bit in the event set associated with event 2. */ +#define RTEMS_EVENT_2 0x00000004 +/** This defines the bit in the event set associated with event 3. */ +#define RTEMS_EVENT_3 0x00000008 +/** This defines the bit in the event set associated with event 4. */ +#define RTEMS_EVENT_4 0x00000010 +/** This defines the bit in the event set associated with event 5. */ +#define RTEMS_EVENT_5 0x00000020 +/** This defines the bit in the event set associated with event 6. */ +#define RTEMS_EVENT_6 0x00000040 +/** This defines the bit in the event set associated with event 7. */ +#define RTEMS_EVENT_7 0x00000080 +/** This defines the bit in the event set associated with event 8. */ +#define RTEMS_EVENT_8 0x00000100 +/** This defines the bit in the event set associated with event 9. */ +#define RTEMS_EVENT_9 0x00000200 +/** This defines the bit in the event set associated with event 10. */ +#define RTEMS_EVENT_10 0x00000400 +/** This defines the bit in the event set associated with event 11. */ +#define RTEMS_EVENT_11 0x00000800 +/** This defines the bit in the event set associated with event 12. */ +#define RTEMS_EVENT_12 0x00001000 +/** This defines the bit in the event set associated with event 13. */ +#define RTEMS_EVENT_13 0x00002000 +/** This defines the bit in the event set associated with event 14. */ +#define RTEMS_EVENT_14 0x00004000 +/** This defines the bit in the event set associated with event 15. */ +#define RTEMS_EVENT_15 0x00008000 +/** This defines the bit in the event set associated with event 16. */ +#define RTEMS_EVENT_16 0x00010000 +/** This defines the bit in the event set associated with event 17. */ +#define RTEMS_EVENT_17 0x00020000 +/** This defines the bit in the event set associated with event 18. */ +#define RTEMS_EVENT_18 0x00040000 +/** This defines the bit in the event set associated with event 19. */ +#define RTEMS_EVENT_19 0x00080000 +/** This defines the bit in the event set associated with event 20. */ +#define RTEMS_EVENT_20 0x00100000 +/** This defines the bit in the event set associated with event 21. */ +#define RTEMS_EVENT_21 0x00200000 +/** This defines the bit in the event set associated with event 22. */ +#define RTEMS_EVENT_22 0x00400000 +/** This defines the bit in the event set associated with event 23. */ +#define RTEMS_EVENT_23 0x00800000 +/** This defines the bit in the event set associated with event 24. */ +#define RTEMS_EVENT_24 0x01000000 +/** This defines the bit in the event set associated with event 25. */ +#define RTEMS_EVENT_25 0x02000000 +/** This defines the bit in the event set associated with event 26. */ +#define RTEMS_EVENT_26 0x04000000 +/** This defines the bit in the event set associated with event 27. */ +#define RTEMS_EVENT_27 0x08000000 +/** This defines the bit in the event set associated with event 29. */ +#define RTEMS_EVENT_28 0x10000000 +/** This defines the bit in the event set associated with event 29. */ +#define RTEMS_EVENT_29 0x20000000 +/** This defines the bit in the event set associated with event 30. */ +#define RTEMS_EVENT_30 0x40000000 +/** This defines the bit in the event set associated with event 31. */ +#define RTEMS_EVENT_31 0x80000000 + +/** + * The following constant is the value of an event set which + * has no events pending. + */ +#define EVENT_SETS_NONE_PENDING 0 + +#ifndef __RTEMS_APPLICATION__ +#include <rtems/rtems/eventset.inl> +#endif + +#ifdef __cplusplus +} +#endif + +/**@}*/ + +#endif +/* end of include file */ diff --git a/cpukit/rtems/include/rtems/rtems/intr.h b/cpukit/rtems/include/rtems/rtems/intr.h new file mode 100644 index 0000000000..9b0b1b4608 --- /dev/null +++ b/cpukit/rtems/include/rtems/rtems/intr.h @@ -0,0 +1,136 @@ +/** + * @file rtems/rtems/intr.h + * + * @brief Header file for the Interrupt Manager. + * + * This include file contains all the constants and structures associated with + * the Interrupt Manager. + */ + +/* 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.com/license/LICENSE. + * + * $Id$ + */ + +#ifndef _RTEMS_RTEMS_INTR_H +#define _RTEMS_RTEMS_INTR_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include <rtems/score/isr.h> + +/** + * @defgroup ClassicINTR Interrupts + * + * @ingroup ClassicRTEMS + * + * This encapsulates functionality which XXX + */ +/**@{*/ + +/** + * @brief Interrupt level type. + */ +typedef ISR_Level rtems_interrupt_level; + +/** + * @brief Control block type used to manage the vectors. + */ +typedef ISR_Vector_number rtems_vector_number; + +/** + * @brief Return type for interrupt handler. + */ +typedef void rtems_isr; + +/** + * @brief Interrupt handler type. + * + * @see rtems_interrupt_catch() + */ +typedef rtems_isr ( *rtems_isr_entry )( + rtems_vector_number + ); + +#if (CPU_SIMPLE_VECTORED_INTERRUPTS == TRUE) +/** + * @brief Implementation of the rtems_interrupt_catch directive. + * + * This directive installs @a new_isr_handler as the RTEMS interrupt service + * routine for the interrupt vector with number @a vector. The previous RTEMS + * interrupt service routine is returned in @a old_isr_handler. + */ +rtems_status_code rtems_interrupt_catch( + rtems_isr_entry new_isr_handler, + rtems_vector_number vector, + rtems_isr_entry *old_isr_handler +); +#endif + +/** + * @brief Disables all maskable interrupts and returns the previous level in + * @a _isr_cookie. + * + * @note The interrupt level shall be of type @ref rtems_interrupt_level. + */ +#define rtems_interrupt_disable( _isr_cookie ) \ + _ISR_Disable(_isr_cookie) + +/** + * @brief Enables maskable interrupts to the level indicated by @a + * _isr_cookie. + * + * @note The interrupt level shall be of type @ref rtems_interrupt_level. + */ +#define rtems_interrupt_enable( _isr_cookie ) \ + _ISR_Enable(_isr_cookie) + +/** + * @brief Temporarily enables maskable interrupts to the level in @a + * _isr_cookie before redisabling them. + * + * @note The interrupt level shall be of type @ref rtems_interrupt_level. + */ +#define rtems_interrupt_flash( _isr_cookie ) \ + _ISR_Flash(_isr_cookie) + +/** + * @brief Returns true if the processor is currently servicing an interrupt + * and false otherwise. + * + * A return value of true indicates that the caller is an interrupt service + * routine and @b not a thread. The directives available to an interrupt + * service routine are restricted. + */ +#define rtems_interrupt_is_in_progress() \ + _ISR_Is_in_progress() + +/** + * @brief This routine generates an interrupt. + * + * @note No implementation. + */ +#define rtems_interrupt_cause( _interrupt_to_cause ) + +/** + * @brief This routine clears the specified interrupt. + * + * @note No implementation. + */ +#define rtems_interrupt_clear( _interrupt_to_clear ) + +#ifdef __cplusplus +} +#endif + +/**@}*/ + +#endif +/* end of include file */ diff --git a/cpukit/rtems/include/rtems/rtems/message.h b/cpukit/rtems/include/rtems/rtems/message.h new file mode 100644 index 0000000000..c56cc220a1 --- /dev/null +++ b/cpukit/rtems/include/rtems/rtems/message.h @@ -0,0 +1,313 @@ +/** + * @file rtems/rtems/message.h + * + * This include file contains all the constants and structures associated + * with the Message Queue Manager. This manager provides a mechanism for + * communication and synchronization between tasks using messages. + * + * Directives provided are: + * + * - create a queue + * - get ID of a queue + * - delete a queue + * - put a message at the rear of a queue + * - put a message at the front of a queue + * - broadcast N messages to a queue + * - receive message from a queue + * - flush all messages on a queue + */ + +/* 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.com/license/LICENSE. + * + * $Id$ + */ + +#ifndef _RTEMS_RTEMS_MESSAGE_H +#define _RTEMS_RTEMS_MESSAGE_H + +/** + * This constant is defined to extern most of the time when using + * this header file. However by defining it to nothing, the data + * declared in this header file can be instantiated. This is done + * in a single per manager file. + */ +#ifndef RTEMS_MESSAGE_EXTERN +#define RTEMS_MESSAGE_EXTERN extern +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#include <rtems/rtems/types.h> +#include <rtems/rtems/status.h> +#include <rtems/rtems/options.h> +#include <rtems/score/chain.h> +#include <rtems/score/object.h> +#include <rtems/rtems/attr.h> +#include <rtems/score/coremsg.h> + +/** + * @defgroup ClassicMessageQueue Message Queues + * + * @ingroup ClassicRTEMS + * + * This encapsulates functionality which XXX + */ +/**@{*/ + +/** + * The following enumerated type details the modes in which a message + * may be submitted to a message queue. The message may be posted + * in a send or urgent fashion. + */ +typedef enum { + /** + * This value indicates the user wants to send the message using the + * normal message insertion protocol (FIFO or priority). + */ + MESSAGE_QUEUE_SEND_REQUEST = 0, + /** + * This value indicates the user considers the message to be urgent + * and wants it inserted at the head of the pending message queue. + */ + MESSAGE_QUEUE_URGENT_REQUEST = 1 +} Message_queue_Submit_types; + +/** + * The following records define the control block used to manage + * each message queue. + */ +typedef struct { + /** This field is the inherited object characteristics. */ + Objects_Control Object; + /** This field is the attribute set as defined by the API. */ + rtems_attribute attribute_set; + /** This field is the instance of the SuperCore Message Queue. */ + CORE_message_queue_Control message_queue; +} Message_queue_Control; + +/** + * The following defines the information control block used to + * manage this class of objects. + */ +RTEMS_MESSAGE_EXTERN Objects_Information _Message_queue_Information; + +/** + * @brief Message_queue_Manager_initialization + * + * This routine performs the initialization necessary for this manager. + */ +void _Message_queue_Manager_initialization(void); + +/** + * @brief rtems_message_queue_create + * + * This routine implements the rtems_message_queue_create directive. The + * message queue will have the name name. If the attribute_set indicates + * that the message queue is to be limited in the number of messages + * that can be outstanding, then count indicates the maximum number of + * messages that will be held. It returns the id of the created + * message queue in ID. + */ +rtems_status_code rtems_message_queue_create( + rtems_name name, + uint32_t count, + size_t max_message_size, + rtems_attribute attribute_set, + rtems_id *id +); + +/** + * @brief rtems_message_queue_ident + * + * This routine implements the rtems_message_queue_ident directive. + * This directive returns the message queue ID associated with NAME. + * If more than one message queue is named name, then the message + * queue to which the ID belongs is arbitrary. node indicates the + * extent of the search for the ID of the message queue named name. + * The search can be limited to a particular node or allowed to + * encompass all nodes. + */ +rtems_status_code rtems_message_queue_ident( + rtems_name name, + uint32_t node, + rtems_id *id +); + +/** + * @brief rtems_message_queue_delete + * + * This routine implements the rtems_message_queue_delete directive. The + * message queue indicated by ID is deleted. + */ +rtems_status_code rtems_message_queue_delete( + rtems_id id +); + +/** + * @brief rtems_message_queue_send + * + * This routine implements the rtems_message_queue_send directive. + * This directive sends the message buffer to the message queue + * indicated by ID. If one or more tasks is blocked waiting + * to receive a message from this message queue, then one will + * receive the message. The task selected to receive the + * message is based on the task queue discipline algorithm in + * use by this particular message queue. If no tasks are waiting, + * then the message buffer will be placed at the REAR of the + * chain of pending messages for this message queue. + */ +rtems_status_code rtems_message_queue_send( + rtems_id id, + const void *buffer, + size_t size +); + +/** + * @brief rtems_message_queue_urgent + * + * This routine implements the rtems_message_queue_urgent directive. + * This directive has the same behavior as rtems_message_queue_send + * except that if no tasks are waiting, the message buffer will + * be placed at the FRONT of the chain of pending messages rather + * than at the REAR. + */ +rtems_status_code rtems_message_queue_urgent( + rtems_id id, + const void *buffer, + size_t size +); + +/** + * @brief rtems_message_queue_broadcast + * + * This routine implements the rtems_message_queue_broadcast directive. + * This directive sends the message buffer to all of the tasks blocked + * waiting for a message on the message queue indicated by ID. + * If no tasks are waiting, then the message buffer will not be queued. + */ +rtems_status_code rtems_message_queue_broadcast( + rtems_id id, + const void *buffer, + size_t size, + uint32_t *count +); + +/** + * @brief rtems_message_queue_receive + * + * This routine implements the rtems_message_queue_receive directive. + * This directive is invoked when the calling task wishes to receive + * a message from the message queue indicated by ID. The received + * message is to be placed in buffer. If no messages are outstanding + * and the option_set indicates that the task is willing to block, + * then the task will be blocked until a message arrives or until, + * optionally, timeout clock ticks have passed. + */ +rtems_status_code rtems_message_queue_receive( + rtems_id id, + void *buffer, + size_t *size, + rtems_option option_set, + rtems_interval timeout +); + +/** + * @brief rtems_message_queue_flush + * + * This routine implements the rtems_message_queue_flush directive. + * This directive takes all outstanding messages for the message + * queue indicated by ID and returns them to the inactive message + * chain. The number of messages flushed is returned in COUNT. + */ +rtems_status_code rtems_message_queue_flush( + rtems_id id, + uint32_t *count +); + +/** + * @brief rtems_message_queue_get_number_pending + * + * This routine implements the rtems_message_queue_get_number_pending + * directive. This directive returns the number of pending + * messages for the message queue indicated by ID + * chain. The number of messages pending is returned in COUNT. + */ +rtems_status_code rtems_message_queue_get_number_pending( + rtems_id id, + uint32_t *count +); + + +/** + * @brief Message_queue_Submit + * + * This routine implements the directives rtems_message_queue_send + * and rtems_message_queue_urgent. It processes a message that is + * to be submitted to the designated message queue. The message will + * either be processed as a send send message which it will be inserted + * at the rear of the queue or it will be processed as an urgent message + * which will be inserted at the front of the queue. + */ +rtems_status_code _Message_queue_Submit( + rtems_id id, + const void *buffer, + size_t size, + Message_queue_Submit_types submit_type +); + +/** + * @brief Message_queue_Allocate + * + * This function allocates a message queue control block from + * the inactive chain of free message queue control blocks. + */ +Message_queue_Control *_Message_queue_Allocate (void); + +/** + * @brief Message_queue_Translate_core_message_queue_return_code + * + * This function returns a RTEMS status code based on the core message queue + * status code specified. + */ +rtems_status_code _Message_queue_Translate_core_message_queue_return_code ( + uint32_t the_message_queue_status +); + +#if defined(RTEMS_MULTIPROCESSING) +/** + * @brief Message_queue_Core_message_queue_mp_support + * + * Input parameters: + * the_thread - the remote thread the message was submitted to + * id - id of the message queue + * + * Output parameters: NONE + */ +void _Message_queue_Core_message_queue_mp_support ( + Thread_Control *the_thread, + rtems_id id +); +#endif + +#ifndef __RTEMS_APPLICATION__ +#include <rtems/rtems/message.inl> +#endif +#if defined(RTEMS_MULTIPROCESSING) +#include <rtems/rtems/msgmp.h> +#endif + +#ifdef __cplusplus +} +#endif + +/**@}*/ + +#endif +/* end of include file */ diff --git a/cpukit/rtems/include/rtems/rtems/modes.h b/cpukit/rtems/include/rtems/rtems/modes.h new file mode 100644 index 0000000000..0665d17c8b --- /dev/null +++ b/cpukit/rtems/include/rtems/rtems/modes.h @@ -0,0 +1,111 @@ +/** + * @file rtems/rtems/modes.h + * + * This include file contains all constants and structures associated + * with the RTEMS thread and RTEMS_ASR modes. + */ + +/* 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.com/license/LICENSE. + * + * $Id$ + */ + +#ifndef _RTEMS_RTEMS_MODES_H +#define _RTEMS_RTEMS_MODES_H + +/** + * @defgroup ClassicModes Modes + * + * @ingroup ClassicRTEMS + * + * This encapsulates functionality which XXX + */ +/**@{*/ + +#ifdef __cplusplus +extern "C" { +#endif + +#include <rtems/score/isr.h> + +/** + * The following type defines the control block used to manage + * each a mode set. + */ +typedef uint32_t Modes_Control; + +/** + * The following constants define the individual modes and masks + * which may be used to compose a mode set and to alter modes. + */ +#define RTEMS_ALL_MODE_MASKS 0x0000ffff + +/** + * This mode constant is the default mode set. + */ +#define RTEMS_DEFAULT_MODES 0x00000000 + +/** + * This mode constant is used when the user wishes to obtain their + * current execution mode. + */ +#define RTEMS_CURRENT_MODE 0 + +/** This mode constant corresponds to the timeslice enable/disable bit. */ +#define RTEMS_TIMESLICE_MASK 0x00000200 + +/** This mode constant corresponds to the preemption enable/disable bit. */ +#define RTEMS_PREEMPT_MASK 0x00000100 + +/** This mode constant corresponds to the signal enable/disable bit. */ +#define RTEMS_ASR_MASK 0x00000400 + +/** This mode constant corresponds to the interrupt enable/disable bits. */ +#define RTEMS_INTERRUPT_MASK CPU_MODES_INTERRUPT_MASK + +/** This mode constant is used to indicate preemption is enabled. */ +#define RTEMS_PREEMPT 0x00000000 +/** This mode constant is used to indicate preemption is disabled. */ +#define RTEMS_NO_PREEMPT 0x00000100 + +/** This mode constant is used to indicate timeslicing is disabled. */ +#define RTEMS_NO_TIMESLICE 0x00000000 +/** This mode constant is used to indicate timeslicing is enabled. */ +#define RTEMS_TIMESLICE 0x00000200 + +/** This mode constant is used to indicate signal processing is enabled. */ +#define RTEMS_ASR 0x00000000 +/** This mode constant is used to indicate signal processing is disabled. */ +#define RTEMS_NO_ASR 0x00000400 + +/** + * @brief RTEMS_INTERRUPT_LEVEL + * + * This function returns the processor dependent interrupt + * level which corresponds to the requested interrupt level. + * + * @note RTEMS supports 256 interrupt levels using the least + * significant eight bits of MODES.CONTROL. On any + * particular CPU, fewer than 256 levels may be supported. + */ +#define RTEMS_INTERRUPT_LEVEL( _mode_set ) \ + ( (_mode_set) & RTEMS_INTERRUPT_MASK ) + + +#ifndef __RTEMS_APPLICATION__ +#include <rtems/rtems/modes.inl> +#endif + +#ifdef __cplusplus +} +#endif + +/**@}*/ + +#endif +/* end of include file */ diff --git a/cpukit/rtems/include/rtems/rtems/mp.h b/cpukit/rtems/include/rtems/rtems/mp.h new file mode 100644 index 0000000000..1f8252aac3 --- /dev/null +++ b/cpukit/rtems/include/rtems/rtems/mp.h @@ -0,0 +1,57 @@ +/** + * @file rtems/rtems/mp.h + * + * This include file contains all the constants and structures associated + * with the Multiprocessing Manager. + */ + +/* 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.com/license/LICENSE. + * + * $Id$ + */ + +#ifndef _RTEMS_RTEMS_MP_H +#define _RTEMS_RTEMS_MP_H + +/** + * @defgroup ClassicMP Multiprocessing + * + * @ingroup ClassicRTEMS + * + * This encapsulates functionality which XXX + */ +/**@{*/ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Multiprocessing_Manager_initialization + * + * This routine performs the initialization necessary for this manager. + */ +void _Multiprocessing_Manager_initialization ( void ); + +/** + * @brief rtems_multiprocessing_announce + * + * This routine implements the MULTIPROCESSING_ANNOUNCE directive. + * It is invoked by the MPCI layer to indicate that an MPCI packet + * has been received. + */ +void rtems_multiprocessing_announce ( void ); + +#ifdef __cplusplus +} +#endif + +/**@}*/ + +#endif +/* end of include file */ diff --git a/cpukit/rtems/include/rtems/rtems/msgmp.h b/cpukit/rtems/include/rtems/rtems/msgmp.h new file mode 100644 index 0000000000..8aa5f533ae --- /dev/null +++ b/cpukit/rtems/include/rtems/rtems/msgmp.h @@ -0,0 +1,166 @@ +/** + * @file rtems/rtems/msgmp.h + * + * This include file contains all the constants and structures associated + * with the Multiprocessing Support in the Message Manager. + */ + +/* 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.com/license/LICENSE. + * + * $Id$ + */ + +#ifndef _RTEMS_RTEMS_MSGMP_H +#define _RTEMS_RTEMS_MSGMP_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include <rtems/rtems/message.h> +#include <rtems/score/mppkt.h> +#include <rtems/score/object.h> +#include <rtems/rtems/options.h> +#include <rtems/score/thread.h> +#include <rtems/score/watchdog.h> + +/** + * @defgroup ClassicMsgMP Message Queue MP Support + * + * @ingroup ClassicMP + * + * This encapsulates functionality which XXX + */ +/**{*/ + +/** + * The following enumerated type defines the list of + * remote message queue operations. + */ +typedef enum { + MESSAGE_QUEUE_MP_ANNOUNCE_CREATE = 0, + MESSAGE_QUEUE_MP_ANNOUNCE_DELETE = 1, + MESSAGE_QUEUE_MP_EXTRACT_PROXY = 2, + MESSAGE_QUEUE_MP_RECEIVE_REQUEST = 3, + MESSAGE_QUEUE_MP_RECEIVE_RESPONSE = 4, + MESSAGE_QUEUE_MP_SEND_REQUEST = 5, + MESSAGE_QUEUE_MP_SEND_RESPONSE = 6, + MESSAGE_QUEUE_MP_URGENT_REQUEST = 7, + MESSAGE_QUEUE_MP_URGENT_RESPONSE = 8, + MESSAGE_QUEUE_MP_BROADCAST_REQUEST = 9, + MESSAGE_QUEUE_MP_BROADCAST_RESPONSE = 10, + MESSAGE_QUEUE_MP_FLUSH_REQUEST = 11, + MESSAGE_QUEUE_MP_FLUSH_RESPONSE = 12, + MESSAGE_QUEUE_MP_GET_NUMBER_PENDING_REQUEST = 13, + MESSAGE_QUEUE_MP_GET_NUMBER_PENDING_RESPONSE = 14 +} Message_queue_MP_Remote_operations; + +/** + * The following data structure defines the packet used to perform + * remote message queue operations. + */ +typedef struct { + rtems_packet_prefix Prefix; + Message_queue_MP_Remote_operations operation; + rtems_name name; + rtems_option option_set; + Objects_Id proxy_id; + uint32_t count; + size_t size; + uint32_t pad0; + CORE_message_queue_Buffer Buffer; +} Message_queue_MP_Packet; + +/** + * @brief _Message_queue_MP_Send_process_packet + * + * This routine performs a remote procedure call so that a + * process operation can be performed on another node. + */ +void _Message_queue_MP_Send_process_packet ( + Message_queue_MP_Remote_operations operation, + Objects_Id message_queue_id, + rtems_name name, + Objects_Id proxy_id +); + +/** + * @brief _Message_queue_MP_Send_request_packet + * + * This routine performs a remote procedure call so that a + * directive operation can be initiated on another node. + */ +rtems_status_code _Message_queue_MP_Send_request_packet ( + Message_queue_MP_Remote_operations operation, + Objects_Id message_queue_id, + const void *buffer, + size_t *size_p, + rtems_option option_set, + rtems_interval timeout +); + +/** + * @brief _Message_queue_MP_Send_response_packet + * + * This routine performs a remote procedure call so that a + * directive can be performed on another node. + */ +void _Message_queue_MP_Send_response_packet ( + Message_queue_MP_Remote_operations operation, + Objects_Id message_queue_id, + Thread_Control *the_thread +); + +/** + * + @brief * _Message_queue_MP_Process_packet + * + * This routine performs the actions specific to this package for + * the request from another node. + */ +void _Message_queue_MP_Process_packet ( + rtems_packet_prefix *the_packet_prefix +); + +/** + * @brief _Message_queue_MP_Send_object_was_deleted + * + * This routine is invoked indirectly by the thread queue + * when a proxy has been removed from the thread queue and + * the remote node must be informed of this. + */ +void _Message_queue_MP_Send_object_was_deleted ( + Thread_Control *the_proxy +); + +/** + * @brief _Message_queue_MP_Send_extract_proxy + * + * This routine is invoked when a task is deleted and it + * has a proxy which must be removed from a thread queue and + * the remote node must be informed of this. + */ +void _Message_queue_MP_Send_extract_proxy ( + void *argument +); + +/** + * @brief _Message_queue_MP_Get_packet + * + * This function is used to obtain a message queue mp packet. + */ +Message_queue_MP_Packet *_Message_queue_MP_Get_packet ( void ); + +#ifdef __cplusplus +} +#endif + +/**@}*/ + +#endif +/* end of file */ diff --git a/cpukit/rtems/include/rtems/rtems/object.h b/cpukit/rtems/include/rtems/rtems/object.h new file mode 100644 index 0000000000..72d65c6562 --- /dev/null +++ b/cpukit/rtems/include/rtems/rtems/object.h @@ -0,0 +1,356 @@ +/** + * @file rtems/rtems/object.h + */ + +/* 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.com/license/LICENSE. + * + * $Id$ + */ + +#ifndef _RTEMS_RTEMS_OBJECT_H +#define _RTEMS_RTEMS_OBJECT_H + +#include <stdint.h> +#include <rtems/score/object.h> +#include <rtems/rtems/status.h> +#include <rtems/rtems/types.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup ClassicClassInfo Object Class Information + * + * @ingroup ClassicRTEMS + * + * This encapsulates functionality which XXX + */ +/**@{*/ + +/** + * This structure is used to return information to the application + * about the objects configured for a specific API/Class combination. + */ +typedef struct { + /** This field is the minimum valid object Id for this class. */ + rtems_id minimum_id; + /** This field is the maximum valid object Id for this class. */ + rtems_id maximum_id; + /** This field is the number of object instances configured for this class. */ + uint32_t maximum; + /** This field indicates if the class is configured for auto-extend. */ + bool auto_extend; + /** This field is the number of currently unallocated objects. */ + uint32_t unallocated; +} rtems_object_api_class_information; + +/** + * @brief Build Object Id + * + * This function returns an object id composed of the + * specified @a api, @a class, @a node, + * and @a index. + * + * @param[in] _api indicates the api to use for the Id + * @param[in] _class indicates the class to use for the Id + * @param[in] _node indicates the node to use for the Id + * @param[in] _index indicates the index to use for the Id + * + * @return This method returns an object Id built from the + * specified values. + * + * @note A body is also provided. + */ +#define rtems_build_id( _api, _class, _node, _index ) \ + _Objects_Build_id( _api, _class, _node, _index ) + +/** + * @brief Build Thirty-Two Bit Object Name + * + * This function returns an object name composed of the four characters + * C1, C2, C3, and C4. + * + * @param[in] _C1 is the first character of the name + * @param[in] _C2 is the second character of the name + * @param[in] _C3 is the third character of the name + * @param[in] _C4 is the fourth character of the name + * + * @note This must be implemented as a macro for use in + * Configuration Tables. A body is also provided. + * + */ +#define rtems_build_name( _C1, _C2, _C3, _C4 ) \ + _Objects_Build_name( _C1, _C2, _C3, _C4 ) + +/** @brief Obtain name of object + * + * This directive returns the name associated with the specified + * object ID. + * + * @param[in] id is the Id of the object to obtain the name of. + * @param[out] name will be set to the name of the object + * + * @note The object must be have a name of the 32-bit form. + * + * @return @a *name will contain user defined object name + * @return @a RTEMS_SUCCESSFUL - if successful + * @return error code - if unsuccessful + */ +rtems_status_code rtems_object_get_classic_name( + rtems_id id, + rtems_name *name +); + +/** + * @brief Obtain Object Name as String + * + * This directive returns the name associated with the specified + * object ID. + * + * @param[in] id is the Id of the object to obtain the name of + * @param[in] length is the length of the output name buffer + * @param[out] name will be set to the name of the object + * + * @return @a *name will contain user defined object name + * @return @a name - if successful + * @return @a NULL - if unsuccessful + */ +char *rtems_object_get_name( + rtems_id id, + size_t length, + char *name +); + +/** + * @brief Set Name of Object + * + * This method allows the caller to set the name of an + * object. This can be used to set the name of objects + * which do not have a naming scheme per their API. + * + * @param[in] id is the Id of the object to obtain the name of + * @param[out] name will be set to the name of the object + * + * @return @a *name will contain user defined object name + * @return @a RTEMS_SUCCESSFUL - if successful + * @return error code - if unsuccessful + */ +rtems_status_code rtems_object_set_name( + rtems_id id, + const char *name +); + +/** + * @brief Get API Portion of Object Id + * + * This function returns the API portion of the Id. + * + * @param[in] _id is the Id of the object to obtain the API from + * + * @return This method returns the API portion of the provided + * @a _id. + * + * @note This method does NOT validate the @a _id provided. + * + * @note A body is also provided. + */ +#define rtems_object_id_get_api( _id ) \ + _Objects_Get_API( _id ) + +/** + * @brief Get Class Portion of Object Id + * + * This function returns the class portion of the ID. + * + * @param[in] _id is the Id of the object to obtain the class from + * + * @return This method returns the class portion of the provided + * @a _id. + * + * @note This method does NOT validate the @a _id provided. + * + * @note A body is also provided. + */ +#define rtems_object_id_get_class( _id ) \ + _Objects_Get_class( _id ) + +/** + * @brief Get Node Portion of Object Id + * + * This function returns the node portion of the ID. + * + * @param[in] _id is the Id of the object to obtain the node from + * + * @return This method returns the node portion of the provided + * @a _id. + * + * @note This method does NOT validate the @a _id provided. + * + * @note A body is also provided. + */ +#define rtems_object_id_get_node( _id ) \ + _Objects_Get_node( _id ) + +/** + * @brief Get Index Portion of Object Id + * + * This function returns the index portion of the ID. + * + * @param[in] _id is the Id of the object to obtain the index from + * + * @return This method returns the index portion of the provided + * @a _id. + * + * @note This method does NOT validate the @a _id provided. + * + * @note A body is also provided. + */ +#define rtems_object_id_get_index( _id ) \ + _Objects_Get_index( _id ) + +/** + * @brief Get Lowest Valid API Index + * + * This method returns the lowest valid value for the API + * portion of an RTEMS object Id. + * + * @return This method returns the least valid value for + * the API portion of an RTEMS object Id. + * + * @note A body is also provided. + */ +#define rtems_object_id_api_minimum() \ + OBJECTS_INTERNAL_API + +/** + * @brief Get Highest Valid API Index + * + * This method returns the highest valid value for the API + * portion of an RTEMS object Id. + * + * @return This method returns the greatest valid value for + * the API portion of an RTEMS object Id. + * + * @note A body is also provided. + */ +#define rtems_object_id_api_maximum() \ + OBJECTS_APIS_LAST + +/** + * @brief Get Lowest Valid Class Value + * + * This method returns the lowest valid value Class for the + * specified @a api. Each API supports a different number + * of object classes. + * + * @param[in] api is the API to obtain the minimum class of + * + * @return This method returns the least valid value for + * class number for the specified @a api. + */ +int rtems_object_api_minimum_class( + int api +); + +/** + * @brief Get Highest Valid Class Value + * + * This method returns the highest valid value Class for the + * specified @a api. Each API supports a different number + * of object classes. + * + * @param[in] api is the API to obtain the maximum class of + * + * @return This method returns the greatet valid value for + * class number for the specified @a api. + */ +int rtems_object_api_maximum_class( + int api +); + + +/** + * @brief Get Highest Valid Class Value + * + * This method returns the lowest valid value Class for the + * specified @a api. Each API supports a different number + * of object classes. + * + * @param[in] api is the API to obtain the maximum class of + * + * @return This method returns the least valid value for + * class number for the specified @a api. + */ +int rtems_object_id_api_maximum_class( + int api +); + +/** + * @brief Get API Name + * + * This method returns a string containing the name of the + * specified @a api. + * + * @param[in] api is the API to obtain the name of + * + * @return If successful, this method returns the name of + * the specified @a api. Otherwise, it returns + * the string "BAD API" + */ +const char *rtems_object_get_api_name( + int api +); + +/** + * @brief Get Class Name + * + * This method returns a string containing the name of the + * @a class from the specified @a api. + * + * @param[in] the_api is the API for the class + * @param[in] the_class is the class to obtain the name of + * + * @return If successful, this method returns the name of + * the specified @a class. Otherwise, it returns + * the string "BAD CLASS" + */ +const char *rtems_object_get_api_class_name( + int the_api, + int the_class +); + +/** + * @brief Get Class Name + * + * This method returns a string containing the name of the + * @a the_class from the specified @a api. + * + * @param[in] the_api is the API for the class + * @param[in] the_class is the class to obtain information about + * @param[in] info points to the information structure to fill in + * + * @return If successful, this method returns the name of + * RTEMS_SUCCESSFUL with @a *info filled in. Otherwise, + * a status is returned to indicate the error. + * + */ +rtems_status_code rtems_object_get_class_information( + int the_api, + int the_class, + rtems_object_api_class_information *info +); + +#ifdef __cplusplus +} +#endif + +/**@}*/ + +#endif +/* end of include file */ diff --git a/cpukit/rtems/include/rtems/rtems/options.h b/cpukit/rtems/include/rtems/rtems/options.h new file mode 100644 index 0000000000..240854519c --- /dev/null +++ b/cpukit/rtems/include/rtems/rtems/options.h @@ -0,0 +1,78 @@ +/** + * @file rtems/rtems/options.h + * + * This include file contains information which defines the + * options available on many directives. + */ + +/* 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.com/license/LICENSE. + * + * $Id$ + */ + +#ifndef _RTEMS_RTEMS_OPTIONS_H +#define _RTEMS_RTEMS_OPTIONS_H + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup ClassicOptions Classic API Options + * + * This encapsulates functionality which XXX + */ +/**@{*/ + +/** + * The following type defines the control block used to manage + * option sets. + */ +typedef uint32_t rtems_option; + +/** + * The following constants define the individual options which may + * be used to compose an option set. + */ +#define RTEMS_DEFAULT_OPTIONS 0x00000000 + +/** + * This option constants indicates that the task is to wait on resource. + */ +#define RTEMS_WAIT 0x00000000 +/** + * This option constants indicates that the task is to not wait on + * the resource. If it is not available, return immediately with + * a status to indicate unsatisfied. + */ +#define RTEMS_NO_WAIT 0x00000001 + +/** + * This option constants indicates that the task wishes to wait until + * all events of interest are available. + */ +#define RTEMS_EVENT_ALL 0x00000000 + +/** + * This option constants indicates that the task wishes to wait until + * ANY events of interest are available. + */ +#define RTEMS_EVENT_ANY 0x00000002 + +#ifndef __RTEMS_APPLICATION__ +#include <rtems/rtems/options.inl> +#endif + +#ifdef __cplusplus +} +#endif + +/**@}*/ + +#endif +/* end of include file */ diff --git a/cpukit/rtems/include/rtems/rtems/part.h b/cpukit/rtems/include/rtems/rtems/part.h new file mode 100644 index 0000000000..3d3d2938ab --- /dev/null +++ b/cpukit/rtems/include/rtems/rtems/part.h @@ -0,0 +1,180 @@ +/** + * @file rtems/rtems/part.h + * + * This include file contains all the constants and structures associated + * with the Partition Manager. This manager provides facilities to + * dynamically allocate memory in fixed-sized units which are returned + * as buffers. + * + * Directives provided are: + * + * - create a partition + * - get an ID of a partition + * - delete a partition + * - get a buffer from a partition + * - return a buffer to a partition + */ + +/* 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.com/license/LICENSE. + * + * $Id$ + */ + +#ifndef _RTEMS_RTEMS_PART_H +#define _RTEMS_RTEMS_PART_H + +/** + * This constant is defined to extern most of the time when using + * this header file. However by defining it to nothing, the data + * declared in this header file can be instantiated. This is done + * in a single per manager file. + */ +#ifndef RTEMS_PART_EXTERN +#define RTEMS_PART_EXTERN extern +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#include <rtems/score/address.h> +#include <rtems/score/object.h> +#include <rtems/rtems/attr.h> +#include <rtems/rtems/status.h> +#include <rtems/rtems/support.h> +#include <rtems/rtems/types.h> + +/** + * @defgroup ClassicPart Partitions + * + * @ingroup ClassicRTEMS + * + * This encapsulates functionality related to the + * Classic API Partition Manager. + */ +/**@{*/ + +/** + * The following defines the control block used to manage each partition. + */ +typedef struct { + /** This field is the object management portion of a Partition instance. */ + Objects_Control Object; + /** This field is the physical starting address of the Partition. */ + void *starting_address; + /** This field is the size of the Partition in bytes. */ + intptr_t length; + /** This field is the size of each buffer in bytes */ + uint32_t buffer_size; + /** This field is the attribute set provided at create time. */ + rtems_attribute attribute_set; + /** This field is the of allocated buffers. */ + uint32_t number_of_used_blocks; + /** This field is the chain used to manage unallocated buffers. */ + Chain_Control Memory; +} Partition_Control; + +/** + * The following defines the information control block used to + * manage this class of objects. + */ +RTEMS_PART_EXTERN Objects_Information _Partition_Information; + +/** + * @brief Partition_Manager_initialization + * + * This routine performs the initialization necessary for this manager. + */ +void _Partition_Manager_initialization(void); + +/** + * @brief rtems_partition_create + * + * This routine implements the rtems_partition_create directive. The + * partition will have the name name. The memory area managed by + * the partition is of length bytes and starts at starting_address. + * The memory area will be divided into as many buffers of + * buffer_size bytes as possible. The attribute_set determines if + * the partition is global or local. It returns the id of the + * created partition in ID. + */ +rtems_status_code rtems_partition_create( + rtems_name name, + void *starting_address, + uint32_t length, + uint32_t buffer_size, + rtems_attribute attribute_set, + rtems_id *id +); + +/** + * @brief rtems_partition_ident + * + * This routine implements the rtems_partition_ident directive. + * This directive returns the partition ID associated with name. + * If more than one partition is named name, then the partition + * to which the ID belongs is arbitrary. node indicates the + * extent of the search for the ID of the partition named name. + * The search can be limited to a particular node or allowed to + * encompass all nodes. + */ +rtems_status_code rtems_partition_ident( + rtems_name name, + uint32_t node, + rtems_id *id +); + +/** + * @brief rtems_partition_delete + * + * This routine implements the rtems_partition_delete directive. The + * partition indicated by ID is deleted. + */ +rtems_status_code rtems_partition_delete( + rtems_id id +); + +/** + * @brief rtems_partition_get_buffer + * + * This routine implements the rtems_partition_get_buffer directive. It + * attempts to allocate a buffer from the partition associated with ID. + * If a buffer is allocated, its address is returned in buffer. + */ +rtems_status_code rtems_partition_get_buffer( + rtems_id id, + void **buffer +); + +/** + * @brief rtems_partition_return_buffer + * + * This routine implements the rtems_partition_return_buffer directive. It + * frees the buffer to the partition associated with ID. The buffer must + * have been previously allocated from the same partition. + */ +rtems_status_code rtems_partition_return_buffer( + rtems_id id, + void *buffer +); + +#ifndef __RTEMS_APPLICATION__ +#include <rtems/rtems/part.inl> +#endif +#if defined(RTEMS_MULTIPROCESSING) +#include <rtems/rtems/partmp.h> +#endif + +#ifdef __cplusplus +} +#endif + +/**@}*/ + +#endif +/* end of include file */ diff --git a/cpukit/rtems/include/rtems/rtems/partmp.h b/cpukit/rtems/include/rtems/rtems/partmp.h new file mode 100644 index 0000000000..f36f0e259c --- /dev/null +++ b/cpukit/rtems/include/rtems/rtems/partmp.h @@ -0,0 +1,151 @@ +/** + * @file rtems/rtems/partmp.h + * + * This include file contains all the constants and structures associated + * with the Multiprocessing Support in the Partition Manager. + */ + +/* 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.com/license/LICENSE. + * + * $Id$ + */ + +#ifndef _RTEMS_RTEMS_PARTMP_H +#define _RTEMS_RTEMS_PARTMP_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include <rtems/score/mppkt.h> +#include <rtems/score/object.h> +#include <rtems/rtems/options.h> +#include <rtems/score/thread.h> + +#include <rtems/rtems/part.h> + +/** + * @defgroup ClassicPartMP Partition MP Support + * + * @ingroup ClassicMP + * + * This encapsulates functionality which XXX + */ +/**{*/ + +/** + * The following enumerated type defines the list of + * remote partition operations. + */ +typedef enum { + PARTITION_MP_ANNOUNCE_CREATE = 0, + PARTITION_MP_ANNOUNCE_DELETE = 1, + PARTITION_MP_EXTRACT_PROXY = 2, + PARTITION_MP_GET_BUFFER_REQUEST = 3, + PARTITION_MP_GET_BUFFER_RESPONSE = 4, + PARTITION_MP_RETURN_BUFFER_REQUEST = 5, + PARTITION_MP_RETURN_BUFFER_RESPONSE = 6 +} Partition_MP_Remote_operations; + +/** + * The following data structure defines the packet used to perform + * remote partition operations. + */ +typedef struct { + rtems_packet_prefix Prefix; + Partition_MP_Remote_operations operation; + rtems_name name; + void *buffer; + Objects_Id proxy_id; +} Partition_MP_Packet; + +/** + * @brief Partition_MP_Send_process_packet + * + * This routine performs a remote procedure call so that a + * process operation can be performed on another node. + */ +void _Partition_MP_Send_process_packet ( + Partition_MP_Remote_operations operation, + Objects_Id partition_id, + rtems_name name, + Objects_Id proxy_id +); + +/** + * @brief Partition_MP_Send_request_packet + * + * This routine performs a remote procedure call so that a + * directive operation can be initiated on another node. + */ +rtems_status_code _Partition_MP_Send_request_packet ( + Partition_MP_Remote_operations operation, + Objects_Id partition_id, + void *buffer +); + +/** + * @brief Partition_MP_Send_response_packet + * + * This routine performs a remote procedure call so that a + * directive can be performed on another node. + */ +void _Partition_MP_Send_response_packet ( + Partition_MP_Remote_operations operation, + Objects_Id partition_id, + Thread_Control *the_thread +); + +/** + * + * @brief Partition_MP_Process_packet + * + * This routine performs the actions specific to this package for + * the request from another node. + */ +void _Partition_MP_Process_packet ( + rtems_packet_prefix *the_packet_prefix +); + +/* + * @brief Partition_MP_Send_object_was_deleted + * + * This routine is invoked indirectly by the thread queue + * when a proxy has been removed from the thread queue and + * the remote node must be informed of this. + * + * This routine is not needed by the Partition since a partition + * cannot be deleted when buffers are in use. + */ + +/** + * @brief Partition_MP_Send_extract_proxy + * + * This routine is invoked when a task is deleted and it + * has a proxy which must be removed from a thread queue and + * the remote node must be informed of this. + */ +void _Partition_MP_Send_extract_proxy ( + void *argument +); + +/** + * @brief Partition_MP_Get_packet + * + * This function is used to obtain a partition mp packet. + */ +Partition_MP_Packet *_Partition_MP_Get_packet ( void ); + +#ifdef __cplusplus +} +#endif + +/**@}*/ + +#endif +/* end of file */ diff --git a/cpukit/rtems/include/rtems/rtems/ratemon.h b/cpukit/rtems/include/rtems/rtems/ratemon.h new file mode 100644 index 0000000000..9e0f1fda09 --- /dev/null +++ b/cpukit/rtems/include/rtems/rtems/ratemon.h @@ -0,0 +1,517 @@ +/** + * @file rtems/rtems/ratemon.h + * + * This include file contains all the constants, structures, and + * prototypes associated with the Rate Monotonic Manager. This manager + * provides facilities to implement threads which execute in a periodic + * fashion. + * + * Directives provided are: + * + * - create a rate monotonic timer + * - cancel a period + * - delete a rate monotonic timer + * - conclude current and start the next period + * - obtain status information on a period + */ + +/* COPYRIGHT (c) 1989-2009. + * 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.com/license/LICENSE. + * + * $Id$ + */ + +#ifndef _RTEMS_RTEMS_RATEMON_H +#define _RTEMS_RTEMS_RATEMON_H + +/** + * This constant is defined to extern most of the time when using + * this header file. However by defining it to nothing, the data + * declared in this header file can be instantiated. This is done + * in a single per manager file. + */ +#ifndef RTEMS_RATEMON_EXTERN +#define RTEMS_RATEMON_EXTERN extern +#endif + +#include <rtems/bspIo.h> + +/** + * @defgroup ClassicRateMon Rate Monotonic Scheduler + * + * @ingroup ClassicRTEMS + * + * This encapsulates functionality related to the + * Classic API Rate Monotonic Manager. + * + * Statistics are kept for each period and can be obtained or printed via + * API calls. The statistics kept include minimum, maximum and average times + * for both cpu usage and wall time. The statistics indicate the execution time + * used by the owning thread between successive calls to rtems_rate_monotonic_period. + */ +/**@{*/ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * This is the public type used for the rate monotonic timing + * statistics. + */ +#ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__ + #include <rtems/score/timespec.h> + + typedef struct timespec rtems_rate_monotonic_period_time_t; +#else + typedef uint32_t rtems_rate_monotonic_period_time_t; +#endif + +/** + * This is the internal type used for the rate monotonic timing + * statistics. + */ +#ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__ + #include <rtems/score/timestamp.h> + + typedef Timestamp_Control Rate_monotonic_Period_time_t; +#else + typedef uint32_t Rate_monotonic_Period_time_t; +#endif + +#include <rtems/score/object.h> +#include <rtems/score/thread.h> +#include <rtems/score/watchdog.h> +#include <rtems/rtems/status.h> +#include <rtems/rtems/support.h> + +#include <string.h> + + +/** + * The following enumerated type defines the states in which a + * period may be. + */ +typedef enum { + /** + * This value indicates the period is off the watchdog chain, + * and has never been initialized. + */ + RATE_MONOTONIC_INACTIVE, + + /** + * This value indicates the period is on the watchdog chain, and + * the owner is blocked waiting on it. + */ + RATE_MONOTONIC_OWNER_IS_BLOCKING, + + /** + * This value indicates the period is on the watchdog chain, and + * running. The owner should be executed or blocked waiting on + * another object. + */ + RATE_MONOTONIC_ACTIVE, + + /** + * This value indicates the period is on the watchdog chain, and + * has expired. The owner should be blocked waiting for the next period. + */ + RATE_MONOTONIC_EXPIRED_WHILE_BLOCKING, + + /** + * This value indicates the period is off the watchdog chain, and + * has expired. The owner is still executing and has taken too much + * all time to complete this iteration of the period. + */ + RATE_MONOTONIC_EXPIRED +} rtems_rate_monotonic_period_states; + +/** + * The following constant is the interval passed to the rate_monontonic_period + * directive to obtain status information. + */ +#define RTEMS_PERIOD_STATUS WATCHDOG_NO_TIMEOUT + +/** + * The following defines the PUBLIC data structure that has the + * statistics kept on each period instance. + * + * @note The public structure uses struct timespec while the + * internal one uses Timestamp_Control. + */ +typedef struct { + /** This field contains the number of periods executed. */ + uint32_t count; + /** This field contains the number of periods missed. */ + uint32_t missed_count; + + /** This field contains the least amount of CPU time used in a period. */ + rtems_thread_cpu_usage_t min_cpu_time; + /** This field contains the highest amount of CPU time used in a period. */ + rtems_thread_cpu_usage_t max_cpu_time; + /** This field contains the total amount of wall time used in a period. */ + rtems_thread_cpu_usage_t total_cpu_time; + + /** This field contains the least amount of wall time used in a period. */ + rtems_rate_monotonic_period_time_t min_wall_time; + /** This field contains the highest amount of wall time used in a period. */ + rtems_rate_monotonic_period_time_t max_wall_time; + /** This field contains the total amount of CPU time used in a period. */ + rtems_rate_monotonic_period_time_t total_wall_time; +} rtems_rate_monotonic_period_statistics; + +/** + * The following defines the INTERNAL data structure that has the + * statistics kept on each period instance. + */ +typedef struct { + /** This field contains the number of periods executed. */ + uint32_t count; + /** This field contains the number of periods missed. */ + uint32_t missed_count; + + /** This field contains the least amount of CPU time used in a period. */ + Thread_CPU_usage_t min_cpu_time; + /** This field contains the highest amount of CPU time used in a period. */ + Thread_CPU_usage_t max_cpu_time; + /** This field contains the total amount of wall time used in a period. */ + Thread_CPU_usage_t total_cpu_time; + + /** This field contains the least amount of wall time used in a period. */ + Rate_monotonic_Period_time_t min_wall_time; + /** This field contains the highest amount of wall time used in a period. */ + Rate_monotonic_Period_time_t max_wall_time; + /** This field contains the total amount of CPU time used in a period. */ + Rate_monotonic_Period_time_t total_wall_time; +} Rate_monotonic_Statistics; + +/** + * The following defines the period status structure. + */ +typedef struct { + /** This is the Id of the thread using this period. */ + rtems_id owner; + + /** This is the current state of this period. */ + rtems_rate_monotonic_period_states state; + + /** + * This is the length of wall time that has passed since this period + * was last initiated. If the period is expired or has not been initiated, + * then this field has no meaning. + */ + rtems_rate_monotonic_period_time_t since_last_period; + + /** + * This is the amount of CPU time that has been used since this period + * was last initiated. If the period is expired or has not been initiated, + * then this field has no meaning. + */ + rtems_thread_cpu_usage_t executed_since_last_period; +} rtems_rate_monotonic_period_status; + +/** + * The following structure defines the control block used to manage + * each period. + */ +typedef struct { + /** This field is the object management portion of a Period instance. */ + Objects_Control Object; + + /** This is the timer used to provide the unblocking mechanism. */ + Watchdog_Control Timer; + + /** This field indicates the current state of the period. */ + rtems_rate_monotonic_period_states state; + + /** + * This field contains the length of the next period to be + * executed. + */ + uint32_t next_length; + + /** + * This field contains a pointer to the TCB for the thread + * which owns and uses this period instance. + */ + Thread_Control *owner; + + /** + * This field contains the cpu usage value of the owning thread when + * the period was initiated. It is used to compute the period's + * statistics. + */ + Thread_CPU_usage_t cpu_usage_period_initiated; + + /** + * This field contains the wall time value when the period + * was initiated. It is used to compute the period's statistics. + */ + Rate_monotonic_Period_time_t time_period_initiated; + + /** + * This field contains the statistics maintained for the period. + */ + Rate_monotonic_Statistics Statistics; +} Rate_monotonic_Control; + +/** + * @brief Rate Monotonic Period Class Management Structure + * + * This instance of Objects_Information is used to manage the + * set of rate monotonic period instances. + */ +RTEMS_RATEMON_EXTERN Objects_Information _Rate_monotonic_Information; + +/** + * @brief Rate Monotonic Manager Initialization + * + * This routine performs the initialization necessary for this manager. + */ +void _Rate_monotonic_Manager_initialization(void); + +/** + * @brief rtems_rate_monotonic_create + * + * This routine implements the rate_monotonic_create directive. The + * period will have the name name. It returns the id of the + * created period in ID. + */ +rtems_status_code rtems_rate_monotonic_create( + rtems_name name, + rtems_id *id +); + +/** + * @brief rtems_rate_monotonic_ident + * + * This routine implements the rtems_rate_monotonic_ident directive. + * It returns the period ID associated with name. If more than one period + * is named name, then the period to which the ID belongs is arbitrary. + */ +rtems_status_code rtems_rate_monotonic_ident( + rtems_name name, + rtems_id *id +); + +/** + * @brief rtems_rate_monotonic_cancel + * + * This routine implements the rtems_rate_monotonic_cancel directive. This + * directive stops the period associated with ID from continuing to + * run. + */ +rtems_status_code rtems_rate_monotonic_cancel( + rtems_id id +); + +/** + * @brief rtems_rate_monotonic_delete + * + * This routine implements the rtems_rate_monotonic_delete directive. The + * period indicated by ID is deleted. + */ +rtems_status_code rtems_rate_monotonic_delete( + rtems_id id +); + +/** + * @brief rtems_rate_monotonic_get_status + * + * This routine implements the rtems_rate_monotonic_get_status directive. + * Information about the period indicated by ID is returned. + * + */ +rtems_status_code rtems_rate_monotonic_get_status( + rtems_id id, + rtems_rate_monotonic_period_status *status +); + +/** + * @brief rtems_rate_monotonic_get_statistics + * + * This routine implements the rtems_rate_monotonic_get_statistics directive. + * Statistics gathered from the use of this period are returned. + */ +rtems_status_code rtems_rate_monotonic_get_statistics( + rtems_id id, + rtems_rate_monotonic_period_statistics *statistics +); + +/** + * @brief rtems_rate_monotonic_reset_statistics + * + * This routine allows a thread to reset the statistics information + * on a specific period instance. + */ +rtems_status_code rtems_rate_monotonic_reset_statistics( + rtems_id id +); + +/** + * @brief rtems_rate_monotonic_reset_all_statistics + * + * This routine allows a thread to reset the statistics information + * on ALL period instances. + */ +void rtems_rate_monotonic_reset_all_statistics( void ); + +/** + * @brief rtems_rate_monotonic_report_statistics + * + * This routine allows a thread to print the statistics information + * on ALL period instances which have non-zero counts using printk. + */ +void rtems_rate_monotonic_report_statistics_with_plugin( + void *context, + rtems_printk_plugin_t print +); + +/** + * @brief rtems_rate_monotonic_report_statistics + * + * This routine allows a thread to print the statistics information + * on ALL period instances which have non-zero counts using printk. + */ +void rtems_rate_monotonic_report_statistics( void ); + +/** + * @brief rtems_rate_monotonic_period + * + * This routine implements the rtems_rate_monotonic_period directive. When + * length is non-zero, this directive initiates the period associated with + * ID from continuing for a period of length. If length is zero, then + * result is set to indicate the current state of the period. + */ +rtems_status_code rtems_rate_monotonic_period( + rtems_id id, + rtems_interval length +); + +/** + * @brief _Rate_monotonic_Timeout + * + * This routine is invoked when the period represented + * by ID expires. If the thread which owns this period is blocked + * waiting for the period to expire, then it is readied and the + * period is restarted. If the owning thread is not waiting for the + * period to expire, then the period is placed in the EXPIRED + * state and not restarted. + */ +void _Rate_monotonic_Timeout( + rtems_id id, + void *ignored +); + +/** + * @brief _Rate_monotonic_Get_status( + * + * This routine is invoked to compute the elapsed wall time and cpu + * time for a period. + * + * @param[in] the_period points to the period being operated upon. + * @param[out] wall_since_last_period is set to the wall time elapsed + * since the period was initiated. + * @param[out] cpu_since_last_period is set to the cpu time used by the + * owning thread since the period was initiated. + * + * @return This routine returns true if the status can be determined + * and false otherwise. + */ +bool _Rate_monotonic_Get_status( + Rate_monotonic_Control *the_period, + Rate_monotonic_Period_time_t *wall_since_last_period, + Thread_CPU_usage_t *cpu_since_last_period +); + +/** + * @brief _Rate_monotonic_Initiate_statistics( + * + * This routine is invoked when a period is initiated via an explicit + * call to rtems_rate_monotonic_period for the period's first iteration + * or from _Rate_monotonic_Timeout for period iterations 2-n. + * + * @param[in] the_period points to the period being operated upon. + */ +void _Rate_monotonic_Initiate_statistics( + Rate_monotonic_Control *the_period +); + +/** + * @brief _Rate_monotonic_Reset_wall_time_statistics + * + * This method resets the statistics information for a period instance. + */ +#ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__ + #define _Rate_monotonic_Reset_wall_time_statistics( _the_period ) \ + do { \ + /* set the minimums to a large value */ \ + _Timestamp_Set( \ + &(_the_period)->Statistics.min_wall_time, \ + 0x7fffffff, \ + 0x7fffffff \ + ); \ + } while (0) +#else + #define _Rate_monotonic_Reset_wall_time_statistics( _the_period ) \ + do { \ + /* set the minimum to a large value */ \ + (_the_period)->Statistics.min_wall_time = 0xffffffff; \ + } while (0) +#endif + +/** + * @brief Rate_monotonic_Reset_cpu_use_statistics + * + * This helper method resets the period CPU usage statistics structure. + */ +#ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__ + #define _Rate_monotonic_Reset_cpu_use_statistics( _the_period ) \ + do { \ + /* set the minimums to a large value */ \ + _Timestamp_Set( \ + &(_the_period)->Statistics.min_cpu_time, \ + 0x7fffffff, \ + 0x7fffffff \ + ); \ + } while (0) +#else + #define _Rate_monotonic_Reset_cpu_use_statistics( _the_period ) \ + do { \ + /* set the minimum to a large value */ \ + (_the_period)->Statistics.min_cpu_time = 0xffffffff; \ + } while (0) +#endif + +/** + * @brief Rate_monotonic_Reset_statistics + * + * This helper method resets the period wall time statistics structure. + */ +#define _Rate_monotonic_Reset_statistics( _the_period ) \ + do { \ + memset( \ + &(_the_period)->Statistics, \ + 0, \ + sizeof( rtems_rate_monotonic_period_statistics ) \ + ); \ + _Rate_monotonic_Reset_cpu_use_statistics( _the_period ); \ + _Rate_monotonic_Reset_wall_time_statistics( _the_period ); \ + } while (0) + +#ifndef __RTEMS_APPLICATION__ +#include <rtems/rtems/ratemon.inl> +#endif + +#ifdef __cplusplus +} +#endif + +/**@}*/ + +#endif +/* end of include file */ diff --git a/cpukit/rtems/include/rtems/rtems/region.h b/cpukit/rtems/include/rtems/rtems/region.h new file mode 100644 index 0000000000..adab79b999 --- /dev/null +++ b/cpukit/rtems/include/rtems/rtems/region.h @@ -0,0 +1,292 @@ +/** + * @file rtems/rtems/region.h + * + * This include file contains all the constants and structures associated + * with the Region Manager. This manager provides facilities to dynamically + * allocate memory in variable sized units which are returned as segments. + * + * Directives provided are: + * + * - create a region + * - get an ID of a region + * - delete a region + * - get a segment from a region + * - return a segment to a region + */ + +/* COPYRIGHT (c) 1989-2009. + * 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.com/license/LICENSE. + * + * $Id$ + */ + +#ifndef _RTEMS_RTEMS_REGION_H +#define _RTEMS_RTEMS_REGION_H + +#include <rtems/score/object.h> +#include <rtems/score/threadq.h> +#include <rtems/score/heap.h> +#include <rtems/debug.h> +#include <rtems/rtems/attr.h> +#include <rtems/rtems/options.h> +#include <rtems/rtems/status.h> +#include <rtems/rtems/support.h> +#include <rtems/rtems/types.h> + +/** + * @defgroup ClassicRegion Regions + * + * @ingroup ClassicRTEMS + * + * This encapsulates functionality which XXX + */ +/**@{*/ + +/** + * This constant is defined to extern most of the time when using + * this header file. However by defining it to nothing, the data + * declared in this header file can be instantiated. This is done + * in a single per manager file. + */ +#ifndef RTEMS_REGION_EXTERN +#define RTEMS_REGION_EXTERN extern +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * The following records define the control block used to manage + * each region. + */ + +typedef struct { + Objects_Control Object; + Thread_queue_Control Wait_queue; /* waiting threads */ + void *starting_address; /* physical start addr */ + uintptr_t length; /* physical length(bytes) */ + uintptr_t page_size; /* in bytes */ + uintptr_t maximum_segment_size; /* in bytes */ + rtems_attribute attribute_set; + uint32_t number_of_used_blocks; /* blocks allocated */ + Heap_Control Memory; +} Region_Control; + +/** + * The following defines the information control block used to + * manage this class of objects. + */ +RTEMS_REGION_EXTERN Objects_Information _Region_Information; + +/** + * @brief _Region_Manager_initialization + * + * This routine performs the initialization necessary for this manager. + */ +void _Region_Manager_initialization(void); + +/** + * @brief rtems_region_create + * + * This routine implements the rtems_region_create directive. The + * region will have the name name. The memory area managed by + * the region is of length bytes and starts at starting_address. + * The memory area will be divided into as many allocatable units of + * page_size bytes as possible. The attribute_set determines which + * thread queue discipline is used by the region. It returns the + * id of the created region in ID. + */ +rtems_status_code rtems_region_create( + rtems_name name, + void *starting_address, + uintptr_t length, + uintptr_t page_size, + rtems_attribute attribute_set, + rtems_id *id +); + +/** + * @brief rtems_region_extend + * + * This routine implements the rtems_region_extend directive. The + * region will have the name name. The memory area managed by + * the region will be attempted to be grown by length bytes using + * the memory starting at starting_address. + */ +rtems_status_code rtems_region_extend( + rtems_id id, + void *starting_address, + uintptr_t length +); + +/** + * @brief rtems_region_ident + * + * This routine implements the rtems_region_ident directive. + * This directive returns the region ID associated with name. + * If more than one region is named name, then the region + * to which the ID belongs is arbitrary. + */ +rtems_status_code rtems_region_ident( + rtems_name name, + rtems_id *id +); + +/** + * @brief rtems_region_get_information + * + * This routine implements the rtems_region_get_information directive. + * This directive returns information about the heap associated with + * this region. + */ +rtems_status_code rtems_region_get_information( + rtems_id id, + Heap_Information_block *the_info +); + +/** + * @brief rtems_region_get_free_information + * + * This routine implements the rtems_region_get_free_information directive. + * This directive returns information about the free blocks in the + * heap associated with this region. + */ +rtems_status_code rtems_region_get_free_information( + rtems_id id, + Heap_Information_block *the_info +); + +/** + * @brief rtems_region_delete + * + * This routine implements the rtems_region_delete directive. The + * region indicated by ID is deleted. + */ +rtems_status_code rtems_region_delete( + rtems_id id +); + +/** + * @brief rtems_region_get_segment + * + * This routine implements the rtems_region_get_segment directive. It + * attempts to allocate a segment from the region associated with ID. + * If a segment of the requested size can be allocated, its address + * is returned in segment. If no segment is available, then the task + * may return immediately or block waiting for a segment with an optional + * timeout of timeout clock ticks. Whether the task blocks or returns + * immediately is based on the no_wait option in the option_set. + */ +rtems_status_code rtems_region_get_segment( + rtems_id id, + uintptr_t size, + rtems_option option_set, + rtems_interval timeout, + void **segment +); + +/** + * @brief rtems_region_get_segment_size + * + * This routine implements the rtems_region_get_segment_size directive. It + * returns the size in bytes of the specified user memory area. + */ +rtems_status_code rtems_region_get_segment_size( + rtems_id id, + void *segment, + uintptr_t *size +); + +/** + * @brief rtems_region_return_segment + * + * This routine implements the rtems_region_return_segment directive. It + * frees the segment to the region associated with ID. The segment must + * have been previously allocated from the same region. If freeing the + * segment results in enough memory being available to satisfy the + * rtems_region_get_segment of the first blocked task, then that task and as + * many subsequent tasks as possible will be unblocked with their requests + * satisfied. + */ +rtems_status_code rtems_region_return_segment( + rtems_id id, + void *segment +); + +/** + * @brief rtems_region_resize_segment + * + * This routine implements the rtems_region_resize_segment directive. It + * tries to resize segment in the region associated with 'id' to the new size + * 'size' in place. The first 'size' or old size bytes of the segment + * (whatever is less) are guaranteed to remain unmodified. The segment must + * have been previously allocated from the same region. If resizing the + * segment results in enough memory being available to satisfy the + * rtems_region_get_segment of the first blocked task, then that task and as + * many subsequent tasks as possible will be unblocked with their requests + * satisfied. + * Returns: + * RTEMS_SUCCESSFUL - operation successful + * RTEMS_UNSATISFIED - the segment can't be resized in place + * any other code - failure. + * On RTEMS_SUCCESSFUL or RTEMS_UNSATISFIED exit it returns into the + * 'old_size' the old size in bytes of the user memory area of the specified + * segment. + */ +rtems_status_code rtems_region_resize_segment( + rtems_id id, + void *segment, + uintptr_t size, + uintptr_t *old_size +); + +#ifndef __RTEMS_APPLICATION__ +#include <rtems/rtems/region.inl> +/** + * @brief Region_Process_queue + * + * This is a helper routine which is invoked any time memory is + * freed. It looks at the set of waiting tasks and attempts to + * satisfy all outstanding requests. + */ +extern void _Region_Process_queue(Region_Control *the_region); + +#endif + +#if defined(RTEMS_MULTIPROCESSING) +#include <rtems/rtems/regionmp.h> +#endif + +/** + * @brief _Region_Debug_Walk + * + * This routine is invoked to verify the integrity of a heap associated + * with the_region. + */ +#ifdef RTEMS_DEBUG + +#define _Region_Debug_Walk( _the_region, _source ) \ + do { \ + if ( rtems_debug_is_enabled( RTEMS_DEBUG_REGION ) ) \ + _Heap_Walk( &(_the_region)->Memory, _source, false ); \ + } while ( 0 ) + +#else + +#define _Region_Debug_Walk( _the_region, _source ) + +#endif + +#ifdef __cplusplus +} +#endif + +/**@}*/ + +#endif +/* end of include file */ diff --git a/cpukit/rtems/include/rtems/rtems/regionmp.h b/cpukit/rtems/include/rtems/rtems/regionmp.h new file mode 100644 index 0000000000..b748aba8e8 --- /dev/null +++ b/cpukit/rtems/include/rtems/rtems/regionmp.h @@ -0,0 +1,155 @@ +/** + * @file rtems/rtems/regionmp.h + * + * This include file contains all the constants and structures associated + * with the Multiprocessing Support in the Region Manager. + */ + +/* 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.com/license/LICENSE. + * + * $Id$ + */ + +#ifndef _RTEMS_RTEMS_REGIONMP_H +#define _RTEMS_RTEMS_REGIONMP_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include <rtems/score/mppkt.h> +#include <rtems/score/object.h> +#include <rtems/score/thread.h> + +#include <rtems/rtems/options.h> +#include <rtems/rtems/region.h> + +/** + * @defgroup ClassicRegionMP Region MP Support + * + * @ingroup ClassicMP + * + * This encapsulates functionality which XXX + */ +/**@{*/ + +/** + * The following enumerated type defines the list of + * remote region operations. + */ +typedef enum { + REGION_MP_ANNOUNCE_CREATE = 0, + REGION_MP_ANNOUNCE_DELETE = 1, + REGION_MP_EXTRACT_PROXY = 2, + REGION_MP_GET_SEGMENT_REQUEST = 3, + REGION_MP_GET_SEGMENT_RESPONSE = 4, + REGION_MP_RETURN_SEGMENT_REQUEST = 5, + REGION_MP_RETURN_SEGMENT_RESPONSE = 6 +} Region_MP_Remote_operations; + +/** + * The following data structure defines the packet used to perform + * remote region operations. + */ +typedef struct { + rtems_packet_prefix Prefix; + Region_MP_Remote_operations operation; + rtems_name name; + rtems_option option_set; + uint32_t size; + Objects_Id proxy_id; + void *segment; +} Region_MP_Packet; + +/** + * @brief _Region_MP_Send_process_packet + * + * This routine performs a remote procedure call so that a + * process operation can be performed on another node. + */ +void _Region_MP_Send_process_packet ( + Region_MP_Remote_operations operation, + Objects_Id region_id, + rtems_name name, + Objects_Id proxy_id +); + +/** + * @brief _Region_MP_Send_request_packet + * + * This routine performs a remote procedure call so that a + * directive operation can be initiated on another node. + */ +rtems_status_code _Region_MP_Send_request_packet ( + Region_MP_Remote_operations operation, + Objects_Id region_id, + void *segment, + intptr_t size, + rtems_option option_set, + rtems_interval timeout +); + +/** + * @brief _Region_MP_Send_response_packet + * + * This routine performs a remote procedure call so that a + * directive can be performed on another node. + */ +void _Region_MP_Send_response_packet ( + Region_MP_Remote_operations operation, + Objects_Id region_id, + Thread_Control *the_thread +); + +/** + * @brief _Region_MP_Process_packet + * + * This routine performs the actions specific to this package for + * the request from another node. + */ +void _Region_MP_Process_packet ( + rtems_packet_prefix *the_packet_prefix +); + +/* + * @brief _Region_MP_Send_object_was_deleted + * + * This routine is invoked indirectly by the thread queue + * when a proxy has been removed from the thread queue and + * the remote node must be informed of this. + * + * This routine is not needed by the Region since a region + * cannot be deleted when segments are in use. + */ + +/** + * @brief _Region_MP_Send_extract_proxy + * + * This routine is invoked when a task is deleted and it + * has a proxy which must be removed from a thread queue and + * the remote node must be informed of this. + */ +void _Region_MP_Send_extract_proxy ( + void *argument +); + +/** + * @brief _Region_MP_Get_packet + * + * This function is used to obtain a region mp packet. + */ +Region_MP_Packet *_Region_MP_Get_packet ( void ); + +#ifdef __cplusplus +} +#endif + +/**@}*/ + +#endif +/* end of file */ diff --git a/cpukit/rtems/include/rtems/rtems/rtemsapi.h b/cpukit/rtems/include/rtems/rtems/rtemsapi.h new file mode 100644 index 0000000000..d75dbb0490 --- /dev/null +++ b/cpukit/rtems/include/rtems/rtems/rtemsapi.h @@ -0,0 +1,32 @@ +/** + * @file rtems/rtems/rtemsapi.h + * + * RTEMS API Support + */ + +/* 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.com/license/LICENSE. + * + * $Id$ + */ + +#ifndef _RTEMS_RTEMS_RTEMSAPI_H +#define _RTEMS_RTEMS_RTEMSAPI_H + +#include <rtems/config.h> + +/** + * _RTEMS_API_Initialize + * + * This routine initializes the RTEMS API by invoking the initialization + * routine for each RTEMS manager with the appropriate parameters + * from the configuration_table. + */ +void _RTEMS_API_Initialize(void); + +#endif +/* end of include file */ diff --git a/cpukit/rtems/include/rtems/rtems/sem.h b/cpukit/rtems/include/rtems/rtems/sem.h new file mode 100644 index 0000000000..b4443241c0 --- /dev/null +++ b/cpukit/rtems/include/rtems/rtems/sem.h @@ -0,0 +1,244 @@ +/** + * @file rtems/rtems/sem.h + * + * This include file contains all the constants and structures associated + * with the Semaphore Manager. This manager utilizes standard Dijkstra + * counting semaphores to provide synchronization and mutual exclusion + * capabilities. + * + * Directives provided are: + * + * - create a semaphore + * - get an ID of a semaphore + * - delete a semaphore + * - acquire a semaphore + * - release a semaphore + */ + +/* 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.com/license/LICENSE. + * + * $Id$ + */ + +#ifndef _RTEMS_RTEMS_SEM_H +#define _RTEMS_RTEMS_SEM_H + +/** + * This constant is defined to extern most of the time when using + * this header file. However by defining it to nothing, the data + * declared in this header file can be instantiated. This is done + * in a single per manager file. + */ +#ifndef RTEMS_SEM_EXTERN +#define RTEMS_SEM_EXTERN extern +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#include <rtems/rtems/types.h> +#include <rtems/rtems/options.h> +#include <rtems/rtems/support.h> +#include <rtems/rtems/tasks.h> +#include <rtems/rtems/attr.h> +#include <rtems/score/coremutex.h> +#include <rtems/score/object.h> +#include <rtems/score/coresem.h> + +/** + * @defgroup ClassicSem Semaphores + * + * @ingroup ClassicRTEMS + * + * This encapsulates functionality related to the Classic API + * Semaphore Manager. + */ +/**@{*/ + +/** + * The following defines the control block used to manage each semaphore. + */ +typedef struct { + /** This field is the object management portion of a Semaphore instance. */ + Objects_Control Object; + + /** + * This is the Classic API attribute provided to the create directive. + * It is translated into behavioral attributes on the SuperCore Semaphore + * or Mutex instance. + */ + rtems_attribute attribute_set; + + /** + * This contains the memory associated with the SuperCore Semaphore or + * Mutex instance that provides the primary functionality of each + * Classic API Semaphore instance. The structure used is dependent + * on the attributes specified by the user on the create directive. + * + * @note Only one of these has meaning in a particular Classic API + * Semaphore instance. + */ + union { + /** + * This is the SuperCore Mutex instance associated with this Classic + * API Semaphore instance. + */ + CORE_mutex_Control mutex; + + /** + * This is the SuperCore Semaphore instance associated with this Classic + * API Semaphore instance. + */ + CORE_semaphore_Control semaphore; + } Core_control; +} Semaphore_Control; + +/** + * The following defines the information control block used to manage + * this class of objects. + */ +RTEMS_SEM_EXTERN Objects_Information _Semaphore_Information; + +/** + * @brief Semaphore_Manager_initialization + * + * This routine performs the initialization necessary for this manager. + */ +void _Semaphore_Manager_initialization(void); + +/** + * @brief rtems_semaphore_create + * + * This routine implements the rtems_semaphore_create directive. The + * semaphore will have the name name. The starting count for + * the semaphore is count. The attribute_set determines if + * the semaphore is global or local and the thread queue + * discipline. It returns the id of the created semaphore in ID. + */ +rtems_status_code rtems_semaphore_create( + rtems_name name, + uint32_t count, + rtems_attribute attribute_set, + rtems_task_priority priority_ceiling, + rtems_id *id +); + +/** + * @brief rtems_semaphore_ident + * + * This routine implements the rtems_semaphore_ident directive. + * This directive returns the semaphore ID associated with name. + * If more than one semaphore is named name, then the semaphore + * to which the ID belongs is arbitrary. node indicates the + * extent of the search for the ID of the semaphore named name. + * The search can be limited to a particular node or allowed to + * encompass all nodes. + */ +rtems_status_code rtems_semaphore_ident( + rtems_name name, + uint32_t node, + rtems_id *id +); + +/** + * @brief rtems_semaphore_delete + * + * This routine implements the rtems_semaphore_delete directive. The + * semaphore indicated by ID is deleted. + */ +rtems_status_code rtems_semaphore_delete( + rtems_id id +); + +/** + * @brief rtems_semaphore_obtain + * + * This routine implements the rtems_semaphore_obtain directive. It + * attempts to obtain a unit from the semaphore associated with ID. + * If a unit can be allocated, the calling task will return immediately. + * If no unit is available, then the task may return immediately or + * block waiting for a unit with an optional timeout of timeout + * clock ticks. Whether the task blocks or returns immediately + * is based on the RTEMS_NO_WAIT option in the option_set. + */ +rtems_status_code rtems_semaphore_obtain( + rtems_id id, + rtems_option option_set, + rtems_interval timeout +); + +/** + * @brief rtems_semaphore_release + * + * This routine implements the rtems_semaphore_release directive. It + * frees a unit to the semaphore associated with ID. If a task was + * blocked waiting for a unit from this semaphore, then that task will + * be readied and the unit given to that task. Otherwise, the unit + * will be returned to the semaphore. + */ +rtems_status_code rtems_semaphore_release( + rtems_id id +); + +/** + * @brief rtems_semaphore_flush + * pending on the semaphore. + */ +rtems_status_code rtems_semaphore_flush( + rtems_id id +); + +/** + * @brief _Semaphore_Seize + * + * This routine attempts to receive a unit from the_semaphore. + * If a unit is available or if the RTEMS_NO_WAIT option is enabled in + * option_set, then the routine returns. Otherwise, the calling task + * is blocked until a unit becomes available. + */ +bool _Semaphore_Seize( + Semaphore_Control *the_semaphore, + uint32_t option_set +); + +/** + * @brief _Semaphore_Translate_core_mutex_return_code + * + * This function returns a RTEMS status code based on the mutex + * status code specified. + */ +rtems_status_code _Semaphore_Translate_core_mutex_return_code ( + uint32_t the_mutex_status +); + +/** + * @brief _Semaphore_Translate_core_semaphore_return_code + * + * This function returns a RTEMS status code based on the semaphore + * status code specified. + */ +rtems_status_code _Semaphore_Translate_core_semaphore_return_code ( + uint32_t the_mutex_status +); + +#ifndef __RTEMS_APPLICATION__ +#include <rtems/rtems/sem.inl> +#endif +#if defined(RTEMS_MULTIPROCESSING) +#include <rtems/rtems/semmp.h> +#endif + +#ifdef __cplusplus +} +#endif + +/**@}*/ + +#endif +/* end of include file */ diff --git a/cpukit/rtems/include/rtems/rtems/semmp.h b/cpukit/rtems/include/rtems/rtems/semmp.h new file mode 100644 index 0000000000..f3a06aeb2f --- /dev/null +++ b/cpukit/rtems/include/rtems/rtems/semmp.h @@ -0,0 +1,175 @@ +/** + * @file rtems/rtems/semmp.h + * + * This include file contains all the constants and structures associated + * with the Multiprocessing Support in the Semaphore Manager. + */ + +/* 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.com/license/LICENSE. + * + * $Id$ + */ + +#ifndef _RTEMS_RTEMS_SEMMP_H +#define _RTEMS_RTEMS_SEMMP_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include <rtems/score/mppkt.h> +#include <rtems/score/object.h> +#include <rtems/rtems/options.h> +#include <rtems/rtems/sem.h> +#include <rtems/score/thread.h> +#include <rtems/score/watchdog.h> + +/** + * @defgroup ClassicSEM Semaphore MP Support + * + * @ingroup ClassicMP + * + * This encapsulates functionality which XXX + */ +/**@{*/ + +/** + * The following enumerated type defines the list of + * remote semaphore operations. + */ +typedef enum { + SEMAPHORE_MP_ANNOUNCE_CREATE = 0, + SEMAPHORE_MP_ANNOUNCE_DELETE = 1, + SEMAPHORE_MP_EXTRACT_PROXY = 2, + SEMAPHORE_MP_OBTAIN_REQUEST = 3, + SEMAPHORE_MP_OBTAIN_RESPONSE = 4, + SEMAPHORE_MP_RELEASE_REQUEST = 5, + SEMAPHORE_MP_RELEASE_RESPONSE = 6 +} Semaphore_MP_Remote_operations; + +/** + * The following data structure defines the packet used to perform + * remote semaphore operations. + */ +typedef struct { + rtems_packet_prefix Prefix; + Semaphore_MP_Remote_operations operation; + rtems_name name; + rtems_option option_set; + Objects_Id proxy_id; +} Semaphore_MP_Packet; + +/** + * @brief Semaphore_MP_Send_process_packet + * + * This routine performs a remote procedure call so that a + * process operation can be performed on another node. + */ +void _Semaphore_MP_Send_process_packet ( + Semaphore_MP_Remote_operations operation, + Objects_Id semaphore_id, + rtems_name name, + Objects_Id proxy_id +); + +/** + * @brief Semaphore_MP_Send_request_packet + * + * This routine performs a remote procedure call so that a + * directive operation can be initiated on another node. + */ +rtems_status_code _Semaphore_MP_Send_request_packet ( + Semaphore_MP_Remote_operations operation, + Objects_Id semaphore_id, + rtems_option option_set, + rtems_interval timeout +); + +/** + * @brief Semaphore_MP_Send_response_packet + * + * This routine performs a remote procedure call so that a + * directive can be performed on another node. + */ +void _Semaphore_MP_Send_response_packet ( + Semaphore_MP_Remote_operations operation, + Objects_Id semaphore_id, + Thread_Control *the_thread +); + +/** + * @brief Semaphore_MP_Process_packet + * + * This routine performs the actions specific to this package for + * the request from another node. + */ +void _Semaphore_MP_Process_packet ( + rtems_packet_prefix *the_packet_prefix +); + +/** + * @brief Semaphore_MP_Send_object_was_deleted + * + * This routine is invoked indirectly by the thread queue + * when a proxy has been removed from the thread queue and + * the remote node must be informed of this. + */ +void _Semaphore_MP_Send_object_was_deleted ( + Thread_Control *the_proxy +); + +/** + * @brief Semaphore_MP_Send_extract_proxy + * + * This routine is invoked when a task is deleted and it + * has a proxy which must be removed from a thread queue and + * the remote node must be informed of this. + */ +void _Semaphore_MP_Send_extract_proxy ( + void *argument +); + +/** + * @brief Semaphore_MP_Get_packet + * + * This function is used to obtain a semaphore mp packet. + */ +Semaphore_MP_Packet *_Semaphore_MP_Get_packet ( void ); + +/** + * @brief _Semaphore_Core_mutex_mp_support + * + * This function processes the global actions necessary for remote + * accesses to a global semaphore based on a core mutex. This function + * is called by the core. + */ +void _Semaphore_Core_mutex_mp_support ( + Thread_Control *the_thread, + Objects_Id id +); + +/** + * @brief Semaphore_Core_mp_support + * + * This function processes the global actions necessary for remote + * accesses to a global semaphore based on a core semaphore. This function + * is called by the core. + */ +void _Semaphore_Core_semaphore_mp_support ( + Thread_Control *the_thread, + Objects_Id id +); + +#ifdef __cplusplus +} +#endif + +/**@}*/ + +#endif +/* end of file */ diff --git a/cpukit/rtems/include/rtems/rtems/signal.h b/cpukit/rtems/include/rtems/rtems/signal.h new file mode 100644 index 0000000000..1517dce734 --- /dev/null +++ b/cpukit/rtems/include/rtems/rtems/signal.h @@ -0,0 +1,87 @@ +/** + * @file rtems/rtems/signal.h + * + * This include file contains all the constants and structures associated + * with the Signal Manager. This manager provides capabilities required + * for asynchronous communication between tasks via signal sets. + * + * Directives provided are: + * + * + establish an asynchronous signal routine + * + send a signal set to a task + */ + +/* 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.com/license/LICENSE. + * + * $Id$ + */ + +#ifndef _RTEMS_RTEMS_SIGNAL_H +#define _RTEMS_RTEMS_SIGNAL_H + +/** + * @defgroup ClassicSignal Signals + * + * @ingroup ClassicRTEMS + * + * This encapsulates functionality which XXX + */ +/**@{*/ + +#include <rtems/rtems/asr.h> +#include <rtems/rtems/modes.h> +#include <rtems/score/object.h> +#include <rtems/rtems/status.h> +#include <rtems/rtems/types.h> + +#ifdef __cplusplus +extern "C" { +#endif +/** + * @brief _Signal_Manager_initialization + * + * This routine performs the initialization necessary for this manager. + */ +void _Signal_Manager_initialization( void ); + +/** + * @brief rtems_signal_catch + * + * This routine implements the rtems_signal_catch directive. This directive + * is used to establish asr_handler as the Asynchronous Signal Routine + * (RTEMS_ASR) for the calling task. The asr_handler will execute with a + * mode of mode_set. + */ +rtems_status_code rtems_signal_catch( + rtems_asr_entry asr_handler, + rtems_mode mode_set +); + +/** + * @brief rtems_signal_send + * + * This routine implements the rtems_signal_send directive. This directive + * sends the signal_set to the task specified by ID. + */ +rtems_status_code rtems_signal_send( + rtems_id id, + rtems_signal_set signal_set +); + +#if defined(RTEMS_MULTIPROCESSING) +#include <rtems/rtems/signalmp.h> +#endif + +#ifdef __cplusplus +} +#endif + +/**@}*/ + +#endif +/* end of include file */ diff --git a/cpukit/rtems/include/rtems/rtems/signalmp.h b/cpukit/rtems/include/rtems/rtems/signalmp.h new file mode 100644 index 0000000000..46e6a60538 --- /dev/null +++ b/cpukit/rtems/include/rtems/rtems/signalmp.h @@ -0,0 +1,138 @@ +/** + * @file rtems/rtems/signalmp.h + * + * This include file contains all the constants and structures associated + * with the Multiprocessing Support in the Signal Manager. + */ + +/* 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.com/license/LICENSE. + * + * $Id$ + */ + +#ifndef _RTEMS_RTEMS_SIGNALMP_H +#define _RTEMS_RTEMS_SIGNALMP_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include <rtems/rtems/asr.h> +#include <rtems/score/mppkt.h> +#include <rtems/score/object.h> +#include <rtems/score/thread.h> +#include <rtems/score/watchdog.h> + +/** + * @defgroup ClassicSignalMP Signal MP Support + * + * @ingroup ClassicMP + * + * This encapsulates functionality which XXX + */ +/**{*/ + +/** + * The following enumerated type defines the list of + * remote signal operations. + */ +typedef enum { + SIGNAL_MP_SEND_REQUEST = 0, + SIGNAL_MP_SEND_RESPONSE = 1 +} Signal_MP_Remote_operations; + +/** + * The following data structure defines the packet used to perform + * remote signal operations. + */ +typedef struct { + rtems_packet_prefix Prefix; + Signal_MP_Remote_operations operation; + rtems_signal_set signal_in; +} Signal_MP_Packet; + +/* + * @brief Signal_MP_Send_process_packet + * + * This routine performs a remote procedure call so that a + * process operation can be performed on another node. + * + * This routine is not needed since there are no process + * packets to be sent by this manager. + */ + +/** + * @brief Signal_MP_Send_request_packet + * + * This routine performs a remote procedure call so that a + * directive operation can be initiated on another node. + */ +rtems_status_code _Signal_MP_Send_request_packet ( + Signal_MP_Remote_operations operation, + Objects_Id task_id, + rtems_signal_set signal_in +); + +/** + * @brief Signal_MP_Send_response_packet + * + * This routine performs a remote procedure call so that a + * directive can be performed on another node. + */ +void _Signal_MP_Send_response_packet ( + Signal_MP_Remote_operations operation, + Thread_Control *the_thread +); + +/** + * @brief Signal_MP_Process_packet + * + * This routine performs the actions specific to this package for + * the request from another node. + */ +void _Signal_MP_Process_packet ( + rtems_packet_prefix *the_packet_prefix +); + +/* + * @brief Signal_MP_Send_object_was_deleted + * + * This routine is invoked indirectly by the thread queue + * when a proxy has been removed from the thread queue and + * the remote node must be informed of this. + * + * This routine is not needed since there are no objects + * deleted by this manager. + */ + +/* + * @brief Signal_MP_Send_extract_proxy + * + * This routine is invoked when a task is deleted and it + * has a proxy which must be removed from a thread queue and + * the remote node must be informed of this. + * + * This routine is not needed since there are no objects + * deleted by this manager. + */ + +/** + * @brief Signal_MP_Get_packet + * + * This function is used to obtain a signal mp packet. + */ +Signal_MP_Packet *_Signal_MP_Get_packet ( void ); + +#ifdef __cplusplus +} +#endif + +/**@}*/ + +#endif +/* end of file */ diff --git a/cpukit/rtems/include/rtems/rtems/status.h b/cpukit/rtems/include/rtems/rtems/status.h new file mode 100644 index 0000000000..0f42a8b54d --- /dev/null +++ b/cpukit/rtems/include/rtems/rtems/status.h @@ -0,0 +1,220 @@ +/** + * @file rtems/rtems/status.h + * + * This include file contains the status codes returned from the + * executive directives. + */ + +/* 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.com/license/LICENSE. + * + * $Id$ + */ + +#ifndef _RTEMS_RTEMS_STATUS_H +#define _RTEMS_RTEMS_STATUS_H + +/** + * @defgroup ClassicStatus Status Codes + * + * @ingroup ClassicRTEMS + * + * This encapsulates functionality which XXX + */ +/**@{*/ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Classic API Status + * + * This enumerates the possible status values returned b + * Classic API directives. + */ +typedef enum { + /** + * This is the status to indicate successful completion. + */ + RTEMS_SUCCESSFUL = 0, + /** + * This is the status to indicate that a thread exited. + */ + RTEMS_TASK_EXITTED = 1, + /** + * This is the status to indicate multiprocessing is not configured. + */ + RTEMS_MP_NOT_CONFIGURED = 2, + /** + * This is the status to indicate that the object name was invalid. + */ + RTEMS_INVALID_NAME = 3, + /** + * This is the status to indicate that the object Id was invalid. + */ + RTEMS_INVALID_ID = 4, + /** + * This is the status to indicate you have attempted to create too many + * instances of a particular object class. + */ + RTEMS_TOO_MANY = 5, + /** + * This is the status to indicate that a blocking directive timed out. + */ + RTEMS_TIMEOUT = 6, + /** + * This is the status to indicate the the object was deleted + * while the task was blocked waiting. + */ + RTEMS_OBJECT_WAS_DELETED = 7, + /** + * This is the status to indicate that the specified size was invalid. + */ + RTEMS_INVALID_SIZE = 8, + /** + * This is the status to indicate that the specified address is invalid. + */ + RTEMS_INVALID_ADDRESS = 9, + /** + * This is the status to indicate that the specified number was invalid. + */ + RTEMS_INVALID_NUMBER = 10, + /** + * This is the status to indicate that the item has not been initialized. + */ + RTEMS_NOT_DEFINED = 11, + /** + * This is the status to indicate that the object still has + * resources in use. + */ + RTEMS_RESOURCE_IN_USE = 12, + /** + * This is the status to indicate that the request was not satisfied. + */ + RTEMS_UNSATISFIED = 13, + /** + * This is the status to indicate that a thread is in wrong state + * was in the wrong execution state for the requested operation. + */ + RTEMS_INCORRECT_STATE = 14, + /** + * This is the status to indicate thread was already suspended. + */ + RTEMS_ALREADY_SUSPENDED = 15, + /** + * This is the status to indicate that the operation is illegal + * on calling thread. + */ + RTEMS_ILLEGAL_ON_SELF = 16, + /** + * This is the status to indicate illegal for remote object. + */ + RTEMS_ILLEGAL_ON_REMOTE_OBJECT = 17, + /** + * This is the status to indicate that the operation should not be + * called from from this excecution environment. + */ + RTEMS_CALLED_FROM_ISR = 18, + /** + * This is the status to indicate that an invalid thread priority + * was provided. + */ + RTEMS_INVALID_PRIORITY = 19, + /** + * This is the status to indicate that the specified date/time was invalid. + */ + RTEMS_INVALID_CLOCK = 20, + /** + * This is the status to indicate that the specified node Id was invalid. + */ + RTEMS_INVALID_NODE = 21, + /** + * This is the status to indicate that the directive was not configured. + */ + RTEMS_NOT_CONFIGURED = 22, + /** + * This is the status to indicate that the caller is not the + * owner of the resource. + */ + RTEMS_NOT_OWNER_OF_RESOURCE = 23, + /** + * This is the status to indicate the the directive or requested + * portion of the directive is not implemented. This is a hint + * that you have stumbled across an opportunity to submit code + * to the RTEMS Project. + */ + RTEMS_NOT_IMPLEMENTED = 24, + /** + * This is the status to indicate that an internal RTEMS inconsistency + * was detected. + */ + RTEMS_INTERNAL_ERROR = 25, + /** + * This is the status to indicate that the directive attempted to allocate + * memory but was unable to do so. + */ + RTEMS_NO_MEMORY = 26, + /** + * This is the status to indicate an driver IO error. + */ + RTEMS_IO_ERROR = 27, + /** + * This is the status is used internally to RTEMS when performing + * operations on behalf of remote tasks. This is referred to as + * proxying operations and this status indicates that the operation + * could not be completed immediately and the "proxy is blocking." + * + * @note This status will @b NOT be returned to the user. + */ + RTEMS_PROXY_BLOCKING = 28 +} rtems_status_code; + +/** + * This is the lowest valid value for a Classic API status code. + */ +#define RTEMS_STATUS_CODES_FIRST RTEMS_SUCCESSFUL + +/** + * This is the highest valid value for a Classic API status code. + */ +#define RTEMS_STATUS_CODES_LAST RTEMS_PROXY_BLOCKING + +/** + * This array is used to map SuperCore Object Handler return + * codes to Classic API status codes. + */ +#ifdef RTEMS_API_INIT +const rtems_status_code _Status_Object_name_errors_to_status[] = { + /** This maps OBJECTS_SUCCESSFUL to RTEMS_SUCCESSFUL. */ + RTEMS_SUCCESSFUL, + /** This maps OBJECTS_INVALID_NAME to RTEMS_INVALID_NAME. */ + RTEMS_INVALID_NAME, + /** This maps OBJECTS_INVALID_ADDRESS to RTEMS_INVALID_NAME. */ + RTEMS_INVALID_ADDRESS, + /** This maps OBJECTS_INVALID_ID to RTEMS_INVALID_ADDRESS. */ + RTEMS_INVALID_ID, + /** This maps OBJECTS_INVALID_NODE to RTEMS_INVALID_NODE. */ + RTEMS_INVALID_NODE +}; +#else +extern rtems_status_code _Status_Object_name_errors_to_status[]; +#endif + +/* + * Applications are allowed to use the macros to compare status codes. + */ +#include <rtems/rtems/status.inl> + +#ifdef __cplusplus +} +#endif + +/**@}*/ + +#endif +/* end of include file */ diff --git a/cpukit/rtems/include/rtems/rtems/support.h b/cpukit/rtems/include/rtems/rtems/support.h new file mode 100644 index 0000000000..220411d984 --- /dev/null +++ b/cpukit/rtems/include/rtems/rtems/support.h @@ -0,0 +1,117 @@ +/** + * @file + * + * @ingroup ClassicRTEMS + * + * @ingroup ClassicRTEMSWorkspace + * + * @brief Classic API support. + */ + +/* 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.com/license/LICENSE. + * + * $Id$ + */ + +#ifndef _RTEMS_RTEMS_SUPPORT_H +#define _RTEMS_RTEMS_SUPPORT_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include <rtems/rtems/types.h> + +/** + * @addtogroup ClassicRTEMS + * + * @{ + */ + +/** + * @brief Returns the number of micro seconds for the milli seconds value @a _ms. + */ +#define RTEMS_MILLISECONDS_TO_MICROSECONDS(_ms) \ + TOD_MILLISECONDS_TO_MICROSECONDS(_ms) + +/** + * @brief Returns the number of ticks for the milli seconds value @a _ms. + */ +#define RTEMS_MILLISECONDS_TO_TICKS(_ms) \ + (TOD_MILLISECONDS_TO_MICROSECONDS(_ms) / \ + rtems_configuration_get_microseconds_per_tick()) + +/** + * @brief Returns the number of ticks for the micro seconds value @a _us. + */ +#define RTEMS_MICROSECONDS_TO_TICKS(_us) \ + ((_us) / rtems_configuration_get_microseconds_per_tick()) + +/** @} */ + +/** + * @defgroup ClassicRTEMSWorkspace Workspace + * + * @ingroup ClassicRTEMS + * + * Workspace definitions. + * + * @{ + */ + +/** + * @brief Gets workspace information. + * + * Returns information about the heap that is used as the RTEMS Executive + * Workspace in @a the_info. + * + * Returns @c true if successful, and @a false otherwise. + */ +bool rtems_workspace_get_information( + Heap_Information_block *the_info +); + +/** + * @brief Allocates memory from the workspace. + * + * A number of @a bytes bytes will be allocated from the RTEMS Executive + * Workspace and returned in @a pointer. + * + * Returns @c true if successful, and @a false otherwise. + */ +bool rtems_workspace_allocate( + size_t bytes, + void **pointer +); + +/** + * @brief Frees memory allocated from the workspace. + * + * This frees the memory indicated by @a pointer that was allocated from the + * RTEMS Executive Workspace. + * + * Returns @c true if successful, and @a false otherwise. + */ +bool rtems_workspace_free( + void *pointer +); + +/** @} */ + +#ifndef __RTEMS_APPLICATION__ +#include <rtems/rtems/support.inl> +#endif + +#ifdef __cplusplus +} +#endif + +/**@}*/ + +#endif +/* end of include file */ diff --git a/cpukit/rtems/include/rtems/rtems/taskmp.h b/cpukit/rtems/include/rtems/rtems/taskmp.h new file mode 100644 index 0000000000..16bf205d8d --- /dev/null +++ b/cpukit/rtems/include/rtems/rtems/taskmp.h @@ -0,0 +1,156 @@ +/** + * @file rtems/rtems/taskmp.h + * + * This include file contains all the constants and structures associated + * with the multiprocessing support in the task manager. + */ + +/* 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.com/license/LICENSE. + * + * $Id$ + */ + +#ifndef _RTEMS_RTEMS_TASKMP_H +#define _RTEMS_RTEMS_TASKMP_H + +#include <rtems/score/mppkt.h> +#include <rtems/score/object.h> +#include <rtems/rtems/options.h> +#include <rtems/score/priority.h> +#include <rtems/rtems/tasks.h> +#include <rtems/score/thread.h> + +/** + * @defgroup ClassicTaskMP Task MP Support + * + * @ingroup ClassicMP + * + * This encapsulates functionality which XXX + */ +/**@{*/ + +#ifdef __cplusplus +extern "C" { +#endif +/** + * The following enumerated type defines the list of + * remote task operations. + */ +typedef enum { + RTEMS_TASKS_MP_ANNOUNCE_CREATE = 0, + RTEMS_TASKS_MP_ANNOUNCE_DELETE = 1, + RTEMS_TASKS_MP_SUSPEND_REQUEST = 2, + RTEMS_TASKS_MP_SUSPEND_RESPONSE = 3, + RTEMS_TASKS_MP_RESUME_REQUEST = 4, + RTEMS_TASKS_MP_RESUME_RESPONSE = 5, + RTEMS_TASKS_MP_SET_PRIORITY_REQUEST = 6, + RTEMS_TASKS_MP_SET_PRIORITY_RESPONSE = 7, + RTEMS_TASKS_MP_GET_NOTE_REQUEST = 8, + RTEMS_TASKS_MP_GET_NOTE_RESPONSE = 9, + RTEMS_TASKS_MP_SET_NOTE_REQUEST = 10, + RTEMS_TASKS_MP_SET_NOTE_RESPONSE = 11 +} RTEMS_tasks_MP_Remote_operations; + +/** + * The following data structure defines the packet used to perform + * remote task operations. + */ +typedef struct { + rtems_packet_prefix Prefix; + RTEMS_tasks_MP_Remote_operations operation; + rtems_name name; + rtems_task_priority the_priority; + uint32_t notepad; + uint32_t note; +} RTEMS_tasks_MP_Packet; + +/** + * @brief _RTEMS_tasks_MP_Send_process_packet + * + * This routine performs a remote procedure call so that a + * process operation can be performed on another node. + */ +void _RTEMS_tasks_MP_Send_process_packet ( + RTEMS_tasks_MP_Remote_operations operation, + Objects_Id task_id, + rtems_name name +); + +/** + * @brief _RTEMS_tasks_MP_Send_request_packet + * + * This routine performs a remote procedure call so that a + * directive operation can be initiated on another node. + */ +rtems_status_code _RTEMS_tasks_MP_Send_request_packet ( + RTEMS_tasks_MP_Remote_operations operation, + Objects_Id task_id, + rtems_task_priority the_priority, + uint32_t notepad, + uint32_t note +); + +/** + * @brief _RTEMS_tasks_MP_Send_response_packet + * + * This routine performs a remote procedure call so that a + * directive can be performed on another node. + */ +void _RTEMS_tasks_MP_Send_response_packet ( + RTEMS_tasks_MP_Remote_operations operation, + Thread_Control *the_thread +); + +/** + * @brief _RTEMS_tasks_MP_Process_packet + * + * This routine performs the actions specific to this package for + * the request from another node. + */ +void _RTEMS_tasks_MP_Process_packet ( + rtems_packet_prefix *the_packet_prefix +); + +/** + * @brief _RTEMS_tasks_MP_Send_object_was_deleted + * + * This routine is invoked indirectly by the thread queue + * when a proxy has been removed from the thread queue and + * the remote node must be informed of this. + * + * This routine is not needed by RTEMS_tasks since a task + * cannot be deleted when segments are in use. + */ + +/* + * _RTEMS_tasks_MP_Send_extract_proxy + * + * This routine is invoked when a task is deleted and it + * has a proxy which must be removed from a thread queue and + * the remote node must be informed of this. + * + * This routine is not needed since there are no objects + * deleted by this manager. + * + */ + +/** + * @brief _RTEMS_tasks_MP_Get_packet + * + * This function is used to obtain a task mp packet. + */ +RTEMS_tasks_MP_Packet *_RTEMS_tasks_MP_Get_packet ( void ); + +#ifdef __cplusplus +} +#endif + +/**@}*/ + +#endif +/* end of file */ diff --git a/cpukit/rtems/include/rtems/rtems/tasks.h b/cpukit/rtems/include/rtems/rtems/tasks.h new file mode 100644 index 0000000000..1e9a9c57e6 --- /dev/null +++ b/cpukit/rtems/include/rtems/rtems/tasks.h @@ -0,0 +1,505 @@ +/** + * @file rtems/rtems/tasks.h + * + * This include file contains all constants and structures associated + * with RTEMS tasks. This manager provides a comprehensive set of directives + * to create, delete, and administer tasks. + * + * Directives provided are: + * + * - create a task + * - get an ID of a task + * - start a task + * - restart a task + * - delete a task + * - suspend a task + * - resume a task + * - set a task's priority + * - change the current task's mode + * - get a task notepad entry + * - set a task notepad entry + * - wake up after interval + * - wake up when specified + */ + +/* 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.com/license/LICENSE. + * + * $Id$ + */ + +#ifndef _RTEMS_RTEMS_TASKS_H +#define _RTEMS_RTEMS_TASKS_H + +#include <rtems/score/object.h> +#include <rtems/score/states.h> +#include <rtems/score/thread.h> +#include <rtems/rtems/types.h> +#include <rtems/rtems/eventset.h> +#include <rtems/rtems/asr.h> +#include <rtems/rtems/attr.h> +#include <rtems/rtems/status.h> + +/** + * This constant is defined to extern most of the time when using + * this header file. However by defining it to nothing, the data + * declared in this header file can be instantiated. This is done + * in a single per manager file. + */ +#ifndef RTEMS_TASKS_EXTERN +#define RTEMS_TASKS_EXTERN extern +#endif + +/** + * @defgroup ClassicTasks Tasks + * + * @ingroup ClassicRTEMS + * + * This encapsulates functionality which X XX + */ +/**@{*/ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Constant to be used as the ID of current task + */ +#define RTEMS_SELF OBJECTS_ID_OF_SELF + +/** + * This constant is passed to the rtems_task_wake_after directive as the + * interval when a task wishes to yield the CPU. + */ +#define RTEMS_YIELD_PROCESSOR WATCHDOG_NO_TIMEOUT + +/** + * Define the type for an RTEMS API task priority. + */ +typedef Priority_Control rtems_task_priority; + +/** + * This is the constant used with the rtems_task_set_priority + * directive to indicate that the caller wants to obtain its + * current priority rather than set it as the name of the + * directive indicates. + */ +#define RTEMS_NO_PRIORITY RTEMS_CURRENT_PRIORITY + +/** + * This constant is the least valid value for a Classic API + * task priority. + */ +#define RTEMS_MINIMUM_PRIORITY (PRIORITY_MINIMUM + 1) + +/** + * This constant is the maximum valid value for a Classic API + * task priority. + * + * @note This is actually the priority of the IDLE thread so + * using this priority will result in having a task + * which never executes. This could be useful if you + * want to ensure that a task does not executes during + * certain operations such as a system mode change. + */ +#define RTEMS_MAXIMUM_PRIORITY PRIORITY_MAXIMUM + +/** + * The following constant is passed to rtems_task_set_priority when the + * caller wants to obtain the current priority. + */ +#define RTEMS_CURRENT_PRIORITY PRIORITY_MINIMUM + +/** This is used to indicate the lowest numbered notepad */ +#define RTEMS_NOTEPAD_FIRST 0 +/** This is used to indicate the notepad location 0. */ +#define RTEMS_NOTEPAD_0 0 +/** This is used to indicate the notepad location 1. */ +#define RTEMS_NOTEPAD_1 1 +/** This is used to indicate the notepad location 2. */ +#define RTEMS_NOTEPAD_2 2 +/** This is used to indicate the notepad location 3. */ +#define RTEMS_NOTEPAD_3 3 +/** This is used to indicate the notepad location 4. */ +#define RTEMS_NOTEPAD_4 4 +/** This is used to indicate the notepad location 5. */ +#define RTEMS_NOTEPAD_5 5 +/** This is used to indicate the notepad location 6. */ +#define RTEMS_NOTEPAD_6 6 +/** This is used to indicate the notepad location 7. */ +#define RTEMS_NOTEPAD_7 7 +/** This is used to indicate the notepad location 8. */ +#define RTEMS_NOTEPAD_8 8 +/** This is used to indicate the notepad location 9. */ +#define RTEMS_NOTEPAD_9 9 +/** This is used to indicate the notepad location 10. */ +#define RTEMS_NOTEPAD_10 10 +/** This is used to indicate the notepad location 11. */ +#define RTEMS_NOTEPAD_11 11 +/** This is used to indicate the notepad location 12. */ +#define RTEMS_NOTEPAD_12 12 +/** This is used to indicate the notepad location 13. */ +#define RTEMS_NOTEPAD_13 13 +/** This is used to indicate the notepad location 14. */ +#define RTEMS_NOTEPAD_14 14 +/** This is used to indicate the notepad location 15. */ +#define RTEMS_NOTEPAD_15 15 +/** This is used to indicate the highest numbered notepad. */ +#define RTEMS_NOTEPAD_LAST RTEMS_NOTEPAD_15 + +/** This is used to indicate the number of notepads available. */ +#define RTEMS_NUMBER_NOTEPADS (RTEMS_NOTEPAD_LAST+1) + +/** + * External API name for Thread_Control + */ +typedef Thread_Control rtems_tcb; + +/** + * The following defines the "return type" of an RTEMS task. + */ +typedef void rtems_task; + +/** + * The following defines the argument to an RTEMS task. + */ +typedef Thread_Entry_numeric_type rtems_task_argument; + +/** + * The following defines the type for the entry point of an RTEMS task. + */ +typedef rtems_task ( *rtems_task_entry )( + rtems_task_argument + ); + +/** + * The following records define the Initialization Tasks Table. + * Each entry contains the information required by RTEMS to + * create and start a user task automatically at executive + * initialization time. + */ +typedef struct { + /** This is the Initialization Task's name. */ + rtems_name name; + /** This is the Initialization Task's stack size. */ + size_t stack_size; + /** This is the Initialization Task's priority. */ + rtems_task_priority initial_priority; + /** This is the Initialization Task's attributes. */ + rtems_attribute attribute_set; + /** This is the Initialization Task's entry point. */ + rtems_task_entry entry_point; + /** This is the Initialization Task's initial mode. */ + rtems_mode mode_set; + /** This is the Initialization Task's argument. */ + rtems_task_argument argument; +} rtems_initialization_tasks_table; + +/** + * This is the API specific information required by each thread for + * the RTEMS API to function correctly. + * + * @note Notepads must be the last entry in the structure and memory + * will be taken away from this structure when allocated if + * notespads are disabled by the application configuration. + */ +typedef struct { + /** This field contains the pending events for this task. */ + rtems_event_set pending_events; + /** This field contains the event wait condition for this task. */ + rtems_event_set event_condition; + /** This field contains the Classic API Signal information for this task. */ + ASR_Information Signal; + /** + * This field contains the notepads for this task. + * + * @note MUST BE LAST ENTRY. + */ + uint32_t Notepads[ RTEMS_NUMBER_NOTEPADS ]; +} RTEMS_API_Control; + +/** + * The following instantiates the information control block used to + * manage this class of objects. + */ +RTEMS_TASKS_EXTERN Objects_Information _RTEMS_tasks_Information; + +/** + * When the user configures a set of Classic API initialization tasks, + * This variable will point to the method used to initialize them. + * + * @note It is instantiated and initialized by confdefs.h based upon + * application requirements. + */ +extern void (*_RTEMS_tasks_Initialize_user_tasks_p)(void); + +/** + * @brief _RTEMS_tasks_Manager_initialization + * + * This routine initializes all Task Manager related data structures. + */ +void _RTEMS_tasks_Manager_initialization(void); + +/** + * @brief rtems_task_create + * + * This routine implements the rtems_task_create directive. The task + * will have the name name. The attribute_set can be used to indicate + * that the task will be globally accessible or utilize floating point. + * The task's stack will be stack_size bytes. The task will begin + * execution with initial_priority and initial_modes. It returns the + * id of the created task in ID. + */ +rtems_status_code rtems_task_create( + rtems_name name, + rtems_task_priority initial_priority, + size_t stack_size, + rtems_mode initial_modes, + rtems_attribute attribute_set, + rtems_id *id +); + +/** + * @brief rtems_task_ident + * + * This routine implements the rtems_task_ident directive. + * This directive returns the task ID associated with name. + * If more than one task is named name, then the task to + * which the ID belongs is arbitrary. node indicates the + * extent of the search for the ID of the task named name. + * The search can be limited to a particular node or allowed to + * encompass all nodes. + */ +rtems_status_code rtems_task_ident( + rtems_name name, + uint32_t node, + rtems_id *id +); + +/** + * @brief rtems_task_delete + * + * This routine implements the rtems_task_delete directive. The + * task indicated by ID is deleted. + */ +rtems_status_code rtems_task_delete( + rtems_id id +); + +/** + * @brief rtems_task_get_note + * + * This routine implements the rtems_task_get_note directive. The + * value of the indicated notepad for the task associated with ID + * is returned in note. + */ +rtems_status_code rtems_task_get_note( + rtems_id id, + uint32_t notepad, + uint32_t *note +); + +/** + * @brief rtems_task_set_note + * + * This routine implements the rtems_task_set_note directive. The + * value of the indicated notepad for the task associated with ID + * is returned in note. + */ +rtems_status_code rtems_task_set_note( + rtems_id id, + uint32_t notepad, + uint32_t note +); + +/** + * @brief rtems_task_mode + * + * This routine implements the rtems_task_mode directive. The current + * values of the modes indicated by mask of the calling task are changed + * to that indicated in mode_set. The former mode of the task is + * returned in mode_set. + */ +rtems_status_code rtems_task_mode( + rtems_mode mode_set, + rtems_mode mask, + rtems_mode *previous_mode_set +); + +/** + * @brief rtems_task_restart + * + * This routine implements the rtems_task_restart directive. The + * task associated with ID is restarted at its initial entry + * point with the new argument. + */ +rtems_status_code rtems_task_restart( + rtems_id id, + uint32_t arg +); + +/** + * @brief rtems_task_suspend + * + * This routine implements the rtems_task_suspend directive. The + * SUSPENDED state is set for task associated with ID. + */ +rtems_status_code rtems_task_suspend( + rtems_id id +); + +/** + * @brief rtems_task_resume + * + * This routine implements the rtems_task_resume Directive. The + * SUSPENDED state is cleared for task associated with ID. + */ +rtems_status_code rtems_task_resume( + rtems_id id +); + +/** + * @brief rtems_task_set_priority + * + * This routine implements the rtems_task_set_priority directive. The + * current priority of the task associated with ID is set to + * new_priority. The former priority of that task is returned + * in old_priority. + */ +rtems_status_code rtems_task_set_priority( + rtems_id id, + rtems_task_priority new_priority, + rtems_task_priority *old_priority +); + +/** + * @brief rtems_task_start + * + * This routine implements the rtems_task_start directive. The + * starting execution point of the task associated with ID is + * set to entry_point with the initial argument. + */ +rtems_status_code rtems_task_start( + rtems_id id, + rtems_task_entry entry_point, + rtems_task_argument argument +); + +/** + * @brief rtems_task_wake_when + * + * This routine implements the rtems_task_wake_when directive. The + * calling task is blocked until the current time of day is + * equal to that indicated by time_buffer. + */ +rtems_status_code rtems_task_wake_when( + rtems_time_of_day *time_buffer +); + +/** + * @brief rtems_task_wake_after + * + * This routine implements the rtems_task_wake_after directive. The + * calling task is blocked until the indicated number of clock + * ticks have occurred. + */ +rtems_status_code rtems_task_wake_after( + rtems_interval ticks +); + +/** + * @brief rtems_task_is_suspended + + * This directive returns a status indicating whether or not + * the specified task is suspended. + */ +rtems_status_code rtems_task_is_suspended( + rtems_id id +); + +/** + * @brief rtems_task_variable_add + * + * This directive adds a per task variable. + */ +rtems_status_code rtems_task_variable_add( + rtems_id tid, + void **ptr, + void (*dtor)(void *) +); + +/** + * @brief rtems_task_variable_get + * + * This directive gets the value of a task variable. + */ +rtems_status_code rtems_task_variable_get( + rtems_id tid, + void **ptr, + void **result +); + +/** + * @brief rtems_task_variable_delete + * + * This directive removes a per task variable. + */ +rtems_status_code rtems_task_variable_delete( + rtems_id tid, + void **ptr +); + +/** + * @brief rtems_task_self + * + * This directive returns the ID of the currently executing task. + */ +rtems_id rtems_task_self(void); + +/** + * @brief _RTEMS_tasks_Initialize_user_tasks + * + * This routine creates and starts all configured user + * initialzation threads. + * + * Input parameters: NONE + * + * Output parameters: NONE + */ +void _RTEMS_tasks_Initialize_user_tasks( void ); + +/** + * @brief _RTEMS_Tasks_Invoke_task_variable_dtor( + * + * This routine invokes the optional user provided destructor on the + * task variable and frees the memory for the task variable. + * + * Input parameters: NONE + * + * Output parameters: NONE + */ +void _RTEMS_Tasks_Invoke_task_variable_dtor( + Thread_Control *the_thread, + rtems_task_variable_t *tvp +); + +#ifndef __RTEMS_APPLICATION__ +#include <rtems/rtems/tasks.inl> +#endif +#if defined(RTEMS_MULTIPROCESSING) +#include <rtems/rtems/taskmp.h> +#endif + +#ifdef __cplusplus +} +#endif + +/**@}*/ + +#endif +/* end of include file */ diff --git a/cpukit/rtems/include/rtems/rtems/timer.h b/cpukit/rtems/include/rtems/rtems/timer.h new file mode 100644 index 0000000000..a328e9a0d1 --- /dev/null +++ b/cpukit/rtems/include/rtems/rtems/timer.h @@ -0,0 +1,408 @@ +/** + * @file rtems/rtems/timer.h + * + * This include file contains all the constants, structures, and + * prototypes associated with the Timer Manager. This manager provides + * facilities to configure, initiate, cancel, and delete timers which will + * fire at specified intervals of time. + * + * Directives provided are: + * + * - create a timer + * - get an ID of a timer + * - delete a timer + * - set timer to fire in context of clock tick + * - after a number of ticks have passed + * - when a specified date and time has been reached + * - initiate the timer server task + * - set timer to fire in context of the timer server task + * - after a number of ticks have passed + * - when a specified date and time has been reached + * - reset a timer + * - cancel a time + */ + +/* COPYRIGHT (c) 1989-2009. + * On-Line Applications Research Corporation (OAR). + * + * Copyright (c) 2009 embedded brains GmbH. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. + * + * $Id$ + */ + +#ifndef _RTEMS_RTEMS_TIMER_H +#define _RTEMS_RTEMS_TIMER_H + +/** + * This constant is defined to extern most of the time when using + * this header file. However by defining it to nothing, the data + * declared in this header file can be instantiated. This is done + * in a single per manager file. + */ +#ifndef RTEMS_TIMER_EXTERN +#define RTEMS_TIMER_EXTERN extern +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#include <rtems/score/object.h> +#include <rtems/score/watchdog.h> +#include <rtems/score/thread.h> +#include <rtems/score/chain.h> +#include <rtems/rtems/clock.h> +#include <rtems/rtems/attr.h> + +/** + * @defgroup ClassicTimer Timers + * + * @ingroup ClassicRTEMS + * + * This encapsulates functionality related to the Classic API Timer + * Manager. This manager provides functionality which allows the + * application to schedule the execution of methods at a specified + * time in the future. These methods may be scheduled based upon + * interval or wall time and may be executed in either the clock tick + * ISR or in a special dedicated timer server task. + */ +/**@{*/ + +/** + * The following enumerated type details the classes to which a timer + * may belong. + */ +typedef enum { + /** + * This value indicates the timer is currently in use as an interval + * timer which will fire in the clock tick ISR. + */ + TIMER_INTERVAL, + + /** + * This value indicates the timer is currently in use as an interval + * timer which will fire in the timer server task. + */ + TIMER_INTERVAL_ON_TASK, + + /** + * This value indicates the timer is currently in use as an time of day + * timer which will fire in the clock tick ISR. + */ + TIMER_TIME_OF_DAY, + + /** + * This value indicates the timer is currently in use as an time of day + * timer which will fire in the timer server task. + */ + TIMER_TIME_OF_DAY_ON_TASK, + + /** + * This value indicates the timer is currently not in use. + */ + TIMER_DORMANT +} Timer_Classes; + +/** + * The following types define a pointer to a timer service routine. + */ +typedef void rtems_timer_service_routine; + +/** + * This type defines the type used to manage and indirectly invoke + * Timer Service Routines (TSRs). This defines the prototype and interface + * for a function which is to be used as a TSR. + */ +typedef rtems_timer_service_routine ( *rtems_timer_service_routine_entry )( + rtems_id, + void * + ); + +/** + * The following records define the control block used to manage + * each timer. + */ +typedef struct { + /** This field is the object management portion of a Timer instance. */ + Objects_Control Object; + /** This field is the Watchdog instance which will be the scheduled. */ + Watchdog_Control Ticker; + /** This field indicates what type of timer this currently is. */ + Timer_Classes the_class; +} Timer_Control; + +typedef struct Timer_server_Control Timer_server_Control; + +/** + * @brief Method used to schedule the insertion of task based timers. + */ +typedef void (*Timer_server_Schedule_operation)( + Timer_server_Control *timer_server, + Timer_Control *timer +); + +typedef struct { + /** + * @brief This watchdog that will be registered in the system tick mechanic + * for timer server wake-up. + */ + Watchdog_Control System_watchdog; + + /** + * @brief Chain for watchdogs which will be triggered by the timer server. + */ + Chain_Control Chain; + + /** + * @brief Last known time snapshot of the timer server. + * + * The units may be ticks or seconds. + */ + Watchdog_Interval volatile last_snapshot; +} Timer_server_Watchdogs; + +struct Timer_server_Control { + /** + * @brief Timer server thread. + */ + Thread_Control *thread; + + /** + * @brief The schedule operation method of the timer server. + */ + Timer_server_Schedule_operation schedule_operation; + + /** + * @brief Interval watchdogs triggered by the timer server. + */ + Timer_server_Watchdogs Interval_watchdogs; + + /** + * @brief TOD watchdogs triggered by the timer server. + */ + Timer_server_Watchdogs TOD_watchdogs; + + /** + * @brief Chain of timers scheduled for insert. + * + * This pointer is not @c NULL whenever the interval and TOD chains are + * processed. After the processing this list will be checked and if + * necessary the processing will be restarted. Processing of these chains + * can be only interrupted through interrupts. + */ + Chain_Control *volatile insert_chain; + + /** + * @brief Indicates that the timer server is active or not. + * + * The server is active after the delay on a system watchdog. The activity + * period of the server ends when no more watchdogs managed by the server + * fire. The system watchdogs must not be manipulated when the server is + * active. + */ + bool volatile active; +}; + +/** + * @brief Pointer to default timer server control block. + * + * This value is @c NULL when the default timer server is not initialized. + */ +RTEMS_TIMER_EXTERN Timer_server_Control *volatile _Timer_server; + +/** + * The following defines the information control block used to manage + * this class of objects. + */ +RTEMS_TIMER_EXTERN Objects_Information _Timer_Information; + +/** + * @brief _Timer_Manager_initialization + * + * This routine performs the initialization necessary for this manager. + */ +void _Timer_Manager_initialization(void); + +/** + * @brief rtems_timer_create + * + * This routine implements the rtems_timer_create directive. The + * timer will have the name name. It returns the id of the + * created timer in ID. + */ +rtems_status_code rtems_timer_create( + rtems_name name, + rtems_id *id +); + +/** + * @brief rtems_timer_ident + * + * This routine implements the rtems_timer_ident directive. + * This directive returns the timer ID associated with name. + * If more than one timer is named name, then the timer + * to which the ID belongs is arbitrary. + */ +rtems_status_code rtems_timer_ident( + rtems_name name, + rtems_id *id +); + +/** + * @brief rtems_timer_cancel + * + * This routine implements the rtems_timer_cancel directive. It is used + * to stop the timer associated with ID from firing. + */ +rtems_status_code rtems_timer_cancel( + rtems_id id +); + +/** + * @brief rtems_timer_delete + * + * This routine implements the rtems_timer_delete directive. The + * timer indicated by ID is deleted. + */ +rtems_status_code rtems_timer_delete( + rtems_id id +); + +/** + * @brief rtems_timer_fire_after + * + * This routine implements the rtems_timer_fire_after directive. It + * initiates the timer associated with ID to fire in ticks clock ticks. + * When the timer fires, the routine will be invoked in the context + * of the rtems_clock_tick directive which is normally invoked as + * part of servicing a periodic interupt. + */ +rtems_status_code rtems_timer_fire_after( + rtems_id id, + rtems_interval ticks, + rtems_timer_service_routine_entry routine, + void *user_data +); + +/** + * @brief rtems_timer_server_fire_after + * + * This routine implements the rtems_timer_server_fire_after directive. It + * initiates the timer associated with ID to fire in ticks clock + * ticks. When the timer fires, the routine will be invoked by the + * Timer Server in the context of a task NOT IN THE CONTEXT of the + * clock tick interrupt. + */ +rtems_status_code rtems_timer_server_fire_after( + rtems_id id, + rtems_interval ticks, + rtems_timer_service_routine_entry routine, + void *user_data +); + +/** + * @brief rtems_timer_fire_when + * + * This routine implements the rtems_timer_fire_when directive. It + * initiates the timer associated with ID to fire at wall_time + * When the timer fires, the routine will be invoked in the context + * of the rtems_clock_tick directive which is normally invoked as + * part of servicing a periodic interupt. + */ +rtems_status_code rtems_timer_fire_when( + rtems_id id, + rtems_time_of_day *wall_time, + rtems_timer_service_routine_entry routine, + void *user_data +); + +/** + * @brief rtems_timer_server_fire_when + * + * This routine implements the rtems_timer_server_fire_when directive. It + * initiates the timer associated with ID to fire at wall_time + * When the timer fires, the routine will be invoked by the + * Timer Server in the context of a task NOT IN THE CONTEXT of the + * clock tick interrupt. + */ +rtems_status_code rtems_timer_server_fire_when( + rtems_id id, + rtems_time_of_day *wall_time, + rtems_timer_service_routine_entry routine, + void *user_data +); + +/** + * @brief rtems_timer_reset + * + * This routine implements the rtems_timer_reset directive. It is used + * to reinitialize the interval timer associated with ID just as if + * rtems_timer_fire_after were re-invoked with the same arguments that + * were used to initiate this timer. + */ +rtems_status_code rtems_timer_reset( + rtems_id id +); + +/** + * @brief rtems_timer_initiate_server + * + * This routine implements the rtems_timer_initiate_server directive. + * It creates and starts the server that executes task-based timers. + * It must be invoked before any task-based timers can be initiated. + */ +rtems_status_code rtems_timer_initiate_server( + uint32_t priority, + uint32_t stack_size, + rtems_attribute attribute_set +); + +/** + * This is the default value for the priority of the Timer Server. + * When given this priority, a special high priority not accessible + * via the Classic API is used. + */ +#define RTEMS_TIMER_SERVER_DEFAULT_PRIORITY (uint32_t) -1 + +/** + * This is the structure filled in by the timer get information + * service. + */ +typedef struct { + /** This indicates the current type of the timer. */ + Timer_Classes the_class; + /** This indicates the initial requested interval. */ + Watchdog_Interval initial; + /** This indicates the time the timer was initially scheduled. */ + Watchdog_Interval start_time; + /** This indicates the time the timer is scheduled to fire. */ + Watchdog_Interval stop_time; +} rtems_timer_information; + +/** + * @brief rtems_timer_get_information + * + * This routine implements the rtems_timer_get_information directive. + * This directive returns information about the timer. + */ +rtems_status_code rtems_timer_get_information( + rtems_id id, + rtems_timer_information *the_info +); + +#ifndef __RTEMS_APPLICATION__ +#include <rtems/rtems/timer.inl> +#endif + +#ifdef __cplusplus +} +#endif + +/**@}*/ + +#endif +/* end of include file */ diff --git a/cpukit/rtems/include/rtems/rtems/types.h b/cpukit/rtems/include/rtems/rtems/types.h new file mode 100644 index 0000000000..2ceeeaa203 --- /dev/null +++ b/cpukit/rtems/include/rtems/rtems/types.h @@ -0,0 +1,238 @@ +/** + * @file + * + * @ingroup ClassicRTEMS + * + * @brief Types used by the Classic API. + */ + +/* COPYRIGHT (c) 1989-2009. + * 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.com/license/LICENSE. + * + * $Id$ + */ + +#ifndef _RTEMS_RTEMS_TYPES_H +#define _RTEMS_RTEMS_TYPES_H + +/* + * RTEMS basic type definitions + */ + +#include <stdint.h> +#include <rtems/score/heap.h> +#include <rtems/score/object.h> +#include <rtems/score/priority.h> +#include <rtems/score/tod.h> +#include <rtems/score/watchdog.h> +#include <rtems/rtems/modes.h> +#if defined(RTEMS_MULTIPROCESSING) +#include <rtems/score/mpci.h> +#include <rtems/score/mppkt.h> +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @addtogroup ClassicRTEMS + * + * @{ + */ + +#ifdef RTEMS_DEPRECATED_TYPES +/** + * @brief Single precision float type. + * + * @deprecated Use @c float instead. + */ +typedef single_precision rtems_single; + +/** + * @brief Double precision float type. + * + * @deprecated Use @c double instead. + */ +typedef double_precision rtems_double; + +/** + * @brief RTEMS boolean type. + * + * @deprecated Use @c bool instead + */ +typedef boolean rtems_boolean; +#endif + +/** + * @brief Classic API @ref ClassicRTEMSSubSecObjectNames "object name" type. + * + * Contains the name of a Classic API object. It is an unsigned 32-bit integer + * which can be treated as a numeric value or initialized using + * rtems_build_name() to contain four ASCII characters. + */ +typedef uint32_t rtems_name; + +/** + * @brief Used to manage and manipulate + * @ref ClassicRTEMSSubSecObjectIdentifiers "RTEMS object identifiers". + */ +typedef Objects_Id rtems_id; + +/** + * @brief Invalid object identifier value. + * + * No object can have this identifier value. + */ +#define RTEMS_ID_NONE OBJECTS_ID_NONE + +/** + * @brief Public name for task context area. + */ +typedef Context_Control rtems_context; + +#if (CPU_HARDWARE_FP == TRUE) || (CPU_SOFTWARE_FP == TRUE) +/** + * @brief Public name for task floating point context area. + */ +typedef Context_Control_fp rtems_context_fp; +#endif + +/** + * @brief Defines the format of the interrupt stack frame as it appears to a + * user ISR. + * + * This data structure may not be defined on all ports + */ +typedef CPU_Interrupt_frame rtems_interrupt_frame; + +/** + * @brief Information structure returned by the Heap Handler via the Region + * Manager. + */ +typedef Heap_Information_block region_information_block; + +/** + * @brief Used to manage and manipulate intervals specified by + * @ref ClassicRTEMSSecTime "clock ticks". + */ +typedef Watchdog_Interval rtems_interval; + +/** + * @brief Represents the CPU usage per thread. + * + * When using nano seconds granularity timing, RTEMS may internally use a + * variety of representations. + */ +#ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__ + typedef struct timespec rtems_thread_cpu_usage_t; +#else + typedef uint32_t rtems_thread_cpu_usage_t; +#endif + +/** + * @brief Data structure to manage and manipulate calendar + * @ref ClassicRTEMSSecTime "time". + */ +typedef struct { + /** + * @brief Year, A.D. + */ + uint32_t year; + /** + * @brief Month, 1 .. 12. + */ + uint32_t month; + /** + * @brief Day, 1 .. 31. + */ + uint32_t day; + /** + * @brief Hour, 0 .. 23. + */ + uint32_t hour; + /** + * @brief Minute, 0 .. 59. + */ + uint32_t minute; + /** + * @brief Second, 0 .. 59. + */ + uint32_t second; + /** + * @brief Elapsed ticks between seconds. + */ + uint32_t ticks; +} rtems_time_of_day; + +/** + * @brief Task mode type. + */ +typedef Modes_Control rtems_mode; + +/* + * MPCI related entries + */ +#if defined(RTEMS_MULTIPROCESSING) +/** + * @brief Set of MPCI packet classes which are internally dispatched to the + * managers. + */ +typedef MP_packet_Classes rtems_mp_packet_classes; + +/** + * @brief Prefix found at the beginning of each MPCI packet sent between nodes. + */ +typedef MP_packet_Prefix rtems_packet_prefix; + +/** + * @brief Indirect pointer to the initialization entry point for an MPCI + * handler. + */ +typedef MPCI_initialization_entry rtems_mpci_initialization_entry; + +/** + * @brief Indirect pointer to the get_packet entry point for an MPCI handler. + */ +typedef MPCI_get_packet_entry rtems_mpci_get_packet_entry; + +/** + * @brief Indirect pointer to the return_packet entry point for an MPCI + * handler. + */ +typedef MPCI_return_packet_entry rtems_mpci_return_packet_entry; + +/** + * @brief Indirect pointer to the send_packet entry point for an MPCI handler. + */ +typedef MPCI_send_entry rtems_mpci_send_packet_entry; + +/** + * @brief Indirect pointer to the receive entry point for an MPCI handler. + */ +typedef MPCI_receive_entry rtems_mpci_receive_packet_entry; + +/** + * @brief Return type from every MPCI handler routine. + */ +typedef MPCI_Entry rtems_mpci_entry; + +/** + * @brief Structure which is used to configure an MPCI handler. + */ +typedef MPCI_Control rtems_mpci_table; + +#endif + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ |