rtems: Add _RTEMS_Name_to_id()

Simplify object name to identifier directives.  Using
_RTEMS_Name_to_id() to implement the directives enables a tail call
optimization.

Change license to BSD-2-Clause according to file history.

Update #3053.
This commit is contained in:
Sebastian Huber
2020-06-24 13:54:23 +02:00
parent 33dbb3355f
commit c7e30854f2
17 changed files with 480 additions and 230 deletions

View File

@@ -745,6 +745,7 @@ librtemscpu_a_SOURCES += rtems/src/regionreturnsegment.c
librtemscpu_a_SOURCES += rtems/src/rtemsbuildid.c librtemscpu_a_SOURCES += rtems/src/rtemsbuildid.c
librtemscpu_a_SOURCES += rtems/src/rtemsbuildname.c librtemscpu_a_SOURCES += rtems/src/rtemsbuildname.c
librtemscpu_a_SOURCES += rtems/src/rtemsmaxprio.c librtemscpu_a_SOURCES += rtems/src/rtemsmaxprio.c
librtemscpu_a_SOURCES += rtems/src/rtemsnametoid.c
librtemscpu_a_SOURCES += rtems/src/rtemsobjectapimaximumclass.c librtemscpu_a_SOURCES += rtems/src/rtemsobjectapimaximumclass.c
librtemscpu_a_SOURCES += rtems/src/rtemsobjectapiminimumclass.c librtemscpu_a_SOURCES += rtems/src/rtemsobjectapiminimumclass.c
librtemscpu_a_SOURCES += rtems/src/rtemsobjectgetapiclassname.c librtemscpu_a_SOURCES += rtems/src/rtemsobjectgetapiclassname.c

View File

@@ -276,6 +276,7 @@ include_rtems_rtems_HEADERS += include/rtems/rtems/modesimpl.h
include_rtems_rtems_HEADERS += include/rtems/rtems/mp.h include_rtems_rtems_HEADERS += include/rtems/rtems/mp.h
include_rtems_rtems_HEADERS += include/rtems/rtems/msgmp.h include_rtems_rtems_HEADERS += include/rtems/rtems/msgmp.h
include_rtems_rtems_HEADERS += include/rtems/rtems/object.h include_rtems_rtems_HEADERS += include/rtems/rtems/object.h
include_rtems_rtems_HEADERS += include/rtems/rtems/objectimpl.h
include_rtems_rtems_HEADERS += include/rtems/rtems/options.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/optionsimpl.h
include_rtems_rtems_HEADERS += include/rtems/rtems/part.h include_rtems_rtems_HEADERS += include/rtems/rtems/part.h

View File

@@ -0,0 +1,82 @@
/* SPDX-License-Identifier: BSD-2-Clause */
/**
* @file
*
* @ingroup ClassicObjectImpl
*
* @brief Implementation Interfaces for Classic Objects
*/
/*
* Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _RTEMS_RTEMS_OBJECTIMPL_H
#define _RTEMS_RTEMS_OBJECTIMPL_H
#include <rtems/score/objectimpl.h>
#include <rtems/rtems/status.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @defgroup ClassicObjectImpl Classic Object Implementation
*
* @ingroup RTEMSInternalClassic
*
* @{
*/
/**
* @brief Calls _Objects_Name_to_id_u32() and converts the status.
*
* @param name is the name of the object to find.
* @param node is the set of nodes to search.
* @param[out] id is the pointer to an object identifier variable or NULL. The
* object identifier will be stored in the referenced variable, if the
* operation was successful.
* @param information is the pointer to an object class information block.
*
* @retval RTEMS_SUCCESSFUL The operations was successful.
* @retval RTEMS_INVALID_ADDRESS The id parameter was NULL.
* @retval RTEMS_INVALID_NAME No object exists with the specified name on the
* specified node set.
*/
rtems_status_code _RTEMS_Name_to_id(
uint32_t name,
uint32_t node,
Objects_Id *id,
const Objects_Information *information
);
/** @} */
#ifdef __cplusplus
}
#endif
#endif /* _RTEMS_RTEMS_OBJECTIMPL_H */

View File

