From 8695cae269f9c87a535e26180c5b2b5d370720fa Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Tue, 23 Jul 2013 14:19:58 +0200 Subject: rtems: Create part implementation header Move implementation specific parts of part.h and part.inl into new header file partimpl.h. The part.h contains now only the application visible API. --- cpukit/libcsupport/src/resource_snapshot.c | 1 + cpukit/libmisc/monitor/mon-object.c | 1 + cpukit/rtems/Makefile.am | 2 +- cpukit/rtems/include/rtems/rtems/part.h | 43 +----- cpukit/rtems/include/rtems/rtems/partimpl.h | 215 ++++++++++++++++++++++++++++ cpukit/rtems/include/rtems/rtems/partmp.h | 8 +- cpukit/rtems/inline/rtems/rtems/part.inl | 177 ----------------------- cpukit/rtems/preinstall.am | 8 +- cpukit/rtems/src/part.c | 2 +- cpukit/rtems/src/partcreate.c | 2 +- cpukit/rtems/src/partdata.c | 3 +- cpukit/rtems/src/partdelete.c | 2 +- cpukit/rtems/src/partgetbuffer.c | 2 +- cpukit/rtems/src/partident.c | 2 +- cpukit/rtems/src/partmp.c | 2 +- cpukit/rtems/src/partreturnbuffer.c | 2 +- cpukit/sapi/src/rtemsapi.c | 2 +- testsuites/sptests/spsize/size.c | 4 +- 18 files changed, 242 insertions(+), 236 deletions(-) create mode 100644 cpukit/rtems/include/rtems/rtems/partimpl.h delete mode 100644 cpukit/rtems/inline/rtems/rtems/part.inl diff --git a/cpukit/libcsupport/src/resource_snapshot.c b/cpukit/libcsupport/src/resource_snapshot.c index c04dcf6cb4..0fd20aeedb 100644 --- a/cpukit/libcsupport/src/resource_snapshot.c +++ b/cpukit/libcsupport/src/resource_snapshot.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include diff --git a/cpukit/libmisc/monitor/mon-object.c b/cpukit/libmisc/monitor/mon-object.c index 3ef9276c9a..cb0ffa1de3 100644 --- a/cpukit/libmisc/monitor/mon-object.c +++ b/cpukit/libmisc/monitor/mon-object.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #if defined(RTEMS_POSIX_API) #include diff --git a/cpukit/rtems/Makefile.am b/cpukit/rtems/Makefile.am index 5b6d526d2d..7e810af561 100644 --- a/cpukit/rtems/Makefile.am +++ b/cpukit/rtems/Makefile.am @@ -36,6 +36,7 @@ include_rtems_rtems_HEADERS += include/rtems/rtems/object.h include_rtems_rtems_HEADERS += include/rtems/rtems/options.h include_rtems_rtems_HEADERS += include/rtems/rtems/optionsimpl.h include_rtems_rtems_HEADERS += include/rtems/rtems/part.h +include_rtems_rtems_HEADERS += include/rtems/rtems/partimpl.h include_rtems_rtems_HEADERS += include/rtems/rtems/ratemon.h include_rtems_rtems_HEADERS += include/rtems/rtems/ratemonimpl.h include_rtems_rtems_HEADERS += include/rtems/rtems/region.h @@ -68,7 +69,6 @@ include_rtems_rtems_HEADERS += include/rtems/rtems/signalmp.h include_rtems_rtems_HEADERS += include/rtems/rtems/taskmp.h endif -include_rtems_rtems_HEADERS += inline/rtems/rtems/part.inl include_rtems_rtems_HEADERS += inline/rtems/rtems/region.inl include_rtems_rtems_HEADERS += inline/rtems/rtems/tasks.inl diff --git a/cpukit/rtems/include/rtems/rtems/part.h b/cpukit/rtems/include/rtems/rtems/part.h index c864bebc5f..e9d2dfccfc 100644 --- a/cpukit/rtems/include/rtems/rtems/part.h +++ b/cpukit/rtems/include/rtems/rtems/part.h @@ -31,29 +31,14 @@ #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. - * - * Partition Manager -- Instantiate Data - */ -#ifndef RTEMS_PART_EXTERN -#define RTEMS_PART_EXTERN extern -#endif +#include +#include +#include #ifdef __cplusplus extern "C" { #endif -#include -#include -#include -#include -#include -#include - /** * @defgroup ClassicPart Partitions * @@ -84,19 +69,6 @@ typedef struct { 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 * @@ -189,18 +161,11 @@ rtems_status_code rtems_partition_return_buffer( void *buffer ); -#ifndef __RTEMS_APPLICATION__ -#include -#endif -#if defined(RTEMS_MULTIPROCESSING) -#include -#endif +/**@}*/ #ifdef __cplusplus } #endif -/**@}*/ - #endif /* end of include file */ diff --git a/cpukit/rtems/include/rtems/rtems/partimpl.h b/cpukit/rtems/include/rtems/rtems/partimpl.h new file mode 100644 index 0000000000..2de8028a8f --- /dev/null +++ b/cpukit/rtems/include/rtems/rtems/partimpl.h @@ -0,0 +1,215 @@ +/** + * @file + * + * @ingroup ClassicPartImpl + * + * @brief Classic Partition Manager Implementation + */ + +/* 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. + */ + +#ifndef _RTEMS_RTEMS_PARTIMPL_H +#define _RTEMS_RTEMS_PARTIMPL_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup ClassicPartImpl Classic Partition Manager Implementation + * + * @ingroup ClassicPart + * + * @{ + */ + +/** + * 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. + * + * Partition Manager -- Instantiate Data + */ +#ifndef RTEMS_PART_EXTERN +#define RTEMS_PART_EXTERN extern +#endif + +/** + * 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 Allocate a buffer from the_partition. + * + * This function attempts to allocate a buffer from the_partition. + * If successful, it returns the address of the allocated buffer. + * Otherwise, it returns NULL. + */ +RTEMS_INLINE_ROUTINE void *_Partition_Allocate_buffer ( + Partition_Control *the_partition +) +{ + return _Chain_Get( &the_partition->Memory ); +} + +/** + * @brief Frees the_buffer to the_partition. + * + * This routine frees the_buffer to the_partition. + */ +RTEMS_INLINE_ROUTINE void _Partition_Free_buffer ( + Partition_Control *the_partition, + Chain_Node *the_buffer +) +{ + _Chain_Append( &the_partition->Memory, the_buffer ); +} + +/** + * @brief Checks whether is on a valid buffer boundary for the_partition. + * + * This function returns TRUE if the_buffer is on a valid buffer + * boundary for the_partition, and FALSE otherwise. + */ +RTEMS_INLINE_ROUTINE bool _Partition_Is_buffer_on_boundary ( + void *the_buffer, + Partition_Control *the_partition +) +{ + uint32_t offset; + + offset = (uint32_t) _Addresses_Subtract( + the_buffer, + the_partition->starting_address + ); + + return ((offset % the_partition->buffer_size) == 0); +} + +/** + * @brief Checks whether the_buffer is a valid buffer from the_partition. + * + * This function returns TRUE if the_buffer is a valid buffer from + * the_partition, otherwise FALSE is returned. + */ +RTEMS_INLINE_ROUTINE bool _Partition_Is_buffer_valid ( + Chain_Node *the_buffer, + Partition_Control *the_partition +) +{ + void *starting; + void *ending; + + starting = the_partition->starting_address; + ending = _Addresses_Add_offset( starting, the_partition->length ); + + return ( + _Addresses_Is_in_range( the_buffer, starting, ending ) && + _Partition_Is_buffer_on_boundary( the_buffer, the_partition ) + ); +} + +/** + * @brief Checks if partition is buffer size aligned. + * + * This function returns TRUE if the use of the specified buffer_size + * will result in the allocation of buffers whose first byte is + * properly aligned, and FALSE otherwise. + */ +RTEMS_INLINE_ROUTINE bool _Partition_Is_buffer_size_aligned ( + uint32_t buffer_size +) +{ + return ((buffer_size % CPU_PARTITION_ALIGNMENT) == 0); +} + +/** + * @brief Allocates a partition control block from the + * inactive chain of free partition control blocks. + * + * This function allocates a partition control block from + * the inactive chain of free partition control blocks. + */ +RTEMS_INLINE_ROUTINE Partition_Control *_Partition_Allocate ( void ) +{ + return (Partition_Control *) _Objects_Allocate( &_Partition_Information ); +} + +/** + * @brief Frees a partition control block to the + * inactive chain of free partition control blocks. + * + * This routine frees a partition control block to the + * inactive chain of free partition control blocks. + */ +RTEMS_INLINE_ROUTINE void _Partition_Free ( + Partition_Control *the_partition +) +{ + _Objects_Free( &_Partition_Information, &the_partition->Object ); +} + +/** + * @brief Maps partition IDs to partition control blocks. + * + * This function maps partition IDs to partition control blocks. + * If ID corresponds to a local partition, then it returns + * the_partition control pointer which maps to ID and location + * is set to OBJECTS_LOCAL. If the partition ID is global and + * resides on a remote node, then location is set to OBJECTS_REMOTE, + * and the_partition is undefined. Otherwise, location is set + * to OBJECTS_ERROR and the_partition is undefined. + */ +RTEMS_INLINE_ROUTINE Partition_Control *_Partition_Get ( + Objects_Id id, + Objects_Locations *location +) +{ + return (Partition_Control *) + _Objects_Get( &_Partition_Information, id, location ); +} + +/** + * @brief Checks if the_partition is NULL. + * + * This function returns TRUE if the_partition is NULL + * and FALSE otherwise. + */ +RTEMS_INLINE_ROUTINE bool _Partition_Is_null ( + Partition_Control *the_partition +) +{ + return ( the_partition == NULL ); +} + +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#if defined(RTEMS_MULTIPROCESSING) +#include +#endif + +#endif +/* end of include file */ diff --git a/cpukit/rtems/include/rtems/rtems/partmp.h b/cpukit/rtems/include/rtems/rtems/partmp.h index 3d3f47fe52..6eae109772 100644 --- a/cpukit/rtems/include/rtems/rtems/partmp.h +++ b/cpukit/rtems/include/rtems/rtems/partmp.h @@ -18,8 +18,8 @@ #ifndef _RTEMS_RTEMS_PARTMP_H #define _RTEMS_RTEMS_PARTMP_H -#ifdef __cplusplus -extern "C" { +#ifndef _RTEMS_RTEMS_PARTIMPL_H +# error "Never use directly; include instead." #endif #include @@ -27,7 +27,9 @@ extern "C" { #include #include -#include +#ifdef __cplusplus +extern "C" { +#endif /** * @defgroup ClassicPartMP Partition MP Support diff --git a/cpukit/rtems/inline/rtems/rtems/part.inl b/cpukit/rtems/inline/rtems/rtems/part.inl deleted file mode 100644 index 0a9bead9cf..0000000000 --- a/cpukit/rtems/inline/rtems/rtems/part.inl +++ /dev/null @@ -1,177 +0,0 @@ -/** - * @file rtems/rtems/part.inl - * - * This file contains the macro implementation of all inlined routines - * 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. - */ - -#ifndef _RTEMS_RTEMS_PART_H -# error "Never use directly; include instead." -#endif - -#ifndef _RTEMS_RTEMS_PART_INL -#define _RTEMS_RTEMS_PART_INL - -#include - -/** - * @addtogroup ClassicPart - * @{ - */ - -/** - * @brief Allocate a buffer from the_partition. - * - * This function attempts to allocate a buffer from the_partition. - * If successful, it returns the address of the allocated buffer. - * Otherwise, it returns NULL. - */ -RTEMS_INLINE_ROUTINE void *_Partition_Allocate_buffer ( - Partition_Control *the_partition -) -{ - return _Chain_Get( &the_partition->Memory ); -} - -/** - * @brief Frees the_buffer to the_partition. - * - * This routine frees the_buffer to the_partition. - */ -RTEMS_INLINE_ROUTINE void _Partition_Free_buffer ( - Partition_Control *the_partition, - Chain_Node *the_buffer -) -{ - _Chain_Append( &the_partition->Memory, the_buffer ); -} - -/** - * @brief Checks whether is on a valid buffer boundary for the_partition. - * - * This function returns TRUE if the_buffer is on a valid buffer - * boundary for the_partition, and FALSE otherwise. - */ -RTEMS_INLINE_ROUTINE bool _Partition_Is_buffer_on_boundary ( - void *the_buffer, - Partition_Control *the_partition -) -{ - uint32_t offset; - - offset = (uint32_t) _Addresses_Subtract( - the_buffer, - the_partition->starting_address - ); - - return ((offset % the_partition->buffer_size) == 0); -} - -/** - * @brief Checks whether the_buffer is a valid buffer from the_partition. - * - * This function returns TRUE if the_buffer is a valid buffer from - * the_partition, otherwise FALSE is returned. - */ -RTEMS_INLINE_ROUTINE bool _Partition_Is_buffer_valid ( - Chain_Node *the_buffer, - Partition_Control *the_partition -) -{ - void *starting; - void *ending; - - starting = the_partition->starting_address; - ending = _Addresses_Add_offset( starting, the_partition->length ); - - return ( - _Addresses_Is_in_range( the_buffer, starting, ending ) && - _Partition_Is_buffer_on_boundary( the_buffer, the_partition ) - ); -} - -/** - * @brief Checks if partition is buffer size aligned. - * - * This function returns TRUE if the use of the specified buffer_size - * will result in the allocation of buffers whose first byte is - * properly aligned, and FALSE otherwise. - */ -RTEMS_INLINE_ROUTINE bool _Partition_Is_buffer_size_aligned ( - uint32_t buffer_size -) -{ - return ((buffer_size % CPU_PARTITION_ALIGNMENT) == 0); -} - -/** - * @brief Allocates a partition control block from the - * inactive chain of free partition control blocks. - * - * This function allocates a partition control block from - * the inactive chain of free partition control blocks. - */ -RTEMS_INLINE_ROUTINE Partition_Control *_Partition_Allocate ( void ) -{ - return (Partition_Control *) _Objects_Allocate( &_Partition_Information ); -} - -/** - * @brief Frees a partition control block to the - * inactive chain of free partition control blocks. - * - * This routine frees a partition control block to the - * inactive chain of free partition control blocks. - */ -RTEMS_INLINE_ROUTINE void _Partition_Free ( - Partition_Control *the_partition -) -{ - _Objects_Free( &_Partition_Information, &the_partition->Object ); -} - -/** - * @brief Maps partition IDs to partition control blocks. - * - * This function maps partition IDs to partition control blocks. - * If ID corresponds to a local partition, then it returns - * the_partition control pointer which maps to ID and location - * is set to OBJECTS_LOCAL. If the partition ID is global and - * resides on a remote node, then location is set to OBJECTS_REMOTE, - * and the_partition is undefined. Otherwise, location is set - * to OBJECTS_ERROR and the_partition is undefined. - */ -RTEMS_INLINE_ROUTINE Partition_Control *_Partition_Get ( - Objects_Id id, - Objects_Locations *location -) -{ - return (Partition_Control *) - _Objects_Get( &_Partition_Information, id, location ); -} - -/** - * @brief Checks if the_partition is NULL. - * - * This function returns TRUE if the_partition is NULL - * and FALSE otherwise. - */ -RTEMS_INLINE_ROUTINE bool _Partition_Is_null ( - Partition_Control *the_partition -) -{ - return ( the_partition == NULL ); -} - -/**@}*/ - -#endif -/* end of include file */ diff --git a/cpukit/rtems/preinstall.am b/cpukit/rtems/preinstall.am index 05dd0d2b66..f98fd1466b 100644 --- a/cpukit/rtems/preinstall.am +++ b/cpukit/rtems/preinstall.am @@ -115,6 +115,10 @@ $(PROJECT_INCLUDE)/rtems/rtems/part.h: include/rtems/rtems/part.h $(PROJECT_INCL $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtems/part.h PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtems/part.h +$(PROJECT_INCLUDE)/rtems/rtems/partimpl.h: include/rtems/rtems/partimpl.h $(PROJECT_INCLUDE)/rtems/rtems/$(dirstamp) + $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtems/partimpl.h +PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtems/partimpl.h + $(PROJECT_INCLUDE)/rtems/rtems/ratemon.h: include/rtems/rtems/ratemon.h $(PROJECT_INCLUDE)/rtems/rtems/$(dirstamp) $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtems/ratemon.h PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtems/ratemon.h @@ -217,10 +221,6 @@ $(PROJECT_INCLUDE)/rtems/rtems/taskmp.h: include/rtems/rtems/taskmp.h $(PROJECT_ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtems/taskmp.h PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtems/taskmp.h endif -$(PROJECT_INCLUDE)/rtems/rtems/part.inl: inline/rtems/rtems/part.inl $(PROJECT_INCLUDE)/rtems/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtems/part.inl -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtems/part.inl - $(PROJECT_INCLUDE)/rtems/rtems/region.inl: inline/rtems/rtems/region.inl $(PROJECT_INCLUDE)/rtems/rtems/$(dirstamp) $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtems/region.inl PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtems/region.inl diff --git a/cpukit/rtems/src/part.c b/cpukit/rtems/src/part.c index 042cdaf19a..c669c968cf 100644 --- a/cpukit/rtems/src/part.c +++ b/cpukit/rtems/src/part.c @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include #include diff --git a/cpukit/rtems/src/partcreate.c b/cpukit/rtems/src/partcreate.c index 536f56e294..edba8eb2ac 100644 --- a/cpukit/rtems/src/partcreate.c +++ b/cpukit/rtems/src/partcreate.c @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include #include diff --git a/cpukit/rtems/src/partdata.c b/cpukit/rtems/src/partdata.c index b568c4dc0c..3197c3d8a8 100644 --- a/cpukit/rtems/src/partdata.c +++ b/cpukit/rtems/src/partdata.c @@ -21,5 +21,4 @@ /* instantiate RTEMS partition data */ #define RTEMS_PART_EXTERN -#include -#include +#include diff --git a/cpukit/rtems/src/partdelete.c b/cpukit/rtems/src/partdelete.c index 2248adc830..48a6768d6f 100644 --- a/cpukit/rtems/src/partdelete.c +++ b/cpukit/rtems/src/partdelete.c @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include #include diff --git a/cpukit/rtems/src/partgetbuffer.c b/cpukit/rtems/src/partgetbuffer.c index 393cab6cd3..0b8f20cf13 100644 --- a/cpukit/rtems/src/partgetbuffer.c +++ b/cpukit/rtems/src/partgetbuffer.c @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include #include diff --git a/cpukit/rtems/src/partident.c b/cpukit/rtems/src/partident.c index d13af32ef0..b6ec38bcc3 100644 --- a/cpukit/rtems/src/partident.c +++ b/cpukit/rtems/src/partident.c @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include #include diff --git a/cpukit/rtems/src/partmp.c b/cpukit/rtems/src/partmp.c index 2928238924..d3b4f73268 100644 --- a/cpukit/rtems/src/partmp.c +++ b/cpukit/rtems/src/partmp.c @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include #include diff --git a/cpukit/rtems/src/partreturnbuffer.c b/cpukit/rtems/src/partreturnbuffer.c index 378b75578b..c5f6c47b4c 100644 --- a/cpukit/rtems/src/partreturnbuffer.c +++ b/cpukit/rtems/src/partreturnbuffer.c @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include #include diff --git a/cpukit/sapi/src/rtemsapi.c b/cpukit/sapi/src/rtemsapi.c index a83a19cfef..8814e8755c 100644 --- a/cpukit/sapi/src/rtemsapi.c +++ b/cpukit/sapi/src/rtemsapi.c @@ -35,7 +35,7 @@ #if defined(RTEMS_MULTIPROCESSING) #include #endif -#include +#include #include #include #include diff --git a/testsuites/sptests/spsize/size.c b/testsuites/sptests/spsize/size.c index 3e5ae9eb31..25df94ff47 100644 --- a/testsuites/sptests/spsize/size.c +++ b/testsuites/sptests/spsize/size.c @@ -33,7 +33,7 @@ #include #include #endif -#include +#include #include #include #include @@ -334,7 +334,7 @@ uninitialized = /*options.h*/ 0 + -/*part.h*/ (sizeof _Partition_Information) + +/*partimpl.h*/ (sizeof _Partition_Information) + #if defined(RTEMS_MULTIPROCESSING) /*partmp.h*/ 0 + -- cgit v1.2.3