@@ -221,26 +221,29 @@ typedef enum {
#define OBJECTS_NAME_ERRORS_LAST OBJECTS_INVALID_NODE #define OBJECTS_NAME_ERRORS_LAST OBJECTS_INVALID_NODE
/** /**
* @brief Converts an object name to an Id. * @brief Searches an object of the specified class with the specified name on
* the specified set of nodes.
* *
* This method converts an object name to an Id. It performs a look up * This method converts an object name to an identifier. It performs a look up
* using the object information block for this object class. * using the object information block for this object class.
* *
* @param information points to an object class information block.
* @param name is the name of the object to find. * @param name is the name of the object to find.
* @param node is the set of nodes to search. * @param node is the set of nodes to search.
* @param[out] id will contain the Id if the search is successful. * @param[out] id is the pointer to an object identifier variable or NULL. The
* object identifier will be stored in the referenced variable, if the
* operation was successful.
* @param information is the pointer to an object class information block.
* *
* @retval OBJECTS_NAME_OR_ID_LOOKUP_SUCCESSFUL The operations was successful * @retval OBJECTS_NAME_OR_ID_LOOKUP_SUCCESSFUL The operations was successful.
* @a id contains the ID. * @retval OBJECTS_INVALID_ADDRESS The id parameter was NULL.
* @retval OBJECTS_INVALID_NAME The name was invalid. * @retval OBJECTS_INVALID_NAME No object exists with the specified name on the
* @retval OBJECTS_INVALID_ID The id is not 0 before the operation. * specified node set.
*/ */
Objects_Name_or_id_lookup_errors _Objects_Name_to_id_u32( Objects_Name_or_id_lookup_errors _Objects_Name_to_id_u32(
const Objects_Information *information,
uint32_t name, uint32_t name,
uint32_t node, uint32_t node,
Objects_Id *id Objects_Id *id,
const Objects_Information *information
); );
typedef enum { typedef enum {

View File

@@ -1,41 +1,52 @@
/* SPDX-License-Identifier: BSD-2-Clause */
/** /**
* @file * @file
* *
* @brief RTEMS Barrier name to Id * @ingroup ClassicBarrierImpl
* @ingroup ClassicBarrier *
* @brief rtems_barrier_ident() Implementation
*/ */
/* /*
* COPYRIGHT (c) 1989-2006. * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
* On-Line Applications Research Corporation (OAR). * Copyright (C) 1989 On-Line Applications Research Corporation (OAR).
* *
* The license and distribution terms for this file may be * Redistribution and use in source and binary forms, with or without
* found in the file LICENSE in this distribution or at * modification, are permitted provided that the following conditions
* http://www.rtems.org/license/LICENSE. * are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
#include "config.h" #include "config.h"
#endif #endif
#include <rtems/rtems/statusimpl.h>
#include <rtems/rtems/support.h>
#include <rtems/rtems/options.h>
#include <rtems/rtems/barrierimpl.h> #include <rtems/rtems/barrierimpl.h>
#include <rtems/rtems/objectimpl.h>
rtems_status_code rtems_barrier_ident( rtems_status_code rtems_barrier_ident( rtems_name name, rtems_id *id )
rtems_name name,
rtems_id *id
)
{ {
Objects_Name_or_id_lookup_errors status; return _RTEMS_Name_to_id(
status = _Objects_Name_to_id_u32(
&_Barrier_Information,
name, name,
OBJECTS_SEARCH_LOCAL_NODE, OBJECTS_SEARCH_LOCAL_NODE,
id id,
&_Barrier_Information
); );
return _Status_Object_name_errors_to_status[ status ];
} }

View File

@@ -1,42 +1,55 @@
/* SPDX-License-Identifier: BSD-2-Clause */
/** /**
* @file * @file
* *
* @brief RTEMS Port Name to Id * @ingroup ClassicDPMEMImpl
* @ingroup ClassicDPMEM *
* @brief rtems_port_ident() Implementation
*/ */
/* /*
* COPYRIGHT (c) 1989-1999. * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
* On-Line Applications Research Corporation (OAR). * Copyright (C) 1989 On-Line Applications Research Corporation (OAR).
* *
* The license and distribution terms for this file may be * Redistribution and use in source and binary forms, with or without
* found in the file LICENSE in this distribution or at * modification, are permitted provided that the following conditions
* http://www.rtems.org/license/LICENSE. * are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
#include "config.h" #include "config.h"
#endif #endif
#include <rtems/rtems/statusimpl.h>
#include <rtems/rtems/support.h>
#include <rtems/score/address.h>
#include <rtems/rtems/dpmemimpl.h> #include <rtems/rtems/dpmemimpl.h>
#include <rtems/score/thread.h> #include <rtems/rtems/objectimpl.h>
rtems_status_code rtems_port_ident( rtems_status_code rtems_port_ident(
rtems_name name, rtems_name name,
rtems_id *id rtems_id *id
) )
{ {
Objects_Name_or_id_lookup_errors status; return _RTEMS_Name_to_id(
status = _Objects_Name_to_id_u32(
&_Dual_ported_memory_Information,
name, name,
OBJECTS_SEARCH_ALL_NODES, OBJECTS_SEARCH_ALL_NODES,
id id,
&_Dual_ported_memory_Information
); );
return _Status_Object_name_errors_to_status[ status ];
} }

View File

@@ -1,33 +1,45 @@
/* SPDX-License-Identifier: BSD-2-Clause */
/** /**
* @file * @file
* *
* @brief RTEMS Message Queue Name to Id * @ingroup ClassicMessageQueueImpl
* @ingroup ClassicMessageQueue *
* @brief rtems_message_queue_ident() Implementation
*/ */
/* /*
* COPYRIGHT (c) 1989-1999. * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
* On-Line Applications Research Corporation (OAR). * Copyright (C) 1989 On-Line Applications Research Corporation (OAR).
* *
* The license and distribution terms for this file may be * Redistribution and use in source and binary forms, with or without
* found in the file LICENSE in this distribution or at * modification, are permitted provided that the following conditions
* http://www.rtems.org/license/LICENSE. * are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
#include "config.h" #include "config.h"
#endif #endif
#include <rtems/score/chain.h>
#include <rtems/score/isr.h>
#include <rtems/score/coremsgimpl.h>
#include <rtems/score/thread.h>
#include <rtems/score/wkspace.h>
#include <rtems/rtems/statusimpl.h>
#include <rtems/rtems/attrimpl.h>
#include <rtems/rtems/messageimpl.h> #include <rtems/rtems/messageimpl.h>
#include <rtems/rtems/options.h> #include <rtems/rtems/objectimpl.h>
#include <rtems/rtems/support.h>
rtems_status_code rtems_message_queue_ident( rtems_status_code rtems_message_queue_ident(
rtems_name name, rtems_name name,
@@ -35,14 +47,5 @@ rtems_status_code rtems_message_queue_ident(
rtems_id *id rtems_id *id
) )
{ {
Objects_Name_or_id_lookup_errors status; return _RTEMS_Name_to_id( name, node, id, &_Message_queue_Information );
status = _Objects_Name_to_id_u32(
&_Message_queue_Information,
name,
node,
id
);
return _Status_Object_name_errors_to_status[ status ];
} }

View File

@@ -1,28 +1,45 @@
/* SPDX-License-Identifier: BSD-2-Clause */
/** /**
* @file * @file
* *
* @brief RTEMS Partition Name to Id * @ingroup ClassicPartitionImpl
* @ingroup ClassicPart *
* @brief rtems_partition_ident() Implementation
*/ */
/* /*
* COPYRIGHT (c) 1989-1999. * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
* On-Line Applications Research Corporation (OAR). * Copyright (C) 1989 On-Line Applications Research Corporation (OAR).
* *
* The license and distribution terms for this file may be * Redistribution and use in source and binary forms, with or without
* found in the file LICENSE in this distribution or at * modification, are permitted provided that the following conditions
* http://www.rtems.org/license/LICENSE. * are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
#include "config.h" #include "config.h"
#endif #endif
#include <rtems/rtems/statusimpl.h>
#include <rtems/rtems/support.h>
#include <rtems/score/address.h>
#include <rtems/rtems/partimpl.h> #include <rtems/rtems/partimpl.h>
#include <rtems/score/thread.h> #include <rtems/rtems/objectimpl.h>
rtems_status_code rtems_partition_ident( rtems_status_code rtems_partition_ident(
rtems_name name, rtems_name name,
@@ -30,9 +47,5 @@ rtems_status_code rtems_partition_ident(
rtems_id *id rtems_id *id
) )
{ {
Objects_Name_or_id_lookup_errors status; return _RTEMS_Name_to_id( name, node, id, &_Partition_Information );
status = _Objects_Name_to_id_u32( &_Partition_Information, name, node, id );
return _Status_Object_name_errors_to_status[ status ];
} }

View File

@@ -1,42 +1,52 @@
/* SPDX-License-Identifier: BSD-2-Clause */
/** /**
* @file * @file
* *
* @brief RTEMS Rate Monotonic Name to Id * @ingroup ClassicRateMonImpl
* @ingroup ClassicRateMon *
* @brief rtems_rate_monotonic_ident() Implementation
*/ */
/* /*
* COPYRIGHT (c) 1989-2007. * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
* On-Line Applications Research Corporation (OAR). * Copyright (C) 1989 On-Line Applications Research Corporation (OAR).
* *
* The license and distribution terms for this file may be * Redistribution and use in source and binary forms, with or without
* found in the file LICENSE in this distribution or at * modification, are permitted provided that the following conditions
* http://www.rtems.org/license/LICENSE. * are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
#include "config.h" #include "config.h"
#endif #endif
#include <rtems/rtems/statusimpl.h>
#include <rtems/rtems/support.h>
#include <rtems/score/isr.h>
#include <rtems/rtems/ratemonimpl.h> #include <rtems/rtems/ratemonimpl.h>
#include <rtems/score/thread.h> #include <rtems/rtems/objectimpl.h>
rtems_status_code rtems_rate_monotonic_ident( rtems_status_code rtems_rate_monotonic_ident( rtems_name name, rtems_id *id )
rtems_name name,
rtems_id *id
)
{ {
Objects_Name_or_id_lookup_errors status; return _RTEMS_Name_to_id(
status = _Objects_Name_to_id_u32(
&_Rate_monotonic_Information,
name, name,
OBJECTS_SEARCH_LOCAL_NODE, OBJECTS_SEARCH_LOCAL_NODE,
id id,
&_Rate_monotonic_Information
); );
return _Status_Object_name_errors_to_status[ status ];
} }

View File

@@ -1,43 +1,52 @@
/* SPDX-License-Identifier: BSD-2-Clause */
/** /**
* @file * @file
* *
* @brief RTEMS Region Name to Id * @ingroup ClassicRegionImpl
* @ingroup ClassicRegion *
* @brief rtems_region_ident() Implementation
*/ */
/* /*
* COPYRIGHT (c) 1989-1999. * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
* On-Line Applications Research Corporation (OAR). * Copyright (C) 1989 On-Line Applications Research Corporation (OAR).
* *
* The license and distribution terms for this file may be * Redistribution and use in source and binary forms, with or without
* found in the file LICENSE in this distribution or at * modification, are permitted provided that the following conditions
* http://www.rtems.org/license/LICENSE. * are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
#include "config.h" #include "config.h"
#endif #endif
#include <rtems/rtems/statusimpl.h>
#include <rtems/rtems/support.h>
#include <rtems/rtems/options.h>
#include <rtems/rtems/regionimpl.h> #include <rtems/rtems/regionimpl.h>
#include <rtems/score/thread.h> #include <rtems/rtems/objectimpl.h>
#include <rtems/score/apimutex.h>
rtems_status_code rtems_region_ident( rtems_status_code rtems_region_ident( rtems_name name, rtems_id *id )
rtems_name name,
rtems_id *id
)
{ {
Objects_Name_or_id_lookup_errors status; return _RTEMS_Name_to_id(
status = _Objects_Name_to_id_u32(
&_Region_Information,
name, name,
OBJECTS_SEARCH_LOCAL_NODE, OBJECTS_SEARCH_LOCAL_NODE,
id id,
&_Region_Information
); );
return _Status_Object_name_errors_to_status[ status ];
} }

View File

@@ -0,0 +1,55 @@
/* SPDX-License-Identifier: BSD-2-Clause */
/**
* @file
*
* @ingroup ClassicObjectImpl
*
* @brief _RTEMS_Name_to_id() Implementation
*/
/*
* Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <rtems/rtems/objectimpl.h>
#include <rtems/rtems/statusimpl.h>
rtems_status_code _RTEMS_Name_to_id(
uint32_t name,
uint32_t node,
Objects_Id *id,
const Objects_Information *information
)
{
Objects_Name_or_id_lookup_errors status;
status = _Objects_Name_to_id_u32( name, node, id, information );
return _Status_Object_name_errors_to_status[ status ];
}

View File

@@ -1,17 +1,37 @@
/* SPDX-License-Identifier: BSD-2-Clause */
/** /**
* @file * @file
* *
* @brief RTEMS Semaphore Name to Id * @ingroup ClassicSemImpl
* @ingroup ClassicSem *
* @brief rtems_semaphore_ident() Implementation
*/ */
/* /*
* COPYRIGHT (c) 1989-1999. * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
* On-Line Applications Research Corporation (OAR). * Copyright (C) 1989 On-Line Applications Research Corporation (OAR).
* *
* The license and distribution terms for this file may be * Redistribution and use in source and binary forms, with or without
* found in the file LICENSE in this distribution or at * modification, are permitted provided that the following conditions
* http://www.rtems.org/license/LICENSE. * are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
@@ -19,7 +39,7 @@
#endif #endif
#include <rtems/rtems/semimpl.h> #include <rtems/rtems/semimpl.h>
#include <rtems/rtems/statusimpl.h> #include <rtems/rtems/objectimpl.h>
rtems_status_code rtems_semaphore_ident( rtems_status_code rtems_semaphore_ident(
rtems_name name, rtems_name name,
@@ -27,9 +47,5 @@ rtems_status_code rtems_semaphore_ident(
rtems_id *id rtems_id *id
) )
{ {
Objects_Name_or_id_lookup_errors status; return _RTEMS_Name_to_id( name, node, id, &_Semaphore_Information );
status = _Objects_Name_to_id_u32( &_Semaphore_Information, name, node, id );
return _Status_Object_name_errors_to_status[ status ];
} }

View File

@@ -1,53 +1,66 @@
/* SPDX-License-Identifier: BSD-2-Clause */
/** /**
* @file * @file
* *
* @brief RTEMS Task Name to Id * @ingroup ClassicTasksImpl
* @ingroup ClassicTasks *
* @brief rtems_task_ident() Implementation
*/ */
/* /*
* COPYRIGHT (c) 1989-1999. * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
* On-Line Applications Research Corporation (OAR). * Copyright (C) 1989 On-Line Applications Research Corporation (OAR).
* *
* The license and distribution terms for this file may be * Redistribution and use in source and binary forms, with or without
* found in the file LICENSE in this distribution or at * modification, are permitted provided that the following conditions
* http://www.rtems.org/license/LICENSE. * are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
#include "config.h" #include "config.h"
#endif #endif
#include <rtems/rtems/statusimpl.h>
#include <rtems/rtems/support.h>
#include <rtems/rtems/modes.h>
#include <rtems/score/stack.h>
#include <rtems/rtems/tasksimpl.h> #include <rtems/rtems/tasksimpl.h>
#include <rtems/score/thread.h> #include <rtems/rtems/objectimpl.h>
#include <rtems/score/wkspace.h> #include <rtems/score/percpu.h>
rtems_status_code rtems_task_ident( rtems_status_code rtems_task_ident(
rtems_name name, rtems_name name,
uint32_t node, uint32_t node,
rtems_id *id rtems_id *id
) )
{ {
Objects_Name_or_id_lookup_errors status; if ( id == NULL ) {
if ( !id )
return RTEMS_INVALID_ADDRESS; return RTEMS_INVALID_ADDRESS;
}
if ( name == OBJECTS_ID_OF_SELF ) { if ( name == OBJECTS_ID_OF_SELF ) {
*id = _Thread_Get_executing()->Object.id; *id = _Thread_Get_executing()->Object.id;
return RTEMS_SUCCESSFUL; return RTEMS_SUCCESSFUL;
} }
status = _Objects_Name_to_id_u32( return _RTEMS_Name_to_id(
&_RTEMS_tasks_Information.Objects,
name, name,
node, node,
id id,
&_RTEMS_tasks_Information.Objects
); );
return _Status_Object_name_errors_to_status[ status ];
} }

View File

@@ -1,42 +1,52 @@
/* SPDX-License-Identifier: BSD-2-Clause */
/** /**
* @file * @file
* *
* @brief RTEMS Timer Name to Id * @ingroup ClassicTimerImpl
* @ingroup ClassicTimer *
* @brief rtems_timer_ident() Implementation
*/ */
/* /*
* COPYRIGHT (c) 1989-2002. * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
* On-Line Applications Research Corporation (OAR). * Copyright (C) 1989 On-Line Applications Research Corporation (OAR).
* *
* The license and distribution terms for this file may be * Redistribution and use in source and binary forms, with or without
* found in the file LICENSE in this distribution or at * modification, are permitted provided that the following conditions
* http://www.rtems.org/license/LICENSE. * are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
#include "config.h" #include "config.h"
#endif #endif
#include <rtems/rtems/statusimpl.h>
#include <rtems/rtems/support.h>
#include <rtems/score/thread.h>
#include <rtems/rtems/timerimpl.h> #include <rtems/rtems/timerimpl.h>
#include <rtems/score/watchdog.h> #include <rtems/rtems/objectimpl.h>
rtems_status_code rtems_timer_ident( rtems_status_code rtems_timer_ident( rtems_name name, rtems_id *id )
rtems_name name,
rtems_id *id
)
{ {
Objects_Name_or_id_lookup_errors status; return _RTEMS_Name_to_id(
status = _Objects_Name_to_id_u32(
&_Timer_Information,
name, name,
OBJECTS_SEARCH_LOCAL_NODE, OBJECTS_SEARCH_LOCAL_NODE,
id id,
&_Timer_Information
); );
return _Status_Object_name_errors_to_status[ status ];
} }

View File

@@ -1,42 +1,52 @@
/* SPDX-License-Identifier: BSD-2-Clause */
/** /**
* @file * @file
* *
* @ingroup ClassicUserExtensions * @ingroup ClassicUserExtensionsImpl
* *
* @brief User Extensions Implementation. * @brief rtems_extension_ident() Implementation
*/ */
/* /*
* COPYRIGHT (c) 1989-2007. * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
* On-Line Applications Research Corporation (OAR). * Copyright (C) 1989 On-Line Applications Research Corporation (OAR).
* *
* The license and distribution terms for this file may be * Redistribution and use in source and binary forms, with or without
* found in the file LICENSE in this distribution or at * modification, are permitted provided that the following conditions
* http://www.rtems.org/license/LICENSE. * are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
#include "config.h" #include "config.h"
#endif #endif
#include <rtems/rtems/statusimpl.h>
#include <rtems/rtems/support.h>
#include <rtems/score/thread.h>
#include <rtems/extensionimpl.h> #include <rtems/extensionimpl.h>
#include <rtems/rtems/objectimpl.h>
rtems_status_code rtems_extension_ident( rtems_status_code rtems_extension_ident( rtems_name name, rtems_id *id )
rtems_name name,
rtems_id *id
)
{ {
Objects_Name_or_id_lookup_errors status; return _RTEMS_Name_to_id(
status = _Objects_Name_to_id_u32(
&_Extension_Information,
name, name,
OBJECTS_SEARCH_LOCAL_NODE, OBJECTS_SEARCH_LOCAL_NODE,
id id,
&_Extension_Information
); );
return _Status_Object_name_errors_to_status[ status ];
} }

View File

@@ -21,10 +21,10 @@
#include <rtems/score/objectimpl.h> #include <rtems/score/objectimpl.h>
Objects_Name_or_id_lookup_errors _Objects_Name_to_id_u32( Objects_Name_or_id_lookup_errors _Objects_Name_to_id_u32(
const Objects_Information *information,
uint32_t name, uint32_t name,
uint32_t node, uint32_t node,
Objects_Id *id Objects_Id *id,
const Objects_Information *information
) )
{ {
bool search_local_node; bool search_local_node;

View File

@@ -81,10 +81,10 @@ rtems_task Init(
TEST_BEGIN(); TEST_BEGIN();
status = _Objects_Name_to_id_u32( status = _Objects_Name_to_id_u32(
&_Thread_Information.Objects,
rtems_build_name( 'I', 'D', 'L', 'E' ), rtems_build_name( 'I', 'D', 'L', 'E' ),
RTEMS_SEARCH_LOCAL_NODE, RTEMS_SEARCH_LOCAL_NODE,
&Idle_id &Idle_id,
&_Thread_Information.Objects
); );
rtems_test_assert( status == RTEMS_SUCCESSFUL ); rtems_test_assert( status == RTEMS_SUCCESSFUL );