From chrisj at rtems.org Thu Dec 2 01:05:47 2021 From: chrisj at rtems.org (Chris Johns) Date: Thu, 2 Dec 2021 12:05:47 +1100 Subject: [PATCH 1/1] Update rtems-notes-5.md In-Reply-To: <20211130150307.15090-2-gabriel.moyano@dlr.de> References: <20211130150307.15090-1-gabriel.moyano@dlr.de> <20211130150307.15090-2-gabriel.moyano@dlr.de> Message-ID: <6f424045-6ae3-1f06-f54f-c2056b961f93@rtems.org> OK to push. Thanks Chris On 1/12/21 2:03 am, Moyano, Gabriel wrote: > --- > rtems-notes-5.md | 9 +++++++++ > 1 file changed, 9 insertions(+) > > diff --git a/rtems-notes-5.md b/rtems-notes-5.md > index 3737199..7697980 100644 > --- a/rtems-notes-5.md > +++ b/rtems-notes-5.md > @@ -374,3 +374,12 @@ Obsoleted architectures: > * RTEMS Trace addition of a new trace record support for target tracing. > > * RTEMS Bootimage, a tool to portably create SD card images. > + > +## RTEMS 5.2 Release Notes > + > +### API Changes > + > +#### API Additions > + > +* NTP support > + * Addition of NTP update second handler via _Timecounter_Set_NTP_update_second() from > From sebastian.huber at embedded-brains.de Thu Dec 2 13:21:44 2021 From: sebastian.huber at embedded-brains.de (Sebastian Huber) Date: Thu, 2 Dec 2021 14:21:44 +0100 Subject: [PATCH] rtems: Move scheduler directives to own header Message-ID: <20211202132144.91476-1-sebastian.huber@embedded-brains.de> Move all rtems_scheduler_* directives to the new header file . Add a Scheduler Manager API and implementation group. --- cpukit/include/rtems.h | 1 + cpukit/include/rtems/rtems/scheduler.h | 551 ++++++++++++++++++ cpukit/include/rtems/rtems/tasks.h | 480 +-------------- cpukit/include/rtems/rtems/tasksimpl.h | 8 + cpukit/libmisc/cpuuse/cpuusagereset.c | 1 + cpukit/rtems/src/scheduleraddprocessor.c | 4 +- cpukit/rtems/src/schedulergetmaxprio.c | 4 +- cpukit/rtems/src/schedulergetprocessor.c | 4 +- cpukit/rtems/src/schedulergetprocessormax.c | 4 +- cpukit/rtems/src/schedulergetprocessorset.c | 4 +- cpukit/rtems/src/schedulerident.c | 4 +- cpukit/rtems/src/scheduleridentbyprocessor.c | 4 +- .../rtems/src/scheduleridentbyprocessorset.c | 4 +- cpukit/rtems/src/schedulermapfromposix.c | 4 +- cpukit/rtems/src/schedulermaptoposix.c | 4 +- cpukit/rtems/src/schedulerremoveprocessor.c | 4 +- spec/build/cpukit/librtemscpu.yml | 1 + 17 files changed, 585 insertions(+), 501 deletions(-) create mode 100644 cpukit/include/rtems/rtems/scheduler.h diff --git a/cpukit/include/rtems.h b/cpukit/include/rtems.h index 32d7769150..809b2b77f4 100644 --- a/cpukit/include/rtems.h +++ b/cpukit/include/rtems.h @@ -73,6 +73,7 @@ #include #include #include +#include #include #include #include diff --git a/cpukit/include/rtems/rtems/scheduler.h b/cpukit/include/rtems/rtems/scheduler.h new file mode 100644 index 0000000000..8bd041558f --- /dev/null +++ b/cpukit/include/rtems/rtems/scheduler.h @@ -0,0 +1,551 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSImplClassicScheduler + * + * @brief This header file defines the main parts of the Scheduler Manager API. + */ + +/* + * Copyright (C) 2013, 2021 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 1988, 2017 On-Line Applications Research Corporation (OAR) + * + * 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. + */ + +/* + * This file is part of the RTEMS quality process and was automatically + * generated. If you find something that needs to be fixed or + * worded better please post a report or patch to an RTEMS mailing list + * or raise a bug report: + * + * https://www.rtems.org/bugs.html + * + * For information on updating and regenerating please refer to the How-To + * section in the Software Requirements Engineering chapter of the + * RTEMS Software Engineering manual. The manual is provided as a part of + * a release. For development sources please refer to the online + * documentation at: + * + * https://docs.rtems.org + */ + +/* Generated from spec:/rtems/scheduler/if/header */ + +#ifndef _RTEMS_RTEMS_SCHEDULER_H +#define _RTEMS_RTEMS_SCHEDULER_H + +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Generated from spec:/rtems/scheduler/if/group */ + +/** + * @defgroup RTEMSAPIClassicScheduler Scheduler Manager + * + * @ingroup RTEMSAPIClassic + * + * @brief The scheduling concepts relate to the allocation of processing time + * for tasks. + * + * The concept of scheduling in real-time systems dictates the ability to + * provide an immediate response to specific external events, particularly the + * necessity of scheduling tasks to run within a specified time limit after the + * occurrence of an event. For example, software embedded in life-support + * systems used to monitor hospital patients must take instant action if a + * change in the patient?s status is detected. + * + * The component of RTEMS responsible for providing this capability is + * appropriately called the scheduler. The scheduler?s sole purpose is to + * allocate the all important resource of processor time to the various tasks + * competing for attention. + */ + +/* Generated from spec:/rtems/scheduler/if/ident */ + +/** + * @ingroup RTEMSAPIClassicScheduler + * + * @brief Identifies a scheduler by the object name. + * + * @param name is the scheduler name to look up. + * + * @param[out] id is the pointer to an ::rtems_id object. When the directive + * call is successful, the identifier of the scheduler will be stored in this + * object. + * + * This directive obtains a scheduler identifier associated with the scheduler + * name specified in ``name``. + * + * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. + * + * @retval ::RTEMS_INVALID_NAME There was no scheduler associated with the + * name. + * + * @retval ::RTEMS_INVALID_ADDRESS The ``id`` parameter was NULL. + * + * @par Notes + * @parblock + * The scheduler name is determined by the scheduler configuration. + * + * The scheduler identifier is used with other scheduler related directives to + * access the scheduler. + * @endparblock + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within any runtime context. + * + * * The directive will not cause the calling task to be preempted. + * @endparblock + */ +rtems_status_code rtems_scheduler_ident( rtems_name name, rtems_id *id ); + +/* Generated from spec:/rtems/scheduler/if/ident-by-processor */ + +/** + * @ingroup RTEMSAPIClassicScheduler + * + * @brief Identifies a scheduler by the processor index. + * + * @param cpu_index is the processor index to identify the scheduler. + * + * @param[out] id is the pointer to an ::rtems_id object. When the directive + * call is successful, the identifier of the scheduler will be stored in this + * object. + * + * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. + * + * @retval ::RTEMS_INVALID_ADDRESS The ``id`` parameter was NULL. + * + * @retval ::RTEMS_INVALID_NAME The processor index was invalid. + * + * @retval ::RTEMS_INCORRECT_STATE The processor index was valid, however, the + * corresponding processor was not owned by a scheduler. + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within any runtime context. + * + * * The directive will not cause the calling task to be preempted. + * @endparblock + */ +rtems_status_code rtems_scheduler_ident_by_processor( + uint32_t cpu_index, + rtems_id *id +); + +/* Generated from spec:/rtems/scheduler/if/ident-by-processor-set */ + +/** + * @ingroup RTEMSAPIClassicScheduler + * + * @brief Identifies a scheduler by the processor set. + * + * @param cpusetsize is the size of the processor set referenced by ``cpuset`` + * in bytes. The size shall be positive. + * + * @param cpuset is the pointer to a cpu_set_t. The referenced processor set + * will be used to identify the scheduler. + * + * @param[out] id is the pointer to an ::rtems_id object. When the directive + * call is successful, the identifier of the scheduler will be stored in this + * object. + * + * The scheduler is selected according to the highest numbered online processor + * in the specified processor set. + * + * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. + * + * @retval ::RTEMS_INVALID_ADDRESS The ``id`` parameter was NULL. + * + * @retval ::RTEMS_INVALID_ADDRESS The ``cpuset`` parameter was NULL. + * + * @retval ::RTEMS_INVALID_SIZE The processor set size was invalid. + * + * @retval ::RTEMS_INVALID_NAME The processor set contained no online + * processor. + * + * @retval ::RTEMS_INCORRECT_STATE The processor set was valid, however, the + * highest numbered online processor in the processor set was not owned by a + * scheduler. + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within any runtime context. + * + * * The directive will not cause the calling task to be preempted. + * @endparblock + */ +rtems_status_code rtems_scheduler_ident_by_processor_set( + size_t cpusetsize, + const cpu_set_t *cpuset, + rtems_id *id +); + +/* Generated from spec:/rtems/scheduler/if/get-maximum-priority */ + +/** + * @ingroup RTEMSAPIClassicScheduler + * + * @brief Gets the maximum task priority of the scheduler. + * + * @param scheduler_id is the scheduler identifier. + * + * @param[out] priority is the pointer to an ::rtems_task_priority object. + * When the directive the maximum priority of the scheduler will be stored in + * this object. + * + * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. + * + * @retval ::RTEMS_INVALID_ID There was no scheduler associated with the + * identifier specified by ``scheduler_id``. + * + * @retval ::RTEMS_INVALID_ADDRESS The ``priority`` parameter was NULL. + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within any runtime context. + * + * * The directive will not cause the calling task to be preempted. + * @endparblock + */ +rtems_status_code rtems_scheduler_get_maximum_priority( + rtems_id scheduler_id, + rtems_task_priority *priority +); + +/* Generated from spec:/rtems/scheduler/if/map-priority-to-posix */ + +/** + * @ingroup RTEMSAPIClassicScheduler + * + * @brief Maps a Classic API task priority to the corresponding POSIX thread + * priority. + * + * @param scheduler_id is the scheduler identifier. + * + * @param priority is the Classic API task priority to map. + * + * @param[out] posix_priority is the pointer to an ``int`` object. When the + * directive call is successful, the POSIX thread priority value + * corresponding to the specified Classic API task priority value will be + * stored in this object. + * + * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. + * + * @retval ::RTEMS_INVALID_ADDRESS The ``posix_priority`` parameter was NULL. + * + * @retval ::RTEMS_INVALID_ID There was no scheduler associated with the + * identifier specified by ``scheduler_id``. + * + * @retval ::RTEMS_INVALID_PRIORITY The Classic API task priority was invalid. + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within any runtime context. + * + * * The directive will not cause the calling task to be preempted. + * @endparblock + */ +rtems_status_code rtems_scheduler_map_priority_to_posix( + rtems_id scheduler_id, + rtems_task_priority priority, + int *posix_priority +); + +/* Generated from spec:/rtems/scheduler/if/map-priority-from-posix */ + +/** + * @ingroup RTEMSAPIClassicScheduler + * + * @brief Maps a POSIX thread priority to the corresponding Classic API task + * priority. + * + * @param scheduler_id is the scheduler identifier. + * + * @param posix_priority is the POSIX thread priority to map. + * + * @param[out] priority is the pointer to an ::rtems_task_priority object. + * When the directive call is successful, the Classic API task priority value + * corresponding to the specified POSIX thread priority value will be stored + * in this object. + * + * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. + * + * @retval ::RTEMS_INVALID_ADDRESS The ``priority`` parameter was NULL. + * + * @retval ::RTEMS_INVALID_ID There was no scheduler associated with the + * identifier specified by ``scheduler_id``. + * + * @retval ::RTEMS_INVALID_PRIORITY The POSIX thread priority was invalid. + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within any runtime context. + * + * * The directive will not cause the calling task to be preempted. + * @endparblock + */ +rtems_status_code rtems_scheduler_map_priority_from_posix( + rtems_id scheduler_id, + int posix_priority, + rtems_task_priority *priority +); + +/* Generated from spec:/rtems/scheduler/if/get-processor */ + +/** + * @ingroup RTEMSAPIClassicScheduler + * + * @brief Returns the index of the current processor. + * + * Where the system was built with SMP support disabled, this directive + * evaluates to a compile time constant of zero. + * + * Where the system was built with SMP support enabled, this directive returns + * the index of the current processor. The set of processor indices is the + * range of integers starting with zero up to + * rtems_scheduler_get_processor_maximum() minus one. + * + * @return Returns the index of the current processor. + * + * @par Notes + * Outside of sections with disabled thread dispatching the current processor + * index may change after every instruction since the thread may migrate from + * one processor to another. Sections with disabled interrupts are sections + * with thread dispatching disabled. + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within any runtime context. + * + * * The directive will not cause the calling task to be preempted. + * @endparblock + */ +uint32_t rtems_scheduler_get_processor( void ); + +/* Generated from spec:/rtems/scheduler/if/get-processor-macro */ +#define rtems_scheduler_get_processor() _SMP_Get_current_processor() + +/* Generated from spec:/rtems/scheduler/if/get-processor-maximum */ + +/** + * @ingroup RTEMSAPIClassicScheduler + * + * @brief Returns the processor maximum supported by the system. + * + * Where the system was built with SMP support disabled, this directive + * evaluates to a compile time constant of one. + * + * Where the system was built with SMP support enabled, this directive returns + * the minimum of the processors (physically or virtually) available at the + * target and the configured processor maximum (see + * #CONFIGURE_MAXIMUM_PROCESSORS). Not all processors in the range from + * processor index zero to the last processor index (which is the processor + * maximum minus one) may be configured to be used by a scheduler or may be + * online (online processors have a scheduler assigned). + * + * @return Returns the processor maximum supported by the system. + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within any runtime context. + * + * * The directive will not cause the calling task to be preempted. + * @endparblock + */ +uint32_t rtems_scheduler_get_processor_maximum( void ); + +/* Generated from spec:/rtems/scheduler/if/get-processor-maximum-macro */ +#define rtems_scheduler_get_processor_maximum() _SMP_Get_processor_maximum() + +/* Generated from spec:/rtems/scheduler/if/get-processor-set */ + +/** + * @ingroup RTEMSAPIClassicScheduler + * + * @brief Gets the set of processors owned by the scheduler. + * + * @param scheduler_id is the scheduler identifier. + * + * @param cpusetsize is the size of the processor set referenced by ``cpuset`` + * in bytes. + * + * @param[out] cpuset is the pointer to a cpu_set_t object. When the directive + * call is successful, the processor set of the scheduler will be stored in + * this object. A set bit in the processor set means that the corresponding + * processor is owned by the scheduler, otherwise the bit is cleared. + * + * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. + * + * @retval ::RTEMS_INVALID_ADDRESS The ``cpuset`` parameter was NULL. + * + * @retval ::RTEMS_INVALID_ID There was no scheduler associated with the + * identifier specified by ``scheduler_id``. + * + * @retval ::RTEMS_INVALID_SIZE The provided processor set was too small for + * the set of processors owned by the scheduler. + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within any runtime context. + * + * * The directive will not cause the calling task to be preempted. + * @endparblock + */ +rtems_status_code rtems_scheduler_get_processor_set( + rtems_id scheduler_id, + size_t cpusetsize, + cpu_set_t *cpuset +); + +/* Generated from spec:/rtems/scheduler/if/add-processor */ + +/** + * @ingroup RTEMSAPIClassicScheduler + * + * @brief Adds the processor to the set of processors owned by the scheduler. + * + * @param scheduler_id is the scheduler identifier. + * + * @param cpu_index is the index of the processor to add. + * + * This directive adds the processor specified by the ``cpu_index`` to the + * scheduler specified by ``scheduler_id``. + * + * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. + * + * @retval ::RTEMS_INVALID_ID There was no scheduler associated with the + * identifier specified by ``scheduler_id``. + * + * @retval ::RTEMS_NOT_CONFIGURED The processor was not configured to be used + * by the application. + * + * @retval ::RTEMS_INCORRECT_STATE The processor was configured to be used by + * the application, however, it was not online. + * + * @retval ::RTEMS_RESOURCE_IN_USE The processor was already assigned to a + * scheduler. + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within device driver initialization + * context. + * + * * The directive may be called from within task context. + * + * * The directive may obtain and release the object allocator mutex. This may + * cause the calling task to be preempted. + * @endparblock + */ +rtems_status_code rtems_scheduler_add_processor( + rtems_id scheduler_id, + uint32_t cpu_index +); + +/* Generated from spec:/rtems/scheduler/if/remove-processor */ + +/** + * @ingroup RTEMSAPIClassicScheduler + * + * @brief Removes the processor from the set of processors owned by the + * scheduler. + * + * @param scheduler_id is the scheduler identifier. + * + * @param cpu_index is the index of the processor to remove. + * + * This directive removes the processor specified by the ``cpu_index`` from the + * scheduler specified by ``scheduler_id``. + * + * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. + * + * @retval ::RTEMS_INVALID_ID There was no scheduler associated with the + * identifier specified by ``scheduler_id``. + * + * @retval ::RTEMS_INVALID_NUMBER The processor was not owned by the scheduler. + * + * @retval ::RTEMS_RESOURCE_IN_USE The processor was required by at least one + * non-idle task that used the scheduler as its home scheduler. + * + * @retval ::RTEMS_RESOURCE_IN_USE The processor was the last processor owned + * by the scheduler and there was at least one task that used the scheduler + * as a helping scheduler. + * + * @par Notes + * Removing a processor from a scheduler is a complex operation that involves + * all tasks of the system. + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within device driver initialization + * context. + * + * * The directive may be called from within task context. + * + * * The directive may obtain and release the object allocator mutex. This may + * cause the calling task to be preempted. + * @endparblock + */ +rtems_status_code rtems_scheduler_remove_processor( + rtems_id scheduler_id, + uint32_t cpu_index +); + +#ifdef __cplusplus +} +#endif + +#endif /* _RTEMS_RTEMS_SCHEDULER_H */ diff --git a/cpukit/include/rtems/rtems/tasks.h b/cpukit/include/rtems/rtems/tasks.h index 8e87bfd14a..e4609f6e9f 100644 --- a/cpukit/include/rtems/rtems/tasks.h +++ b/cpukit/include/rtems/rtems/tasks.h @@ -9,7 +9,7 @@ */ /* - * Copyright (C) 2013, 2021 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 2020, 2021 embedded brains GmbH (http://www.embedded-brains.de) * Copyright (C) 1988, 2017 On-Line Applications Research Corporation (OAR) * * Redistribution and use in source and binary forms, with or without @@ -68,7 +68,6 @@ #include #include #include -#include #include #include @@ -76,29 +75,6 @@ extern "C" { #endif -/* Generated from spec:/rtems/scheduler/if/group */ - -/** - * @defgroup RTEMSAPIClassicScheduler Scheduler Manager - * - * @ingroup RTEMSAPIClassic - * - * @brief The scheduling concepts relate to the allocation of processing time - * for tasks. - * - * The concept of scheduling in real-time systems dictates the ability to - * provide an immediate response to specific external events, particularly the - * necessity of scheduling tasks to run within a specified time limit after the - * occurrence of an event. For example, software embedded in life-support - * systems used to monitor hospital patients must take instant action if a - * change in the patient?s status is detected. - * - * The component of RTEMS responsible for providing this capability is - * appropriately called the scheduler. The scheduler?s sole purpose is to - * allocate the all important resource of processor time to the various tasks - * competing for attention. - */ - /* Generated from spec:/rtems/task/if/group */ /** @@ -442,460 +418,6 @@ rtems_task_priority _RTEMS_Maximum_priority( void ); */ #define RTEMS_MAXIMUM_PRIORITY _RTEMS_Maximum_priority() -/* Generated from spec:/rtems/scheduler/if/ident */ - -/** - * @ingroup RTEMSAPIClassicScheduler - * - * @brief Identifies a scheduler by the object name. - * - * @param name is the scheduler name to look up. - * - * @param[out] id is the pointer to an ::rtems_id object. When the directive - * call is successful, the identifier of the scheduler will be stored in this - * object. - * - * This directive obtains a scheduler identifier associated with the scheduler - * name specified in ``name``. - * - * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. - * - * @retval ::RTEMS_INVALID_NAME There was no scheduler associated with the - * name. - * - * @retval ::RTEMS_INVALID_ADDRESS The ``id`` parameter was NULL. - * - * @par Notes - * @parblock - * The scheduler name is determined by the scheduler configuration. - * - * The scheduler identifier is used with other scheduler related directives to - * access the scheduler. - * @endparblock - * - * @par Constraints - * @parblock - * The following constraints apply to this directive: - * - * * The directive may be called from within any runtime context. - * - * * The directive will not cause the calling task to be preempted. - * @endparblock - */ -rtems_status_code rtems_scheduler_ident( rtems_name name, rtems_id *id ); - -/* Generated from spec:/rtems/scheduler/if/ident-by-processor */ - -/** - * @ingroup RTEMSAPIClassicScheduler - * - * @brief Identifies a scheduler by the processor index. - * - * @param cpu_index is the processor index to identify the scheduler. - * - * @param[out] id is the pointer to an ::rtems_id object. When the directive - * call is successful, the identifier of the scheduler will be stored in this - * object. - * - * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. - * - * @retval ::RTEMS_INVALID_ADDRESS The ``id`` parameter was NULL. - * - * @retval ::RTEMS_INVALID_NAME The processor index was invalid. - * - * @retval ::RTEMS_INCORRECT_STATE The processor index was valid, however, the - * corresponding processor was not owned by a scheduler. - * - * @par Constraints - * @parblock - * The following constraints apply to this directive: - * - * * The directive may be called from within any runtime context. - * - * * The directive will not cause the calling task to be preempted. - * @endparblock - */ -rtems_status_code rtems_scheduler_ident_by_processor( - uint32_t cpu_index, - rtems_id *id -); - -/* Generated from spec:/rtems/scheduler/if/ident-by-processor-set */ - -/** - * @ingroup RTEMSAPIClassicScheduler - * - * @brief Identifies a scheduler by the processor set. - * - * @param cpusetsize is the size of the processor set referenced by ``cpuset`` - * in bytes. The size shall be positive. - * - * @param cpuset is the pointer to a cpu_set_t. The referenced processor set - * will be used to identify the scheduler. - * - * @param[out] id is the pointer to an ::rtems_id object. When the directive - * call is successful, the identifier of the scheduler will be stored in this - * object. - * - * The scheduler is selected according to the highest numbered online processor - * in the specified processor set. - * - * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. - * - * @retval ::RTEMS_INVALID_ADDRESS The ``id`` parameter was NULL. - * - * @retval ::RTEMS_INVALID_ADDRESS The ``cpuset`` parameter was NULL. - * - * @retval ::RTEMS_INVALID_SIZE The processor set size was invalid. - * - * @retval ::RTEMS_INVALID_NAME The processor set contained no online - * processor. - * - * @retval ::RTEMS_INCORRECT_STATE The processor set was valid, however, the - * highest numbered online processor in the processor set was not owned by a - * scheduler. - * - * @par Constraints - * @parblock - * The following constraints apply to this directive: - * - * * The directive may be called from within any runtime context. - * - * * The directive will not cause the calling task to be preempted. - * @endparblock - */ -rtems_status_code rtems_scheduler_ident_by_processor_set( - size_t cpusetsize, - const cpu_set_t *cpuset, - rtems_id *id -); - -/* Generated from spec:/rtems/scheduler/if/get-maximum-priority */ - -/** - * @ingroup RTEMSAPIClassicScheduler - * - * @brief Gets the maximum task priority of the scheduler. - * - * @param scheduler_id is the scheduler identifier. - * - * @param[out] priority is the pointer to an ::rtems_task_priority object. - * When the directive the maximum priority of the scheduler will be stored in - * this object. - * - * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. - * - * @retval ::RTEMS_INVALID_ID There was no scheduler associated with the - * identifier specified by ``scheduler_id``. - * - * @retval ::RTEMS_INVALID_ADDRESS The ``priority`` parameter was NULL. - * - * @par Constraints - * @parblock - * The following constraints apply to this directive: - * - * * The directive may be called from within any runtime context. - * - * * The directive will not cause the calling task to be preempted. - * @endparblock - */ -rtems_status_code rtems_scheduler_get_maximum_priority( - rtems_id scheduler_id, - rtems_task_priority *priority -); - -/* Generated from spec:/rtems/scheduler/if/map-priority-to-posix */ - -/** - * @ingroup RTEMSAPIClassicScheduler - * - * @brief Maps a Classic API task priority to the corresponding POSIX thread - * priority. - * - * @param scheduler_id is the scheduler identifier. - * - * @param priority is the Classic API task priority to map. - * - * @param[out] posix_priority is the pointer to an ``int`` object. When the - * directive call is successful, the POSIX thread priority value - * corresponding to the specified Classic API task priority value will be - * stored in this object. - * - * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. - * - * @retval ::RTEMS_INVALID_ADDRESS The ``posix_priority`` parameter was NULL. - * - * @retval ::RTEMS_INVALID_ID There was no scheduler associated with the - * identifier specified by ``scheduler_id``. - * - * @retval ::RTEMS_INVALID_PRIORITY The Classic API task priority was invalid. - * - * @par Constraints - * @parblock - * The following constraints apply to this directive: - * - * * The directive may be called from within any runtime context. - * - * * The directive will not cause the calling task to be preempted. - * @endparblock - */ -rtems_status_code rtems_scheduler_map_priority_to_posix( - rtems_id scheduler_id, - rtems_task_priority priority, - int *posix_priority -); - -/* Generated from spec:/rtems/scheduler/if/map-priority-from-posix */ - -/** - * @ingroup RTEMSAPIClassicScheduler - * - * @brief Maps a POSIX thread priority to the corresponding Classic API task - * priority. - * - * @param scheduler_id is the scheduler identifier. - * - * @param posix_priority is the POSIX thread priority to map. - * - * @param[out] priority is the pointer to an ::rtems_task_priority object. - * When the directive call is successful, the Classic API task priority value - * corresponding to the specified POSIX thread priority value will be stored - * in this object. - * - * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. - * - * @retval ::RTEMS_INVALID_ADDRESS The ``priority`` parameter was NULL. - * - * @retval ::RTEMS_INVALID_ID There was no scheduler associated with the - * identifier specified by ``scheduler_id``. - * - * @retval ::RTEMS_INVALID_PRIORITY The POSIX thread priority was invalid. - * - * @par Constraints - * @parblock - * The following constraints apply to this directive: - * - * * The directive may be called from within any runtime context. - * - * * The directive will not cause the calling task to be preempted. - * @endparblock - */ -rtems_status_code rtems_scheduler_map_priority_from_posix( - rtems_id scheduler_id, - int posix_priority, - rtems_task_priority *priority -); - -/* Generated from spec:/rtems/scheduler/if/get-processor */ - -/** - * @ingroup RTEMSAPIClassicScheduler - * - * @brief Returns the index of the current processor. - * - * Where the system was built with SMP support disabled, this directive - * evaluates to a compile time constant of zero. - * - * Where the system was built with SMP support enabled, this directive returns - * the index of the current processor. The set of processor indices is the - * range of integers starting with zero up to - * rtems_scheduler_get_processor_maximum() minus one. - * - * @return Returns the index of the current processor. - * - * @par Notes - * Outside of sections with disabled thread dispatching the current processor - * index may change after every instruction since the thread may migrate from - * one processor to another. Sections with disabled interrupts are sections - * with thread dispatching disabled. - * - * @par Constraints - * @parblock - * The following constraints apply to this directive: - * - * * The directive may be called from within any runtime context. - * - * * The directive will not cause the calling task to be preempted. - * @endparblock - */ -uint32_t rtems_scheduler_get_processor( void ); - -/* Generated from spec:/rtems/scheduler/if/get-processor-macro */ -#define rtems_scheduler_get_processor() _SMP_Get_current_processor() - -/* Generated from spec:/rtems/scheduler/if/get-processor-maximum */ - -/** - * @ingroup RTEMSAPIClassicScheduler - * - * @brief Returns the processor maximum supported by the system. - * - * Where the system was built with SMP support disabled, this directive - * evaluates to a compile time constant of one. - * - * Where the system was built with SMP support enabled, this directive returns - * the minimum of the processors (physically or virtually) available at the - * target and the configured processor maximum (see - * #CONFIGURE_MAXIMUM_PROCESSORS). Not all processors in the range from - * processor index zero to the last processor index (which is the processor - * maximum minus one) may be configured to be used by a scheduler or may be - * online (online processors have a scheduler assigned). - * - * @return Returns the processor maximum supported by the system. - * - * @par Constraints - * @parblock - * The following constraints apply to this directive: - * - * * The directive may be called from within any runtime context. - * - * * The directive will not cause the calling task to be preempted. - * @endparblock - */ -uint32_t rtems_scheduler_get_processor_maximum( void ); - -/* Generated from spec:/rtems/scheduler/if/get-processor-maximum-macro */ -#define rtems_scheduler_get_processor_maximum() _SMP_Get_processor_maximum() - -/* Generated from spec:/rtems/scheduler/if/get-processor-set */ - -/** - * @ingroup RTEMSAPIClassicScheduler - * - * @brief Gets the set of processors owned by the scheduler. - * - * @param scheduler_id is the scheduler identifier. - * - * @param cpusetsize is the size of the processor set referenced by ``cpuset`` - * in bytes. - * - * @param[out] cpuset is the pointer to a cpu_set_t object. When the directive - * call is successful, the processor set of the scheduler will be stored in - * this object. A set bit in the processor set means that the corresponding - * processor is owned by the scheduler, otherwise the bit is cleared. - * - * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. - * - * @retval ::RTEMS_INVALID_ADDRESS The ``cpuset`` parameter was NULL. - * - * @retval ::RTEMS_INVALID_ID There was no scheduler associated with the - * identifier specified by ``scheduler_id``. - * - * @retval ::RTEMS_INVALID_SIZE The provided processor set was too small for - * the set of processors owned by the scheduler. - * - * @par Constraints - * @parblock - * The following constraints apply to this directive: - * - * * The directive may be called from within any runtime context. - * - * * The directive will not cause the calling task to be preempted. - * @endparblock - */ -rtems_status_code rtems_scheduler_get_processor_set( - rtems_id scheduler_id, - size_t cpusetsize, - cpu_set_t *cpuset -); - -/* Generated from spec:/rtems/scheduler/if/add-processor */ - -/** - * @ingroup RTEMSAPIClassicScheduler - * - * @brief Adds the processor to the set of processors owned by the scheduler. - * - * @param scheduler_id is the scheduler identifier. - * - * @param cpu_index is the index of the processor to add. - * - * This directive adds the processor specified by the ``cpu_index`` to the - * scheduler specified by ``scheduler_id``. - * - * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. - * - * @retval ::RTEMS_INVALID_ID There was no scheduler associated with the - * identifier specified by ``scheduler_id``. - * - * @retval ::RTEMS_NOT_CONFIGURED The processor was not configured to be used - * by the application. - * - * @retval ::RTEMS_INCORRECT_STATE The processor was configured to be used by - * the application, however, it was not online. - * - * @retval ::RTEMS_RESOURCE_IN_USE The processor was already assigned to a - * scheduler. - * - * @par Constraints - * @parblock - * The following constraints apply to this directive: - * - * * The directive may be called from within device driver initialization - * context. - * - * * The directive may be called from within task context. - * - * * The directive may obtain and release the object allocator mutex. This may - * cause the calling task to be preempted. - * @endparblock - */ -rtems_status_code rtems_scheduler_add_processor( - rtems_id scheduler_id, - uint32_t cpu_index -); - -/* Generated from spec:/rtems/scheduler/if/remove-processor */ - -/** - * @ingroup RTEMSAPIClassicScheduler - * - * @brief Removes the processor from the set of processors owned by the - * scheduler. - * - * @param scheduler_id is the scheduler identifier. - * - * @param cpu_index is the index of the processor to remove. - * - * This directive removes the processor specified by the ``cpu_index`` from the - * scheduler specified by ``scheduler_id``. - * - * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. - * - * @retval ::RTEMS_INVALID_ID There was no scheduler associated with the - * identifier specified by ``scheduler_id``. - * - * @retval ::RTEMS_INVALID_NUMBER The processor was not owned by the scheduler. - * - * @retval ::RTEMS_RESOURCE_IN_USE The processor was required by at least one - * non-idle task that used the scheduler as its home scheduler. - * - * @retval ::RTEMS_RESOURCE_IN_USE The processor was the last processor owned - * by the scheduler and there was at least one task that used the scheduler - * as a helping scheduler. - * - * @par Notes - * Removing a processor from a scheduler is a complex operation that involves - * all tasks of the system. - * - * @par Constraints - * @parblock - * The following constraints apply to this directive: - * - * * The directive may be called from within device driver initialization - * context. - * - * * The directive may be called from within task context. - * - * * The directive may obtain and release the object allocator mutex. This may - * cause the calling task to be preempted. - * @endparblock - */ -rtems_status_code rtems_scheduler_remove_processor( - rtems_id scheduler_id, - uint32_t cpu_index -); - /* Generated from spec:/rtems/task/if/create */ /** diff --git a/cpukit/include/rtems/rtems/tasksimpl.h b/cpukit/include/rtems/rtems/tasksimpl.h index 62a618b635..f32255b0d9 100644 --- a/cpukit/include/rtems/rtems/tasksimpl.h +++ b/cpukit/include/rtems/rtems/tasksimpl.h @@ -111,6 +111,14 @@ RTEMS_INLINE_ROUTINE rtems_task_priority _RTEMS_Priority_From_core( /**@}*/ +/** + * @defgroup RTEMSImplClassicScheduler Scheduler Manager + * + * @ingroup RTEMSImplClassic + * + * @brief This group contains the Scheduler Manager implementation. + */ + #if defined(RTEMS_MULTIPROCESSING) #include #endif diff --git a/cpukit/libmisc/cpuuse/cpuusagereset.c b/cpukit/libmisc/cpuuse/cpuusagereset.c index d1f0e65180..d677c6d330 100644 --- a/cpukit/libmisc/cpuuse/cpuusagereset.c +++ b/cpukit/libmisc/cpuuse/cpuusagereset.c @@ -20,6 +20,7 @@ #endif #include +#include #include #include #include diff --git a/cpukit/rtems/src/scheduleraddprocessor.c b/cpukit/rtems/src/scheduleraddprocessor.c index d8e55a1c97..e9984fd989 100644 --- a/cpukit/rtems/src/scheduleraddprocessor.c +++ b/cpukit/rtems/src/scheduleraddprocessor.c @@ -1,7 +1,7 @@ /** * @file * - * @ingroup RTEMSImplClassic + * @ingroup RTEMSImplClassicScheduler * * @brief This source file contains the implementation of * rtems_scheduler_add_processor(). @@ -25,7 +25,7 @@ #include "config.h" #endif -#include +#include #include #include #include diff --git a/cpukit/rtems/src/schedulergetmaxprio.c b/cpukit/rtems/src/schedulergetmaxprio.c index 49633387e0..77be7faa2d 100644 --- a/cpukit/rtems/src/schedulergetmaxprio.c +++ b/cpukit/rtems/src/schedulergetmaxprio.c @@ -3,7 +3,7 @@ /** * @file * - * @ingroup RTEMSImplClassic + * @ingroup RTEMSImplClassicScheduler * * @brief This source file contains the implementation of * rtems_scheduler_get_maximum_priority(). @@ -38,7 +38,7 @@ #include "config.h" #endif -#include +#include #include rtems_status_code rtems_scheduler_get_maximum_priority( diff --git a/cpukit/rtems/src/schedulergetprocessor.c b/cpukit/rtems/src/schedulergetprocessor.c index 5aafeae204..687b55b0c8 100644 --- a/cpukit/rtems/src/schedulergetprocessor.c +++ b/cpukit/rtems/src/schedulergetprocessor.c @@ -3,7 +3,7 @@ /** * @file * - * @ingroup RTEMSImplClassic + * @ingroup RTEMSImplClassicScheduler * * @brief This source file contains the implementation of * rtems_scheduler_get_processor() which may be used by binding for languages @@ -39,7 +39,7 @@ #include "config.h" #endif -#include +#include static uint32_t _RTEMS_Scheduler_get_processor( void ) { diff --git a/cpukit/rtems/src/schedulergetprocessormax.c b/cpukit/rtems/src/schedulergetprocessormax.c index 0091a6e544..1b4796f81a 100644 --- a/cpukit/rtems/src/schedulergetprocessormax.c +++ b/cpukit/rtems/src/schedulergetprocessormax.c @@ -3,7 +3,7 @@ /** * @file * - * @ingroup RTEMSImplClassic + * @ingroup RTEMSImplClassicScheduler * * @brief This source file contains the implementation of * rtems_scheduler_get_processor_maximum() which may be used by binding for @@ -39,7 +39,7 @@ #include "config.h" #endif -#include +#include static uint32_t _RTEMS_Scheduler_get_processor_maximum( void ) { diff --git a/cpukit/rtems/src/schedulergetprocessorset.c b/cpukit/rtems/src/schedulergetprocessorset.c index 71a351528a..3a3b92b7c0 100644 --- a/cpukit/rtems/src/schedulergetprocessorset.c +++ b/cpukit/rtems/src/schedulergetprocessorset.c @@ -1,7 +1,7 @@ /** * @file * - * @ingroup RTEMSImplClassic + * @ingroup RTEMSImplClassicScheduler * * @brief This source file contains the implementation of * rtems_scheduler_get_processor_set(). @@ -25,7 +25,7 @@ #include "config.h" #endif -#include +#include #include rtems_status_code rtems_scheduler_get_processor_set( diff --git a/cpukit/rtems/src/schedulerident.c b/cpukit/rtems/src/schedulerident.c index bc8ada39df..e2d4a01996 100644 --- a/cpukit/rtems/src/schedulerident.c +++ b/cpukit/rtems/src/schedulerident.c @@ -1,7 +1,7 @@ /** * @file * - * @ingroup RTEMSImplClassic + * @ingroup RTEMSImplClassicScheduler * * @brief This source file contains the implementation of * rtems_scheduler_ident(). @@ -25,7 +25,7 @@ #include "config.h" #endif -#include +#include #include rtems_status_code rtems_scheduler_ident( diff --git a/cpukit/rtems/src/scheduleridentbyprocessor.c b/cpukit/rtems/src/scheduleridentbyprocessor.c index a03ef7b04e..d6d980b4e3 100644 --- a/cpukit/rtems/src/scheduleridentbyprocessor.c +++ b/cpukit/rtems/src/scheduleridentbyprocessor.c @@ -1,7 +1,7 @@ /** * @file * - * @ingroup RTEMSImplClassic + * @ingroup RTEMSImplClassicScheduler * * @brief This source file contains the implementation of * rtems_scheduler_ident_by_processor(). @@ -25,7 +25,7 @@ #include "config.h" #endif -#include +#include #include #include diff --git a/cpukit/rtems/src/scheduleridentbyprocessorset.c b/cpukit/rtems/src/scheduleridentbyprocessorset.c index 8d55d470f5..15ef1780b7 100644 --- a/cpukit/rtems/src/scheduleridentbyprocessorset.c +++ b/cpukit/rtems/src/scheduleridentbyprocessorset.c @@ -1,7 +1,7 @@ /** * @file * - * @ingroup RTEMSImplClassic + * @ingroup RTEMSImplClassicScheduler * * @brief This source file contains the implementation of * rtems_scheduler_ident_by_processor_set(). @@ -25,7 +25,7 @@ #include "config.h" #endif -#include +#include #include #include diff --git a/cpukit/rtems/src/schedulermapfromposix.c b/cpukit/rtems/src/schedulermapfromposix.c index 72170582a4..dac748cae5 100644 --- a/cpukit/rtems/src/schedulermapfromposix.c +++ b/cpukit/rtems/src/schedulermapfromposix.c @@ -3,7 +3,7 @@ /** * @file * - * @ingroup RTEMSImplClassic + * @ingroup RTEMSImplClassicScheduler * * @brief This source file contains the implementation of * rtems_scheduler_map_priority_from_posix(). @@ -38,7 +38,7 @@ #include "config.h" #endif -#include +#include #include rtems_status_code rtems_scheduler_map_priority_from_posix( diff --git a/cpukit/rtems/src/schedulermaptoposix.c b/cpukit/rtems/src/schedulermaptoposix.c index 38afe87d0e..1d3b8fc085 100644 --- a/cpukit/rtems/src/schedulermaptoposix.c +++ b/cpukit/rtems/src/schedulermaptoposix.c @@ -3,7 +3,7 @@ /** * @file * - * @ingroup RTEMSImplClassic + * @ingroup RTEMSImplClassicScheduler * * @brief This source file contains the implementation of * rtems_scheduler_map_priority_to_posix(). @@ -38,7 +38,7 @@ #include "config.h" #endif -#include +#include #include rtems_status_code rtems_scheduler_map_priority_to_posix( diff --git a/cpukit/rtems/src/schedulerremoveprocessor.c b/cpukit/rtems/src/schedulerremoveprocessor.c index 3136a8e0c0..b8861634d3 100644 --- a/cpukit/rtems/src/schedulerremoveprocessor.c +++ b/cpukit/rtems/src/schedulerremoveprocessor.c @@ -1,7 +1,7 @@ /** * @file * - * @ingroup RTEMSImplClassic + * @ingroup RTEMSImplClassicScheduler * * @brief This source file contains the implementation of * rtems_scheduler_remove_processor(). @@ -25,7 +25,7 @@ #include "config.h" #endif -#include +#include #include #include diff --git a/spec/build/cpukit/librtemscpu.yml b/spec/build/cpukit/librtemscpu.yml index 319ea26e4d..77c8d316e3 100644 --- a/spec/build/cpukit/librtemscpu.yml +++ b/spec/build/cpukit/librtemscpu.yml @@ -303,6 +303,7 @@ install: - cpukit/include/rtems/rtems/region.h - cpukit/include/rtems/rtems/regiondata.h - cpukit/include/rtems/rtems/regionimpl.h + - cpukit/include/rtems/rtems/scheduler.h - cpukit/include/rtems/rtems/sem.h - cpukit/include/rtems/rtems/semdata.h - cpukit/include/rtems/rtems/semimpl.h -- 2.26.2 From sebastian.huber at embedded-brains.de Thu Dec 2 14:12:18 2021 From: sebastian.huber at embedded-brains.de (Sebastian Huber) Date: Thu, 2 Dec 2021 15:12:18 +0100 Subject: [PATCH] rtems: Move all Interrupt Manager stuff to intr.h Message-ID: <20211202141218.52327-1-sebastian.huber@embedded-brains.de> Since the previous Interrupt Manager Extension API moved to the Interrupt Manager, we can move the interfaces to so that they are available via #include . --- cpukit/include/rtems/irq-extension.h | 2257 +----------------------- cpukit/include/rtems/rtems/intr.h | 2375 +++++++++++++++++++++++++- 2 files changed, 2315 insertions(+), 2317 deletions(-) diff --git a/cpukit/include/rtems/irq-extension.h b/cpukit/include/rtems/irq-extension.h index e45ea43004..76b930dc69 100644 --- a/cpukit/include/rtems/irq-extension.h +++ b/cpukit/include/rtems/irq-extension.h @@ -5,11 +5,11 @@ * * @ingroup RTEMSAPIClassicIntr * - * @brief This header file defines the Interrupt Manager Extension API. + * @brief This header file is provided for backward compatiblility. */ /* - * Copyright (C) 2008, 2021 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 2021 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 @@ -55,2265 +55,12 @@ #ifndef _RTEMS_IRQ_EXTENSION_H #define _RTEMS_IRQ_EXTENSION_H -#include -#include -#include -#include #include -#include -#include -#include -#include -#include #ifdef __cplusplus extern "C" { #endif -/* Generated from spec:/rtems/intr/if/handler */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief Interrupt handler routines shall have this type. - */ -typedef void ( *rtems_interrupt_handler )( void * ); - -/* Generated from spec:/rtems/intr/if/per-handler-routine */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief Visitor routines invoked by rtems_interrupt_handler_iterate() shall - * have this type. - */ -typedef void ( *rtems_interrupt_per_handler_routine )( - void *, - const char *, - rtems_option, - rtems_interrupt_handler, - void * -); - -/* Generated from spec:/rtems/intr/if/shared */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief This interrupt handler install option allows that the interrupt - * handler may share the interrupt vector with other handler. - */ -#define RTEMS_INTERRUPT_SHARED ( (rtems_option) 0x00000000 ) - -/* Generated from spec:/rtems/intr/if/unique */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief This interrupt handler install option ensures that the interrupt - * handler is unique. - * - * This option prevents other handler from using the same interrupt vector. - */ -#define RTEMS_INTERRUPT_UNIQUE ( (rtems_option) 0x00000001 ) - -/* Generated from spec:/rtems/intr/if/replace */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief This interrupt handler install option requests that the interrupt - * handler replaces the first handler with the same argument. - */ -#define RTEMS_INTERRUPT_REPLACE ( (rtems_option) 0x00000002 ) - -/* Generated from spec:/rtems/intr/if/is-shared */ - -/** - * @brief Checks if the interrupt handler shared option is set. - * - * @param _options is the interrupt handler option set to check. - * - * @return Returns true, if the interrupt handler shared option - * #RTEMS_INTERRUPT_SHARED is set, otherwise false. - */ -#define RTEMS_INTERRUPT_IS_SHARED( _options ) \ - ( ( _options ) & RTEMS_INTERRUPT_SHARED ) - -/* Generated from spec:/rtems/intr/if/is-unique */ - -/** - * @brief Checks if the interrupt handler unique option is set. - * - * @param _options is the interrupt handler option set to check. - * - * @return Returns true, if the interrupt handler unique option - * #RTEMS_INTERRUPT_UNIQUE is set, otherwise false. - */ -#define RTEMS_INTERRUPT_IS_UNIQUE( _options ) \ - ( ( _options ) & RTEMS_INTERRUPT_UNIQUE ) - -/* Generated from spec:/rtems/intr/if/is-replace */ - -/** - * @brief Checks if the interrupt handler replace option is set. - * - * @param _options is the interrupt handler option set to check. - * - * @return Returns true, if the interrupt handler replace option - * #RTEMS_INTERRUPT_REPLACE is set, otherwise false. - */ -#define RTEMS_INTERRUPT_IS_REPLACE( _options ) \ - ( ( _options ) & RTEMS_INTERRUPT_REPLACE ) - -/* Generated from spec:/rtems/intr/if/entry */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief This structure represents an interrupt entry. - * - * @par Notes - * This structure shall be treated as an opaque data type from the API point of - * view. Members shall not be accessed directly. An entry may be initialized - * by RTEMS_INTERRUPT_ENTRY_INITIALIZER() or - * rtems_interrupt_entry_initialize(). It may be installed for an interrupt - * vector with rtems_interrupt_entry_install() and removed from an interrupt - * vector by rtems_interrupt_entry_remove(). - */ -typedef struct rtems_interrupt_entry { - /** - * @brief This member is the interrupt handler routine. - */ - rtems_interrupt_handler handler; - - /** - * @brief This member is the interrupt handler argument. - */ - void *arg; - - /** - * @brief This member is the reference to the next entry or NULL. - */ - struct rtems_interrupt_entry *next; - - /** - * @brief This member is the descriptive information of the entry. - */ - const char *info; -} rtems_interrupt_entry; - -/* Generated from spec:/rtems/intr/if/entry-initializer */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief Statically initializes an interrupt entry object. - * - * @param _routine is the interrupt handler routine for the entry. - * - * @param _arg is the interrupt handler argument for the entry. - * - * @param _info is the descriptive information for the entry. - * - * @par Notes - * Alternatively, rtems_interrupt_entry_initialize() may be used to dynamically - * initialize an interrupt entry. - */ -#define RTEMS_INTERRUPT_ENTRY_INITIALIZER( _routine, _arg, _info ) \ - { _routine, _arg, NULL, _info } - -/* Generated from spec:/rtems/intr/if/entry-initialize */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief Initializes the interrupt entry. - * - * @param[out] entry is the interrupt entry to initialize. - * - * @param routine is the interrupt handler routine for the entry. - * - * @param arg is the interrupt handler argument for the entry. - * - * @param info is the descriptive information for the entry. - * - * @par Notes - * Alternatively, RTEMS_INTERRUPT_ENTRY_INITIALIZER() may be used to statically - * initialize an interrupt entry. - * - * @par Constraints - * @parblock - * The following constraints apply to this directive: - * - * * The directive may be called from within any runtime context. - * - * * The directive will not cause the calling task to be preempted. - * @endparblock - */ -static inline void rtems_interrupt_entry_initialize( - rtems_interrupt_entry *entry, - rtems_interrupt_handler routine, - void *arg, - const char *info -) -{ - entry->handler = routine; - entry->arg = arg; - entry->next = NULL; - entry->info = info; -} - -/* Generated from spec:/rtems/intr/if/entry-install */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief Installs the interrupt entry at the interrupt vector. - * - * @param vector is the interrupt vector number. - * - * @param options is the interrupt entry install option set. - * - * @param entry is the interrupt entry to install. - * - * One of the following mutually exclusive options - * - * * #RTEMS_INTERRUPT_UNIQUE, and - * - * * #RTEMS_INTERRUPT_SHARED - * - * shall be set in the ``options`` parameter. - * - * The handler routine of the entry specified by ``entry`` will be called with - * the handler argument of the entry when dispatched. The order in which - * shared interrupt handlers are dispatched for one vector is defined by the - * installation order. The first installed handler is dispatched first. - * - * If the option #RTEMS_INTERRUPT_UNIQUE is set, then it will be ensured that - * the handler will be the only one for the interrupt vector. - * - * If the option #RTEMS_INTERRUPT_SHARED is set, then multiple handlers may be - * installed for the interrupt vector. - * - * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. - * - * @retval ::RTEMS_INVALID_ADDRESS The ``entry`` parameter was NULL. - * - * @retval ::RTEMS_INCORRECT_STATE The service was not initialized. - * - * @retval ::RTEMS_INVALID_ADDRESS The handler routine of the entry was NULL. - * - * @retval ::RTEMS_INVALID_ID There was no interrupt vector associated with the - * number specified by ``vector``. - * - * @retval ::RTEMS_CALLED_FROM_ISR The directive was called from within - * interrupt context. - * - * @retval ::RTEMS_INVALID_NUMBER An option specified by ``options`` was not - * applicable. - * - * @retval ::RTEMS_RESOURCE_IN_USE The #RTEMS_INTERRUPT_UNIQUE option was set - * in ``entry`` and the interrupt vector was already occupied by a handler. - * - * @retval ::RTEMS_RESOURCE_IN_USE The #RTEMS_INTERRUPT_SHARED option was set - * in ``entry`` and the interrupt vector was already occupied by a unique - * handler. - * - * @retval ::RTEMS_TOO_MANY The handler routine of the entry specified by - * ``entry`` was already installed for the interrupt vector specified by - * ``vector`` with an argument equal to the handler argument of the entry. - * - * @par Notes - * When the directive call was successful, the ownership of the interrupt entry - * has been transferred from the caller to the interrupt service. An installed - * interrupt entry may be removed from the interrupt service by calling - * rtems_interrupt_entry_remove(). - * - * @par Constraints - * @parblock - * The following constraints apply to this directive: - * - * * The directive may be called from within device driver initialization - * context. - * - * * The directive may be called from within task context. - * - * * The directive may obtain and release the object allocator mutex. This may - * cause the calling task to be preempted. - * - * * The interrupt entry shall have been initialized by - * rtems_interrupt_entry_initialize() or RTEMS_INTERRUPT_ENTRY_INITIALIZER(). - * @endparblock - */ -rtems_status_code rtems_interrupt_entry_install( - rtems_vector_number vector, - rtems_option options, - rtems_interrupt_entry *entry -); - -/* Generated from spec:/rtems/intr/if/entry-remove */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief Removes the interrupt entry from the interrupt vector. - * - * @param vector is the interrupt vector number. - * - * @param entry is the interrupt entry to remove. - * - * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. - * - * @retval ::RTEMS_INCORRECT_STATE The service was not initialized. - * - * @retval ::RTEMS_INVALID_ADDRESS The ``entry`` parameter was NULL. - * - * @retval ::RTEMS_INVALID_ID There was no interrupt vector associated with the - * number specified by ``vector``. - * - * @retval ::RTEMS_CALLED_FROM_ISR The directive was called from within - * interrupt context. - * - * @retval ::RTEMS_UNSATISFIED The entry specified by ``entry`` was not - * installed at the interrupt vector specified by ``vector``. - * - * @par Notes - * When the directive call was successful, the ownership of the interrupt entry - * has been transferred from the interrupt service to the caller. - * - * @par Constraints - * @parblock - * The following constraints apply to this directive: - * - * * The directive may be called from within device driver initialization - * context. - * - * * The directive may be called from within task context. - * - * * The directive may obtain and release the object allocator mutex. This may - * cause the calling task to be preempted. - * - * * The interrupt entry shall have been installed by - * rtems_interrupt_entry_install(). - * @endparblock - */ -rtems_status_code rtems_interrupt_entry_remove( - rtems_vector_number vector, - rtems_interrupt_entry *entry -); - -/* Generated from spec:/rtems/intr/if/handler-install */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief Installs the interrupt handler routine and argument at the interrupt - * vector. - * - * @param vector is the interrupt vector number. - * - * @param info is the descriptive information of the interrupt handler to - * install. - * - * @param options is the interrupt handler install option set. - * - * @param routine is the interrupt handler routine to install. - * - * @param arg is the interrupt handler argument to install. - * - * One of the following mutually exclusive options - * - * * #RTEMS_INTERRUPT_UNIQUE, - * - * * #RTEMS_INTERRUPT_SHARED, and - * - * * #RTEMS_INTERRUPT_REPLACE - * - * shall be set in the ``options`` parameter. - * - * The handler routine will be called with the argument specified by ``arg`` - * when dispatched. The order in which shared interrupt handlers are - * dispatched for one vector is defined by the installation order. The first - * installed handler is dispatched first. - * - * If the option #RTEMS_INTERRUPT_UNIQUE is set, then it will be ensured that - * the handler will be the only one for the interrupt vector. - * - * If the option #RTEMS_INTERRUPT_SHARED is set, then multiple handler may be - * installed for the interrupt vector. - * - * If the option #RTEMS_INTERRUPT_REPLACE is set, then the handler specified by - * ``routine`` will replace the first handler with the same argument for the - * interrupt vector if it exists, otherwise an error status will be returned. - * A second handler with the same argument for the interrupt vector will remain - * unchanged. The new handler will inherit the unique or shared options from - * the replaced handler. - * - * An informative description may be provided in ``info``. It may be used for - * system debugging and diagnostic tools. The referenced string has to be - * persistent as long as the handler is installed. - * - * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. - * - * @retval ::RTEMS_INCORRECT_STATE The service was not initialized. - * - * @retval ::RTEMS_INVALID_ADDRESS The ``routine`` parameter was NULL. - * - * @retval ::RTEMS_INVALID_ID There was no interrupt vector associated with the - * number specified by ``vector``. - * - * @retval ::RTEMS_CALLED_FROM_ISR The directive was called from within - * interrupt context. - * - * @retval ::RTEMS_NO_MEMORY There was not enough memory available to allocate - * data structures to install the handler. - * - * @retval ::RTEMS_RESOURCE_IN_USE The #RTEMS_INTERRUPT_UNIQUE option was set - * in ``options`` and the interrupt vector was already occupied by a handler. - * - * @retval ::RTEMS_RESOURCE_IN_USE The #RTEMS_INTERRUPT_SHARED option was set - * in ``options`` and the interrupt vector was already occupied by a unique - * handler. - * - * @retval ::RTEMS_TOO_MANY The handler specified by ``routine`` was already - * installed for the interrupt vector specified by ``vector`` with an - * argument equal to the argument specified by ``arg``. - * - * @retval ::RTEMS_UNSATISFIED The #RTEMS_INTERRUPT_REPLACE option was set in - * ``options`` and no handler to replace was installed. - * - * @par Constraints - * @parblock - * The following constraints apply to this directive: - * - * * The directive may be called from within device driver initialization - * context. - * - * * The directive may be called from within task context. - * - * * The directive may obtain and release the object allocator mutex. This may - * cause the calling task to be preempted. - * @endparblock - */ -rtems_status_code rtems_interrupt_handler_install( - rtems_vector_number vector, - const char *info, - rtems_option options, - rtems_interrupt_handler routine, - void *arg -); - -/* Generated from spec:/rtems/intr/if/handler-remove */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief Removes the interrupt handler routine and argument from the interrupt - * vector. - * - * @param vector is the interrupt vector number. - * - * @param routine is the interrupt handler routine to remove. - * - * @param arg is the interrupt handler argument to remove. - * - * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. - * - * @retval ::RTEMS_INCORRECT_STATE The service was not initialized. - * - * @retval ::RTEMS_INVALID_ADDRESS The ``routine`` parameter was NULL. - * - * @retval ::RTEMS_INVALID_ID There was no interrupt vector associated with the - * number specified by ``vector``. - * - * @retval ::RTEMS_CALLED_FROM_ISR The directive was called from within - * interrupt context. - * - * @retval ::RTEMS_UNSATISFIED There was no handler routine and argument pair - * installed specified by ``routine`` and ``arg``. - * - * @par Constraints - * @parblock - * The following constraints apply to this directive: - * - * * The directive may be called from within device driver initialization - * context. - * - * * The directive may be called from within task context. - * - * * The directive may obtain and release the object allocator mutex. This may - * cause the calling task to be preempted. - * @endparblock - */ -rtems_status_code rtems_interrupt_handler_remove( - rtems_vector_number vector, - rtems_interrupt_handler routine, - void *arg -); - -/* Generated from spec:/rtems/intr/if/vector-is-enabled */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief Checks if the interrupt vector is enabled. - * - * @param vector is the interrupt vector number. - * - * @param[out] enabled is the pointer to a ``bool`` object. When the directive - * call is successful, the enabled status of the interrupt associated with - * the interrupt vector specified by ``vector`` will be stored in this - * object. When the interrupt was enabled for the processor executing the - * directive call at some time point during the call, the object value will - * be set to true, otherwise to false. - * - * The directive checks if the interrupt associated with the interrupt vector - * specified by ``vector`` was enabled for the processor executing the - * directive call at some time point during the call. - * - * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. - * - * @retval ::RTEMS_INVALID_ADDRESS The ``enabled`` parameter was NULL. - * - * @retval ::RTEMS_INVALID_ID There was no interrupt vector associated with the - * number specified by ``vector``. - * - * @par Notes - * Interrupt vectors may be enabled by rtems_interrupt_vector_enable() and - * disabled by rtems_interrupt_vector_disable(). - * - * @par Constraints - * @parblock - * The following constraints apply to this directive: - * - * * The directive may be called from within interrupt context. - * - * * The directive may be called from within device driver initialization - * context. - * - * * The directive may be called from within task context. - * - * * The directive will not cause the calling task to be preempted. - * @endparblock - */ -rtems_status_code rtems_interrupt_vector_is_enabled( - rtems_vector_number vector, - bool *enabled -); - -/* Generated from spec:/rtems/intr/if/vector-enable */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief Enables the interrupt vector. - * - * @param vector is the number of the interrupt vector to enable. - * - * The directive enables the interrupt vector specified by ``vector``. This - * allows that interrupt service requests are issued to the target processors - * of the interrupt vector. Interrupt service requests for an interrupt vector - * may be raised by rtems_interrupt_raise(), rtems_interrupt_raise_on(), - * external signals, or messages. - * - * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. - * - * @retval ::RTEMS_INVALID_ID There was no interrupt vector associated with the - * number specified by ``vector``. - * - * @retval ::RTEMS_UNSATISFIED The request to enable the interrupt vector has - * not been satisfied. - * - * @par Notes - * The rtems_interrupt_get_attributes() directive may be used to check if an - * interrupt vector can be enabled. Interrupt vectors may be disabled by - * rtems_interrupt_vector_disable(). - * - * @par Constraints - * @parblock - * The following constraints apply to this directive: - * - * * The directive may be called from within interrupt context. - * - * * The directive may be called from within device driver initialization - * context. - * - * * The directive may be called from within task context. - * - * * The directive will not cause the calling task to be preempted. - * @endparblock - */ -rtems_status_code rtems_interrupt_vector_enable( rtems_vector_number vector ); - -/* Generated from spec:/rtems/intr/if/vector-disable */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief Disables the interrupt vector. - * - * @param vector is the number of the interrupt vector to disable. - * - * The directive disables the interrupt vector specified by ``vector``. This - * prevents that an interrupt service request is issued to the target - * processors of the interrupt vector. - * - * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. - * - * @retval ::RTEMS_INVALID_ID There was no interrupt vector associated with the - * number specified by ``vector``. - * - * @retval ::RTEMS_UNSATISFIED The request to disable the interrupt vector has - * not been satisfied. - * - * @par Notes - * The rtems_interrupt_get_attributes() directive may be used to check if an - * interrupt vector can be disabled. Interrupt vectors may be enabled by - * rtems_interrupt_vector_enable(). There may be targets on which some - * interrupt vectors cannot be disabled, for example a hardware watchdog - * interrupt or software generated interrupts. - * - * @par Constraints - * @parblock - * The following constraints apply to this directive: - * - * * The directive may be called from within interrupt context. - * - * * The directive may be called from within device driver initialization - * context. - * - * * The directive may be called from within task context. - * - * * The directive will not cause the calling task to be preempted. - * @endparblock - */ -rtems_status_code rtems_interrupt_vector_disable( rtems_vector_number vector ); - -/* Generated from spec:/rtems/intr/if/is-pending */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief Checks if the interrupt is pending. - * - * @param vector is the interrupt vector number. - * - * @param[out] pending is the pointer to a ``bool`` object. When the directive - * call is successful, the pending status of the interrupt associated with - * the interrupt vector specified by ``vector`` will be stored in this - * object. When the interrupt was pending for the processor executing the - * directive call at some time point during the call, the object value will - * be set to true, otherwise to false. - * - * The directive checks if the interrupt associated with the interrupt vector - * specified by ``vector`` was pending for the processor executing the - * directive call at some time point during the call. - * - * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. - * - * @retval ::RTEMS_INVALID_ADDRESS The ``pending`` parameter was NULL. - * - * @retval ::RTEMS_INVALID_ID There was no interrupt vector associated with the - * number specified by ``vector``. - * - * @retval ::RTEMS_UNSATISFIED The request to get the pending status has not - * been satisfied. - * - * @par Notes - * Interrupts may be made pending by calling the rtems_interrupt_raise() or - * rtems_interrupt_raise_on() directives or due to external signals or - * messages. The pending state may be cleared by rtems_interrupt_clear(). - * - * @par Constraints - * @parblock - * The following constraints apply to this directive: - * - * * The directive may be called from within interrupt context. - * - * * The directive may be called from within device driver initialization - * context. - * - * * The directive may be called from within task context. - * - * * The directive will not cause the calling task to be preempted. - * @endparblock - */ -rtems_status_code rtems_interrupt_is_pending( - rtems_vector_number vector, - bool *pending -); - -/* Generated from spec:/rtems/intr/if/get-affinity */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief Gets the processor affinity set of the interrupt vector. - * - * @param vector is the interrupt vector number. - * - * @param affinity_size is the size of the processor set referenced by - * ``affinity`` in bytes. - * - * @param[out] affinity is the pointer to a cpu_set_t object. When the - * directive call is successful, the processor affinity set of the interrupt - * vector will be stored in this object. A set bit in the processor set - * means that the corresponding processor is in the processor affinity set of - * the interrupt vector, otherwise the bit is cleared. - * - * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. - * - * @retval ::RTEMS_INVALID_ADDRESS The ``affinity`` parameter was NULL. - * - * @retval ::RTEMS_INVALID_ID There was no interrupt vector associated with the - * number specified by ``vector``. - * - * @retval ::RTEMS_INVALID_SIZE The size specified by ``affinity_size`` of the - * processor set was too small for the processor affinity set of the - * interrupt vector. - * - * @par Constraints - * @parblock - * The following constraints apply to this directive: - * - * * The directive may be called from within interrupt context. - * - * * The directive may be called from within device driver initialization - * context. - * - * * The directive may be called from within task context. - * - * * The directive will not cause the calling task to be preempted. - * @endparblock - */ -rtems_status_code rtems_interrupt_get_affinity( - rtems_vector_number vector, - size_t affinity_size, - cpu_set_t *affinity -); - -/* Generated from spec:/rtems/intr/if/set-affinity */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief Sets the processor affinity set of the interrupt vector. - * - * @param vector is the interrupt vector number. - * - * @param affinity_size is the size of the processor set referenced by - * ``affinity`` in bytes. - * - * @param affinity is the pointer to a cpu_set_t object. The processor set - * defines the new processor affinity set of the interrupt vector. A set bit - * in the processor set means that the corresponding processor shall be in - * the processor affinity set of the interrupt vector, otherwise the bit - * shall be cleared. - * - * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. - * - * @retval ::RTEMS_INVALID_ADDRESS The ``affinity`` parameter was NULL. - * - * @retval ::RTEMS_INVALID_ID There was no interrupt vector associated with the - * number specified by ``vector``. - * - * @retval ::RTEMS_INVALID_NUMBER The referenced processor set was not a valid - * new processor affinity set for the interrupt vector. - * - * @retval ::RTEMS_UNSATISFIED The request to set the processor affinity of the - * interrupt vector has not been satisfied. - * - * @par Notes - * The rtems_interrupt_get_attributes() directive may be used to check if the - * processor affinity of an interrupt vector can be set. - * - * @par Constraints - * @parblock - * The following constraints apply to this directive: - * - * * The directive may be called from within interrupt context. - * - * * The directive may be called from within device driver initialization - * context. - * - * * The directive may be called from within task context. - * - * * The directive will not cause the calling task to be preempted. - * @endparblock - */ -rtems_status_code rtems_interrupt_set_affinity( - rtems_vector_number vector, - size_t affinity_size, - const cpu_set_t *affinity -); - -/* Generated from spec:/rtems/intr/if/signal-variant */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief This enumeration provides interrupt trigger signal variants. - */ -typedef enum { - /** - * @brief This interrupt signal variant indicates that the interrupt trigger - * signal is unspecified. - */ - RTEMS_INTERRUPT_UNSPECIFIED_SIGNAL, - - /** - * @brief This interrupt signal variant indicates that the interrupt cannot be - * triggered by a signal. - */ - RTEMS_INTERRUPT_NO_SIGNAL, - - /** - * @brief This interrupt signal variant indicates that the interrupt is - * triggered by a low level signal. - */ - RTEMS_INTERRUPT_SIGNAL_LEVEL_LOW, - - /** - * @brief This interrupt signal variant indicates that the interrupt is - * triggered by a high level signal. - */ - RTEMS_INTERRUPT_SIGNAL_LEVEL_HIGH, - - /** - * @brief This interrupt signal variant indicates that the interrupt is - * triggered by a falling edge signal. - */ - RTEMS_INTERRUPT_SIGNAL_EDGE_FALLING, - - /** - * @brief This interrupt signal variant indicates that the interrupt is - * triggered by a raising edge signal. - */ - RTEMS_INTERRUPT_SIGNAL_EDGE_RAISING -} rtems_interrupt_signal_variant; - -/* Generated from spec:/rtems/intr/if/attributes */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief This structure provides the attributes of an interrupt vector. - * - * The rtems_interrupt_get_attributes() directive may be used to obtain the - * attributes of an interrupt vector. - */ -typedef struct { - /** - * @brief This member is true, if the interrupt vector is maskable by - * rtems_interrupt_local_disable(), otherwise it is false. - * - * Interrupt vectors which are not maskable by rtems_interrupt_local_disable() - * should be used with care since they cannot use most operating system - * services. - */ - bool is_maskable; - - /** - * @brief This member is true, if the interrupt vector can be enabled by - * rtems_interrupt_vector_enable(), otherwise it is false. - * - * When an interrupt vector can be enabled, this means that the enabled state - * can always be changed from disabled to enabled. For an interrupt vector - * which can be enabled it follows that it may be enabled. - */ - bool can_enable; - - /** - * @brief This member is true, if the interrupt vector may be enabled by - * rtems_interrupt_vector_enable(), otherwise it is false. - * - * When an interrupt vector may be enabled, this means that the enabled state - * may be changed from disabled to enabled. The requested enabled state change - * should be checked by rtems_interrupt_vector_is_enabled(). Some interrupt - * vectors may be optionally available and cannot be enabled on a particular - * target. - */ - bool maybe_enable; - - /** - * @brief This member is true, if the interrupt vector can be disabled by - * rtems_interrupt_vector_disable(), otherwise it is false. - * - * When an interrupt vector can be disabled, this means that the enabled state - * can be changed from enabled to disabled. For an interrupt vector which can - * be disabled it follows that it may be disabled. - */ - bool can_disable; - - /** - * @brief This member is true, if the interrupt vector may be disabled by - * rtems_interrupt_vector_disable(), otherwise it is false. - * - * When an interrupt vector may be disabled, this means that the enabled state - * may be changed from enabled to disabled. The requested enabled state change - * should be checked by rtems_interrupt_vector_is_enabled(). Some interrupt - * vectors may be always enabled and cannot be disabled on a particular target. - */ - bool maybe_disable; - - /** - * @brief This member is true, if the interrupt vector can be raised by - * rtems_interrupt_raise(), otherwise it is false. - */ - bool can_raise; - - /** - * @brief This member is true, if the interrupt vector can be raised on a - * processor by rtems_interrupt_raise_on(), otherwise it is false. - */ - bool can_raise_on; - - /** - * @brief This member is true, if the interrupt vector can be cleared by - * rtems_interrupt_clear(), otherwise it is false. - */ - bool can_clear; - - /** - * @brief This member is true, if the pending status of the interrupt - * associated with the interrupt vector is cleared by an interrupt - * acknowledge from the processor, otherwise it is false. - */ - bool cleared_by_acknowledge; - - /** - * @brief This member is true, if the affinity set of the interrupt vector can - * be obtained by rtems_interrupt_get_affinity(), otherwise it is false. - */ - bool can_get_affinity; - - /** - * @brief This member is true, if the affinity set of the interrupt vector can - * be set by rtems_interrupt_set_affinity(), otherwise it is false. - */ - bool can_set_affinity; - - /** - * @brief This member is true, if the interrupt associated with the interrupt - * vector can be triggered by a message. - * - * Interrupts may be also triggered by signals, rtems_interrupt_raise(), or - * rtems_interrupt_raise_on(). Examples for message triggered interrupts are - * the PCIe MSI/MSI-X and the ARM GICv3 Locality-specific Peripheral Interrupts - * (LPI). - */ - bool can_be_triggered_by_message; - - /** - * @brief This member describes the trigger signal of the interrupt associated - * with the interrupt vector. - * - * Interrupts are normally triggered by signals which indicate an interrupt - * request from a peripheral. Interrupts may be also triggered by messages, - * rtems_interrupt_raise(), or rtems_interrupt_raise_on(). - */ - rtems_interrupt_signal_variant trigger_signal; -} rtems_interrupt_attributes; - -/* Generated from spec:/rtems/intr/if/get-attributes */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief Gets the attributes of the interrupt vector. - * - * @param vector is the interrupt vector number. - * - * @param[out] attributes is the pointer to an rtems_interrupt_attributes - * object. When the directive call is successful, the attributes of the - * interrupt vector will be stored in this object. - * - * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. - * - * @retval ::RTEMS_INVALID_ADDRESS The ``attributes`` parameter was NULL. - * - * @retval ::RTEMS_INVALID_ID There was no interrupt vector associated with the - * number specified by ``vector``. - * - * @par Constraints - * @parblock - * The following constraints apply to this directive: - * - * * The directive may be called from within interrupt context. - * - * * The directive may be called from within device driver initialization - * context. - * - * * The directive may be called from within task context. - * - * * The directive will not cause the calling task to be preempted. - * @endparblock - */ -rtems_status_code rtems_interrupt_get_attributes( - rtems_vector_number vector, - rtems_interrupt_attributes *attributes -); - -/* Generated from spec:/rtems/intr/if/handler-iterate */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief Iterates over all interrupt handler installed at the interrupt - * vector. - * - * @param vector is the interrupt vector number. - * - * @param routine is the visitor routine. - * - * @param arg is the visitor argument. - * - * For each installed handler at the interrupt vector the visitor function - * specified by ``routine`` will be called with the argument specified by - * ``arg`` and the handler information, options, routine and argument. - * - * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. - * - * @retval ::RTEMS_INCORRECT_STATE The service was not initialized. - * - * @retval ::RTEMS_INVALID_ADDRESS The ``routine`` parameter was NULL. - * - * @retval ::RTEMS_INVALID_ID There was no interrupt vector associated with the - * number specified by ``vector``. - * - * @retval ::RTEMS_CALLED_FROM_ISR The directive was called from within - * interrupt context. - * - * @par Notes - * @parblock - * The directive is intended for system information and diagnostics. - * - * Never install or remove an interrupt handler within the visitor function. - * This may result in a deadlock. - * @endparblock - * - * @par Constraints - * @parblock - * The following constraints apply to this directive: - * - * * The directive may be called from within device driver initialization - * context. - * - * * The directive may be called from within task context. - * - * * The directive may obtain and release the object allocator mutex. This may - * cause the calling task to be preempted. - * @endparblock - */ -rtems_status_code rtems_interrupt_handler_iterate( - rtems_vector_number vector, - rtems_interrupt_per_handler_routine routine, - void *arg -); - -/* Generated from spec:/rtems/intr/if/server-default */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief The constant represents the index of the default interrupt server. - */ -#define RTEMS_INTERRUPT_SERVER_DEFAULT 0 - -/* Generated from spec:/rtems/intr/if/server-control */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief This structure represents an interrupt server. - * - * @par Notes - * This structure shall be treated as an opaque data type from the API point of - * view. Members shall not be accessed directly. The structure is initialized - * by rtems_interrupt_server_create() and maintained by the interrupt server - * support. - */ -typedef struct rtems_interrupt_server_control { - #if defined(RTEMS_SMP) - /** - * @brief This member is the ISR lock protecting the server control state. - */ - rtems_interrupt_lock lock; - #endif - - /** - * @brief This member is the chain of pending interrupt entries. - */ - Chain_Control entries; - - /** - * @brief This member is the identifier of the server task. - */ - rtems_id server; - - /** - * @brief This member is the error count. - */ - unsigned long errors; - - /** - * @brief This member is the server index. - */ - uint32_t index; - - /** - * @brief This member is the node for the interrupt server registry. - */ - Chain_Node node; - - /** - * @brief This member is the optional handler to destroy the interrupt server - * control. - */ - void ( *destroy )( struct rtems_interrupt_server_control * ); -} rtems_interrupt_server_control; - -/* Generated from spec:/rtems/intr/if/server-config */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief This structure defines an interrupt server configuration. - * - * @par Notes - * See also rtems_interrupt_server_create(). - */ -typedef struct { - /** - * @brief This member is the task name of the interrupt server. - */ - rtems_name name; - - /** - * @brief This member is the initial task priority of the interrupt server. - */ - rtems_task_priority priority; - - /** - * @brief This member is the task storage area of the interrupt server. - * - * It shall be NULL for interrupt servers created by - * rtems_interrupt_server_create(). - */ - void *storage_area; - - /** - * @brief This member is the task storage size of the interrupt server. - * - * For interrupt servers created by rtems_interrupt_server_create() this is the - * task stack size. - */ - size_t storage_size; - - /** - * @brief This member is the initial mode set of the interrupt server. - */ - rtems_mode modes; - - /** - * @brief This member is the attribute set of the interrupt server. - */ - rtems_attribute attributes; - - /** - * @brief This member is an optional handler to destroy the interrupt server - * control handed over to rtems_interrupt_server_create(). - * - * The destroy handler is optional and may be NULL. If the destroy handler is - * present, it is called from within the context of the interrupt server to be - * deleted, see also rtems_interrupt_server_delete(). - */ - void ( *destroy )( rtems_interrupt_server_control * ); -} rtems_interrupt_server_config; - -/* Generated from spec:/rtems/intr/if/server-initialize */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief Initializes the interrupt server tasks. - * - * @param priority is the initial task priority of the created interrupt - * servers. - * - * @param stack_size is the task stack size of the created interrupt servers. - * - * @param modes is the initial mode set of the created interrupt servers. - * - * @param attributes is the attribute set of the created interrupt servers. - * - * @param[out] server_count is the pointer to an uint32_t object or NULL. When - * the pointer is not equal to NULL, the count of successfully created - * interrupt servers is stored in this object regardless of the return - * status. - * - * The directive tries to create an interrupt server task for each online - * processor in the system. The tasks will have the initial priority specified - * by ``priority``, the stack size specified by ``stack_size``, the initial - * mode set specified by ``modes``, and the attribute set specified by - * ``attributes``. The count of successfully created server tasks will be - * returned in ``server_count`` if the pointer is not equal to NULL. - * - * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. - * - * @retval ::RTEMS_INCORRECT_STATE The interrupt servers were already - * initialized. - * - * @return The directive uses rtems_task_create(). If this directive fails, - * then its error status will be returned. - * - * @par Notes - * @parblock - * Interrupt handlers may be installed on an interrupt server with - * rtems_interrupt_server_handler_install() and removed with - * rtems_interrupt_server_handler_remove() using a server index. In case of an - * interrupt, the request will be forwarded to the interrupt server. The - * handlers are executed within the interrupt server context. If one handler - * blocks on something this may delay the processing of other handlers. - * - * Interrupt servers may be deleted by rtems_interrupt_server_delete(). - * @endparblock - * - * @par Constraints - * @parblock - * The following constraints apply to this directive: - * - * * The directive may be called from within device driver initialization - * context. - * - * * The directive may be called from within task context. - * - * * The directive may obtain and release the object allocator mutex. This may - * cause the calling task to be preempted. - * @endparblock - */ -rtems_status_code rtems_interrupt_server_initialize( - rtems_task_priority priority, - size_t stack_size, - rtems_mode modes, - rtems_attribute attributes, - uint32_t *server_count -); - -/* Generated from spec:/rtems/intr/if/server-create */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief Creates an interrupt server. - * - * @param[out] control is the pointer to an rtems_interrupt_server_control - * object. When the directive call was successful, the ownership of the - * object was transferred from the caller of the directive to the interrupt - * server management. - * - * @param config is the interrupt server configuration. - * - * @param[out] server_index is the pointer to an uint32_t object. When the - * directive call was successful, the index of the created interrupt server - * will be stored in this object. - * - * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. - * - * @return The directive uses rtems_task_create(). If this directive fails, - * then its error status will be returned. - * - * @par Notes - * See also rtems_interrupt_server_initialize() and - * rtems_interrupt_server_delete(). - * - * @par Constraints - * @parblock - * The following constraints apply to this directive: - * - * * The directive may be called from within device driver initialization - * context. - * - * * The directive may be called from within task context. - * - * * The directive may obtain and release the object allocator mutex. This may - * cause the calling task to be preempted. - * @endparblock - */ -rtems_status_code rtems_interrupt_server_create( - rtems_interrupt_server_control *control, - const rtems_interrupt_server_config *config, - uint32_t *server_index -); - -/* Generated from spec:/rtems/intr/if/server-handler-install */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief Installs the interrupt handler routine and argument at the interrupt - * vector on the interrupt server. - * - * @param server_index is the interrupt server index. The constant - * #RTEMS_INTERRUPT_SERVER_DEFAULT may be used to specify the default - * interrupt server. - * - * @param vector is the interrupt vector number. - * - * @param info is the descriptive information of the interrupt handler to - * install. - * - * @param options is the interrupt handler install option set. - * - * @param routine is the interrupt handler routine to install. - * - * @param arg is the interrupt handler argument to install. - * - * The handler routine specified by ``routine`` will be executed within the - * context of the interrupt server task specified by ``server_index``. - * - * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. - * - * @retval ::RTEMS_INVALID_ID There was no interrupt server associated with the - * index specified by ``server_index``. - * - * @retval ::RTEMS_CALLED_FROM_ISR The directive was called from within - * interrupt context. - * - * @retval ::RTEMS_INVALID_ADDRESS The ``routine`` parameter was NULL. - * - * @retval ::RTEMS_INVALID_ID There was no interrupt vector associated with the - * number specified by ``vector``. - * - * @retval ::RTEMS_INVALID_NUMBER An option specified by ``info`` was not - * applicable. - * - * @retval ::RTEMS_RESOURCE_IN_USE The #RTEMS_INTERRUPT_UNIQUE option was set - * in ``info`` and the interrupt vector was already occupied by a handler. - * - * @retval ::RTEMS_RESOURCE_IN_USE The #RTEMS_INTERRUPT_SHARED option was set - * in ``info`` and the interrupt vector was already occupied by a unique - * handler. - * - * @retval ::RTEMS_TOO_MANY The handler specified by ``routine`` was already - * installed for the interrupt vector specified by ``vector`` with an - * argument equal to the argument specified by ``arg``. - * - * @retval ::RTEMS_UNSATISFIED The #RTEMS_INTERRUPT_REPLACE option was set in - * ``info`` and no handler to replace was installed. - * - * @par Notes - * See also rtems_interrupt_handler_install(). - * - * @par Constraints - * @parblock - * The following constraints apply to this directive: - * - * * The directive may be called from within device driver initialization - * context. - * - * * The directive may be called from within task context. - * - * * The directive may obtain and release the object allocator mutex. This may - * cause the calling task to be preempted. - * @endparblock - */ -rtems_status_code rtems_interrupt_server_handler_install( - uint32_t server_index, - rtems_vector_number vector, - const char *info, - rtems_option options, - rtems_interrupt_handler routine, - void *arg -); - -/* Generated from spec:/rtems/intr/if/server-handler-remove */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief Removes the interrupt handler routine and argument from the interrupt - * vector and the interrupt server. - * - * @param server_index is the interrupt server index. The constant - * #RTEMS_INTERRUPT_SERVER_DEFAULT may be used to specify the default - * interrupt server. - * - * @param vector is the interrupt vector number. - * - * @param routine is the interrupt handler routine to remove. - * - * @param arg is the interrupt handler argument to remove. - * - * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. - * - * @retval ::RTEMS_INVALID_ID There was no interrupt server associated with the - * index specified by ``server_index``. - * - * @retval ::RTEMS_INVALID_ID There was no interrupt vector associated with the - * number specified by ``vector``. - * - * @retval ::RTEMS_UNSATISFIED There was no handler routine and argument pair - * installed specified by ``routine`` and ``arg``. - * - * @par Constraints - * @parblock - * The following constraints apply to this directive: - * - * * The directive may be called from within task context. - * - * * The directive may obtain and release the object allocator mutex. This may - * cause the calling task to be preempted. - * - * * The directive sends a request to another task and waits for a response. - * This may cause the calling task to be blocked and unblocked. - * - * * The directive shall not be called from within the context of an interrupt - * server. Calling the directive from within the context of an interrupt - * server is undefined behaviour. - * @endparblock - */ -rtems_status_code rtems_interrupt_server_handler_remove( - uint32_t server_index, - rtems_vector_number vector, - rtems_interrupt_handler routine, - void *arg -); - -/* Generated from spec:/rtems/intr/if/server-set-affinity */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief Sets the processor affinity of the interrupt server. - * - * @param server_index is the interrupt server index. The constant - * #RTEMS_INTERRUPT_SERVER_DEFAULT may be used to specify the default - * interrupt server. - * - * @param affinity_size is the size of the processor set referenced by - * ``affinity`` in bytes. - * - * @param affinity is the pointer to a cpu_set_t object. The processor set - * defines the new processor affinity set of the interrupt server. A set bit - * in the processor set means that the corresponding processor shall be in - * the processor affinity set of the task, otherwise the bit shall be - * cleared. - * - * @param priority is the new real priority for the interrupt server. - * - * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. - * - * @retval ::RTEMS_INVALID_ID There was no interrupt server associated with the - * index specified by ``server_index``. - * - * @return The directive uses rtems_scheduler_ident_by_processor_set(), - * rtems_task_set_scheduler(), and rtems_task_set_affinity(). If one of - * these directive fails, then its error status will be returned. - * - * @par Notes - * @parblock - * The scheduler is set determined by the highest numbered processor in the - * affinity set specified by ``affinity``. - * - * This operation is only reliable in case the interrupt server was suspended - * via rtems_interrupt_server_suspend(). - * @endparblock - * - * @par Constraints - * @parblock - * The following constraints apply to this directive: - * - * * The directive may be called from within interrupt context. - * - * * The directive may be called from within device driver initialization - * context. - * - * * The directive may be called from within task context. - * - * * The directive may change the processor affinity of a task. This may cause - * the calling task to be preempted. - * - * * The directive may change the priority of a task. This may cause the - * calling task to be preempted. - * @endparblock - */ -rtems_status_code rtems_interrupt_server_set_affinity( - uint32_t server_index, - size_t affinity_size, - const cpu_set_t *affinity, - rtems_task_priority priority -); - -/* Generated from spec:/rtems/intr/if/server-delete */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief Deletes the interrupt server. - * - * @param server_index is the index of the interrupt server to delete. - * - * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. - * - * @retval ::RTEMS_INVALID_ID There was no interrupt server associated with the - * server index specified by ``server_index``. - * - * @par Notes - * @parblock - * The interrupt server deletes itself, so after the return of the directive - * the interrupt server may be still in the termination process depending on - * the task priorities of the system. - * - * See also rtems_interrupt_server_create(). - * @endparblock - * - * @par Constraints - * @parblock - * The following constraints apply to this directive: - * - * * The directive may be called from within task context. - * - * * The directive shall not be called from within the context of an interrupt - * server. Calling the directive from within the context of an interrupt - * server is undefined behaviour. - * - * * The directive sends a request to another task and waits for a response. - * This may cause the calling task to be blocked and unblocked. - * @endparblock - */ -rtems_status_code rtems_interrupt_server_delete( uint32_t server_index ); - -/* Generated from spec:/rtems/intr/if/server-suspend */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief Suspends the interrupt server. - * - * @param server_index is the index of the interrupt server to suspend. The - * constant #RTEMS_INTERRUPT_SERVER_DEFAULT may be used to specify the - * default interrupt server. - * - * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. - * - * @retval ::RTEMS_INVALID_ID There was no interrupt server associated with the - * index specified by ``server_index``. - * - * @par Notes - * Interrupt server may be resumed by rtems_interrupt_server_resume(). - * - * @par Constraints - * @parblock - * The following constraints apply to this directive: - * - * * The directive may be called from within task context. - * - * * The directive shall not be called from within the context of an interrupt - * server. Calling the directive from within the context of an interrupt - * server is undefined behaviour. - * - * * The directive sends a request to another task and waits for a response. - * This may cause the calling task to be blocked and unblocked. - * @endparblock - */ -rtems_status_code rtems_interrupt_server_suspend( uint32_t server_index ); - -/* Generated from spec:/rtems/intr/if/server-resume */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief Resumes the interrupt server. - * - * @param server_index is the index of the interrupt server to resume. The - * constant #RTEMS_INTERRUPT_SERVER_DEFAULT may be used to specify the - * default interrupt server. - * - * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. - * - * @retval ::RTEMS_INVALID_ID There was no interrupt server associated with the - * index specified by ``server_index``. - * - * @par Notes - * Interrupt server may be suspended by rtems_interrupt_server_suspend(). - * - * @par Constraints - * @parblock - * The following constraints apply to this directive: - * - * * The directive may be called from within task context. - * - * * The directive shall not be called from within the context of an interrupt - * server. Calling the directive from within the context of an interrupt - * server is undefined behaviour. - * - * * The directive sends a request to another task and waits for a response. - * This may cause the calling task to be blocked and unblocked. - * @endparblock - */ -rtems_status_code rtems_interrupt_server_resume( uint32_t server_index ); - -/* Generated from spec:/rtems/intr/if/server-move */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief Moves the interrupt handlers installed at the interrupt vector and - * the source interrupt server to the destination interrupt server. - * - * @param source_server_index is the index of the source interrupt server. The - * constant #RTEMS_INTERRUPT_SERVER_DEFAULT may be used to specify the - * default interrupt server. - * - * @param vector is the interrupt vector number. - * - * @param destination_server_index is the index of the destination interrupt - * server. The constant #RTEMS_INTERRUPT_SERVER_DEFAULT may be used to - * specify the default interrupt server. - * - * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. - * - * @retval ::RTEMS_INVALID_ID There was no interrupt server associated with the - * index specified by ``source_server_index``. - * - * @retval ::RTEMS_INVALID_ID There was no interrupt server associated with the - * index specified by ``destination_server_index``. - * - * @retval ::RTEMS_INVALID_ID There was no interrupt vector associated with the - * number specified by ``vector``. - * - * @par Constraints - * @parblock - * The following constraints apply to this directive: - * - * * The directive may be called from within task context. - * - * * The directive shall not be called from within the context of an interrupt - * server. Calling the directive from within the context of an interrupt - * server is undefined behaviour. - * - * * The directive sends a request to another task and waits for a response. - * This may cause the calling task to be blocked and unblocked. - * @endparblock - */ -rtems_status_code rtems_interrupt_server_move( - uint32_t source_server_index, - rtems_vector_number vector, - uint32_t destination_server_index -); - -/* Generated from spec:/rtems/intr/if/server-handler-iterate */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief Iterates over all interrupt handler installed at the interrupt vector - * and interrupt server. - * - * @param server_index is the index of the interrupt server. - * - * @param vector is the interrupt vector number. - * - * @param routine is the visitor routine. - * - * @param arg is the visitor argument. - * - * For each installed handler at the interrupt vector and interrupt server the - * visitor function specified by ``vector`` will be called with the argument - * specified by ``routine`` and the handler information, options, routine and - * argument. - * - * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. - * - * @retval ::RTEMS_INVALID_ID There was no interrupt server associated with the - * index specified by ``server_index``. - * - * @retval ::RTEMS_INVALID_ID There was no interrupt vector associated with the - * number specified by ``vector``. - * - * @par Notes - * @parblock - * The directive is intended for system information and diagnostics. - * - * Never install or remove an interrupt handler within the visitor function. - * This may result in a deadlock. - * @endparblock - * - * @par Constraints - * @parblock - * The following constraints apply to this directive: - * - * * The directive may be called from within device driver initialization - * context. - * - * * The directive may be called from within task context. - * - * * The directive may obtain and release the object allocator mutex. This may - * cause the calling task to be preempted. - * @endparblock - */ -rtems_status_code rtems_interrupt_server_handler_iterate( - uint32_t server_index, - rtems_vector_number vector, - rtems_interrupt_per_handler_routine routine, - void *arg -); - -/* Generated from spec:/rtems/intr/if/server-action */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief This structure represents an interrupt server action. - * - * @par Notes - * This structure shall be treated as an opaque data type from the API point of - * view. Members shall not be accessed directly. - */ -typedef struct rtems_interrupt_server_action { - /** - * @brief This member is the reference to the next action or NULL. - */ - struct rtems_interrupt_server_action *next; - - /** - * @brief This member is the interrupt handler. - */ - rtems_interrupt_handler handler; - - /** - * @brief This member is the interrupt handler argument. - */ - void *arg; -} rtems_interrupt_server_action; - -/* Generated from spec:/rtems/intr/if/server-entry */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief This structure represents an interrupt server entry. - * - * @par Notes - * This structure shall be treated as an opaque data type from the API point of - * view. Members shall not be accessed directly. An entry is initialized by - * rtems_interrupt_server_entry_initialize() and destroyed by - * rtems_interrupt_server_entry_destroy(). Interrupt server actions can be - * prepended to the entry by rtems_interrupt_server_action_prepend(). The - * entry is submitted to be serviced by rtems_interrupt_server_entry_submit(). - */ -typedef struct { - /** - * @brief This member is the node for the interrupt entry processing. - */ - Chain_Node node; - - /** - * @brief This member references the interrupt server used to process the - * entry. - */ - rtems_interrupt_server_control *server; - - /** - * @brief This member is the interrupt vector number. - */ - rtems_vector_number vector; - - /** - * @brief This member is the interrupt server actions list head. - */ - rtems_interrupt_server_action *actions; -} rtems_interrupt_server_entry; - -/* Generated from spec:/rtems/intr/if/server-entry-initialize */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief Initializes the interrupt server entry. - * - * @param server_index is the interrupt server index. The constant - * #RTEMS_INTERRUPT_SERVER_DEFAULT may be used to specify the default - * interrupt server. - * - * @param entry is the interrupt server entry to initialize. - * - * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. - * - * @retval ::RTEMS_INVALID_ID There was no interrupt server associated with the - * index specified by ``server_index``. - * - * @par Notes - * After initialization, the list of actions of the interrupt server entry is - * empty. Actions may be prepended by rtems_interrupt_server_action_prepend(). - * Interrupt server entries may be moved to another interrupt vector with - * rtems_interrupt_server_entry_move(). Server entries may be submitted to get - * serviced by the interrupt server with rtems_interrupt_server_entry_submit(). - * Server entries may be destroyed by rtems_interrupt_server_entry_destroy(). - * - * @par Constraints - * @parblock - * The following constraints apply to this directive: - * - * * The directive may be called from within device driver initialization - * context. - * - * * The directive may be called from within task context. - * - * * The directive may obtain and release the object allocator mutex. This may - * cause the calling task to be preempted. - * @endparblock - */ -rtems_status_code rtems_interrupt_server_entry_initialize( - uint32_t server_index, - rtems_interrupt_server_entry *entry -); - -/* Generated from spec:/rtems/intr/if/server-action-prepend */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief Prepends the interrupt server action to the list of actions of the - * interrupt server entry. - * - * @param[in,out] entry is the interrupt server entry to prepend the interrupt - * server action. It shall have been initialized via - * rtems_interrupt_server_entry_initialize(). - * - * @param[out] action is the interrupt server action to initialize and prepend - * to the list of actions of the entry. - * - * @param routine is the interrupt handler routine to set in the action. - * - * @param arg is the interrupt handler argument to set in the action. - * - * @par Notes - * No error checking is performed by the directive. - * - * @par Constraints - * @parblock - * The following constraints apply to this directive: - * - * * The directive may be called from within interrupt context. - * - * * The directive may be called from within device driver initialization - * context. - * - * * The directive may be called from within task context. - * - * * The directive will not cause the calling task to be preempted. - * - * * The interrupt server entry shall have been initialized by - * rtems_interrupt_server_entry_initialize() and further optional calls to - * rtems_interrupt_server_action_prepend(). - * - * * The directive shall not be called concurrently with - * rtems_interrupt_server_action_prepend() with the same interrupt server - * entry. Calling the directive under this condition is undefined behaviour. - * - * * The directive shall not be called concurrently with - * rtems_interrupt_server_entry_move() with the same interrupt server entry. - * Calling the directive under this condition is undefined behaviour. - * - * * The directive shall not be called concurrently with - * rtems_interrupt_server_entry_submit() with the same interrupt server - * entry. Calling the directive under this condition is undefined behaviour. - * - * * The directive shall not be called while the interrupt server entry is - * pending on or serviced by its current interrupt server. Calling the - * directive under these conditions is undefined behaviour. - * @endparblock - */ -void rtems_interrupt_server_action_prepend( - rtems_interrupt_server_entry *entry, - rtems_interrupt_server_action *action, - rtems_interrupt_handler routine, - void *arg -); - -/* Generated from spec:/rtems/intr/if/server-entry-destroy */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief Destroys the interrupt server entry. - * - * @param[in,out] entry is the interrupt server entry to destroy. - * - * @par Notes - * No error checking is performed by the directive. - * - * @par Constraints - * @parblock - * The following constraints apply to this directive: - * - * * The directive may be called from within task context. - * - * * The directive shall not be called from within the context of an interrupt - * server. Calling the directive from within the context of an interrupt - * server is undefined behaviour. - * - * * The directive sends a request to another task and waits for a response. - * This may cause the calling task to be blocked and unblocked. - * - * * The interrupt server entry shall have been initialized by - * rtems_interrupt_server_entry_initialize() and further optional calls to - * rtems_interrupt_server_action_prepend(). - * @endparblock - */ -void rtems_interrupt_server_entry_destroy( - rtems_interrupt_server_entry *entry -); - -/* Generated from spec:/rtems/intr/if/server-entry-submit */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief Submits the interrupt server entry to be serviced by the interrupt - * server. - * - * @param entry is the interrupt server entry to submit. - * - * The directive appends the entry to the pending entries of the interrupt - * server. The interrupt server is notified that a new entry is pending. Once - * the interrupt server is scheduled it services the actions of all pending - * entries. - * - * @par Notes - * @parblock - * This directive may be used to do a two-step interrupt processing. The first - * step is done from within interrupt context by a call to this directive. The - * second step is then done from within the context of the interrupt server. - * - * No error checking is performed by the directive. - * - * A submitted entry may be destroyed by - * rtems_interrupt_server_entry_destroy(). - * @endparblock - * - * @par Constraints - * @parblock - * The following constraints apply to this directive: - * - * * The directive may be called from within interrupt context. - * - * * The directive may be called from within device driver initialization - * context. - * - * * The directive may be called from within task context. - * - * * The directive may unblock a task. This may cause the calling task to be - * preempted. - * - * * The interrupt server entry shall have been initialized by - * rtems_interrupt_server_entry_initialize() and further optional calls to - * rtems_interrupt_server_action_prepend(). - * - * * The directive shall not be called concurrently with - * rtems_interrupt_server_action_prepend() with the same interrupt server - * entry. Calling the directive under this condition is undefined behaviour. - * - * * The directive shall not be called concurrently with - * rtems_interrupt_server_entry_move() with the same interrupt server entry. - * Calling the directive under this condition is undefined behaviour. - * @endparblock - */ -void rtems_interrupt_server_entry_submit( - rtems_interrupt_server_entry *entry -); - -/* Generated from spec:/rtems/intr/if/server-entry-move */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief Moves the interrupt server entry to the interrupt server. - * - * @param entry is the interrupt server entry to move. - * - * @param server_index is the index of the destination interrupt server. The - * constant #RTEMS_INTERRUPT_SERVER_DEFAULT may be used to specify the - * default interrupt server. - * - * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. - * - * @retval ::RTEMS_INVALID_ID There was no interrupt server associated with the - * index specified by ``server_index``. - * - * @par Constraints - * @parblock - * The following constraints apply to this directive: - * - * * The directive may be called from within device driver initialization - * context. - * - * * The directive may be called from within task context. - * - * * The directive may obtain and release the object allocator mutex. This may - * cause the calling task to be preempted. - * - * * The interrupt server entry shall have been initialized by - * rtems_interrupt_server_entry_initialize() and further optional calls to - * rtems_interrupt_server_action_prepend(). - * - * * The directive shall not be called concurrently with - * rtems_interrupt_server_action_prepend() with the same interrupt server - * entry. Calling the directive under this condition is undefined behaviour. - * - * * The directive shall not be called concurrently with - * rtems_interrupt_server_entry_move() with the same interrupt server entry. - * Calling the directive under this condition is undefined behaviour. - * - * * The directive shall not be called concurrently with - * rtems_interrupt_server_entry_submit() with the same interrupt server - * entry. Calling the directive under this condition is undefined behaviour. - * - * * The directive shall not be called while the interrupt server entry is - * pending on or serviced by its current interrupt server. Calling the - * directive under these conditions is undefined behaviour. - * @endparblock - */ -rtems_status_code rtems_interrupt_server_entry_move( - rtems_interrupt_server_entry *entry, - uint32_t server_index -); - -/* Generated from spec:/rtems/intr/if/server-request */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief This structure represents an interrupt server request. - * - * @par Notes - * This structure shall be treated as an opaque data type from the API point of - * view. Members shall not be accessed directly. A request is initialized by - * rtems_interrupt_server_request_initialize() and destroyed by - * rtems_interrupt_server_request_destroy(). The interrupt vector of the - * request can be set by rtems_interrupt_server_request_set_vector(). The - * request is submitted to be serviced by - * rtems_interrupt_server_request_submit(). - */ -typedef struct { - /** - * @brief This member is the interrupt server entry. - */ - rtems_interrupt_server_entry entry; - - /** - * @brief This member is the interrupt server action. - */ - rtems_interrupt_server_action action; -} rtems_interrupt_server_request; - -/* Generated from spec:/rtems/intr/if/server-request-initialize */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief Initializes the interrupt server request. - * - * @param server_index is the interrupt server index. The constant - * #RTEMS_INTERRUPT_SERVER_DEFAULT may be used to specify the default - * interrupt server. - * - * @param[out] request is the interrupt server request to initialize. - * - * @param routine is the interrupt handler routine for the request action. - * - * @param arg is the interrupt handler argument for the request action. - * - * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. - * - * @retval ::RTEMS_INVALID_ID There was no interrupt server associated with the - * index specified by ``server_index``. - * - * @par Notes - * An interrupt server requests consists of an interrupt server entry and - * exactly one interrupt server action. The interrupt vector of the request - * may be changed with rtems_interrupt_server_request_set_vector(). Interrupt - * server requests may be submitted to get serviced by the interrupt server - * with rtems_interrupt_server_request_submit(). Requests may be destroyed by - * rtems_interrupt_server_request_destroy(). - * - * @par Constraints - * @parblock - * The following constraints apply to this directive: - * - * * The directive may be called from within device driver initialization - * context. - * - * * The directive may be called from within task context. - * - * * The directive may obtain and release the object allocator mutex. This may - * cause the calling task to be preempted. - * @endparblock - */ -rtems_status_code rtems_interrupt_server_request_initialize( - uint32_t server_index, - rtems_interrupt_server_request *request, - rtems_interrupt_handler routine, - void *arg -); - -/* Generated from spec:/rtems/intr/if/server-request-set-vector */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief Sets the interrupt vector in the interrupt server request. - * - * @param[in,out] request is the interrupt server request to change. - * - * @param vector is the interrupt vector number to be used by the request. - * - * @par Notes - * @parblock - * By default, the interrupt vector of an interrupt server request is set to a - * special value which is outside the range of vectors supported by the - * interrupt controller hardware. - * - * Calls to rtems_interrupt_server_request_submit() will disable the interrupt - * vector of the request. After processing of the request by the interrupt - * server the interrupt vector will be enabled again. - * @endparblock - * - * @par Constraints - * @parblock - * The following constraints apply to this directive: - * - * * The directive may be called from within interrupt context. - * - * * The directive may be called from within device driver initialization - * context. - * - * * The directive may be called from within task context. - * - * * The directive will not cause the calling task to be preempted. - * - * * The interrupt server request shall have been initialized by - * rtems_interrupt_server_request_initialize(). - * - * * The directive shall not be called concurrently with - * rtems_interrupt_server_request_set_vector() with the same interrupt server - * request. Calling the directive under this condition is undefined - * behaviour. - * - * * The directive shall not be called concurrently with - * rtems_interrupt_server_request_submit() with the same interrupt server - * request. Calling the directive under this condition is undefined - * behaviour. - * - * * The directive shall not be called while the interrupt server entry is - * pending on or serviced by its current interrupt server. Calling the - * directive under these conditions is undefined behaviour. - * @endparblock - */ -static inline void rtems_interrupt_server_request_set_vector( - rtems_interrupt_server_request *request, - rtems_vector_number vector -) -{ - request->entry.vector = vector; -} - -/* Generated from spec:/rtems/intr/if/server-request-destroy */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief Destroys the interrupt server request. - * - * @param[in,out] request is the interrupt server request to destroy. - * - * @par Notes - * No error checking is performed by the directive. - * - * @par Constraints - * @parblock - * The following constraints apply to this directive: - * - * * The directive may be called from within task context. - * - * * The directive shall not be called from within the context of an interrupt - * server. Calling the directive from within the context of an interrupt - * server is undefined behaviour. - * - * * The directive sends a request to another task and waits for a response. - * This may cause the calling task to be blocked and unblocked. - * - * * The interrupt server request shall have been initialized by - * rtems_interrupt_server_request_initialize(). - * @endparblock - */ -static inline void rtems_interrupt_server_request_destroy( - rtems_interrupt_server_request *request -) -{ - rtems_interrupt_server_entry_destroy( &request->entry ); -} - -/* Generated from spec:/rtems/intr/if/server-request-submit */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief Submits the interrupt server request to be serviced by the interrupt - * server. - * - * @param[in,out] request is the interrupt server request to submit. - * - * The directive appends the interrupt server entry of the request to the - * pending entries of the interrupt server. The interrupt server is notified - * that a new entry is pending. Once the interrupt server is scheduled it - * services the actions of all pending entries. - * - * @par Notes - * @parblock - * This directive may be used to do a two-step interrupt processing. The first - * step is done from within interrupt context by a call to this directive. The - * second step is then done from within the context of the interrupt server. - * - * No error checking is performed by the directive. - * - * A submitted request may be destroyed by - * rtems_interrupt_server_request_destroy(). - * @endparblock - * - * @par Constraints - * @parblock - * The following constraints apply to this directive: - * - * * The directive may be called from within interrupt context. - * - * * The directive may be called from within device driver initialization - * context. - * - * * The directive may be called from within task context. - * - * * The directive may unblock a task. This may cause the calling task to be - * preempted. - * - * * The interrupt server request shall have been initialized by - * rtems_interrupt_server_request_initialize(). - * - * * The directive shall not be called concurrently with - * rtems_interrupt_server_request_set_vector() with the same interrupt server - * request. Calling the directive under this condition is undefined - * behaviour. - * @endparblock - */ -static inline void rtems_interrupt_server_request_submit( - rtems_interrupt_server_request *request -) -{ - rtems_interrupt_server_entry_submit( &request->entry ); -} - #ifdef __cplusplus } #endif diff --git a/cpukit/include/rtems/rtems/intr.h b/cpukit/include/rtems/rtems/intr.h index 7663541adc..b99050e9ce 100644 --- a/cpukit/include/rtems/rtems/intr.h +++ b/cpukit/include/rtems/rtems/intr.h @@ -7,7 +7,7 @@ */ /* - * Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 2008, 2021 embedded brains GmbH (http://www.embedded-brains.de) * Copyright (C) 1988, 2008 On-Line Applications Research Corporation (OAR) * * Redistribution and use in source and binary forms, with or without @@ -54,9 +54,16 @@ #ifndef _RTEMS_RTEMS_INTR_H #define _RTEMS_RTEMS_INTR_H +#include #include +#include +#include +#include +#include #include +#include #include +#include #include #include #include @@ -82,6 +89,286 @@ extern "C" { * task to be preempted upon exit from an ISR. */ +/* Generated from spec:/rtems/intr/if/handler */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief Interrupt handler routines shall have this type. + */ +typedef void ( *rtems_interrupt_handler )( void * ); + +/* Generated from spec:/rtems/intr/if/lock */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief This structure represents an ISR lock. + */ +typedef ISR_lock_Control rtems_interrupt_lock; + +/* Generated from spec:/rtems/intr/if/per-handler-routine */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief Visitor routines invoked by rtems_interrupt_handler_iterate() shall + * have this type. + */ +typedef void ( *rtems_interrupt_per_handler_routine )( + void *, + const char *, + rtems_option, + rtems_interrupt_handler, + void * +); + +/* Generated from spec:/rtems/intr/if/vector-number */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief This integer type represents interrupt vector numbers. + */ +typedef ISR_Vector_number rtems_vector_number; + +/* Generated from spec:/rtems/intr/if/shared */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief This interrupt handler install option allows that the interrupt + * handler may share the interrupt vector with other handler. + */ +#define RTEMS_INTERRUPT_SHARED ( (rtems_option) 0x00000000 ) + +/* Generated from spec:/rtems/intr/if/unique */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief This interrupt handler install option ensures that the interrupt + * handler is unique. + * + * This option prevents other handler from using the same interrupt vector. + */ +#define RTEMS_INTERRUPT_UNIQUE ( (rtems_option) 0x00000001 ) + +/* Generated from spec:/rtems/intr/if/replace */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief This interrupt handler install option requests that the interrupt + * handler replaces the first handler with the same argument. + */ +#define RTEMS_INTERRUPT_REPLACE ( (rtems_option) 0x00000002 ) + +/* Generated from spec:/rtems/intr/if/entry */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief This structure represents an interrupt entry. + * + * @par Notes + * This structure shall be treated as an opaque data type from the API point of + * view. Members shall not be accessed directly. An entry may be initialized + * by RTEMS_INTERRUPT_ENTRY_INITIALIZER() or + * rtems_interrupt_entry_initialize(). It may be installed for an interrupt + * vector with rtems_interrupt_entry_install() and removed from an interrupt + * vector by rtems_interrupt_entry_remove(). + */ +typedef struct rtems_interrupt_entry { + /** + * @brief This member is the interrupt handler routine. + */ + rtems_interrupt_handler handler; + + /** + * @brief This member is the interrupt handler argument. + */ + void *arg; + + /** + * @brief This member is the reference to the next entry or NULL. + */ + struct rtems_interrupt_entry *next; + + /** + * @brief This member is the descriptive information of the entry. + */ + const char *info; +} rtems_interrupt_entry; + +/* Generated from spec:/rtems/intr/if/signal-variant */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief This enumeration provides interrupt trigger signal variants. + */ +typedef enum { + /** + * @brief This interrupt signal variant indicates that the interrupt trigger + * signal is unspecified. + */ + RTEMS_INTERRUPT_UNSPECIFIED_SIGNAL, + + /** + * @brief This interrupt signal variant indicates that the interrupt cannot be + * triggered by a signal. + */ + RTEMS_INTERRUPT_NO_SIGNAL, + + /** + * @brief This interrupt signal variant indicates that the interrupt is + * triggered by a low level signal. + */ + RTEMS_INTERRUPT_SIGNAL_LEVEL_LOW, + + /** + * @brief This interrupt signal variant indicates that the interrupt is + * triggered by a high level signal. + */ + RTEMS_INTERRUPT_SIGNAL_LEVEL_HIGH, + + /** + * @brief This interrupt signal variant indicates that the interrupt is + * triggered by a falling edge signal. + */ + RTEMS_INTERRUPT_SIGNAL_EDGE_FALLING, + + /** + * @brief This interrupt signal variant indicates that the interrupt is + * triggered by a raising edge signal. + */ + RTEMS_INTERRUPT_SIGNAL_EDGE_RAISING +} rtems_interrupt_signal_variant; + +/* Generated from spec:/rtems/intr/if/attributes */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief This structure provides the attributes of an interrupt vector. + * + * The rtems_interrupt_get_attributes() directive may be used to obtain the + * attributes of an interrupt vector. + */ +typedef struct { + /** + * @brief This member is true, if the interrupt vector is maskable by + * rtems_interrupt_local_disable(), otherwise it is false. + * + * Interrupt vectors which are not maskable by rtems_interrupt_local_disable() + * should be used with care since they cannot use most operating system + * services. + */ + bool is_maskable; + + /** + * @brief This member is true, if the interrupt vector can be enabled by + * rtems_interrupt_vector_enable(), otherwise it is false. + * + * When an interrupt vector can be enabled, this means that the enabled state + * can always be changed from disabled to enabled. For an interrupt vector + * which can be enabled it follows that it may be enabled. + */ + bool can_enable; + + /** + * @brief This member is true, if the interrupt vector may be enabled by + * rtems_interrupt_vector_enable(), otherwise it is false. + * + * When an interrupt vector may be enabled, this means that the enabled state + * may be changed from disabled to enabled. The requested enabled state change + * should be checked by rtems_interrupt_vector_is_enabled(). Some interrupt + * vectors may be optionally available and cannot be enabled on a particular + * target. + */ + bool maybe_enable; + + /** + * @brief This member is true, if the interrupt vector can be disabled by + * rtems_interrupt_vector_disable(), otherwise it is false. + * + * When an interrupt vector can be disabled, this means that the enabled state + * can be changed from enabled to disabled. For an interrupt vector which can + * be disabled it follows that it may be disabled. + */ + bool can_disable; + + /** + * @brief This member is true, if the interrupt vector may be disabled by + * rtems_interrupt_vector_disable(), otherwise it is false. + * + * When an interrupt vector may be disabled, this means that the enabled state + * may be changed from enabled to disabled. The requested enabled state change + * should be checked by rtems_interrupt_vector_is_enabled(). Some interrupt + * vectors may be always enabled and cannot be disabled on a particular target. + */ + bool maybe_disable; + + /** + * @brief This member is true, if the interrupt vector can be raised by + * rtems_interrupt_raise(), otherwise it is false. + */ + bool can_raise; + + /** + * @brief This member is true, if the interrupt vector can be raised on a + * processor by rtems_interrupt_raise_on(), otherwise it is false. + */ + bool can_raise_on; + + /** + * @brief This member is true, if the interrupt vector can be cleared by + * rtems_interrupt_clear(), otherwise it is false. + */ + bool can_clear; + + /** + * @brief This member is true, if the pending status of the interrupt + * associated with the interrupt vector is cleared by an interrupt + * acknowledge from the processor, otherwise it is false. + */ + bool cleared_by_acknowledge; + + /** + * @brief This member is true, if the affinity set of the interrupt vector can + * be obtained by rtems_interrupt_get_affinity(), otherwise it is false. + */ + bool can_get_affinity; + + /** + * @brief This member is true, if the affinity set of the interrupt vector can + * be set by rtems_interrupt_set_affinity(), otherwise it is false. + */ + bool can_set_affinity; + + /** + * @brief This member is true, if the interrupt associated with the interrupt + * vector can be triggered by a message. + * + * Interrupts may be also triggered by signals, rtems_interrupt_raise(), or + * rtems_interrupt_raise_on(). Examples for message triggered interrupts are + * the PCIe MSI/MSI-X and the ARM GICv3 Locality-specific Peripheral Interrupts + * (LPI). + */ + bool can_be_triggered_by_message; + + /** + * @brief This member describes the trigger signal of the interrupt associated + * with the interrupt vector. + * + * Interrupts are normally triggered by signals which indicate an interrupt + * request from a peripheral. Interrupts may be also triggered by messages, + * rtems_interrupt_raise(), or rtems_interrupt_raise_on(). + */ + rtems_interrupt_signal_variant trigger_signal; +} rtems_interrupt_attributes; + /* Generated from spec:/rtems/intr/if/isr */ /** @@ -117,15 +404,6 @@ typedef ISR_Handler rtems_isr; */ typedef ISR_Level rtems_interrupt_level; -/* Generated from spec:/rtems/intr/if/lock */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief This structure represents an ISR lock. - */ -typedef ISR_lock_Control rtems_interrupt_lock; - /* Generated from spec:/rtems/intr/if/lock-context */ /** @@ -136,15 +414,6 @@ typedef ISR_lock_Control rtems_interrupt_lock; */ typedef ISR_lock_Context rtems_interrupt_lock_context; -/* Generated from spec:/rtems/intr/if/vector-number */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief This integer type represents interrupt vector numbers. - */ -typedef ISR_Vector_number rtems_vector_number; - /* Generated from spec:/rtems/intr/if/catch */ /** @@ -874,111 +1143,691 @@ rtems_status_code rtems_interrupt_catch( #define RTEMS_INTERRUPT_LOCK_REFERENCE( _designator, _target ) \ ISR_LOCK_REFERENCE( _designator, _target ) -/* Generated from spec:/rtems/intr/if/raise */ +/* Generated from spec:/rtems/intr/if/is-shared */ + +/** + * @brief Checks if the interrupt handler shared option is set. + * + * @param _options is the interrupt handler option set to check. + * + * @return Returns true, if the interrupt handler shared option + * #RTEMS_INTERRUPT_SHARED is set, otherwise false. + */ +#define RTEMS_INTERRUPT_IS_SHARED( _options ) \ + ( ( _options ) & RTEMS_INTERRUPT_SHARED ) + +/* Generated from spec:/rtems/intr/if/is-unique */ + +/** + * @brief Checks if the interrupt handler unique option is set. + * + * @param _options is the interrupt handler option set to check. + * + * @return Returns true, if the interrupt handler unique option + * #RTEMS_INTERRUPT_UNIQUE is set, otherwise false. + */ +#define RTEMS_INTERRUPT_IS_UNIQUE( _options ) \ + ( ( _options ) & RTEMS_INTERRUPT_UNIQUE ) + +/* Generated from spec:/rtems/intr/if/is-replace */ + +/** + * @brief Checks if the interrupt handler replace option is set. + * + * @param _options is the interrupt handler option set to check. + * + * @return Returns true, if the interrupt handler replace option + * #RTEMS_INTERRUPT_REPLACE is set, otherwise false. + */ +#define RTEMS_INTERRUPT_IS_REPLACE( _options ) \ + ( ( _options ) & RTEMS_INTERRUPT_REPLACE ) + +/* Generated from spec:/rtems/intr/if/entry-initializer */ /** * @ingroup RTEMSAPIClassicIntr * - * @brief Raises the interrupt vector. + * @brief Statically initializes an interrupt entry object. * - * @param vector is the number of the interrupt vector to raise. + * @param _routine is the interrupt handler routine for the entry. * - * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. + * @param _arg is the interrupt handler argument for the entry. * - * @retval ::RTEMS_INVALID_ID There was no interrupt vector associated with the - * number specified by ``vector``. + * @param _info is the descriptive information for the entry. * - * @retval ::RTEMS_UNSATISFIED The request to raise the interrupt vector has - * not been satisfied. + * @par Notes + * Alternatively, rtems_interrupt_entry_initialize() may be used to dynamically + * initialize an interrupt entry. + */ +#define RTEMS_INTERRUPT_ENTRY_INITIALIZER( _routine, _arg, _info ) \ + { _routine, _arg, NULL, _info } + +/* Generated from spec:/rtems/intr/if/entry-initialize */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief Initializes the interrupt entry. + * + * @param[out] entry is the interrupt entry to initialize. + * + * @param routine is the interrupt handler routine for the entry. + * + * @param arg is the interrupt handler argument for the entry. + * + * @param info is the descriptive information for the entry. * * @par Notes - * The rtems_interrupt_get_attributes() directive may be used to check if an - * interrupt vector can be raised. + * Alternatively, RTEMS_INTERRUPT_ENTRY_INITIALIZER() may be used to statically + * initialize an interrupt entry. * * @par Constraints * @parblock * The following constraints apply to this directive: * - * * The directive may be called from within interrupt context. - * - * * The directive may be called from within device driver initialization - * context. - * - * * The directive may be called from within task context. + * * The directive may be called from within any runtime context. * * * The directive will not cause the calling task to be preempted. * @endparblock */ -rtems_status_code rtems_interrupt_raise( rtems_vector_number vector ); +static inline void rtems_interrupt_entry_initialize( + rtems_interrupt_entry *entry, + rtems_interrupt_handler routine, + void *arg, + const char *info +) +{ + entry->handler = routine; + entry->arg = arg; + entry->next = NULL; + entry->info = info; +} -/* Generated from spec:/rtems/intr/if/raise-on */ +/* Generated from spec:/rtems/intr/if/entry-install */ /** * @ingroup RTEMSAPIClassicIntr * - * @brief Raises the interrupt vector on the processor. + * @brief Installs the interrupt entry at the interrupt vector. * - * @param vector is the number of the interrupt vector to raise. + * @param vector is the interrupt vector number. * - * @param cpu_index is the index of the target processor of the interrupt - * vector to raise. + * @param options is the interrupt entry install option set. + * + * @param entry is the interrupt entry to install. + * + * One of the following mutually exclusive options + * + * * #RTEMS_INTERRUPT_UNIQUE, and + * + * * #RTEMS_INTERRUPT_SHARED + * + * shall be set in the ``options`` parameter. + * + * The handler routine of the entry specified by ``entry`` will be called with + * the handler argument of the entry when dispatched. The order in which + * shared interrupt handlers are dispatched for one vector is defined by the + * installation order. The first installed handler is dispatched first. + * + * If the option #RTEMS_INTERRUPT_UNIQUE is set, then it will be ensured that + * the handler will be the only one for the interrupt vector. + * + * If the option #RTEMS_INTERRUPT_SHARED is set, then multiple handlers may be + * installed for the interrupt vector. * * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. * + * @retval ::RTEMS_INVALID_ADDRESS The ``entry`` parameter was NULL. + * + * @retval ::RTEMS_INCORRECT_STATE The service was not initialized. + * + * @retval ::RTEMS_INVALID_ADDRESS The handler routine of the entry was NULL. + * * @retval ::RTEMS_INVALID_ID There was no interrupt vector associated with the * number specified by ``vector``. * - * @retval ::RTEMS_NOT_CONFIGURED The processor specified by ``cpu_index`` was - * not configured to be used by the application. + * @retval ::RTEMS_CALLED_FROM_ISR The directive was called from within + * interrupt context. * - * @retval ::RTEMS_INCORRECT_STATE The processor specified by ``cpu_index`` was - * configured to be used by the application, however, it was not online. + * @retval ::RTEMS_INVALID_NUMBER An option specified by ``options`` was not + * applicable. * - * @retval ::RTEMS_UNSATISFIED The request to raise the interrupt vector has - * not been satisfied. + * @retval ::RTEMS_RESOURCE_IN_USE The #RTEMS_INTERRUPT_UNIQUE option was set + * in ``entry`` and the interrupt vector was already occupied by a handler. + * + * @retval ::RTEMS_RESOURCE_IN_USE The #RTEMS_INTERRUPT_SHARED option was set + * in ``entry`` and the interrupt vector was already occupied by a unique + * handler. + * + * @retval ::RTEMS_TOO_MANY The handler routine of the entry specified by + * ``entry`` was already installed for the interrupt vector specified by + * ``vector`` with an argument equal to the handler argument of the entry. * * @par Notes - * The rtems_interrupt_get_attributes() directive may be used to check if an - * interrupt vector can be raised on a processor. + * When the directive call was successful, the ownership of the interrupt entry + * has been transferred from the caller to the interrupt service. An installed + * interrupt entry may be removed from the interrupt service by calling + * rtems_interrupt_entry_remove(). * * @par Constraints * @parblock * The following constraints apply to this directive: * - * * The directive may be called from within interrupt context. - * * * The directive may be called from within device driver initialization * context. * * * The directive may be called from within task context. * - * * The directive will not cause the calling task to be preempted. + * * The directive may obtain and release the object allocator mutex. This may + * cause the calling task to be preempted. + * + * * The interrupt entry shall have been initialized by + * rtems_interrupt_entry_initialize() or RTEMS_INTERRUPT_ENTRY_INITIALIZER(). * @endparblock */ -rtems_status_code rtems_interrupt_raise_on( - rtems_vector_number vector, - uint32_t cpu_index +rtems_status_code rtems_interrupt_entry_install( + rtems_vector_number vector, + rtems_option options, + rtems_interrupt_entry *entry ); -/* Generated from spec:/rtems/intr/if/clear */ +/* Generated from spec:/rtems/intr/if/entry-remove */ /** * @ingroup RTEMSAPIClassicIntr * - * @brief Clears the interrupt vector. + * @brief Removes the interrupt entry from the interrupt vector. * - * @param vector is the number of the interrupt vector to clear. + * @param vector is the interrupt vector number. + * + * @param entry is the interrupt entry to remove. * * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. * + * @retval ::RTEMS_INCORRECT_STATE The service was not initialized. + * + * @retval ::RTEMS_INVALID_ADDRESS The ``entry`` parameter was NULL. + * * @retval ::RTEMS_INVALID_ID There was no interrupt vector associated with the * number specified by ``vector``. * - * @retval ::RTEMS_UNSATISFIED The request to raise the interrupt vector has - * not been satisfied. + * @retval ::RTEMS_CALLED_FROM_ISR The directive was called from within + * interrupt context. + * + * @retval ::RTEMS_UNSATISFIED The entry specified by ``entry`` was not + * installed at the interrupt vector specified by ``vector``. * * @par Notes - * The rtems_interrupt_get_attributes() directive may be used to check if an + * When the directive call was successful, the ownership of the interrupt entry + * has been transferred from the interrupt service to the caller. + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within device driver initialization + * context. + * + * * The directive may be called from within task context. + * + * * The directive may obtain and release the object allocator mutex. This may + * cause the calling task to be preempted. + * + * * The interrupt entry shall have been installed by + * rtems_interrupt_entry_install(). + * @endparblock + */ +rtems_status_code rtems_interrupt_entry_remove( + rtems_vector_number vector, + rtems_interrupt_entry *entry +); + +/* Generated from spec:/rtems/intr/if/handler-install */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief Installs the interrupt handler routine and argument at the interrupt + * vector. + * + * @param vector is the interrupt vector number. + * + * @param info is the descriptive information of the interrupt handler to + * install. + * + * @param options is the interrupt handler install option set. + * + * @param routine is the interrupt handler routine to install. + * + * @param arg is the interrupt handler argument to install. + * + * One of the following mutually exclusive options + * + * * #RTEMS_INTERRUPT_UNIQUE, + * + * * #RTEMS_INTERRUPT_SHARED, and + * + * * #RTEMS_INTERRUPT_REPLACE + * + * shall be set in the ``options`` parameter. + * + * The handler routine will be called with the argument specified by ``arg`` + * when dispatched. The order in which shared interrupt handlers are + * dispatched for one vector is defined by the installation order. The first + * installed handler is dispatched first. + * + * If the option #RTEMS_INTERRUPT_UNIQUE is set, then it will be ensured that + * the handler will be the only one for the interrupt vector. + * + * If the option #RTEMS_INTERRUPT_SHARED is set, then multiple handler may be + * installed for the interrupt vector. + * + * If the option #RTEMS_INTERRUPT_REPLACE is set, then the handler specified by + * ``routine`` will replace the first handler with the same argument for the + * interrupt vector if it exists, otherwise an error status will be returned. + * A second handler with the same argument for the interrupt vector will remain + * unchanged. The new handler will inherit the unique or shared options from + * the replaced handler. + * + * An informative description may be provided in ``info``. It may be used for + * system debugging and diagnostic tools. The referenced string has to be + * persistent as long as the handler is installed. + * + * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. + * + * @retval ::RTEMS_INCORRECT_STATE The service was not initialized. + * + * @retval ::RTEMS_INVALID_ADDRESS The ``routine`` parameter was NULL. + * + * @retval ::RTEMS_INVALID_ID There was no interrupt vector associated with the + * number specified by ``vector``. + * + * @retval ::RTEMS_CALLED_FROM_ISR The directive was called from within + * interrupt context. + * + * @retval ::RTEMS_NO_MEMORY There was not enough memory available to allocate + * data structures to install the handler. + * + * @retval ::RTEMS_RESOURCE_IN_USE The #RTEMS_INTERRUPT_UNIQUE option was set + * in ``options`` and the interrupt vector was already occupied by a handler. + * + * @retval ::RTEMS_RESOURCE_IN_USE The #RTEMS_INTERRUPT_SHARED option was set + * in ``options`` and the interrupt vector was already occupied by a unique + * handler. + * + * @retval ::RTEMS_TOO_MANY The handler specified by ``routine`` was already + * installed for the interrupt vector specified by ``vector`` with an + * argument equal to the argument specified by ``arg``. + * + * @retval ::RTEMS_UNSATISFIED The #RTEMS_INTERRUPT_REPLACE option was set in + * ``options`` and no handler to replace was installed. + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within device driver initialization + * context. + * + * * The directive may be called from within task context. + * + * * The directive may obtain and release the object allocator mutex. This may + * cause the calling task to be preempted. + * @endparblock + */ +rtems_status_code rtems_interrupt_handler_install( + rtems_vector_number vector, + const char *info, + rtems_option options, + rtems_interrupt_handler routine, + void *arg +); + +/* Generated from spec:/rtems/intr/if/handler-remove */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief Removes the interrupt handler routine and argument from the interrupt + * vector. + * + * @param vector is the interrupt vector number. + * + * @param routine is the interrupt handler routine to remove. + * + * @param arg is the interrupt handler argument to remove. + * + * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. + * + * @retval ::RTEMS_INCORRECT_STATE The service was not initialized. + * + * @retval ::RTEMS_INVALID_ADDRESS The ``routine`` parameter was NULL. + * + * @retval ::RTEMS_INVALID_ID There was no interrupt vector associated with the + * number specified by ``vector``. + * + * @retval ::RTEMS_CALLED_FROM_ISR The directive was called from within + * interrupt context. + * + * @retval ::RTEMS_UNSATISFIED There was no handler routine and argument pair + * installed specified by ``routine`` and ``arg``. + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within device driver initialization + * context. + * + * * The directive may be called from within task context. + * + * * The directive may obtain and release the object allocator mutex. This may + * cause the calling task to be preempted. + * @endparblock + */ +rtems_status_code rtems_interrupt_handler_remove( + rtems_vector_number vector, + rtems_interrupt_handler routine, + void *arg +); + +/* Generated from spec:/rtems/intr/if/vector-is-enabled */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief Checks if the interrupt vector is enabled. + * + * @param vector is the interrupt vector number. + * + * @param[out] enabled is the pointer to a ``bool`` object. When the directive + * call is successful, the enabled status of the interrupt associated with + * the interrupt vector specified by ``vector`` will be stored in this + * object. When the interrupt was enabled for the processor executing the + * directive call at some time point during the call, the object value will + * be set to true, otherwise to false. + * + * The directive checks if the interrupt associated with the interrupt vector + * specified by ``vector`` was enabled for the processor executing the + * directive call at some time point during the call. + * + * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. + * + * @retval ::RTEMS_INVALID_ADDRESS The ``enabled`` parameter was NULL. + * + * @retval ::RTEMS_INVALID_ID There was no interrupt vector associated with the + * number specified by ``vector``. + * + * @par Notes + * Interrupt vectors may be enabled by rtems_interrupt_vector_enable() and + * disabled by rtems_interrupt_vector_disable(). + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within interrupt context. + * + * * The directive may be called from within device driver initialization + * context. + * + * * The directive may be called from within task context. + * + * * The directive will not cause the calling task to be preempted. + * @endparblock + */ +rtems_status_code rtems_interrupt_vector_is_enabled( + rtems_vector_number vector, + bool *enabled +); + +/* Generated from spec:/rtems/intr/if/vector-enable */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief Enables the interrupt vector. + * + * @param vector is the number of the interrupt vector to enable. + * + * The directive enables the interrupt vector specified by ``vector``. This + * allows that interrupt service requests are issued to the target processors + * of the interrupt vector. Interrupt service requests for an interrupt vector + * may be raised by rtems_interrupt_raise(), rtems_interrupt_raise_on(), + * external signals, or messages. + * + * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. + * + * @retval ::RTEMS_INVALID_ID There was no interrupt vector associated with the + * number specified by ``vector``. + * + * @retval ::RTEMS_UNSATISFIED The request to enable the interrupt vector has + * not been satisfied. + * + * @par Notes + * The rtems_interrupt_get_attributes() directive may be used to check if an + * interrupt vector can be enabled. Interrupt vectors may be disabled by + * rtems_interrupt_vector_disable(). + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within interrupt context. + * + * * The directive may be called from within device driver initialization + * context. + * + * * The directive may be called from within task context. + * + * * The directive will not cause the calling task to be preempted. + * @endparblock + */ +rtems_status_code rtems_interrupt_vector_enable( rtems_vector_number vector ); + +/* Generated from spec:/rtems/intr/if/vector-disable */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief Disables the interrupt vector. + * + * @param vector is the number of the interrupt vector to disable. + * + * The directive disables the interrupt vector specified by ``vector``. This + * prevents that an interrupt service request is issued to the target + * processors of the interrupt vector. + * + * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. + * + * @retval ::RTEMS_INVALID_ID There was no interrupt vector associated with the + * number specified by ``vector``. + * + * @retval ::RTEMS_UNSATISFIED The request to disable the interrupt vector has + * not been satisfied. + * + * @par Notes + * The rtems_interrupt_get_attributes() directive may be used to check if an + * interrupt vector can be disabled. Interrupt vectors may be enabled by + * rtems_interrupt_vector_enable(). There may be targets on which some + * interrupt vectors cannot be disabled, for example a hardware watchdog + * interrupt or software generated interrupts. + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within interrupt context. + * + * * The directive may be called from within device driver initialization + * context. + * + * * The directive may be called from within task context. + * + * * The directive will not cause the calling task to be preempted. + * @endparblock + */ +rtems_status_code rtems_interrupt_vector_disable( rtems_vector_number vector ); + +/* Generated from spec:/rtems/intr/if/is-pending */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief Checks if the interrupt is pending. + * + * @param vector is the interrupt vector number. + * + * @param[out] pending is the pointer to a ``bool`` object. When the directive + * call is successful, the pending status of the interrupt associated with + * the interrupt vector specified by ``vector`` will be stored in this + * object. When the interrupt was pending for the processor executing the + * directive call at some time point during the call, the object value will + * be set to true, otherwise to false. + * + * The directive checks if the interrupt associated with the interrupt vector + * specified by ``vector`` was pending for the processor executing the + * directive call at some time point during the call. + * + * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. + * + * @retval ::RTEMS_INVALID_ADDRESS The ``pending`` parameter was NULL. + * + * @retval ::RTEMS_INVALID_ID There was no interrupt vector associated with the + * number specified by ``vector``. + * + * @retval ::RTEMS_UNSATISFIED The request to get the pending status has not + * been satisfied. + * + * @par Notes + * Interrupts may be made pending by calling the rtems_interrupt_raise() or + * rtems_interrupt_raise_on() directives or due to external signals or + * messages. The pending state may be cleared by rtems_interrupt_clear(). + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within interrupt context. + * + * * The directive may be called from within device driver initialization + * context. + * + * * The directive may be called from within task context. + * + * * The directive will not cause the calling task to be preempted. + * @endparblock + */ +rtems_status_code rtems_interrupt_is_pending( + rtems_vector_number vector, + bool *pending +); + +/* Generated from spec:/rtems/intr/if/raise */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief Raises the interrupt vector. + * + * @param vector is the number of the interrupt vector to raise. + * + * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. + * + * @retval ::RTEMS_INVALID_ID There was no interrupt vector associated with the + * number specified by ``vector``. + * + * @retval ::RTEMS_UNSATISFIED The request to raise the interrupt vector has + * not been satisfied. + * + * @par Notes + * The rtems_interrupt_get_attributes() directive may be used to check if an + * interrupt vector can be raised. + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within interrupt context. + * + * * The directive may be called from within device driver initialization + * context. + * + * * The directive may be called from within task context. + * + * * The directive will not cause the calling task to be preempted. + * @endparblock + */ +rtems_status_code rtems_interrupt_raise( rtems_vector_number vector ); + +/* Generated from spec:/rtems/intr/if/raise-on */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief Raises the interrupt vector on the processor. + * + * @param vector is the number of the interrupt vector to raise. + * + * @param cpu_index is the index of the target processor of the interrupt + * vector to raise. + * + * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. + * + * @retval ::RTEMS_INVALID_ID There was no interrupt vector associated with the + * number specified by ``vector``. + * + * @retval ::RTEMS_NOT_CONFIGURED The processor specified by ``cpu_index`` was + * not configured to be used by the application. + * + * @retval ::RTEMS_INCORRECT_STATE The processor specified by ``cpu_index`` was + * configured to be used by the application, however, it was not online. + * + * @retval ::RTEMS_UNSATISFIED The request to raise the interrupt vector has + * not been satisfied. + * + * @par Notes + * The rtems_interrupt_get_attributes() directive may be used to check if an + * interrupt vector can be raised on a processor. + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within interrupt context. + * + * * The directive may be called from within device driver initialization + * context. + * + * * The directive may be called from within task context. + * + * * The directive will not cause the calling task to be preempted. + * @endparblock + */ +rtems_status_code rtems_interrupt_raise_on( + rtems_vector_number vector, + uint32_t cpu_index +); + +/* Generated from spec:/rtems/intr/if/clear */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief Clears the interrupt vector. + * + * @param vector is the number of the interrupt vector to clear. + * + * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. + * + * @retval ::RTEMS_INVALID_ID There was no interrupt vector associated with the + * number specified by ``vector``. + * + * @retval ::RTEMS_UNSATISFIED The request to raise the interrupt vector has + * not been satisfied. + * + * @par Notes + * The rtems_interrupt_get_attributes() directive may be used to check if an * interrupt vector can be cleared. * * @par Constraints @@ -995,7 +1844,1409 @@ rtems_status_code rtems_interrupt_raise_on( * * The directive will not cause the calling task to be preempted. * @endparblock */ -rtems_status_code rtems_interrupt_clear( rtems_vector_number vector ); +rtems_status_code rtems_interrupt_clear( rtems_vector_number vector ); + +/* Generated from spec:/rtems/intr/if/get-affinity */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief Gets the processor affinity set of the interrupt vector. + * + * @param vector is the interrupt vector number. + * + * @param affinity_size is the size of the processor set referenced by + * ``affinity`` in bytes. + * + * @param[out] affinity is the pointer to a cpu_set_t object. When the + * directive call is successful, the processor affinity set of the interrupt + * vector will be stored in this object. A set bit in the processor set + * means that the corresponding processor is in the processor affinity set of + * the interrupt vector, otherwise the bit is cleared. + * + * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. + * + * @retval ::RTEMS_INVALID_ADDRESS The ``affinity`` parameter was NULL. + * + * @retval ::RTEMS_INVALID_ID There was no interrupt vector associated with the + * number specified by ``vector``. + * + * @retval ::RTEMS_INVALID_SIZE The size specified by ``affinity_size`` of the + * processor set was too small for the processor affinity set of the + * interrupt vector. + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within interrupt context. + * + * * The directive may be called from within device driver initialization + * context. + * + * * The directive may be called from within task context. + * + * * The directive will not cause the calling task to be preempted. + * @endparblock + */ +rtems_status_code rtems_interrupt_get_affinity( + rtems_vector_number vector, + size_t affinity_size, + cpu_set_t *affinity +); + +/* Generated from spec:/rtems/intr/if/set-affinity */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief Sets the processor affinity set of the interrupt vector. + * + * @param vector is the interrupt vector number. + * + * @param affinity_size is the size of the processor set referenced by + * ``affinity`` in bytes. + * + * @param affinity is the pointer to a cpu_set_t object. The processor set + * defines the new processor affinity set of the interrupt vector. A set bit + * in the processor set means that the corresponding processor shall be in + * the processor affinity set of the interrupt vector, otherwise the bit + * shall be cleared. + * + * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. + * + * @retval ::RTEMS_INVALID_ADDRESS The ``affinity`` parameter was NULL. + * + * @retval ::RTEMS_INVALID_ID There was no interrupt vector associated with the + * number specified by ``vector``. + * + * @retval ::RTEMS_INVALID_NUMBER The referenced processor set was not a valid + * new processor affinity set for the interrupt vector. + * + * @retval ::RTEMS_UNSATISFIED The request to set the processor affinity of the + * interrupt vector has not been satisfied. + * + * @par Notes + * The rtems_interrupt_get_attributes() directive may be used to check if the + * processor affinity of an interrupt vector can be set. + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within interrupt context. + * + * * The directive may be called from within device driver initialization + * context. + * + * * The directive may be called from within task context. + * + * * The directive will not cause the calling task to be preempted. + * @endparblock + */ +rtems_status_code rtems_interrupt_set_affinity( + rtems_vector_number vector, + size_t affinity_size, + const cpu_set_t *affinity +); + +/* Generated from spec:/rtems/intr/if/get-attributes */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief Gets the attributes of the interrupt vector. + * + * @param vector is the interrupt vector number. + * + * @param[out] attributes is the pointer to an rtems_interrupt_attributes + * object. When the directive call is successful, the attributes of the + * interrupt vector will be stored in this object. + * + * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. + * + * @retval ::RTEMS_INVALID_ADDRESS The ``attributes`` parameter was NULL. + * + * @retval ::RTEMS_INVALID_ID There was no interrupt vector associated with the + * number specified by ``vector``. + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within interrupt context. + * + * * The directive may be called from within device driver initialization + * context. + * + * * The directive may be called from within task context. + * + * * The directive will not cause the calling task to be preempted. + * @endparblock + */ +rtems_status_code rtems_interrupt_get_attributes( + rtems_vector_number vector, + rtems_interrupt_attributes *attributes +); + +/* Generated from spec:/rtems/intr/if/handler-iterate */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief Iterates over all interrupt handler installed at the interrupt + * vector. + * + * @param vector is the interrupt vector number. + * + * @param routine is the visitor routine. + * + * @param arg is the visitor argument. + * + * For each installed handler at the interrupt vector the visitor function + * specified by ``routine`` will be called with the argument specified by + * ``arg`` and the handler information, options, routine and argument. + * + * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. + * + * @retval ::RTEMS_INCORRECT_STATE The service was not initialized. + * + * @retval ::RTEMS_INVALID_ADDRESS The ``routine`` parameter was NULL. + * + * @retval ::RTEMS_INVALID_ID There was no interrupt vector associated with the + * number specified by ``vector``. + * + * @retval ::RTEMS_CALLED_FROM_ISR The directive was called from within + * interrupt context. + * + * @par Notes + * @parblock + * The directive is intended for system information and diagnostics. + * + * Never install or remove an interrupt handler within the visitor function. + * This may result in a deadlock. + * @endparblock + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within device driver initialization + * context. + * + * * The directive may be called from within task context. + * + * * The directive may obtain and release the object allocator mutex. This may + * cause the calling task to be preempted. + * @endparblock + */ +rtems_status_code rtems_interrupt_handler_iterate( + rtems_vector_number vector, + rtems_interrupt_per_handler_routine routine, + void *arg +); + +/* Generated from spec:/rtems/intr/if/server-default */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief The constant represents the index of the default interrupt server. + */ +#define RTEMS_INTERRUPT_SERVER_DEFAULT 0 + +/* Generated from spec:/rtems/intr/if/server-control */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief This structure represents an interrupt server. + * + * @par Notes + * This structure shall be treated as an opaque data type from the API point of + * view. Members shall not be accessed directly. The structure is initialized + * by rtems_interrupt_server_create() and maintained by the interrupt server + * support. + */ +typedef struct rtems_interrupt_server_control { + #if defined(RTEMS_SMP) + /** + * @brief This member is the ISR lock protecting the server control state. + */ + rtems_interrupt_lock lock; + #endif + + /** + * @brief This member is the chain of pending interrupt entries. + */ + Chain_Control entries; + + /** + * @brief This member is the identifier of the server task. + */ + rtems_id server; + + /** + * @brief This member is the error count. + */ + unsigned long errors; + + /** + * @brief This member is the server index. + */ + uint32_t index; + + /** + * @brief This member is the node for the interrupt server registry. + */ + Chain_Node node; + + /** + * @brief This member is the optional handler to destroy the interrupt server + * control. + */ + void ( *destroy )( struct rtems_interrupt_server_control * ); +} rtems_interrupt_server_control; + +/* Generated from spec:/rtems/intr/if/server-config */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief This structure defines an interrupt server configuration. + * + * @par Notes + * See also rtems_interrupt_server_create(). + */ +typedef struct { + /** + * @brief This member is the task name of the interrupt server. + */ + rtems_name name; + + /** + * @brief This member is the initial task priority of the interrupt server. + */ + rtems_task_priority priority; + + /** + * @brief This member is the task storage area of the interrupt server. + * + * It shall be NULL for interrupt servers created by + * rtems_interrupt_server_create(). + */ + void *storage_area; + + /** + * @brief This member is the task storage size of the interrupt server. + * + * For interrupt servers created by rtems_interrupt_server_create() this is the + * task stack size. + */ + size_t storage_size; + + /** + * @brief This member is the initial mode set of the interrupt server. + */ + rtems_mode modes; + + /** + * @brief This member is the attribute set of the interrupt server. + */ + rtems_attribute attributes; + + /** + * @brief This member is an optional handler to destroy the interrupt server + * control handed over to rtems_interrupt_server_create(). + * + * The destroy handler is optional and may be NULL. If the destroy handler is + * present, it is called from within the context of the interrupt server to be + * deleted, see also rtems_interrupt_server_delete(). + */ + void ( *destroy )( rtems_interrupt_server_control * ); +} rtems_interrupt_server_config; + +/* Generated from spec:/rtems/intr/if/server-initialize */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief Initializes the interrupt server tasks. + * + * @param priority is the initial task priority of the created interrupt + * servers. + * + * @param stack_size is the task stack size of the created interrupt servers. + * + * @param modes is the initial mode set of the created interrupt servers. + * + * @param attributes is the attribute set of the created interrupt servers. + * + * @param[out] server_count is the pointer to an uint32_t object or NULL. When + * the pointer is not equal to NULL, the count of successfully created + * interrupt servers is stored in this object regardless of the return + * status. + * + * The directive tries to create an interrupt server task for each online + * processor in the system. The tasks will have the initial priority specified + * by ``priority``, the stack size specified by ``stack_size``, the initial + * mode set specified by ``modes``, and the attribute set specified by + * ``attributes``. The count of successfully created server tasks will be + * returned in ``server_count`` if the pointer is not equal to NULL. + * + * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. + * + * @retval ::RTEMS_INCORRECT_STATE The interrupt servers were already + * initialized. + * + * @return The directive uses rtems_task_create(). If this directive fails, + * then its error status will be returned. + * + * @par Notes + * @parblock + * Interrupt handlers may be installed on an interrupt server with + * rtems_interrupt_server_handler_install() and removed with + * rtems_interrupt_server_handler_remove() using a server index. In case of an + * interrupt, the request will be forwarded to the interrupt server. The + * handlers are executed within the interrupt server context. If one handler + * blocks on something this may delay the processing of other handlers. + * + * Interrupt servers may be deleted by rtems_interrupt_server_delete(). + * @endparblock + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within device driver initialization + * context. + * + * * The directive may be called from within task context. + * + * * The directive may obtain and release the object allocator mutex. This may + * cause the calling task to be preempted. + * @endparblock + */ +rtems_status_code rtems_interrupt_server_initialize( + rtems_task_priority priority, + size_t stack_size, + rtems_mode modes, + rtems_attribute attributes, + uint32_t *server_count +); + +/* Generated from spec:/rtems/intr/if/server-create */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief Creates an interrupt server. + * + * @param[out] control is the pointer to an rtems_interrupt_server_control + * object. When the directive call was successful, the ownership of the + * object was transferred from the caller of the directive to the interrupt + * server management. + * + * @param config is the interrupt server configuration. + * + * @param[out] server_index is the pointer to an uint32_t object. When the + * directive call was successful, the index of the created interrupt server + * will be stored in this object. + * + * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. + * + * @return The directive uses rtems_task_create(). If this directive fails, + * then its error status will be returned. + * + * @par Notes + * See also rtems_interrupt_server_initialize() and + * rtems_interrupt_server_delete(). + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within device driver initialization + * context. + * + * * The directive may be called from within task context. + * + * * The directive may obtain and release the object allocator mutex. This may + * cause the calling task to be preempted. + * @endparblock + */ +rtems_status_code rtems_interrupt_server_create( + rtems_interrupt_server_control *control, + const rtems_interrupt_server_config *config, + uint32_t *server_index +); + +/* Generated from spec:/rtems/intr/if/server-handler-install */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief Installs the interrupt handler routine and argument at the interrupt + * vector on the interrupt server. + * + * @param server_index is the interrupt server index. The constant + * #RTEMS_INTERRUPT_SERVER_DEFAULT may be used to specify the default + * interrupt server. + * + * @param vector is the interrupt vector number. + * + * @param info is the descriptive information of the interrupt handler to + * install. + * + * @param options is the interrupt handler install option set. + * + * @param routine is the interrupt handler routine to install. + * + * @param arg is the interrupt handler argument to install. + * + * The handler routine specified by ``routine`` will be executed within the + * context of the interrupt server task specified by ``server_index``. + * + * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. + * + * @retval ::RTEMS_INVALID_ID There was no interrupt server associated with the + * index specified by ``server_index``. + * + * @retval ::RTEMS_CALLED_FROM_ISR The directive was called from within + * interrupt context. + * + * @retval ::RTEMS_INVALID_ADDRESS The ``routine`` parameter was NULL. + * + * @retval ::RTEMS_INVALID_ID There was no interrupt vector associated with the + * number specified by ``vector``. + * + * @retval ::RTEMS_INVALID_NUMBER An option specified by ``info`` was not + * applicable. + * + * @retval ::RTEMS_RESOURCE_IN_USE The #RTEMS_INTERRUPT_UNIQUE option was set + * in ``info`` and the interrupt vector was already occupied by a handler. + * + * @retval ::RTEMS_RESOURCE_IN_USE The #RTEMS_INTERRUPT_SHARED option was set + * in ``info`` and the interrupt vector was already occupied by a unique + * handler. + * + * @retval ::RTEMS_TOO_MANY The handler specified by ``routine`` was already + * installed for the interrupt vector specified by ``vector`` with an + * argument equal to the argument specified by ``arg``. + * + * @retval ::RTEMS_UNSATISFIED The #RTEMS_INTERRUPT_REPLACE option was set in + * ``info`` and no handler to replace was installed. + * + * @par Notes + * See also rtems_interrupt_handler_install(). + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within device driver initialization + * context. + * + * * The directive may be called from within task context. + * + * * The directive may obtain and release the object allocator mutex. This may + * cause the calling task to be preempted. + * @endparblock + */ +rtems_status_code rtems_interrupt_server_handler_install( + uint32_t server_index, + rtems_vector_number vector, + const char *info, + rtems_option options, + rtems_interrupt_handler routine, + void *arg +); + +/* Generated from spec:/rtems/intr/if/server-handler-remove */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief Removes the interrupt handler routine and argument from the interrupt + * vector and the interrupt server. + * + * @param server_index is the interrupt server index. The constant + * #RTEMS_INTERRUPT_SERVER_DEFAULT may be used to specify the default + * interrupt server. + * + * @param vector is the interrupt vector number. + * + * @param routine is the interrupt handler routine to remove. + * + * @param arg is the interrupt handler argument to remove. + * + * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. + * + * @retval ::RTEMS_INVALID_ID There was no interrupt server associated with the + * index specified by ``server_index``. + * + * @retval ::RTEMS_INVALID_ID There was no interrupt vector associated with the + * number specified by ``vector``. + * + * @retval ::RTEMS_UNSATISFIED There was no handler routine and argument pair + * installed specified by ``routine`` and ``arg``. + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within task context. + * + * * The directive may obtain and release the object allocator mutex. This may + * cause the calling task to be preempted. + * + * * The directive sends a request to another task and waits for a response. + * This may cause the calling task to be blocked and unblocked. + * + * * The directive shall not be called from within the context of an interrupt + * server. Calling the directive from within the context of an interrupt + * server is undefined behaviour. + * @endparblock + */ +rtems_status_code rtems_interrupt_server_handler_remove( + uint32_t server_index, + rtems_vector_number vector, + rtems_interrupt_handler routine, + void *arg +); + +/* Generated from spec:/rtems/intr/if/server-set-affinity */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief Sets the processor affinity of the interrupt server. + * + * @param server_index is the interrupt server index. The constant + * #RTEMS_INTERRUPT_SERVER_DEFAULT may be used to specify the default + * interrupt server. + * + * @param affinity_size is the size of the processor set referenced by + * ``affinity`` in bytes. + * + * @param affinity is the pointer to a cpu_set_t object. The processor set + * defines the new processor affinity set of the interrupt server. A set bit + * in the processor set means that the corresponding processor shall be in + * the processor affinity set of the task, otherwise the bit shall be + * cleared. + * + * @param priority is the new real priority for the interrupt server. + * + * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. + * + * @retval ::RTEMS_INVALID_ID There was no interrupt server associated with the + * index specified by ``server_index``. + * + * @return The directive uses rtems_scheduler_ident_by_processor_set(), + * rtems_task_set_scheduler(), and rtems_task_set_affinity(). If one of + * these directive fails, then its error status will be returned. + * + * @par Notes + * @parblock + * The scheduler is set determined by the highest numbered processor in the + * affinity set specified by ``affinity``. + * + * This operation is only reliable in case the interrupt server was suspended + * via rtems_interrupt_server_suspend(). + * @endparblock + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within interrupt context. + * + * * The directive may be called from within device driver initialization + * context. + * + * * The directive may be called from within task context. + * + * * The directive may change the processor affinity of a task. This may cause + * the calling task to be preempted. + * + * * The directive may change the priority of a task. This may cause the + * calling task to be preempted. + * @endparblock + */ +rtems_status_code rtems_interrupt_server_set_affinity( + uint32_t server_index, + size_t affinity_size, + const cpu_set_t *affinity, + rtems_task_priority priority +); + +/* Generated from spec:/rtems/intr/if/server-delete */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief Deletes the interrupt server. + * + * @param server_index is the index of the interrupt server to delete. + * + * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. + * + * @retval ::RTEMS_INVALID_ID There was no interrupt server associated with the + * server index specified by ``server_index``. + * + * @par Notes + * @parblock + * The interrupt server deletes itself, so after the return of the directive + * the interrupt server may be still in the termination process depending on + * the task priorities of the system. + * + * See also rtems_interrupt_server_create(). + * @endparblock + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within task context. + * + * * The directive shall not be called from within the context of an interrupt + * server. Calling the directive from within the context of an interrupt + * server is undefined behaviour. + * + * * The directive sends a request to another task and waits for a response. + * This may cause the calling task to be blocked and unblocked. + * @endparblock + */ +rtems_status_code rtems_interrupt_server_delete( uint32_t server_index ); + +/* Generated from spec:/rtems/intr/if/server-suspend */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief Suspends the interrupt server. + * + * @param server_index is the index of the interrupt server to suspend. The + * constant #RTEMS_INTERRUPT_SERVER_DEFAULT may be used to specify the + * default interrupt server. + * + * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. + * + * @retval ::RTEMS_INVALID_ID There was no interrupt server associated with the + * index specified by ``server_index``. + * + * @par Notes + * Interrupt server may be resumed by rtems_interrupt_server_resume(). + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within task context. + * + * * The directive shall not be called from within the context of an interrupt + * server. Calling the directive from within the context of an interrupt + * server is undefined behaviour. + * + * * The directive sends a request to another task and waits for a response. + * This may cause the calling task to be blocked and unblocked. + * @endparblock + */ +rtems_status_code rtems_interrupt_server_suspend( uint32_t server_index ); + +/* Generated from spec:/rtems/intr/if/server-resume */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief Resumes the interrupt server. + * + * @param server_index is the index of the interrupt server to resume. The + * constant #RTEMS_INTERRUPT_SERVER_DEFAULT may be used to specify the + * default interrupt server. + * + * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. + * + * @retval ::RTEMS_INVALID_ID There was no interrupt server associated with the + * index specified by ``server_index``. + * + * @par Notes + * Interrupt server may be suspended by rtems_interrupt_server_suspend(). + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within task context. + * + * * The directive shall not be called from within the context of an interrupt + * server. Calling the directive from within the context of an interrupt + * server is undefined behaviour. + * + * * The directive sends a request to another task and waits for a response. + * This may cause the calling task to be blocked and unblocked. + * @endparblock + */ +rtems_status_code rtems_interrupt_server_resume( uint32_t server_index ); + +/* Generated from spec:/rtems/intr/if/server-move */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief Moves the interrupt handlers installed at the interrupt vector and + * the source interrupt server to the destination interrupt server. + * + * @param source_server_index is the index of the source interrupt server. The + * constant #RTEMS_INTERRUPT_SERVER_DEFAULT may be used to specify the + * default interrupt server. + * + * @param vector is the interrupt vector number. + * + * @param destination_server_index is the index of the destination interrupt + * server. The constant #RTEMS_INTERRUPT_SERVER_DEFAULT may be used to + * specify the default interrupt server. + * + * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. + * + * @retval ::RTEMS_INVALID_ID There was no interrupt server associated with the + * index specified by ``source_server_index``. + * + * @retval ::RTEMS_INVALID_ID There was no interrupt server associated with the + * index specified by ``destination_server_index``. + * + * @retval ::RTEMS_INVALID_ID There was no interrupt vector associated with the + * number specified by ``vector``. + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within task context. + * + * * The directive shall not be called from within the context of an interrupt + * server. Calling the directive from within the context of an interrupt + * server is undefined behaviour. + * + * * The directive sends a request to another task and waits for a response. + * This may cause the calling task to be blocked and unblocked. + * @endparblock + */ +rtems_status_code rtems_interrupt_server_move( + uint32_t source_server_index, + rtems_vector_number vector, + uint32_t destination_server_index +); + +/* Generated from spec:/rtems/intr/if/server-handler-iterate */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief Iterates over all interrupt handler installed at the interrupt vector + * and interrupt server. + * + * @param server_index is the index of the interrupt server. + * + * @param vector is the interrupt vector number. + * + * @param routine is the visitor routine. + * + * @param arg is the visitor argument. + * + * For each installed handler at the interrupt vector and interrupt server the + * visitor function specified by ``vector`` will be called with the argument + * specified by ``routine`` and the handler information, options, routine and + * argument. + * + * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. + * + * @retval ::RTEMS_INVALID_ID There was no interrupt server associated with the + * index specified by ``server_index``. + * + * @retval ::RTEMS_INVALID_ID There was no interrupt vector associated with the + * number specified by ``vector``. + * + * @par Notes + * @parblock + * The directive is intended for system information and diagnostics. + * + * Never install or remove an interrupt handler within the visitor function. + * This may result in a deadlock. + * @endparblock + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within device driver initialization + * context. + * + * * The directive may be called from within task context. + * + * * The directive may obtain and release the object allocator mutex. This may + * cause the calling task to be preempted. + * @endparblock + */ +rtems_status_code rtems_interrupt_server_handler_iterate( + uint32_t server_index, + rtems_vector_number vector, + rtems_interrupt_per_handler_routine routine, + void *arg +); + +/* Generated from spec:/rtems/intr/if/server-action */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief This structure represents an interrupt server action. + * + * @par Notes + * This structure shall be treated as an opaque data type from the API point of + * view. Members shall not be accessed directly. + */ +typedef struct rtems_interrupt_server_action { + /** + * @brief This member is the reference to the next action or NULL. + */ + struct rtems_interrupt_server_action *next; + + /** + * @brief This member is the interrupt handler. + */ + rtems_interrupt_handler handler; + + /** + * @brief This member is the interrupt handler argument. + */ + void *arg; +} rtems_interrupt_server_action; + +/* Generated from spec:/rtems/intr/if/server-entry */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief This structure represents an interrupt server entry. + * + * @par Notes + * This structure shall be treated as an opaque data type from the API point of + * view. Members shall not be accessed directly. An entry is initialized by + * rtems_interrupt_server_entry_initialize() and destroyed by + * rtems_interrupt_server_entry_destroy(). Interrupt server actions can be + * prepended to the entry by rtems_interrupt_server_action_prepend(). The + * entry is submitted to be serviced by rtems_interrupt_server_entry_submit(). + */ +typedef struct { + /** + * @brief This member is the node for the interrupt entry processing. + */ + Chain_Node node; + + /** + * @brief This member references the interrupt server used to process the + * entry. + */ + rtems_interrupt_server_control *server; + + /** + * @brief This member is the interrupt vector number. + */ + rtems_vector_number vector; + + /** + * @brief This member is the interrupt server actions list head. + */ + rtems_interrupt_server_action *actions; +} rtems_interrupt_server_entry; + +/* Generated from spec:/rtems/intr/if/server-entry-initialize */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief Initializes the interrupt server entry. + * + * @param server_index is the interrupt server index. The constant + * #RTEMS_INTERRUPT_SERVER_DEFAULT may be used to specify the default + * interrupt server. + * + * @param entry is the interrupt server entry to initialize. + * + * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. + * + * @retval ::RTEMS_INVALID_ID There was no interrupt server associated with the + * index specified by ``server_index``. + * + * @par Notes + * After initialization, the list of actions of the interrupt server entry is + * empty. Actions may be prepended by rtems_interrupt_server_action_prepend(). + * Interrupt server entries may be moved to another interrupt vector with + * rtems_interrupt_server_entry_move(). Server entries may be submitted to get + * serviced by the interrupt server with rtems_interrupt_server_entry_submit(). + * Server entries may be destroyed by rtems_interrupt_server_entry_destroy(). + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within device driver initialization + * context. + * + * * The directive may be called from within task context. + * + * * The directive may obtain and release the object allocator mutex. This may + * cause the calling task to be preempted. + * @endparblock + */ +rtems_status_code rtems_interrupt_server_entry_initialize( + uint32_t server_index, + rtems_interrupt_server_entry *entry +); + +/* Generated from spec:/rtems/intr/if/server-action-prepend */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief Prepends the interrupt server action to the list of actions of the + * interrupt server entry. + * + * @param[in,out] entry is the interrupt server entry to prepend the interrupt + * server action. It shall have been initialized via + * rtems_interrupt_server_entry_initialize(). + * + * @param[out] action is the interrupt server action to initialize and prepend + * to the list of actions of the entry. + * + * @param routine is the interrupt handler routine to set in the action. + * + * @param arg is the interrupt handler argument to set in the action. + * + * @par Notes + * No error checking is performed by the directive. + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within interrupt context. + * + * * The directive may be called from within device driver initialization + * context. + * + * * The directive may be called from within task context. + * + * * The directive will not cause the calling task to be preempted. + * + * * The interrupt server entry shall have been initialized by + * rtems_interrupt_server_entry_initialize() and further optional calls to + * rtems_interrupt_server_action_prepend(). + * + * * The directive shall not be called concurrently with + * rtems_interrupt_server_action_prepend() with the same interrupt server + * entry. Calling the directive under this condition is undefined behaviour. + * + * * The directive shall not be called concurrently with + * rtems_interrupt_server_entry_move() with the same interrupt server entry. + * Calling the directive under this condition is undefined behaviour. + * + * * The directive shall not be called concurrently with + * rtems_interrupt_server_entry_submit() with the same interrupt server + * entry. Calling the directive under this condition is undefined behaviour. + * + * * The directive shall not be called while the interrupt server entry is + * pending on or serviced by its current interrupt server. Calling the + * directive under these conditions is undefined behaviour. + * @endparblock + */ +void rtems_interrupt_server_action_prepend( + rtems_interrupt_server_entry *entry, + rtems_interrupt_server_action *action, + rtems_interrupt_handler routine, + void *arg +); + +/* Generated from spec:/rtems/intr/if/server-entry-destroy */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief Destroys the interrupt server entry. + * + * @param[in,out] entry is the interrupt server entry to destroy. + * + * @par Notes + * No error checking is performed by the directive. + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within task context. + * + * * The directive shall not be called from within the context of an interrupt + * server. Calling the directive from within the context of an interrupt + * server is undefined behaviour. + * + * * The directive sends a request to another task and waits for a response. + * This may cause the calling task to be blocked and unblocked. + * + * * The interrupt server entry shall have been initialized by + * rtems_interrupt_server_entry_initialize() and further optional calls to + * rtems_interrupt_server_action_prepend(). + * @endparblock + */ +void rtems_interrupt_server_entry_destroy( + rtems_interrupt_server_entry *entry +); + +/* Generated from spec:/rtems/intr/if/server-entry-submit */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief Submits the interrupt server entry to be serviced by the interrupt + * server. + * + * @param entry is the interrupt server entry to submit. + * + * The directive appends the entry to the pending entries of the interrupt + * server. The interrupt server is notified that a new entry is pending. Once + * the interrupt server is scheduled it services the actions of all pending + * entries. + * + * @par Notes + * @parblock + * This directive may be used to do a two-step interrupt processing. The first + * step is done from within interrupt context by a call to this directive. The + * second step is then done from within the context of the interrupt server. + * + * No error checking is performed by the directive. + * + * A submitted entry may be destroyed by + * rtems_interrupt_server_entry_destroy(). + * @endparblock + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within interrupt context. + * + * * The directive may be called from within device driver initialization + * context. + * + * * The directive may be called from within task context. + * + * * The directive may unblock a task. This may cause the calling task to be + * preempted. + * + * * The interrupt server entry shall have been initialized by + * rtems_interrupt_server_entry_initialize() and further optional calls to + * rtems_interrupt_server_action_prepend(). + * + * * The directive shall not be called concurrently with + * rtems_interrupt_server_action_prepend() with the same interrupt server + * entry. Calling the directive under this condition is undefined behaviour. + * + * * The directive shall not be called concurrently with + * rtems_interrupt_server_entry_move() with the same interrupt server entry. + * Calling the directive under this condition is undefined behaviour. + * @endparblock + */ +void rtems_interrupt_server_entry_submit( + rtems_interrupt_server_entry *entry +); + +/* Generated from spec:/rtems/intr/if/server-entry-move */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief Moves the interrupt server entry to the interrupt server. + * + * @param entry is the interrupt server entry to move. + * + * @param server_index is the index of the destination interrupt server. The + * constant #RTEMS_INTERRUPT_SERVER_DEFAULT may be used to specify the + * default interrupt server. + * + * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. + * + * @retval ::RTEMS_INVALID_ID There was no interrupt server associated with the + * index specified by ``server_index``. + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within device driver initialization + * context. + * + * * The directive may be called from within task context. + * + * * The directive may obtain and release the object allocator mutex. This may + * cause the calling task to be preempted. + * + * * The interrupt server entry shall have been initialized by + * rtems_interrupt_server_entry_initialize() and further optional calls to + * rtems_interrupt_server_action_prepend(). + * + * * The directive shall not be called concurrently with + * rtems_interrupt_server_action_prepend() with the same interrupt server + * entry. Calling the directive under this condition is undefined behaviour. + * + * * The directive shall not be called concurrently with + * rtems_interrupt_server_entry_move() with the same interrupt server entry. + * Calling the directive under this condition is undefined behaviour. + * + * * The directive shall not be called concurrently with + * rtems_interrupt_server_entry_submit() with the same interrupt server + * entry. Calling the directive under this condition is undefined behaviour. + * + * * The directive shall not be called while the interrupt server entry is + * pending on or serviced by its current interrupt server. Calling the + * directive under these conditions is undefined behaviour. + * @endparblock + */ +rtems_status_code rtems_interrupt_server_entry_move( + rtems_interrupt_server_entry *entry, + uint32_t server_index +); + +/* Generated from spec:/rtems/intr/if/server-request */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief This structure represents an interrupt server request. + * + * @par Notes + * This structure shall be treated as an opaque data type from the API point of + * view. Members shall not be accessed directly. A request is initialized by + * rtems_interrupt_server_request_initialize() and destroyed by + * rtems_interrupt_server_request_destroy(). The interrupt vector of the + * request can be set by rtems_interrupt_server_request_set_vector(). The + * request is submitted to be serviced by + * rtems_interrupt_server_request_submit(). + */ +typedef struct { + /** + * @brief This member is the interrupt server entry. + */ + rtems_interrupt_server_entry entry; + + /** + * @brief This member is the interrupt server action. + */ + rtems_interrupt_server_action action; +} rtems_interrupt_server_request; + +/* Generated from spec:/rtems/intr/if/server-request-initialize */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief Initializes the interrupt server request. + * + * @param server_index is the interrupt server index. The constant + * #RTEMS_INTERRUPT_SERVER_DEFAULT may be used to specify the default + * interrupt server. + * + * @param[out] request is the interrupt server request to initialize. + * + * @param routine is the interrupt handler routine for the request action. + * + * @param arg is the interrupt handler argument for the request action. + * + * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. + * + * @retval ::RTEMS_INVALID_ID There was no interrupt server associated with the + * index specified by ``server_index``. + * + * @par Notes + * An interrupt server requests consists of an interrupt server entry and + * exactly one interrupt server action. The interrupt vector of the request + * may be changed with rtems_interrupt_server_request_set_vector(). Interrupt + * server requests may be submitted to get serviced by the interrupt server + * with rtems_interrupt_server_request_submit(). Requests may be destroyed by + * rtems_interrupt_server_request_destroy(). + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within device driver initialization + * context. + * + * * The directive may be called from within task context. + * + * * The directive may obtain and release the object allocator mutex. This may + * cause the calling task to be preempted. + * @endparblock + */ +rtems_status_code rtems_interrupt_server_request_initialize( + uint32_t server_index, + rtems_interrupt_server_request *request, + rtems_interrupt_handler routine, + void *arg +); + +/* Generated from spec:/rtems/intr/if/server-request-set-vector */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief Sets the interrupt vector in the interrupt server request. + * + * @param[in,out] request is the interrupt server request to change. + * + * @param vector is the interrupt vector number to be used by the request. + * + * @par Notes + * @parblock + * By default, the interrupt vector of an interrupt server request is set to a + * special value which is outside the range of vectors supported by the + * interrupt controller hardware. + * + * Calls to rtems_interrupt_server_request_submit() will disable the interrupt + * vector of the request. After processing of the request by the interrupt + * server the interrupt vector will be enabled again. + * @endparblock + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within interrupt context. + * + * * The directive may be called from within device driver initialization + * context. + * + * * The directive may be called from within task context. + * + * * The directive will not cause the calling task to be preempted. + * + * * The interrupt server request shall have been initialized by + * rtems_interrupt_server_request_initialize(). + * + * * The directive shall not be called concurrently with + * rtems_interrupt_server_request_set_vector() with the same interrupt server + * request. Calling the directive under this condition is undefined + * behaviour. + * + * * The directive shall not be called concurrently with + * rtems_interrupt_server_request_submit() with the same interrupt server + * request. Calling the directive under this condition is undefined + * behaviour. + * + * * The directive shall not be called while the interrupt server entry is + * pending on or serviced by its current interrupt server. Calling the + * directive under these conditions is undefined behaviour. + * @endparblock + */ +static inline void rtems_interrupt_server_request_set_vector( + rtems_interrupt_server_request *request, + rtems_vector_number vector +) +{ + request->entry.vector = vector; +} + +/* Generated from spec:/rtems/intr/if/server-request-destroy */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief Destroys the interrupt server request. + * + * @param[in,out] request is the interrupt server request to destroy. + * + * @par Notes + * No error checking is performed by the directive. + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within task context. + * + * * The directive shall not be called from within the context of an interrupt + * server. Calling the directive from within the context of an interrupt + * server is undefined behaviour. + * + * * The directive sends a request to another task and waits for a response. + * This may cause the calling task to be blocked and unblocked. + * + * * The interrupt server request shall have been initialized by + * rtems_interrupt_server_request_initialize(). + * @endparblock + */ +static inline void rtems_interrupt_server_request_destroy( + rtems_interrupt_server_request *request +) +{ + rtems_interrupt_server_entry_destroy( &request->entry ); +} + +/* Generated from spec:/rtems/intr/if/server-request-submit */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief Submits the interrupt server request to be serviced by the interrupt + * server. + * + * @param[in,out] request is the interrupt server request to submit. + * + * The directive appends the interrupt server entry of the request to the + * pending entries of the interrupt server. The interrupt server is notified + * that a new entry is pending. Once the interrupt server is scheduled it + * services the actions of all pending entries. + * + * @par Notes + * @parblock + * This directive may be used to do a two-step interrupt processing. The first + * step is done from within interrupt context by a call to this directive. The + * second step is then done from within the context of the interrupt server. + * + * No error checking is performed by the directive. + * + * A submitted request may be destroyed by + * rtems_interrupt_server_request_destroy(). + * @endparblock + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within interrupt context. + * + * * The directive may be called from within device driver initialization + * context. + * + * * The directive may be called from within task context. + * + * * The directive may unblock a task. This may cause the calling task to be + * preempted. + * + * * The interrupt server request shall have been initialized by + * rtems_interrupt_server_request_initialize(). + * + * * The directive shall not be called concurrently with + * rtems_interrupt_server_request_set_vector() with the same interrupt server + * request. Calling the directive under this condition is undefined + * behaviour. + * @endparblock + */ +static inline void rtems_interrupt_server_request_submit( + rtems_interrupt_server_request *request +) +{ + rtems_interrupt_server_entry_submit( &request->entry ); +} #ifdef __cplusplus } -- 2.26.2 From chrisj at rtems.org Thu Dec 2 21:10:44 2021 From: chrisj at rtems.org (Chris Johns) Date: Fri, 3 Dec 2021 08:10:44 +1100 Subject: [PATCH 1/1] Update rtems-notes-5.md In-Reply-To: References: <20211130150307.15090-1-gabriel.moyano@dlr.de> <20211130150307.15090-2-gabriel.moyano@dlr.de> <6f424045-6ae3-1f06-f54f-c2056b961f93@rtems.org> Message-ID: On 2/12/21 7:27 pm, Jan.Sommer at dlr.de wrote: >> -----Original Message----- >> From: devel On Behalf Of Chris Johns >> Sent: Thursday, December 2, 2021 2:06 AM >> To: Moyano Heredia, Victor Gabriel ; >> devel at rtems.org >> Subject: Re: [PATCH 1/1] Update rtems-notes-5.md >> >> OK to push. > > Should I push the addition to master, 5, or both branches? Good question, I think both. Thanks Chris From christian.mauderer at embedded-brains.de Fri Dec 3 12:50:57 2021 From: christian.mauderer at embedded-brains.de (Christian Mauderer) Date: Fri, 3 Dec 2021 13:50:57 +0100 Subject: [PATCH] untar: Make behavior similar to GNU or BSD tar Message-ID: <20211203125057.16329-1-christian.mauderer@embedded-brains.de> RTEMS untar implementation had problems with overwriting or integrating archives into existing directory structures. This patch adapts the behavior to mimic that of a GNU tar or BSD tar and extends the tar01 test to check for the behavior. That is: * If a directory structure exists, the files from the archive will be integrated. Existing files are overwritten. * If a file exists and the archive contains a directory with the same name, the file is removed and a directory is created. In the above example: if l1/l2 is a file it will be overwritten with a new directory. * If a directory exists and the archive contains a file with the same name, the directory will be replaced if it is empty. If it contains files, the result is an error. * An archive also can contain only a file without the parent directories. If in that case one of the parent directories exists as a file extracting the archive results in an error. In the example: if l1/l2 is a file and the archive doesn't contain the directories but only the file l1/l2/x.txt that would be an error. * In case of an error, it is possible that the archive has been partially extracted. Closes #4552 --- cpukit/libmisc/untar/untar.c | 57 +++++--- testsuites/libtests/tar01/init.c | 199 +++++++++++++++++++++++++++- testsuites/libtests/tar01/tar01.doc | 1 + testsuites/libtests/tar01/tar01.scn | 54 ++++++-- testsuites/libtests/tar01/tar01.tar | Bin 10240 -> 10240 bytes 5 files changed, 282 insertions(+), 29 deletions(-) diff --git a/cpukit/libmisc/untar/untar.c b/cpukit/libmisc/untar/untar.c index a2f09fb99f..8888ab2c57 100644 --- a/cpukit/libmisc/untar/untar.c +++ b/cpukit/libmisc/untar/untar.c @@ -126,30 +126,25 @@ Make_Path(const rtems_printer *printer, char *path) *p = '\0'; if (p[1] == '\0') { - /* Speculatively unlink the last component so that it can be re-created */ - unlink(path); return 0; } if (mkdir(path, S_IRWXU | S_IRWXG | S_IRWXO) != 0) { - if (errno == EEXIST || errno == EISDIR) { + if (errno == EEXIST) { + /* If it exists already: Check whether it is a directory */ struct stat sb; - - if (stat(path, &sb) != 0) { + if (lstat(path, &sb) != 0) { + Print_Error(printer, "lstat", path); + return -1; + } else if (!S_ISDIR(sb.st_mode)) { + rtems_printf(printer, + "untar: mkdir: %s: exists but is not a directory\n", + path); return -1; } - - if (!S_ISDIR(sb.st_mode)) { - if (unlink(path) != 0) { - Print_Error(printer, "unlink", path); - return -1; - } - - if (mkdir(path, S_IRWXU | S_IRWXG | S_IRWXO) != 0) { - Print_Error(printer, "mkdir (unlink)", path); - return -1; - } - } + } else { + Print_Error(printer, "mkdir", path); + return -1; } } @@ -206,6 +201,12 @@ Untar_ProcessHeader( if (Make_Path(ctx->printer, ctx->file_path) != 0) { retval = UNTAR_FAIL; + } else { + /* + * Speculatively unlink. This should unlink everything but non-empty + * directories or write protected stuff. + */ + unlink(ctx->file_path); } if (ctx->linkflag == SYMTYPE) { @@ -225,8 +226,22 @@ Untar_ProcessHeader( rtems_printf(ctx->printer, "untar: dir: %s\n", ctx->file_path); r = mkdir(ctx->file_path, ctx->mode); if (r != 0) { - Print_Error(ctx->printer, "mkdir", ctx->file_path); - retval = UNTAR_FAIL; + if (errno == EEXIST) { + /* If it exists already: Check whether it is a directory */ + struct stat sb; + if (lstat(ctx->file_path, &sb) != 0) { + Print_Error(ctx->printer, "lstat", ctx->file_path); + retval = UNTAR_FAIL; + } else if (!S_ISDIR(sb.st_mode)) { + rtems_printf(ctx->printer, + "untar: mkdir: %s: exists but is not a directory\n", + ctx->file_path); + retval = UNTAR_FAIL; + } + } else { + Print_Error(ctx->printer, "mkdir", ctx->file_path); + retval = UNTAR_FAIL; + } } } @@ -426,7 +441,9 @@ Untar_FromFile_Print( */ if ((out_fd = creat(ctx.file_path, ctx.mode)) == -1) { - (void) lseek(fd, SEEK_CUR, 512UL * ctx.nblocks); + /* Couldn't create that file. Abort. */ + retval = UNTAR_FAIL; + break; } else { for (i = 0; i < ctx.nblocks; i++) { n = read(fd, bufr, 512); diff --git a/testsuites/libtests/tar01/init.c b/testsuites/libtests/tar01/init.c index 4cad67a6ae..2deff3a482 100644 --- a/testsuites/libtests/tar01/init.c +++ b/testsuites/libtests/tar01/init.c @@ -7,6 +7,33 @@ * http://www.rtems.org/license/LICENSE. */ +/* + * Note on the used tar file: Generate the file on a system that supports + * symlinks with the following commands (tested on Linux - you might have to + * adapt on other systems): + * + * export WORK=some_work_directory + * rm -r ${WORK} + * mkdir -p ${WORK}/home/abc/def + * mkdir -p ${WORK}/home/dir + * cd ${WORK} + * echo "#! joel" > home/abc/def/test_script + * echo "ls -las /dev" >> home/abc/def/test_script + * chmod 755 home/abc/def/test_script + * echo "This is a test of loading an RTEMS filesystem from an" > home/test_file + * echo "initial tar image." >> home/test_file + * echo "Hello world" >> home/dir/file + * ln -s home/test_file symlink + * tar cf tar01.tar --format=ustar \ + * symlink \ + * home/test_file \ + * home/abc/def/test_script \ + * home/dir + * + * Note that "home/dir" is in the archive as separate directory. "home/abc" is + * only in the archive as a parent of the file "test_script". + */ + #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -95,6 +122,84 @@ void test_untar_from_memory(void) } +static void assert_file_content( + const char *name, + const char *expected_content, + ssize_t expected_size +) +{ + char buf[16]; + int fd; + int rd; + + fd = open(name, O_RDONLY); + rtems_test_assert( fd >= 0 ); + do { + rd = read(fd, buf, sizeof(buf)); + rtems_test_assert( rd >= 0 ); + if (rd > 0) { + rtems_test_assert( expected_size - rd >= 0 ); + rtems_test_assert( memcmp(buf, expected_content, rd) == 0 ); + expected_content += rd; + expected_size -= rd; + } + } while(rd > 0); + rtems_test_assert( expected_size == 0 ); + close(fd); +} + +static void assert_content_like_expected(void) +{ + const char *directories[] = { + "home", + "home/abc", + "home/abc/def", + "home/dir", + }; + const char *symlinks[] = { + "symlink", + }; + const struct { + const char *name; + const char *content; + } files[] = { + { + .name = "home/abc/def/test_script", + .content = "#! joel\nls -las /dev\n", + }, { + .name = "home/test_file", + .content = "This is a test of loading an RTEMS filesystem from an\n" + "initial tar image.\n", + }, { + .name = "home/dir/file", + .content = "Hello world\n", + } + }; + size_t i; + struct stat st; + + for(i = 0; i < RTEMS_ARRAY_SIZE(directories); ++i) { + lstat(directories[i], &st); + rtems_test_assert( S_ISDIR(st.st_mode) ); + } + + for(i = 0; i < RTEMS_ARRAY_SIZE(symlinks); ++i) { + lstat(symlinks[i], &st); + rtems_test_assert( S_ISLNK(st.st_mode) ); + } + + for(i = 0; i < RTEMS_ARRAY_SIZE(files); ++i) { + lstat(files[i].name, &st); + rtems_test_assert( S_ISREG(st.st_mode) ); + + assert_file_content( + files[i].name, + files[i].content, + strlen(files[i].content) + ); + } +} + void test_untar_from_file(void) { int fd; @@ -119,13 +224,105 @@ void test_untar_from_file(void) rv = chdir( "/dest" ); rtems_test_assert( rv == 0 ); - /* Untar it */ + /* Case 1: Untar it into empty directory */ rv = Untar_FromFile( "/test.tar" ); printf("Untaring from file - "); if (rv != UNTAR_SUCCESSFUL) { printf ("error: untar failed: %i\n", rv); exit(1); } + assert_content_like_expected(); + printf ("successful\n"); + + /* Case 2: Most files exist */ + rv = unlink("/dest/home/test_file"); + rtems_test_assert( rv == 0 ); + + rv = Untar_FromFile( "/test.tar" ); + printf("Untar from file into existing structure with one missing file - "); + if (rv != UNTAR_SUCCESSFUL) { + printf ("error: untar failed: %i\n", rv); + exit(1); + } + assert_content_like_expected(); + printf ("successful\n"); + + /* Case 3: An empty directory exists where a file should be */ + rv = unlink("/dest/home/test_file"); + rtems_test_assert( rv == 0 ); + rv = mkdir("/dest/home/test_file", S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); + rtems_test_assert( rv == 0 ); + + rv = Untar_FromFile( "/test.tar" ); + printf("Untar from file; overwrite empty directory with file - "); + if (rv != UNTAR_SUCCESSFUL) { + printf ("error: untar failed: %i\n", rv); + exit(1); + } + assert_content_like_expected(); + printf ("successful\n"); + + /* Case 4: A file exists where a parent directory should be created */ + rv = unlink("/dest/home/abc/def/test_script"); + rtems_test_assert( rv == 0 ); + rv = unlink("/dest/home/abc/def"); + rtems_test_assert( rv == 0 ); + rv = unlink("/dest/home/abc"); + rtems_test_assert( rv == 0 ); + fd = creat("/dest/home/abc", S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); + rtems_test_assert( fd >= 0 ); + close(fd); + + rv = Untar_FromFile( "/test.tar" ); + printf("Untar from file; file exists where parent dir should be created - "); + if (rv != UNTAR_FAIL) { + printf ("error: untar didn't fail like expected: %i\n", rv); + exit(1); + } + printf ("expected fail\n"); + /* cleanup so that the next one works */ + rv = unlink("/dest/home/abc"); + rtems_test_assert( rv == 0 ); + + /* Case 5: A non-empty directory exists where a file should be created */ + rv = unlink("/dest/home/test_file"); + rtems_test_assert( rv == 0 ); + rv = mkdir("/dest/home/test_file", S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); + rtems_test_assert( rv == 0 ); + fd = creat("/dest/home/test_file/file", + S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); + rtems_test_assert( fd >= 0 ); + close(fd); + + rv = Untar_FromFile( "/test.tar" ); + printf("Untar from file; non-empty dir where file should be created - "); + if (rv != UNTAR_FAIL) { + printf ("error: untar didn't fail like expected: %i\n", rv); + exit(1); + } + printf ("expected fail\n"); + /* cleanup so that the next one works */ + rv = unlink("/dest/home/test_file/file"); + rtems_test_assert( rv == 0 ); + rv = unlink("/dest/home/test_file"); + rtems_test_assert( rv == 0 ); + + /* Case 6: A file exists where a directory is explicitly in the archive */ + rv = unlink("/dest/home/dir/file"); + rtems_test_assert( rv == 0 ); + rv = unlink("/dest/home/dir"); + rtems_test_assert( rv == 0 ); + fd = creat("/dest/home/dir", S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); + rtems_test_assert( fd >= 0 ); + close(fd); + + rv = Untar_FromFile( "/test.tar" ); + printf("Untar from file; overwrite file with explicit directory - "); + if (rv != UNTAR_SUCCESSFUL) { + printf ("error: untar failed: %i\n", rv); + exit(1); + } + assert_content_like_expected(); printf ("successful\n"); /******************/ diff --git a/testsuites/libtests/tar01/tar01.doc b/testsuites/libtests/tar01/tar01.doc index 060f98a813..adffdca291 100644 --- a/testsuites/libtests/tar01/tar01.doc +++ b/testsuites/libtests/tar01/tar01.doc @@ -20,3 +20,4 @@ directives: concepts: + exercise these routines ++ check whether existing files are overwritten or not overwritten like expected diff --git a/testsuites/libtests/tar01/tar01.scn b/testsuites/libtests/tar01/tar01.scn index 68fa951881..dd72f9517b 100644 --- a/testsuites/libtests/tar01/tar01.scn +++ b/testsuites/libtests/tar01/tar01.scn @@ -1,9 +1,24 @@ -*** TAR01 TEST *** -Untaring from memory - successful +*** BEGIN OF TEST TAR 1 *** +*** TEST VERSION: 6.0.0.e1efb4eb8a9d6dd5f6f37dafc9feb0a9e6a888f1 +*** TEST STATE: EXPECTED_PASS +*** TEST BUILD: RTEMS_POSIX_API +*** TEST TOOLS: 10.3.1 20210409 (RTEMS 6, RSB ad54d1dd3cf8249d9d39deb1dd28b2f294df062d-modified, Newlib eb03ac1) +Untaring from memory - untar: memory at 0x11ece8 (10240) +untar: symlink: home/test_file -> symlink +untar: file: home/test_file (s:73,m:0644) +untar: file: home/abc/def/test_script (s:21,m:0755) +untar: dir: home/dir +untar: file: home/dir/file (s:12,m:0644) +successful ========= /home/test_file ========= (0)This is a test of loading an RTEMS filesystem from an initial tar image. +========= /home/abc/def/test_script ========= +(0)#! joel +ls -las /dev + + /home/abc/def/test_script: mode: 0755 want: 0755 ========= /symlink ========= (0)This is a test of loading an RTEMS filesystem from an initial tar image. @@ -11,35 +26,58 @@ initial tar image. Copy tar image to test.tar Untaring from file - successful +Untar from file into existing structure with one missing file - successful +Untar from file; overwrite empty directory with file - successful +Untar from file; file exists where parent dir should be created - expected fail +Untar from file; non-empty dir where file should be created - expected fail +Untar from file; overwrite file with explicit directory - successful ========= /dest/home/test_file ========= (0)This is a test of loading an RTEMS filesystem from an initial tar image. +========= /dest/home/abc/def/test_script ========= +(0)#! joel +ls -las /dev + + /dest/home/abc/def/test_script: mode: 0755 want: 0755 ========= /dest/symlink ========= (0)This is a test of loading an RTEMS filesystem from an initial tar image. -Untaring chunks from memory - untar: dir: home -untar: file: home/test_file (73) +Untaring chunks from memory - untar: symlink: home/test_file -> symlink +untar: file: home/test_file (s:73,m:0644) +untar: file: home/abc/def/test_script (s:21,m:0755) +untar: dir: home/dir +untar: file: home/dir/file (s:12,m:0644) successful ========= /dest2/home/test_file ========= (0)This is a test of loading an RTEMS filesystem from an initial tar image. +========= /dest2/home/abc/def/test_script ========= +(0)#! joel +ls -las /dev + + /dest2/home/abc/def/test_script: mode: 0755 want: 0755 ========= /dest2/symlink ========= (0)This is a test of loading an RTEMS filesystem from an initial tar image. -Untaring chunks from tgz- untar: dir: home -untar: file: home/test_file (73) -successful +Untaring chunks from tgz - successful ========= /dest3/home/test_file ========= (0)This is a test of loading an RTEMS filesystem from an initial tar image. +========= /dest3/home/abc/def/test_script ========= +(0)#! joel +ls -las /dev + + /dest3/home/abc/def/test_script: mode: 0755 want: 0755 ========= /dest3/symlink ========= (0)This is a test of loading an RTEMS filesystem from an initial tar image. -*** END OF TAR01 TEST *** + + +*** END OF TEST TAR 1 *** diff --git a/testsuites/libtests/tar01/tar01.tar b/testsuites/libtests/tar01/tar01.tar index 6c6952ef183d51a9635c6ebbc8ed0443e8da1725..9874f426d15eb817f270af7dab48fce1f36be848 100644 GIT binary patch literal 10240 zcmeH}-%i6I6vlhKr#QxI9dtmSz{DGGboUFc)S*yJ=`?$L>C6^qR=rsp7sHb!M0) zu4Aj4w4~*#v9YzfUihOEmBDLUucK+=(e~X&cIDAdf3I>3#2pePlCC}abIuR-=Srnx zLTn6NXRiNzWh13eQ|B`Z6}g~GTR)Mm>3)85_duQZ;wHAnQ`H2Y8YZ^3$tsSLb;x at C zWUeP;XoWdWPGIYQ{kWW#rus~^aoO0{_LLKK{x78L^*_tyq5pFx(scp0w4eaAOHd&00JNY0w4eaAOHd& V00JNY0w4eaAOHd&00LtX_yCHOyx{-< literal 10240 zcmeI!-)h1z6b5jw`xIyFdh?`zpJ11}*}Ru%Q=2VqM^7F2_Dfp^QXGoV;n)`hsW~ah z&wOdirZUUUNVhJmGmBXo`p7d6{RW-lY}|){VG$LubX8ylbi0P z)9r#;%tlLRb-gYp72{>zRNB_G7t_kAf^jMR;)X`2YHskiRcVF%M^nEEs42)bI=A(X zbWJa-r{`DdH-;RfGZhtWQ~8d-*49%w@^oY?y)%!&4XzDSIxkT6`PZB6GB?F|4#>8( zAKm$pmsj+G$dcqJ_uuEhm=z9_N&Z8{afbX~PJDIc{T;nE#syC3!D%7C4?dCQt2zJN zKsi*-*6*{0Tj at K8~^|S -- 2.31.1 From ryan.long at oarcorp.com Fri Dec 3 14:47:51 2021 From: ryan.long at oarcorp.com (Ryan Long) Date: Fri, 3 Dec 2021 09:47:51 -0500 Subject: [PATCH rtems-tools 0/8] Convert and reformat pt. 4 Message-ID: <1638542879-31098-1-git-send-email-ryan.long@oarcorp.com> Hi, For this series of patches, I followed this series of steps: 1. Convert a file from the C way of doing things to C++. 2. Go through all the files that had to do with the converted file and make the formatting consistent. Thanks, Ryan Ryan Long (8): ExecutableInfo.cc: Fix formatting ExecutableInfo.h: Fix formatting Explanations: Convert to C++ Explanations.cc: Fix formatting Explanations.h: Fix formatting TraceConverter.cc: Convert to C++ TraceConverter.cc: Fix formatting TraceList.cc: Convert from C to C++ tester/covoar/ExecutableInfo.cc | 103 ++++++++++++++++++++++------------------ tester/covoar/ExecutableInfo.h | 16 +++---- tester/covoar/Explanations.cc | 51 ++++++++++---------- tester/covoar/Explanations.h | 14 ++---- tester/covoar/TraceConverter.cc | 75 ++++++++++++++--------------- tester/covoar/TraceList.cc | 14 +++--- 6 files changed, 140 insertions(+), 133 deletions(-) -- 1.8.3.1 From ryan.long at oarcorp.com Fri Dec 3 14:47:52 2021 From: ryan.long at oarcorp.com (Ryan Long) Date: Fri, 3 Dec 2021 09:47:52 -0500 Subject: [PATCH rtems-tools 1/8] ExecutableInfo.cc: Fix formatting In-Reply-To: <1638542879-31098-1-git-send-email-ryan.long@oarcorp.com> References: <1638542879-31098-1-git-send-email-ryan.long@oarcorp.com> Message-ID: <1638542879-31098-2-git-send-email-ryan.long@oarcorp.com> --- tester/covoar/ExecutableInfo.cc | 103 ++++++++++++++++++++++------------------ 1 file changed, 58 insertions(+), 45 deletions(-) diff --git a/tester/covoar/ExecutableInfo.cc b/tester/covoar/ExecutableInfo.cc index 9589cee..bfae02b 100644 --- a/tester/covoar/ExecutableInfo.cc +++ b/tester/covoar/ExecutableInfo.cc @@ -21,74 +21,81 @@ namespace Coverage { const std::string& theLibraryName, bool verbose, DesiredSymbols& symbolsToAnalyze - ) : fileName(theExecutableName), - loadAddress(0), - symbolsToAnalyze_m(symbolsToAnalyze) + ) : fileName( theExecutableName ), + loadAddress( 0 ), + symbolsToAnalyze_m( symbolsToAnalyze ) { - if ( !theLibraryName.empty() ) + if ( !theLibraryName.empty() ) { libraryName = theLibraryName; + } - if (verbose) { + if ( verbose ) { std::cerr << "Loading executable " << theExecutableName; - if ( !theLibraryName.empty() ) + if ( !theLibraryName.empty() ) { std::cerr << " (" << theLibraryName << ')'; + } + std::cerr << std::endl; } - rld::files::object executable(theExecutableName); + rld::files::object executable( theExecutableName ); executable.open(); executable.begin(); - executable.load_symbols(symbols); + executable.load_symbols( symbols ); rld::dwarf::file debug; - debug.begin(executable.elf()); + debug.begin( executable.elf() ); debug.load_debug(); debug.load_functions(); - for (auto& cu : debug.get_cus()) { - AddressLineRange& range = mapper.makeRange(cu.pc_low(), cu.pc_high()); + for ( auto& cu : debug.get_cus() ) { + AddressLineRange& range = mapper.makeRange( cu.pc_low(), cu.pc_high() ); // Does not filter on desired symbols under the assumption that the test // code and any support code is small relative to what is being tested. - for (const auto &address : cu.get_addresses()) { - range.addSourceLine(address); + for ( const auto &address : cu.get_addresses() ) { + range.addSourceLine( address ); } - for (auto& func : cu.get_functions()) { - if (!func.has_machine_code()) { + for ( auto& func : cu.get_functions() ) { + if ( !func.has_machine_code() ) { continue; } - if (!symbolsToAnalyze_m.isDesired(func.name())) { + if ( !symbolsToAnalyze_m.isDesired( func.name() ) ) { continue; } - if (func.is_inlined()) { - if (func.is_external()) { + if ( func.is_inlined() ) { + if ( func.is_external() ) { // Flag it std::cerr << "Function is both external and inlined: " << func.name() << std::endl; } - if (func.has_entry_pc()) { + if ( func.has_entry_pc() ) { continue; } // If the low PC address is zero, the symbol does not appear in // this executable. - if (func.pc_low() == 0) { + if ( func.pc_low() == 0 ) { continue; } } // We can't process a zero size function. - if (func.pc_high() == 0) { + if ( func.pc_high() == 0 ) { continue; } - createCoverageMap (cu.name(), func.name(), - func.pc_low(), func.pc_high() - 1); + createCoverageMap( + cu.name(), + func.name(), + func.pc_low(), + func.pc_high() - 1 + ); } } } @@ -97,16 +104,18 @@ namespace Coverage { { } - void ExecutableInfo::dumpCoverageMaps( void ) { - ExecutableInfo::CoverageMaps::iterator itr; + void ExecutableInfo::dumpCoverageMaps() + { + ExecutableInfo::CoverageMaps::iterator itr; - for (auto& cm : coverageMaps) { + for ( auto& cm : coverageMaps ) { std::cerr << "Coverage Map for " << cm.first << std::endl; cm.second->dump(); } } - void ExecutableInfo::dumpExecutableInfo( void ){ + void ExecutableInfo::dumpExecutableInfo() + { std::cout << std::endl << "== Executable info ==" << std::endl << "executable = " << getFileName () << std::endl @@ -115,7 +124,7 @@ namespace Coverage { theSymbolTable.dumpSymbolTable(); } - CoverageMapBase* ExecutableInfo::getCoverageMap ( uint32_t address ) + CoverageMapBase* ExecutableInfo::getCoverageMap( uint32_t address ) { CoverageMapBase* aCoverageMap = NULL; CoverageMaps::iterator it; @@ -123,29 +132,29 @@ namespace Coverage { // Obtain the coverage map containing the specified address. itsSymbol = theSymbolTable.getSymbol( address ); - if (itsSymbol != "") { - aCoverageMap = &findCoverageMap(itsSymbol); + if ( itsSymbol != "" ) { + aCoverageMap = &findCoverageMap( itsSymbol ); } return aCoverageMap; } - const std::string& ExecutableInfo::getFileName ( void ) const + const std::string& ExecutableInfo::getFileName() const { return fileName; } - const std::string ExecutableInfo::getLibraryName( void ) const + const std::string ExecutableInfo::getLibraryName() const { return libraryName; } - uint32_t ExecutableInfo::getLoadAddress( void ) const + uint32_t ExecutableInfo::getLoadAddress() const { return loadAddress; } - SymbolTable* ExecutableInfo::getSymbolTable ( void ) + SymbolTable* ExecutableInfo::getSymbolTable() { return &theSymbolTable; } @@ -155,8 +164,10 @@ namespace Coverage { ) { CoverageMaps::iterator cmi = coverageMaps.find( symbolName ); - if ( cmi == coverageMaps.end() ) - throw CoverageMapNotFoundError(symbolName); + if ( cmi == coverageMaps.end() ) { + throw CoverageMapNotFoundError( symbolName ); + } + return *(cmi->second); } @@ -167,8 +178,8 @@ namespace Coverage { uint32_t highAddress ) { - CoverageMapBase *theMap; - CoverageMaps::iterator itr; + CoverageMapBase* theMap; + CoverageMaps::iterator itr; if ( lowAddress > highAddress ) { std::ostringstream what; @@ -195,22 +206,24 @@ namespace Coverage { std::string& line ) { - std::string file; - int lno; - mapper.getSource (address, file, lno); + std::string file; + int lno; std::ostringstream ss; + + mapper.getSource( address, file, lno ); ss << file << ':' << lno; line = ss.str (); } - bool ExecutableInfo::hasDynamicLibrary( void ) + bool ExecutableInfo::hasDynamicLibrary() { return !libraryName.empty(); } - void ExecutableInfo::mergeCoverage( void ) { - for (auto& cm : coverageMaps) { - if (symbolsToAnalyze_m.isDesired( cm.first )) + void ExecutableInfo::mergeCoverage() + { + for ( auto& cm : coverageMaps ) { + if ( symbolsToAnalyze_m.isDesired( cm.first ) ) symbolsToAnalyze_m.mergeCoverageMap( cm.first, cm.second ); } } -- 1.8.3.1 From ryan.long at oarcorp.com Fri Dec 3 14:47:53 2021 From: ryan.long at oarcorp.com (Ryan Long) Date: Fri, 3 Dec 2021 09:47:53 -0500 Subject: [PATCH rtems-tools 2/8] ExecutableInfo.h: Fix formatting In-Reply-To: <1638542879-31098-1-git-send-email-ryan.long@oarcorp.com> References: <1638542879-31098-1-git-send-email-ryan.long@oarcorp.com> Message-ID: <1638542879-31098-3-git-send-email-ryan.long@oarcorp.com> --- tester/covoar/ExecutableInfo.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tester/covoar/ExecutableInfo.h b/tester/covoar/ExecutableInfo.h index fe46e1f..fd720ba 100644 --- a/tester/covoar/ExecutableInfo.h +++ b/tester/covoar/ExecutableInfo.h @@ -62,12 +62,12 @@ class DesiredSymbols; * This method prints the contents of all coverage maps for * this executable. */ - void dumpCoverageMaps( void ); + void dumpCoverageMaps(); /*! * This method prints the contents of Executable info containers */ - void dumpExecutableInfo( void ); + void dumpExecutableInfo(); /*! * This method returns a pointer to the executable's coverage map @@ -84,28 +84,28 @@ class DesiredSymbols; * * @return Returns the executable's file name */ - const std::string& getFileName( void ) const; + const std::string& getFileName() const; /*! * This method returns the library name associated with the executable. * * @return Returns the executable's library name */ - const std::string getLibraryName( void ) const; + const std::string getLibraryName() const; /*! * This method returns the load address of the dynamic library * * @return Returns the load address of the dynamic library */ - uint32_t getLoadAddress( void ) const; + uint32_t getLoadAddress() const; /*! * This method returns a pointer to the executable's symbol table. * * @return Returns a pointer to the symbol table. */ - SymbolTable* getSymbolTable( void ); + SymbolTable* getSymbolTable(); /*! * This method finds a coverage map for the specified symbol. @@ -131,13 +131,13 @@ class DesiredSymbols; * * @return Returns TRUE if */ - bool hasDynamicLibrary( void ); + bool hasDynamicLibrary(); /*! * This method merges the coverage maps for this executable into * the unified coverage map. */ - void mergeCoverage( void ); + void mergeCoverage(); /*! * This method sets the load address of the dynamic library -- 1.8.3.1 From ryan.long at oarcorp.com Fri Dec 3 14:47:57 2021 From: ryan.long at oarcorp.com (Ryan Long) Date: Fri, 3 Dec 2021 09:47:57 -0500 Subject: [PATCH rtems-tools 6/8] TraceConverter.cc: Convert to C++ In-Reply-To: <1638542879-31098-1-git-send-email-ryan.long@oarcorp.com> References: <1638542879-31098-1-git-send-email-ryan.long@oarcorp.com> Message-ID: <1638542879-31098-7-git-send-email-ryan.long@oarcorp.com> --- tester/covoar/TraceConverter.cc | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/tester/covoar/TraceConverter.cc b/tester/covoar/TraceConverter.cc index 4c62b06..1a03b49 100644 --- a/tester/covoar/TraceConverter.cc +++ b/tester/covoar/TraceConverter.cc @@ -27,15 +27,14 @@ #define kill(p,s) raise(s) #endif -char* progname; +std::string progname; void usage() { - fprintf( - stderr, - "Usage: %s [-v] -c CPU -e executable -t tracefile [-E logfile]\n", - progname - ); + std::cerr << "Usage: " + << progname + << " [-v] -c CPU -e executable -t tracefile [-E logfile]" + << std::endl; exit(1); } @@ -81,10 +80,10 @@ int main( int opt; Trace::TraceReaderLogQEMU log; Trace::TraceWriterQEMU trace; - const char *cpuname = ""; - const char *executable = ""; - const char *tracefile = ""; - const char *logname = "/tmp/qemu.log"; + std::string cpuname; + std::string executable; + std::string tracefile; + std::string logname = "/tmp/qemu.log"; Coverage::ExecutableInfo* executableInfo; rld::process::tempfile objdumpFile( ".dmp" ); rld::process::tempfile err( ".err" ); @@ -114,18 +113,18 @@ int main( } // Make sure we have all the required parameters - if ( !cpuname ) { - fprintf( stderr, "cpuname not specified\n" ); + if ( cpuname.empty() ) { + std::cerr << "cpuname not specified" << std::endl; usage(); } - if ( !executable ) { - fprintf( stderr, "executable not specified\n" ); + if ( executable.empty() ) { + std::cerr << "executable not specified" << std::endl; usage(); } - if ( !tracefile ) { - fprintf( stderr, "output trace file not specified\n" ); + if ( tracefile.empty() ) { + std::cerr << "output trace file not specified" << std::endl; usage(); } @@ -195,8 +194,8 @@ int main( try { objdumpProcessor.loadAddressTable( executableInfo, objdumpFile, err ); - log.processFile( logname, objdumpProcessor ); - trace.writeFile( tracefile, &log, verbose ); + log.processFile( logname.c_str(), objdumpProcessor ); + trace.writeFile( tracefile.c_str(), &log, verbose ); } catch ( rld::error re ) { -- 1.8.3.1 From ryan.long at oarcorp.com Fri Dec 3 14:47:54 2021 From: ryan.long at oarcorp.com (Ryan Long) Date: Fri, 3 Dec 2021 09:47:54 -0500 Subject: [PATCH rtems-tools 3/8] Explanations: Convert to C++ In-Reply-To: <1638542879-31098-1-git-send-email-ryan.long@oarcorp.com> References: <1638542879-31098-1-git-send-email-ryan.long@oarcorp.com> Message-ID: <1638542879-31098-4-git-send-email-ryan.long@oarcorp.com> --- tester/covoar/Explanations.cc | 10 +++++----- tester/covoar/Explanations.h | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tester/covoar/Explanations.cc b/tester/covoar/Explanations.cc index 4142418..028c00e 100644 --- a/tester/covoar/Explanations.cc +++ b/tester/covoar/Explanations.cc @@ -27,14 +27,14 @@ namespace Coverage { } void Explanations::load( - const char* const explanations + const std::string& explanations ) { std::ifstream explain; Explanation e; int line = 1; - if (!explanations) + if (explanations.empty()) return; explain.open( explanations ); @@ -121,13 +121,13 @@ namespace Coverage { } void Explanations::writeNotFound( - const char* const fileName + const std::string& fileName ) { std::ofstream notFoundFile; bool notFoundOccurred = false; - if (!fileName) + if (fileName.empty()) return; notFoundFile.open( fileName ); @@ -151,7 +151,7 @@ namespace Coverage { } if (!notFoundOccurred) { - if (!unlink( fileName )) { + if (!unlink( fileName.c_str())) { std::cerr << "Warning: Unable to unlink " << fileName << std::endl << std::endl; diff --git a/tester/covoar/Explanations.h b/tester/covoar/Explanations.h index de0c051..ca7c749 100644 --- a/tester/covoar/Explanations.h +++ b/tester/covoar/Explanations.h @@ -88,7 +88,7 @@ namespace Coverage { * the explanation information */ void load( - const char* const explanations + const std::string& explanations ); /*! @@ -109,7 +109,7 @@ namespace Coverage { * @param[in] fileName specifies the name of the file to write */ void writeNotFound( - const char* const fileName + const std::string& fileName ); }; -- 1.8.3.1 From ryan.long at oarcorp.com Fri Dec 3 14:47:55 2021 From: ryan.long at oarcorp.com (Ryan Long) Date: Fri, 3 Dec 2021 09:47:55 -0500 Subject: [PATCH rtems-tools 4/8] Explanations.cc: Fix formatting In-Reply-To: <1638542879-31098-1-git-send-email-ryan.long@oarcorp.com> References: <1638542879-31098-1-git-send-email-ryan.long@oarcorp.com> Message-ID: <1638542879-31098-5-git-send-email-ryan.long@oarcorp.com> --- tester/covoar/Explanations.cc | 51 ++++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/tester/covoar/Explanations.cc b/tester/covoar/Explanations.cc index 028c00e..d9d7a4f 100644 --- a/tester/covoar/Explanations.cc +++ b/tester/covoar/Explanations.cc @@ -26,19 +26,18 @@ namespace Coverage { { } - void Explanations::load( - const std::string& explanations - ) + void Explanations::load( const std::string& explanations ) { - std::ifstream explain; - Explanation e; - int line = 1; + std::ifstream explain; + Explanation e; + int line = 1; - if (explanations.empty()) + if ( explanations.empty() ) { return; + } explain.open( explanations ); - if (!explain) { + if ( !explain ) { std::ostringstream what; what << "Unable to open " << explanations; throw rld::error( what, "Explanations::load" ); @@ -50,14 +49,15 @@ namespace Coverage { // skip blank lines between do { std::getline( explain, input_line ); - if (explain.fail()) { + if ( explain.fail() ) { return; } + line++; } while ( input_line.empty() ); // Have we already seen this one? - if (set.find( input_line ) != set.end()) { + if ( set.find( input_line ) != set.end() ) { std::ostringstream what; what << "line " << line << "contains a duplicate explanation (" @@ -71,7 +71,7 @@ namespace Coverage { // Get the classification std::getline( explain, input_line ); - if (explain.fail()) { + if ( explain.fail() ) { std::ostringstream what; what << "line " << line << "out of sync at the classification"; @@ -85,14 +85,14 @@ namespace Coverage { line++; const std::string delimiter = "+++"; - if (input_line.compare( delimiter ) == 0) { + if ( input_line.compare( delimiter ) == 0 ) { break; } // XXX only taking last line. Needs to be a vector e.explanation.push_back( input_line ); } - if (explain.fail()) { + if ( explain.fail() ) { std::ostringstream what; what << "line " << line << "out of sync at the explanation"; @@ -109,7 +109,7 @@ namespace Coverage { const std::string& start ) { - if (set.find( start ) == set.end()) { + if ( set.find( start ) == set.end() ) { #if 0 std::cerr << "Warning: Unable to find explanation for " << start << std::endl; @@ -120,38 +120,39 @@ namespace Coverage { return &set[ start ]; } - void Explanations::writeNotFound( - const std::string& fileName - ) + void Explanations::writeNotFound( const std::string& fileName ) { std::ofstream notFoundFile; bool notFoundOccurred = false; - if (fileName.empty()) + if ( fileName.empty() ) { return; + } notFoundFile.open( fileName ); - if (!notFoundFile) { + if ( !notFoundFile ) { std::ostringstream what; what << "Unable to open " << fileName << " out of sync at the explanation"; throw rld::error( what, "Explanations::writeNotFound" ); } - for (std::map::iterator itr = set.begin(); - itr != set.end(); - itr++) { + for ( + std::map::iterator itr = set.begin(); + itr != set.end(); + itr++ + ) { Explanation e = (*itr).second; std::string key = (*itr).first; - if (!e.found) { + if ( !e.found ) { notFoundOccurred = true; notFoundFile << e.startingPoint << std::endl; } } - if (!notFoundOccurred) { - if (!unlink( fileName.c_str())) { + if ( !notFoundOccurred ) { + if ( !unlink( fileName.c_str() ) ) { std::cerr << "Warning: Unable to unlink " << fileName << std::endl << std::endl; -- 1.8.3.1 From ryan.long at oarcorp.com Fri Dec 3 14:47:56 2021 From: ryan.long at oarcorp.com (Ryan Long) Date: Fri, 3 Dec 2021 09:47:56 -0500 Subject: [PATCH rtems-tools 5/8] Explanations.h: Fix formatting In-Reply-To: <1638542879-31098-1-git-send-email-ryan.long@oarcorp.com> References: <1638542879-31098-1-git-send-email-ryan.long@oarcorp.com> Message-ID: <1638542879-31098-6-git-send-email-ryan.long@oarcorp.com> --- tester/covoar/Explanations.h | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/tester/covoar/Explanations.h b/tester/covoar/Explanations.h index ca7c749..c147c11 100644 --- a/tester/covoar/Explanations.h +++ b/tester/covoar/Explanations.h @@ -49,7 +49,7 @@ namespace Coverage { /*! * This method constructs an Explanation instance. */ - Explanation() {found = false;} + Explanation() { found = false; } /*! * This method destructs an Explanation instance. @@ -87,9 +87,7 @@ namespace Coverage { * @param[in] explanations specifies the file name containing * the explanation information */ - void load( - const std::string& explanations - ); + void load( const std::string& explanations ); /*! * This method returns the explanation associated with the @@ -98,9 +96,7 @@ namespace Coverage { * @param[in] start specifies the starting line number for * which to search */ - const Explanation *lookupExplanation( - const std::string& start - ); + const Explanation *lookupExplanation( const std::string& start ); /*! * This method writes a file that contains a list of any @@ -108,9 +104,7 @@ namespace Coverage { * * @param[in] fileName specifies the name of the file to write */ - void writeNotFound( - const std::string& fileName - ); + void writeNotFound( const std::string& fileName ); }; -- 1.8.3.1 From ryan.long at oarcorp.com Fri Dec 3 14:47:58 2021 From: ryan.long at oarcorp.com (Ryan Long) Date: Fri, 3 Dec 2021 09:47:58 -0500 Subject: [PATCH rtems-tools 7/8] TraceConverter.cc: Fix formatting In-Reply-To: <1638542879-31098-1-git-send-email-ryan.long@oarcorp.com> References: <1638542879-31098-1-git-send-email-ryan.long@oarcorp.com> Message-ID: <1638542879-31098-8-git-send-email-ryan.long@oarcorp.com> --- tester/covoar/TraceConverter.cc | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/tester/covoar/TraceConverter.cc b/tester/covoar/TraceConverter.cc index 1a03b49..b5dc20c 100644 --- a/tester/covoar/TraceConverter.cc +++ b/tester/covoar/TraceConverter.cc @@ -35,11 +35,10 @@ void usage() << progname << " [-v] -c CPU -e executable -t tracefile [-E logfile]" << std::endl; - exit(1); + exit( 1 ); } -static void -fatal_signal( int signum ) +static void fatal_signal( int signum ) { signal( signum, SIG_DFL ); @@ -52,20 +51,23 @@ fatal_signal( int signum ) kill( getpid(), signum ); } -static void -setup_signals( void ) +static void setup_signals() { - if ( signal (SIGINT, SIG_IGN) != SIG_IGN ) + if ( signal (SIGINT, SIG_IGN) != SIG_IGN ) { signal( SIGINT, fatal_signal ); + } #ifdef SIGHUP - if ( signal( SIGHUP, SIG_IGN ) != SIG_IGN ) + if ( signal( SIGHUP, SIG_IGN ) != SIG_IGN ) { signal( SIGHUP, fatal_signal ); + } #endif - if ( signal( SIGTERM, SIG_IGN ) != SIG_IGN ) + if ( signal( SIGTERM, SIG_IGN ) != SIG_IGN ) { signal( SIGTERM, fatal_signal ); + } #ifdef SIGPIPE - if ( signal( SIGPIPE, SIG_IGN ) != SIG_IGN ) + if ( signal( SIGPIPE, SIG_IGN ) != SIG_IGN ) { signal( SIGPIPE, fatal_signal ); + } #endif #ifdef SIGCHLD signal( SIGCHLD, SIG_DFL ); @@ -100,15 +102,15 @@ int main( // progname = argv[0]; - while ((opt = getopt(argc, argv, "c:e:l:L:t:v")) != -1) { - switch (opt) { - case 'c': cpuname = optarg; break; - case 'e': executable = optarg; break; - case 'l': logname = optarg; break; + while ( (opt = getopt( argc, argv, "c:e:l:L:t:v" ) ) != -1 ) { + switch ( opt ) { + case 'c': cpuname = optarg; break; + case 'e': executable = optarg; break; + case 'l': logname = optarg; break; case 'L': dynamicLibrary = optarg; break; - case 't': tracefile = optarg; break; - case 'v': verbose = true; break; - default: usage(); + case 't': tracefile = optarg; break; + case 'v': verbose = true; break; + default: usage(); } } @@ -146,14 +148,14 @@ int main( Coverage::ObjdumpProcessor objdumpProcessor( symbolsToAnalyze, targetInfo ); - if ( !dynamicLibrary.empty() ) + if ( !dynamicLibrary.empty() ) { executableInfo = new Coverage::ExecutableInfo( executable, dynamicLibrary, false, symbolsToAnalyze ); - else { + } else { try { executableInfo = new Coverage::ExecutableInfo( -- 1.8.3.1 From ryan.long at oarcorp.com Fri Dec 3 14:47:59 2021 From: ryan.long at oarcorp.com (Ryan Long) Date: Fri, 3 Dec 2021 09:47:59 -0500 Subject: [PATCH rtems-tools 8/8] TraceList.cc: Convert from C to C++ In-Reply-To: <1638542879-31098-1-git-send-email-ryan.long@oarcorp.com> References: <1638542879-31098-1-git-send-email-ryan.long@oarcorp.com> Message-ID: <1638542879-31098-9-git-send-email-ryan.long@oarcorp.com> --- tester/covoar/TraceList.cc | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/tester/covoar/TraceList.cc b/tester/covoar/TraceList.cc index a4e29e6..51ecfd8 100644 --- a/tester/covoar/TraceList.cc +++ b/tester/covoar/TraceList.cc @@ -1,5 +1,6 @@ #include "TraceList.h" -#include +#include +#include namespace Trace { @@ -20,7 +21,7 @@ namespace Trace { traceRange_t t; t.lowAddress = lowAddressArg; - t.length = highAddressArg - lowAddressArg; + t.length = highAddressArg - lowAddressArg; t.exitReason = why; set.push_back( t ); @@ -28,12 +29,9 @@ namespace Trace { void TraceList::ShowTrace( traceRange_t *t) { - printf( - "Start 0x%x, length 0x%03x Reason %d\n", - t->lowAddress, - t->length, - t->exitReason - ); + std::cout << std::hex << "Start 0x" << t->lowAddress + << ", length 0x" << std::setfill( '0' ) << std::setw( 3 ) + << t->length << " Reason " << t->exitReason << std::endl; } void TraceList::ShowList() -- 1.8.3.1 From joel at rtems.org Fri Dec 3 17:34:08 2021 From: joel at rtems.org (Joel Sherrill) Date: Fri, 3 Dec 2021 11:34:08 -0600 Subject: [PATCH] untar: Make behavior similar to GNU or BSD tar In-Reply-To: <20211203125057.16329-1-christian.mauderer@embedded-brains.de> References: <20211203125057.16329-1-christian.mauderer@embedded-brains.de> Message-ID: I don't see anything that would stop this from being committed. This does make me realize that I think all of the untar capabilities are undocumented. --joel On Fri, Dec 3, 2021 at 6:51 AM Christian Mauderer wrote: > > RTEMS untar implementation had problems with overwriting or integrating > archives into existing directory structures. This patch adapts the > behavior to mimic that of a GNU tar or BSD tar and extends the tar01 > test to check for the behavior. That is: > > * If a directory structure exists, the files from the archive will be > integrated. Existing files are overwritten. > > * If a file exists and the archive contains a directory with the same > name, the file is removed and a directory is created. In the above > example: if l1/l2 is a file it will be overwritten with a new > directory. > > * If a directory exists and the archive contains a file with the same > name, the directory will be replaced if it is empty. If it contains > files, the result is an error. > > * An archive also can contain only a file without the parent > directories. If in that case one of the parent directories exists as a > file extracting the archive results in an error. In the example: if > l1/l2 is a file and the archive doesn't contain the directories but > only the file l1/l2/x.txt that would be an error. > > * In case of an error, it is possible that the archive has been > partially extracted. > > Closes #4552 > --- > cpukit/libmisc/untar/untar.c | 57 +++++--- > testsuites/libtests/tar01/init.c | 199 +++++++++++++++++++++++++++- > testsuites/libtests/tar01/tar01.doc | 1 + > testsuites/libtests/tar01/tar01.scn | 54 ++++++-- > testsuites/libtests/tar01/tar01.tar | Bin 10240 -> 10240 bytes > 5 files changed, 282 insertions(+), 29 deletions(-) > > diff --git a/cpukit/libmisc/untar/untar.c b/cpukit/libmisc/untar/untar.c > index a2f09fb99f..8888ab2c57 100644 > --- a/cpukit/libmisc/untar/untar.c > +++ b/cpukit/libmisc/untar/untar.c > @@ -126,30 +126,25 @@ Make_Path(const rtems_printer *printer, char *path) > > *p = '\0'; > if (p[1] == '\0') { > - /* Speculatively unlink the last component so that it can be re-created */ > - unlink(path); > return 0; > } > > if (mkdir(path, S_IRWXU | S_IRWXG | S_IRWXO) != 0) { > - if (errno == EEXIST || errno == EISDIR) { > + if (errno == EEXIST) { > + /* If it exists already: Check whether it is a directory */ > struct stat sb; > - > - if (stat(path, &sb) != 0) { > + if (lstat(path, &sb) != 0) { > + Print_Error(printer, "lstat", path); > + return -1; > + } else if (!S_ISDIR(sb.st_mode)) { > + rtems_printf(printer, > + "untar: mkdir: %s: exists but is not a directory\n", > + path); > return -1; > } > - > - if (!S_ISDIR(sb.st_mode)) { > - if (unlink(path) != 0) { > - Print_Error(printer, "unlink", path); > - return -1; > - } > - > - if (mkdir(path, S_IRWXU | S_IRWXG | S_IRWXO) != 0) { > - Print_Error(printer, "mkdir (unlink)", path); > - return -1; > - } > - } > + } else { > + Print_Error(printer, "mkdir", path); > + return -1; > } > } > > @@ -206,6 +201,12 @@ Untar_ProcessHeader( > > if (Make_Path(ctx->printer, ctx->file_path) != 0) { > retval = UNTAR_FAIL; > + } else { > + /* > + * Speculatively unlink. This should unlink everything but non-empty > + * directories or write protected stuff. > + */ > + unlink(ctx->file_path); > } > > if (ctx->linkflag == SYMTYPE) { > @@ -225,8 +226,22 @@ Untar_ProcessHeader( > rtems_printf(ctx->printer, "untar: dir: %s\n", ctx->file_path); > r = mkdir(ctx->file_path, ctx->mode); > if (r != 0) { > - Print_Error(ctx->printer, "mkdir", ctx->file_path); > - retval = UNTAR_FAIL; > + if (errno == EEXIST) { > + /* If it exists already: Check whether it is a directory */ > + struct stat sb; > + if (lstat(ctx->file_path, &sb) != 0) { > + Print_Error(ctx->printer, "lstat", ctx->file_path); > + retval = UNTAR_FAIL; > + } else if (!S_ISDIR(sb.st_mode)) { > + rtems_printf(ctx->printer, > + "untar: mkdir: %s: exists but is not a directory\n", > + ctx->file_path); > + retval = UNTAR_FAIL; > + } > + } else { > + Print_Error(ctx->printer, "mkdir", ctx->file_path); > + retval = UNTAR_FAIL; > + } > } > } > > @@ -426,7 +441,9 @@ Untar_FromFile_Print( > */ > > if ((out_fd = creat(ctx.file_path, ctx.mode)) == -1) { > - (void) lseek(fd, SEEK_CUR, 512UL * ctx.nblocks); > + /* Couldn't create that file. Abort. */ > + retval = UNTAR_FAIL; > + break; > } else { > for (i = 0; i < ctx.nblocks; i++) { > n = read(fd, bufr, 512); > diff --git a/testsuites/libtests/tar01/init.c b/testsuites/libtests/tar01/init.c > index 4cad67a6ae..2deff3a482 100644 > --- a/testsuites/libtests/tar01/init.c > +++ b/testsuites/libtests/tar01/init.c > @@ -7,6 +7,33 @@ > * http://www.rtems.org/license/LICENSE. > */ > > +/* > + * Note on the used tar file: Generate the file on a system that supports > + * symlinks with the following commands (tested on Linux - you might have to > + * adapt on other systems): > + * > + * export WORK=some_work_directory > + * rm -r ${WORK} > + * mkdir -p ${WORK}/home/abc/def > + * mkdir -p ${WORK}/home/dir > + * cd ${WORK} > + * echo "#! joel" > home/abc/def/test_script > + * echo "ls -las /dev" >> home/abc/def/test_script > + * chmod 755 home/abc/def/test_script > + * echo "This is a test of loading an RTEMS filesystem from an" > home/test_file > + * echo "initial tar image." >> home/test_file > + * echo "Hello world" >> home/dir/file > + * ln -s home/test_file symlink > + * tar cf tar01.tar --format=ustar \ > + * symlink \ > + * home/test_file \ > + * home/abc/def/test_script \ > + * home/dir > + * > + * Note that "home/dir" is in the archive as separate directory. "home/abc" is > + * only in the archive as a parent of the file "test_script". > + */ > + > #ifdef HAVE_CONFIG_H > #include "config.h" > #endif > @@ -95,6 +122,84 @@ void test_untar_from_memory(void) > > } > > +static void assert_file_content( > + const char *name, > + const char *expected_content, > + ssize_t expected_size > +) > +{ > + char buf[16]; > + int fd; > + int rd; > + > + fd = open(name, O_RDONLY); > + rtems_test_assert( fd >= 0 ); > + do { > + rd = read(fd, buf, sizeof(buf)); > + rtems_test_assert( rd >= 0 ); > + if (rd > 0) { > + rtems_test_assert( expected_size - rd >= 0 ); > + rtems_test_assert( memcmp(buf, expected_content, rd) == 0 ); > + expected_content += rd; > + expected_size -= rd; > + } > + } while(rd > 0); > + rtems_test_assert( expected_size == 0 ); > + close(fd); > +} > + > +static void assert_content_like_expected(void) > +{ > + const char *directories[] = { > + "home", > + "home/abc", > + "home/abc/def", > + "home/dir", > + }; > + const char *symlinks[] = { > + "symlink", > + }; > + const struct { > + const char *name; > + const char *content; > + } files[] = { > + { > + .name = "home/abc/def/test_script", > + .content = "#! joel\nls -las /dev\n", > + }, { > + .name = "home/test_file", > + .content = "This is a test of loading an RTEMS filesystem from an\n" > + "initial tar image.\n", > + }, { > + .name = "home/dir/file", > + .content = "Hello world\n", > + } > + }; > + size_t i; > + struct stat st; > + > + for(i = 0; i < RTEMS_ARRAY_SIZE(directories); ++i) { > + lstat(directories[i], &st); > + rtems_test_assert( S_ISDIR(st.st_mode) ); > + } > + > + for(i = 0; i < RTEMS_ARRAY_SIZE(symlinks); ++i) { > + lstat(symlinks[i], &st); > + rtems_test_assert( S_ISLNK(st.st_mode) ); > + } > + > + for(i = 0; i < RTEMS_ARRAY_SIZE(files); ++i) { > + lstat(files[i].name, &st); > + rtems_test_assert( S_ISREG(st.st_mode) ); > + > + assert_file_content( > + files[i].name, > + files[i].content, > + strlen(files[i].content) > + ); > + } > +} > + > void test_untar_from_file(void) > { > int fd; > @@ -119,13 +224,105 @@ void test_untar_from_file(void) > rv = chdir( "/dest" ); > rtems_test_assert( rv == 0 ); > > - /* Untar it */ > + /* Case 1: Untar it into empty directory */ > rv = Untar_FromFile( "/test.tar" ); > printf("Untaring from file - "); > if (rv != UNTAR_SUCCESSFUL) { > printf ("error: untar failed: %i\n", rv); > exit(1); > } > + assert_content_like_expected(); > + printf ("successful\n"); > + > + /* Case 2: Most files exist */ > + rv = unlink("/dest/home/test_file"); > + rtems_test_assert( rv == 0 ); > + > + rv = Untar_FromFile( "/test.tar" ); > + printf("Untar from file into existing structure with one missing file - "); > + if (rv != UNTAR_SUCCESSFUL) { > + printf ("error: untar failed: %i\n", rv); > + exit(1); > + } > + assert_content_like_expected(); > + printf ("successful\n"); > + > + /* Case 3: An empty directory exists where a file should be */ > + rv = unlink("/dest/home/test_file"); > + rtems_test_assert( rv == 0 ); > + rv = mkdir("/dest/home/test_file", S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); > + rtems_test_assert( rv == 0 ); > + > + rv = Untar_FromFile( "/test.tar" ); > + printf("Untar from file; overwrite empty directory with file - "); > + if (rv != UNTAR_SUCCESSFUL) { > + printf ("error: untar failed: %i\n", rv); > + exit(1); > + } > + assert_content_like_expected(); > + printf ("successful\n"); > + > + /* Case 4: A file exists where a parent directory should be created */ > + rv = unlink("/dest/home/abc/def/test_script"); > + rtems_test_assert( rv == 0 ); > + rv = unlink("/dest/home/abc/def"); > + rtems_test_assert( rv == 0 ); > + rv = unlink("/dest/home/abc"); > + rtems_test_assert( rv == 0 ); > + fd = creat("/dest/home/abc", S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); > + rtems_test_assert( fd >= 0 ); > + close(fd); > + > + rv = Untar_FromFile( "/test.tar" ); > + printf("Untar from file; file exists where parent dir should be created - "); > + if (rv != UNTAR_FAIL) { > + printf ("error: untar didn't fail like expected: %i\n", rv); > + exit(1); > + } > + printf ("expected fail\n"); > + /* cleanup so that the next one works */ > + rv = unlink("/dest/home/abc"); > + rtems_test_assert( rv == 0 ); > + > + /* Case 5: A non-empty directory exists where a file should be created */ > + rv = unlink("/dest/home/test_file"); > + rtems_test_assert( rv == 0 ); > + rv = mkdir("/dest/home/test_file", S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); > + rtems_test_assert( rv == 0 ); > + fd = creat("/dest/home/test_file/file", > + S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); > + rtems_test_assert( fd >= 0 ); > + close(fd); > + > + rv = Untar_FromFile( "/test.tar" ); > + printf("Untar from file; non-empty dir where file should be created - "); > + if (rv != UNTAR_FAIL) { > + printf ("error: untar didn't fail like expected: %i\n", rv); > + exit(1); > + } > + printf ("expected fail\n"); > + /* cleanup so that the next one works */ > + rv = unlink("/dest/home/test_file/file"); > + rtems_test_assert( rv == 0 ); > + rv = unlink("/dest/home/test_file"); > + rtems_test_assert( rv == 0 ); > + > + /* Case 6: A file exists where a directory is explicitly in the archive */ > + rv = unlink("/dest/home/dir/file"); > + rtems_test_assert( rv == 0 ); > + rv = unlink("/dest/home/dir"); > + rtems_test_assert( rv == 0 ); > + fd = creat("/dest/home/dir", S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); > + rtems_test_assert( fd >= 0 ); > + close(fd); > + > + rv = Untar_FromFile( "/test.tar" ); > + printf("Untar from file; overwrite file with explicit directory - "); > + if (rv != UNTAR_SUCCESSFUL) { > + printf ("error: untar failed: %i\n", rv); > + exit(1); > + } > + assert_content_like_expected(); > printf ("successful\n"); > > /******************/ > diff --git a/testsuites/libtests/tar01/tar01.doc b/testsuites/libtests/tar01/tar01.doc > index 060f98a813..adffdca291 100644 > --- a/testsuites/libtests/tar01/tar01.doc > +++ b/testsuites/libtests/tar01/tar01.doc > @@ -20,3 +20,4 @@ directives: > concepts: > > + exercise these routines > ++ check whether existing files are overwritten or not overwritten like expected > diff --git a/testsuites/libtests/tar01/tar01.scn b/testsuites/libtests/tar01/tar01.scn > index 68fa951881..dd72f9517b 100644 > --- a/testsuites/libtests/tar01/tar01.scn > +++ b/testsuites/libtests/tar01/tar01.scn > @@ -1,9 +1,24 @@ > -*** TAR01 TEST *** > -Untaring from memory - successful > +*** BEGIN OF TEST TAR 1 *** > +*** TEST VERSION: 6.0.0.e1efb4eb8a9d6dd5f6f37dafc9feb0a9e6a888f1 > +*** TEST STATE: EXPECTED_PASS > +*** TEST BUILD: RTEMS_POSIX_API > +*** TEST TOOLS: 10.3.1 20210409 (RTEMS 6, RSB ad54d1dd3cf8249d9d39deb1dd28b2f294df062d-modified, Newlib eb03ac1) > +Untaring from memory - untar: memory at 0x11ece8 (10240) > +untar: symlink: home/test_file -> symlink > +untar: file: home/test_file (s:73,m:0644) > +untar: file: home/abc/def/test_script (s:21,m:0755) > +untar: dir: home/dir > +untar: file: home/dir/file (s:12,m:0644) > +successful > ========= /home/test_file ========= > (0)This is a test of loading an RTEMS filesystem from an > initial tar image. > > +========= /home/abc/def/test_script ========= > +(0)#! joel > +ls -las /dev > + > + /home/abc/def/test_script: mode: 0755 want: 0755 > ========= /symlink ========= > (0)This is a test of loading an RTEMS filesystem from an > initial tar image. > @@ -11,35 +26,58 @@ initial tar image. > > Copy tar image to test.tar > Untaring from file - successful > +Untar from file into existing structure with one missing file - successful > +Untar from file; overwrite empty directory with file - successful > +Untar from file; file exists where parent dir should be created - expected fail > +Untar from file; non-empty dir where file should be created - expected fail > +Untar from file; overwrite file with explicit directory - successful > ========= /dest/home/test_file ========= > (0)This is a test of loading an RTEMS filesystem from an > initial tar image. > > +========= /dest/home/abc/def/test_script ========= > +(0)#! joel > +ls -las /dev > + > + /dest/home/abc/def/test_script: mode: 0755 want: 0755 > ========= /dest/symlink ========= > (0)This is a test of loading an RTEMS filesystem from an > initial tar image. > > > -Untaring chunks from memory - untar: dir: home > -untar: file: home/test_file (73) > +Untaring chunks from memory - untar: symlink: home/test_file -> symlink > +untar: file: home/test_file (s:73,m:0644) > +untar: file: home/abc/def/test_script (s:21,m:0755) > +untar: dir: home/dir > +untar: file: home/dir/file (s:12,m:0644) > successful > ========= /dest2/home/test_file ========= > (0)This is a test of loading an RTEMS filesystem from an > initial tar image. > > +========= /dest2/home/abc/def/test_script ========= > +(0)#! joel > +ls -las /dev > + > + /dest2/home/abc/def/test_script: mode: 0755 want: 0755 > ========= /dest2/symlink ========= > (0)This is a test of loading an RTEMS filesystem from an > initial tar image. > > > -Untaring chunks from tgz- untar: dir: home > -untar: file: home/test_file (73) > -successful > +Untaring chunks from tgz - successful > ========= /dest3/home/test_file ========= > (0)This is a test of loading an RTEMS filesystem from an > initial tar image. > > +========= /dest3/home/abc/def/test_script ========= > +(0)#! joel > +ls -las /dev > + > + /dest3/home/abc/def/test_script: mode: 0755 want: 0755 > ========= /dest3/symlink ========= > (0)This is a test of loading an RTEMS filesystem from an > initial tar image. > -*** END OF TAR01 TEST *** > + > + > +*** END OF TEST TAR 1 *** > diff --git a/testsuites/libtests/tar01/tar01.tar b/testsuites/libtests/tar01/tar01.tar > index 6c6952ef183d51a9635c6ebbc8ed0443e8da1725..9874f426d15eb817f270af7dab48fce1f36be848 100644 > GIT binary patch > literal 10240 > zcmeH}-%i6I6vlhKr#QxI9dtmSz{DGGboUFc)S*yJ=`?$L>C6^qR=rsp z`}hvTjd!+w$%YJ;q9}@tv3w?S_NDAvwvlncWzL0CN at Ofg9c4!ODtI$(O>7sHb!M0) > zu4Aj4w4~*#v9YzfUihOEmBDLUucK+=(e~X&cIDAdf3I>3#2pePlCC}abIuR-=Srnx > zLTn6NXRiNzWh13eQ|B`Z6}g~GTR)Mm>3)85_duQZ;wHAnQ`H2Y8YZ^3$tsSLb;x at C > zWUeP;XoWdWPGIYQ{kWW#rus~^aoO0{_LLKK{x78L^*_tyq5pFx(scp zIT$x_k*=JMl+M8$yxarpA69SuU)p9m;NE`qKVygf=Tb6}ksNSM`=QVL{@?3A+zUJ9 > z{h!}|jEisjtC`@)|NApK;LojbF3@{uT#2+lAZH8>0w4eaAOHd&00JNY0w4eaAOHd& > V00JNY0w4eaAOHd&00LtX_yCHOyx{-< > > literal 10240 > zcmeI!-)h1z6b5jw`xIyFdh?`zpJ11}*}Ru%Q=2VqM^7F2_Dfp^QXGoV;n)`hsW~ah > z&wOdirZUUUNVhJmGmBXo`p7d6{RW-lY}|){VG$LubX8ylbi0P > z)9r#;%tlLRb-gYp72{>zRNB_G7t_kAf^jMR;)X`2YHskiRcVF%M^nEEs42)bI=A(X > zbWJa-r{`DdH-;RfGZhtWQ~8d-*49%w@^oY?y)%!&4XzDSIxkT6`PZB6GB?F|4#>8( > zAKm$pmsj+G$dcqJ_uuEhm=z9_N&Z8{afbX~PJDIc{T;nE#syC3!D%7C4?dCQt2zJN > zKsi*-*6*{ g5P$##AOHafKmY;|fB*y_009U<00Izzz^@5>0Tj at K8~^|S > > -- > 2.31.1 > > _______________________________________________ > devel mailing list > devel at rtems.org > http://lists.rtems.org/mailman/listinfo/devel From ryan.long at oarcorp.com Fri Dec 3 20:57:43 2021 From: ryan.long at oarcorp.com (Ryan Long) Date: Fri, 3 Dec 2021 15:57:43 -0500 Subject: [RTEMS 5 PATCH] devel/qemu4: Add patches so qemu4 can build Message-ID: <1638565063-7881-1-git-send-email-ryan.long@oarcorp.com> These patches add patches that fix the build issues preventing qemu4 from building on Ubuntu. Closes #4561 --- bare/config/devel/glib-2.46.2-1.cfg | 2 ++ bare/config/devel/qemu4-git-1.cfg | 2 ++ 2 files changed, 4 insertions(+) diff --git a/bare/config/devel/glib-2.46.2-1.cfg b/bare/config/devel/glib-2.46.2-1.cfg index 1dc8f78..0dda685 100644 --- a/bare/config/devel/glib-2.46.2-1.cfg +++ b/bare/config/devel/glib-2.46.2-1.cfg @@ -17,6 +17,8 @@ %patch add glib https://gaisler.se/qemu/glib-2.46.2-werror.patch %hash sha256 glib-2.46.2-werror.patch 389c00993f2890edaff6774d0dcfc7fcc99e92795ba913443fb9ec522f44a443 +%patch add glib https://gist.githubusercontent.com/roncapat/34eb82ece80ac26fd290a50dc7e85219/raw/247750ad17c31b26ef31af909fbcac05e57f71bd/glibc_2.46-2.1_rtems_5_rsb.patch + # # The GLib build instructions. We use 2.x.x Release 1. diff --git a/bare/config/devel/qemu4-git-1.cfg b/bare/config/devel/qemu4-git-1.cfg index ff241bb..479aa20 100644 --- a/bare/config/devel/qemu4-git-1.cfg +++ b/bare/config/devel/qemu4-git-1.cfg @@ -36,6 +36,8 @@ %hash sha256 qemu-4.1.0-leon3.patch \ d62ff3418903f1c5eb7f6d727af0400caeb250e23cc120111930601c9ecce02a +%patch add qemu https://gist.githubusercontent.com/roncapat/34eb82ece80ac26fd290a50dc7e85219/raw/9445c0a954e92d3323596c51b1958c7be38b1cb4/qemu_4.10_rtems_5_rsb.patch + # # The Qemu build instructions. We use 4.x.x Release 1. # -- 1.8.3.1 From ryan.long at oarcorp.com Mon Dec 6 15:08:01 2021 From: ryan.long at oarcorp.com (Ryan Long) Date: Mon, 6 Dec 2021 10:08:01 -0500 Subject: [PATCH v2] devel/dtc: Bump dtc hash to match rtems6 Message-ID: <1638803281-30987-1-git-send-email-ryan.long@oarcorp.com> Bumped dtc version to get rid of build failure for dtc. Closes #4562 --- bare/config/devel/dtc-1.6.1-1.cfg | 18 ++++++++++++++++++ bare/config/devel/dtc.bset | 2 +- rtems/config/5/rtems-moxie.bset | 2 +- 3 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 bare/config/devel/dtc-1.6.1-1.cfg diff --git a/bare/config/devel/dtc-1.6.1-1.cfg b/bare/config/devel/dtc-1.6.1-1.cfg new file mode 100644 index 0000000..54aed09 --- /dev/null +++ b/bare/config/devel/dtc-1.6.1-1.cfg @@ -0,0 +1,18 @@ +# +# DTC (Device Tree Compiler) 1.6.1 +# + +%if %{release} == %{nil} +%define release 1 +%endif + +%include %{_configdir}/base.cfg + +%define dtc_version 1.6.1 + +%hash sha256 dtc-%{dtc_version}.tar.gz 38a6257f2c23cb9dfa1781ac4ad122d8358e1a22d33b2da0eb492c190644a376 + +# +# The DTC build instructions. We use 1.x.x Release 1. +# +%include %{_configdir}/dtc-1-1.cfg diff --git a/bare/config/devel/dtc.bset b/bare/config/devel/dtc.bset index 54521f6..56fb61e 100644 --- a/bare/config/devel/dtc.bset +++ b/bare/config/devel/dtc.bset @@ -4,4 +4,4 @@ %define release 1 -devel/dtc-1.4.1-1 +devel/dtc-1.6.1-1 diff --git a/rtems/config/5/rtems-moxie.bset b/rtems/config/5/rtems-moxie.bset index 5051b85..85ced02 100644 --- a/rtems/config/5/rtems-moxie.bset +++ b/rtems/config/5/rtems-moxie.bset @@ -8,5 +8,5 @@ %define with_libgomp # Moxie needs dtc to build gdb, then pick up the rest of the set -devel/dtc-1.4.1-1 +devel/dtc-1.6.1-1 %include 5/rtems-default.bset -- 1.8.3.1 From christian.mauderer at embedded-brains.de Mon Dec 6 15:11:44 2021 From: christian.mauderer at embedded-brains.de (Christian MAUDERER) Date: Mon, 6 Dec 2021 16:11:44 +0100 Subject: [PATCH] untar: Make behavior similar to GNU or BSD tar In-Reply-To: References: <20211203125057.16329-1-christian.mauderer@embedded-brains.de> Message-ID: <6b96570e-fb98-ea77-e549-1ba5ddd95714@embedded-brains.de> Hello Joel, thanks for the review. I'll apply it on master in the next few days. The behavior that our untar can't overwrite directories is in 5 too. The behavior on 5 changed last with the patches from ticket #3823 in 2019-11. I would lean to creating a ticket for 5 and apply the patch there too. What do you think? Best regards Christian Am 03.12.21 um 18:34 schrieb Joel Sherrill: > I don't see anything that would stop this from being committed. > > This does make me realize that I think all of the untar capabilities > are undocumented. > > --joel > > On Fri, Dec 3, 2021 at 6:51 AM Christian Mauderer > wrote: >> >> RTEMS untar implementation had problems with overwriting or integrating >> archives into existing directory structures. This patch adapts the >> behavior to mimic that of a GNU tar or BSD tar and extends the tar01 >> test to check for the behavior. That is: >> >> * If a directory structure exists, the files from the archive will be >> integrated. Existing files are overwritten. >> >> * If a file exists and the archive contains a directory with the same >> name, the file is removed and a directory is created. In the above >> example: if l1/l2 is a file it will be overwritten with a new >> directory. >> >> * If a directory exists and the archive contains a file with the same >> name, the directory will be replaced if it is empty. If it contains >> files, the result is an error. >> >> * An archive also can contain only a file without the parent >> directories. If in that case one of the parent directories exists as a >> file extracting the archive results in an error. In the example: if >> l1/l2 is a file and the archive doesn't contain the directories but >> only the file l1/l2/x.txt that would be an error. >> >> * In case of an error, it is possible that the archive has been >> partially extracted. >> >> Closes #4552 >> --- >> cpukit/libmisc/untar/untar.c | 57 +++++--- >> testsuites/libtests/tar01/init.c | 199 +++++++++++++++++++++++++++- >> testsuites/libtests/tar01/tar01.doc | 1 + >> testsuites/libtests/tar01/tar01.scn | 54 ++++++-- >> testsuites/libtests/tar01/tar01.tar | Bin 10240 -> 10240 bytes >> 5 files changed, 282 insertions(+), 29 deletions(-) >> >> diff --git a/cpukit/libmisc/untar/untar.c b/cpukit/libmisc/untar/untar.c >> index a2f09fb99f..8888ab2c57 100644 >> --- a/cpukit/libmisc/untar/untar.c >> +++ b/cpukit/libmisc/untar/untar.c >> @@ -126,30 +126,25 @@ Make_Path(const rtems_printer *printer, char *path) >> >> *p = '\0'; >> if (p[1] == '\0') { >> - /* Speculatively unlink the last component so that it can be re-created */ >> - unlink(path); >> return 0; >> } >> >> if (mkdir(path, S_IRWXU | S_IRWXG | S_IRWXO) != 0) { >> - if (errno == EEXIST || errno == EISDIR) { >> + if (errno == EEXIST) { >> + /* If it exists already: Check whether it is a directory */ >> struct stat sb; >> - >> - if (stat(path, &sb) != 0) { >> + if (lstat(path, &sb) != 0) { >> + Print_Error(printer, "lstat", path); >> + return -1; >> + } else if (!S_ISDIR(sb.st_mode)) { >> + rtems_printf(printer, >> + "untar: mkdir: %s: exists but is not a directory\n", >> + path); >> return -1; >> } >> - >> - if (!S_ISDIR(sb.st_mode)) { >> - if (unlink(path) != 0) { >> - Print_Error(printer, "unlink", path); >> - return -1; >> - } >> - >> - if (mkdir(path, S_IRWXU | S_IRWXG | S_IRWXO) != 0) { >> - Print_Error(printer, "mkdir (unlink)", path); >> - return -1; >> - } >> - } >> + } else { >> + Print_Error(printer, "mkdir", path); >> + return -1; >> } >> } >> >> @@ -206,6 +201,12 @@ Untar_ProcessHeader( >> >> if (Make_Path(ctx->printer, ctx->file_path) != 0) { >> retval = UNTAR_FAIL; >> + } else { >> + /* >> + * Speculatively unlink. This should unlink everything but non-empty >> + * directories or write protected stuff. >> + */ >> + unlink(ctx->file_path); >> } >> >> if (ctx->linkflag == SYMTYPE) { >> @@ -225,8 +226,22 @@ Untar_ProcessHeader( >> rtems_printf(ctx->printer, "untar: dir: %s\n", ctx->file_path); >> r = mkdir(ctx->file_path, ctx->mode); >> if (r != 0) { >> - Print_Error(ctx->printer, "mkdir", ctx->file_path); >> - retval = UNTAR_FAIL; >> + if (errno == EEXIST) { >> + /* If it exists already: Check whether it is a directory */ >> + struct stat sb; >> + if (lstat(ctx->file_path, &sb) != 0) { >> + Print_Error(ctx->printer, "lstat", ctx->file_path); >> + retval = UNTAR_FAIL; >> + } else if (!S_ISDIR(sb.st_mode)) { >> + rtems_printf(ctx->printer, >> + "untar: mkdir: %s: exists but is not a directory\n", >> + ctx->file_path); >> + retval = UNTAR_FAIL; >> + } >> + } else { >> + Print_Error(ctx->printer, "mkdir", ctx->file_path); >> + retval = UNTAR_FAIL; >> + } >> } >> } >> >> @@ -426,7 +441,9 @@ Untar_FromFile_Print( >> */ >> >> if ((out_fd = creat(ctx.file_path, ctx.mode)) == -1) { >> - (void) lseek(fd, SEEK_CUR, 512UL * ctx.nblocks); >> + /* Couldn't create that file. Abort. */ >> + retval = UNTAR_FAIL; >> + break; >> } else { >> for (i = 0; i < ctx.nblocks; i++) { >> n = read(fd, bufr, 512); >> diff --git a/testsuites/libtests/tar01/init.c b/testsuites/libtests/tar01/init.c >> index 4cad67a6ae..2deff3a482 100644 >> --- a/testsuites/libtests/tar01/init.c >> +++ b/testsuites/libtests/tar01/init.c >> @@ -7,6 +7,33 @@ >> * http://www.rtems.org/license/LICENSE. >> */ >> >> +/* >> + * Note on the used tar file: Generate the file on a system that supports >> + * symlinks with the following commands (tested on Linux - you might have to >> + * adapt on other systems): >> + * >> + * export WORK=some_work_directory >> + * rm -r ${WORK} >> + * mkdir -p ${WORK}/home/abc/def >> + * mkdir -p ${WORK}/home/dir >> + * cd ${WORK} >> + * echo "#! joel" > home/abc/def/test_script >> + * echo "ls -las /dev" >> home/abc/def/test_script >> + * chmod 755 home/abc/def/test_script >> + * echo "This is a test of loading an RTEMS filesystem from an" > home/test_file >> + * echo "initial tar image." >> home/test_file >> + * echo "Hello world" >> home/dir/file >> + * ln -s home/test_file symlink >> + * tar cf tar01.tar --format=ustar \ >> + * symlink \ >> + * home/test_file \ >> + * home/abc/def/test_script \ >> + * home/dir >> + * >> + * Note that "home/dir" is in the archive as separate directory. "home/abc" is >> + * only in the archive as a parent of the file "test_script". >> + */ >> + >> #ifdef HAVE_CONFIG_H >> #include "config.h" >> #endif >> @@ -95,6 +122,84 @@ void test_untar_from_memory(void) >> >> } >> >> +static void assert_file_content( >> + const char *name, >> + const char *expected_content, >> + ssize_t expected_size >> +) >> +{ >> + char buf[16]; >> + int fd; >> + int rd; >> + >> + fd = open(name, O_RDONLY); >> + rtems_test_assert( fd >= 0 ); >> + do { >> + rd = read(fd, buf, sizeof(buf)); >> + rtems_test_assert( rd >= 0 ); >> + if (rd > 0) { >> + rtems_test_assert( expected_size - rd >= 0 ); >> + rtems_test_assert( memcmp(buf, expected_content, rd) == 0 ); >> + expected_content += rd; >> + expected_size -= rd; >> + } >> + } while(rd > 0); >> + rtems_test_assert( expected_size == 0 ); >> + close(fd); >> +} >> + >> +static void assert_content_like_expected(void) >> +{ >> + const char *directories[] = { >> + "home", >> + "home/abc", >> + "home/abc/def", >> + "home/dir", >> + }; >> + const char *symlinks[] = { >> + "symlink", >> + }; >> + const struct { >> + const char *name; >> + const char *content; >> + } files[] = { >> + { >> + .name = "home/abc/def/test_script", >> + .content = "#! joel\nls -las /dev\n", >> + }, { >> + .name = "home/test_file", >> + .content = "This is a test of loading an RTEMS filesystem from an\n" >> + "initial tar image.\n", >> + }, { >> + .name = "home/dir/file", >> + .content = "Hello world\n", >> + } >> + }; >> + size_t i; >> + struct stat st; >> + >> + for(i = 0; i < RTEMS_ARRAY_SIZE(directories); ++i) { >> + lstat(directories[i], &st); >> + rtems_test_assert( S_ISDIR(st.st_mode) ); >> + } >> + >> + for(i = 0; i < RTEMS_ARRAY_SIZE(symlinks); ++i) { >> + lstat(symlinks[i], &st); >> + rtems_test_assert( S_ISLNK(st.st_mode) ); >> + } >> + >> + for(i = 0; i < RTEMS_ARRAY_SIZE(files); ++i) { >> + lstat(files[i].name, &st); >> + rtems_test_assert( S_ISREG(st.st_mode) ); >> + >> + assert_file_content( >> + files[i].name, >> + files[i].content, >> + strlen(files[i].content) >> + ); >> + } >> +} >> + >> void test_untar_from_file(void) >> { >> int fd; >> @@ -119,13 +224,105 @@ void test_untar_from_file(void) >> rv = chdir( "/dest" ); >> rtems_test_assert( rv == 0 ); >> >> - /* Untar it */ >> + /* Case 1: Untar it into empty directory */ >> rv = Untar_FromFile( "/test.tar" ); >> printf("Untaring from file - "); >> if (rv != UNTAR_SUCCESSFUL) { >> printf ("error: untar failed: %i\n", rv); >> exit(1); >> } >> + assert_content_like_expected(); >> + printf ("successful\n"); >> + >> + /* Case 2: Most files exist */ >> + rv = unlink("/dest/home/test_file"); >> + rtems_test_assert( rv == 0 ); >> + >> + rv = Untar_FromFile( "/test.tar" ); >> + printf("Untar from file into existing structure with one missing file - "); >> + if (rv != UNTAR_SUCCESSFUL) { >> + printf ("error: untar failed: %i\n", rv); >> + exit(1); >> + } >> + assert_content_like_expected(); >> + printf ("successful\n"); >> + >> + /* Case 3: An empty directory exists where a file should be */ >> + rv = unlink("/dest/home/test_file"); >> + rtems_test_assert( rv == 0 ); >> + rv = mkdir("/dest/home/test_file", S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); >> + rtems_test_assert( rv == 0 ); >> + >> + rv = Untar_FromFile( "/test.tar" ); >> + printf("Untar from file; overwrite empty directory with file - "); >> + if (rv != UNTAR_SUCCESSFUL) { >> + printf ("error: untar failed: %i\n", rv); >> + exit(1); >> + } >> + assert_content_like_expected(); >> + printf ("successful\n"); >> + >> + /* Case 4: A file exists where a parent directory should be created */ >> + rv = unlink("/dest/home/abc/def/test_script"); >> + rtems_test_assert( rv == 0 ); >> + rv = unlink("/dest/home/abc/def"); >> + rtems_test_assert( rv == 0 ); >> + rv = unlink("/dest/home/abc"); >> + rtems_test_assert( rv == 0 ); >> + fd = creat("/dest/home/abc", S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); >> + rtems_test_assert( fd >= 0 ); >> + close(fd); >> + >> + rv = Untar_FromFile( "/test.tar" ); >> + printf("Untar from file; file exists where parent dir should be created - "); >> + if (rv != UNTAR_FAIL) { >> + printf ("error: untar didn't fail like expected: %i\n", rv); >> + exit(1); >> + } >> + printf ("expected fail\n"); >> + /* cleanup so that the next one works */ >> + rv = unlink("/dest/home/abc"); >> + rtems_test_assert( rv == 0 ); >> + >> + /* Case 5: A non-empty directory exists where a file should be created */ >> + rv = unlink("/dest/home/test_file"); >> + rtems_test_assert( rv == 0 ); >> + rv = mkdir("/dest/home/test_file", S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); >> + rtems_test_assert( rv == 0 ); >> + fd = creat("/dest/home/test_file/file", >> + S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); >> + rtems_test_assert( fd >= 0 ); >> + close(fd); >> + >> + rv = Untar_FromFile( "/test.tar" ); >> + printf("Untar from file; non-empty dir where file should be created - "); >> + if (rv != UNTAR_FAIL) { >> + printf ("error: untar didn't fail like expected: %i\n", rv); >> + exit(1); >> + } >> + printf ("expected fail\n"); >> + /* cleanup so that the next one works */ >> + rv = unlink("/dest/home/test_file/file"); >> + rtems_test_assert( rv == 0 ); >> + rv = unlink("/dest/home/test_file"); >> + rtems_test_assert( rv == 0 ); >> + >> + /* Case 6: A file exists where a directory is explicitly in the archive */ >> + rv = unlink("/dest/home/dir/file"); >> + rtems_test_assert( rv == 0 ); >> + rv = unlink("/dest/home/dir"); >> + rtems_test_assert( rv == 0 ); >> + fd = creat("/dest/home/dir", S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); >> + rtems_test_assert( fd >= 0 ); >> + close(fd); >> + >> + rv = Untar_FromFile( "/test.tar" ); >> + printf("Untar from file; overwrite file with explicit directory - "); >> + if (rv != UNTAR_SUCCESSFUL) { >> + printf ("error: untar failed: %i\n", rv); >> + exit(1); >> + } >> + assert_content_like_expected(); >> printf ("successful\n"); >> >> /******************/ >> diff --git a/testsuites/libtests/tar01/tar01.doc b/testsuites/libtests/tar01/tar01.doc >> index 060f98a813..adffdca291 100644 >> --- a/testsuites/libtests/tar01/tar01.doc >> +++ b/testsuites/libtests/tar01/tar01.doc >> @@ -20,3 +20,4 @@ directives: >> concepts: >> >> + exercise these routines >> ++ check whether existing files are overwritten or not overwritten like expected >> diff --git a/testsuites/libtests/tar01/tar01.scn b/testsuites/libtests/tar01/tar01.scn >> index 68fa951881..dd72f9517b 100644 >> --- a/testsuites/libtests/tar01/tar01.scn >> +++ b/testsuites/libtests/tar01/tar01.scn >> @@ -1,9 +1,24 @@ >> -*** TAR01 TEST *** >> -Untaring from memory - successful >> +*** BEGIN OF TEST TAR 1 *** >> +*** TEST VERSION: 6.0.0.e1efb4eb8a9d6dd5f6f37dafc9feb0a9e6a888f1 >> +*** TEST STATE: EXPECTED_PASS >> +*** TEST BUILD: RTEMS_POSIX_API >> +*** TEST TOOLS: 10.3.1 20210409 (RTEMS 6, RSB ad54d1dd3cf8249d9d39deb1dd28b2f294df062d-modified, Newlib eb03ac1) >> +Untaring from memory - untar: memory at 0x11ece8 (10240) >> +untar: symlink: home/test_file -> symlink >> +untar: file: home/test_file (s:73,m:0644) >> +untar: file: home/abc/def/test_script (s:21,m:0755) >> +untar: dir: home/dir >> +untar: file: home/dir/file (s:12,m:0644) >> +successful >> ========= /home/test_file ========= >> (0)This is a test of loading an RTEMS filesystem from an >> initial tar image. >> >> +========= /home/abc/def/test_script ========= >> +(0)#! joel >> +ls -las /dev >> + >> + /home/abc/def/test_script: mode: 0755 want: 0755 >> ========= /symlink ========= >> (0)This is a test of loading an RTEMS filesystem from an >> initial tar image. >> @@ -11,35 +26,58 @@ initial tar image. >> >> Copy tar image to test.tar >> Untaring from file - successful >> +Untar from file into existing structure with one missing file - successful >> +Untar from file; overwrite empty directory with file - successful >> +Untar from file; file exists where parent dir should be created - expected fail >> +Untar from file; non-empty dir where file should be created - expected fail >> +Untar from file; overwrite file with explicit directory - successful >> ========= /dest/home/test_file ========= >> (0)This is a test of loading an RTEMS filesystem from an >> initial tar image. >> >> +========= /dest/home/abc/def/test_script ========= >> +(0)#! joel >> +ls -las /dev >> + >> + /dest/home/abc/def/test_script: mode: 0755 want: 0755 >> ========= /dest/symlink ========= >> (0)This is a test of loading an RTEMS filesystem from an >> initial tar image. >> >> >> -Untaring chunks from memory - untar: dir: home >> -untar: file: home/test_file (73) >> +Untaring chunks from memory - untar: symlink: home/test_file -> symlink >> +untar: file: home/test_file (s:73,m:0644) >> +untar: file: home/abc/def/test_script (s:21,m:0755) >> +untar: dir: home/dir >> +untar: file: home/dir/file (s:12,m:0644) >> successful >> ========= /dest2/home/test_file ========= >> (0)This is a test of loading an RTEMS filesystem from an >> initial tar image. >> >> +========= /dest2/home/abc/def/test_script ========= >> +(0)#! joel >> +ls -las /dev >> + >> + /dest2/home/abc/def/test_script: mode: 0755 want: 0755 >> ========= /dest2/symlink ========= >> (0)This is a test of loading an RTEMS filesystem from an >> initial tar image. >> >> >> -Untaring chunks from tgz- untar: dir: home >> -untar: file: home/test_file (73) >> -successful >> +Untaring chunks from tgz - successful >> ========= /dest3/home/test_file ========= >> (0)This is a test of loading an RTEMS filesystem from an >> initial tar image. >> >> +========= /dest3/home/abc/def/test_script ========= >> +(0)#! joel >> +ls -las /dev >> + >> + /dest3/home/abc/def/test_script: mode: 0755 want: 0755 >> ========= /dest3/symlink ========= >> (0)This is a test of loading an RTEMS filesystem from an >> initial tar image. >> -*** END OF TAR01 TEST *** >> + >> + >> +*** END OF TEST TAR 1 *** >> diff --git a/testsuites/libtests/tar01/tar01.tar b/testsuites/libtests/tar01/tar01.tar >> index 6c6952ef183d51a9635c6ebbc8ed0443e8da1725..9874f426d15eb817f270af7dab48fce1f36be848 100644 >> GIT binary patch >> literal 10240 >> zcmeH}-%i6I6vlhKr#QxI9dtmSz{DGGboUFc)S*yJ=`?$L>C6^qR=rsp> z`}hvTjd!+w$%YJ;q9}@tv3w?S_NDAvwvlncWzL0CN at Ofg9c4!ODtI$(O>7sHb!M0) >> zu4Aj4w4~*#v9YzfUihOEmBDLUucK+=(e~X&cIDAdf3I>3#2pePlCC}abIuR-=Srnx >> zLTn6NXRiNzWh13eQ|B`Z6}g~GTR)Mm>3)85_duQZ;wHAnQ`H2Y8YZ^3$tsSLb;x at C >> zWUeP;XoWdWPGIYQ{kWW#rus~^aoO0{_LLKK{x78L^*_tyq5pFx(scp> zIT$x_k*=JMl+M8$yxarpA69SuU)p9m;NE`qKVygf=Tb6}ksNSM`=QVL{@?3A+zUJ9 >> z{h!}|jEisjtC`@)|NApK;LojbF3@{uT#2+lAZH8>0w4eaAOHd&00JNY0w4eaAOHd& >> V00JNY0w4eaAOHd&00LtX_yCHOyx{-< >> >> literal 10240 >> zcmeI!-)h1z6b5jw`xIyFdh?`zpJ11}*}Ru%Q=2VqM^7F2_Dfp^QXGoV;n)`hsW~ah >> z&wOdirZUUUNVhJmGmBXo`p7d6{RW-lY}|){VG$LubX8ylbi0P >> z)9r#;%tlLRb-gYp72{>zRNB_G7t_kAf^jMR;)X`2YHskiRcVF%M^nEEs42)bI=A(X >> zbWJa-r{`DdH-;RfGZhtWQ~8d-*49%w@^oY?y)%!&4XzDSIxkT6`PZB6GB?F|4#>8( >> zAKm$pmsj+G$dcqJ_uuEhm=z9_N&Z8{afbX~PJDIc{T;nE#syC3!D%7C4?dCQt2zJN >> zKsi*-*6*{> g5P$##AOHafKmY;|fB*y_009U<00Izzz^@5>0Tj at K8~^|S >> >> -- >> 2.31.1 >> >> _______________________________________________ >> devel mailing list >> devel at rtems.org >> http://lists.rtems.org/mailman/listinfo/devel -- -------------------------------------------- embedded brains GmbH Herr Christian MAUDERER Dornierstr. 4 82178 Puchheim Germany email: christian.mauderer at embedded-brains.de phone: +49-89-18 94 741 - 18 fax: +49-89-18 94 741 - 08 Registergericht: Amtsgericht M?nchen Registernummer: HRB 157899 Vertretungsberechtigte Gesch?ftsf?hrer: Peter Rasmussen, Thomas D?rfler Unsere Datenschutzerkl?rung finden Sie hier: https://embedded-brains.de/datenschutzerklaerung/ From joel at rtems.org Mon Dec 6 15:26:44 2021 From: joel at rtems.org (Joel Sherrill) Date: Mon, 6 Dec 2021 09:26:44 -0600 Subject: [PATCH] untar: Make behavior similar to GNU or BSD tar In-Reply-To: <6b96570e-fb98-ea77-e549-1ba5ddd95714@embedded-brains.de> References: <20211203125057.16329-1-christian.mauderer@embedded-brains.de> <6b96570e-fb98-ea77-e549-1ba5ddd95714@embedded-brains.de> Message-ID: On Mon, Dec 6, 2021 at 9:11 AM Christian MAUDERER wrote: > > Hello Joel, > > thanks for the review. I'll apply it on master in the next few days. > > The behavior that our untar can't overwrite directories is in 5 too. The > behavior on 5 changed last with the patches from ticket #3823 in > 2019-11. I would lean to creating a ticket for 5 and apply the patch > there too. What do you think? I think it is worth fixing. Go ahead. If there isn't any documentation on the untar family, please file a ticket on that. FWIW Ryan is trying to get all the tools to build on 5 so we can add it to the automated build sweep. There will likely be more patches like his dtc upgrade to allow things to build. --joel > > Best regards > > Christian > > Am 03.12.21 um 18:34 schrieb Joel Sherrill: > > I don't see anything that would stop this from being committed. > > > > This does make me realize that I think all of the untar capabilities > > are undocumented. > > > > --joel > > > > On Fri, Dec 3, 2021 at 6:51 AM Christian Mauderer > > wrote: > >> > >> RTEMS untar implementation had problems with overwriting or integrating > >> archives into existing directory structures. This patch adapts the > >> behavior to mimic that of a GNU tar or BSD tar and extends the tar01 > >> test to check for the behavior. That is: > >> > >> * If a directory structure exists, the files from the archive will be > >> integrated. Existing files are overwritten. > >> > >> * If a file exists and the archive contains a directory with the same > >> name, the file is removed and a directory is created. In the above > >> example: if l1/l2 is a file it will be overwritten with a new > >> directory. > >> > >> * If a directory exists and the archive contains a file with the same > >> name, the directory will be replaced if it is empty. If it contains > >> files, the result is an error. > >> > >> * An archive also can contain only a file without the parent > >> directories. If in that case one of the parent directories exists as a > >> file extracting the archive results in an error. In the example: if > >> l1/l2 is a file and the archive doesn't contain the directories but > >> only the file l1/l2/x.txt that would be an error. > >> > >> * In case of an error, it is possible that the archive has been > >> partially extracted. > >> > >> Closes #4552 > >> --- > >> cpukit/libmisc/untar/untar.c | 57 +++++--- > >> testsuites/libtests/tar01/init.c | 199 +++++++++++++++++++++++++++- > >> testsuites/libtests/tar01/tar01.doc | 1 + > >> testsuites/libtests/tar01/tar01.scn | 54 ++++++-- > >> testsuites/libtests/tar01/tar01.tar | Bin 10240 -> 10240 bytes > >> 5 files changed, 282 insertions(+), 29 deletions(-) > >> > >> diff --git a/cpukit/libmisc/untar/untar.c b/cpukit/libmisc/untar/untar.c > >> index a2f09fb99f..8888ab2c57 100644 > >> --- a/cpukit/libmisc/untar/untar.c > >> +++ b/cpukit/libmisc/untar/untar.c > >> @@ -126,30 +126,25 @@ Make_Path(const rtems_printer *printer, char *path) > >> > >> *p = '\0'; > >> if (p[1] == '\0') { > >> - /* Speculatively unlink the last component so that it can be re-created */ > >> - unlink(path); > >> return 0; > >> } > >> > >> if (mkdir(path, S_IRWXU | S_IRWXG | S_IRWXO) != 0) { > >> - if (errno == EEXIST || errno == EISDIR) { > >> + if (errno == EEXIST) { > >> + /* If it exists already: Check whether it is a directory */ > >> struct stat sb; > >> - > >> - if (stat(path, &sb) != 0) { > >> + if (lstat(path, &sb) != 0) { > >> + Print_Error(printer, "lstat", path); > >> + return -1; > >> + } else if (!S_ISDIR(sb.st_mode)) { > >> + rtems_printf(printer, > >> + "untar: mkdir: %s: exists but is not a directory\n", > >> + path); > >> return -1; > >> } > >> - > >> - if (!S_ISDIR(sb.st_mode)) { > >> - if (unlink(path) != 0) { > >> - Print_Error(printer, "unlink", path); > >> - return -1; > >> - } > >> - > >> - if (mkdir(path, S_IRWXU | S_IRWXG | S_IRWXO) != 0) { > >> - Print_Error(printer, "mkdir (unlink)", path); > >> - return -1; > >> - } > >> - } > >> + } else { > >> + Print_Error(printer, "mkdir", path); > >> + return -1; > >> } > >> } > >> > >> @@ -206,6 +201,12 @@ Untar_ProcessHeader( > >> > >> if (Make_Path(ctx->printer, ctx->file_path) != 0) { > >> retval = UNTAR_FAIL; > >> + } else { > >> + /* > >> + * Speculatively unlink. This should unlink everything but non-empty > >> + * directories or write protected stuff. > >> + */ > >> + unlink(ctx->file_path); > >> } > >> > >> if (ctx->linkflag == SYMTYPE) { > >> @@ -225,8 +226,22 @@ Untar_ProcessHeader( > >> rtems_printf(ctx->printer, "untar: dir: %s\n", ctx->file_path); > >> r = mkdir(ctx->file_path, ctx->mode); > >> if (r != 0) { > >> - Print_Error(ctx->printer, "mkdir", ctx->file_path); > >> - retval = UNTAR_FAIL; > >> + if (errno == EEXIST) { > >> + /* If it exists already: Check whether it is a directory */ > >> + struct stat sb; > >> + if (lstat(ctx->file_path, &sb) != 0) { > >> + Print_Error(ctx->printer, "lstat", ctx->file_path); > >> + retval = UNTAR_FAIL; > >> + } else if (!S_ISDIR(sb.st_mode)) { > >> + rtems_printf(ctx->printer, > >> + "untar: mkdir: %s: exists but is not a directory\n", > >> + ctx->file_path); > >> + retval = UNTAR_FAIL; > >> + } > >> + } else { > >> + Print_Error(ctx->printer, "mkdir", ctx->file_path); > >> + retval = UNTAR_FAIL; > >> + } > >> } > >> } > >> > >> @@ -426,7 +441,9 @@ Untar_FromFile_Print( > >> */ > >> > >> if ((out_fd = creat(ctx.file_path, ctx.mode)) == -1) { > >> - (void) lseek(fd, SEEK_CUR, 512UL * ctx.nblocks); > >> + /* Couldn't create that file. Abort. */ > >> + retval = UNTAR_FAIL; > >> + break; > >> } else { > >> for (i = 0; i < ctx.nblocks; i++) { > >> n = read(fd, bufr, 512); > >> diff --git a/testsuites/libtests/tar01/init.c b/testsuites/libtests/tar01/init.c > >> index 4cad67a6ae..2deff3a482 100644 > >> --- a/testsuites/libtests/tar01/init.c > >> +++ b/testsuites/libtests/tar01/init.c > >> @@ -7,6 +7,33 @@ > >> * http://www.rtems.org/license/LICENSE. > >> */ > >> > >> +/* > >> + * Note on the used tar file: Generate the file on a system that supports > >> + * symlinks with the following commands (tested on Linux - you might have to > >> + * adapt on other systems): > >> + * > >> + * export WORK=some_work_directory > >> + * rm -r ${WORK} > >> + * mkdir -p ${WORK}/home/abc/def > >> + * mkdir -p ${WORK}/home/dir > >> + * cd ${WORK} > >> + * echo "#! joel" > home/abc/def/test_script > >> + * echo "ls -las /dev" >> home/abc/def/test_script > >> + * chmod 755 home/abc/def/test_script > >> + * echo "This is a test of loading an RTEMS filesystem from an" > home/test_file > >> + * echo "initial tar image." >> home/test_file > >> + * echo "Hello world" >> home/dir/file > >> + * ln -s home/test_file symlink > >> + * tar cf tar01.tar --format=ustar \ > >> + * symlink \ > >> + * home/test_file \ > >> + * home/abc/def/test_script \ > >> + * home/dir > >> + * > >> + * Note that "home/dir" is in the archive as separate directory. "home/abc" is > >> + * only in the archive as a parent of the file "test_script". > >> + */ > >> + > >> #ifdef HAVE_CONFIG_H > >> #include "config.h" > >> #endif > >> @@ -95,6 +122,84 @@ void test_untar_from_memory(void) > >> > >> } > >> > >> +static void assert_file_content( > >> + const char *name, > >> + const char *expected_content, > >> + ssize_t expected_size > >> +) > >> +{ > >> + char buf[16]; > >> + int fd; > >> + int rd; > >> + > >> + fd = open(name, O_RDONLY); > >> + rtems_test_assert( fd >= 0 ); > >> + do { > >> + rd = read(fd, buf, sizeof(buf)); > >> + rtems_test_assert( rd >= 0 ); > >> + if (rd > 0) { > >> + rtems_test_assert( expected_size - rd >= 0 ); > >> + rtems_test_assert( memcmp(buf, expected_content, rd) == 0 ); > >> + expected_content += rd; > >> + expected_size -= rd; > >> + } > >> + } while(rd > 0); > >> + rtems_test_assert( expected_size == 0 ); > >> + close(fd); > >> +} > >> + > >> +static void assert_content_like_expected(void) > >> +{ > >> + const char *directories[] = { > >> + "home", > >> + "home/abc", > >> + "home/abc/def", > >> + "home/dir", > >> + }; > >> + const char *symlinks[] = { > >> + "symlink", > >> + }; > >> + const struct { > >> + const char *name; > >> + const char *content; > >> + } files[] = { > >> + { > >> + .name = "home/abc/def/test_script", > >> + .content = "#! joel\nls -las /dev\n", > >> + }, { > >> + .name = "home/test_file", > >> + .content = "This is a test of loading an RTEMS filesystem from an\n" > >> + "initial tar image.\n", > >> + }, { > >> + .name = "home/dir/file", > >> + .content = "Hello world\n", > >> + } > >> + }; > >> + size_t i; > >> + struct stat st; > >> + > >> + for(i = 0; i < RTEMS_ARRAY_SIZE(directories); ++i) { > >> + lstat(directories[i], &st); > >> + rtems_test_assert( S_ISDIR(st.st_mode) ); > >> + } > >> + > >> + for(i = 0; i < RTEMS_ARRAY_SIZE(symlinks); ++i) { > >> + lstat(symlinks[i], &st); > >> + rtems_test_assert( S_ISLNK(st.st_mode) ); > >> + } > >> + > >> + for(i = 0; i < RTEMS_ARRAY_SIZE(files); ++i) { > >> + lstat(files[i].name, &st); > >> + rtems_test_assert( S_ISREG(st.st_mode) ); > >> + > >> + assert_file_content( > >> + files[i].name, > >> + files[i].content, > >> + strlen(files[i].content) > >> + ); > >> + } > >> +} > >> + > >> void test_untar_from_file(void) > >> { > >> int fd; > >> @@ -119,13 +224,105 @@ void test_untar_from_file(void) > >> rv = chdir( "/dest" ); > >> rtems_test_assert( rv == 0 ); > >> > >> - /* Untar it */ > >> + /* Case 1: Untar it into empty directory */ > >> rv = Untar_FromFile( "/test.tar" ); > >> printf("Untaring from file - "); > >> if (rv != UNTAR_SUCCESSFUL) { > >> printf ("error: untar failed: %i\n", rv); > >> exit(1); > >> } > >> + assert_content_like_expected(); > >> + printf ("successful\n"); > >> + > >> + /* Case 2: Most files exist */ > >> + rv = unlink("/dest/home/test_file"); > >> + rtems_test_assert( rv == 0 ); > >> + > >> + rv = Untar_FromFile( "/test.tar" ); > >> + printf("Untar from file into existing structure with one missing file - "); > >> + if (rv != UNTAR_SUCCESSFUL) { > >> + printf ("error: untar failed: %i\n", rv); > >> + exit(1); > >> + } > >> + assert_content_like_expected(); > >> + printf ("successful\n"); > >> + > >> + /* Case 3: An empty directory exists where a file should be */ > >> + rv = unlink("/dest/home/test_file"); > >> + rtems_test_assert( rv == 0 ); > >> + rv = mkdir("/dest/home/test_file", S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); > >> + rtems_test_assert( rv == 0 ); > >> + > >> + rv = Untar_FromFile( "/test.tar" ); > >> + printf("Untar from file; overwrite empty directory with file - "); > >> + if (rv != UNTAR_SUCCESSFUL) { > >> + printf ("error: untar failed: %i\n", rv); > >> + exit(1); > >> + } > >> + assert_content_like_expected(); > >> + printf ("successful\n"); > >> + > >> + /* Case 4: A file exists where a parent directory should be created */ > >> + rv = unlink("/dest/home/abc/def/test_script"); > >> + rtems_test_assert( rv == 0 ); > >> + rv = unlink("/dest/home/abc/def"); > >> + rtems_test_assert( rv == 0 ); > >> + rv = unlink("/dest/home/abc"); > >> + rtems_test_assert( rv == 0 ); > >> + fd = creat("/dest/home/abc", S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); > >> + rtems_test_assert( fd >= 0 ); > >> + close(fd); > >> + > >> + rv = Untar_FromFile( "/test.tar" ); > >> + printf("Untar from file; file exists where parent dir should be created - "); > >> + if (rv != UNTAR_FAIL) { > >> + printf ("error: untar didn't fail like expected: %i\n", rv); > >> + exit(1); > >> + } > >> + printf ("expected fail\n"); > >> + /* cleanup so that the next one works */ > >> + rv = unlink("/dest/home/abc"); > >> + rtems_test_assert( rv == 0 ); > >> + > >> + /* Case 5: A non-empty directory exists where a file should be created */ > >> + rv = unlink("/dest/home/test_file"); > >> + rtems_test_assert( rv == 0 ); > >> + rv = mkdir("/dest/home/test_file", S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); > >> + rtems_test_assert( rv == 0 ); > >> + fd = creat("/dest/home/test_file/file", > >> + S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); > >> + rtems_test_assert( fd >= 0 ); > >> + close(fd); > >> + > >> + rv = Untar_FromFile( "/test.tar" ); > >> + printf("Untar from file; non-empty dir where file should be created - "); > >> + if (rv != UNTAR_FAIL) { > >> + printf ("error: untar didn't fail like expected: %i\n", rv); > >> + exit(1); > >> + } > >> + printf ("expected fail\n"); > >> + /* cleanup so that the next one works */ > >> + rv = unlink("/dest/home/test_file/file"); > >> + rtems_test_assert( rv == 0 ); > >> + rv = unlink("/dest/home/test_file"); > >> + rtems_test_assert( rv == 0 ); > >> + > >> + /* Case 6: A file exists where a directory is explicitly in the archive */ > >> + rv = unlink("/dest/home/dir/file"); > >> + rtems_test_assert( rv == 0 ); > >> + rv = unlink("/dest/home/dir"); > >> + rtems_test_assert( rv == 0 ); > >> + fd = creat("/dest/home/dir", S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); > >> + rtems_test_assert( fd >= 0 ); > >> + close(fd); > >> + > >> + rv = Untar_FromFile( "/test.tar" ); > >> + printf("Untar from file; overwrite file with explicit directory - "); > >> + if (rv != UNTAR_SUCCESSFUL) { > >> + printf ("error: untar failed: %i\n", rv); > >> + exit(1); > >> + } > >> + assert_content_like_expected(); > >> printf ("successful\n"); > >> > >> /******************/ > >> diff --git a/testsuites/libtests/tar01/tar01.doc b/testsuites/libtests/tar01/tar01.doc > >> index 060f98a813..adffdca291 100644 > >> --- a/testsuites/libtests/tar01/tar01.doc > >> +++ b/testsuites/libtests/tar01/tar01.doc > >> @@ -20,3 +20,4 @@ directives: > >> concepts: > >> > >> + exercise these routines > >> ++ check whether existing files are overwritten or not overwritten like expected > >> diff --git a/testsuites/libtests/tar01/tar01.scn b/testsuites/libtests/tar01/tar01.scn > >> index 68fa951881..dd72f9517b 100644 > >> --- a/testsuites/libtests/tar01/tar01.scn > >> +++ b/testsuites/libtests/tar01/tar01.scn > >> @@ -1,9 +1,24 @@ > >> -*** TAR01 TEST *** > >> -Untaring from memory - successful > >> +*** BEGIN OF TEST TAR 1 *** > >> +*** TEST VERSION: 6.0.0.e1efb4eb8a9d6dd5f6f37dafc9feb0a9e6a888f1 > >> +*** TEST STATE: EXPECTED_PASS > >> +*** TEST BUILD: RTEMS_POSIX_API > >> +*** TEST TOOLS: 10.3.1 20210409 (RTEMS 6, RSB ad54d1dd3cf8249d9d39deb1dd28b2f294df062d-modified, Newlib eb03ac1) > >> +Untaring from memory - untar: memory at 0x11ece8 (10240) > >> +untar: symlink: home/test_file -> symlink > >> +untar: file: home/test_file (s:73,m:0644) > >> +untar: file: home/abc/def/test_script (s:21,m:0755) > >> +untar: dir: home/dir > >> +untar: file: home/dir/file (s:12,m:0644) > >> +successful > >> ========= /home/test_file ========= > >> (0)This is a test of loading an RTEMS filesystem from an > >> initial tar image. > >> > >> +========= /home/abc/def/test_script ========= > >> +(0)#! joel > >> +ls -las /dev > >> + > >> + /home/abc/def/test_script: mode: 0755 want: 0755 > >> ========= /symlink ========= > >> (0)This is a test of loading an RTEMS filesystem from an > >> initial tar image. > >> @@ -11,35 +26,58 @@ initial tar image. > >> > >> Copy tar image to test.tar > >> Untaring from file - successful > >> +Untar from file into existing structure with one missing file - successful > >> +Untar from file; overwrite empty directory with file - successful > >> +Untar from file; file exists where parent dir should be created - expected fail > >> +Untar from file; non-empty dir where file should be created - expected fail > >> +Untar from file; overwrite file with explicit directory - successful > >> ========= /dest/home/test_file ========= > >> (0)This is a test of loading an RTEMS filesystem from an > >> initial tar image. > >> > >> +========= /dest/home/abc/def/test_script ========= > >> +(0)#! joel > >> +ls -las /dev > >> + > >> + /dest/home/abc/def/test_script: mode: 0755 want: 0755 > >> ========= /dest/symlink ========= > >> (0)This is a test of loading an RTEMS filesystem from an > >> initial tar image. > >> > >> > >> -Untaring chunks from memory - untar: dir: home > >> -untar: file: home/test_file (73) > >> +Untaring chunks from memory - untar: symlink: home/test_file -> symlink > >> +untar: file: home/test_file (s:73,m:0644) > >> +untar: file: home/abc/def/test_script (s:21,m:0755) > >> +untar: dir: home/dir > >> +untar: file: home/dir/file (s:12,m:0644) > >> successful > >> ========= /dest2/home/test_file ========= > >> (0)This is a test of loading an RTEMS filesystem from an > >> initial tar image. > >> > >> +========= /dest2/home/abc/def/test_script ========= > >> +(0)#! joel > >> +ls -las /dev > >> + > >> + /dest2/home/abc/def/test_script: mode: 0755 want: 0755 > >> ========= /dest2/symlink ========= > >> (0)This is a test of loading an RTEMS filesystem from an > >> initial tar image. > >> > >> > >> -Untaring chunks from tgz- untar: dir: home > >> -untar: file: home/test_file (73) > >> -successful > >> +Untaring chunks from tgz - successful > >> ========= /dest3/home/test_file ========= > >> (0)This is a test of loading an RTEMS filesystem from an > >> initial tar image. > >> > >> +========= /dest3/home/abc/def/test_script ========= > >> +(0)#! joel > >> +ls -las /dev > >> + > >> + /dest3/home/abc/def/test_script: mode: 0755 want: 0755 > >> ========= /dest3/symlink ========= > >> (0)This is a test of loading an RTEMS filesystem from an > >> initial tar image. > >> -*** END OF TAR01 TEST *** > >> + > >> + > >> +*** END OF TEST TAR 1 *** > >> diff --git a/testsuites/libtests/tar01/tar01.tar b/testsuites/libtests/tar01/tar01.tar > >> index 6c6952ef183d51a9635c6ebbc8ed0443e8da1725..9874f426d15eb817f270af7dab48fce1f36be848 100644 > >> GIT binary patch > >> literal 10240 > >> zcmeH}-%i6I6vlhKr#QxI9dtmSz{DGGboUFc)S*yJ=`?$L>C6^qR=rsp >> z`}hvTjd!+w$%YJ;q9}@tv3w?S_NDAvwvlncWzL0CN at Ofg9c4!ODtI$(O>7sHb!M0) > >> zu4Aj4w4~*#v9YzfUihOEmBDLUucK+=(e~X&cIDAdf3I>3#2pePlCC}abIuR-=Srnx > >> zLTn6NXRiNzWh13eQ|B`Z6}g~GTR)Mm>3)85_duQZ;wHAnQ`H2Y8YZ^3$tsSLb;x at C > >> zWUeP;XoWdWPGIYQ{kWW#rus~^aoO0{_LLKK{x78L^*_tyq5pFx(scp >> zIT$x_k*=JMl+M8$yxarpA69SuU)p9m;NE`qKVygf=Tb6}ksNSM`=QVL{@?3A+zUJ9 > >> z{h!}|jEisjtC`@)|NApK;LojbF3@{uT#2+lAZH8>0w4eaAOHd&00JNY0w4eaAOHd& > >> V00JNY0w4eaAOHd&00LtX_yCHOyx{-< > >> > >> literal 10240 > >> zcmeI!-)h1z6b5jw`xIyFdh?`zpJ11}*}Ru%Q=2VqM^7F2_Dfp^QXGoV;n)`hsW~ah > >> z&wOdirZUUUNVhJmGmBXo`p7d6{RW-lY}|){VG$LubX8ylbi0P > >> z)9r#;%tlLRb-gYp72{>zRNB_G7t_kAf^jMR;)X`2YHskiRcVF%M^nEEs42)bI=A(X > >> zbWJa-r{`DdH-;RfGZhtWQ~8d-*49%w@^oY?y)%!&4XzDSIxkT6`PZB6GB?F|4#>8( > >> zAKm$pmsj+G$dcqJ_uuEhm=z9_N&Z8{afbX~PJDIc{T;nE#syC3!D%7C4?dCQt2zJN > >> zKsi*-*6*{ >> g5P$##AOHafKmY;|fB*y_009U<00Izzz^@5>0Tj at K8~^|S > >> > >> -- > >> 2.31.1 > >> > >> _______________________________________________ > >> devel mailing list > >> devel at rtems.org > >> http://lists.rtems.org/mailman/listinfo/devel > > -- > -------------------------------------------- > embedded brains GmbH > Herr Christian MAUDERER > Dornierstr. 4 > 82178 Puchheim > Germany > email: christian.mauderer at embedded-brains.de > phone: +49-89-18 94 741 - 18 > fax: +49-89-18 94 741 - 08 > > Registergericht: Amtsgericht M?nchen > Registernummer: HRB 157899 > Vertretungsberechtigte Gesch?ftsf?hrer: Peter Rasmussen, Thomas D?rfler > Unsere Datenschutzerkl?rung finden Sie hier: > https://embedded-brains.de/datenschutzerklaerung/ From chrisj at rtems.org Tue Dec 7 04:05:06 2021 From: chrisj at rtems.org (Chris Johns) Date: Tue, 7 Dec 2021 15:05:06 +1100 Subject: [PATCH 1/1] Update rtems-notes-5.md In-Reply-To: <588cdc7938904646b939731a694dae52@dlr.de> References: <20211130150307.15090-1-gabriel.moyano@dlr.de> <20211130150307.15090-2-gabriel.moyano@dlr.de> <6f424045-6ae3-1f06-f54f-c2056b961f93@rtems.org> <588cdc7938904646b939731a694dae52@dlr.de> Message-ID: On 3/12/21 8:26 pm, Jan.Sommer at dlr.de wrote: >> -----Original Message----- >> From: Chris Johns >> Sent: Thursday, December 2, 2021 10:11 PM >> To: Sommer, Jan ; Moyano Heredia, Victor Gabriel >> ; devel at rtems.org >> Subject: Re: [PATCH 1/1] Update rtems-notes-5.md >> >> On 2/12/21 7:27 pm, Jan.Sommer at dlr.de wrote: >>>> -----Original Message----- >>>> From: devel On Behalf Of Chris Johns >>>> Sent: Thursday, December 2, 2021 2:06 AM >>>> To: Moyano Heredia, Victor Gabriel ; >>>> devel at rtems.org >>>> Subject: Re: [PATCH 1/1] Update rtems-notes-5.md >>>> >>>> OK to push. >>> >>> Should I push the addition to master, 5, or both branches? >> >> Good question, I think both. >> > > One more question: > Adding the 5.2 Release notes below the ones from 5.1 is correct? > Or do you prefer to have the newest release notes on top? I think top. Chris From chrisj at rtems.org Tue Dec 7 04:09:54 2021 From: chrisj at rtems.org (Chris Johns) Date: Tue, 7 Dec 2021 15:09:54 +1100 Subject: [PATCH rtems-tools 0/8] Convert and reformat pt. 4 In-Reply-To: <1638542879-31098-1-git-send-email-ryan.long@oarcorp.com> References: <1638542879-31098-1-git-send-email-ryan.long@oarcorp.com> Message-ID: <334bc228-36a4-722a-960c-24621685880f@rtems.org> On 4/12/21 1:47 am, Ryan Long wrote: > Hi, > > For this series of patches, I followed this series of steps: > > 1. Convert a file from the C way of doing things to C++. > 2. Go through all the files that had to do with the converted file and > make the formatting consistent. OK to push. It would be helpful in future to separate the white space changes from any code changes. Thanks Chris From chrisj at rtems.org Tue Dec 7 04:10:54 2021 From: chrisj at rtems.org (Chris Johns) Date: Tue, 7 Dec 2021 15:10:54 +1100 Subject: [PATCH] untar: Make behavior similar to GNU or BSD tar In-Reply-To: <20211203125057.16329-1-christian.mauderer@embedded-brains.de> References: <20211203125057.16329-1-christian.mauderer@embedded-brains.de> Message-ID: <5b572a4c-7b94-5440-dac2-03b529e63f02@rtems.org> On 3/12/21 11:50 pm, Christian Mauderer wrote: > RTEMS untar implementation had problems with overwriting or integrating > archives into existing directory structures. This patch adapts the > behavior to mimic that of a GNU tar or BSD tar and extends the tar01 > test to check for the behavior. That is: > > * If a directory structure exists, the files from the archive will be > integrated. Existing files are overwritten. What currently happens? > * If a file exists and the archive contains a directory with the same > name, the file is removed and a directory is created. In the above > example: if l1/l2 is a file it will be overwritten with a new > directory. OK > * If a directory exists and the archive contains a file with the same > name, the directory will be replaced if it is empty. If it contains > files, the result is an error. > > * An archive also can contain only a file without the parent > directories. If in that case one of the parent directories exists as a > file extracting the archive results in an error. In the example: if > l1/l2 is a file and the archive doesn't contain the directories but > only the file l1/l2/x.txt that would be an error. > > * In case of an error, it is possible that the archive has been > partially extracted. And what was there is not recoverable. Functionally this is not a big change and so I am left wondering why the original developer(s) did not do this? I think the changes make sense and I do not think it will break any applications I know of that use this code. Chris From christian.mauderer at embedded-brains.de Tue Dec 7 08:52:30 2021 From: christian.mauderer at embedded-brains.de (Christian MAUDERER) Date: Tue, 7 Dec 2021 09:52:30 +0100 Subject: [PATCH] untar: Make behavior similar to GNU or BSD tar In-Reply-To: <5b572a4c-7b94-5440-dac2-03b529e63f02@rtems.org> References: <20211203125057.16329-1-christian.mauderer@embedded-brains.de> <5b572a4c-7b94-5440-dac2-03b529e63f02@rtems.org> Message-ID: Hello Chris, Am 07.12.21 um 05:10 schrieb Chris Johns: > On 3/12/21 11:50 pm, Christian Mauderer wrote: >> RTEMS untar implementation had problems with overwriting or integrating >> archives into existing directory structures. This patch adapts the >> behavior to mimic that of a GNU tar or BSD tar and extends the tar01 >> test to check for the behavior. That is: >> >> * If a directory structure exists, the files from the archive will be >> integrated. Existing files are overwritten. > > What currently happens? The untar fails if a directory exists that is in the archive. Note that is mostly true if the archive contains directories and not only files. That means: If I have two example archives that look like follows: > tar tvf image-error.tar.gz drwxr-xr-x christian_m/domainusers 0 2021-11-26 15:31 l1/ drwxr-xr-x christian_m/domainusers 0 2021-11-26 14:38 l1/l2/ -rw-r--r-- christian_m/domainusers 12 2021-11-26 14:27 l1/l2/x.txt > tar tvf image-ok.tar.gz -rw-r--r-- christian_m/domainusers 12 2021-11-26 14:27 l1/l2/x.txt The first image contains the directories l1 and l1/l2 and the file l1/l2/x.txt. The second contains only the l1/l2/x.txt. With our current implementation, I would be able to extract the first archive one times and a second try would fail because l1 and l1/l2 already exist. The second archive could be extracted multiple times and would overwrite x.txt every time. > >> * If a file exists and the archive contains a directory with the same >> name, the file is removed and a directory is created. In the above >> example: if l1/l2 is a file it will be overwritten with a new >> directory. > > OK > >> * If a directory exists and the archive contains a file with the same >> name, the directory will be replaced if it is empty. If it contains >> files, the result is an error. >> >> * An archive also can contain only a file without the parent >> directories. If in that case one of the parent directories exists as a >> file extracting the archive results in an error. In the example: if >> l1/l2 is a file and the archive doesn't contain the directories but >> only the file l1/l2/x.txt that would be an error. >> >> * In case of an error, it is possible that the archive has been >> partially extracted. > > And what was there is not recoverable. > Correct. Note that I basically just tested what GNU and BSD tar do to get a reference what is "expected behavior". See https://devel.rtems.org/ticket/4552 There would be a number of other reasonable behaviors that could be considered right too. But I think the default tar utilities are a good reference. > Functionally this is not a big change and so I am left wondering why the > original developer(s) did not do this? I think the original behavior of the code in RTEMS was a bit different. I found a bug from 2019: https://devel.rtems.org/ticket/3823 The solution to that bug solved the bug but changed the behavior of tar a bit and introduced the new problem that tar can't integrate data into existing directory structures. > > I think the changes make sense and I do not think it will break any applications > I know of that use this code. Thanks for reviewing it. I'll push the patch soon. Best regards Christian > > Chris > -- -------------------------------------------- embedded brains GmbH Herr Christian MAUDERER Dornierstr. 4 82178 Puchheim Germany email: christian.mauderer at embedded-brains.de phone: +49-89-18 94 741 - 18 fax: +49-89-18 94 741 - 08 Registergericht: Amtsgericht M?nchen Registernummer: HRB 157899 Vertretungsberechtigte Gesch?ftsf?hrer: Peter Rasmussen, Thomas D?rfler Unsere Datenschutzerkl?rung finden Sie hier: https://embedded-brains.de/datenschutzerklaerung/ From ral051 at oarcorp.com Tue Dec 7 14:09:01 2021 From: ral051 at oarcorp.com (Ryan Long) Date: Tue, 7 Dec 2021 08:09:01 -0600 Subject: [PATCH rtems-tools 0/8] Convert and reformat pt. 4 In-Reply-To: <334bc228-36a4-722a-960c-24621685880f@rtems.org> References: <1638542879-31098-1-git-send-email-ryan.long@oarcorp.com> <334bc228-36a4-722a-960c-24621685880f@rtems.org> Message-ID: On 12/6/2021 10:09 PM, Chris Johns wrote: > On 4/12/21 1:47 am, Ryan Long wrote: >> Hi, >> >> For this series of patches, I followed this series of steps: >> >> 1. Convert a file from the C way of doing things to C++. >> 2. Go through all the files that had to do with the converted file and >> make the formatting consistent. > OK to push. > > It would be helpful in future to separate the white space changes from any code > changes. I guess removing "void" from an empty parameter list and adding curly brackets around if statements counts as code changes? I didn't see any whitespace changes in the code changes. Thanks, Ryan > > Thanks > Chris From sebastian.huber at embedded-brains.de Tue Dec 7 15:34:19 2021 From: sebastian.huber at embedded-brains.de (Sebastian Huber) Date: Tue, 7 Dec 2021 16:34:19 +0100 Subject: [PATCH] score: Fix _Workspace_Initialize_for_one_area() Message-ID: <20211207153419.57807-1-sebastian.huber@embedded-brains.de> In _Workspace_Initialize_for_one_area(), properly check if there is enough free memory available for the configured workspace size. The bug was introduced by commit 3d0620b607ff6459fec9d30efc1e0589bbd010f9. --- cpukit/include/rtems/score/wkspaceinitone.h | 34 ++++++++++++--------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/cpukit/include/rtems/score/wkspaceinitone.h b/cpukit/include/rtems/score/wkspaceinitone.h index c68e1b5db1..ce26a1cf8f 100644 --- a/cpukit/include/rtems/score/wkspaceinitone.h +++ b/cpukit/include/rtems/score/wkspaceinitone.h @@ -59,26 +59,29 @@ extern "C" { */ RTEMS_INLINE_ROUTINE void _Workspace_Initialize_for_one_area( void ) { - uintptr_t page_size; - uintptr_t wkspace_size; - uintptr_t wkspace_size_with_overhead; - uintptr_t available_size; + uintptr_t page_size; + uintptr_t wkspace_size; + uintptr_t wkspace_size_with_overhead; + const Memory_Information *mem; + Memory_Area *area; + uintptr_t free_size; + uintptr_t available_size; page_size = CPU_HEAP_ALIGNMENT; wkspace_size = rtems_configuration_get_work_space_size(); wkspace_size_with_overhead = wkspace_size + _Heap_Area_overhead( page_size ); - if ( wkspace_size < wkspace_size_with_overhead ) { - const Memory_Information *mem; - Memory_Area *area; - uintptr_t free_size; - uintptr_t size; + mem = _Memory_Get(); + _Assert( _Memory_Get_count( mem ) == 1 ); - mem = _Memory_Get(); - _Assert( _Memory_Get_count( mem ) == 1 ); + area = _Memory_Get_area( mem, 0 ); + free_size = _Memory_Get_free_size( area ); - area = _Memory_Get_area( mem, 0 ); - free_size = _Memory_Get_free_size( area ); + if ( + wkspace_size < wkspace_size_with_overhead && + free_size >= wkspace_size_with_overhead + ) { + uintptr_t size; if ( rtems_configuration_get_unified_work_area() ) { size = free_size; @@ -95,7 +98,10 @@ RTEMS_INLINE_ROUTINE void _Workspace_Initialize_for_one_area( void ) _Memory_Consume( area, size ); } else { - /* An unsigned integer overflow happened */ + /* + * An unsigned integer overflow happened, or the available free memory is + * not enough. + */ available_size = 0; } -- 2.26.2 From sebastian.huber at embedded-brains.de Tue Dec 7 17:07:51 2021 From: sebastian.huber at embedded-brains.de (Sebastian Huber) Date: Tue, 7 Dec 2021 18:07:51 +0100 Subject: [PATCH] score: Fix _Workspace_Initialize_for_one_area() Message-ID: <20211207170751.58787-1-sebastian.huber@embedded-brains.de> In _Workspace_Initialize_for_one_area(), properly check if there is enough free memory available for the configured workspace size. The bug was introduced by commit 3d0620b607ff6459fec9d30efc1e0589bbd010f9. --- cpukit/include/rtems/score/wkspaceinitone.h | 34 ++++++++++++--------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/cpukit/include/rtems/score/wkspaceinitone.h b/cpukit/include/rtems/score/wkspaceinitone.h index c68e1b5db1..ce26a1cf8f 100644 --- a/cpukit/include/rtems/score/wkspaceinitone.h +++ b/cpukit/include/rtems/score/wkspaceinitone.h @@ -59,26 +59,29 @@ extern "C" { */ RTEMS_INLINE_ROUTINE void _Workspace_Initialize_for_one_area( void ) { - uintptr_t page_size; - uintptr_t wkspace_size; - uintptr_t wkspace_size_with_overhead; - uintptr_t available_size; + uintptr_t page_size; + uintptr_t wkspace_size; + uintptr_t wkspace_size_with_overhead; + const Memory_Information *mem; + Memory_Area *area; + uintptr_t free_size; + uintptr_t available_size; page_size = CPU_HEAP_ALIGNMENT; wkspace_size = rtems_configuration_get_work_space_size(); wkspace_size_with_overhead = wkspace_size + _Heap_Area_overhead( page_size ); - if ( wkspace_size < wkspace_size_with_overhead ) { - const Memory_Information *mem; - Memory_Area *area; - uintptr_t free_size; - uintptr_t size; + mem = _Memory_Get(); + _Assert( _Memory_Get_count( mem ) == 1 ); - mem = _Memory_Get(); - _Assert( _Memory_Get_count( mem ) == 1 ); + area = _Memory_Get_area( mem, 0 ); + free_size = _Memory_Get_free_size( area ); - area = _Memory_Get_area( mem, 0 ); - free_size = _Memory_Get_free_size( area ); + if ( + wkspace_size < wkspace_size_with_overhead && + free_size >= wkspace_size_with_overhead + ) { + uintptr_t size; if ( rtems_configuration_get_unified_work_area() ) { size = free_size; @@ -95,7 +98,10 @@ RTEMS_INLINE_ROUTINE void _Workspace_Initialize_for_one_area( void ) _Memory_Consume( area, size ); } else { - /* An unsigned integer overflow happened */ + /* + * An unsigned integer overflow happened, or the available free memory is + * not enough. + */ available_size = 0; } -- 2.26.2 From sebastian.huber at embedded-brains.de Tue Dec 7 17:55:54 2021 From: sebastian.huber at embedded-brains.de (Sebastian Huber) Date: Tue, 7 Dec 2021 18:55:54 +0100 Subject: [PATCH] score: Fix _Workspace_Initialize_for_one_area() In-Reply-To: <20211207170751.58787-1-sebastian.huber@embedded-brains.de> References: <20211207170751.58787-1-sebastian.huber@embedded-brains.de> Message-ID: <4b7493f9-8c0b-43dc-e4e0-b04564132ce1@embedded-brains.de> On 07/12/2021 18:07, Sebastian Huber wrote: > In _Workspace_Initialize_for_one_area(), properly check if there is enough > free memory available for the configured workspace size. > > The bug was introduced by commit 3d0620b607ff6459fec9d30efc1e0589bbd010f9. Please ignore this patch. Our mail server restarted and I sent it twice. -- embedded brains GmbH Herr Sebastian HUBER Dornierstr. 4 82178 Puchheim Germany email: sebastian.huber at embedded-brains.de phone: +49-89-18 94 741 - 16 fax: +49-89-18 94 741 - 08 Registergericht: Amtsgericht M?nchen Registernummer: HRB 157899 Vertretungsberechtigte Gesch?ftsf?hrer: Peter Rasmussen, Thomas D?rfler Unsere Datenschutzerkl?rung finden Sie hier: https://embedded-brains.de/datenschutzerklaerung/ From chrisj at rtems.org Tue Dec 7 21:30:22 2021 From: chrisj at rtems.org (Chris Johns) Date: Wed, 8 Dec 2021 08:30:22 +1100 Subject: [PATCH rtems-tools 0/8] Convert and reformat pt. 4 In-Reply-To: References: <1638542879-31098-1-git-send-email-ryan.long@oarcorp.com> <334bc228-36a4-722a-960c-24621685880f@rtems.org> Message-ID: On 8/12/21 1:09 am, Ryan Long wrote: > On 12/6/2021 10:09 PM, Chris Johns wrote: >> On 4/12/21 1:47 am, Ryan Long wrote: >>> Hi, >>> >>> For this series of patches, I followed this series of steps: >>> >>> 1. Convert a file from the C way of doing things to C++. >>> 2. Go through all the files that had to do with the converted file and >>> make the formatting consistent. >> OK to push. >> >> It would be helpful in future to separate the white space changes from any code >> changes. > > I guess removing "void" from an empty parameter list and adding curly brackets > around if statements counts as code changes? Yes. > I didn't see any whitespace changes in the code changes. The following is an example: - debug.begin(executable.elf()); + debug.begin( executable.elf() ); It takes time for me to check and see if this is the same code with whitespace changes or whitespace and code changes. Chris From ryan.long at oarcorp.com Wed Dec 8 15:15:49 2021 From: ryan.long at oarcorp.com (Ryan Long) Date: Wed, 8 Dec 2021 10:15:49 -0500 Subject: [PATCH v1 1/4] TargetFactory.cc: Convert to C++ In-Reply-To: <1638976552-30164-1-git-send-email-ryan.long@oarcorp.com> References: <1638976552-30164-1-git-send-email-ryan.long@oarcorp.com> Message-ID: <1638976552-30164-2-git-send-email-ryan.long@oarcorp.com> --- tester/covoar/TargetFactory.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tester/covoar/TargetFactory.cc b/tester/covoar/TargetFactory.cc index 57ba686..fa72f05 100644 --- a/tester/covoar/TargetFactory.cc +++ b/tester/covoar/TargetFactory.cc @@ -37,7 +37,7 @@ namespace Target { //! typedef struct { //! This is the string found in configuration to match. - const char *theTarget; + std::string theTarget; //! This is the static wrapper for the constructor. TargetBase *(*theCtor)( std::string @@ -76,10 +76,10 @@ namespace Target { else cpu = targetName.substr( 0, i ); - // fprintf( stderr, "%s --> %s\n", targetName.c_str(), cpu.c_str()); + // std::cerr << targetName << " --> " << cpu << std::endl; // Iterate over the table trying to find an entry with a matching name for ( i=0 ; i < sizeof(FactoryTable) / sizeof(FactoryEntry_t); i++ ) { - if ( !strcmp(FactoryTable[i].theTarget, cpu.c_str() ) ) + if ( FactoryTable[i].theTarget == cpu ) return FactoryTable[i].theCtor( targetName ); } -- 1.8.3.1 From ryan.long at oarcorp.com Wed Dec 8 15:15:48 2021 From: ryan.long at oarcorp.com (Ryan Long) Date: Wed, 8 Dec 2021 10:15:48 -0500 Subject: [PATCH rtems-tools v1 0/4] Convert to C++ patches Message-ID: <1638976552-30164-1-git-send-email-ryan.long@oarcorp.com> Hi, For this series of patches, I - Changed char * parameters and variables to a string - Changed C functions to corresponding C++ functions - Switched C file handling out for C++ file handling Thanks, Ryan Ryan Long (4): TargetFactory.cc: Convert to C++ Target: Convert to C++ ConfigFile: Convert to C++ ObjdumpProcessor: Convert to C++ tester/covoar/ConfigFile.cc | 79 +++++++++++++++------------------------ tester/covoar/ConfigFile.h | 2 +- tester/covoar/ObjdumpProcessor.cc | 27 +++++++------ tester/covoar/ObjdumpProcessor.h | 6 +-- tester/covoar/TargetBase.cc | 35 ++++++++--------- tester/covoar/TargetBase.h | 18 ++++----- tester/covoar/TargetFactory.cc | 6 +-- tester/covoar/Target_aarch64.cc | 18 +++++---- tester/covoar/Target_aarch64.h | 6 +-- tester/covoar/Target_arm.cc | 16 ++++---- tester/covoar/Target_arm.h | 6 +-- tester/covoar/Target_i386.cc | 22 ++++++----- tester/covoar/Target_i386.h | 4 +- tester/covoar/Target_lm32.cc | 6 +-- tester/covoar/Target_lm32.h | 4 +- tester/covoar/Target_m68k.cc | 12 +++--- tester/covoar/Target_m68k.h | 6 +-- tester/covoar/Target_powerpc.cc | 8 ++-- tester/covoar/Target_powerpc.h | 4 +- tester/covoar/Target_riscv.cc | 6 +-- tester/covoar/Target_riscv.h | 6 +-- tester/covoar/Target_sparc.cc | 12 +++--- tester/covoar/Target_sparc.h | 6 +-- 23 files changed, 155 insertions(+), 160 deletions(-) -- 1.8.3.1 From ryan.long at oarcorp.com Wed Dec 8 15:15:50 2021 From: ryan.long at oarcorp.com (Ryan Long) Date: Wed, 8 Dec 2021 10:15:50 -0500 Subject: [PATCH v1 2/4] Target: Convert to C++ In-Reply-To: <1638976552-30164-1-git-send-email-ryan.long@oarcorp.com> References: <1638976552-30164-1-git-send-email-ryan.long@oarcorp.com> Message-ID: <1638976552-30164-3-git-send-email-ryan.long@oarcorp.com> --- tester/covoar/TargetBase.cc | 35 ++++++++++++++++++----------------- tester/covoar/TargetBase.h | 18 +++++++++--------- tester/covoar/Target_aarch64.cc | 18 ++++++++++-------- tester/covoar/Target_aarch64.h | 6 +++--- tester/covoar/Target_arm.cc | 16 +++++++++------- tester/covoar/Target_arm.h | 6 +++--- tester/covoar/Target_i386.cc | 22 ++++++++++++---------- tester/covoar/Target_i386.h | 4 ++-- tester/covoar/Target_lm32.cc | 6 +++--- tester/covoar/Target_lm32.h | 4 ++-- tester/covoar/Target_m68k.cc | 12 +++++++----- tester/covoar/Target_m68k.h | 6 +++--- tester/covoar/Target_powerpc.cc | 8 ++++---- tester/covoar/Target_powerpc.h | 4 ++-- tester/covoar/Target_riscv.cc | 6 +++--- tester/covoar/Target_riscv.h | 6 +++--- tester/covoar/Target_sparc.cc | 12 +++++++----- tester/covoar/Target_sparc.h | 6 +++--- 18 files changed, 103 insertions(+), 92 deletions(-) diff --git a/tester/covoar/TargetBase.cc b/tester/covoar/TargetBase.cc index 7ee45b5..a62e90f 100644 --- a/tester/covoar/TargetBase.cc +++ b/tester/covoar/TargetBase.cc @@ -40,24 +40,24 @@ namespace Target { { } - const char* TargetBase::getAddr2line() const + const std::string& TargetBase::getAddr2line() const { - return addr2line_m.c_str(); + return addr2line_m; } - const char* TargetBase::getCPU( void ) const + const std::string& TargetBase::getCPU() const { - return cpu_m.c_str(); + return cpu_m; } - const char* TargetBase::getObjdump() const + const std::string& TargetBase::getObjdump() const { - return objdump_m.c_str(); + return objdump_m; } - const char* TargetBase::getTarget( void ) const + const std::string& TargetBase::getTarget() const { - return targetName_m.c_str(); + return targetName_m; } bool TargetBase::isBranch( const std::string& instruction ) @@ -83,12 +83,13 @@ namespace Target { } bool TargetBase::isBranchLine( - const char* const line + const std::string& line ) { - #define WARNING \ - "WARNING: TargetBase::isBranchLine - (%d) " \ - "Unable to find instruction in: %s\n" + #define WARNING_PT1 \ + "WARNING: TargetBase::isBranchLine - (" + #define WARNING_PT2 \ + ") Unable to find instruction in: " const char *ch; char instruction[120]; int result; @@ -101,7 +102,7 @@ namespace Target { ch++; } if (*ch != '\t') { - fprintf( stderr, WARNING, 1, line ); + std::cerr << WARNING_PT1 << 1 << WARNING_PT2 << line << std::endl; return false; } ch++; @@ -110,7 +111,7 @@ namespace Target { while ((*ch != '\t') && (*ch != '\0')) ch++; if (*ch != '\t') { - fprintf( stderr, WARNING, 2, line) ; + std::cerr << WARNING_PT1 << 2 << WARNING_PT2 << line << std::endl; return false; } ch++; @@ -119,19 +120,19 @@ namespace Target { // after the second tab. result = sscanf( ch, "%s", instruction ); if (result != 1) { - fprintf( stderr, WARNING, 3, line ); + std::cerr << WARNING_PT1 << 3 << WARNING_PT2 << line << std::endl; return false; } return isBranch( instruction ); } - uint8_t TargetBase::qemuTakenBit(void) + uint8_t TargetBase::qemuTakenBit() { return TRACE_OP_BR0; } - uint8_t TargetBase::qemuNotTakenBit(void) + uint8_t TargetBase::qemuNotTakenBit() { return TRACE_OP_BR1; } diff --git a/tester/covoar/TargetBase.h b/tester/covoar/TargetBase.h index e5c143e..0a75c85 100644 --- a/tester/covoar/TargetBase.h +++ b/tester/covoar/TargetBase.h @@ -42,28 +42,28 @@ namespace Target { * * @return Returns the target specific addr2line program name */ - const char* getAddr2line( void ) const; + const std::string& getAddr2line() const; /*! * This method returns the CPU name. * * @return Returns the target cpu name */ - const char* getCPU( void ) const; + const std::string& getCPU() const; /*! * This method returns the program name for objdump. * * @return Returns the target specific objdump program name */ - const char* getObjdump( void ) const; + const std::string& getObjdump() const; /*! * This method returns the target name. * * @return Returns the target name */ - const char* getTarget( void ) const; + const std::string& getTarget() const; /*! * This method determines whether the specified line from a @@ -75,8 +75,8 @@ namespace Target { * @return Returns TRUE if the instruction is a nop, FALSE otherwise. */ virtual bool isNopLine( - const char* const line, - int& size + const std::string& line, + int& size ) = 0; @@ -90,7 +90,7 @@ namespace Target { * @return Returns TRUE if the instruction is a branch, FALSE otherwise. */ bool isBranchLine( - const char* const line + const std::string& line ); @@ -104,13 +104,13 @@ namespace Target { * This method returns the bit set by Qemu in the trace record * when a branch is taken. */ - virtual uint8_t qemuTakenBit(void); + virtual uint8_t qemuTakenBit(); /*! * This method returns the bit set by Qemu in the trace record * when a branch is taken. */ - virtual uint8_t qemuNotTakenBit(void); + virtual uint8_t qemuNotTakenBit(); protected: diff --git a/tester/covoar/Target_aarch64.cc b/tester/covoar/Target_aarch64.cc index 4d16456..139f5fe 100644 --- a/tester/covoar/Target_aarch64.cc +++ b/tester/covoar/Target_aarch64.cc @@ -49,31 +49,33 @@ namespace Target { } bool Target_aarch64::isNopLine( - const char* const line, - int& size + const std::string& line, + int& size ) { - if (!strcmp( &line[strlen(line)-3], "nop")) { + size_t stringLen = line.length(); + + if ( line.substr( stringLen - 3 ) == "nop" ) { size = 4; return true; } - if (!strncmp( &line[strlen(line)-6], "udf", 3)) { + if ( line.substr( stringLen - 6, 3 ) == "udf" ) { size = 4; return true; } // On ARM, there are literal tables at the end of methods. // We need to avoid them. - if (!strncmp( &line[strlen(line)-10], ".byte", 5)) { + if ( line.substr( stringLen - 10, 5 ) == ".byte" ) { size = 1; return true; } - if (!strncmp( &line[strlen(line)-13], ".short", 6)) { + if ( line.substr( stringLen - 13, 6 ) == ".short" ) { size = 2; return true; } - if (!strncmp( &line[strlen(line)-16], ".word", 5)) { + if ( line.substr( stringLen - 16, 5 ) == ".word" ) { size = 4; return true; } @@ -82,7 +84,7 @@ namespace Target { } bool Target_aarch64::isBranch( - const char* instruction + const std::string& instruction ) { throw rld::error( diff --git a/tester/covoar/Target_aarch64.h b/tester/covoar/Target_aarch64.h index fb011e8..42353e5 100644 --- a/tester/covoar/Target_aarch64.h +++ b/tester/covoar/Target_aarch64.h @@ -42,8 +42,8 @@ namespace Target { * @return Returns TRUE if the instruction is a nop, FALSE otherwise. */ virtual bool isNopLine( - const char* const line, - int& size + const std::string& line, + int& size ) override; /*! @@ -51,7 +51,7 @@ namespace Target { * objdump file is a branch instruction. */ bool isBranch( - const char* const instruction + const std::string& instruction ); /* Documentation inherited from base class */ diff --git a/tester/covoar/Target_arm.cc b/tester/covoar/Target_arm.cc index 94d50bb..50c9ce3 100644 --- a/tester/covoar/Target_arm.cc +++ b/tester/covoar/Target_arm.cc @@ -82,26 +82,28 @@ namespace Target { } bool Target_arm::isNopLine( - const char* const line, - int& size + const std::string& line, + int& size ) { - if (!strcmp( &line[strlen(line)-3], "nop")) { + size_t stringLen = line.length(); + + if ( line.substr( stringLen - 3 ) == "nop" ) { size = 4; return true; } // On ARM, there are literal tables at the end of methods. // We need to avoid them. - if (!strncmp( &line[strlen(line)-10], ".byte", 5)) { + if ( line.substr( stringLen - 10, 5 ) == ".byte" ) { size = 1; return true; } - if (!strncmp( &line[strlen(line)-13], ".short", 6)) { + if ( line.substr( stringLen - 13, 6 ) == ".short" ) { size = 2; return true; } - if (!strncmp( &line[strlen(line)-16], ".word", 5)) { + if ( line.substr( stringLen - 16, 5 ) == ".word" ) { size = 4; return true; } @@ -111,7 +113,7 @@ namespace Target { } bool Target_arm::isBranch( - const char* instruction + const std::string& instruction ) { throw rld::error( diff --git a/tester/covoar/Target_arm.h b/tester/covoar/Target_arm.h index 80b68af..3ff9b6f 100644 --- a/tester/covoar/Target_arm.h +++ b/tester/covoar/Target_arm.h @@ -42,8 +42,8 @@ namespace Target { * @return Returns TRUE if the instruction is a nop, FALSE otherwise. */ bool isNopLine( - const char* const line, - int& size + const std::string& line, + int& size ); /*! @@ -51,7 +51,7 @@ namespace Target { * objdump file is a branch instruction. */ bool isBranch( - const char* const instruction + const std::string& instruction ); private: diff --git a/tester/covoar/Target_i386.cc b/tester/covoar/Target_i386.cc index 2990273..cb8e64d 100644 --- a/tester/covoar/Target_i386.cc +++ b/tester/covoar/Target_i386.cc @@ -57,39 +57,41 @@ namespace Target { } bool Target_i386::isNopLine( - const char* const line, - int& size + const std::string& line, + int& size ) { - if (!strcmp( &line[strlen(line)-3], "nop")) { + size_t stringLen = line.length(); + + if ( line.substr( stringLen - 3 ) == "nop" ) { size = 1; return true; } // i386 has some two and three byte nops - if (!strncmp( &line[strlen(line)-14], "xchg %ax,%ax", 14)) { + if ( line.substr( stringLen - 14 ) == "xchg %ax,%ax" ) { size = 2; return true; } - if (!strncmp( &line[strlen(line)-16], "xor %eax,%eax", 16)) { + if ( line.substr( stringLen - 16 ) == "xor %eax,%eax" ) { size = 2; return true; } - if (!strncmp( &line[strlen(line)-16], "xor %ebx,%ebx", 16)) { + if ( line.substr( stringLen - 16 ) == "xor %ebx,%ebx" ) { size = 2; return true; } - if (!strncmp( &line[strlen(line)-16], "xor %esi,%esi", 16)) { + if ( line.substr( stringLen - 16 ) == "xor %esi,%esi" ) { size = 2; return true; } - if (!strncmp( &line[strlen(line)-21], "lea 0x0(%esi),%esi", 21)) { + if ( line.substr( stringLen - 21 ) == "lea 0x0(%esi),%esi" ) { size = 3; return true; } - if (!strncmp( &line[strlen(line)-28], "lea 0x0(%esi,%eiz,1),%esi", 28)) { + if ( line.substr( stringLen - 28 ) == "lea 0x0(%esi,%eiz,1),%esi" ) { // Could be 4 or 7 bytes of padding. - if (!strncmp( &line[strlen(line)-32], "00", 2)) { + if ( line.substr( stringLen - 32, 2 ) == "00" ) { size = 7; } else { size = 4; diff --git a/tester/covoar/Target_i386.h b/tester/covoar/Target_i386.h index 3641de7..c9a79cd 100644 --- a/tester/covoar/Target_i386.h +++ b/tester/covoar/Target_i386.h @@ -43,8 +43,8 @@ namespace Target { * @return Returns TRUE if the instruction is a nop, FALSE otherwise. */ bool isNopLine( - const char* const line, - int& size + const std::string& line, + int& size ); /* Documentation inherited from base class */ diff --git a/tester/covoar/Target_lm32.cc b/tester/covoar/Target_lm32.cc index 18e7191..7babbd2 100644 --- a/tester/covoar/Target_lm32.cc +++ b/tester/covoar/Target_lm32.cc @@ -30,11 +30,11 @@ namespace Target { } bool Target_lm32::isNopLine( - const char* const line, - int& size + const std::string& line, + int& size ) { - if (!strcmp( &line[strlen(line)-3], "nop")) { + if ( line.substr( line.length() - 3 ) == "nop" ) { size = 4; return true; } diff --git a/tester/covoar/Target_lm32.h b/tester/covoar/Target_lm32.h index 5d23db5..d21776e 100644 --- a/tester/covoar/Target_lm32.h +++ b/tester/covoar/Target_lm32.h @@ -43,8 +43,8 @@ namespace Target { * @return Returns TRUE if the instruction is a nop, FALSE otherwise. */ bool isNopLine( - const char* const line, - int& size + const std::string& line, + int& size ); private: diff --git a/tester/covoar/Target_m68k.cc b/tester/covoar/Target_m68k.cc index 536ae80..7c761be 100644 --- a/tester/covoar/Target_m68k.cc +++ b/tester/covoar/Target_m68k.cc @@ -77,11 +77,13 @@ namespace Target { } bool Target_m68k::isNopLine( - const char* const line, - int& size + const std::string& line, + int& size ) { - if (!strcmp( &line[strlen(line)-3], "nop")) { + size_t stringLen = line.length(); + + if ( line.substr( stringLen - 3 ) == "nop" ) { size = 2; return true; } @@ -89,7 +91,7 @@ namespace Target { #define GNU_LD_FILLS_ALIGNMENT_WITH_RTS #if defined(GNU_LD_FILLS_ALIGNMENT_WITH_RTS) // Until binutils 2.20, binutils would fill with rts not nop - if (!strcmp( &line[strlen(line)-3], "rts")) { + if ( line.substr( stringLen - 3 ) == "rts" ) { size = 4; return true; } @@ -99,7 +101,7 @@ namespace Target { } bool Target_m68k::isBranch( - const char* const instruction + const std::string& instruction ) { throw rld::error( diff --git a/tester/covoar/Target_m68k.h b/tester/covoar/Target_m68k.h index 5ed7933..13a6030 100644 --- a/tester/covoar/Target_m68k.h +++ b/tester/covoar/Target_m68k.h @@ -43,8 +43,8 @@ namespace Target { * @return Returns TRUE if the instruction is a nop, FALSE otherwise. */ bool isNopLine( - const char* const line, - int& size + const std::string& line, + int& size ); /*! @@ -52,7 +52,7 @@ namespace Target { * objdump file is a branch instruction. */ bool isBranch( - const char* const instruction + const std::string& instruction ); /* Documentation inherited from base class */ diff --git a/tester/covoar/Target_powerpc.cc b/tester/covoar/Target_powerpc.cc index c62feb0..6cc541d 100644 --- a/tester/covoar/Target_powerpc.cc +++ b/tester/covoar/Target_powerpc.cc @@ -58,11 +58,11 @@ namespace Target { } bool Target_powerpc::isNopLine( - const char* const line, - int& size + const std::string& line, + int& size ) { - if (!strcmp( &line[strlen(line)-3], "nop")) { + if ( line.substr( line.length() - 3 ) == "nop" ) { size = 4; return true; } @@ -71,7 +71,7 @@ namespace Target { } bool Target_powerpc::isBranch( - const char* const instruction + const std::string& instruction ) { throw rld::error( diff --git a/tester/covoar/Target_powerpc.h b/tester/covoar/Target_powerpc.h index 3008d4c..b446918 100644 --- a/tester/covoar/Target_powerpc.h +++ b/tester/covoar/Target_powerpc.h @@ -43,7 +43,7 @@ namespace Target { * @return Returns TRUE if the instruction is a nop, FALSE otherwise. */ bool isNopLine( - const char* const line, + const std::string& line, int& size ); @@ -52,7 +52,7 @@ namespace Target { * objdump file is a branch instruction. */ bool isBranch( - const char* const instruction + const std::string& instruction ); private: diff --git a/tester/covoar/Target_riscv.cc b/tester/covoar/Target_riscv.cc index 13c81c5..d0b5a8e 100644 --- a/tester/covoar/Target_riscv.cc +++ b/tester/covoar/Target_riscv.cc @@ -62,11 +62,11 @@ namespace Target { } bool Target_riscv::isNopLine( - const char* const line, - int& size + const std::string& line, + int& size ) { - if (!strcmp( &line[strlen(line)-3], "nop")){ + if ( line.substr( line.length() - 3 ) == "nop" ) { size = 4; return true; } diff --git a/tester/covoar/Target_riscv.h b/tester/covoar/Target_riscv.h index 64a63d4..1442f69 100644 --- a/tester/covoar/Target_riscv.h +++ b/tester/covoar/Target_riscv.h @@ -67,8 +67,8 @@ namespace Target { * @return Returns True if the instruction is nop, False otherwise. */ bool isNopLine( - const char* const line, - int& size + const std::string& line, + int& size ); /*! @@ -80,7 +80,7 @@ namespace Target { */ bool isBranch( - const char* const instruction + const std::string& instruction ); private: diff --git a/tester/covoar/Target_sparc.cc b/tester/covoar/Target_sparc.cc index fbdcd1e..a9435cb 100644 --- a/tester/covoar/Target_sparc.cc +++ b/tester/covoar/Target_sparc.cc @@ -56,23 +56,25 @@ namespace Target { } bool Target_sparc::isNopLine( - const char* const line, - int& size + const std::string& line, + int& size ) { - if (!strcmp( &line[strlen(line)-3], "nop")) { + size_t stringLen = line.length(); + + if ( line.substr( stringLen - 3 ) == "nop" ) { size = 4; return true; } - if (!strcmp( &line[strlen(line)-7], "unknown")) { + if ( line.substr( stringLen - 7 ) == "unknown" ) { size = 4; return true; } #define GNU_LD_FILLS_ALIGNMENT_WITH_RTS #if defined(GNU_LD_FILLS_ALIGNMENT_WITH_RTS) // Until binutils 2.20, binutils would fill with rts not nop - if (!strcmp( &line[strlen(line)-3], "rts")) { + if ( line.substr( stringLen - 3 ) == "rts" ) { size = 4; return true; } diff --git a/tester/covoar/Target_sparc.h b/tester/covoar/Target_sparc.h index 0e38859..cbe2faf 100644 --- a/tester/covoar/Target_sparc.h +++ b/tester/covoar/Target_sparc.h @@ -43,8 +43,8 @@ namespace Target { * @return Returns TRUE if the instruction is a nop, FALSE otherwise. */ bool isNopLine( - const char* const line, - int& size + const std::string& line, + int& size ); /*! @@ -52,7 +52,7 @@ namespace Target { * objdump file is a branch instruction. */ bool isBranch( - const char* const instruction + const std::string& instruction ); private: -- 1.8.3.1 From ryan.long at oarcorp.com Wed Dec 8 15:15:52 2021 From: ryan.long at oarcorp.com (Ryan Long) Date: Wed, 8 Dec 2021 10:15:52 -0500 Subject: [PATCH v1 4/4] ObjdumpProcessor: Convert to C++ In-Reply-To: <1638976552-30164-1-git-send-email-ryan.long@oarcorp.com> References: <1638976552-30164-1-git-send-email-ryan.long@oarcorp.com> Message-ID: <1638976552-30164-5-git-send-email-ryan.long@oarcorp.com> --- tester/covoar/ObjdumpProcessor.cc | 27 +++++++++++++++------------ tester/covoar/ObjdumpProcessor.h | 6 +++--- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/tester/covoar/ObjdumpProcessor.cc b/tester/covoar/ObjdumpProcessor.cc index c910046..8c0e8dc 100644 --- a/tester/covoar/ObjdumpProcessor.cc +++ b/tester/covoar/ObjdumpProcessor.cc @@ -13,6 +13,8 @@ #include #include #include +#include +#include #include "ObjdumpProcessor.h" #include "CoverageMap.h" @@ -139,8 +141,7 @@ namespace Coverage { ) { #define METHOD "ERROR: ObjdumpProcessor::determineLoadAddress - " - FILE* loadAddressFile = NULL; - char* cStatus; + std::ifstream loadAddressFile; uint32_t offset; char inputBuffer[MAX_LINE_LENGTH]; @@ -155,8 +156,8 @@ namespace Coverage { dlinfoName += ".dlinfo"; // Read load address. - loadAddressFile = ::fopen( dlinfoName.c_str(), "r" ); - if (!loadAddressFile) { + loadAddressFile.open( dlinfoName ); + if (!loadAddressFile.is_open()) { std::ostringstream what; what << "Unable to open " << dlinfoName; throw rld::error( what, METHOD ); @@ -166,9 +167,9 @@ namespace Coverage { while ( 1 ) { // Get a line. - cStatus = ::fgets( inputBuffer, MAX_LINE_LENGTH, loadAddressFile ); - if (cStatus == NULL) { - ::fclose( loadAddressFile ); + loadAddressFile.getline( inputBuffer, MAX_LINE_LENGTH ); + if ( loadAddressFile.fail() && loadAddressFile.is_open() ) { + loadAddressFile.close(); std::ostringstream what; what << "library " << Library << " not found in " << dlinfoName; throw rld::error( what, METHOD ); @@ -176,13 +177,15 @@ namespace Coverage { sscanf( inputBuffer, "%s %x", inLibName, &offset ); std::string tmp = inLibName; if ( tmp.find( Library ) != tmp.npos ) { - // fprintf( stderr, "%s - 0x%08x\n", inLibName, offset ); + // std::cerr << inLibName << " - 0x" + // << std::setfill( '0' ) << std::setw( 8 ) << std::hex + // << offset << std::endl + // << std::dec << std::setfill( ' ' ); address = offset; break; } } - ::fclose( loadAddressFile ); return address; #undef METHOD @@ -203,7 +206,7 @@ namespace Coverage { } bool ObjdumpProcessor::isBranchLine( - const char* const line + const std::string& line ) { if ( !targetInfo_m ) { @@ -219,8 +222,8 @@ namespace Coverage { } bool ObjdumpProcessor::isNop( - const char* const line, - int& size + const std::string& line, + int& size ) { if ( !targetInfo_m ){ diff --git a/tester/covoar/ObjdumpProcessor.h b/tester/covoar/ObjdumpProcessor.h index 05a667f..0ca14b8 100644 --- a/tester/covoar/ObjdumpProcessor.h +++ b/tester/covoar/ObjdumpProcessor.h @@ -151,7 +151,7 @@ namespace Coverage { * otherwise it returns false. */ bool isBranchLine( - const char* const line + const std::string& line ); /*! @@ -179,8 +179,8 @@ namespace Coverage { * @return Returns TRUE if the instruction is a nop, FALSE otherwise. */ bool isNop( - const char* const line, - int& size + const std::string& line, + int& size ); /*! -- 1.8.3.1 From ryan.long at oarcorp.com Wed Dec 8 15:15:51 2021 From: ryan.long at oarcorp.com (Ryan Long) Date: Wed, 8 Dec 2021 10:15:51 -0500 Subject: [PATCH v1 3/4] ConfigFile: Convert to C++ In-Reply-To: <1638976552-30164-1-git-send-email-ryan.long@oarcorp.com> References: <1638976552-30164-1-git-send-email-ryan.long@oarcorp.com> Message-ID: <1638976552-30164-4-git-send-email-ryan.long@oarcorp.com> --- tester/covoar/ConfigFile.cc | 79 +++++++++++++++++---------------------------- tester/covoar/ConfigFile.h | 2 +- 2 files changed, 31 insertions(+), 50 deletions(-) diff --git a/tester/covoar/ConfigFile.cc b/tester/covoar/ConfigFile.cc index c16b64a..5c8949e 100644 --- a/tester/covoar/ConfigFile.cc +++ b/tester/covoar/ConfigFile.cc @@ -10,6 +10,10 @@ #include #include +#include +#include +#include + namespace Configuration { FileReader::FileReader( @@ -24,43 +28,40 @@ namespace Configuration { } bool FileReader::processFile( - const char* const file + const std::string& file ) { #define METHOD "FileReader::processFile - " - FILE * in; - char line[256]; - char option[256]; - char value[256]; + #define MAX_LENGTH 256 + std::ifstream in; + std::string line; + char option[MAX_LENGTH]; + char value[MAX_LENGTH]; int line_no; int i; int j; - if ( file == NULL ) { - fprintf( stderr, METHOD "NULL filename\n" ); + if ( file.empty() ) { + std::cerr << METHOD << "Empty filename" << std::endl; return false; } - in = fopen( file, "r" ); - if ( !in ) { - fprintf( stderr, METHOD "unable to open %s\n", file ); + in.open( file ); + if ( !in.is_open() ) { + std::cerr << METHOD << "unable to open " << file << std::endl; return false; } line_no = 0; - while (fgets(line, sizeof(line), in) != NULL) { + while ( std::getline( line, MAX_LENGTH ) ) { int length; line_no++; - length = (int) strlen( line ); - if ( line[length - 1] != '\n' ) { - fprintf( - stderr, - "%s: line %d is too long", - file, - line_no - ); + length = (int) line.length(); + if ( length > MAX_LENGTH ) { + std::cerr << file << ": line " << line_no << " is too long" + << std::endl; continue; } @@ -96,14 +97,9 @@ namespace Configuration { if (line[0] == '\0') continue; - if (sscanf(line, "%s", option) != 1) { - fprintf( - stderr, - "%s: line %d is invalid: %s\n", - file, - line_no, - line - ); + if (sscanf(line.c_str(), "%s", option) != 1) { + std::cerr << file << ": line" << line_no << " is invalid: " << line + << std::endl; continue; } @@ -111,13 +107,8 @@ namespace Configuration { ; if (i == length) { - fprintf( - stderr, - "%s: line %d is invalid: %s\n", - file, - line_no, - line - ); + std::cerr << file << ": line" << line_no << " is invalid: " << line + << std::endl; continue; } @@ -129,24 +120,14 @@ namespace Configuration { value[j] = line[i]; value[j] = '\0'; if (value[0] == '\0') { - fprintf( - stderr, - "%s: line %d is invalid: %s\n", - file, - line_no, - line - ); + std::cerr << file << ": line" << line_no << " is invalid: " << line + << std::endl; continue; } if ( !setOption(option, value) ) { - fprintf( - stderr, - "%s: line %d: option %s is unknown\n", - file, - line_no, - option - ); + std::cerr << file << ": line" << line_no << " is invalid: " << line + << std::endl; continue; } @@ -190,7 +171,7 @@ namespace Configuration { Options_t *o; for ( o=options_m ; o->option ; o++ ) { - fprintf( stderr, "(%s)=(%s)\n", o->option, o->value ); + std::cerr << '(' << o->option << ")=(" << o->value << ')' << std::endl; } } } diff --git a/tester/covoar/ConfigFile.h b/tester/covoar/ConfigFile.h index 0bae7ac..f8bd9c5 100644 --- a/tester/covoar/ConfigFile.h +++ b/tester/covoar/ConfigFile.h @@ -54,7 +54,7 @@ namespace Configuration { * @return Returns TRUE if the method succeeded and FALSE if it failed. */ virtual bool processFile( - const char* const file + const std::string& file ); bool setOption( -- 1.8.3.1 From ral051 at oarcorp.com Wed Dec 8 15:29:27 2021 From: ral051 at oarcorp.com (Ryan Long) Date: Wed, 8 Dec 2021 09:29:27 -0600 Subject: [rtems-tools] tester: Update jobs configuration In-Reply-To: References: <1634760357-27539-1-git-send-email-ryan.long@oarcorp.com> Message-ID: ping On 11/1/2021 5:31 PM, Ryan Long wrote: > ping > > -----Original Message----- > From: Ryan Long > Sent: Wednesday, October 20, 2021 3:06 PM > To: devel at rtems.org > Cc: Ryan Long > Subject: [rtems-tools] tester: Update jobs configuration > > Allow for default_jobs and max_jobs to be specified in the BSP's configuration file. > --- > rtemstoolkit/options.py | 45 +++++++++++++--------- > tester/rtems/testing/bsps/beagleboardxm.ini | 2 +- > tester/rtems/testing/bsps/beagleboneblack.ini | 2 +- > tester/rtems/testing/bsps/imx7.ini | 2 +- > tester/rtems/testing/bsps/mcf5235.ini | 2 +- > tester/rtems/testing/bsps/mvme2307.ini | 2 +- > tester/rtems/testing/bsps/pc.ini | 2 +- > tester/rtems/testing/bsps/qoriq_e500.ini | 2 +- > tester/rtems/testing/bsps/qoriq_e6500_32.ini | 2 +- > tester/rtems/testing/bsps/qoriq_e6500_64.ini | 2 +- > tester/rtems/testing/bsps/raspberrypi2.ini | 2 +- > tester/rtems/testing/bsps/xilinx_versal_vck190.ini | 2 +- .../rtems/testing/bsps/xilinx_zynq_a9_qemu_smp.ini | 2 +- > tester/rtems/testing/bsps/xilinx_zynq_zc706.ini | 2 +- > tester/rtems/testing/bsps/xilinx_zynq_zedboard.ini | 2 +- > .../testing/bsps/xilinx_zynqmp_ilp32_zu3eg.ini | 2 +- > .../testing/bsps/xilinx_zynqmp_lp64_zu3eg.ini | 2 +- > tester/rtems/testing/defaults.mc | 2 + > 18 files changed, 45 insertions(+), 34 deletions(-) > > diff --git a/rtemstoolkit/options.py b/rtemstoolkit/options.py index 5ebe3bc..4b7a93a 100644 > --- a/rtemstoolkit/options.py > +++ b/rtemstoolkit/options.py > @@ -102,7 +102,7 @@ class command_line(object): > '--no-clean': 'Do not clean up the build tree', > '--always-clean': 'Always clean the build tree, even with an error', > '--keep-going': 'Do not stop on an error.', > - '--jobs=[0..n,none,half,full]': 'Run with specified number of jobs, default: num CPUs.', > + '--jobs=[0..n,none,half,full]': 'Run with specified number > + of jobs (default: defined in configuration file)', > '--macros file[,file]': 'Macro format files to load after the defaults', > '--log file': 'Log file where all build output is written to', > } > @@ -327,6 +327,11 @@ class command_line(object): > # Handle the jobs for make > if '_ncpus' not in self.defaults: > raise error.general('host number of CPUs not set') > + if self.defaults['default_jobs'] != '0': > + print( > + 'default_jobs is %d and the default is %d' % > + (self.defaults['default_jobs'], 0) > + ) > ncpus = self.jobs(self.defaults['_ncpus']) > if ncpus > 1: > self.defaults['_smp_mflags'] = '-j %d' % (ncpus) @@ -427,28 +432,25 @@ class command_line(object): > um += [m] > return um if len(um) else None > > - def jobs(self, cpus): > + def jobs(self, num_cpus): > try: > - cpus = int(cpus) > + cpus = int(num_cpus) > except: > raise error.general('invalid host cpu value') > opt_jobs = self.opts['jobs'] > if opt_jobs == 'default': > - _jobs = self.defaults.get_value('jobs') > - if _jobs is not None: > - if _jobs == 'none': > - cpus = 0 > - elif _jobs == 'max': > - pass > - elif _jobs == 'half': > - cpus = cpus / 2 > - else: > - try: > - cpus = int(_jobs) > - except: > - raise error.general('invalid %%{jobs} value: %s' % (_jobs)) > + _jobs = self.defaults.get_value('default_jobs') > + if _jobs == 'none': > + cpus = 0 > + elif _jobs == 'max': > + pass > + elif _jobs == 'half': > + cpus = cpus / 2 > else: > - opt_jobs = 'max' > + try: > + cpus = int(_jobs) > + except: > + raise error.general('invalid %%{jobs} value: %s' % > + (_jobs)) > if opt_jobs != 'default': > if opt_jobs == 'none': > cpus = 0 > @@ -474,7 +476,14 @@ class command_line(object): > if not ok: > raise error.internal('bad jobs option: %s' % (opt_jobs)) > if cpus <= 0: > - cpu = 1 > + cpus = 1 > + max_jobs = int(self.defaults.get_value('max_jobs')) > + if max_jobs == 0: > + max_jobs = cpus > + if cpus > max_jobs: > + raise error.internal( > + 'exceeded maximum number of jobs: %d > %d' % (cpus, max_jobs) > + ) > return cpus > > def params(self): > diff --git a/tester/rtems/testing/bsps/beagleboardxm.ini b/tester/rtems/testing/bsps/beagleboardxm.ini > index e8a79a6..72e6e8f 100644 > --- a/tester/rtems/testing/bsps/beagleboardxm.ini > +++ b/tester/rtems/testing/bsps/beagleboardxm.ini > @@ -36,7 +36,7 @@ > [beagleboardxm] > bsp = beagleboardxm > arch = arm > -jobs = 1 > +max_jobs = 1 > tester = %{_rtscripts}/gdb.cfg > gdb_script = bsp_gdb_script > requires = bsp_tty_dev, bsp_gdb_script > diff --git a/tester/rtems/testing/bsps/beagleboneblack.ini b/tester/rtems/testing/bsps/beagleboneblack.ini > index 4bf850f..346d859 100644 > --- a/tester/rtems/testing/bsps/beagleboneblack.ini > +++ b/tester/rtems/testing/bsps/beagleboneblack.ini > @@ -35,7 +35,7 @@ > [beagleboneblack] > bsp = beagleboneblack > arch = arm > -jobs = 1 > +max_jobs = 1 > tester = %{_rtscripts}/tftp.cfg > test_restarts = 3 > target_reset_regex = ^No ethernet found.*|BOOTP broadcast 6.*|^ERROR: can.t get kernel image diff --git a/tester/rtems/testing/bsps/imx7.ini b/tester/rtems/testing/bsps/imx7.ini > index 0a56ba8..28dd77f 100644 > --- a/tester/rtems/testing/bsps/imx7.ini > +++ b/tester/rtems/testing/bsps/imx7.ini > @@ -35,7 +35,7 @@ > [imx7] > bsp = imx7 > arch = arm > -jobs = 1 > +max_jobs = 1 > tester = %{_rtscripts}/tftp.cfg > test_restarts = 3 > target_start_regex = Hit any key to stop autoboot: > diff --git a/tester/rtems/testing/bsps/mcf5235.ini b/tester/rtems/testing/bsps/mcf5235.ini > index 00f6a26..5023275 100644 > --- a/tester/rtems/testing/bsps/mcf5235.ini > +++ b/tester/rtems/testing/bsps/mcf5235.ini > @@ -34,6 +34,6 @@ > [mcf5235] > bsp = mcf5235 > arch = m68k > -jobs = 1 > +max_jobs = 1 > tester = %{_rtscripts}/gdb.cfg > requires = bsp_tty_dev, gdb_script > diff --git a/tester/rtems/testing/bsps/mvme2307.ini b/tester/rtems/testing/bsps/mvme2307.ini > index b142aa9..bb7e15f 100644 > --- a/tester/rtems/testing/bsps/mvme2307.ini > +++ b/tester/rtems/testing/bsps/mvme2307.ini > @@ -52,7 +52,7 @@ > [mvme2307] > bsp = mvme2307 > arch = powerpc > -jobs = 1 > +max_jobs = 1 > test_restarts = 3 > tester = %{_rtscripts}/wait.cfg > target_start_regex = ^Copyright Motorola Inc.*, All Rights Reserved diff --git a/tester/rtems/testing/bsps/pc.ini b/tester/rtems/testing/bsps/pc.ini > index 93a5dae..5f81336 100644 > --- a/tester/rtems/testing/bsps/pc.ini > +++ b/tester/rtems/testing/bsps/pc.ini > @@ -31,7 +31,7 @@ > [pc] > bsp = pc686 > arch = i386 > -jobs = 1 > +max_jobs = 1 > tester = %{_rtscripts}/tftp.cfg > test_restarts = 3 > requires = bsp_tty_dev, target_on_command, target_off_command, target_reset_command > diff --git a/tester/rtems/testing/bsps/qoriq_e500.ini b/tester/rtems/testing/bsps/qoriq_e500.ini > index 322069b..1756bcd 100644 > --- a/tester/rtems/testing/bsps/qoriq_e500.ini > +++ b/tester/rtems/testing/bsps/qoriq_e500.ini > @@ -35,7 +35,7 @@ > [qoriq_e500] > bsp = qoriq_e500 > arch = powerpc > -jobs = 1 > +max_jobs = 1 > tester = %{_rtscripts}/tftp.cfg > test_restarts = 3 > target_start_regex = U-Boot > diff --git a/tester/rtems/testing/bsps/qoriq_e6500_32.ini b/tester/rtems/testing/bsps/qoriq_e6500_32.ini > index 26ee3ae..daf564e 100644 > --- a/tester/rtems/testing/bsps/qoriq_e6500_32.ini > +++ b/tester/rtems/testing/bsps/qoriq_e6500_32.ini > @@ -36,7 +36,7 @@ > [qoriq_e6500_32] > bsp = qoriq_e6500_32 > arch = powerpc > -jobs = 1 > +max_jobs = 1 > tester = %{_rtscripts}/tftp.cfg > test_restarts = 3 > target_start_regex = U-Boot > diff --git a/tester/rtems/testing/bsps/qoriq_e6500_64.ini b/tester/rtems/testing/bsps/qoriq_e6500_64.ini > index c9b6ab7..e507032 100644 > --- a/tester/rtems/testing/bsps/qoriq_e6500_64.ini > +++ b/tester/rtems/testing/bsps/qoriq_e6500_64.ini > @@ -36,7 +36,7 @@ > [qoriq_e6500_64] > bsp = qoriq_e6500_64 > arch = powerpc > -jobs = 1 > +max_jobs = 1 > tester = %{_rtscripts}/tftp.cfg > test_restarts = 3 > target_start_regex = U-Boot > diff --git a/tester/rtems/testing/bsps/raspberrypi2.ini b/tester/rtems/testing/bsps/raspberrypi2.ini > index e8043ac..f7f3c8c 100644 > --- a/tester/rtems/testing/bsps/raspberrypi2.ini > +++ b/tester/rtems/testing/bsps/raspberrypi2.ini > @@ -35,7 +35,7 @@ > [raspberrypi2] > bsp = raspberrypi2 > arch = arm > -jobs = 1 > +max_jobs = 1 > tester = %{_rtscripts}/tftp.cfg > test_restarts = 3 > target_reset_regex = BOOTP broadcast 6.*|^ERROR: can.t get kernel image diff --git a/tester/rtems/testing/bsps/xilinx_versal_vck190.ini b/tester/rtems/testing/bsps/xilinx_versal_vck190.ini > index 3bdd6be..a7695a7 100644 > --- a/tester/rtems/testing/bsps/xilinx_versal_vck190.ini > +++ b/tester/rtems/testing/bsps/xilinx_versal_vck190.ini > @@ -36,7 +36,7 @@ > bsp = xilinx_versal_vck190 > arch = aarch64 > tester = %{_rtscripts}/tftp.cfg > -jobs = 1 > +max_jobs = 1 > test_restarts = 3 > target_reset_regex = ^No ethernet found.*|^BOOTP broadcast 6.*|^.+complete\.+ TIMEOUT.* target_start_regex = .* PSCI Power Domain Map:$|^U-Boot .* diff --git a/tester/rtems/testing/bsps/xilinx_zynq_a9_qemu_smp.ini b/tester/rtems/testing/bsps/xilinx_zynq_a9_qemu_smp.ini > index 4366ffc..b6b39b6 100644 > --- a/tester/rtems/testing/bsps/xilinx_zynq_a9_qemu_smp.ini > +++ b/tester/rtems/testing/bsps/xilinx_zynq_a9_qemu_smp.ini > @@ -34,6 +34,6 @@ > [xilinx_zynq_a9_qemu_smp] > bsp = xilinx_zynq_a9_qemu > arch = arm > -jobs = half > +default_jobs = half > tester = %{_rtscripts}/qemu.cfg > bsp_qemu_opts = %{qemu_opts_base} %{qemu_opts_no_net} %{qemu_opts_serial} -M xilinx-zynq-a9 -m 256M -smp cpus=2 diff --git a/tester/rtems/testing/bsps/xilinx_zynq_zc706.ini b/tester/rtems/testing/bsps/xilinx_zynq_zc706.ini > index e543022..844776d 100644 > --- a/tester/rtems/testing/bsps/xilinx_zynq_zc706.ini > +++ b/tester/rtems/testing/bsps/xilinx_zynq_zc706.ini > @@ -35,7 +35,7 @@ > [xilinx_zynq_zc706] > bsp = xilinx_zynq_zc706 > arch = arm > -jobs = 1 > +max_jobs = 1 > tester = %{_rtscripts}/gdb.cfg > gdb_script = bsp_gdb_script > requires = bsp_tty_dev, bsp_gdb_script > diff --git a/tester/rtems/testing/bsps/xilinx_zynq_zedboard.ini b/tester/rtems/testing/bsps/xilinx_zynq_zedboard.ini > index 14b4d94..5c2451b 100644 > --- a/tester/rtems/testing/bsps/xilinx_zynq_zedboard.ini > +++ b/tester/rtems/testing/bsps/xilinx_zynq_zedboard.ini > @@ -36,7 +36,7 @@ > bsp = xilinx_zynq_zedboard > arch = arm > tester = %{_rtscripts}/tftp.cfg > -jobs = 1 > +max_jobs = 1 > test_restarts = 3 > target_reset_regex = ^No ethernet found.*|^BOOTP broadcast 6.*|^.+complete\.+ TIMEOUT.* target_start_regex = ^U-Boot SPL .* diff --git a/tester/rtems/testing/bsps/xilinx_zynqmp_ilp32_zu3eg.ini b/tester/rtems/testing/bsps/xilinx_zynqmp_ilp32_zu3eg.ini > index 8c1c839..eefe173 100644 > --- a/tester/rtems/testing/bsps/xilinx_zynqmp_ilp32_zu3eg.ini > +++ b/tester/rtems/testing/bsps/xilinx_zynqmp_ilp32_zu3eg.ini > @@ -35,7 +35,7 @@ > bsp = xilinx_zynqmp_ilp32_zu3eg > arch = aarch64 > tester = %{_rtscripts}/tftp.cfg > -jobs = 1 > +max_jobs = 1 > test_restarts = 3 > target_reset_regex = ^No ethernet found.*|^.*: No link\..* target_start_regex = ^.*Xilinx Zynq MP First Stage Boot Loader.* diff --git a/tester/rtems/testing/bsps/xilinx_zynqmp_lp64_zu3eg.ini b/tester/rtems/testing/bsps/xilinx_zynqmp_lp64_zu3eg.ini > index 663e5de..1fa35e5 100644 > --- a/tester/rtems/testing/bsps/xilinx_zynqmp_lp64_zu3eg.ini > +++ b/tester/rtems/testing/bsps/xilinx_zynqmp_lp64_zu3eg.ini > @@ -35,7 +35,7 @@ > bsp = xilinx_zynqmp_lp64_zu3eg > arch = aarch64 > tester = %{_rtscripts}/tftp.cfg > -jobs = 1 > +max_jobs = 1 > test_restarts = 3 > target_reset_regex = ^No ethernet found.*|^.*: No link\..* target_start_regex = ^.*Xilinx Zynq MP First Stage Boot Loader.* diff --git a/tester/rtems/testing/defaults.mc b/tester/rtems/testing/defaults.mc > index d3e16a9..830b377 100644 > --- a/tester/rtems/testing/defaults.mc > +++ b/tester/rtems/testing/defaults.mc > @@ -116,6 +116,8 @@ __xz: exe, required, '/usr/bin/xz' > > # Default settings > _target: none, none, '%{nil}' > +max_jobs: none, none, '0' > +default_jobs: none, none, '0' > > # Paths > _rtbase: none, none, '%{_rtdir}' > -- > 1.8.3.1 > > _______________________________________________ > devel mailing list > devel at rtems.org > http://lists.rtems.org/mailman/listinfo/devel From kinsey.moore at oarcorp.com Thu Dec 9 01:08:56 2021 From: kinsey.moore at oarcorp.com (Kinsey Moore) Date: Wed, 8 Dec 2021 19:08:56 -0600 Subject: [PATCH] spec: Update location of cadence I2C Message-ID: <20211209010856.2745170-1-kinsey.moore@oarcorp.com> When the cadence I2C code was moved to a shared directory, the references were updated but the install locations weren't. This updates the install locations to match what out-of-tree applications expect. --- spec/build/bsps/aarch64/xilinx-zynqmp/objcadencei2c.yml | 4 +++- spec/build/bsps/arm/xilinx-zynq/obj.yml | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/spec/build/bsps/aarch64/xilinx-zynqmp/objcadencei2c.yml b/spec/build/bsps/aarch64/xilinx-zynqmp/objcadencei2c.yml index fd9d51dfa9..fa269d61ad 100644 --- a/spec/build/bsps/aarch64/xilinx-zynqmp/objcadencei2c.yml +++ b/spec/build/bsps/aarch64/xilinx-zynqmp/objcadencei2c.yml @@ -9,10 +9,12 @@ enabled-by: true includes: [] install: - destination: ${BSP_INCLUDEDIR}/bsp + source: + - bsps/aarch64/xilinx-zynqmp/include/bsp/i2c.h +- destination: ${BSP_INCLUDEDIR}/dev/i2c source: - bsps/include/dev/i2c/cadence-i2c-regs.h - bsps/include/dev/i2c/cadence-i2c.h - - bsps/aarch64/xilinx-zynqmp/include/bsp/i2c.h links: [] source: - bsps/shared/dev/i2c/cadence-i2c.c diff --git a/spec/build/bsps/arm/xilinx-zynq/obj.yml b/spec/build/bsps/arm/xilinx-zynq/obj.yml index bc675cd38c..dcac09126b 100644 --- a/spec/build/bsps/arm/xilinx-zynq/obj.yml +++ b/spec/build/bsps/arm/xilinx-zynq/obj.yml @@ -14,10 +14,12 @@ install: - bsps/arm/xilinx-zynq/include/tm27.h - destination: ${BSP_INCLUDEDIR}/bsp source: - - bsps/include/dev/i2c/cadence-i2c-regs.h - - bsps/include/dev/i2c/cadence-i2c.h - bsps/arm/xilinx-zynq/include/bsp/i2c.h - bsps/arm/xilinx-zynq/include/bsp/irq.h +- destination: ${BSP_INCLUDEDIR}/dev/i2c + source: + - bsps/include/dev/i2c/cadence-i2c-regs.h + - bsps/include/dev/i2c/cadence-i2c.h links: [] source: - bsps/arm/shared/cache/cache-l2c-310.c -- 2.30.2 From chrisj at rtems.org Thu Dec 9 02:30:22 2021 From: chrisj at rtems.org (Chris Johns) Date: Thu, 9 Dec 2021 13:30:22 +1100 Subject: [PATCH] spec: Update location of cadence I2C In-Reply-To: <20211209010856.2745170-1-kinsey.moore@oarcorp.com> References: <20211209010856.2745170-1-kinsey.moore@oarcorp.com> Message-ID: <1f4eaa15-eede-a675-9f8f-bde0f15d6ffe@rtems.org> OK and thanks Chris On 9/12/21 12:08 pm, Kinsey Moore wrote: > When the cadence I2C code was moved to a shared directory, the > references were updated but the install locations weren't. This updates > the install locations to match what out-of-tree applications expect. > --- > spec/build/bsps/aarch64/xilinx-zynqmp/objcadencei2c.yml | 4 +++- > spec/build/bsps/arm/xilinx-zynq/obj.yml | 6 ++++-- > 2 files changed, 7 insertions(+), 3 deletions(-) > > diff --git a/spec/build/bsps/aarch64/xilinx-zynqmp/objcadencei2c.yml b/spec/build/bsps/aarch64/xilinx-zynqmp/objcadencei2c.yml > index fd9d51dfa9..fa269d61ad 100644 > --- a/spec/build/bsps/aarch64/xilinx-zynqmp/objcadencei2c.yml > +++ b/spec/build/bsps/aarch64/xilinx-zynqmp/objcadencei2c.yml > @@ -9,10 +9,12 @@ enabled-by: true > includes: [] > install: > - destination: ${BSP_INCLUDEDIR}/bsp > + source: > + - bsps/aarch64/xilinx-zynqmp/include/bsp/i2c.h > +- destination: ${BSP_INCLUDEDIR}/dev/i2c > source: > - bsps/include/dev/i2c/cadence-i2c-regs.h > - bsps/include/dev/i2c/cadence-i2c.h > - - bsps/aarch64/xilinx-zynqmp/include/bsp/i2c.h > links: [] > source: > - bsps/shared/dev/i2c/cadence-i2c.c > diff --git a/spec/build/bsps/arm/xilinx-zynq/obj.yml b/spec/build/bsps/arm/xilinx-zynq/obj.yml > index bc675cd38c..dcac09126b 100644 > --- a/spec/build/bsps/arm/xilinx-zynq/obj.yml > +++ b/spec/build/bsps/arm/xilinx-zynq/obj.yml > @@ -14,10 +14,12 @@ install: > - bsps/arm/xilinx-zynq/include/tm27.h > - destination: ${BSP_INCLUDEDIR}/bsp > source: > - - bsps/include/dev/i2c/cadence-i2c-regs.h > - - bsps/include/dev/i2c/cadence-i2c.h > - bsps/arm/xilinx-zynq/include/bsp/i2c.h > - bsps/arm/xilinx-zynq/include/bsp/irq.h > +- destination: ${BSP_INCLUDEDIR}/dev/i2c > + source: > + - bsps/include/dev/i2c/cadence-i2c-regs.h > + - bsps/include/dev/i2c/cadence-i2c.h > links: [] > source: > - bsps/arm/shared/cache/cache-l2c-310.c > From chrisj at rtems.org Thu Dec 9 02:41:24 2021 From: chrisj at rtems.org (Chris Johns) Date: Thu, 9 Dec 2021 13:41:24 +1100 Subject: [PATCH v1 3/4] ConfigFile: Convert to C++ In-Reply-To: <1638976552-30164-4-git-send-email-ryan.long@oarcorp.com> References: <1638976552-30164-1-git-send-email-ryan.long@oarcorp.com> <1638976552-30164-4-git-send-email-ryan.long@oarcorp.com> Message-ID: On 9/12/21 2:15 am, Ryan Long wrote: > --- > tester/covoar/ConfigFile.cc | 79 +++++++++++++++++---------------------------- > tester/covoar/ConfigFile.h | 2 +- > 2 files changed, 31 insertions(+), 50 deletions(-) > > diff --git a/tester/covoar/ConfigFile.cc b/tester/covoar/ConfigFile.cc > index c16b64a..5c8949e 100644 > --- a/tester/covoar/ConfigFile.cc > +++ b/tester/covoar/ConfigFile.cc > @@ -10,6 +10,10 @@ > #include Is this needed? I think reducing the C interfaces included would help the long maintenance. > #include > > +#include > +#include > +#include > + > namespace Configuration { > > FileReader::FileReader( > @@ -24,43 +28,40 @@ namespace Configuration { > } > > bool FileReader::processFile( > - const char* const file > + const std::string& file > ) > { > #define METHOD "FileReader::processFile - " > - FILE * in; > - char line[256]; > - char option[256]; > - char value[256]; > + #define MAX_LENGTH 256 > + std::ifstream in; > + std::string line; > + char option[MAX_LENGTH]; > + char value[MAX_LENGTH]; > int line_no; > int i; > int j; > > - if ( file == NULL ) { > - fprintf( stderr, METHOD "NULL filename\n" ); > + if ( file.empty() ) { > + std::cerr << METHOD << "Empty filename" << std::endl; > return false; > } > > - in = fopen( file, "r" ); > - if ( !in ) { > - fprintf( stderr, METHOD "unable to open %s\n", file ); > + in.open( file ); > + if ( !in.is_open() ) { > + std::cerr << METHOD << "unable to open " << file << std::endl; > return false; > } > > line_no = 0; > - while (fgets(line, sizeof(line), in) != NULL) { > + while ( std::getline( line, MAX_LENGTH ) ) { > int length; > > line_no++; > > - length = (int) strlen( line ); > - if ( line[length - 1] != '\n' ) { > - fprintf( > - stderr, > - "%s: line %d is too long", > - file, > - line_no > - ); > + length = (int) line.length(); > + if ( length > MAX_LENGTH ) { > + std::cerr << file << ": line " << line_no << " is too long" > + << std::endl; > continue; > } > > @@ -96,14 +97,9 @@ namespace Configuration { > if (line[0] == '\0') > continue; > > - if (sscanf(line, "%s", option) != 1) { > - fprintf( > - stderr, > - "%s: line %d is invalid: %s\n", > - file, > - line_no, > - line > - ); > + if (sscanf(line.c_str(), "%s", option) != 1) { I suggest you use the C++ interface .. https://en.cppreference.com/w/cpp/io/c/fscanf > + std::cerr << file << ": line" << line_no << " is invalid: " << line > + << std::endl; Please make the repeated code a helper function with line number and line as args. Chris From chrisj at rtems.org Thu Dec 9 07:33:59 2021 From: chrisj at rtems.org (Chris Johns) Date: Thu, 9 Dec 2021 18:33:59 +1100 Subject: [rtems commit] untar: Make behavior similar to GNU or BSD tar In-Reply-To: <20211209072118.C0B524E76F@lists.rtems.org> References: <20211209072118.C0B524E76F@lists.rtems.org> Message-ID: Hi Christian, I did not know this was for the 5 branch. Where was this discussed? Functional changes to a release branch need to be treated carefully and in this case I would not approve it. I am sorry if I did not pick up it was for 5 as well. Thanks Chris On 9/12/21 6:21 pm, Christian Mauderer wrote: > Module: rtems > Branch: 5 > Commit: ff3f3490df7120c9ec039b5acd1935265c3f9262 > Changeset: http://git.rtems.org/rtems/commit/?id=ff3f3490df7120c9ec039b5acd1935265c3f9262 > > Author: Christian Mauderer > Date: Wed Dec 1 16:39:46 2021 +0100 > > untar: Make behavior similar to GNU or BSD tar > > RTEMS untar implementation had problems with overwriting or integrating > archives into existing directory structures. This patch adapts the > behavior to mimic that of a GNU tar or BSD tar and extends the tar01 > test to check for the behavior. That is: > > * If a directory structure exists, the files from the archive will be > integrated. Existing files are overwritten. > > * If a file exists and the archive contains a directory with the same > name, the file is removed and a directory is created. In the above > example: if l1/l2 is a file it will be overwritten with a new > directory. > > * If a directory exists and the archive contains a file with the same > name, the directory will be replaced if it is empty. If it contains > files, the result is an error. > > * An archive also can contain only a file without the parent > directories. If in that case one of the parent directories exists as a > file extracting the archive results in an error. In the example: if > l1/l2 is a file and the archive doesn't contain the directories but > only the file l1/l2/x.txt that would be an error. > > * In case of an error, it is possible that the archive has been > partially extracted. > > Closes #4552 > > --- > > cpukit/libmisc/untar/untar.c | 57 +++++++---- > testsuites/libtests/tar01/init.c | 199 +++++++++++++++++++++++++++++++++++- > testsuites/libtests/tar01/tar01.doc | 1 + > testsuites/libtests/tar01/tar01.scn | 54 ++++++++-- > testsuites/libtests/tar01/tar01.tar | Bin 10240 -> 10240 bytes > 5 files changed, 282 insertions(+), 29 deletions(-) > > diff --git a/cpukit/libmisc/untar/untar.c b/cpukit/libmisc/untar/untar.c > index a2f09fb..8888ab2 100644 > --- a/cpukit/libmisc/untar/untar.c > +++ b/cpukit/libmisc/untar/untar.c > @@ -126,30 +126,25 @@ Make_Path(const rtems_printer *printer, char *path) > > *p = '\0'; > if (p[1] == '\0') { > - /* Speculatively unlink the last component so that it can be re-created */ > - unlink(path); > return 0; > } > > if (mkdir(path, S_IRWXU | S_IRWXG | S_IRWXO) != 0) { > - if (errno == EEXIST || errno == EISDIR) { > + if (errno == EEXIST) { > + /* If it exists already: Check whether it is a directory */ > struct stat sb; > - > - if (stat(path, &sb) != 0) { > + if (lstat(path, &sb) != 0) { > + Print_Error(printer, "lstat", path); > + return -1; > + } else if (!S_ISDIR(sb.st_mode)) { > + rtems_printf(printer, > + "untar: mkdir: %s: exists but is not a directory\n", > + path); > return -1; > } > - > - if (!S_ISDIR(sb.st_mode)) { > - if (unlink(path) != 0) { > - Print_Error(printer, "unlink", path); > - return -1; > - } > - > - if (mkdir(path, S_IRWXU | S_IRWXG | S_IRWXO) != 0) { > - Print_Error(printer, "mkdir (unlink)", path); > - return -1; > - } > - } > + } else { > + Print_Error(printer, "mkdir", path); > + return -1; > } > } > > @@ -206,6 +201,12 @@ Untar_ProcessHeader( > > if (Make_Path(ctx->printer, ctx->file_path) != 0) { > retval = UNTAR_FAIL; > + } else { > + /* > + * Speculatively unlink. This should unlink everything but non-empty > + * directories or write protected stuff. > + */ > + unlink(ctx->file_path); > } > > if (ctx->linkflag == SYMTYPE) { > @@ -225,8 +226,22 @@ Untar_ProcessHeader( > rtems_printf(ctx->printer, "untar: dir: %s\n", ctx->file_path); > r = mkdir(ctx->file_path, ctx->mode); > if (r != 0) { > - Print_Error(ctx->printer, "mkdir", ctx->file_path); > - retval = UNTAR_FAIL; > + if (errno == EEXIST) { > + /* If it exists already: Check whether it is a directory */ > + struct stat sb; > + if (lstat(ctx->file_path, &sb) != 0) { > + Print_Error(ctx->printer, "lstat", ctx->file_path); > + retval = UNTAR_FAIL; > + } else if (!S_ISDIR(sb.st_mode)) { > + rtems_printf(ctx->printer, > + "untar: mkdir: %s: exists but is not a directory\n", > + ctx->file_path); > + retval = UNTAR_FAIL; > + } > + } else { > + Print_Error(ctx->printer, "mkdir", ctx->file_path); > + retval = UNTAR_FAIL; > + } > } > } > > @@ -426,7 +441,9 @@ Untar_FromFile_Print( > */ > > if ((out_fd = creat(ctx.file_path, ctx.mode)) == -1) { > - (void) lseek(fd, SEEK_CUR, 512UL * ctx.nblocks); > + /* Couldn't create that file. Abort. */ > + retval = UNTAR_FAIL; > + break; > } else { > for (i = 0; i < ctx.nblocks; i++) { > n = read(fd, bufr, 512); > diff --git a/testsuites/libtests/tar01/init.c b/testsuites/libtests/tar01/init.c > index 4cad67a..2deff3a 100644 > --- a/testsuites/libtests/tar01/init.c > +++ b/testsuites/libtests/tar01/init.c > @@ -7,6 +7,33 @@ > * http://www.rtems.org/license/LICENSE. > */ > > +/* > + * Note on the used tar file: Generate the file on a system that supports > + * symlinks with the following commands (tested on Linux - you might have to > + * adapt on other systems): > + * > + * export WORK=some_work_directory > + * rm -r ${WORK} > + * mkdir -p ${WORK}/home/abc/def > + * mkdir -p ${WORK}/home/dir > + * cd ${WORK} > + * echo "#! joel" > home/abc/def/test_script > + * echo "ls -las /dev" >> home/abc/def/test_script > + * chmod 755 home/abc/def/test_script > + * echo "This is a test of loading an RTEMS filesystem from an" > home/test_file > + * echo "initial tar image." >> home/test_file > + * echo "Hello world" >> home/dir/file > + * ln -s home/test_file symlink > + * tar cf tar01.tar --format=ustar \ > + * symlink \ > + * home/test_file \ > + * home/abc/def/test_script \ > + * home/dir > + * > + * Note that "home/dir" is in the archive as separate directory. "home/abc" is > + * only in the archive as a parent of the file "test_script". > + */ > + > #ifdef HAVE_CONFIG_H > #include "config.h" > #endif > @@ -95,6 +122,84 @@ void test_untar_from_memory(void) > > } > > +static void assert_file_content( > + const char *name, > + const char *expected_content, > + ssize_t expected_size > +) > +{ > + char buf[16]; > + int fd; > + int rd; > + > + fd = open(name, O_RDONLY); > + rtems_test_assert( fd >= 0 ); > + do { > + rd = read(fd, buf, sizeof(buf)); > + rtems_test_assert( rd >= 0 ); > + if (rd > 0) { > + rtems_test_assert( expected_size - rd >= 0 ); > + rtems_test_assert( memcmp(buf, expected_content, rd) == 0 ); > + expected_content += rd; > + expected_size -= rd; > + } > + } while(rd > 0); > + rtems_test_assert( expected_size == 0 ); > + close(fd); > +} > + > +static void assert_content_like_expected(void) > +{ > + const char *directories[] = { > + "home", > + "home/abc", > + "home/abc/def", > + "home/dir", > + }; > + const char *symlinks[] = { > + "symlink", > + }; > + const struct { > + const char *name; > + const char *content; > + } files[] = { > + { > + .name = "home/abc/def/test_script", > + .content = "#! joel\nls -las /dev\n", > + }, { > + .name = "home/test_file", > + .content = "This is a test of loading an RTEMS filesystem from an\n" > + "initial tar image.\n", > + }, { > + .name = "home/dir/file", > + .content = "Hello world\n", > + } > + }; > + size_t i; > + struct stat st; > + > + for(i = 0; i < RTEMS_ARRAY_SIZE(directories); ++i) { > + lstat(directories[i], &st); > + rtems_test_assert( S_ISDIR(st.st_mode) ); > + } > + > + for(i = 0; i < RTEMS_ARRAY_SIZE(symlinks); ++i) { > + lstat(symlinks[i], &st); > + rtems_test_assert( S_ISLNK(st.st_mode) ); > + } > + > + for(i = 0; i < RTEMS_ARRAY_SIZE(files); ++i) { > + lstat(files[i].name, &st); > + rtems_test_assert( S_ISREG(st.st_mode) ); > + > + assert_file_content( > + files[i].name, > + files[i].content, > + strlen(files[i].content) > + ); > + } > +} > + > void test_untar_from_file(void) > { > int fd; > @@ -119,13 +224,105 @@ void test_untar_from_file(void) > rv = chdir( "/dest" ); > rtems_test_assert( rv == 0 ); > > - /* Untar it */ > + /* Case 1: Untar it into empty directory */ > rv = Untar_FromFile( "/test.tar" ); > printf("Untaring from file - "); > if (rv != UNTAR_SUCCESSFUL) { > printf ("error: untar failed: %i\n", rv); > exit(1); > } > + assert_content_like_expected(); > + printf ("successful\n"); > + > + /* Case 2: Most files exist */ > + rv = unlink("/dest/home/test_file"); > + rtems_test_assert( rv == 0 ); > + > + rv = Untar_FromFile( "/test.tar" ); > + printf("Untar from file into existing structure with one missing file - "); > + if (rv != UNTAR_SUCCESSFUL) { > + printf ("error: untar failed: %i\n", rv); > + exit(1); > + } > + assert_content_like_expected(); > + printf ("successful\n"); > + > + /* Case 3: An empty directory exists where a file should be */ > + rv = unlink("/dest/home/test_file"); > + rtems_test_assert( rv == 0 ); > + rv = mkdir("/dest/home/test_file", S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); > + rtems_test_assert( rv == 0 ); > + > + rv = Untar_FromFile( "/test.tar" ); > + printf("Untar from file; overwrite empty directory with file - "); > + if (rv != UNTAR_SUCCESSFUL) { > + printf ("error: untar failed: %i\n", rv); > + exit(1); > + } > + assert_content_like_expected(); > + printf ("successful\n"); > + > + /* Case 4: A file exists where a parent directory should be created */ > + rv = unlink("/dest/home/abc/def/test_script"); > + rtems_test_assert( rv == 0 ); > + rv = unlink("/dest/home/abc/def"); > + rtems_test_assert( rv == 0 ); > + rv = unlink("/dest/home/abc"); > + rtems_test_assert( rv == 0 ); > + fd = creat("/dest/home/abc", S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); > + rtems_test_assert( fd >= 0 ); > + close(fd); > + > + rv = Untar_FromFile( "/test.tar" ); > + printf("Untar from file; file exists where parent dir should be created - "); > + if (rv != UNTAR_FAIL) { > + printf ("error: untar didn't fail like expected: %i\n", rv); > + exit(1); > + } > + printf ("expected fail\n"); > + /* cleanup so that the next one works */ > + rv = unlink("/dest/home/abc"); > + rtems_test_assert( rv == 0 ); > + > + /* Case 5: A non-empty directory exists where a file should be created */ > + rv = unlink("/dest/home/test_file"); > + rtems_test_assert( rv == 0 ); > + rv = mkdir("/dest/home/test_file", S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); > + rtems_test_assert( rv == 0 ); > + fd = creat("/dest/home/test_file/file", > + S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); > + rtems_test_assert( fd >= 0 ); > + close(fd); > + > + rv = Untar_FromFile( "/test.tar" ); > + printf("Untar from file; non-empty dir where file should be created - "); > + if (rv != UNTAR_FAIL) { > + printf ("error: untar didn't fail like expected: %i\n", rv); > + exit(1); > + } > + printf ("expected fail\n"); > + /* cleanup so that the next one works */ > + rv = unlink("/dest/home/test_file/file"); > + rtems_test_assert( rv == 0 ); > + rv = unlink("/dest/home/test_file"); > + rtems_test_assert( rv == 0 ); > + > + /* Case 6: A file exists where a directory is explicitly in the archive */ > + rv = unlink("/dest/home/dir/file"); > + rtems_test_assert( rv == 0 ); > + rv = unlink("/dest/home/dir"); > + rtems_test_assert( rv == 0 ); > + fd = creat("/dest/home/dir", S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); > + rtems_test_assert( fd >= 0 ); > + close(fd); > + > + rv = Untar_FromFile( "/test.tar" ); > + printf("Untar from file; overwrite file with explicit directory - "); > + if (rv != UNTAR_SUCCESSFUL) { > + printf ("error: untar failed: %i\n", rv); > + exit(1); > + } > + assert_content_like_expected(); > printf ("successful\n"); > > /******************/ > diff --git a/testsuites/libtests/tar01/tar01.doc b/testsuites/libtests/tar01/tar01.doc > index 060f98a..adffdca 100644 > --- a/testsuites/libtests/tar01/tar01.doc > +++ b/testsuites/libtests/tar01/tar01.doc > @@ -20,3 +20,4 @@ directives: > concepts: > > + exercise these routines > ++ check whether existing files are overwritten or not overwritten like expected > diff --git a/testsuites/libtests/tar01/tar01.scn b/testsuites/libtests/tar01/tar01.scn > index 68fa951..dd72f95 100644 > --- a/testsuites/libtests/tar01/tar01.scn > +++ b/testsuites/libtests/tar01/tar01.scn > @@ -1,9 +1,24 @@ > -*** TAR01 TEST *** > -Untaring from memory - successful > +*** BEGIN OF TEST TAR 1 *** > +*** TEST VERSION: 6.0.0.e1efb4eb8a9d6dd5f6f37dafc9feb0a9e6a888f1 > +*** TEST STATE: EXPECTED_PASS > +*** TEST BUILD: RTEMS_POSIX_API > +*** TEST TOOLS: 10.3.1 20210409 (RTEMS 6, RSB ad54d1dd3cf8249d9d39deb1dd28b2f294df062d-modified, Newlib eb03ac1) > +Untaring from memory - untar: memory at 0x11ece8 (10240) > +untar: symlink: home/test_file -> symlink > +untar: file: home/test_file (s:73,m:0644) > +untar: file: home/abc/def/test_script (s:21,m:0755) > +untar: dir: home/dir > +untar: file: home/dir/file (s:12,m:0644) > +successful > ========= /home/test_file ========= > (0)This is a test of loading an RTEMS filesystem from an > initial tar image. > > +========= /home/abc/def/test_script ========= > +(0)#! joel > +ls -las /dev > + > + /home/abc/def/test_script: mode: 0755 want: 0755 > ========= /symlink ========= > (0)This is a test of loading an RTEMS filesystem from an > initial tar image. > @@ -11,35 +26,58 @@ initial tar image. > > Copy tar image to test.tar > Untaring from file - successful > +Untar from file into existing structure with one missing file - successful > +Untar from file; overwrite empty directory with file - successful > +Untar from file; file exists where parent dir should be created - expected fail > +Untar from file; non-empty dir where file should be created - expected fail > +Untar from file; overwrite file with explicit directory - successful > ========= /dest/home/test_file ========= > (0)This is a test of loading an RTEMS filesystem from an > initial tar image. > > +========= /dest/home/abc/def/test_script ========= > +(0)#! joel > +ls -las /dev > + > + /dest/home/abc/def/test_script: mode: 0755 want: 0755 > ========= /dest/symlink ========= > (0)This is a test of loading an RTEMS filesystem from an > initial tar image. > > > -Untaring chunks from memory - untar: dir: home > -untar: file: home/test_file (73) > +Untaring chunks from memory - untar: symlink: home/test_file -> symlink > +untar: file: home/test_file (s:73,m:0644) > +untar: file: home/abc/def/test_script (s:21,m:0755) > +untar: dir: home/dir > +untar: file: home/dir/file (s:12,m:0644) > successful > ========= /dest2/home/test_file ========= > (0)This is a test of loading an RTEMS filesystem from an > initial tar image. > > +========= /dest2/home/abc/def/test_script ========= > +(0)#! joel > +ls -las /dev > + > + /dest2/home/abc/def/test_script: mode: 0755 want: 0755 > ========= /dest2/symlink ========= > (0)This is a test of loading an RTEMS filesystem from an > initial tar image. > > > -Untaring chunks from tgz- untar: dir: home > -untar: file: home/test_file (73) > -successful > +Untaring chunks from tgz - successful > ========= /dest3/home/test_file ========= > (0)This is a test of loading an RTEMS filesystem from an > initial tar image. > > +========= /dest3/home/abc/def/test_script ========= > +(0)#! joel > +ls -las /dev > + > + /dest3/home/abc/def/test_script: mode: 0755 want: 0755 > ========= /dest3/symlink ========= > (0)This is a test of loading an RTEMS filesystem from an > initial tar image. > -*** END OF TAR01 TEST *** > + > + > +*** END OF TEST TAR 1 *** > diff --git a/testsuites/libtests/tar01/tar01.tar b/testsuites/libtests/tar01/tar01.tar > index 6c6952e..9874f42 100644 > Binary files a/testsuites/libtests/tar01/tar01.tar and b/testsuites/libtests/tar01/tar01.tar differ > > _______________________________________________ > vc mailing list > vc at rtems.org > http://lists.rtems.org/mailman/listinfo/vc > From christian.mauderer at embedded-brains.de Thu Dec 9 07:47:15 2021 From: christian.mauderer at embedded-brains.de (Christian MAUDERER) Date: Thu, 9 Dec 2021 08:47:15 +0100 Subject: [rtems commit] untar: Make behavior similar to GNU or BSD tar In-Reply-To: References: <20211209072118.C0B524E76F@lists.rtems.org> Message-ID: <9ec242f5-f3a7-7bbf-0443-81e5cfc4d7a9@embedded-brains.de> Hello Chris, sorry that I haven't been clear enough. 1. The ticket #4552 that I created before sending the patch to the list and that was closed by the patch was for 5. 2. I asked as an answer to Joels review and I understood him that he is OK with that change: https://lists.rtems.org/pipermail/devel/2021-December/070092.html and https://lists.rtems.org/pipermail/devel/2021-December/070093.html Do you want me to revert that patch on 5? Best regards Christian Am 09.12.21 um 08:33 schrieb Chris Johns: > Hi Christian, > > I did not know this was for the 5 branch. Where was this discussed? > > Functional changes to a release branch need to be treated carefully and in this > case I would not approve it. I am sorry if I did not pick up it was for 5 as well. > > Thanks > Chris > > On 9/12/21 6:21 pm, Christian Mauderer wrote: >> Module: rtems >> Branch: 5 >> Commit: ff3f3490df7120c9ec039b5acd1935265c3f9262 >> Changeset: http://git.rtems.org/rtems/commit/?id=ff3f3490df7120c9ec039b5acd1935265c3f9262 >> >> Author: Christian Mauderer >> Date: Wed Dec 1 16:39:46 2021 +0100 >> >> untar: Make behavior similar to GNU or BSD tar >> >> RTEMS untar implementation had problems with overwriting or integrating >> archives into existing directory structures. This patch adapts the >> behavior to mimic that of a GNU tar or BSD tar and extends the tar01 >> test to check for the behavior. That is: >> >> * If a directory structure exists, the files from the archive will be >> integrated. Existing files are overwritten. >> >> * If a file exists and the archive contains a directory with the same >> name, the file is removed and a directory is created. In the above >> example: if l1/l2 is a file it will be overwritten with a new >> directory. >> >> * If a directory exists and the archive contains a file with the same >> name, the directory will be replaced if it is empty. If it contains >> files, the result is an error. >> >> * An archive also can contain only a file without the parent >> directories. If in that case one of the parent directories exists as a >> file extracting the archive results in an error. In the example: if >> l1/l2 is a file and the archive doesn't contain the directories but >> only the file l1/l2/x.txt that would be an error. >> >> * In case of an error, it is possible that the archive has been >> partially extracted. >> >> Closes #4552 >> >> --- >> >> cpukit/libmisc/untar/untar.c | 57 +++++++---- >> testsuites/libtests/tar01/init.c | 199 +++++++++++++++++++++++++++++++++++- >> testsuites/libtests/tar01/tar01.doc | 1 + >> testsuites/libtests/tar01/tar01.scn | 54 ++++++++-- >> testsuites/libtests/tar01/tar01.tar | Bin 10240 -> 10240 bytes >> 5 files changed, 282 insertions(+), 29 deletions(-) >> >> diff --git a/cpukit/libmisc/untar/untar.c b/cpukit/libmisc/untar/untar.c >> index a2f09fb..8888ab2 100644 >> --- a/cpukit/libmisc/untar/untar.c >> +++ b/cpukit/libmisc/untar/untar.c >> @@ -126,30 +126,25 @@ Make_Path(const rtems_printer *printer, char *path) >> >> *p = '\0'; >> if (p[1] == '\0') { >> - /* Speculatively unlink the last component so that it can be re-created */ >> - unlink(path); >> return 0; >> } >> >> if (mkdir(path, S_IRWXU | S_IRWXG | S_IRWXO) != 0) { >> - if (errno == EEXIST || errno == EISDIR) { >> + if (errno == EEXIST) { >> + /* If it exists already: Check whether it is a directory */ >> struct stat sb; >> - >> - if (stat(path, &sb) != 0) { >> + if (lstat(path, &sb) != 0) { >> + Print_Error(printer, "lstat", path); >> + return -1; >> + } else if (!S_ISDIR(sb.st_mode)) { >> + rtems_printf(printer, >> + "untar: mkdir: %s: exists but is not a directory\n", >> + path); >> return -1; >> } >> - >> - if (!S_ISDIR(sb.st_mode)) { >> - if (unlink(path) != 0) { >> - Print_Error(printer, "unlink", path); >> - return -1; >> - } >> - >> - if (mkdir(path, S_IRWXU | S_IRWXG | S_IRWXO) != 0) { >> - Print_Error(printer, "mkdir (unlink)", path); >> - return -1; >> - } >> - } >> + } else { >> + Print_Error(printer, "mkdir", path); >> + return -1; >> } >> } >> >> @@ -206,6 +201,12 @@ Untar_ProcessHeader( >> >> if (Make_Path(ctx->printer, ctx->file_path) != 0) { >> retval = UNTAR_FAIL; >> + } else { >> + /* >> + * Speculatively unlink. This should unlink everything but non-empty >> + * directories or write protected stuff. >> + */ >> + unlink(ctx->file_path); >> } >> >> if (ctx->linkflag == SYMTYPE) { >> @@ -225,8 +226,22 @@ Untar_ProcessHeader( >> rtems_printf(ctx->printer, "untar: dir: %s\n", ctx->file_path); >> r = mkdir(ctx->file_path, ctx->mode); >> if (r != 0) { >> - Print_Error(ctx->printer, "mkdir", ctx->file_path); >> - retval = UNTAR_FAIL; >> + if (errno == EEXIST) { >> + /* If it exists already: Check whether it is a directory */ >> + struct stat sb; >> + if (lstat(ctx->file_path, &sb) != 0) { >> + Print_Error(ctx->printer, "lstat", ctx->file_path); >> + retval = UNTAR_FAIL; >> + } else if (!S_ISDIR(sb.st_mode)) { >> + rtems_printf(ctx->printer, >> + "untar: mkdir: %s: exists but is not a directory\n", >> + ctx->file_path); >> + retval = UNTAR_FAIL; >> + } >> + } else { >> + Print_Error(ctx->printer, "mkdir", ctx->file_path); >> + retval = UNTAR_FAIL; >> + } >> } >> } >> >> @@ -426,7 +441,9 @@ Untar_FromFile_Print( >> */ >> >> if ((out_fd = creat(ctx.file_path, ctx.mode)) == -1) { >> - (void) lseek(fd, SEEK_CUR, 512UL * ctx.nblocks); >> + /* Couldn't create that file. Abort. */ >> + retval = UNTAR_FAIL; >> + break; >> } else { >> for (i = 0; i < ctx.nblocks; i++) { >> n = read(fd, bufr, 512); >> diff --git a/testsuites/libtests/tar01/init.c b/testsuites/libtests/tar01/init.c >> index 4cad67a..2deff3a 100644 >> --- a/testsuites/libtests/tar01/init.c >> +++ b/testsuites/libtests/tar01/init.c >> @@ -7,6 +7,33 @@ >> * http://www.rtems.org/license/LICENSE. >> */ >> >> +/* >> + * Note on the used tar file: Generate the file on a system that supports >> + * symlinks with the following commands (tested on Linux - you might have to >> + * adapt on other systems): >> + * >> + * export WORK=some_work_directory >> + * rm -r ${WORK} >> + * mkdir -p ${WORK}/home/abc/def >> + * mkdir -p ${WORK}/home/dir >> + * cd ${WORK} >> + * echo "#! joel" > home/abc/def/test_script >> + * echo "ls -las /dev" >> home/abc/def/test_script >> + * chmod 755 home/abc/def/test_script >> + * echo "This is a test of loading an RTEMS filesystem from an" > home/test_file >> + * echo "initial tar image." >> home/test_file >> + * echo "Hello world" >> home/dir/file >> + * ln -s home/test_file symlink >> + * tar cf tar01.tar --format=ustar \ >> + * symlink \ >> + * home/test_file \ >> + * home/abc/def/test_script \ >> + * home/dir >> + * >> + * Note that "home/dir" is in the archive as separate directory. "home/abc" is >> + * only in the archive as a parent of the file "test_script". >> + */ >> + >> #ifdef HAVE_CONFIG_H >> #include "config.h" >> #endif >> @@ -95,6 +122,84 @@ void test_untar_from_memory(void) >> >> } >> >> +static void assert_file_content( >> + const char *name, >> + const char *expected_content, >> + ssize_t expected_size >> +) >> +{ >> + char buf[16]; >> + int fd; >> + int rd; >> + >> + fd = open(name, O_RDONLY); >> + rtems_test_assert( fd >= 0 ); >> + do { >> + rd = read(fd, buf, sizeof(buf)); >> + rtems_test_assert( rd >= 0 ); >> + if (rd > 0) { >> + rtems_test_assert( expected_size - rd >= 0 ); >> + rtems_test_assert( memcmp(buf, expected_content, rd) == 0 ); >> + expected_content += rd; >> + expected_size -= rd; >> + } >> + } while(rd > 0); >> + rtems_test_assert( expected_size == 0 ); >> + close(fd); >> +} >> + >> +static void assert_content_like_expected(void) >> +{ >> + const char *directories[] = { >> + "home", >> + "home/abc", >> + "home/abc/def", >> + "home/dir", >> + }; >> + const char *symlinks[] = { >> + "symlink", >> + }; >> + const struct { >> + const char *name; >> + const char *content; >> + } files[] = { >> + { >> + .name = "home/abc/def/test_script", >> + .content = "#! joel\nls -las /dev\n", >> + }, { >> + .name = "home/test_file", >> + .content = "This is a test of loading an RTEMS filesystem from an\n" >> + "initial tar image.\n", >> + }, { >> + .name = "home/dir/file", >> + .content = "Hello world\n", >> + } >> + }; >> + size_t i; >> + struct stat st; >> + >> + for(i = 0; i < RTEMS_ARRAY_SIZE(directories); ++i) { >> + lstat(directories[i], &st); >> + rtems_test_assert( S_ISDIR(st.st_mode) ); >> + } >> + >> + for(i = 0; i < RTEMS_ARRAY_SIZE(symlinks); ++i) { >> + lstat(symlinks[i], &st); >> + rtems_test_assert( S_ISLNK(st.st_mode) ); >> + } >> + >> + for(i = 0; i < RTEMS_ARRAY_SIZE(files); ++i) { >> + lstat(files[i].name, &st); >> + rtems_test_assert( S_ISREG(st.st_mode) ); >> + >> + assert_file_content( >> + files[i].name, >> + files[i].content, >> + strlen(files[i].content) >> + ); >> + } >> +} >> + >> void test_untar_from_file(void) >> { >> int fd; >> @@ -119,13 +224,105 @@ void test_untar_from_file(void) >> rv = chdir( "/dest" ); >> rtems_test_assert( rv == 0 ); >> >> - /* Untar it */ >> + /* Case 1: Untar it into empty directory */ >> rv = Untar_FromFile( "/test.tar" ); >> printf("Untaring from file - "); >> if (rv != UNTAR_SUCCESSFUL) { >> printf ("error: untar failed: %i\n", rv); >> exit(1); >> } >> + assert_content_like_expected(); >> + printf ("successful\n"); >> + >> + /* Case 2: Most files exist */ >> + rv = unlink("/dest/home/test_file"); >> + rtems_test_assert( rv == 0 ); >> + >> + rv = Untar_FromFile( "/test.tar" ); >> + printf("Untar from file into existing structure with one missing file - "); >> + if (rv != UNTAR_SUCCESSFUL) { >> + printf ("error: untar failed: %i\n", rv); >> + exit(1); >> + } >> + assert_content_like_expected(); >> + printf ("successful\n"); >> + >> + /* Case 3: An empty directory exists where a file should be */ >> + rv = unlink("/dest/home/test_file"); >> + rtems_test_assert( rv == 0 ); >> + rv = mkdir("/dest/home/test_file", S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); >> + rtems_test_assert( rv == 0 ); >> + >> + rv = Untar_FromFile( "/test.tar" ); >> + printf("Untar from file; overwrite empty directory with file - "); >> + if (rv != UNTAR_SUCCESSFUL) { >> + printf ("error: untar failed: %i\n", rv); >> + exit(1); >> + } >> + assert_content_like_expected(); >> + printf ("successful\n"); >> + >> + /* Case 4: A file exists where a parent directory should be created */ >> + rv = unlink("/dest/home/abc/def/test_script"); >> + rtems_test_assert( rv == 0 ); >> + rv = unlink("/dest/home/abc/def"); >> + rtems_test_assert( rv == 0 ); >> + rv = unlink("/dest/home/abc"); >> + rtems_test_assert( rv == 0 ); >> + fd = creat("/dest/home/abc", S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); >> + rtems_test_assert( fd >= 0 ); >> + close(fd); >> + >> + rv = Untar_FromFile( "/test.tar" ); >> + printf("Untar from file; file exists where parent dir should be created - "); >> + if (rv != UNTAR_FAIL) { >> + printf ("error: untar didn't fail like expected: %i\n", rv); >> + exit(1); >> + } >> + printf ("expected fail\n"); >> + /* cleanup so that the next one works */ >> + rv = unlink("/dest/home/abc"); >> + rtems_test_assert( rv == 0 ); >> + >> + /* Case 5: A non-empty directory exists where a file should be created */ >> + rv = unlink("/dest/home/test_file"); >> + rtems_test_assert( rv == 0 ); >> + rv = mkdir("/dest/home/test_file", S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); >> + rtems_test_assert( rv == 0 ); >> + fd = creat("/dest/home/test_file/file", >> + S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); >> + rtems_test_assert( fd >= 0 ); >> + close(fd); >> + >> + rv = Untar_FromFile( "/test.tar" ); >> + printf("Untar from file; non-empty dir where file should be created - "); >> + if (rv != UNTAR_FAIL) { >> + printf ("error: untar didn't fail like expected: %i\n", rv); >> + exit(1); >> + } >> + printf ("expected fail\n"); >> + /* cleanup so that the next one works */ >> + rv = unlink("/dest/home/test_file/file"); >> + rtems_test_assert( rv == 0 ); >> + rv = unlink("/dest/home/test_file"); >> + rtems_test_assert( rv == 0 ); >> + >> + /* Case 6: A file exists where a directory is explicitly in the archive */ >> + rv = unlink("/dest/home/dir/file"); >> + rtems_test_assert( rv == 0 ); >> + rv = unlink("/dest/home/dir"); >> + rtems_test_assert( rv == 0 ); >> + fd = creat("/dest/home/dir", S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); >> + rtems_test_assert( fd >= 0 ); >> + close(fd); >> + >> + rv = Untar_FromFile( "/test.tar" ); >> + printf("Untar from file; overwrite file with explicit directory - "); >> + if (rv != UNTAR_SUCCESSFUL) { >> + printf ("error: untar failed: %i\n", rv); >> + exit(1); >> + } >> + assert_content_like_expected(); >> printf ("successful\n"); >> >> /******************/ >> diff --git a/testsuites/libtests/tar01/tar01.doc b/testsuites/libtests/tar01/tar01.doc >> index 060f98a..adffdca 100644 >> --- a/testsuites/libtests/tar01/tar01.doc >> +++ b/testsuites/libtests/tar01/tar01.doc >> @@ -20,3 +20,4 @@ directives: >> concepts: >> >> + exercise these routines >> ++ check whether existing files are overwritten or not overwritten like expected >> diff --git a/testsuites/libtests/tar01/tar01.scn b/testsuites/libtests/tar01/tar01.scn >> index 68fa951..dd72f95 100644 >> --- a/testsuites/libtests/tar01/tar01.scn >> +++ b/testsuites/libtests/tar01/tar01.scn >> @@ -1,9 +1,24 @@ >> -*** TAR01 TEST *** >> -Untaring from memory - successful >> +*** BEGIN OF TEST TAR 1 *** >> +*** TEST VERSION: 6.0.0.e1efb4eb8a9d6dd5f6f37dafc9feb0a9e6a888f1 >> +*** TEST STATE: EXPECTED_PASS >> +*** TEST BUILD: RTEMS_POSIX_API >> +*** TEST TOOLS: 10.3.1 20210409 (RTEMS 6, RSB ad54d1dd3cf8249d9d39deb1dd28b2f294df062d-modified, Newlib eb03ac1) >> +Untaring from memory - untar: memory at 0x11ece8 (10240) >> +untar: symlink: home/test_file -> symlink >> +untar: file: home/test_file (s:73,m:0644) >> +untar: file: home/abc/def/test_script (s:21,m:0755) >> +untar: dir: home/dir >> +untar: file: home/dir/file (s:12,m:0644) >> +successful >> ========= /home/test_file ========= >> (0)This is a test of loading an RTEMS filesystem from an >> initial tar image. >> >> +========= /home/abc/def/test_script ========= >> +(0)#! joel >> +ls -las /dev >> + >> + /home/abc/def/test_script: mode: 0755 want: 0755 >> ========= /symlink ========= >> (0)This is a test of loading an RTEMS filesystem from an >> initial tar image. >> @@ -11,35 +26,58 @@ initial tar image. >> >> Copy tar image to test.tar >> Untaring from file - successful >> +Untar from file into existing structure with one missing file - successful >> +Untar from file; overwrite empty directory with file - successful >> +Untar from file; file exists where parent dir should be created - expected fail >> +Untar from file; non-empty dir where file should be created - expected fail >> +Untar from file; overwrite file with explicit directory - successful >> ========= /dest/home/test_file ========= >> (0)This is a test of loading an RTEMS filesystem from an >> initial tar image. >> >> +========= /dest/home/abc/def/test_script ========= >> +(0)#! joel >> +ls -las /dev >> + >> + /dest/home/abc/def/test_script: mode: 0755 want: 0755 >> ========= /dest/symlink ========= >> (0)This is a test of loading an RTEMS filesystem from an >> initial tar image. >> >> >> -Untaring chunks from memory - untar: dir: home >> -untar: file: home/test_file (73) >> +Untaring chunks from memory - untar: symlink: home/test_file -> symlink >> +untar: file: home/test_file (s:73,m:0644) >> +untar: file: home/abc/def/test_script (s:21,m:0755) >> +untar: dir: home/dir >> +untar: file: home/dir/file (s:12,m:0644) >> successful >> ========= /dest2/home/test_file ========= >> (0)This is a test of loading an RTEMS filesystem from an >> initial tar image. >> >> +========= /dest2/home/abc/def/test_script ========= >> +(0)#! joel >> +ls -las /dev >> + >> + /dest2/home/abc/def/test_script: mode: 0755 want: 0755 >> ========= /dest2/symlink ========= >> (0)This is a test of loading an RTEMS filesystem from an >> initial tar image. >> >> >> -Untaring chunks from tgz- untar: dir: home >> -untar: file: home/test_file (73) >> -successful >> +Untaring chunks from tgz - successful >> ========= /dest3/home/test_file ========= >> (0)This is a test of loading an RTEMS filesystem from an >> initial tar image. >> >> +========= /dest3/home/abc/def/test_script ========= >> +(0)#! joel >> +ls -las /dev >> + >> + /dest3/home/abc/def/test_script: mode: 0755 want: 0755 >> ========= /dest3/symlink ========= >> (0)This is a test of loading an RTEMS filesystem from an >> initial tar image. >> -*** END OF TAR01 TEST *** >> + >> + >> +*** END OF TEST TAR 1 *** >> diff --git a/testsuites/libtests/tar01/tar01.tar b/testsuites/libtests/tar01/tar01.tar >> index 6c6952e..9874f42 100644 >> Binary files a/testsuites/libtests/tar01/tar01.tar and b/testsuites/libtests/tar01/tar01.tar differ >> >> _______________________________________________ >> vc mailing list >> vc at rtems.org >> http://lists.rtems.org/mailman/listinfo/vc >> > _______________________________________________ > devel mailing list > devel at rtems.org > http://lists.rtems.org/mailman/listinfo/devel > -- -------------------------------------------- embedded brains GmbH Herr Christian MAUDERER Dornierstr. 4 82178 Puchheim Germany email: christian.mauderer at embedded-brains.de phone: +49-89-18 94 741 - 18 fax: +49-89-18 94 741 - 08 Registergericht: Amtsgericht M?nchen Registernummer: HRB 157899 Vertretungsberechtigte Gesch?ftsf?hrer: Peter Rasmussen, Thomas D?rfler Unsere Datenschutzerkl?rung finden Sie hier: https://embedded-brains.de/datenschutzerklaerung/ From sebastian.huber at embedded-brains.de Thu Dec 9 12:46:09 2021 From: sebastian.huber at embedded-brains.de (Sebastian Huber) Date: Thu, 9 Dec 2021 13:46:09 +0100 Subject: [PATCH] Avoid ISR_LOCK_MEMBER() since it confuses Doxygen Message-ID: <20211209124609.4218-1-sebastian.huber@embedded-brains.de> If RTEMS_SMP is not defined, then Doxygen adds the comments intended for conditional the lock member to the next member. --- cpukit/include/rtems/rtems/partdata.h | 4 +++- cpukit/include/rtems/rtems/ratemondata.h | 4 +++- cpukit/include/rtems/score/percpu.h | 4 +++- cpukit/include/rtems/score/scheduler.h | 4 ++-- cpukit/include/rtems/score/thread.h | 4 +++- cpukit/include/rtems/score/userextimpl.h | 4 +++- 6 files changed, 17 insertions(+), 7 deletions(-) diff --git a/cpukit/include/rtems/rtems/partdata.h b/cpukit/include/rtems/rtems/partdata.h index 196c2142ae..a6bcee229a 100644 --- a/cpukit/include/rtems/rtems/partdata.h +++ b/cpukit/include/rtems/rtems/partdata.h @@ -41,11 +41,13 @@ typedef struct { */ Objects_Control Object; +#if defined(RTEMS_SMP) /** * @brief This lock protects the chain of unallocated buffers and the number * of allocated buffers. */ - ISR_LOCK_MEMBER( Lock ) + ISR_lock_Control Lock; +#endif /** * @brief This member contains the base address of the buffer area. diff --git a/cpukit/include/rtems/rtems/ratemondata.h b/cpukit/include/rtems/rtems/ratemondata.h index f35fa7eb61..700285c7b4 100644 --- a/cpukit/include/rtems/rtems/ratemondata.h +++ b/cpukit/include/rtems/rtems/ratemondata.h @@ -71,10 +71,12 @@ typedef struct { /** This field is the object management portion of a Period instance. */ Objects_Control Object; +#if defined(RTEMS_SMP) /** * @brief Protects the rate monotonic period state. */ - ISR_LOCK_MEMBER( Lock ) + ISR_lock_Control Lock; +#endif /** This is the timer used to provide the unblocking mechanism. */ Watchdog_Control Timer; diff --git a/cpukit/include/rtems/score/percpu.h b/cpukit/include/rtems/score/percpu.h index 0794f15f69..1dfa7f628d 100644 --- a/cpukit/include/rtems/score/percpu.h +++ b/cpukit/include/rtems/score/percpu.h @@ -465,10 +465,12 @@ typedef struct Per_CPU_Control { * @brief Watchdog state for this processor. */ struct { +#if defined(RTEMS_SMP) /** * @brief Protects all watchdog operations on this processor. */ - ISR_LOCK_MEMBER( Lock ) + ISR_lock_Control Lock; +#endif /** * @brief Watchdog ticks on this processor used for monotonic clock diff --git a/cpukit/include/rtems/score/scheduler.h b/cpukit/include/rtems/score/scheduler.h index 95b4414bea..55be638a8d 100644 --- a/cpukit/include/rtems/score/scheduler.h +++ b/cpukit/include/rtems/score/scheduler.h @@ -297,12 +297,12 @@ typedef struct { * this structure at the begin of its context structure. */ typedef struct Scheduler_Context { +#if defined(RTEMS_SMP) /** * @brief Lock to protect this scheduler instance. */ - ISR_LOCK_MEMBER( Lock ) + ISR_lock_Control Lock; -#if defined(RTEMS_SMP) /** * @brief The set of processors owned by this scheduler instance. */ diff --git a/cpukit/include/rtems/score/thread.h b/cpukit/include/rtems/score/thread.h index c3c37eb160..adde98f9bf 100644 --- a/cpukit/include/rtems/score/thread.h +++ b/cpukit/include/rtems/score/thread.h @@ -673,10 +673,12 @@ typedef struct { */ RBTree_Control Key_value_pairs; +#if defined(RTEMS_SMP) /** * @brief Lock to protect the tree operations. */ - ISR_LOCK_MEMBER( Lock ) + ISR_lock_Control Lock; +#endif } Thread_Keys_information; /** diff --git a/cpukit/include/rtems/score/userextimpl.h b/cpukit/include/rtems/score/userextimpl.h index fd075a94ec..649d191b18 100644 --- a/cpukit/include/rtems/score/userextimpl.h +++ b/cpukit/include/rtems/score/userextimpl.h @@ -60,11 +60,13 @@ typedef struct { */ Chain_Iterator_registry Iterators; +#if defined(RTEMS_SMP) /** * @brief Lock to protect User_extensions_List::Active and * User_extensions_List::Iterators. */ - ISR_LOCK_MEMBER( Lock ) + ISR_lock_Control Lock; +#endif } User_extensions_List; /** -- 2.31.1 From chrisj at rtems.org Thu Dec 9 21:09:22 2021 From: chrisj at rtems.org (Chris Johns) Date: Fri, 10 Dec 2021 08:09:22 +1100 Subject: [rtems commit] untar: Make behavior similar to GNU or BSD tar In-Reply-To: <9ec242f5-f3a7-7bbf-0443-81e5cfc4d7a9@embedded-brains.de> References: <20211209072118.C0B524E76F@lists.rtems.org> <9ec242f5-f3a7-7bbf-0443-81e5cfc4d7a9@embedded-brains.de> Message-ID: <75ec8bd7-49cc-d252-e13d-89898a31759b@rtems.org> On 9/12/21 6:47 pm, Christian MAUDERER wrote: > Hello Chris, > > sorry that I haven't been clear enough. > > 1. The ticket #4552 that I created before sending the patch to the list and that > was closed by the patch was for 5. > > 2. I asked as an answer to Joels review and I understood him that he is OK with > that change: > > ? https://lists.rtems.org/pipermail/devel/2021-December/070092.html > > and > > ? https://lists.rtems.org/pipermail/devel/2021-December/070093.html Again sorry I missed this when I brushed over the emails. > > Do you want me to revert that patch on 5? > It does change the expected functionality and we should be careful about doing that. It is not clear if someone has relied on it working this way as a cheap way to detect an overwrite. I am fine on RTEMS 6 because of the upgrade and a ticket in the release notes covering the change however if it breaks in a dot release then that is a different issue. Given it is in maybe we let it sit and it there is feedback we come back and take another look? Chris From ryan.long at oarcorp.com Thu Dec 9 23:00:08 2021 From: ryan.long at oarcorp.com (Ryan Long) Date: Thu, 9 Dec 2021 18:00:08 -0500 Subject: [PATCH v2 1/4] TargetFactory.cc: Convert to C++ In-Reply-To: <1639090811-29435-1-git-send-email-ryan.long@oarcorp.com> References: <1639090811-29435-1-git-send-email-ryan.long@oarcorp.com> Message-ID: <1639090811-29435-2-git-send-email-ryan.long@oarcorp.com> --- tester/covoar/TargetFactory.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tester/covoar/TargetFactory.cc b/tester/covoar/TargetFactory.cc index 57ba686..fa72f05 100644 --- a/tester/covoar/TargetFactory.cc +++ b/tester/covoar/TargetFactory.cc @@ -37,7 +37,7 @@ namespace Target { //! typedef struct { //! This is the string found in configuration to match. - const char *theTarget; + std::string theTarget; //! This is the static wrapper for the constructor. TargetBase *(*theCtor)( std::string @@ -76,10 +76,10 @@ namespace Target { else cpu = targetName.substr( 0, i ); - // fprintf( stderr, "%s --> %s\n", targetName.c_str(), cpu.c_str()); + // std::cerr << targetName << " --> " << cpu << std::endl; // Iterate over the table trying to find an entry with a matching name for ( i=0 ; i < sizeof(FactoryTable) / sizeof(FactoryEntry_t); i++ ) { - if ( !strcmp(FactoryTable[i].theTarget, cpu.c_str() ) ) + if ( FactoryTable[i].theTarget == cpu ) return FactoryTable[i].theCtor( targetName ); } -- 1.8.3.1 From ryan.long at oarcorp.com Thu Dec 9 23:00:07 2021 From: ryan.long at oarcorp.com (Ryan Long) Date: Thu, 9 Dec 2021 18:00:07 -0500 Subject: [PATCH rtems-tools v2 0/4] Convert to C++ patches Message-ID: <1639090811-29435-1-git-send-email-ryan.long@oarcorp.com> Hi, For this round of changes, I made some revisions that were recommended in ConfigFile.cc - deleted a library include - changed a function call from sscanf to std::sscanf - consolidated some error messages into a function Thanks, Ryan Ryan Long (4): TargetFactory.cc: Convert to C++ Target: Convert to C++ ConfigFile: Convert to C++ ObjdumpProcessor: Convert to C++ tester/covoar/ConfigFile.cc | 82 +++++++++++++++------------------------ tester/covoar/ConfigFile.h | 2 +- tester/covoar/ObjdumpProcessor.cc | 27 +++++++------ tester/covoar/ObjdumpProcessor.h | 6 +-- tester/covoar/TargetBase.cc | 35 +++++++++-------- tester/covoar/TargetBase.h | 18 ++++----- tester/covoar/TargetFactory.cc | 6 +-- tester/covoar/Target_aarch64.cc | 18 +++++---- tester/covoar/Target_aarch64.h | 6 +-- tester/covoar/Target_arm.cc | 16 ++++---- tester/covoar/Target_arm.h | 6 +-- tester/covoar/Target_i386.cc | 22 ++++++----- tester/covoar/Target_i386.h | 4 +- tester/covoar/Target_lm32.cc | 6 +-- tester/covoar/Target_lm32.h | 4 +- tester/covoar/Target_m68k.cc | 12 +++--- tester/covoar/Target_m68k.h | 6 +-- tester/covoar/Target_powerpc.cc | 8 ++-- tester/covoar/Target_powerpc.h | 4 +- tester/covoar/Target_riscv.cc | 6 +-- tester/covoar/Target_riscv.h | 6 +-- tester/covoar/Target_sparc.cc | 12 +++--- tester/covoar/Target_sparc.h | 6 +-- 23 files changed, 157 insertions(+), 161 deletions(-) -- 1.8.3.1 From ryan.long at oarcorp.com Thu Dec 9 23:00:10 2021 From: ryan.long at oarcorp.com (Ryan Long) Date: Thu, 9 Dec 2021 18:00:10 -0500 Subject: [PATCH v2 3/4] ConfigFile: Convert to C++ In-Reply-To: <1639090811-29435-1-git-send-email-ryan.long@oarcorp.com> References: <1639090811-29435-1-git-send-email-ryan.long@oarcorp.com> Message-ID: <1639090811-29435-4-git-send-email-ryan.long@oarcorp.com> --- tester/covoar/ConfigFile.cc | 82 ++++++++++++++++++--------------------------- tester/covoar/ConfigFile.h | 2 +- 2 files changed, 33 insertions(+), 51 deletions(-) diff --git a/tester/covoar/ConfigFile.cc b/tester/covoar/ConfigFile.cc index c16b64a..7109b2c 100644 --- a/tester/covoar/ConfigFile.cc +++ b/tester/covoar/ConfigFile.cc @@ -7,9 +7,18 @@ #include "ConfigFile.h" #include -#include #include +#include +#include +#include + +static void print_invalid_line_number( const std::string& file, int line_no ) +{ + std::cerr << file << ": line" << line_no << " is invalid: " << line + << std::endl; +} + namespace Configuration { FileReader::FileReader( @@ -24,43 +33,40 @@ namespace Configuration { } bool FileReader::processFile( - const char* const file + const std::string& file ) { #define METHOD "FileReader::processFile - " - FILE * in; - char line[256]; - char option[256]; - char value[256]; + #define MAX_LENGTH 256 + std::ifstream in; + std::string line; + char option[MAX_LENGTH]; + char value[MAX_LENGTH]; int line_no; int i; int j; - if ( file == NULL ) { - fprintf( stderr, METHOD "NULL filename\n" ); + if ( file.empty() ) { + std::cerr << METHOD << "Empty filename" << std::endl; return false; } - in = fopen( file, "r" ); - if ( !in ) { - fprintf( stderr, METHOD "unable to open %s\n", file ); + in.open( file ); + if ( !in.is_open() ) { + std::cerr << METHOD << "unable to open " << file << std::endl; return false; } line_no = 0; - while (fgets(line, sizeof(line), in) != NULL) { + while ( std::getline( line, MAX_LENGTH ) ) { int length; line_no++; - length = (int) strlen( line ); - if ( line[length - 1] != '\n' ) { - fprintf( - stderr, - "%s: line %d is too long", - file, - line_no - ); + length = (int) line.length(); + if ( length > MAX_LENGTH ) { + std::cerr << file << ": line " << line_no << " is too long" + << std::endl; continue; } @@ -96,14 +102,8 @@ namespace Configuration { if (line[0] == '\0') continue; - if (sscanf(line, "%s", option) != 1) { - fprintf( - stderr, - "%s: line %d is invalid: %s\n", - file, - line_no, - line - ); + if (std::sscanf(line.c_str(), "%s", option) != 1) { + print_invalid_line_number(file, line_no); continue; } @@ -111,13 +111,7 @@ namespace Configuration { ; if (i == length) { - fprintf( - stderr, - "%s: line %d is invalid: %s\n", - file, - line_no, - line - ); + print_invalid_line_number(file, line_no); continue; } @@ -129,24 +123,12 @@ namespace Configuration { value[j] = line[i]; value[j] = '\0'; if (value[0] == '\0') { - fprintf( - stderr, - "%s: line %d is invalid: %s\n", - file, - line_no, - line - ); + print_invalid_line_number(file, line_no); continue; } if ( !setOption(option, value) ) { - fprintf( - stderr, - "%s: line %d: option %s is unknown\n", - file, - line_no, - option - ); + print_invalid_line_number(file, line_no); continue; } @@ -190,7 +172,7 @@ namespace Configuration { Options_t *o; for ( o=options_m ; o->option ; o++ ) { - fprintf( stderr, "(%s)=(%s)\n", o->option, o->value ); + std::cerr << '(' << o->option << ")=(" << o->value << ')' << std::endl; } } } diff --git a/tester/covoar/ConfigFile.h b/tester/covoar/ConfigFile.h index 0bae7ac..f8bd9c5 100644 --- a/tester/covoar/ConfigFile.h +++ b/tester/covoar/ConfigFile.h @@ -54,7 +54,7 @@ namespace Configuration { * @return Returns TRUE if the method succeeded and FALSE if it failed. */ virtual bool processFile( - const char* const file + const std::string& file ); bool setOption( -- 1.8.3.1 From ryan.long at oarcorp.com Thu Dec 9 23:00:09 2021 From: ryan.long at oarcorp.com (Ryan Long) Date: Thu, 9 Dec 2021 18:00:09 -0500 Subject: [PATCH v2 2/4] Target: Convert to C++ In-Reply-To: <1639090811-29435-1-git-send-email-ryan.long@oarcorp.com> References: <1639090811-29435-1-git-send-email-ryan.long@oarcorp.com> Message-ID: <1639090811-29435-3-git-send-email-ryan.long@oarcorp.com> --- tester/covoar/TargetBase.cc | 35 ++++++++++++++++++----------------- tester/covoar/TargetBase.h | 18 +++++++++--------- tester/covoar/Target_aarch64.cc | 18 ++++++++++-------- tester/covoar/Target_aarch64.h | 6 +++--- tester/covoar/Target_arm.cc | 16 +++++++++------- tester/covoar/Target_arm.h | 6 +++--- tester/covoar/Target_i386.cc | 22 ++++++++++++---------- tester/covoar/Target_i386.h | 4 ++-- tester/covoar/Target_lm32.cc | 6 +++--- tester/covoar/Target_lm32.h | 4 ++-- tester/covoar/Target_m68k.cc | 12 +++++++----- tester/covoar/Target_m68k.h | 6 +++--- tester/covoar/Target_powerpc.cc | 8 ++++---- tester/covoar/Target_powerpc.h | 4 ++-- tester/covoar/Target_riscv.cc | 6 +++--- tester/covoar/Target_riscv.h | 6 +++--- tester/covoar/Target_sparc.cc | 12 +++++++----- tester/covoar/Target_sparc.h | 6 +++--- 18 files changed, 103 insertions(+), 92 deletions(-) diff --git a/tester/covoar/TargetBase.cc b/tester/covoar/TargetBase.cc index 7ee45b5..a62e90f 100644 --- a/tester/covoar/TargetBase.cc +++ b/tester/covoar/TargetBase.cc @@ -40,24 +40,24 @@ namespace Target { { } - const char* TargetBase::getAddr2line() const + const std::string& TargetBase::getAddr2line() const { - return addr2line_m.c_str(); + return addr2line_m; } - const char* TargetBase::getCPU( void ) const + const std::string& TargetBase::getCPU() const { - return cpu_m.c_str(); + return cpu_m; } - const char* TargetBase::getObjdump() const + const std::string& TargetBase::getObjdump() const { - return objdump_m.c_str(); + return objdump_m; } - const char* TargetBase::getTarget( void ) const + const std::string& TargetBase::getTarget() const { - return targetName_m.c_str(); + return targetName_m; } bool TargetBase::isBranch( const std::string& instruction ) @@ -83,12 +83,13 @@ namespace Target { } bool TargetBase::isBranchLine( - const char* const line + const std::string& line ) { - #define WARNING \ - "WARNING: TargetBase::isBranchLine - (%d) " \ - "Unable to find instruction in: %s\n" + #define WARNING_PT1 \ + "WARNING: TargetBase::isBranchLine - (" + #define WARNING_PT2 \ + ") Unable to find instruction in: " const char *ch; char instruction[120]; int result; @@ -101,7 +102,7 @@ namespace Target { ch++; } if (*ch != '\t') { - fprintf( stderr, WARNING, 1, line ); + std::cerr << WARNING_PT1 << 1 << WARNING_PT2 << line << std::endl; return false; } ch++; @@ -110,7 +111,7 @@ namespace Target { while ((*ch != '\t') && (*ch != '\0')) ch++; if (*ch != '\t') { - fprintf( stderr, WARNING, 2, line) ; + std::cerr << WARNING_PT1 << 2 << WARNING_PT2 << line << std::endl; return false; } ch++; @@ -119,19 +120,19 @@ namespace Target { // after the second tab. result = sscanf( ch, "%s", instruction ); if (result != 1) { - fprintf( stderr, WARNING, 3, line ); + std::cerr << WARNING_PT1 << 3 << WARNING_PT2 << line << std::endl; return false; } return isBranch( instruction ); } - uint8_t TargetBase::qemuTakenBit(void) + uint8_t TargetBase::qemuTakenBit() { return TRACE_OP_BR0; } - uint8_t TargetBase::qemuNotTakenBit(void) + uint8_t TargetBase::qemuNotTakenBit() { return TRACE_OP_BR1; } diff --git a/tester/covoar/TargetBase.h b/tester/covoar/TargetBase.h index e5c143e..0a75c85 100644 --- a/tester/covoar/TargetBase.h +++ b/tester/covoar/TargetBase.h @@ -42,28 +42,28 @@ namespace Target { * * @return Returns the target specific addr2line program name */ - const char* getAddr2line( void ) const; + const std::string& getAddr2line() const; /*! * This method returns the CPU name. * * @return Returns the target cpu name */ - const char* getCPU( void ) const; + const std::string& getCPU() const; /*! * This method returns the program name for objdump. * * @return Returns the target specific objdump program name */ - const char* getObjdump( void ) const; + const std::string& getObjdump() const; /*! * This method returns the target name. * * @return Returns the target name */ - const char* getTarget( void ) const; + const std::string& getTarget() const; /*! * This method determines whether the specified line from a @@ -75,8 +75,8 @@ namespace Target { * @return Returns TRUE if the instruction is a nop, FALSE otherwise. */ virtual bool isNopLine( - const char* const line, - int& size + const std::string& line, + int& size ) = 0; @@ -90,7 +90,7 @@ namespace Target { * @return Returns TRUE if the instruction is a branch, FALSE otherwise. */ bool isBranchLine( - const char* const line + const std::string& line ); @@ -104,13 +104,13 @@ namespace Target { * This method returns the bit set by Qemu in the trace record * when a branch is taken. */ - virtual uint8_t qemuTakenBit(void); + virtual uint8_t qemuTakenBit(); /*! * This method returns the bit set by Qemu in the trace record * when a branch is taken. */ - virtual uint8_t qemuNotTakenBit(void); + virtual uint8_t qemuNotTakenBit(); protected: diff --git a/tester/covoar/Target_aarch64.cc b/tester/covoar/Target_aarch64.cc index 4d16456..139f5fe 100644 --- a/tester/covoar/Target_aarch64.cc +++ b/tester/covoar/Target_aarch64.cc @@ -49,31 +49,33 @@ namespace Target { } bool Target_aarch64::isNopLine( - const char* const line, - int& size + const std::string& line, + int& size ) { - if (!strcmp( &line[strlen(line)-3], "nop")) { + size_t stringLen = line.length(); + + if ( line.substr( stringLen - 3 ) == "nop" ) { size = 4; return true; } - if (!strncmp( &line[strlen(line)-6], "udf", 3)) { + if ( line.substr( stringLen - 6, 3 ) == "udf" ) { size = 4; return true; } // On ARM, there are literal tables at the end of methods. // We need to avoid them. - if (!strncmp( &line[strlen(line)-10], ".byte", 5)) { + if ( line.substr( stringLen - 10, 5 ) == ".byte" ) { size = 1; return true; } - if (!strncmp( &line[strlen(line)-13], ".short", 6)) { + if ( line.substr( stringLen - 13, 6 ) == ".short" ) { size = 2; return true; } - if (!strncmp( &line[strlen(line)-16], ".word", 5)) { + if ( line.substr( stringLen - 16, 5 ) == ".word" ) { size = 4; return true; } @@ -82,7 +84,7 @@ namespace Target { } bool Target_aarch64::isBranch( - const char* instruction + const std::string& instruction ) { throw rld::error( diff --git a/tester/covoar/Target_aarch64.h b/tester/covoar/Target_aarch64.h index fb011e8..42353e5 100644 --- a/tester/covoar/Target_aarch64.h +++ b/tester/covoar/Target_aarch64.h @@ -42,8 +42,8 @@ namespace Target { * @return Returns TRUE if the instruction is a nop, FALSE otherwise. */ virtual bool isNopLine( - const char* const line, - int& size + const std::string& line, + int& size ) override; /*! @@ -51,7 +51,7 @@ namespace Target { * objdump file is a branch instruction. */ bool isBranch( - const char* const instruction + const std::string& instruction ); /* Documentation inherited from base class */ diff --git a/tester/covoar/Target_arm.cc b/tester/covoar/Target_arm.cc index 94d50bb..50c9ce3 100644 --- a/tester/covoar/Target_arm.cc +++ b/tester/covoar/Target_arm.cc @@ -82,26 +82,28 @@ namespace Target { } bool Target_arm::isNopLine( - const char* const line, - int& size + const std::string& line, + int& size ) { - if (!strcmp( &line[strlen(line)-3], "nop")) { + size_t stringLen = line.length(); + + if ( line.substr( stringLen - 3 ) == "nop" ) { size = 4; return true; } // On ARM, there are literal tables at the end of methods. // We need to avoid them. - if (!strncmp( &line[strlen(line)-10], ".byte", 5)) { + if ( line.substr( stringLen - 10, 5 ) == ".byte" ) { size = 1; return true; } - if (!strncmp( &line[strlen(line)-13], ".short", 6)) { + if ( line.substr( stringLen - 13, 6 ) == ".short" ) { size = 2; return true; } - if (!strncmp( &line[strlen(line)-16], ".word", 5)) { + if ( line.substr( stringLen - 16, 5 ) == ".word" ) { size = 4; return true; } @@ -111,7 +113,7 @@ namespace Target { } bool Target_arm::isBranch( - const char* instruction + const std::string& instruction ) { throw rld::error( diff --git a/tester/covoar/Target_arm.h b/tester/covoar/Target_arm.h index 80b68af..3ff9b6f 100644 --- a/tester/covoar/Target_arm.h +++ b/tester/covoar/Target_arm.h @@ -42,8 +42,8 @@ namespace Target { * @return Returns TRUE if the instruction is a nop, FALSE otherwise. */ bool isNopLine( - const char* const line, - int& size + const std::string& line, + int& size ); /*! @@ -51,7 +51,7 @@ namespace Target { * objdump file is a branch instruction. */ bool isBranch( - const char* const instruction + const std::string& instruction ); private: diff --git a/tester/covoar/Target_i386.cc b/tester/covoar/Target_i386.cc index 2990273..cb8e64d 100644 --- a/tester/covoar/Target_i386.cc +++ b/tester/covoar/Target_i386.cc @@ -57,39 +57,41 @@ namespace Target { } bool Target_i386::isNopLine( - const char* const line, - int& size + const std::string& line, + int& size ) { - if (!strcmp( &line[strlen(line)-3], "nop")) { + size_t stringLen = line.length(); + + if ( line.substr( stringLen - 3 ) == "nop" ) { size = 1; return true; } // i386 has some two and three byte nops - if (!strncmp( &line[strlen(line)-14], "xchg %ax,%ax", 14)) { + if ( line.substr( stringLen - 14 ) == "xchg %ax,%ax" ) { size = 2; return true; } - if (!strncmp( &line[strlen(line)-16], "xor %eax,%eax", 16)) { + if ( line.substr( stringLen - 16 ) == "xor %eax,%eax" ) { size = 2; return true; } - if (!strncmp( &line[strlen(line)-16], "xor %ebx,%ebx", 16)) { + if ( line.substr( stringLen - 16 ) == "xor %ebx,%ebx" ) { size = 2; return true; } - if (!strncmp( &line[strlen(line)-16], "xor %esi,%esi", 16)) { + if ( line.substr( stringLen - 16 ) == "xor %esi,%esi" ) { size = 2; return true; } - if (!strncmp( &line[strlen(line)-21], "lea 0x0(%esi),%esi", 21)) { + if ( line.substr( stringLen - 21 ) == "lea 0x0(%esi),%esi" ) { size = 3; return true; } - if (!strncmp( &line[strlen(line)-28], "lea 0x0(%esi,%eiz,1),%esi", 28)) { + if ( line.substr( stringLen - 28 ) == "lea 0x0(%esi,%eiz,1),%esi" ) { // Could be 4 or 7 bytes of padding. - if (!strncmp( &line[strlen(line)-32], "00", 2)) { + if ( line.substr( stringLen - 32, 2 ) == "00" ) { size = 7; } else { size = 4; diff --git a/tester/covoar/Target_i386.h b/tester/covoar/Target_i386.h index 3641de7..c9a79cd 100644 --- a/tester/covoar/Target_i386.h +++ b/tester/covoar/Target_i386.h @@ -43,8 +43,8 @@ namespace Target { * @return Returns TRUE if the instruction is a nop, FALSE otherwise. */ bool isNopLine( - const char* const line, - int& size + const std::string& line, + int& size ); /* Documentation inherited from base class */ diff --git a/tester/covoar/Target_lm32.cc b/tester/covoar/Target_lm32.cc index 18e7191..7babbd2 100644 --- a/tester/covoar/Target_lm32.cc +++ b/tester/covoar/Target_lm32.cc @@ -30,11 +30,11 @@ namespace Target { } bool Target_lm32::isNopLine( - const char* const line, - int& size + const std::string& line, + int& size ) { - if (!strcmp( &line[strlen(line)-3], "nop")) { + if ( line.substr( line.length() - 3 ) == "nop" ) { size = 4; return true; } diff --git a/tester/covoar/Target_lm32.h b/tester/covoar/Target_lm32.h index 5d23db5..d21776e 100644 --- a/tester/covoar/Target_lm32.h +++ b/tester/covoar/Target_lm32.h @@ -43,8 +43,8 @@ namespace Target { * @return Returns TRUE if the instruction is a nop, FALSE otherwise. */ bool isNopLine( - const char* const line, - int& size + const std::string& line, + int& size ); private: diff --git a/tester/covoar/Target_m68k.cc b/tester/covoar/Target_m68k.cc index 536ae80..7c761be 100644 --- a/tester/covoar/Target_m68k.cc +++ b/tester/covoar/Target_m68k.cc @@ -77,11 +77,13 @@ namespace Target { } bool Target_m68k::isNopLine( - const char* const line, - int& size + const std::string& line, + int& size ) { - if (!strcmp( &line[strlen(line)-3], "nop")) { + size_t stringLen = line.length(); + + if ( line.substr( stringLen - 3 ) == "nop" ) { size = 2; return true; } @@ -89,7 +91,7 @@ namespace Target { #define GNU_LD_FILLS_ALIGNMENT_WITH_RTS #if defined(GNU_LD_FILLS_ALIGNMENT_WITH_RTS) // Until binutils 2.20, binutils would fill with rts not nop - if (!strcmp( &line[strlen(line)-3], "rts")) { + if ( line.substr( stringLen - 3 ) == "rts" ) { size = 4; return true; } @@ -99,7 +101,7 @@ namespace Target { } bool Target_m68k::isBranch( - const char* const instruction + const std::string& instruction ) { throw rld::error( diff --git a/tester/covoar/Target_m68k.h b/tester/covoar/Target_m68k.h index 5ed7933..13a6030 100644 --- a/tester/covoar/Target_m68k.h +++ b/tester/covoar/Target_m68k.h @@ -43,8 +43,8 @@ namespace Target { * @return Returns TRUE if the instruction is a nop, FALSE otherwise. */ bool isNopLine( - const char* const line, - int& size + const std::string& line, + int& size ); /*! @@ -52,7 +52,7 @@ namespace Target { * objdump file is a branch instruction. */ bool isBranch( - const char* const instruction + const std::string& instruction ); /* Documentation inherited from base class */ diff --git a/tester/covoar/Target_powerpc.cc b/tester/covoar/Target_powerpc.cc index c62feb0..6cc541d 100644 --- a/tester/covoar/Target_powerpc.cc +++ b/tester/covoar/Target_powerpc.cc @@ -58,11 +58,11 @@ namespace Target { } bool Target_powerpc::isNopLine( - const char* const line, - int& size + const std::string& line, + int& size ) { - if (!strcmp( &line[strlen(line)-3], "nop")) { + if ( line.substr( line.length() - 3 ) == "nop" ) { size = 4; return true; } @@ -71,7 +71,7 @@ namespace Target { } bool Target_powerpc::isBranch( - const char* const instruction + const std::string& instruction ) { throw rld::error( diff --git a/tester/covoar/Target_powerpc.h b/tester/covoar/Target_powerpc.h index 3008d4c..b446918 100644 --- a/tester/covoar/Target_powerpc.h +++ b/tester/covoar/Target_powerpc.h @@ -43,7 +43,7 @@ namespace Target { * @return Returns TRUE if the instruction is a nop, FALSE otherwise. */ bool isNopLine( - const char* const line, + const std::string& line, int& size ); @@ -52,7 +52,7 @@ namespace Target { * objdump file is a branch instruction. */ bool isBranch( - const char* const instruction + const std::string& instruction ); private: diff --git a/tester/covoar/Target_riscv.cc b/tester/covoar/Target_riscv.cc index 13c81c5..d0b5a8e 100644 --- a/tester/covoar/Target_riscv.cc +++ b/tester/covoar/Target_riscv.cc @@ -62,11 +62,11 @@ namespace Target { } bool Target_riscv::isNopLine( - const char* const line, - int& size + const std::string& line, + int& size ) { - if (!strcmp( &line[strlen(line)-3], "nop")){ + if ( line.substr( line.length() - 3 ) == "nop" ) { size = 4; return true; } diff --git a/tester/covoar/Target_riscv.h b/tester/covoar/Target_riscv.h index 64a63d4..1442f69 100644 --- a/tester/covoar/Target_riscv.h +++ b/tester/covoar/Target_riscv.h @@ -67,8 +67,8 @@ namespace Target { * @return Returns True if the instruction is nop, False otherwise. */ bool isNopLine( - const char* const line, - int& size + const std::string& line, + int& size ); /*! @@ -80,7 +80,7 @@ namespace Target { */ bool isBranch( - const char* const instruction + const std::string& instruction ); private: diff --git a/tester/covoar/Target_sparc.cc b/tester/covoar/Target_sparc.cc index fbdcd1e..a9435cb 100644 --- a/tester/covoar/Target_sparc.cc +++ b/tester/covoar/Target_sparc.cc @@ -56,23 +56,25 @@ namespace Target { } bool Target_sparc::isNopLine( - const char* const line, - int& size + const std::string& line, + int& size ) { - if (!strcmp( &line[strlen(line)-3], "nop")) { + size_t stringLen = line.length(); + + if ( line.substr( stringLen - 3 ) == "nop" ) { size = 4; return true; } - if (!strcmp( &line[strlen(line)-7], "unknown")) { + if ( line.substr( stringLen - 7 ) == "unknown" ) { size = 4; return true; } #define GNU_LD_FILLS_ALIGNMENT_WITH_RTS #if defined(GNU_LD_FILLS_ALIGNMENT_WITH_RTS) // Until binutils 2.20, binutils would fill with rts not nop - if (!strcmp( &line[strlen(line)-3], "rts")) { + if ( line.substr( stringLen - 3 ) == "rts" ) { size = 4; return true; } diff --git a/tester/covoar/Target_sparc.h b/tester/covoar/Target_sparc.h index 0e38859..cbe2faf 100644 --- a/tester/covoar/Target_sparc.h +++ b/tester/covoar/Target_sparc.h @@ -43,8 +43,8 @@ namespace Target { * @return Returns TRUE if the instruction is a nop, FALSE otherwise. */ bool isNopLine( - const char* const line, - int& size + const std::string& line, + int& size ); /*! @@ -52,7 +52,7 @@ namespace Target { * objdump file is a branch instruction. */ bool isBranch( - const char* const instruction + const std::string& instruction ); private: -- 1.8.3.1 From ryan.long at oarcorp.com Thu Dec 9 23:00:11 2021 From: ryan.long at oarcorp.com (Ryan Long) Date: Thu, 9 Dec 2021 18:00:11 -0500 Subject: [PATCH v2 4/4] ObjdumpProcessor: Convert to C++ In-Reply-To: <1639090811-29435-1-git-send-email-ryan.long@oarcorp.com> References: <1639090811-29435-1-git-send-email-ryan.long@oarcorp.com> Message-ID: <1639090811-29435-5-git-send-email-ryan.long@oarcorp.com> --- tester/covoar/ObjdumpProcessor.cc | 27 +++++++++++++++------------ tester/covoar/ObjdumpProcessor.h | 6 +++--- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/tester/covoar/ObjdumpProcessor.cc b/tester/covoar/ObjdumpProcessor.cc index c910046..8c0e8dc 100644 --- a/tester/covoar/ObjdumpProcessor.cc +++ b/tester/covoar/ObjdumpProcessor.cc @@ -13,6 +13,8 @@ #include #include #include +#include +#include #include "ObjdumpProcessor.h" #include "CoverageMap.h" @@ -139,8 +141,7 @@ namespace Coverage { ) { #define METHOD "ERROR: ObjdumpProcessor::determineLoadAddress - " - FILE* loadAddressFile = NULL; - char* cStatus; + std::ifstream loadAddressFile; uint32_t offset; char inputBuffer[MAX_LINE_LENGTH]; @@ -155,8 +156,8 @@ namespace Coverage { dlinfoName += ".dlinfo"; // Read load address. - loadAddressFile = ::fopen( dlinfoName.c_str(), "r" ); - if (!loadAddressFile) { + loadAddressFile.open( dlinfoName ); + if (!loadAddressFile.is_open()) { std::ostringstream what; what << "Unable to open " << dlinfoName; throw rld::error( what, METHOD ); @@ -166,9 +167,9 @@ namespace Coverage { while ( 1 ) { // Get a line. - cStatus = ::fgets( inputBuffer, MAX_LINE_LENGTH, loadAddressFile ); - if (cStatus == NULL) { - ::fclose( loadAddressFile ); + loadAddressFile.getline( inputBuffer, MAX_LINE_LENGTH ); + if ( loadAddressFile.fail() && loadAddressFile.is_open() ) { + loadAddressFile.close(); std::ostringstream what; what << "library " << Library << " not found in " << dlinfoName; throw rld::error( what, METHOD ); @@ -176,13 +177,15 @@ namespace Coverage { sscanf( inputBuffer, "%s %x", inLibName, &offset ); std::string tmp = inLibName; if ( tmp.find( Library ) != tmp.npos ) { - // fprintf( stderr, "%s - 0x%08x\n", inLibName, offset ); + // std::cerr << inLibName << " - 0x" + // << std::setfill( '0' ) << std::setw( 8 ) << std::hex + // << offset << std::endl + // << std::dec << std::setfill( ' ' ); address = offset; break; } } - ::fclose( loadAddressFile ); return address; #undef METHOD @@ -203,7 +206,7 @@ namespace Coverage { } bool ObjdumpProcessor::isBranchLine( - const char* const line + const std::string& line ) { if ( !targetInfo_m ) { @@ -219,8 +222,8 @@ namespace Coverage { } bool ObjdumpProcessor::isNop( - const char* const line, - int& size + const std::string& line, + int& size ) { if ( !targetInfo_m ){ diff --git a/tester/covoar/ObjdumpProcessor.h b/tester/covoar/ObjdumpProcessor.h index 05a667f..0ca14b8 100644 --- a/tester/covoar/ObjdumpProcessor.h +++ b/tester/covoar/ObjdumpProcessor.h @@ -151,7 +151,7 @@ namespace Coverage { * otherwise it returns false. */ bool isBranchLine( - const char* const line + const std::string& line ); /*! @@ -179,8 +179,8 @@ namespace Coverage { * @return Returns TRUE if the instruction is a nop, FALSE otherwise. */ bool isNop( - const char* const line, - int& size + const std::string& line, + int& size ); /*! -- 1.8.3.1 From chrisj at rtems.org Fri Dec 10 00:51:44 2021 From: chrisj at rtems.org (Chris Johns) Date: Fri, 10 Dec 2021 11:51:44 +1100 Subject: [PATCH rtems-tools v2 0/4] Convert to C++ patches In-Reply-To: <1639090811-29435-1-git-send-email-ryan.long@oarcorp.com> References: <1639090811-29435-1-git-send-email-ryan.long@oarcorp.com> Message-ID: On 10/12/21 10:00 am, Ryan Long wrote: > For this round of changes, I made some revisions that were recommended > in ConfigFile.cc > > - deleted a library include > - changed a function call from sscanf to std::sscanf > - consolidated some error messages into a function OK to push. Thanks Chris From christian.mauderer at embedded-brains.de Fri Dec 10 07:20:29 2021 From: christian.mauderer at embedded-brains.de (Christian MAUDERER) Date: Fri, 10 Dec 2021 08:20:29 +0100 Subject: [rtems commit] untar: Make behavior similar to GNU or BSD tar In-Reply-To: <75ec8bd7-49cc-d252-e13d-89898a31759b@rtems.org> References: <20211209072118.C0B524E76F@lists.rtems.org> <9ec242f5-f3a7-7bbf-0443-81e5cfc4d7a9@embedded-brains.de> <75ec8bd7-49cc-d252-e13d-89898a31759b@rtems.org> Message-ID: <86fdf8ac-6315-2fcc-79b3-066c416d206d@embedded-brains.de> Hello Chris, Am 09.12.21 um 22:09 schrieb Chris Johns: > On 9/12/21 6:47 pm, Christian MAUDERER wrote: >> Hello Chris, >> >> sorry that I haven't been clear enough. >> >> 1. The ticket #4552 that I created before sending the patch to the list and that >> was closed by the patch was for 5. >> >> 2. I asked as an answer to Joels review and I understood him that he is OK with >> that change: >> >> ? https://lists.rtems.org/pipermail/devel/2021-December/070092.html >> >> and >> >> ? https://lists.rtems.org/pipermail/devel/2021-December/070093.html > > Again sorry I missed this when I brushed over the emails. > My fault for not making it more clear. I'll try to add this kind of information into the first mail next time. >> >> Do you want me to revert that patch on 5? >> > > It does change the expected functionality and we should be careful about doing > that. It is not clear if someone has relied on it working this way as a cheap > way to detect an overwrite. I am fine on RTEMS 6 because of the upgrade and a > ticket in the release notes covering the change however if it breaks in a dot > release then that is a different issue. Also that would be a horrible and very fragile method to detect an overwrite (files could still be overwritten; the archive would have to be packed correctly with a directory at the beginning to detect it reliable) I understand your point. Even if it is unlikely, it could be possible that someone tested for that behavior and maybe has problems if it changes. > > Given it is in maybe we let it sit and it there is feedback we come back and > take another look? No problem with that. I will try to be extra sensitive for problems with Untar that appear on the list in the next months. Best regards Christian > > Chris > -- -------------------------------------------- embedded brains GmbH Herr Christian MAUDERER Dornierstr. 4 82178 Puchheim Germany email: christian.mauderer at embedded-brains.de phone: +49-89-18 94 741 - 18 fax: +49-89-18 94 741 - 08 Registergericht: Amtsgericht M?nchen Registernummer: HRB 157899 Vertretungsberechtigte Gesch?ftsf?hrer: Peter Rasmussen, Thomas D?rfler Unsere Datenschutzerkl?rung finden Sie hier: https://embedded-brains.de/datenschutzerklaerung/ From sebastian.huber at embedded-brains.de Fri Dec 10 07:53:02 2021 From: sebastian.huber at embedded-brains.de (Sebastian Huber) Date: Fri, 10 Dec 2021 08:53:02 +0100 Subject: [PATCH] rtems: Improve ordering in Message-ID: <20211210075302.6445-1-sebastian.huber@embedded-brains.de> Move the data structure definitions closer to the directives which use them. --- cpukit/include/rtems/rtems/intr.h | 604 +++++++++++++++--------------- 1 file changed, 302 insertions(+), 302 deletions(-) diff --git a/cpukit/include/rtems/rtems/intr.h b/cpukit/include/rtems/rtems/intr.h index b99050e9ce..573cdf6f17 100644 --- a/cpukit/include/rtems/rtems/intr.h +++ b/cpukit/include/rtems/rtems/intr.h @@ -89,40 +89,6 @@ extern "C" { * task to be preempted upon exit from an ISR. */ -/* Generated from spec:/rtems/intr/if/handler */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief Interrupt handler routines shall have this type. - */ -typedef void ( *rtems_interrupt_handler )( void * ); - -/* Generated from spec:/rtems/intr/if/lock */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief This structure represents an ISR lock. - */ -typedef ISR_lock_Control rtems_interrupt_lock; - -/* Generated from spec:/rtems/intr/if/per-handler-routine */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief Visitor routines invoked by rtems_interrupt_handler_iterate() shall - * have this type. - */ -typedef void ( *rtems_interrupt_per_handler_routine )( - void *, - const char *, - rtems_option, - rtems_interrupt_handler, - void * -); - /* Generated from spec:/rtems/intr/if/vector-number */ /** @@ -132,242 +98,14 @@ typedef void ( *rtems_interrupt_per_handler_routine )( */ typedef ISR_Vector_number rtems_vector_number; -/* Generated from spec:/rtems/intr/if/shared */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief This interrupt handler install option allows that the interrupt - * handler may share the interrupt vector with other handler. - */ -#define RTEMS_INTERRUPT_SHARED ( (rtems_option) 0x00000000 ) - -/* Generated from spec:/rtems/intr/if/unique */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief This interrupt handler install option ensures that the interrupt - * handler is unique. - * - * This option prevents other handler from using the same interrupt vector. - */ -#define RTEMS_INTERRUPT_UNIQUE ( (rtems_option) 0x00000001 ) - -/* Generated from spec:/rtems/intr/if/replace */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief This interrupt handler install option requests that the interrupt - * handler replaces the first handler with the same argument. - */ -#define RTEMS_INTERRUPT_REPLACE ( (rtems_option) 0x00000002 ) - -/* Generated from spec:/rtems/intr/if/entry */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief This structure represents an interrupt entry. - * - * @par Notes - * This structure shall be treated as an opaque data type from the API point of - * view. Members shall not be accessed directly. An entry may be initialized - * by RTEMS_INTERRUPT_ENTRY_INITIALIZER() or - * rtems_interrupt_entry_initialize(). It may be installed for an interrupt - * vector with rtems_interrupt_entry_install() and removed from an interrupt - * vector by rtems_interrupt_entry_remove(). - */ -typedef struct rtems_interrupt_entry { - /** - * @brief This member is the interrupt handler routine. - */ - rtems_interrupt_handler handler; - - /** - * @brief This member is the interrupt handler argument. - */ - void *arg; - - /** - * @brief This member is the reference to the next entry or NULL. - */ - struct rtems_interrupt_entry *next; - - /** - * @brief This member is the descriptive information of the entry. - */ - const char *info; -} rtems_interrupt_entry; - -/* Generated from spec:/rtems/intr/if/signal-variant */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief This enumeration provides interrupt trigger signal variants. - */ -typedef enum { - /** - * @brief This interrupt signal variant indicates that the interrupt trigger - * signal is unspecified. - */ - RTEMS_INTERRUPT_UNSPECIFIED_SIGNAL, - - /** - * @brief This interrupt signal variant indicates that the interrupt cannot be - * triggered by a signal. - */ - RTEMS_INTERRUPT_NO_SIGNAL, - - /** - * @brief This interrupt signal variant indicates that the interrupt is - * triggered by a low level signal. - */ - RTEMS_INTERRUPT_SIGNAL_LEVEL_LOW, - - /** - * @brief This interrupt signal variant indicates that the interrupt is - * triggered by a high level signal. - */ - RTEMS_INTERRUPT_SIGNAL_LEVEL_HIGH, - - /** - * @brief This interrupt signal variant indicates that the interrupt is - * triggered by a falling edge signal. - */ - RTEMS_INTERRUPT_SIGNAL_EDGE_FALLING, - - /** - * @brief This interrupt signal variant indicates that the interrupt is - * triggered by a raising edge signal. - */ - RTEMS_INTERRUPT_SIGNAL_EDGE_RAISING -} rtems_interrupt_signal_variant; - -/* Generated from spec:/rtems/intr/if/attributes */ +/* Generated from spec:/rtems/intr/if/level */ /** * @ingroup RTEMSAPIClassicIntr * - * @brief This structure provides the attributes of an interrupt vector. - * - * The rtems_interrupt_get_attributes() directive may be used to obtain the - * attributes of an interrupt vector. + * @brief This integer type represents interrupt levels. */ -typedef struct { - /** - * @brief This member is true, if the interrupt vector is maskable by - * rtems_interrupt_local_disable(), otherwise it is false. - * - * Interrupt vectors which are not maskable by rtems_interrupt_local_disable() - * should be used with care since they cannot use most operating system - * services. - */ - bool is_maskable; - - /** - * @brief This member is true, if the interrupt vector can be enabled by - * rtems_interrupt_vector_enable(), otherwise it is false. - * - * When an interrupt vector can be enabled, this means that the enabled state - * can always be changed from disabled to enabled. For an interrupt vector - * which can be enabled it follows that it may be enabled. - */ - bool can_enable; - - /** - * @brief This member is true, if the interrupt vector may be enabled by - * rtems_interrupt_vector_enable(), otherwise it is false. - * - * When an interrupt vector may be enabled, this means that the enabled state - * may be changed from disabled to enabled. The requested enabled state change - * should be checked by rtems_interrupt_vector_is_enabled(). Some interrupt - * vectors may be optionally available and cannot be enabled on a particular - * target. - */ - bool maybe_enable; - - /** - * @brief This member is true, if the interrupt vector can be disabled by - * rtems_interrupt_vector_disable(), otherwise it is false. - * - * When an interrupt vector can be disabled, this means that the enabled state - * can be changed from enabled to disabled. For an interrupt vector which can - * be disabled it follows that it may be disabled. - */ - bool can_disable; - - /** - * @brief This member is true, if the interrupt vector may be disabled by - * rtems_interrupt_vector_disable(), otherwise it is false. - * - * When an interrupt vector may be disabled, this means that the enabled state - * may be changed from enabled to disabled. The requested enabled state change - * should be checked by rtems_interrupt_vector_is_enabled(). Some interrupt - * vectors may be always enabled and cannot be disabled on a particular target. - */ - bool maybe_disable; - - /** - * @brief This member is true, if the interrupt vector can be raised by - * rtems_interrupt_raise(), otherwise it is false. - */ - bool can_raise; - - /** - * @brief This member is true, if the interrupt vector can be raised on a - * processor by rtems_interrupt_raise_on(), otherwise it is false. - */ - bool can_raise_on; - - /** - * @brief This member is true, if the interrupt vector can be cleared by - * rtems_interrupt_clear(), otherwise it is false. - */ - bool can_clear; - - /** - * @brief This member is true, if the pending status of the interrupt - * associated with the interrupt vector is cleared by an interrupt - * acknowledge from the processor, otherwise it is false. - */ - bool cleared_by_acknowledge; - - /** - * @brief This member is true, if the affinity set of the interrupt vector can - * be obtained by rtems_interrupt_get_affinity(), otherwise it is false. - */ - bool can_get_affinity; - - /** - * @brief This member is true, if the affinity set of the interrupt vector can - * be set by rtems_interrupt_set_affinity(), otherwise it is false. - */ - bool can_set_affinity; - - /** - * @brief This member is true, if the interrupt associated with the interrupt - * vector can be triggered by a message. - * - * Interrupts may be also triggered by signals, rtems_interrupt_raise(), or - * rtems_interrupt_raise_on(). Examples for message triggered interrupts are - * the PCIe MSI/MSI-X and the ARM GICv3 Locality-specific Peripheral Interrupts - * (LPI). - */ - bool can_be_triggered_by_message; - - /** - * @brief This member describes the trigger signal of the interrupt associated - * with the interrupt vector. - * - * Interrupts are normally triggered by signals which indicate an interrupt - * request from a peripheral. Interrupts may be also triggered by messages, - * rtems_interrupt_raise(), or rtems_interrupt_raise_on(). - */ - rtems_interrupt_signal_variant trigger_signal; -} rtems_interrupt_attributes; +typedef ISR_Level rtems_interrupt_level; /* Generated from spec:/rtems/intr/if/isr */ @@ -395,25 +133,6 @@ typedef ISR_Handler rtems_isr; typedef void ( *rtems_isr_entry )( void * ); #endif -/* Generated from spec:/rtems/intr/if/level */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief This integer type represents interrupt levels. - */ -typedef ISR_Level rtems_interrupt_level; - -/* Generated from spec:/rtems/intr/if/lock-context */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief This structure provides an ISR lock context for acquire and release - * pairs. - */ -typedef ISR_lock_Context rtems_interrupt_lock_context; - /* Generated from spec:/rtems/intr/if/catch */ /** @@ -772,6 +491,25 @@ rtems_status_code rtems_interrupt_catch( */ #define rtems_interrupt_is_in_progress() _ISR_Is_in_progress() +/* Generated from spec:/rtems/intr/if/lock */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief This structure represents an ISR lock. + */ +typedef ISR_lock_Control rtems_interrupt_lock; + +/* Generated from spec:/rtems/intr/if/lock-context */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief This structure provides an ISR lock context for acquire and release + * pairs. + */ +typedef ISR_lock_Context rtems_interrupt_lock_context; + /* Generated from spec:/rtems/intr/if/lock-initialize */ /** @@ -1116,32 +854,64 @@ rtems_status_code rtems_interrupt_catch( /** * @ingroup RTEMSAPIClassicIntr * - * @brief Defines an ISR lock member. - * - * @param _designator is the ISR lock member designator. + * @brief Defines an ISR lock member. + * + * @param _designator is the ISR lock member designator. + * + * @par Notes + * Do not add a ";" after this macro. + */ +#define RTEMS_INTERRUPT_LOCK_MEMBER( _designator ) \ + ISR_LOCK_MEMBER( _designator ) + +/* Generated from spec:/rtems/intr/if/lock-reference */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief Defines an ISR lock object reference. + * + * @param _designator is the ISR lock reference designator. + * + * @param _target is the target object to reference. + * + * @par Notes + * Do not add a ";" after this macro. + */ +#define RTEMS_INTERRUPT_LOCK_REFERENCE( _designator, _target ) \ + ISR_LOCK_REFERENCE( _designator, _target ) + +/* Generated from spec:/rtems/intr/if/shared */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief This interrupt handler install option allows that the interrupt + * handler may share the interrupt vector with other handler. + */ +#define RTEMS_INTERRUPT_SHARED ( (rtems_option) 0x00000000 ) + +/* Generated from spec:/rtems/intr/if/unique */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief This interrupt handler install option ensures that the interrupt + * handler is unique. * - * @par Notes - * Do not add a ";" after this macro. + * This option prevents other handler from using the same interrupt vector. */ -#define RTEMS_INTERRUPT_LOCK_MEMBER( _designator ) \ - ISR_LOCK_MEMBER( _designator ) +#define RTEMS_INTERRUPT_UNIQUE ( (rtems_option) 0x00000001 ) -/* Generated from spec:/rtems/intr/if/lock-reference */ +/* Generated from spec:/rtems/intr/if/replace */ /** * @ingroup RTEMSAPIClassicIntr * - * @brief Defines an ISR lock object reference. - * - * @param _designator is the ISR lock reference designator. - * - * @param _target is the target object to reference. - * - * @par Notes - * Do not add a ";" after this macro. + * @brief This interrupt handler install option requests that the interrupt + * handler replaces the first handler with the same argument. */ -#define RTEMS_INTERRUPT_LOCK_REFERENCE( _designator, _target ) \ - ISR_LOCK_REFERENCE( _designator, _target ) +#define RTEMS_INTERRUPT_REPLACE ( (rtems_option) 0x00000002 ) /* Generated from spec:/rtems/intr/if/is-shared */ @@ -1182,6 +952,68 @@ rtems_status_code rtems_interrupt_catch( #define RTEMS_INTERRUPT_IS_REPLACE( _options ) \ ( ( _options ) & RTEMS_INTERRUPT_REPLACE ) +/* Generated from spec:/rtems/intr/if/handler */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief Interrupt handler routines shall have this type. + */ +typedef void ( *rtems_interrupt_handler )( void * ); + +/* Generated from spec:/rtems/intr/if/per-handler-routine */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief Visitor routines invoked by rtems_interrupt_handler_iterate() shall + * have this type. + */ +typedef void ( *rtems_interrupt_per_handler_routine )( + void *, + const char *, + rtems_option, + rtems_interrupt_handler, + void * +); + +/* Generated from spec:/rtems/intr/if/entry */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief This structure represents an interrupt entry. + * + * @par Notes + * This structure shall be treated as an opaque data type from the API point of + * view. Members shall not be accessed directly. An entry may be initialized + * by RTEMS_INTERRUPT_ENTRY_INITIALIZER() or + * rtems_interrupt_entry_initialize(). It may be installed for an interrupt + * vector with rtems_interrupt_entry_install() and removed from an interrupt + * vector by rtems_interrupt_entry_remove(). + */ +typedef struct rtems_interrupt_entry { + /** + * @brief This member is the interrupt handler routine. + */ + rtems_interrupt_handler handler; + + /** + * @brief This member is the interrupt handler argument. + */ + void *arg; + + /** + * @brief This member is the reference to the next entry or NULL. + */ + struct rtems_interrupt_entry *next; + + /** + * @brief This member is the descriptive information of the entry. + */ + const char *info; +} rtems_interrupt_entry; + /* Generated from spec:/rtems/intr/if/entry-initializer */ /** @@ -1950,6 +1782,174 @@ rtems_status_code rtems_interrupt_set_affinity( const cpu_set_t *affinity ); +/* Generated from spec:/rtems/intr/if/signal-variant */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief This enumeration provides interrupt trigger signal variants. + */ +typedef enum { + /** + * @brief This interrupt signal variant indicates that the interrupt trigger + * signal is unspecified. + */ + RTEMS_INTERRUPT_UNSPECIFIED_SIGNAL, + + /** + * @brief This interrupt signal variant indicates that the interrupt cannot be + * triggered by a signal. + */ + RTEMS_INTERRUPT_NO_SIGNAL, + + /** + * @brief This interrupt signal variant indicates that the interrupt is + * triggered by a low level signal. + */ + RTEMS_INTERRUPT_SIGNAL_LEVEL_LOW, + + /** + * @brief This interrupt signal variant indicates that the interrupt is + * triggered by a high level signal. + */ + RTEMS_INTERRUPT_SIGNAL_LEVEL_HIGH, + + /** + * @brief This interrupt signal variant indicates that the interrupt is + * triggered by a falling edge signal. + */ + RTEMS_INTERRUPT_SIGNAL_EDGE_FALLING, + + /** + * @brief This interrupt signal variant indicates that the interrupt is + * triggered by a raising edge signal. + */ + RTEMS_INTERRUPT_SIGNAL_EDGE_RAISING +} rtems_interrupt_signal_variant; + +/* Generated from spec:/rtems/intr/if/attributes */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief This structure provides the attributes of an interrupt vector. + * + * The rtems_interrupt_get_attributes() directive may be used to obtain the + * attributes of an interrupt vector. + */ +typedef struct { + /** + * @brief This member is true, if the interrupt vector is maskable by + * rtems_interrupt_local_disable(), otherwise it is false. + * + * Interrupt vectors which are not maskable by rtems_interrupt_local_disable() + * should be used with care since they cannot use most operating system + * services. + */ + bool is_maskable; + + /** + * @brief This member is true, if the interrupt vector can be enabled by + * rtems_interrupt_vector_enable(), otherwise it is false. + * + * When an interrupt vector can be enabled, this means that the enabled state + * can always be changed from disabled to enabled. For an interrupt vector + * which can be enabled it follows that it may be enabled. + */ + bool can_enable; + + /** + * @brief This member is true, if the interrupt vector may be enabled by + * rtems_interrupt_vector_enable(), otherwise it is false. + * + * When an interrupt vector may be enabled, this means that the enabled state + * may be changed from disabled to enabled. The requested enabled state change + * should be checked by rtems_interrupt_vector_is_enabled(). Some interrupt + * vectors may be optionally available and cannot be enabled on a particular + * target. + */ + bool maybe_enable; + + /** + * @brief This member is true, if the interrupt vector can be disabled by + * rtems_interrupt_vector_disable(), otherwise it is false. + * + * When an interrupt vector can be disabled, this means that the enabled state + * can be changed from enabled to disabled. For an interrupt vector which can + * be disabled it follows that it may be disabled. + */ + bool can_disable; + + /** + * @brief This member is true, if the interrupt vector may be disabled by + * rtems_interrupt_vector_disable(), otherwise it is false. + * + * When an interrupt vector may be disabled, this means that the enabled state + * may be changed from enabled to disabled. The requested enabled state change + * should be checked by rtems_interrupt_vector_is_enabled(). Some interrupt + * vectors may be always enabled and cannot be disabled on a particular target. + */ + bool maybe_disable; + + /** + * @brief This member is true, if the interrupt vector can be raised by + * rtems_interrupt_raise(), otherwise it is false. + */ + bool can_raise; + + /** + * @brief This member is true, if the interrupt vector can be raised on a + * processor by rtems_interrupt_raise_on(), otherwise it is false. + */ + bool can_raise_on; + + /** + * @brief This member is true, if the interrupt vector can be cleared by + * rtems_interrupt_clear(), otherwise it is false. + */ + bool can_clear; + + /** + * @brief This member is true, if the pending status of the interrupt + * associated with the interrupt vector is cleared by an interrupt + * acknowledge from the processor, otherwise it is false. + */ + bool cleared_by_acknowledge; + + /** + * @brief This member is true, if the affinity set of the interrupt vector can + * be obtained by rtems_interrupt_get_affinity(), otherwise it is false. + */ + bool can_get_affinity; + + /** + * @brief This member is true, if the affinity set of the interrupt vector can + * be set by rtems_interrupt_set_affinity(), otherwise it is false. + */ + bool can_set_affinity; + + /** + * @brief This member is true, if the interrupt associated with the interrupt + * vector can be triggered by a message. + * + * Interrupts may be also triggered by signals, rtems_interrupt_raise(), or + * rtems_interrupt_raise_on(). Examples for message triggered interrupts are + * the PCIe MSI/MSI-X and the ARM GICv3 Locality-specific Peripheral Interrupts + * (LPI). + */ + bool can_be_triggered_by_message; + + /** + * @brief This member describes the trigger signal of the interrupt associated + * with the interrupt vector. + * + * Interrupts are normally triggered by signals which indicate an interrupt + * request from a peripheral. Interrupts may be also triggered by messages, + * rtems_interrupt_raise(), or rtems_interrupt_raise_on(). + */ + rtems_interrupt_signal_variant trigger_signal; +} rtems_interrupt_attributes; + /* Generated from spec:/rtems/intr/if/get-attributes */ /** -- 2.31.1 From sebastian.huber at embedded-brains.de Fri Dec 10 08:11:07 2021 From: sebastian.huber at embedded-brains.de (Sebastian Huber) Date: Fri, 10 Dec 2021 09:11:07 +0100 Subject: [PATCH] score: Add _IO_Relax() Message-ID: <20211210081107.6966-1-sebastian.huber@embedded-brains.de> This function may be used to burn a couple of processor cycles with minimum impact on the system bus. It may be used in busy wait loops. Since it is a global function, it is possible to wrap it in device driver test code. --- cpukit/include/rtems/score/io.h | 8 +++++ cpukit/score/src/iorelax.c | 53 +++++++++++++++++++++++++++++++ spec/build/cpukit/librtemscpu.yml | 1 + 3 files changed, 62 insertions(+) create mode 100644 cpukit/score/src/iorelax.c diff --git a/cpukit/include/rtems/score/io.h b/cpukit/include/rtems/score/io.h index f7b576fddd..5cc946bba8 100644 --- a/cpukit/include/rtems/score/io.h +++ b/cpukit/include/rtems/score/io.h @@ -120,6 +120,14 @@ int _IO_Base64url( int wordlen ); +/** + * @brief Issues a couple of no-operation instructions. + * + * This function may be used to burn a couple of processor cycles with minimum + * impact on the system bus. It may be used in busy wait loops. + */ +void _IO_Relax( void ); + /** @} */ #ifdef __cplusplus diff --git a/cpukit/score/src/iorelax.c b/cpukit/score/src/iorelax.c new file mode 100644 index 0000000000..f37d848605 --- /dev/null +++ b/cpukit/score/src/iorelax.c @@ -0,0 +1,53 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSScoreIO + * + * @brief This source file contains the implementation of _IO_Relax(). + */ + +/* + * Copyright (C) 2021 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 +#include + +void _IO_Relax( void ) +{ + _CPU_Instruction_no_operation(); + _CPU_Instruction_no_operation(); + _CPU_Instruction_no_operation(); + _CPU_Instruction_no_operation(); + _CPU_Instruction_no_operation(); + _CPU_Instruction_no_operation(); + _CPU_Instruction_no_operation(); + _CPU_Instruction_no_operation(); +} diff --git a/spec/build/cpukit/librtemscpu.yml b/spec/build/cpukit/librtemscpu.yml index 423974502c..f8594a7784 100644 --- a/spec/build/cpukit/librtemscpu.yml +++ b/spec/build/cpukit/librtemscpu.yml @@ -1421,6 +1421,7 @@ source: - cpukit/score/src/interr.c - cpukit/score/src/iobase64.c - cpukit/score/src/ioprintf.c +- cpukit/score/src/iorelax.c - cpukit/score/src/iovprintf.c - cpukit/score/src/isr.c - cpukit/score/src/isrisinprogress.c -- 2.31.1 From sebastian.huber at embedded-brains.de Fri Dec 10 13:38:32 2021 From: sebastian.huber at embedded-brains.de (Sebastian Huber) Date: Fri, 10 Dec 2021 14:38:32 +0100 Subject: [PATCH 2/4] bsp/leon3: Use interrupt entry for the SMP support In-Reply-To: <20211210133834.42457-1-sebastian.huber@embedded-brains.de> References: <20211210133834.42457-1-sebastian.huber@embedded-brains.de> Message-ID: <20211210133834.42457-2-sebastian.huber@embedded-brains.de> Using rtems_interrupt_entry_install() instead of rtems_interrupt_handler_install() avoids a dependency on the dynamic memory allocation. --- bsps/sparc/leon3/start/bspsmp.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/bsps/sparc/leon3/start/bspsmp.c b/bsps/sparc/leon3/start/bspsmp.c index a556da1e09..74f9df5404 100644 --- a/bsps/sparc/leon3/start/bspsmp.c +++ b/bsps/sparc/leon3/start/bspsmp.c @@ -51,6 +51,13 @@ void bsp_start_on_secondary_processor(Per_CPU_Control *cpu_self) _SMP_Start_multitasking_on_secondary_processor(cpu_self); } +static rtems_interrupt_entry leon3_inter_processor_interrupt_entry = + RTEMS_INTERRUPT_ENTRY_INITIALIZER( + bsp_inter_processor_interrupt, + NULL, + "IPI" + ); + static void leon3_install_inter_processor_interrupt( void ) { rtems_status_code sc; @@ -60,12 +67,10 @@ static void leon3_install_inter_processor_interrupt( void ) bsp_interrupt_set_affinity( irq, _SMP_Get_online_processors() ); - sc = rtems_interrupt_handler_install( + sc = rtems_interrupt_entry_install( irq, - "IPI", RTEMS_INTERRUPT_SHARED, - bsp_inter_processor_interrupt, - NULL + &leon3_inter_processor_interrupt_entry ); _Assert_Unused_variable_equals( sc, RTEMS_SUCCESSFUL ); } -- 2.26.2 From sebastian.huber at embedded-brains.de Fri Dec 10 13:38:31 2021 From: sebastian.huber at embedded-brains.de (Sebastian Huber) Date: Fri, 10 Dec 2021 14:38:31 +0100 Subject: [PATCH 1/4] bsp/leon3: Use interrupt entry for Clock Driver Message-ID: <20211210133834.42457-1-sebastian.huber@embedded-brains.de> Using rtems_interrupt_entry_install() instead of rtems_interrupt_handler_install() avoids a dependency on the dynamic memory allocation. --- bsps/sparc/leon3/clock/ckinit.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/bsps/sparc/leon3/clock/ckinit.c b/bsps/sparc/leon3/clock/ckinit.c index 4d30e0fd64..69afb25f3c 100644 --- a/bsps/sparc/leon3/clock/ckinit.c +++ b/bsps/sparc/leon3/clock/ckinit.c @@ -133,16 +133,22 @@ static void leon3_tc_do_tick(void) #define Clock_driver_support_install_isr(isr) \ bsp_clock_handler_install(isr) +static rtems_interrupt_entry leon3_clock_interrupt_entry; + static void bsp_clock_handler_install(rtems_interrupt_handler isr) { rtems_status_code sc; - sc = rtems_interrupt_handler_install( + rtems_interrupt_entry_initialize( + &leon3_clock_interrupt_entry, + isr, + NULL, + "Clock" + ); + sc = rtems_interrupt_entry_install( clkirq, - "Clock", RTEMS_INTERRUPT_UNIQUE, - isr, - NULL + &leon3_clock_interrupt_entry ); if (sc != RTEMS_SUCCESSFUL) { rtems_fatal(RTEMS_FATAL_SOURCE_BSP, LEON3_FATAL_CLOCK_INITIALIZATION); -- 2.26.2 From sebastian.huber at embedded-brains.de Fri Dec 10 13:38:34 2021 From: sebastian.huber at embedded-brains.de (Sebastian Huber) Date: Fri, 10 Dec 2021 14:38:34 +0100 Subject: [PATCH 4/4] bsp/leon3: Do not invalidate cache in SMP start In-Reply-To: <20211210133834.42457-1-sebastian.huber@embedded-brains.de> References: <20211210133834.42457-1-sebastian.huber@embedded-brains.de> Message-ID: <20211210133834.42457-4-sebastian.huber@embedded-brains.de> Since the trap table is now statically initialized, there is no need to invalidate the instruction cache. --- bsps/sparc/leon3/start/bspsmp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bsps/sparc/leon3/start/bspsmp.c b/bsps/sparc/leon3/start/bspsmp.c index 74f9df5404..acd932843a 100644 --- a/bsps/sparc/leon3/start/bspsmp.c +++ b/bsps/sparc/leon3/start/bspsmp.c @@ -105,7 +105,7 @@ void _CPU_SMP_Finalize_initialization( uint32_t cpu_count ) void _CPU_SMP_Prepare_start_multitasking( void ) { - rtems_cache_invalidate_entire_instruction(); + /* Do nothing */ } void _CPU_SMP_Send_interrupt(uint32_t target_processor_index) -- 2.26.2 From sebastian.huber at embedded-brains.de Fri Dec 10 13:38:33 2021 From: sebastian.huber at embedded-brains.de (Sebastian Huber) Date: Fri, 10 Dec 2021 14:38:33 +0100 Subject: [PATCH 3/4] bsp/leon3: Use interrupt entry for tm27 support In-Reply-To: <20211210133834.42457-1-sebastian.huber@embedded-brains.de> References: <20211210133834.42457-1-sebastian.huber@embedded-brains.de> Message-ID: <20211210133834.42457-3-sebastian.huber@embedded-brains.de> Using rtems_interrupt_entry_install() instead of rtems_interrupt_handler_install() avoids a dependency on the dynamic memory allocation. Use Interrupt Manager directives instead of a BSP-specific API. Use inline functions. In SMP configurations, set an affinity to all online processors and raise the interrupt on the current processor. --- bsps/sparc/leon3/include/tm27.h | 75 ++++++++++++++++++++++++--------- 1 file changed, 55 insertions(+), 20 deletions(-) diff --git a/bsps/sparc/leon3/include/tm27.h b/bsps/sparc/leon3/include/tm27.h index dda21f558f..7635d9b070 100644 --- a/bsps/sparc/leon3/include/tm27.h +++ b/bsps/sparc/leon3/include/tm27.h @@ -21,7 +21,11 @@ #define __tm27_h #include -#include +#include + +#if defined(RTEMS_SMP) +#include +#endif /* * Define the interrupt mechanism for Time Test 27 @@ -59,40 +63,71 @@ #else /* use a regular asynchronous trap */ -#define TEST_INTERRUPT_SOURCE LEON_INTERRUPT_EXTERNAL_1 -#define TEST_INTERRUPT_SOURCE2 LEON_INTERRUPT_EXTERNAL_1+1 +#define TEST_INTERRUPT_SOURCE 5 +#define TEST_INTERRUPT_SOURCE2 6 #define MUST_WAIT_FOR_INTERRUPT 1 static inline void Install_tm27_vector( void ( *handler )( rtems_vector_number ) ) { - (void) rtems_interrupt_handler_install( + static rtems_interrupt_entry entry_low; + static rtems_interrupt_entry entry_high; + +#if defined(RTEMS_SMP) + bsp_interrupt_set_affinity( + TEST_INTERRUPT_SOURCE, + _SMP_Get_online_processors() + ); + bsp_interrupt_set_affinity( + TEST_INTERRUPT_SOURCE2, + _SMP_Get_online_processors() + ); +#endif + + rtems_interrupt_entry_initialize( + &entry_low, + (rtems_interrupt_handler) handler, + NULL, + "tm27 low" + ); + (void) rtems_interrupt_entry_install( TEST_INTERRUPT_SOURCE, - "tm27 low", RTEMS_INTERRUPT_SHARED, + &entry_low + ); + rtems_interrupt_entry_initialize( + &entry_high, (rtems_interrupt_handler) handler, - NULL + NULL, + "tm27 high" ); - (void) rtems_interrupt_handler_install( + (void) rtems_interrupt_entry_install( TEST_INTERRUPT_SOURCE2, - "tm27 high", RTEMS_INTERRUPT_SHARED, - (rtems_interrupt_handler) handler, - NULL + &entry_high ); } -#define Cause_tm27_intr() \ - do { \ - LEON_Force_interrupt( TEST_INTERRUPT_SOURCE+(Interrupt_nest>>1)); \ - nop(); \ - nop(); \ - nop(); \ - } while (0) - -#define Clear_tm27_intr() \ - LEON_Clear_interrupt( TEST_INTERRUPT_SOURCE ) +static inline void Cause_tm27_intr( void ) +{ + rtems_vector_number vector; + + vector = TEST_INTERRUPT_SOURCE + ( Interrupt_nest >> 1 ); +#if defined(RTEMS_SMP) + (void) rtems_interrupt_raise_on( vector, rtems_scheduler_get_processor() ); +#else + (void) rtems_interrupt_raise( vector ); +#endif + nop(); + nop(); + nop(); +} + +static inline void Clear_tm27_intr( void ) +{ + (void) rtems_interrupt_clear( TEST_INTERRUPT_SOURCE ); +} #define Lower_tm27_intr() /* empty */ -- 2.26.2 From kinsey.moore at oarcorp.com Fri Dec 10 15:49:37 2021 From: kinsey.moore at oarcorp.com (Kinsey Moore) Date: Fri, 10 Dec 2021 09:49:37 -0600 Subject: [PATCH] bsps/aarch64: Remove erroneous cache feature Message-ID: <20211210154937.18479-1-kinsey.moore@oarcorp.com> The AArch64 cache implementation does not define rtems_cache_disable_data(), but declares that it does via CPU_CACHE_SUPPORT_PROVIDES_DISABLE_DATA. The existing implementation of _CPU_cache_disable_data() is sufficient to enable this functionality without the erroneous cache feature flag. Closes #4569 --- bsps/aarch64/shared/cache/cache.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/bsps/aarch64/shared/cache/cache.c b/bsps/aarch64/shared/cache/cache.c index 9e7446a077..fc1766c2b9 100644 --- a/bsps/aarch64/shared/cache/cache.c +++ b/bsps/aarch64/shared/cache/cache.c @@ -47,8 +47,6 @@ #define CPU_CACHE_SUPPORT_PROVIDES_CACHE_SIZE_FUNCTIONS -#define CPU_CACHE_SUPPORT_PROVIDES_DISABLE_DATA - #define AARCH64_CACHE_L1_CPU_DATA_ALIGNMENT ( (size_t) 64 ) #define AARCH64_CACHE_PREPARE_MVA(mva) (const void *) \ RTEMS_ALIGN_DOWN ( (size_t) mva, AARCH64_CACHE_L1_CPU_DATA_ALIGNMENT ) -- 2.30.2 From sebastian.huber at embedded-brains.de Fri Dec 10 17:19:14 2021 From: sebastian.huber at embedded-brains.de (Sebastian Huber) Date: Fri, 10 Dec 2021 18:19:14 +0100 Subject: [PATCH] bsps/aarch64: Remove erroneous cache feature In-Reply-To: <20211210154937.18479-1-kinsey.moore@oarcorp.com> References: <20211210154937.18479-1-kinsey.moore@oarcorp.com> Message-ID: <0d384bff-e841-5796-ae7c-1c2d2433bd56@embedded-brains.de> On 10/12/2021 16:49, Kinsey Moore wrote: > The AArch64 cache implementation does not define > rtems_cache_disable_data(), but declares that it does via > CPU_CACHE_SUPPORT_PROVIDES_DISABLE_DATA. The existing implementation of > _CPU_cache_disable_data() is sufficient to enable this functionality > without the erroneous cache feature flag. > > Closes #4569 Thanks, please check it in. At least for ARMv7 we have an assembler implementation for this function: bsps/arm/shared/cache/cache-v7ar-disable-data.S -- embedded brains GmbH Herr Sebastian HUBER Dornierstr. 4 82178 Puchheim Germany email: sebastian.huber at embedded-brains.de phone: +49-89-18 94 741 - 16 fax: +49-89-18 94 741 - 08 Registergericht: Amtsgericht M?nchen Registernummer: HRB 157899 Vertretungsberechtigte Gesch?ftsf?hrer: Peter Rasmussen, Thomas D?rfler Unsere Datenschutzerkl?rung finden Sie hier: https://embedded-brains.de/datenschutzerklaerung/ From chrisj at rtems.org Sat Dec 11 02:59:37 2021 From: chrisj at rtems.org (Chris Johns) Date: Sat, 11 Dec 2021 13:59:37 +1100 Subject: [rtems commit] untar: Make behavior similar to GNU or BSD tar In-Reply-To: <86fdf8ac-6315-2fcc-79b3-066c416d206d@embedded-brains.de> References: <20211209072118.C0B524E76F@lists.rtems.org> <9ec242f5-f3a7-7bbf-0443-81e5cfc4d7a9@embedded-brains.de> <75ec8bd7-49cc-d252-e13d-89898a31759b@rtems.org> <86fdf8ac-6315-2fcc-79b3-066c416d206d@embedded-brains.de> Message-ID: <863f62cf-6036-709d-cb85-09fe21d81c8f@rtems.org> On 10/12/21 6:20 pm, Christian MAUDERER wrote: > Am 09.12.21 um 22:09 schrieb Chris Johns: >> On 9/12/21 6:47 pm, Christian MAUDERER wrote: >> >> Given it is in maybe we let it sit and it there is feedback we come back and >> take another look? > > No problem with that. I will try to be extra sensitive for problems with Untar > that appear on the list in the next months. > Thanks. There is no easy or clear guideline with this as a number of factors effect this. Chris From gedare at rtems.org Sat Dec 11 15:40:51 2021 From: gedare at rtems.org (Gedare Bloom) Date: Sat, 11 Dec 2021 08:40:51 -0700 Subject: Ticket 4503 In-Reply-To: References: Message-ID: On Thu, Nov 18, 2021 at 7:22 PM zack leung wrote: > > bump > > On Mon, 18 Oct 2021 at 23:58, zack leung wrote: > > > bump > > > > > > On Sat, 25 Sept 2021 at 00:26, zack leung > > wrote: > > > >> bump > >> > >> On Thu, 9 Sept 2021 at 02:17, zack leung > >> wrote: > >> > >>> >Thanks! I guess i'm really unsure about how the pointer relates to the > >>> amount of memory that you can use. I assume the Malloc keeps track of the > >>> sections being used in the heap. Does this function Allocate 2 blocks since > >>> the pointer is set to > >>> > >>> (uintptr_t) next_block + HEAP_ALLOC_BONUS - alloc_begin; > >>> No, this is calculating the size of 'this block' considering that it's allocated memory starts at "alloc_begin" and it ends at the "next_block" heap block metadata or header. You should read about how malloc implementations generally work. The allocated memory has some metadata before it to implement the linked data structures necessary to support dynamic allocation. So a block is the header + allocated range. Only the allocated range plus any excess before the next block's header is considered usable. > >>> >(I know it's a bit naive to assume this given my first question) > >>> > >>> think the method is _Heap_Size_of_alloc_area. It may need a wrapper > >>> added to the protected heap wrapper for safety. I don't know if it has one. > >>> It should be the equivalent functionality. > >>> > How would i implement a wrapper and what safety measures need to be > >>> implemented. So far it's checking if : the block is not in the heap and if > >>> it's been previously used. Is the usable memory in the heap calculated by: > >>> the size of the block * # of blocks? > >>> You would have to see if the Protected Heap implementation has some additional metadata between the end of an allocated range in one block and the block header in the next. I don't think it matters too much because most of the 'protected' aspects have to do with free block management. But that should be confirmed. The check is not "if it's been previously used" I suggest that you look at what the invoked function does and how it is documented. Avoid making assumptions based on names. The usable memory is NOT the size of the block * # of blocks, because the size of the block includes the header. > >>> Thanks, Zack > >>> > >>> ---------- Forwarded message --------- > >>> From: Joel Sherrill > >>> Date: Wed, 8 Sept 2021 at 20:30 > >>> Subject: Re: Ticket 4503 > >>> To: Gedare Bloom > >>> Cc: zack leung , rtems-devel at rtems.org < > >>> devel at rtems.org> > >>> > >>> > >>> > >>> > >>> On Wed, Sep 8, 2021 at 11:02 AM Gedare Bloom wrote: > >>> > >>>> Hi Zack, > >>>> > >>>> https://devel.rtems.org/ticket/4503 > >>>> > >>>> The malloc implementation exists in the score as the Heap Manager. > >>>> search for "Heap_" within cpukit to get some ideas where to look. > >>>> > >>> > >>> I think the method is _Heap_Size_of_alloc_area. It may need a wrapper > >>> added to the protected heap wrapper for safety. I don't know if it has one. > >>> It should be the equivalent functionality. > >>> > >>> newlib's malloc.h will need looking at to make sure we provide the right > >>> methods. > >>> > >>> > >>> > >>>> > >>>> @Joel are these two tickets duplicates? > >>>> https://devel.rtems.org/ticket/4503 > >>>> https://devel.rtems.org/ticket/4271 > >>>> > >>> > >>> Yes. Closed #4271 and merged comments. > >>> > >>> --joel > >>> > >>> > >>>> > >>>> > >>>> -Gedare > >>>> > >>>> On Tue, Sep 7, 2021 at 7:14 PM zack leung > >>>> wrote: > >>>> > >>>>> I was wondering about ticket 4503. I was wondering where The required > >>>>> functionality should be in the underlying score/ capability used can be > >>>>> found to write this function. Also how does this relate to > >>>>> > >>>>> Add common malloc family extension method malloc_usable_size() > >>>>> ? > >>>>> Thanks > >>>>> Zack > >>>>> _______________________________________________ > >>>>> devel mailing list > >>>>> devel at rtems.org > >>>>> http://lists.rtems.org/mailman/listinfo/devel > >>>> > >>>> > _______________________________________________ > devel mailing list > devel at rtems.org > http://lists.rtems.org/mailman/listinfo/devel From gedare at rtems.org Sat Dec 11 16:16:01 2021 From: gedare at rtems.org (Gedare Bloom) Date: Sat, 11 Dec 2021 09:16:01 -0700 Subject: [PATCH v2 0/3] Add Secure Monitor Call API Message-ID: <20211211161604.1309486-1-gedare@rtems.org> These patches add and use an internal API to make secure monitor call (SMC) invocations. SMC is used currently in aarch64 for secondary processor boot and bsp_reset. Although SMC is available on arm, it does not appear to be currently used by any of arm BSPs. So the current approach is only implemented in the aarch64. Replicating the implementation for arm (with SMC32) should be simple if needed, but the placement of the API may need some more thought. Currently, the only place that aarch64 and arm can easily share code is underneath bsps/shared. Also, it should be straightforward to add a similar API for hypervisor call (HVC) invocations. v2: address comments from reviewers (Sebastian, Kinsey) Gedare Bloom (3): aarch64: add internal API for secure monitor call (smc) bsps/aarch64: use SMC API in bspsmp-arm-psci bsps/aarch64: use SMC API in bspreset-arm-psci bsps/shared/start/bspreset-arm-psci.c | 41 +++++++-- bsps/shared/start/bspsmp-arm-psci.c | 19 ++++- cpukit/score/cpu/aarch64/aarch64-smc.c | 72 ++++++++++++++++ .../aarch64/include/rtems/score/aarch64-smc.h | 83 +++++++++++++++++++ spec/build/cpukit/cpuaarch64.yml | 2 + 5 files changed, 205 insertions(+), 12 deletions(-) create mode 100644 cpukit/score/cpu/aarch64/aarch64-smc.c create mode 100644 cpukit/score/cpu/aarch64/include/rtems/score/aarch64-smc.h -- 2.25.1 From gedare at rtems.org Sat Dec 11 16:16:03 2021 From: gedare at rtems.org (Gedare Bloom) Date: Sat, 11 Dec 2021 09:16:03 -0700 Subject: [PATCH v2 2/3] bsps/aarch64: use SMC API in bspsmp-arm-psci In-Reply-To: <20211211161604.1309486-1-gedare@rtems.org> References: <20211211161604.1309486-1-gedare@rtems.org> Message-ID: <20211211161604.1309486-3-gedare@rtems.org> --- bsps/shared/start/bspsmp-arm-psci.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/bsps/shared/start/bspsmp-arm-psci.c b/bsps/shared/start/bspsmp-arm-psci.c index 1ff5b7bb89..77fa3cc816 100644 --- a/bsps/shared/start/bspsmp-arm-psci.c +++ b/bsps/shared/start/bspsmp-arm-psci.c @@ -41,6 +41,7 @@ #if defined( AARCH64_MULTILIB_ARCH_V8 ) || \ defined( AARCH64_MULTILIB_ARCH_V8_ILP32 ) #include +#include #else #include #endif @@ -67,22 +68,32 @@ bool _CPU_SMP_Start_processor( uint32_t cpu_index ) target_cpu &= ~( 0xff0000ffUL ); target_cpu |= cpu_index; +#ifdef BSP_CPU_ON_USES_SMC + ret = _AArch64_SMC_Invoke( + PSCI_FN_SYSTEM_CPU_ON, + target_cpu, + _start, + 0, + 0, + 0, + 0, + 0, + NULL + ); +#else __asm__ volatile ( "mov " REGISTER_PREFIX "0, %1\n" "mov " REGISTER_PREFIX "1, %2\n" "mov " REGISTER_PREFIX "2, %3\n" "mov " REGISTER_PREFIX "3, #0\n" -#ifdef BSP_CPU_ON_USES_SMC - "smc #0\n" -#else "hvc #0\n" -#endif "mov %0, " REGISTER_PREFIX "0\n" : "=r" ( ret ) : "r" ( PSCI_FN_SYSTEM_CPU_ON ), "r" ( target_cpu ), "r" ( _start ) : REGISTER_PREFIX "0", REGISTER_PREFIX "1", REGISTER_PREFIX "2", REGISTER_PREFIX "3" ); +#endif if ( ret != 0 ) { return false; -- 2.25.1 From gedare at rtems.org Sat Dec 11 16:16:02 2021 From: gedare at rtems.org (Gedare Bloom) Date: Sat, 11 Dec 2021 09:16:02 -0700 Subject: [PATCH v2 1/3] aarch64: add internal API for secure monitor call (smc) In-Reply-To: <20211211161604.1309486-1-gedare@rtems.org> References: <20211211161604.1309486-1-gedare@rtems.org> Message-ID: <20211211161604.1309486-2-gedare@rtems.org> --- cpukit/score/cpu/aarch64/aarch64-smc.c | 72 ++++++++++++++++ .../aarch64/include/rtems/score/aarch64-smc.h | 83 +++++++++++++++++++ spec/build/cpukit/cpuaarch64.yml | 2 + 3 files changed, 157 insertions(+) create mode 100644 cpukit/score/cpu/aarch64/aarch64-smc.c create mode 100644 cpukit/score/cpu/aarch64/include/rtems/score/aarch64-smc.h diff --git a/cpukit/score/cpu/aarch64/aarch64-smc.c b/cpukit/score/cpu/aarch64/aarch64-smc.c new file mode 100644 index 0000000000..c531d074d8 --- /dev/null +++ b/cpukit/score/cpu/aarch64/aarch64-smc.c @@ -0,0 +1,72 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @brief This source file contains the implementation of + * _AArch64_SMC_Invoke(). + */ + +/* + * Copyright (C) 2021 Gedare Bloom + * + * 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 + +int _AArch64_SMC_Invoke( + uint32_t function_id, + uintptr_t arg0, + uintptr_t arg1, + uintptr_t arg2, + uintptr_t arg3, + uintptr_t arg4, + uintptr_t arg5, + uintptr_t arg6, + AArch64_SMC_Return *result +) { + int rv; + + /* This only works for SMC that return 4 or fewer results. It may be extended + * up to the full 18 return results specified for SMC64, but then we would + * need to allocate a callee-saved register for *result */ + __asm__ volatile( + "smc #0\n" + "mov %0, x0\n" + "ldr x15, [sp]\n" + "cbz x15, 0f\n" + "stp x0, x1, [x15]\n" + "stp x2, x3, [x15, #16]\n" + "0:\n" + : "=r" ( rv ) + : + : "x0", "x1", "x2", "x3", "x15" + ); + + return rv; +} + diff --git a/cpukit/score/cpu/aarch64/include/rtems/score/aarch64-smc.h b/cpukit/score/cpu/aarch64/include/rtems/score/aarch64-smc.h new file mode 100644 index 0000000000..e80cc1e99b --- /dev/null +++ b/cpukit/score/cpu/aarch64/include/rtems/score/aarch64-smc.h @@ -0,0 +1,83 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSScoreCPUAArch64 + * + * @brief This header file provides API to wrap secure monitor calls (smc). + */ + +/* + * Copyright (C) 2021 Gedare Bloom + * + * 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_SCORE_AARCH64_SMC_H +#define _RTEMS_SCORE_AARCH64_SMC_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup RTEMSScoreCPUAArch64SMC Secure Monitor Call Support + * + * @ingroup RTEMSScoreCPUAArch64 + * + * @brief This group provides functions to invoke secure monitor mode. + * + * @{ + */ + +/* + * @brief The return result from smc invocation. + */ +typedef struct { + uintptr_t x0; + uintptr_t x1; + uintptr_t x2; + uintptr_t x3; +} AArch64_SMC_Return; + +int _AArch64_SMC_Invoke( + uint32_t function_id, + uintptr_t arg0, + uintptr_t arg1, + uintptr_t arg2, + uintptr_t arg3, + uintptr_t arg4, + uintptr_t arg5, + uintptr_t arg6, + AArch64_SMC_Return *result +); + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* _RTEMS_SCORE_AARCH64_SMC_H */ diff --git a/spec/build/cpukit/cpuaarch64.yml b/spec/build/cpukit/cpuaarch64.yml index 70d80f0b6c..1f3f07f0a2 100644 --- a/spec/build/cpukit/cpuaarch64.yml +++ b/spec/build/cpukit/cpuaarch64.yml @@ -19,6 +19,7 @@ install: - destination: ${BSP_INCLUDEDIR}/rtems/score source: - cpukit/score/cpu/aarch64/include/rtems/score/aarch64-system-registers.h + - cpukit/score/cpu/aarch64/include/rtems/score/aarch64-smc.h - cpukit/score/cpu/aarch64/include/rtems/score/cpu.h - cpukit/score/cpu/aarch64/include/rtems/score/cpuatomic.h - cpukit/score/cpu/aarch64/include/rtems/score/cpuimpl.h @@ -32,6 +33,7 @@ source: - cpukit/score/cpu/aarch64/aarch64-exception-default.c - cpukit/score/cpu/aarch64/aarch64-exception-frame-print.c - cpukit/score/cpu/aarch64/aarch64-exception-interrupt.S +- cpukit/score/cpu/aarch64/aarch64-smc.c - cpukit/score/cpu/aarch64/aarch64-thread-idle.c - cpukit/score/cpu/aarch64/cpu.c - cpukit/score/cpu/aarch64/cpu_asm.S -- 2.25.1 From gedare at rtems.org Sat Dec 11 16:16:04 2021 From: gedare at rtems.org (Gedare Bloom) Date: Sat, 11 Dec 2021 09:16:04 -0700 Subject: [PATCH v2 3/3] bsps/aarch64: use SMC API in bspreset-arm-psci In-Reply-To: <20211211161604.1309486-1-gedare@rtems.org> References: <20211211161604.1309486-1-gedare@rtems.org> Message-ID: <20211211161604.1309486-4-gedare@rtems.org> --- bsps/shared/start/bspreset-arm-psci.c | 41 +++++++++++++++++++++------ 1 file changed, 33 insertions(+), 8 deletions(-) diff --git a/bsps/shared/start/bspreset-arm-psci.c b/bsps/shared/start/bspreset-arm-psci.c index 215be5c9b5..aa039b7816 100644 --- a/bsps/shared/start/bspreset-arm-psci.c +++ b/bsps/shared/start/bspreset-arm-psci.c @@ -37,20 +37,45 @@ #include #include +#if defined( AARCH64_MULTILIB_ARCH_V8 ) || \ + defined( AARCH64_MULTILIB_ARCH_V8_ILP32 ) +#include +#endif + void bsp_reset(void) { - uint32_t PSCI_FN_SYSTEM_RESET = 0x84000009; - __asm__ volatile( + uint32_t PSCI_FN_SYSTEM_RESET = 0x84000009; #if defined(AARCH64_MULTILIB_ARCH_V8) || defined(AARCH64_MULTILIB_ARCH_V8_ILP32) - "mov x0, %0\n" +#ifdef BSP_RESET_SMC + (void) _AArch64_SMC_Invoke( + PSCI_FN_SYSTEM_RESET, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + NULL + ); #else - "mov r0, %0\n" + /* _AArch64_HVC_Invoke */ + __asm__ volatile( + "mov x0, %0\n" + "hvc #0\n" + : : "r" (PSCI_FN_SYSTEM_RESET) + ); #endif +#else + /* _AArch32 */ + __asm__ volatile( + "mov r0, %0\n" #ifdef BSP_RESET_SMC - "smc #0\n" + "smc #0\n" #else - "hvc #0\n" + "hvc #0\n" +#endif + : : "r" (PSCI_FN_SYSTEM_RESET) + ); #endif - : : "r" (PSCI_FN_SYSTEM_RESET) - ); } -- 2.25.1 From gedare at rtems.org Sat Dec 11 16:19:03 2021 From: gedare at rtems.org (Gedare Bloom) Date: Sat, 11 Dec 2021 09:19:03 -0700 Subject: [PATCH 1/3] aarch64: add internal API for secure monitor call (smc) In-Reply-To: <9cf74f84-3356-82b4-a985-44c1388018b0@oarcorp.com> References: <20211016201225.463390-1-gedare@rtems.org> <20211016201225.463390-2-gedare@rtems.org> <9cf74f84-3356-82b4-a985-44c1388018b0@oarcorp.com> Message-ID: On Mon, Oct 18, 2021 at 8:18 AM Kinsey Moore wrote: > > Comments inline below. > > On 10/16/2021 15:12, Gedare Bloom wrote: > > --- > > cpukit/score/cpu/aarch64/aarch64-smc.c | 72 ++++++++++++++++ > > .../aarch64/include/rtems/score/aarch64-smc.h | 84 +++++++++++++++++++ > > spec/build/cpukit/cpuaarch64.yml | 2 + > > 3 files changed, 158 insertions(+) > > create mode 100644 cpukit/score/cpu/aarch64/aarch64-smc.c > > create mode 100644 cpukit/score/cpu/aarch64/include/rtems/score/aarch64-smc.h > > > > diff --git a/cpukit/score/cpu/aarch64/aarch64-smc.c b/cpukit/score/cpu/aarch64/aarch64-smc.c > > new file mode 100644 > > index 0000000000..4cfee91a0b > > --- /dev/null > > +++ b/cpukit/score/cpu/aarch64/aarch64-smc.c > > @@ -0,0 +1,72 @@ > > +/* SPDX-License-Identifier: BSD-2-Clause */ > > + > > +/** > > + * @file > > + * > > + * @brief Secure Monitor Call > > + */ > > + > > +/* > > + * Copyright (C) 2021 Gedare Bloom > > + * > > + * 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 > > + > > +int _AArch64_SMC_Invoke( > > + int function_id, > Nit: The function ID should be uint32_t. > > + uintptr_t arg0, > > + uintptr_t arg1, > > + uintptr_t arg2, > > + uintptr_t arg3, > > + uintptr_t arg4, > > + uintptr_t arg5, > > + uintptr_t arg6, > > + uintptr_t arg7, > Only arguments 0-7 are passed in registers according to the AAPCS64. > arg7 here would be the 9th argument and thus passed on the stack which > is incompatible with the SMC calling convention which exclusively uses > registers for passing arguments. It should be fine to drop this argument > since we're not yet using any PSCI functionality that requires that many > arguments. Nice catch, thanks for this one. It would have messed up the return values. From gedare at rtems.org Sat Dec 11 16:20:03 2021 From: gedare at rtems.org (Gedare Bloom) Date: Sat, 11 Dec 2021 09:20:03 -0700 Subject: [PATCH 3/3] bsps/aarch64: use SMC API in bspreset-arm-psci In-Reply-To: References: <20211016201225.463390-1-gedare@rtems.org> <20211016201225.463390-4-gedare@rtems.org> Message-ID: On Mon, Oct 18, 2021 at 8:40 AM Kinsey Moore wrote: > > Comments below. > > On 10/16/2021 15:12, Gedare Bloom wrote: > > --- > > bsps/shared/start/bspreset-arm-psci.c | 20 ++++++++++++++++++++ > > 1 file changed, 20 insertions(+) > > > > diff --git a/bsps/shared/start/bspreset-arm-psci.c b/bsps/shared/start/bspreset-arm-psci.c > > index 215be5c9b5..bafdfe6299 100644 > > --- a/bsps/shared/start/bspreset-arm-psci.c > > +++ b/bsps/shared/start/bspreset-arm-psci.c > > @@ -37,9 +37,28 @@ > > #include > > #include > > > > +#if defined( AARCH64_MULTILIB_ARCH_V8 ) || \ > > + defined( AARCH64_MULTILIB_ARCH_V8_ILP32 ) > > +#include > > +#endif > > + > > void bsp_reset(void) > > { > > uint32_t PSCI_FN_SYSTEM_RESET = 0x84000009; > > +#ifdef BSP_RESET_SMC > > + (void) _AArch64_SMC_Invoke( > > + PSCI_FN_SYSTEM_RESET, > > + 0, > > + 0, > > + 0, > > + 0, > > + 0, > > + 0, > > + 0, > > + 0, > > + NULL > > + ); > > +#else > > __asm__ volatile( > > #if defined(AARCH64_MULTILIB_ARCH_V8) || defined(AARCH64_MULTILIB_ARCH_V8_ILP32) > > "mov x0, %0\n" > > @@ -53,4 +72,5 @@ void bsp_reset(void) > > #endif > This leaves dead code just above the break in this patch. > > : : "r" (PSCI_FN_SYSTEM_RESET) > > ); > > +#endif > > } > > > The existing PSCI functionality was coded such that both ARM and AArch64 > could use it in either mode. The way this has been added breaks SMC > conduit functionality on 32-bit ARM for both secondary CPU startup and > system reset. > I decided to separate the two cases (aarch64/32) a little bit more cleanly to resolve this issue. Thanks for the review! > > Kinsey > > _______________________________________________ > devel mailing list > devel at rtems.org > http://lists.rtems.org/mailman/listinfo/devel From gedare at rtems.org Sat Dec 11 18:18:00 2021 From: gedare at rtems.org (Gedare Bloom) Date: Sat, 11 Dec 2021 11:18:00 -0700 Subject: [PATCH] bsps/aarch64: Remove erroneous cache feature In-Reply-To: <0d384bff-e841-5796-ae7c-1c2d2433bd56@embedded-brains.de> References: <20211210154937.18479-1-kinsey.moore@oarcorp.com> <0d384bff-e841-5796-ae7c-1c2d2433bd56@embedded-brains.de> Message-ID: On Fri, Dec 10, 2021 at 10:19 AM Sebastian Huber wrote: > > On 10/12/2021 16:49, Kinsey Moore wrote: > > The AArch64 cache implementation does not define > > rtems_cache_disable_data(), but declares that it does via > > CPU_CACHE_SUPPORT_PROVIDES_DISABLE_DATA. The existing implementation of > > _CPU_cache_disable_data() is sufficient to enable this functionality > > without the erroneous cache feature flag. > > > > Closes #4569 > > Thanks, please check it in. > > At least for ARMv7 we have an assembler implementation for this function: > > bsps/arm/shared/cache/cache-v7ar-disable-data.S > Basically the same code should work for aarch64, replacing the access with SCTLR_EL3 mrs x0, SCTLR_EL1 bic x0, x0, #0x4 msr SCTLR_EL1, x0 isb > -- > embedded brains GmbH > Herr Sebastian HUBER > Dornierstr. 4 > 82178 Puchheim > Germany > email: sebastian.huber at embedded-brains.de > phone: +49-89-18 94 741 - 16 > fax: +49-89-18 94 741 - 08 > > Registergericht: Amtsgericht M?nchen > Registernummer: HRB 157899 > Vertretungsberechtigte Gesch?ftsf?hrer: Peter Rasmussen, Thomas D?rfler > Unsere Datenschutzerkl?rung finden Sie hier: > https://embedded-brains.de/datenschutzerklaerung/ > _______________________________________________ > devel mailing list > devel at rtems.org > http://lists.rtems.org/mailman/listinfo/devel From gedare at rtems.org Sat Dec 11 18:18:30 2021 From: gedare at rtems.org (Gedare Bloom) Date: Sat, 11 Dec 2021 11:18:30 -0700 Subject: [PATCH] bsps/aarch64: Remove erroneous cache feature In-Reply-To: References: <20211210154937.18479-1-kinsey.moore@oarcorp.com> <0d384bff-e841-5796-ae7c-1c2d2433bd56@embedded-brains.de> Message-ID: On Sat, Dec 11, 2021 at 11:18 AM Gedare Bloom wrote: > > On Fri, Dec 10, 2021 at 10:19 AM Sebastian Huber > wrote: > > > > On 10/12/2021 16:49, Kinsey Moore wrote: > > > The AArch64 cache implementation does not define > > > rtems_cache_disable_data(), but declares that it does via > > > CPU_CACHE_SUPPORT_PROVIDES_DISABLE_DATA. The existing implementation of > > > _CPU_cache_disable_data() is sufficient to enable this functionality > > > without the erroneous cache feature flag. > > > > > > Closes #4569 > > > > Thanks, please check it in. > > > > At least for ARMv7 we have an assembler implementation for this function: > > > > bsps/arm/shared/cache/cache-v7ar-disable-data.S > > > Basically the same code should work for aarch64, replacing the access > with SCTLR_EL3 I meant EL1 :) the following code snippet should work anyway. > mrs x0, SCTLR_EL1 > bic x0, x0, #0x4 > msr SCTLR_EL1, x0 > isb > > > > -- > > embedded brains GmbH > > Herr Sebastian HUBER > > Dornierstr. 4 > > 82178 Puchheim > > Germany > > email: sebastian.huber at embedded-brains.de > > phone: +49-89-18 94 741 - 16 > > fax: +49-89-18 94 741 - 08 > > > > Registergericht: Amtsgericht M?nchen > > Registernummer: HRB 157899 > > Vertretungsberechtigte Gesch?ftsf?hrer: Peter Rasmussen, Thomas D?rfler > > Unsere Datenschutzerkl?rung finden Sie hier: > > https://embedded-brains.de/datenschutzerklaerung/ > > _______________________________________________ > > devel mailing list > > devel at rtems.org > > http://lists.rtems.org/mailman/listinfo/devel From sebastian.huber at embedded-brains.de Mon Dec 13 07:28:08 2021 From: sebastian.huber at embedded-brains.de (Sebastian Huber) Date: Mon, 13 Dec 2021 08:28:08 +0100 Subject: [PATCH] bsp/mrm332: Fix TLS support in linker command file Message-ID: <20211213072808.105627-1-sebastian.huber@embedded-brains.de> --- bsps/m68k/mrm332/start/linkcmds | 16 ++++++---------- spec/build/bsps/m68k/mrm332/tstmrm332.yml | 2 -- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/bsps/m68k/mrm332/start/linkcmds b/bsps/m68k/mrm332/start/linkcmds index 7c31b92dd1..3ae0d027bd 100644 --- a/bsps/m68k/mrm332/start/linkcmds +++ b/bsps/m68k/mrm332/start/linkcmds @@ -139,11 +139,6 @@ SECTIONS *(.rodata*) KEEP (*(SORT(.rtemsroset.*))) *(.gnu.linkonce.r*) - - . = ALIGN (16); - PROVIDE (_etext = .); - _endtext = .; - __data_start_rom = .; } > rom .tdata : { _TLS_Data_begin = .; @@ -154,6 +149,11 @@ SECTIONS _TLS_BSS_begin = .; *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) _TLS_BSS_end = .; + + . = ALIGN (16); + PROVIDE (_etext = .); + _endtext = .; + __data_start_rom = .; } > rom _TLS_Data_size = _TLS_Data_end - _TLS_Data_begin; _TLS_Data_begin = _TLS_Data_size != 0 ? _TLS_Data_begin : _TLS_BSS_begin; @@ -161,17 +161,13 @@ SECTIONS _TLS_BSS_size = _TLS_BSS_end - _TLS_BSS_begin; _TLS_Size = _TLS_BSS_end - _TLS_Data_begin; _TLS_Alignment = MAX (ALIGNOF (.tdata), ALIGNOF (.tbss)); - .gcc_exc : - AT ( ADDR(.tdata) + SIZEOF( .tdata ) ) - { - *(.gcc_exc) - } > ram .data : AT(__data_start_rom) { PROVIDE (_copy_start = .); *(.data*) KEEP (*(SORT(.rtemsrwset.*))) *(.gnu.linkonce.d*) + *(.gcc_exc) *(.gcc_except_table*) *(.jcr) . = ALIGN (16); diff --git a/spec/build/bsps/m68k/mrm332/tstmrm332.yml b/spec/build/bsps/m68k/mrm332/tstmrm332.yml index 5c045c1764..d7c2c3e452 100644 --- a/spec/build/bsps/m68k/mrm332/tstmrm332.yml +++ b/spec/build/bsps/m68k/mrm332/tstmrm332.yml @@ -9,8 +9,6 @@ actions: iostream: exclude linpack: exclude record02: exclude - sptls01: exclude - sptls02: exclude utf8proc01: exclude build-type: option copyrights: -- 2.26.2 From kinsey.moore at oarcorp.com Mon Dec 13 14:28:22 2021 From: kinsey.moore at oarcorp.com (Kinsey Moore) Date: Mon, 13 Dec 2021 08:28:22 -0600 Subject: [PATCH v2 1/3] aarch64: add internal API for secure monitor call (smc) In-Reply-To: <20211211161604.1309486-2-gedare@rtems.org> References: <20211211161604.1309486-1-gedare@rtems.org> <20211211161604.1309486-2-gedare@rtems.org> Message-ID: Everything else looks good. Just one nit below. On 12/11/2021 10:16, Gedare Bloom wrote: > --- > cpukit/score/cpu/aarch64/aarch64-smc.c | 72 ++++++++++++++++ > .../aarch64/include/rtems/score/aarch64-smc.h | 83 +++++++++++++++++++ > spec/build/cpukit/cpuaarch64.yml | 2 + > 3 files changed, 157 insertions(+) > create mode 100644 cpukit/score/cpu/aarch64/aarch64-smc.c > create mode 100644 cpukit/score/cpu/aarch64/include/rtems/score/aarch64-smc.h > > diff --git a/cpukit/score/cpu/aarch64/aarch64-smc.c b/cpukit/score/cpu/aarch64/aarch64-smc.c > new file mode 100644 > index 0000000000..c531d074d8 > --- /dev/null > +++ b/cpukit/score/cpu/aarch64/aarch64-smc.c > @@ -0,0 +1,72 @@ > +/* SPDX-License-Identifier: BSD-2-Clause */ > + > +/** > + * @file > + * > + * @brief This source file contains the implementation of > + * _AArch64_SMC_Invoke(). > + */ > + > +/* > + * Copyright (C) 2021 Gedare Bloom > + * > + * 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 > + > +int _AArch64_SMC_Invoke( > + uint32_t function_id, > + uintptr_t arg0, > + uintptr_t arg1, > + uintptr_t arg2, > + uintptr_t arg3, > + uintptr_t arg4, > + uintptr_t arg5, > + uintptr_t arg6, The SMC arguments here should be uint64_t for all AArch64 calls regardless of ABI. > + AArch64_SMC_Return *result > +) { > + int rv; > + > + /* This only works for SMC that return 4 or fewer results. It may be extended > + * up to the full 18 return results specified for SMC64, but then we would > + * need to allocate a callee-saved register for *result */ > + __asm__ volatile( > + "smc #0\n" > + "mov %0, x0\n" > + "ldr x15, [sp]\n" > + "cbz x15, 0f\n" > + "stp x0, x1, [x15]\n" > + "stp x2, x3, [x15, #16]\n" > + "0:\n" > + : "=r" ( rv ) > + : > + : "x0", "x1", "x2", "x3", "x15" > + ); > + > + return rv; > +} > + > diff --git a/cpukit/score/cpu/aarch64/include/rtems/score/aarch64-smc.h b/cpukit/score/cpu/aarch64/include/rtems/score/aarch64-smc.h > new file mode 100644 > index 0000000000..e80cc1e99b > --- /dev/null > +++ b/cpukit/score/cpu/aarch64/include/rtems/score/aarch64-smc.h > @@ -0,0 +1,83 @@ > +/* SPDX-License-Identifier: BSD-2-Clause */ > + > +/** > + * @file > + * > + * @ingroup RTEMSScoreCPUAArch64 > + * > + * @brief This header file provides API to wrap secure monitor calls (smc). > + */ > + > +/* > + * Copyright (C) 2021 Gedare Bloom > + * > + * 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_SCORE_AARCH64_SMC_H > +#define _RTEMS_SCORE_AARCH64_SMC_H > + > +#include > + > +#ifdef __cplusplus > +extern "C" { > +#endif > + > +/** > + * @defgroup RTEMSScoreCPUAArch64SMC Secure Monitor Call Support > + * > + * @ingroup RTEMSScoreCPUAArch64 > + * > + * @brief This group provides functions to invoke secure monitor mode. > + * > + * @{ > + */ > + > +/* > + * @brief The return result from smc invocation. > + */ > +typedef struct { > + uintptr_t x0; > + uintptr_t x1; > + uintptr_t x2; > + uintptr_t x3; > +} AArch64_SMC_Return; > + > +int _AArch64_SMC_Invoke( > + uint32_t function_id, > + uintptr_t arg0, > + uintptr_t arg1, > + uintptr_t arg2, > + uintptr_t arg3, > + uintptr_t arg4, > + uintptr_t arg5, > + uintptr_t arg6, > + AArch64_SMC_Return *result > +); > + > +/** @} */ > + > +#ifdef __cplusplus > +} > +#endif > + > +#endif /* _RTEMS_SCORE_AARCH64_SMC_H */ > diff --git a/spec/build/cpukit/cpuaarch64.yml b/spec/build/cpukit/cpuaarch64.yml > index 70d80f0b6c..1f3f07f0a2 100644 > --- a/spec/build/cpukit/cpuaarch64.yml > +++ b/spec/build/cpukit/cpuaarch64.yml > @@ -19,6 +19,7 @@ install: > - destination: ${BSP_INCLUDEDIR}/rtems/score > source: > - cpukit/score/cpu/aarch64/include/rtems/score/aarch64-system-registers.h > + - cpukit/score/cpu/aarch64/include/rtems/score/aarch64-smc.h > - cpukit/score/cpu/aarch64/include/rtems/score/cpu.h > - cpukit/score/cpu/aarch64/include/rtems/score/cpuatomic.h > - cpukit/score/cpu/aarch64/include/rtems/score/cpuimpl.h > @@ -32,6 +33,7 @@ source: > - cpukit/score/cpu/aarch64/aarch64-exception-default.c > - cpukit/score/cpu/aarch64/aarch64-exception-frame-print.c > - cpukit/score/cpu/aarch64/aarch64-exception-interrupt.S > +- cpukit/score/cpu/aarch64/aarch64-smc.c > - cpukit/score/cpu/aarch64/aarch64-thread-idle.c > - cpukit/score/cpu/aarch64/cpu.c > - cpukit/score/cpu/aarch64/cpu_asm.S From sebastian.huber at embedded-brains.de Mon Dec 13 14:53:07 2021 From: sebastian.huber at embedded-brains.de (Sebastian Huber) Date: Mon, 13 Dec 2021 15:53:07 +0100 Subject: New validation test suites Message-ID: <5c4d51cb-660d-93ec-7a59-4a98be61d4c1@embedded-brains.de> Hello, the ESA activity to pre-qualify parts of RTEMS according to ECSS requirements is nearly complete. There is a short presentation available here: https://indico.esa.int/event/374/timetable/ We finished the specification of the pre-qualified RTEMS feature set. The specification is available in an RTEMS Project repository: https://git.rtems.org/rtems-central/tree/spec The validation tests are generated from the specification using the "./spec2modules.py" script and end up in the RTEMS sources of a Git submodule. I think the specification and the generation tool is now sufficiently stable so that the validation test code can be integrated in the RTEMS master branch. The patch set is too big for the mailing list, so you can review it here: https://git.rtems.org/sebh/rtems.git/log/?h=validation https://github.com/sebhub/rtems/tree/validation The patch set is organized so that general support code for the validation tests is added first and then there are commits for each pre-qualified Classic API Manager or subsystem. I did build all BSPs with the patch set. The validation tests use only statically allocated resources. Some low memory targets are not able to link all test suites. -- embedded brains GmbH Herr Sebastian HUBER Dornierstr. 4 82178 Puchheim Germany email: sebastian.huber at embedded-brains.de phone: +49-89-18 94 741 - 16 fax: +49-89-18 94 741 - 08 Registergericht: Amtsgericht M?nchen Registernummer: HRB 157899 Vertretungsberechtigte Gesch?ftsf?hrer: Peter Rasmussen, Thomas D?rfler Unsere Datenschutzerkl?rung finden Sie hier: https://embedded-brains.de/datenschutzerklaerung/ From ryan.long at oarcorp.com Mon Dec 13 16:09:28 2021 From: ryan.long at oarcorp.com (Ryan Long) Date: Mon, 13 Dec 2021 11:09:28 -0500 Subject: [PATCH rtems-tools 1/6] ObjdumpProcessor.cc: Fix formatting In-Reply-To: <1639411773-18020-1-git-send-email-ryan.long@oarcorp.com> References: <1639411773-18020-1-git-send-email-ryan.long@oarcorp.com> Message-ID: <1639411773-18020-2-git-send-email-ryan.long@oarcorp.com> --- tester/covoar/ObjdumpProcessor.cc | 64 ++++++++++++++++++++++----------------- 1 file changed, 36 insertions(+), 28 deletions(-) diff --git a/tester/covoar/ObjdumpProcessor.cc b/tester/covoar/ObjdumpProcessor.cc index 8c0e8dc..92e812d 100644 --- a/tester/covoar/ObjdumpProcessor.cc +++ b/tester/covoar/ObjdumpProcessor.cc @@ -38,73 +38,81 @@ namespace Coverage { ) { // Find the symbol's coverage map. try { - CoverageMapBase& coverageMap = executableInfo->findCoverageMap(symbolName); + CoverageMapBase& coverageMap = + executableInfo->findCoverageMap( symbolName ); uint32_t firstInstructionAddress = UINT32_MAX; // Find the address of the first instruction. - for (auto& line : instructions) { - if (line.isInstruction) { + for ( auto& line : instructions ) { + if ( line.isInstruction ) { firstInstructionAddress = line.address; break; } } - if (firstInstructionAddress == UINT32_MAX) { + if ( firstInstructionAddress == UINT32_MAX ) { std::ostringstream what; what << "Could not find first instruction address for symbol " - << symbolName << " in " << executableInfo->getFileName(); + << symbolName << " in " << executableInfo->getFileName(); throw rld::error( what, "Coverage::finalizeSymbol" ); } - int rangeIndex = -1; + int rangeIndex = -1; uint32_t lowAddress = UINT32_MAX; do { rangeIndex++; - lowAddress = coverageMap.getLowAddressOfRange(rangeIndex); - } while (firstInstructionAddress != lowAddress); + lowAddress = coverageMap.getLowAddressOfRange( rangeIndex ); + } while ( firstInstructionAddress != lowAddress ); - uint32_t sizeWithoutNops = coverageMap.getSizeOfRange(rangeIndex); - uint32_t size = sizeWithoutNops; - uint32_t highAddress = lowAddress + size - 1; + uint32_t sizeWithoutNops = coverageMap.getSizeOfRange( rangeIndex ); + uint32_t size = sizeWithoutNops; + uint32_t highAddress = lowAddress + size - 1; uint32_t computedHighAddress = highAddress; // Find the high address as reported by the address of the last NOP // instruction. This ensures that NOPs get marked as executed later. - for (auto instruction = instructions.rbegin(); - instruction != instructions.rend(); - instruction++) { - if (instruction->isInstruction) { - if (instruction->isNop) { + for ( + auto instruction = instructions.rbegin(); + instruction != instructions.rend(); + instruction++ + ) { + if ( instruction->isInstruction ) { + if ( instruction->isNop ) { computedHighAddress = instruction->address + instruction->nopSize; } + break; } } - if (highAddress != computedHighAddress) { - std::cerr << "Function's high address differs between DWARF and objdump: " - << symbolName << " (0x" << std::hex << highAddress << " and 0x" - << computedHighAddress - 1 << ")" << std::dec << std::endl; + if ( highAddress != computedHighAddress ) { + std::cerr << "Function's high address differs between DWARF and " + << "objdump: " << symbolName << " (0x" << std::hex + << highAddress << " and 0x" + << computedHighAddress - 1 << ")" << std::dec << std::endl; + size = computedHighAddress - lowAddress; } // If there are NOT already saved instructions, save them. SymbolInformation* symbolInfo = symbolsToAnalyze.find( symbolName ); - if (symbolInfo->instructions.empty()) { - symbolInfo->sourceFile = executableInfo; - symbolInfo->baseAddress = lowAddress; + if ( symbolInfo->instructions.empty() ) { + symbolInfo->sourceFile = executableInfo; + symbolInfo->baseAddress = lowAddress; symbolInfo->instructions = instructions; } // Add the symbol to this executable's symbol table. SymbolTable* theSymbolTable = executableInfo->getSymbolTable(); theSymbolTable->addSymbol( - symbolName, lowAddress, highAddress - lowAddress + 1 + symbolName, + lowAddress, + highAddress - lowAddress + 1 ); // Mark the start of each instruction in the coverage map. - for (auto& instruction : instructions) { + for ( auto& instruction : instructions ) { coverageMap.setIsStartOfInstruction( instruction.address ); } @@ -116,16 +124,16 @@ namespace Coverage { sizeWithoutNops, verbose ); - } catch (const ExecutableInfo::CoverageMapNotFoundError& e) { + } catch ( const ExecutableInfo::CoverageMapNotFoundError& e ) { // Allow execution to continue even if a coverage map could not be // found. std::cerr << "Coverage map not found for symbol " << e.what() - << std::endl; + << std::endl; } } ObjdumpProcessor::ObjdumpProcessor( - DesiredSymbols& symbolsToAnalyze, + DesiredSymbols& symbolsToAnalyze, std::shared_ptr& targetInfo ): symbolsToAnalyze_m( symbolsToAnalyze ), targetInfo_m( targetInfo ) -- 1.8.3.1 From ryan.long at oarcorp.com Mon Dec 13 13:47:44 2021 From: ryan.long at oarcorp.com (Ryan Long) Date: Mon, 13 Dec 2021 08:47:44 -0500 Subject: [PATCH] TraceConverter.cc: Fix Uncaught exception issue Message-ID: <1639403264-7621-1-git-send-email-ryan.long@oarcorp.com> CID 1471639: Uncaught exception Closes #4501 --- tester/covoar/TraceConverter.cc | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/tester/covoar/TraceConverter.cc b/tester/covoar/TraceConverter.cc index 8e30ae5..2c5330a 100644 --- a/tester/covoar/TraceConverter.cc +++ b/tester/covoar/TraceConverter.cc @@ -87,14 +87,30 @@ int main( std::string tracefile; std::string logname = "/tmp/qemu.log"; Coverage::ExecutableInfo* executableInfo; - rld::process::tempfile objdumpFile( ".dmp" ); - rld::process::tempfile err( ".err" ); Coverage::DesiredSymbols symbolsToAnalyze; bool verbose = false; std::string dynamicLibrary; int ec = 0; std::shared_ptr targetInfo; + try + { + rld::process::tempfile objdumpFile( ".dmp" ); + } + catch ( rld::error re ) + { + std::cerr << "Failed to make .dmp tempfile " << std::endl; + } + + try + { + rld::process::tempfile err( ".err" ); + } + catch ( rld::error re ) + { + std::cerr << "Failed to make .err tempfile " << std::endl; + } + setup_signals(); // -- 1.8.3.1 From ryan.long at oarcorp.com Mon Dec 13 16:09:29 2021 From: ryan.long at oarcorp.com (Ryan Long) Date: Mon, 13 Dec 2021 11:09:29 -0500 Subject: [PATCH rtems-tools 2/6] TargetFactory.cc: Fix formatting In-Reply-To: <1639411773-18020-1-git-send-email-ryan.long@oarcorp.com> References: <1639411773-18020-1-git-send-email-ryan.long@oarcorp.com> Message-ID: <1639411773-18020-3-git-send-email-ryan.long@oarcorp.com> --- tester/covoar/TargetFactory.cc | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/tester/covoar/TargetFactory.cc b/tester/covoar/TargetFactory.cc index fa72f05..0b6be52 100644 --- a/tester/covoar/TargetFactory.cc +++ b/tester/covoar/TargetFactory.cc @@ -39,9 +39,7 @@ namespace Target { //! This is the string found in configuration to match. std::string theTarget; //! This is the static wrapper for the constructor. - TargetBase *(*theCtor)( - std::string - ); + TargetBase *(*theCtor)( std::string ); } FactoryEntry_t; //! @@ -60,27 +58,27 @@ namespace Target { { "powerpc", Target_powerpc_Constructor }, { "sparc", Target_sparc_Constructor }, { "riscv", Target_riscv_Constructor }, - { "TBD", NULL }, + { "TBD", NULL } }; - TargetBase* TargetFactory( - std::string targetName - ) + TargetBase* TargetFactory( std::string targetName ) { size_t i; std::string cpu; i = targetName.find( '-' ); - if ( i == targetName.npos ) + if ( i == targetName.npos ) { cpu = targetName; - else + } else { cpu = targetName.substr( 0, i ); + } // std::cerr << targetName << " --> " << cpu << std::endl; // Iterate over the table trying to find an entry with a matching name - for ( i=0 ; i < sizeof(FactoryTable) / sizeof(FactoryEntry_t); i++ ) { - if ( FactoryTable[i].theTarget == cpu ) + for ( i = 0 ; i < sizeof( FactoryTable ) / sizeof( FactoryEntry_t ); i++) { + if ( FactoryTable[i].theTarget == cpu ) { return FactoryTable[i].theCtor( targetName ); + } } std::ostringstream what; -- 1.8.3.1 From ryan.long at oarcorp.com Mon Dec 13 16:09:32 2021 From: ryan.long at oarcorp.com (Ryan Long) Date: Mon, 13 Dec 2021 11:09:32 -0500 Subject: [PATCH rtems-tools 5/6] ObjdumpProcessor.h: Fix formatting In-Reply-To: <1639411773-18020-1-git-send-email-ryan.long@oarcorp.com> References: <1639411773-18020-1-git-send-email-ryan.long@oarcorp.com> Message-ID: <1639411773-18020-6-git-send-email-ryan.long@oarcorp.com> --- tester/covoar/ObjdumpProcessor.h | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/tester/covoar/ObjdumpProcessor.h b/tester/covoar/ObjdumpProcessor.h index 0ca14b8..b3c7262 100644 --- a/tester/covoar/ObjdumpProcessor.h +++ b/tester/covoar/ObjdumpProcessor.h @@ -91,7 +91,7 @@ namespace Coverage { * This method constructs an ObjdumpProcessor instance. */ ObjdumpProcessor( - DesiredSymbols& symbolsToAnalyze, + DesiredSymbols& symbolsToAnalyze, std::shared_ptr& targetInfo ); @@ -100,24 +100,24 @@ namespace Coverage { */ virtual ~ObjdumpProcessor(); - uint32_t determineLoadAddress( - ExecutableInfo* theExecutable - ); + uint32_t determineLoadAddress( ExecutableInfo* theExecutable ); /*! * This method fills a tempfile with the .text section of objdump * for the given file name. */ - void getFile( std::string fileName, - rld::process::tempfile& dmp, - rld::process::tempfile& err ); + void getFile( + std::string fileName, + rld::process::tempfile& dmp, + rld::process::tempfile& err + ); /*! * This method fills the objdumpList list with all the * instruction addresses in the object dump file. */ void loadAddressTable ( - ExecutableInfo* const executableInformation, + ExecutableInfo* const executableInformation, rld::process::tempfile& dmp, rld::process::tempfile& err ); @@ -150,9 +150,7 @@ namespace Coverage { * the given line in the objdmp file is a branch instruction, * otherwise it returns false. */ - bool isBranchLine( - const std::string& line - ); + bool isBranchLine( const std::string& line ); /*! * This method sets the targetInfo_m variable. @@ -167,7 +165,7 @@ namespace Coverage { * This variable consists of a list of all instruction addresses * extracted from the obj dump file. */ - objdumpFile_t objdumpList; + objdumpFile_t objdumpList; /*! * This method determines whether the specified line is a -- 1.8.3.1 From ryan.long at oarcorp.com Mon Dec 13 16:09:33 2021 From: ryan.long at oarcorp.com (Ryan Long) Date: Mon, 13 Dec 2021 11:09:33 -0500 Subject: [PATCH rtems-tools 6/6] SymbolTable.cc: Fix formatting In-Reply-To: <1639411773-18020-1-git-send-email-ryan.long@oarcorp.com> References: <1639411773-18020-1-git-send-email-ryan.long@oarcorp.com> Message-ID: <1639411773-18020-7-git-send-email-ryan.long@oarcorp.com> --- tester/covoar/SymbolTable.cc | 70 ++++++++++++++++++++++++-------------------- 1 file changed, 38 insertions(+), 32 deletions(-) diff --git a/tester/covoar/SymbolTable.cc b/tester/covoar/SymbolTable.cc index cfbd7a3..a33a348 100644 --- a/tester/covoar/SymbolTable.cc +++ b/tester/covoar/SymbolTable.cc @@ -30,9 +30,9 @@ namespace Coverage { const uint32_t length ) { - uint32_t end = 0; - symbol_entry_t entry; - symbolInfo_t symbolData; + uint32_t end = 0; + symbol_entry_t entry; + symbolInfo_t symbolData; // Add an entry to the address map. end = start + length - 1; @@ -45,14 +45,14 @@ namespace Coverage { symbolData.startingAddress = start; symbolData.length = length; - for (auto& symData : info[ symbol ]) { + for ( auto& symData : info[ symbol ] ) { // The starting address could differ since we strip any suffixes beginning // with a '.' - if (symData.startingAddress != start) { + if ( symData.startingAddress != start ) { continue; } - if (symData.length != length) { + if ( symData.length != length ) { std::ostringstream what; what << "Different lengths for the symbol " << symbol @@ -66,39 +66,36 @@ namespace Coverage { info[ symbol ].push_back( symbolData ); } - SymbolTable::symbolInfo* SymbolTable::getInfo( - const std::string& symbol - ) + SymbolTable::symbolInfo* SymbolTable::getInfo( const std::string& symbol ) { info_t::iterator it = info.find( symbol ); - if (it == info.end()) + if ( it == info.end() ) { return NULL; - else - return (&(it->second)); + } else { + return ( &(it->second) ); + } } - uint32_t SymbolTable::getLength( - const std::string& symbol - ) + uint32_t SymbolTable::getLength( const std::string& symbol ) { info_t::iterator it = info.find( symbol ); - if (it == info.end()) + if ( it == info.end() ) { return 0; - else - return ((*it).second.front().length); + } else { + return ( (*it).second.front().length ); + } } - std::string SymbolTable::getSymbol( - uint32_t address - ) + std::string SymbolTable::getSymbol( uint32_t address ) { contents_t::iterator it; // Ensure that the symbol table is not empty. - if ( contents.size() == 0 ) + if ( contents.size() == 0 ) { return ""; + } // Find the first entry whose end address is greater // than the specified address. @@ -106,23 +103,32 @@ namespace Coverage { // If an entry was found and its low address is less than or // equal to the specified address, then return the symbol. - if ((it != contents.end()) && ((it->second).low <= address )) + if ( ( it != contents.end() ) && ( ( it->second ).low <= address ) ) { return (it->second).symbol; + } return ""; } void SymbolTable::dumpSymbolTable( void ) { - symbolInfo symbolTable; - symbolInfoIterator_t symbolIterator; - infoIterator_t infoIterator; - - for (infoIterator = info.begin() ; infoIterator != info.end(); infoIterator++) - { - for (symbolIterator = infoIterator->second.begin() ; symbolIterator != infoIterator->second.end(); symbolIterator++) - { - fprintf( stdout, "%s:\tStarting address = %#x\tLength = %u\n", infoIterator->first.c_str(), symbolIterator->startingAddress, symbolIterator->length ); + symbolInfo symbolTable; + symbolInfoIterator_t symbolIterator; + infoIterator_t infoIterator; + + for ( + infoIterator = info.begin(); + infoIterator != info.end(); + infoIterator++ + ) { + for ( + symbolIterator = infoIterator->second.begin(); + symbolIterator != infoIterator->second.end(); + symbolIterator++ + ) { + std::cerr << infoIterator->first << ":\tStarting address = 0x" + << std::hex << symbolIterator->startingAddress << std::dec + << "\tLength = " << symbolIterator->length << std::endl; } } } -- 1.8.3.1 From ryan.long at oarcorp.com Mon Dec 13 16:09:27 2021 From: ryan.long at oarcorp.com (Ryan Long) Date: Mon, 13 Dec 2021 11:09:27 -0500 Subject: [PATCH rtems-tools 0/6] Fix formatting patches Message-ID: <1639411773-18020-1-git-send-email-ryan.long@oarcorp.com> Hi, For this patchset I made the formatting more consistent. This included: - adding whitespace - adding curly braces to if statements or loops - fixing the layout of long lists of function parameters Thanks, Ryan Ryan Long (6): ObjdumpProcessor.cc: Fix formatting TargetFactory.cc: Fix formatting ConfigFile: Fix formatting ObjdumpProcessor.cc: Fix formatting ObjdumpProcessor.h: Fix formatting SymbolTable.cc: Fix formatting tester/covoar/ConfigFile.cc | 66 +++++----- tester/covoar/ConfigFile.h | 8 +- tester/covoar/ObjdumpProcessor.cc | 261 +++++++++++++++++++++----------------- tester/covoar/ObjdumpProcessor.h | 22 ++-- tester/covoar/SymbolTable.cc | 70 +++++----- tester/covoar/TargetFactory.cc | 20 ++- 6 files changed, 241 insertions(+), 206 deletions(-) -- 1.8.3.1 From ryan.long at oarcorp.com Mon Dec 13 16:09:30 2021 From: ryan.long at oarcorp.com (Ryan Long) Date: Mon, 13 Dec 2021 11:09:30 -0500 Subject: [PATCH rtems-tools 3/6] ConfigFile: Fix formatting In-Reply-To: <1639411773-18020-1-git-send-email-ryan.long@oarcorp.com> References: <1639411773-18020-1-git-send-email-ryan.long@oarcorp.com> Message-ID: <1639411773-18020-4-git-send-email-ryan.long@oarcorp.com> --- tester/covoar/ConfigFile.cc | 66 +++++++++++++++++++++++---------------------- tester/covoar/ConfigFile.h | 8 +++--- 2 files changed, 37 insertions(+), 37 deletions(-) diff --git a/tester/covoar/ConfigFile.cc b/tester/covoar/ConfigFile.cc index 7109b2c..1fbefd1 100644 --- a/tester/covoar/ConfigFile.cc +++ b/tester/covoar/ConfigFile.cc @@ -21,9 +21,7 @@ static void print_invalid_line_number( const std::string& file, int line_no ) namespace Configuration { - FileReader::FileReader( - Options_t *options - ) + FileReader::FileReader( Options_t *options ) { options_m = options; } @@ -32,19 +30,18 @@ namespace Configuration { { } - bool FileReader::processFile( - const std::string& file - ) + bool FileReader::processFile( const std::string& file ) { #define METHOD "FileReader::processFile - " #define MAX_LENGTH 256 + std::ifstream in; std::string line; char option[MAX_LENGTH]; char value[MAX_LENGTH]; - int line_no; - int i; - int j; + int line_no; + int i; + int j; if ( file.empty() ) { std::cerr << METHOD << "Empty filename" << std::endl; @@ -78,7 +75,7 @@ namespace Configuration { * * LHS = RHS # comment */ - for (i=0 ; i=0 && isspace(line[i]) ; i-- ) + for ( i = length - 1; i >= 0 && isspace( line[i] ); i-- ) ; line[i+1] = '\0'; - length = i+1; + length = i + 1; /* Ignore empty lines. We have stripped * all comments and blanks therefore, only * an empty string needs to be checked. */ - if (line[0] == '\0') + if ( line[0] == '\0' ) { continue; + } - if (std::sscanf(line.c_str(), "%s", option) != 1) { - print_invalid_line_number(file, line_no); + if ( std::sscanf( line.c_str(), "%s", option ) != 1 ) { + print_invalid_line_number( file, line_no ); continue; } - for (i=0; ((line[i] != '=') && (ioption ; o++ ) { + for ( o = options_m; o->option; o++ ) { if ( !strcmp( o->option, option ) ) { o->value = strdup( value ); return true; } } + return false; } - const char *FileReader::getOption( - const char* const option - ) + const char *FileReader::getOption( const char* const option ) { Options_t *o; - for ( o=options_m ; o->option ; o++ ) { + for ( o = options_m; o->option; o++ ) { if ( !strcmp( o->option, option ) ) { return o->value; } } + return NULL; } - void FileReader::printOptions(void) + void FileReader::printOptions() { Options_t *o; - for ( o=options_m ; o->option ; o++ ) { + for ( o = options_m; o->option; o++ ) { std::cerr << '(' << o->option << ")=(" << o->value << ')' << std::endl; } } diff --git a/tester/covoar/ConfigFile.h b/tester/covoar/ConfigFile.h index f8bd9c5..0339c12 100644 --- a/tester/covoar/ConfigFile.h +++ b/tester/covoar/ConfigFile.h @@ -53,9 +53,7 @@ namespace Configuration { * * @return Returns TRUE if the method succeeded and FALSE if it failed. */ - virtual bool processFile( - const std::string& file - ); + virtual bool processFile( const std::string& file ); bool setOption( const char* const option, @@ -66,7 +64,7 @@ namespace Configuration { const char* const option ); - void printOptions(void); + void printOptions(); private: /*! @@ -78,7 +76,7 @@ namespace Configuration { * * @return Returns TRUE if the method succeeded and FALSE if it failed. */ - Options_t *options_m; + Options_t* options_m; }; -- 1.8.3.1 From ryan.long at oarcorp.com Mon Dec 13 16:09:31 2021 From: ryan.long at oarcorp.com (Ryan Long) Date: Mon, 13 Dec 2021 11:09:31 -0500 Subject: [PATCH rtems-tools 4/6] ObjdumpProcessor.cc: Fix formatting In-Reply-To: <1639411773-18020-1-git-send-email-ryan.long@oarcorp.com> References: <1639411773-18020-1-git-send-email-ryan.long@oarcorp.com> Message-ID: <1639411773-18020-5-git-send-email-ryan.long@oarcorp.com> --- tester/covoar/ObjdumpProcessor.cc | 197 +++++++++++++++++++++----------------- 1 file changed, 111 insertions(+), 86 deletions(-) diff --git a/tester/covoar/ObjdumpProcessor.cc b/tester/covoar/ObjdumpProcessor.cc index 92e812d..0aef978 100644 --- a/tester/covoar/ObjdumpProcessor.cc +++ b/tester/covoar/ObjdumpProcessor.cc @@ -150,12 +150,13 @@ namespace Coverage { { #define METHOD "ERROR: ObjdumpProcessor::determineLoadAddress - " std::ifstream loadAddressFile; - uint32_t offset; - char inputBuffer[MAX_LINE_LENGTH]; + uint32_t offset; + char inputBuffer[ MAX_LINE_LENGTH ]; // This method should only be call for a dynamic library. - if (!theExecutable->hasDynamicLibrary()) + if ( !theExecutable->hasDynamicLibrary() ) { return 0; + } std::string dlinfoName = theExecutable->getFileName(); uint32_t address; @@ -165,7 +166,7 @@ namespace Coverage { dlinfoName += ".dlinfo"; // Read load address. loadAddressFile.open( dlinfoName ); - if (!loadAddressFile.is_open()) { + if ( !loadAddressFile.is_open() ) { std::ostringstream what; what << "Unable to open " << dlinfoName; throw rld::error( what, METHOD ); @@ -182,6 +183,7 @@ namespace Coverage { what << "library " << Library << " not found in " << dlinfoName; throw rld::error( what, METHOD ); } + sscanf( inputBuffer, "%s %x", inLibName, &offset ); std::string tmp = inLibName; if ( tmp.find( Library ) != tmp.npos ) { @@ -206,23 +208,21 @@ namespace Coverage { stderr, "ERROR: ObjdumpProcessor::IsBranch - unknown architecture\n" ); - assert(0); + assert( 0 ); return false; } return targetInfo_m->isBranch( instruction ); } - bool ObjdumpProcessor::isBranchLine( - const std::string& line - ) + bool ObjdumpProcessor::isBranchLine( const std::string& line ) { if ( !targetInfo_m ) { fprintf( stderr, "ERROR: ObjdumpProcessor::isBranchLine - unknown architecture\n" ); - assert(0); + assert( 0 ); return false; } @@ -234,7 +234,7 @@ namespace Coverage { int& size ) { - if ( !targetInfo_m ){ + if ( !targetInfo_m ) { fprintf( stderr, "ERROR: ObjdumpProcessor::isNop - unknown architecture\n" @@ -247,21 +247,32 @@ namespace Coverage { } void ObjdumpProcessor::getFile( - std::string fileName, + std::string fileName, rld::process::tempfile& objdumpFile, rld::process::tempfile& err - ) + ) { rld::process::status status; - rld::process::arg_container args = { targetInfo_m->getObjdump(), - "-Cda", "--section=.text", "--source", - fileName }; + rld::process::arg_container args = { + targetInfo_m->getObjdump(), + "-Cda", + "--section=.text", + "--source", + fileName + }; + try { - status = rld::process::execute( targetInfo_m->getObjdump(), - args, objdumpFile.name(), err.name() ); - if ( (status.type != rld::process::status::normal) - || (status.code != 0) ) { + status = rld::process::execute( + targetInfo_m->getObjdump(), + args, + objdumpFile.name(), + err.name() + ); + if ( + ( status.type != rld::process::status::normal ) || + ( status.code != 0 ) + ) { throw rld::error( "Objdump error", "generating objdump" ); } } catch( rld::error& err ) @@ -280,12 +291,12 @@ namespace Coverage { objdumpFile_t::iterator itr; itr = find ( objdumpList.begin(), objdumpList.end(), address ); - if (itr == objdumpList.end()) { + if ( itr == objdumpList.end() ) { return 0; } itr++; - if (itr == objdumpList.end()) { + if ( itr == objdumpList.end() ) { return 0; } @@ -294,21 +305,22 @@ namespace Coverage { } void ObjdumpProcessor::loadAddressTable ( - ExecutableInfo* const executableInformation, - rld::process::tempfile& objdumpFile, - rld::process::tempfile& err + ExecutableInfo* const executableInformation, + rld::process::tempfile& objdumpFile, + rld::process::tempfile& err ) { - int items; - uint32_t offset; - char terminator; - std::string line; + int items; + uint32_t offset; + char terminator; + std::string line; // Obtain the objdump file. - if ( !executableInformation->hasDynamicLibrary() ) + if ( !executableInformation->hasDynamicLibrary() ) { getFile( executableInformation->getFileName(), objdumpFile, err ); - else + } else { getFile( executableInformation->getLibraryName(), objdumpFile, err ); + } // Process all lines from the objdump file. while ( true ) { @@ -320,14 +332,10 @@ namespace Coverage { } // See if it is the dump of an instruction. - items = sscanf( - line.c_str(), - "%x%c", - &offset, &terminator - ); + items = sscanf( line.c_str(), "%x%c", &offset, &terminator ); // If it looks like an instruction ... - if ((items == 2) && (terminator == ':')) { + if ( ( items == 2 ) && ( terminator == ':' ) ) { objdumpList.push_back( executableInformation->getLoadAddress() + offset ); @@ -336,42 +344,43 @@ namespace Coverage { } void ObjdumpProcessor::load( - ExecutableInfo* const executableInformation, - rld::process::tempfile& objdumpFile, - rld::process::tempfile& err, - bool verbose + ExecutableInfo* const executableInformation, + rld::process::tempfile& objdumpFile, + rld::process::tempfile& err, + bool verbose ) { - std::string currentSymbol = ""; - uint32_t instructionOffset; - int items; - int found; - objdumpLine_t lineInfo; - uint32_t offset; - bool processSymbol = false; - char symbol[ MAX_LINE_LENGTH ]; - char terminator1; - char terminatorOne; - char terminator2; - objdumpLines_t theInstructions; - char instruction[ MAX_LINE_LENGTH ]; - char ID[ MAX_LINE_LENGTH ]; - std::string call = ""; - std::string jumpTableID = ""; - std::string line = ""; + std::string currentSymbol = ""; + uint32_t instructionOffset; + int items; + int found; + objdumpLine_t lineInfo; + uint32_t offset; + bool processSymbol = false; + char symbol[ MAX_LINE_LENGTH ]; + char terminator1; + char terminatorOne; + char terminator2; + objdumpLines_t theInstructions; + char instruction[ MAX_LINE_LENGTH ]; + char ID[ MAX_LINE_LENGTH ]; + std::string call = ""; + std::string jumpTableID = ""; + std::string line = ""; // Obtain the objdump file. - if ( !executableInformation->hasDynamicLibrary() ) + if ( !executableInformation->hasDynamicLibrary() ) { getFile( executableInformation->getFileName(), objdumpFile, err ); - else + } else { getFile( executableInformation->getLibraryName(), objdumpFile, err ); + } while ( true ) { // Get the line. objdumpFile.read_line( line ); if ( line.empty() ) { // If we are currently processing a symbol, finalize it. - if (processSymbol) { + if ( processSymbol ) { finalizeSymbol( executableInformation, currentSymbol, @@ -379,23 +388,23 @@ namespace Coverage { verbose, symbolsToAnalyze_m ); - fprintf( - stderr, - "WARNING: ObjdumpProcessor::load - analysis of symbol %s \n" - " may be incorrect. It was the last symbol in %s\n" - " and the length of its last instruction is assumed " - " to be one.\n", - currentSymbol.c_str(), - executableInformation->getFileName().c_str() - ); + + std::cerr << "WARNING: ObjdumpProcessor::load - analysis of symbol " + << currentSymbol << std::endl + << " may be incorrect. It was the last symbol in " + << executableInformation->getFileName() << std::endl + << " and the length of its last instruction" + << " is assumed to be one." + << std::endl; } + objdumpFile.close(); break; } // Remove any extra line break - if (line.back() == '\n') { - line.erase(line.end() - 1); + if ( line.back() == '\n' ) { + line.erase( line.end() - 1 ); } lineInfo.line = line; @@ -413,22 +422,28 @@ namespace Coverage { items = sscanf( line.c_str(), "%x <%[^>]>%c", - &offset, symbol, &terminator1 + &offset, + symbol, + &terminator1 ); // See if it is a jump table. found = sscanf( line.c_str(), "%x%c\t%*[^\t]%c%s %*x %*[^+]%s", - &instructionOffset, &terminatorOne, &terminator2, instruction, ID + &instructionOffset, + &terminatorOne, + &terminator2, + instruction, + ID ); call = instruction; jumpTableID = ID; // If all items found, we are at the beginning of a symbol's objdump. - if ((items == 3) && (terminator1 == ':')) { + if ( ( items == 3 ) && ( terminator1 == ':' ) ) { // If we are currently processing a symbol, finalize it. - if (processSymbol) { + if ( processSymbol ) { finalizeSymbol( executableInformation, currentSymbol, @@ -453,24 +468,27 @@ namespace Coverage { // When this happens, the compiler will generate a function with a // ".part.n" suffix. For our purposes, this generated function part is // equivalent to the original function and should be treated as such. - char *periodIndex = strstr(symbol, "."); - if (periodIndex != NULL) { + char *periodIndex = strstr( symbol, "." ); + if ( periodIndex != NULL ) { *periodIndex = 0; } // See if the new symbol is one that we care about. - if (symbolsToAnalyze_m.isDesired( symbol )) { + if ( symbolsToAnalyze_m.isDesired( symbol ) ) { currentSymbol = symbol; processSymbol = true; theInstructions.push_back( lineInfo ); } } // If it looks like a jump table, finalize the symbol. - else if ( (found == 5) && (terminatorOne == ':') && (terminator2 == '\t') - && (call.find( "call" ) != std::string::npos) - && (jumpTableID.find( "+0x" ) != std::string::npos) - && processSymbol ) - { + else if ( + ( found == 5 ) && + ( terminatorOne == ':' ) && + ( terminator2 == '\t' ) && + ( call.find( "call" ) != std::string::npos ) && + ( jumpTableID.find( "+0x" ) != std::string::npos ) && + processSymbol + ) { // If we are currently processing a symbol, finalize it. if ( processSymbol ) { finalizeSymbol( @@ -481,19 +499,26 @@ namespace Coverage { symbolsToAnalyze_m ); } + processSymbol = false; } - else if (processSymbol) { + else if ( processSymbol ) { // See if it is the dump of an instruction. items = sscanf( line.c_str(), "%x%c\t%*[^\t]%c", - &instructionOffset, &terminator1, &terminator2 + &instructionOffset, + &terminator1, + &terminator2 ); // If it looks like an instruction ... - if ((items == 3) && (terminator1 == ':') && (terminator2 == '\t')) { + if ( + ( items == 3 ) && + ( terminator1 == ':' ) && + ( terminator2 == '\t' ) + ) { // update the line's information, save it and ... lineInfo.address = executableInformation->getLoadAddress() + instructionOffset; -- 1.8.3.1 From chrisj at rtems.org Mon Dec 13 21:03:53 2021 From: chrisj at rtems.org (Chris Johns) Date: Tue, 14 Dec 2021 08:03:53 +1100 Subject: [PATCH rtems-tools 0/6] Fix formatting patches In-Reply-To: <1639411773-18020-1-git-send-email-ryan.long@oarcorp.com> References: <1639411773-18020-1-git-send-email-ryan.long@oarcorp.com> Message-ID: <389270ac-f090-b9ce-a503-90a99ad874f9@rtems.org> OK and thanks for the split. Thanks Chris On 14/12/21 3:09 am, Ryan Long wrote: > Hi, > > For this patchset I made the formatting more consistent. > > This included: > > - adding whitespace > - adding curly braces to if statements or loops > - fixing the layout of long lists of function parameters > > Thanks, > Ryan > > Ryan Long (6): > ObjdumpProcessor.cc: Fix formatting > TargetFactory.cc: Fix formatting > ConfigFile: Fix formatting > ObjdumpProcessor.cc: Fix formatting > ObjdumpProcessor.h: Fix formatting > SymbolTable.cc: Fix formatting > > tester/covoar/ConfigFile.cc | 66 +++++----- > tester/covoar/ConfigFile.h | 8 +- > tester/covoar/ObjdumpProcessor.cc | 261 +++++++++++++++++++++----------------- > tester/covoar/ObjdumpProcessor.h | 22 ++-- > tester/covoar/SymbolTable.cc | 70 +++++----- > tester/covoar/TargetFactory.cc | 20 ++- > 6 files changed, 241 insertions(+), 206 deletions(-) > From chrisj at rtems.org Mon Dec 13 21:01:18 2021 From: chrisj at rtems.org (Chris Johns) Date: Tue, 14 Dec 2021 08:01:18 +1100 Subject: New validation test suites In-Reply-To: <5c4d51cb-660d-93ec-7a59-4a98be61d4c1@embedded-brains.de> References: <5c4d51cb-660d-93ec-7a59-4a98be61d4c1@embedded-brains.de> Message-ID: <514bddac-9f20-5fa6-52a0-57c8f8787c82@rtems.org> On 14/12/21 1:53 am, Sebastian Huber wrote: > Hello, > > the ESA activity to pre-qualify parts of RTEMS according to ECSS requirements is > nearly complete. There is a short presentation available here: > > https://indico.esa.int/event/374/timetable/ Was the change in memory usage for 4.8 of 23812 bytes to 68896 explained? > We finished the specification of the pre-qualified RTEMS feature set. The > specification is available in an RTEMS Project repository: > > https://git.rtems.org/rtems-central/tree/spec I had a quick look. Is there a more user friendly view of this data? I think the term "specification" is a little bit misleading because the data files are not easily read by a person. I understand this is the specification data set however it is not what I am traditionally use to seeing. > The validation tests are generated from the specification using the > "./spec2modules.py" script and end up in the RTEMS sources of a Git submodule. I > think the specification and the generation tool is now sufficiently stable so > that the validation test code can be integrated in the RTEMS master branch. The > patch set is too big for the mailing list, so you can review it here: > > https://git.rtems.org/sebh/rtems.git/log/?h=validation The link failed. > https://github.com/sebhub/rtems/tree/validation The header in a test says the regeneration instructions are in the engineering manual but I could not quickly find them? > The patch set is organized so that general support code for the validation tests > is added first and then there are commits for each pre-qualified Classic API > Manager or subsystem. > > I did build all BSPs with the patch set. The validation tests use only > statically allocated resources. Are the validation tests compatible with rtems-test? How many test executables does this add to the testsuite? What hardware have the validation tests been run on? Any tier 1 archs? Is there anything that interprets the new test output format? It looks like lots of great info but a little difficult to read. > Some low memory targets are not able to link all test suites. Are these excluded in the normal way? Chris From chrisj at rtems.org Mon Dec 13 21:03:20 2021 From: chrisj at rtems.org (Chris Johns) Date: Tue, 14 Dec 2021 08:03:20 +1100 Subject: [PATCH] TraceConverter.cc: Fix Uncaught exception issue In-Reply-To: <1639403264-7621-1-git-send-email-ryan.long@oarcorp.com> References: <1639403264-7621-1-git-send-email-ryan.long@oarcorp.com> Message-ID: OK On 14/12/21 12:47 am, Ryan Long wrote: > CID 1471639: Uncaught exception > > Closes #4501 > --- > tester/covoar/TraceConverter.cc | 20 ++++++++++++++++++-- > 1 file changed, 18 insertions(+), 2 deletions(-) > > diff --git a/tester/covoar/TraceConverter.cc b/tester/covoar/TraceConverter.cc > index 8e30ae5..2c5330a 100644 > --- a/tester/covoar/TraceConverter.cc > +++ b/tester/covoar/TraceConverter.cc > @@ -87,14 +87,30 @@ int main( > std::string tracefile; > std::string logname = "/tmp/qemu.log"; > Coverage::ExecutableInfo* executableInfo; > - rld::process::tempfile objdumpFile( ".dmp" ); > - rld::process::tempfile err( ".err" ); > Coverage::DesiredSymbols symbolsToAnalyze; > bool verbose = false; > std::string dynamicLibrary; > int ec = 0; > std::shared_ptr targetInfo; > > + try > + { > + rld::process::tempfile objdumpFile( ".dmp" ); > + } > + catch ( rld::error re ) > + { > + std::cerr << "Failed to make .dmp tempfile " << std::endl; > + } > + > + try > + { > + rld::process::tempfile err( ".err" ); > + } > + catch ( rld::error re ) > + { > + std::cerr << "Failed to make .err tempfile " << std::endl; > + } > + > setup_signals(); > > // > From zakthertemsdev at gmail.com Tue Dec 14 01:47:47 2021 From: zakthertemsdev at gmail.com (zack leung) Date: Tue, 14 Dec 2021 01:47:47 +0000 Subject: New validation test suites In-Reply-To: <514bddac-9f20-5fa6-52a0-57c8f8787c82@rtems.org> References: <5c4d51cb-660d-93ec-7a59-4a98be61d4c1@embedded-brains.de> <514bddac-9f20-5fa6-52a0-57c8f8787c82@rtems.org> Message-ID: What tasks can I do that can help with ECSS compliance? Zack On Mon, 13 Dec 2021 at 21:40, Chris Johns wrote: > On 14/12/21 1:53 am, Sebastian Huber wrote: > > Hello, > > > > the ESA activity to pre-qualify parts of RTEMS according to ECSS > requirements is > > nearly complete. There is a short presentation available here: > > > > https://indico.esa.int/event/374/timetable/ > > Was the change in memory usage for 4.8 of 23812 bytes to 68896 explained? > > We finished the specification of the pre-qualified RTEMS feature set. The > > specification is available in an RTEMS Project repository: > > > > https://git.rtems.org/rtems-central/tree/spec > > I had a quick look. Is there a more user friendly view of this data? > > I think the term "specification" is a little bit misleading because the > data > files are not easily read by a person. I understand this is the > specification > data set however it is not what I am traditionally use to seeing. > > > The validation tests are generated from the specification using the > > "./spec2modules.py" script and end up in the RTEMS sources of a Git > submodule. I > > think the specification and the generation tool is now sufficiently > stable so > > that the validation test code can be integrated in the RTEMS master > branch. The > > patch set is too big for the mailing list, so you can review it here: > > > > https://git.rtems.org/sebh/rtems.git/log/?h=validation > > The link failed. > > > https://github.com/sebhub/rtems/tree/validation > > The header in a test says the regeneration instructions are in the > engineering > manual but I could not quickly find them? > > > The patch set is organized so that general support code for the > validation tests > > is added first and then there are commits for each pre-qualified Classic > API > > Manager or subsystem. > > > > I did build all BSPs with the patch set. The validation tests use only > > statically allocated resources. > > Are the validation tests compatible with rtems-test? > > How many test executables does this add to the testsuite? > > What hardware have the validation tests been run on? Any tier 1 archs? > > Is there anything that interprets the new test output format? It looks > like lots > of great info but a little difficult to read. > > > Some low memory targets are not able to link all test suites. > > Are these excluded in the normal way? > > Chris > _______________________________________________ > devel mailing list > devel at rtems.org > http://lists.rtems.org/mailman/listinfo/devel > From gedare at rtems.org Tue Dec 14 01:56:38 2021 From: gedare at rtems.org (Gedare Bloom) Date: Mon, 13 Dec 2021 18:56:38 -0700 Subject: [PATCH v2 1/3] aarch64: add internal API for secure monitor call (smc) In-Reply-To: References: <20211211161604.1309486-1-gedare@rtems.org> <20211211161604.1309486-2-gedare@rtems.org> Message-ID: On Mon, Dec 13, 2021 at 9:55 AM Kinsey Moore wrote: > > Everything else looks good. Just one nit below. > > On 12/11/2021 10:16, Gedare Bloom wrote: > > --- > > cpukit/score/cpu/aarch64/aarch64-smc.c | 72 ++++++++++++++++ > > .../aarch64/include/rtems/score/aarch64-smc.h | 83 +++++++++++++++++++ > > spec/build/cpukit/cpuaarch64.yml | 2 + > > 3 files changed, 157 insertions(+) > > create mode 100644 cpukit/score/cpu/aarch64/aarch64-smc.c > > create mode 100644 cpukit/score/cpu/aarch64/include/rtems/score/aarch64-smc.h > > > > diff --git a/cpukit/score/cpu/aarch64/aarch64-smc.c b/cpukit/score/cpu/aarch64/aarch64-smc.c > > new file mode 100644 > > index 0000000000..c531d074d8 > > --- /dev/null > > +++ b/cpukit/score/cpu/aarch64/aarch64-smc.c > > @@ -0,0 +1,72 @@ > > +/* SPDX-License-Identifier: BSD-2-Clause */ > > + > > +/** > > + * @file > > + * > > + * @brief This source file contains the implementation of > > + * _AArch64_SMC_Invoke(). > > + */ > > + > > +/* > > + * Copyright (C) 2021 Gedare Bloom > > + * > > + * 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 > > + > > +int _AArch64_SMC_Invoke( > > + uint32_t function_id, > > + uintptr_t arg0, > > + uintptr_t arg1, > > + uintptr_t arg2, > > + uintptr_t arg3, > > + uintptr_t arg4, > > + uintptr_t arg5, > > + uintptr_t arg6, > > The SMC arguments here should be uint64_t for all AArch64 calls > regardless of ABI. > This shouldn't matter, since AArch64 calls will have LP64? I guess I can change it. My thinking was that if we want to later add _AArch32_SMC_Invoke() it can have almost the exact same prototype as this function (except the return type but even that is a pointer), which might simplify some programming. > > > + AArch64_SMC_Return *result > > +) { > > + int rv; > > + > > + /* This only works for SMC that return 4 or fewer results. It may be extended > > + * up to the full 18 return results specified for SMC64, but then we would > > + * need to allocate a callee-saved register for *result */ > > + __asm__ volatile( > > + "smc #0\n" > > + "mov %0, x0\n" > > + "ldr x15, [sp]\n" > > + "cbz x15, 0f\n" > > + "stp x0, x1, [x15]\n" > > + "stp x2, x3, [x15, #16]\n" > > + "0:\n" > > + : "=r" ( rv ) > > + : > > + : "x0", "x1", "x2", "x3", "x15" > > + ); > > + > > + return rv; > > +} > > + > > diff --git a/cpukit/score/cpu/aarch64/include/rtems/score/aarch64-smc.h b/cpukit/score/cpu/aarch64/include/rtems/score/aarch64-smc.h > > new file mode 100644 > > index 0000000000..e80cc1e99b > > --- /dev/null > > +++ b/cpukit/score/cpu/aarch64/include/rtems/score/aarch64-smc.h > > @@ -0,0 +1,83 @@ > > +/* SPDX-License-Identifier: BSD-2-Clause */ > > + > > +/** > > + * @file > > + * > > + * @ingroup RTEMSScoreCPUAArch64 > > + * > > + * @brief This header file provides API to wrap secure monitor calls (smc). > > + */ > > + > > +/* > > + * Copyright (C) 2021 Gedare Bloom > > + * > > + * 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_SCORE_AARCH64_SMC_H > > +#define _RTEMS_SCORE_AARCH64_SMC_H > > + > > +#include > > + > > +#ifdef __cplusplus > > +extern "C" { > > +#endif > > + > > +/** > > + * @defgroup RTEMSScoreCPUAArch64SMC Secure Monitor Call Support > > + * > > + * @ingroup RTEMSScoreCPUAArch64 > > + * > > + * @brief This group provides functions to invoke secure monitor mode. > > + * > > + * @{ > > + */ > > + > > +/* > > + * @brief The return result from smc invocation. > > + */ > > +typedef struct { > > + uintptr_t x0; > > + uintptr_t x1; > > + uintptr_t x2; > > + uintptr_t x3; > > +} AArch64_SMC_Return; > > + > > +int _AArch64_SMC_Invoke( > > + uint32_t function_id, > > + uintptr_t arg0, > > + uintptr_t arg1, > > + uintptr_t arg2, > > + uintptr_t arg3, > > + uintptr_t arg4, > > + uintptr_t arg5, > > + uintptr_t arg6, > > + AArch64_SMC_Return *result > > +); > > + > > +/** @} */ > > + > > +#ifdef __cplusplus > > +} > > +#endif > > + > > +#endif /* _RTEMS_SCORE_AARCH64_SMC_H */ > > diff --git a/spec/build/cpukit/cpuaarch64.yml b/spec/build/cpukit/cpuaarch64.yml > > index 70d80f0b6c..1f3f07f0a2 100644 > > --- a/spec/build/cpukit/cpuaarch64.yml > > +++ b/spec/build/cpukit/cpuaarch64.yml > > @@ -19,6 +19,7 @@ install: > > - destination: ${BSP_INCLUDEDIR}/rtems/score > > source: > > - cpukit/score/cpu/aarch64/include/rtems/score/aarch64-system-registers.h > > + - cpukit/score/cpu/aarch64/include/rtems/score/aarch64-smc.h > > - cpukit/score/cpu/aarch64/include/rtems/score/cpu.h > > - cpukit/score/cpu/aarch64/include/rtems/score/cpuatomic.h > > - cpukit/score/cpu/aarch64/include/rtems/score/cpuimpl.h > > @@ -32,6 +33,7 @@ source: > > - cpukit/score/cpu/aarch64/aarch64-exception-default.c > > - cpukit/score/cpu/aarch64/aarch64-exception-frame-print.c > > - cpukit/score/cpu/aarch64/aarch64-exception-interrupt.S > > +- cpukit/score/cpu/aarch64/aarch64-smc.c > > - cpukit/score/cpu/aarch64/aarch64-thread-idle.c > > - cpukit/score/cpu/aarch64/cpu.c > > - cpukit/score/cpu/aarch64/cpu_asm.S > _______________________________________________ > devel mailing list > devel at rtems.org > http://lists.rtems.org/mailman/listinfo/devel From kinsey.moore at oarcorp.com Tue Dec 14 02:18:06 2021 From: kinsey.moore at oarcorp.com (Kinsey Moore) Date: Mon, 13 Dec 2021 20:18:06 -0600 Subject: [PATCH v2 1/3] aarch64: add internal API for secure monitor call (smc) In-Reply-To: References: <20211211161604.1309486-1-gedare@rtems.org> <20211211161604.1309486-2-gedare@rtems.org> Message-ID: <682d9c9e-e08f-6078-9e3a-926ce72a2e9e@oarcorp.com> On 12/13/2021 19:56, Gedare Bloom wrote: > On Mon, Dec 13, 2021 at 9:55 AM Kinsey Moore wrote: >> Everything else looks good. Just one nit below. >> >> On 12/11/2021 10:16, Gedare Bloom wrote: >>> --- >>> cpukit/score/cpu/aarch64/aarch64-smc.c | 72 ++++++++++++++++ >>> .../aarch64/include/rtems/score/aarch64-smc.h | 83 +++++++++++++++++++ >>> spec/build/cpukit/cpuaarch64.yml | 2 + >>> 3 files changed, 157 insertions(+) >>> create mode 100644 cpukit/score/cpu/aarch64/aarch64-smc.c >>> create mode 100644 cpukit/score/cpu/aarch64/include/rtems/score/aarch64-smc.h >>> >>> diff --git a/cpukit/score/cpu/aarch64/aarch64-smc.c b/cpukit/score/cpu/aarch64/aarch64-smc.c >>> new file mode 100644 >>> index 0000000000..c531d074d8 >>> --- /dev/null >>> +++ b/cpukit/score/cpu/aarch64/aarch64-smc.c >>> @@ -0,0 +1,72 @@ >>> +/* SPDX-License-Identifier: BSD-2-Clause */ >>> + >>> +/** >>> + * @file >>> + * >>> + * @brief This source file contains the implementation of >>> + * _AArch64_SMC_Invoke(). >>> + */ >>> + >>> +/* >>> + * Copyright (C) 2021 Gedare Bloom >>> + * >>> + * 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 >>> + >>> +int _AArch64_SMC_Invoke( >>> + uint32_t function_id, >>> + uintptr_t arg0, >>> + uintptr_t arg1, >>> + uintptr_t arg2, >>> + uintptr_t arg3, >>> + uintptr_t arg4, >>> + uintptr_t arg5, >>> + uintptr_t arg6, >> The SMC arguments here should be uint64_t for all AArch64 calls >> regardless of ABI. >> > This shouldn't matter, since AArch64 calls will have LP64? I guess I > can change it. My thinking was that if we want to later add > _AArch32_SMC_Invoke() it can have almost the exact same prototype as > this function (except the return type but even that is a pointer), > which might simplify some programming. The problem is that AArch64 has the LP64 and ILP32 ABIs which both use SMC64 since ILP32 is really just normal AArch64 instructions, memory space, and 64-bit registers under the hood. AArch32/ARMv7 has the same data model as AArch64/ILP32, but AArch32/ARMv7 uses SMC32 calls since it's 32-bit registers. This all assumes that I've read/remember the specs correctly. > >>> + AArch64_SMC_Return *result >>> +) { >>> + int rv; >>> + >>> + /* This only works for SMC that return 4 or fewer results. It may be extended >>> + * up to the full 18 return results specified for SMC64, but then we would >>> + * need to allocate a callee-saved register for *result */ >>> + __asm__ volatile( >>> + "smc #0\n" >>> + "mov %0, x0\n" >>> + "ldr x15, [sp]\n" >>> + "cbz x15, 0f\n" >>> + "stp x0, x1, [x15]\n" >>> + "stp x2, x3, [x15, #16]\n" >>> + "0:\n" >>> + : "=r" ( rv ) >>> + : >>> + : "x0", "x1", "x2", "x3", "x15" >>> + ); >>> + >>> + return rv; >>> +} >>> + >>> diff --git a/cpukit/score/cpu/aarch64/include/rtems/score/aarch64-smc.h b/cpukit/score/cpu/aarch64/include/rtems/score/aarch64-smc.h >>> new file mode 100644 >>> index 0000000000..e80cc1e99b >>> --- /dev/null >>> +++ b/cpukit/score/cpu/aarch64/include/rtems/score/aarch64-smc.h >>> @@ -0,0 +1,83 @@ >>> +/* SPDX-License-Identifier: BSD-2-Clause */ >>> + >>> +/** >>> + * @file >>> + * >>> + * @ingroup RTEMSScoreCPUAArch64 >>> + * >>> + * @brief This header file provides API to wrap secure monitor calls (smc). >>> + */ >>> + >>> +/* >>> + * Copyright (C) 2021 Gedare Bloom >>> + * >>> + * 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_SCORE_AARCH64_SMC_H >>> +#define _RTEMS_SCORE_AARCH64_SMC_H >>> + >>> +#include >>> + >>> +#ifdef __cplusplus >>> +extern "C" { >>> +#endif >>> + >>> +/** >>> + * @defgroup RTEMSScoreCPUAArch64SMC Secure Monitor Call Support >>> + * >>> + * @ingroup RTEMSScoreCPUAArch64 >>> + * >>> + * @brief This group provides functions to invoke secure monitor mode. >>> + * >>> + * @{ >>> + */ >>> + >>> +/* >>> + * @brief The return result from smc invocation. >>> + */ >>> +typedef struct { >>> + uintptr_t x0; >>> + uintptr_t x1; >>> + uintptr_t x2; >>> + uintptr_t x3; >>> +} AArch64_SMC_Return; >>> + >>> +int _AArch64_SMC_Invoke( >>> + uint32_t function_id, >>> + uintptr_t arg0, >>> + uintptr_t arg1, >>> + uintptr_t arg2, >>> + uintptr_t arg3, >>> + uintptr_t arg4, >>> + uintptr_t arg5, >>> + uintptr_t arg6, >>> + AArch64_SMC_Return *result >>> +); >>> + >>> +/** @} */ >>> + >>> +#ifdef __cplusplus >>> +} >>> +#endif >>> + >>> +#endif /* _RTEMS_SCORE_AARCH64_SMC_H */ >>> diff --git a/spec/build/cpukit/cpuaarch64.yml b/spec/build/cpukit/cpuaarch64.yml >>> index 70d80f0b6c..1f3f07f0a2 100644 >>> --- a/spec/build/cpukit/cpuaarch64.yml >>> +++ b/spec/build/cpukit/cpuaarch64.yml >>> @@ -19,6 +19,7 @@ install: >>> - destination: ${BSP_INCLUDEDIR}/rtems/score >>> source: >>> - cpukit/score/cpu/aarch64/include/rtems/score/aarch64-system-registers.h >>> + - cpukit/score/cpu/aarch64/include/rtems/score/aarch64-smc.h >>> - cpukit/score/cpu/aarch64/include/rtems/score/cpu.h >>> - cpukit/score/cpu/aarch64/include/rtems/score/cpuatomic.h >>> - cpukit/score/cpu/aarch64/include/rtems/score/cpuimpl.h >>> @@ -32,6 +33,7 @@ source: >>> - cpukit/score/cpu/aarch64/aarch64-exception-default.c >>> - cpukit/score/cpu/aarch64/aarch64-exception-frame-print.c >>> - cpukit/score/cpu/aarch64/aarch64-exception-interrupt.S >>> +- cpukit/score/cpu/aarch64/aarch64-smc.c >>> - cpukit/score/cpu/aarch64/aarch64-thread-idle.c >>> - cpukit/score/cpu/aarch64/cpu.c >>> - cpukit/score/cpu/aarch64/cpu_asm.S >> _______________________________________________ >> devel mailing list >> devel at rtems.org >> http://lists.rtems.org/mailman/listinfo/devel From gedare at rtems.org Tue Dec 14 02:45:46 2021 From: gedare at rtems.org (Gedare Bloom) Date: Mon, 13 Dec 2021 19:45:46 -0700 Subject: [PATCH v2 1/3] aarch64: add internal API for secure monitor call (smc) In-Reply-To: <682d9c9e-e08f-6078-9e3a-926ce72a2e9e@oarcorp.com> References: <20211211161604.1309486-1-gedare@rtems.org> <20211211161604.1309486-2-gedare@rtems.org> <682d9c9e-e08f-6078-9e3a-926ce72a2e9e@oarcorp.com> Message-ID: On Mon, Dec 13, 2021 at 7:18 PM Kinsey Moore wrote: > > On 12/13/2021 19:56, Gedare Bloom wrote: > > On Mon, Dec 13, 2021 at 9:55 AM Kinsey Moore wrote: > >> Everything else looks good. Just one nit below. > >> > >> On 12/11/2021 10:16, Gedare Bloom wrote: > >>> --- > >>> cpukit/score/cpu/aarch64/aarch64-smc.c | 72 ++++++++++++++++ > >>> .../aarch64/include/rtems/score/aarch64-smc.h | 83 +++++++++++++++++++ > >>> spec/build/cpukit/cpuaarch64.yml | 2 + > >>> 3 files changed, 157 insertions(+) > >>> create mode 100644 cpukit/score/cpu/aarch64/aarch64-smc.c > >>> create mode 100644 cpukit/score/cpu/aarch64/include/rtems/score/aarch64-smc.h > >>> > >>> diff --git a/cpukit/score/cpu/aarch64/aarch64-smc.c b/cpukit/score/cpu/aarch64/aarch64-smc.c > >>> new file mode 100644 > >>> index 0000000000..c531d074d8 > >>> --- /dev/null > >>> +++ b/cpukit/score/cpu/aarch64/aarch64-smc.c > >>> @@ -0,0 +1,72 @@ > >>> +/* SPDX-License-Identifier: BSD-2-Clause */ > >>> + > >>> +/** > >>> + * @file > >>> + * > >>> + * @brief This source file contains the implementation of > >>> + * _AArch64_SMC_Invoke(). > >>> + */ > >>> + > >>> +/* > >>> + * Copyright (C) 2021 Gedare Bloom > >>> + * > >>> + * 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 > >>> + > >>> +int _AArch64_SMC_Invoke( > >>> + uint32_t function_id, > >>> + uintptr_t arg0, > >>> + uintptr_t arg1, > >>> + uintptr_t arg2, > >>> + uintptr_t arg3, > >>> + uintptr_t arg4, > >>> + uintptr_t arg5, > >>> + uintptr_t arg6, > >> The SMC arguments here should be uint64_t for all AArch64 calls > >> regardless of ABI. > >> > > This shouldn't matter, since AArch64 calls will have LP64? I guess I > > can change it. My thinking was that if we want to later add > > _AArch32_SMC_Invoke() it can have almost the exact same prototype as > > this function (except the return type but even that is a pointer), > > which might simplify some programming. > The problem is that AArch64 has the LP64 and ILP32 ABIs which both use > SMC64 since ILP32 is really just normal AArch64 instructions, memory > space, and 64-bit registers under the hood. AArch32/ARMv7 has the same > data model as AArch64/ILP32, but AArch32/ARMv7 uses SMC32 calls since > it's 32-bit registers. This all assumes that I've read/remember the > specs correctly. I see. I will change it to uint64_t, it won't hurt anything for me. I'll probably check these in tomorrow. > > > >>> + AArch64_SMC_Return *result > >>> +) { > >>> + int rv; > >>> + > >>> + /* This only works for SMC that return 4 or fewer results. It may be extended > >>> + * up to the full 18 return results specified for SMC64, but then we would > >>> + * need to allocate a callee-saved register for *result */ > >>> + __asm__ volatile( > >>> + "smc #0\n" > >>> + "mov %0, x0\n" > >>> + "ldr x15, [sp]\n" > >>> + "cbz x15, 0f\n" > >>> + "stp x0, x1, [x15]\n" > >>> + "stp x2, x3, [x15, #16]\n" > >>> + "0:\n" > >>> + : "=r" ( rv ) > >>> + : > >>> + : "x0", "x1", "x2", "x3", "x15" > >>> + ); > >>> + > >>> + return rv; > >>> +} > >>> + > >>> diff --git a/cpukit/score/cpu/aarch64/include/rtems/score/aarch64-smc.h b/cpukit/score/cpu/aarch64/include/rtems/score/aarch64-smc.h > >>> new file mode 100644 > >>> index 0000000000..e80cc1e99b > >>> --- /dev/null > >>> +++ b/cpukit/score/cpu/aarch64/include/rtems/score/aarch64-smc.h > >>> @@ -0,0 +1,83 @@ > >>> +/* SPDX-License-Identifier: BSD-2-Clause */ > >>> + > >>> +/** > >>> + * @file > >>> + * > >>> + * @ingroup RTEMSScoreCPUAArch64 > >>> + * > >>> + * @brief This header file provides API to wrap secure monitor calls (smc). > >>> + */ > >>> + > >>> +/* > >>> + * Copyright (C) 2021 Gedare Bloom > >>> + * > >>> + * 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_SCORE_AARCH64_SMC_H > >>> +#define _RTEMS_SCORE_AARCH64_SMC_H > >>> + > >>> +#include > >>> + > >>> +#ifdef __cplusplus > >>> +extern "C" { > >>> +#endif > >>> + > >>> +/** > >>> + * @defgroup RTEMSScoreCPUAArch64SMC Secure Monitor Call Support > >>> + * > >>> + * @ingroup RTEMSScoreCPUAArch64 > >>> + * > >>> + * @brief This group provides functions to invoke secure monitor mode. > >>> + * > >>> + * @{ > >>> + */ > >>> + > >>> +/* > >>> + * @brief The return result from smc invocation. > >>> + */ > >>> +typedef struct { > >>> + uintptr_t x0; > >>> + uintptr_t x1; > >>> + uintptr_t x2; > >>> + uintptr_t x3; > >>> +} AArch64_SMC_Return; > >>> + > >>> +int _AArch64_SMC_Invoke( > >>> + uint32_t function_id, > >>> + uintptr_t arg0, > >>> + uintptr_t arg1, > >>> + uintptr_t arg2, > >>> + uintptr_t arg3, > >>> + uintptr_t arg4, > >>> + uintptr_t arg5, > >>> + uintptr_t arg6, > >>> + AArch64_SMC_Return *result > >>> +); > >>> + > >>> +/** @} */ > >>> + > >>> +#ifdef __cplusplus > >>> +} > >>> +#endif > >>> + > >>> +#endif /* _RTEMS_SCORE_AARCH64_SMC_H */ > >>> diff --git a/spec/build/cpukit/cpuaarch64.yml b/spec/build/cpukit/cpuaarch64.yml > >>> index 70d80f0b6c..1f3f07f0a2 100644 > >>> --- a/spec/build/cpukit/cpuaarch64.yml > >>> +++ b/spec/build/cpukit/cpuaarch64.yml > >>> @@ -19,6 +19,7 @@ install: > >>> - destination: ${BSP_INCLUDEDIR}/rtems/score > >>> source: > >>> - cpukit/score/cpu/aarch64/include/rtems/score/aarch64-system-registers.h > >>> + - cpukit/score/cpu/aarch64/include/rtems/score/aarch64-smc.h > >>> - cpukit/score/cpu/aarch64/include/rtems/score/cpu.h > >>> - cpukit/score/cpu/aarch64/include/rtems/score/cpuatomic.h > >>> - cpukit/score/cpu/aarch64/include/rtems/score/cpuimpl.h > >>> @@ -32,6 +33,7 @@ source: > >>> - cpukit/score/cpu/aarch64/aarch64-exception-default.c > >>> - cpukit/score/cpu/aarch64/aarch64-exception-frame-print.c > >>> - cpukit/score/cpu/aarch64/aarch64-exception-interrupt.S > >>> +- cpukit/score/cpu/aarch64/aarch64-smc.c > >>> - cpukit/score/cpu/aarch64/aarch64-thread-idle.c > >>> - cpukit/score/cpu/aarch64/cpu.c > >>> - cpukit/score/cpu/aarch64/cpu_asm.S > >> _______________________________________________ > >> devel mailing list > >> devel at rtems.org > >> http://lists.rtems.org/mailman/listinfo/devel From sebastian.huber at embedded-brains.de Tue Dec 14 07:24:33 2021 From: sebastian.huber at embedded-brains.de (Sebastian Huber) Date: Tue, 14 Dec 2021 08:24:33 +0100 Subject: New validation test suites In-Reply-To: <514bddac-9f20-5fa6-52a0-57c8f8787c82@rtems.org> References: <5c4d51cb-660d-93ec-7a59-4a98be61d4c1@embedded-brains.de> <514bddac-9f20-5fa6-52a0-57c8f8787c82@rtems.org> Message-ID: <6f5145de-94f8-1984-5590-fb05741d282b@embedded-brains.de> Hello Chris, On 13/12/2021 22:01, Chris Johns wrote: > On 14/12/21 1:53 am, Sebastian Huber wrote: >> Hello, >> >> the ESA activity to pre-qualify parts of RTEMS according to ECSS requirements is >> nearly complete. There is a short presentation available here: >> >> https://indico.esa.int/event/374/timetable/ > > Was the change in memory usage for 4.8 of 23812 bytes to 68896 explained? The foot print increase has mainly five reasons: * General GCC code generation * Chip errata workarounds done by GCC * More features used from RTEMS (for example uniprocessor synchronization done via task priorities vs. mutex synchronization) * SMP support of RTEMS * New RTEMS features such as transitive priority inheritance >> We finished the specification of the pre-qualified RTEMS feature set. The >> specification is available in an RTEMS Project repository: >> >> https://git.rtems.org/rtems-central/tree/spec > > I had a quick look. Is there a more user friendly view of this data? > > I think the term "specification" is a little bit misleading because the data > files are not easily read by a person. I understand this is the specification > data set however it is not what I am traditionally use to seeing. You can use the "./specview.py" script to get views of the specification. For example, this command displays the transition map for the rtems_signal_send() directive: ./specview.py --filter=action-table /rtems/signal/req/send .. table:: :class: longtable ===== ========== ===== ======= ======= ======== ====== ====== ============= ========= Entry Descriptor Task Set Handler ASR Nested Status Handler Recursive ===== ========== ===== ======= ======= ======== ====== ====== ============= ========= 0 0 NoObj Zero Invalid Enabled Yes InvNum NoCall No 1 0 NoObj Zero Invalid Enabled No InvNum NoCall No 2 0 NoObj Zero Invalid Disabled Yes InvNum NoCall No 3 0 NoObj Zero Invalid Disabled No InvNum NoCall No 4 0 NoObj Zero Valid Enabled Yes InvNum NoCall No 5 0 NoObj Zero Valid Enabled No InvNum NoCall No 6 0 NoObj Zero Valid Disabled Yes InvNum NoCall No 7 0 NoObj Zero Valid Disabled No InvNum NoCall No 8 1 NoObj NonZero Invalid Enabled Yes InvId NoCall No 9 1 NoObj NonZero Invalid Enabled No InvId NoCall No 10 1 NoObj NonZero Invalid Disabled Yes InvId NoCall No 11 1 NoObj NonZero Invalid Disabled No InvId NoCall No 12 1 NoObj NonZero Valid Enabled Yes InvId NoCall No 13 1 NoObj NonZero Valid Enabled No InvId NoCall No 14 1 NoObj NonZero Valid Disabled Yes InvId NoCall No 15 1 NoObj NonZero Valid Disabled No InvId NoCall No 16 0 Self Zero Invalid Enabled Yes InvNum NoCall No 17 0 Self Zero Invalid Enabled No InvNum NoCall No 18 0 Self Zero Invalid Disabled Yes InvNum NoCall No 19 0 Self Zero Invalid Disabled No InvNum NoCall No 20 0 Self Zero Valid Enabled Yes InvNum NoCall No 21 0 Self Zero Valid Enabled No InvNum NoCall No 22 0 Self Zero Valid Disabled Yes InvNum NoCall No 23 0 Self Zero Valid Disabled No InvNum NoCall No 24 2 Self NonZero Invalid Enabled Yes NotDef NoCall No 25 2 Self NonZero Invalid Enabled No NotDef NoCall No 26 2 Self NonZero Invalid Disabled Yes NotDef NoCall No 27 2 Self NonZero Invalid Disabled No NotDef NoCall No 28 6 Self NonZero Valid Enabled Yes Ok DuringSend Yes 29 4 Self NonZero Valid Enabled No Ok DuringSend No 30 3 Self NonZero Valid Disabled Yes Ok AfterEnable No 31 3 Self NonZero Valid Disabled No Ok AfterEnable No 32 0 Other Zero Invalid Enabled Yes InvNum NoCall No 33 0 Other Zero Invalid Enabled No InvNum NoCall No 34 0 Other Zero Invalid Disabled Yes InvNum NoCall No 35 0 Other Zero Invalid Disabled No InvNum NoCall No 36 0 Other Zero Valid Enabled Yes InvNum NoCall No 37 0 Other Zero Valid Enabled No InvNum NoCall No 38 0 Other Zero Valid Disabled Yes InvNum NoCall No 39 0 Other Zero Valid Disabled No InvNum NoCall No 40 2 Other NonZero Invalid Enabled Yes NotDef NoCall No 41 2 Other NonZero Invalid Enabled No NotDef NoCall No 42 2 Other NonZero Invalid Disabled Yes NotDef NoCall No 43 2 Other NonZero Invalid Disabled No NotDef NoCall No 44 7 Other NonZero Valid Enabled Yes Ok AfterDispatch Yes 45 5 Other NonZero Valid Enabled No Ok AfterDispatch No 46 3 Other NonZero Valid Disabled Yes Ok AfterEnable No 47 3 Other NonZero Valid Disabled No Ok AfterEnable No ===== ========== ===== ======= ======= ======== ====== ====== ============= ========= Here the same information in a different view, for each post-condition set the pre-condition sets are displayed: ./specview.py --filter=action-list /rtems/signal/req/send Status = Ok, Handler = DuringSend, Recursive = Yes * Task = Self, Set = NonZero, Handler = Valid, ASR = Enabled, Nested = Yes Status = Ok, Handler = DuringSend, Recursive = No * Task = Self, Set = NonZero, Handler = Valid, ASR = Enabled, Nested = No Status = Ok, Handler = AfterDispatch, Recursive = Yes * Task = Other, Set = NonZero, Handler = Valid, ASR = Enabled, Nested = Yes Status = Ok, Handler = AfterDispatch, Recursive = No * Task = Other, Set = NonZero, Handler = Valid, ASR = Enabled, Nested = No Status = Ok, Handler = AfterEnable, Recursive = No * Task = { Self, Other }, Set = NonZero, Handler = Valid, ASR = Disabled, Nested = { Yes, No } Status = InvId, Handler = NoCall, Recursive = No * Task = NoObj, Set = NonZero, Handler = { Invalid, Valid }, ASR = { Enabled, Disabled }, Nested = { Yes, No } Status = NotDef, Handler = NoCall, Recursive = No * Task = { Self, Other }, Set = NonZero, Handler = Invalid, ASR = { Enabled, Disabled }, Nested = { Yes, No } Status = InvNum, Handler = NoCall, Recursive = No * Task = { NoObj, Self, Other }, Set = Zero, Handler = { Invalid, Valid }, ASR = { Enabled, Disabled }, Nested = { Yes, No } > >> The validation tests are generated from the specification using the >> "./spec2modules.py" script and end up in the RTEMS sources of a Git submodule. I >> think the specification and the generation tool is now sufficiently stable so >> that the validation test code can be integrated in the RTEMS master branch. The >> patch set is too big for the mailing list, so you can review it here: >> >> https://git.rtems.org/sebh/rtems.git/log/?h=validation > > The link failed. Yes, viewing my personal repository no longer works. I am not sure if this is a temporary issue. This is why I added the github link. > >> https://github.com/sebhub/rtems/tree/validation > > The header in a test says the regeneration instructions are in the engineering > manual but I could not quickly find them? https://docs.rtems.org/branches/master/eng/req/howto.html#generate-content-after-changes In an earlier version of the header, we had a link which you didn't like: commit a6689fb147649a29ff5533cec8a53635e2c95ec6 Author: Sebastian Huber Date: Fri Jan 22 16:01:46 2021 +0100 Improve file header comment in generated files diff --git a/cpukit/include/rtems/rtems/types.h b/cpukit/include/rtems/rtems/types.h index 32b45113c8..a058eedea1 100644 --- a/cpukit/include/rtems/rtems/types.h +++ b/cpukit/include/rtems/rtems/types.h @@ -38,11 +38,15 @@ * worded better please post a report or patch to an RTEMS mailing list * or raise a bug report: * - * https://docs.rtems.org/branches/master/user/support/bugs.html + * https://www.rtems.org/bugs.html * - * For information on updating and regenerating please refer to: + * For information on updating and regenerating please refer to the How-To + * section in the Software Requirements Engineering chapter of the + * RTEMS Software Engineering manual. The manual is provided as a part of + * a release. For development sources please refer to the online + * documentation at: * - * https://docs.rtems.org/branches/master/eng/req/howto.html + * https://docs.rtems.org */ /* Generated from spec:/rtems/type/if/header */ > >> The patch set is organized so that general support code for the validation tests >> is added first and then there are commits for each pre-qualified Classic API >> Manager or subsystem. >> >> I did build all BSPs with the patch set. The validation tests use only >> statically allocated resources. > > Are the validation tests compatible with rtems-test? Yes. > How many test executables does this add to the testsuite? If RTEMS_SMP is disabled, then there are 19 new executables in the patch set. If RTEMS_SMP is enable, then there are 28 new executables. > > What hardware have the validation tests been run on? Any tier 1 archs? I tested with the sparc/leon3 BSPs and the arm/realview_pbx_a9_qemu. You need a full implementation of the new Interrupt Manager directives and a working Cache Manager implementation. I noticed an issue with the thread restart on aarch64/a53_lp64_qemu. On powerpc/psim there is an issue in one test case, due to: #define CPU_ALL_TASKS_ARE_FP CPU_HARDWARE_FP Another issue is that the tm27 interrupt must be independent of the clock driver interrupt. This is not the case for powerpc/psim. There is definitely some work left to cover all edge cases. Some tests are quite complicated. > > Is there anything that interprets the new test output format? It looks like lots > of great info but a little difficult to read. EDISOFT worked on a test report generator, however, it is not yet in a reviewable state. > >> Some low memory targets are not able to link all test suites. > > Are these excluded in the normal way? Yes: https://github.com/sebhub/rtems/commit/2feedb9e7805f483e35b7914b9bd7c808e31a8b4#diff-bf7b325198d4133c9e52f49d77447905ecd3c6ac5159d5cd85e7efeffa6da47e -- embedded brains GmbH Herr Sebastian HUBER Dornierstr. 4 82178 Puchheim Germany email: sebastian.huber at embedded-brains.de phone: +49-89-18 94 741 - 16 fax: +49-89-18 94 741 - 08 Registergericht: Amtsgericht M?nchen Registernummer: HRB 157899 Vertretungsberechtigte Gesch?ftsf?hrer: Peter Rasmussen, Thomas D?rfler Unsere Datenschutzerkl?rung finden Sie hier: https://embedded-brains.de/datenschutzerklaerung/ From sebastian.huber at embedded-brains.de Tue Dec 14 18:48:28 2021 From: sebastian.huber at embedded-brains.de (Sebastian Huber) Date: Tue, 14 Dec 2021 19:48:28 +0100 Subject: [PATCH] 6: Update GCC to fix PR100108 Message-ID: <20211214184828.6313-1-sebastian.huber@embedded-brains.de> This update fixes a GCC 10 regression which resulted in invalid code generation for some 32-bit powerpc targets: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100108 --- rtems/config/tools/rtems-gcc-10-newlib-head.cfg | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rtems/config/tools/rtems-gcc-10-newlib-head.cfg b/rtems/config/tools/rtems-gcc-10-newlib-head.cfg index 29b56c0..f496611 100644 --- a/rtems/config/tools/rtems-gcc-10-newlib-head.cfg +++ b/rtems/config/tools/rtems-gcc-10-newlib-head.cfg @@ -1,11 +1,11 @@ %include %{_configdir}/checks.cfg %include %{_configdir}/base.cfg -%define gcc_version 348fb9d +%define gcc_version f3e56c6 %define gcc_external 1 %define gcc_expand_name gnu-mirror-gcc-%{gcc_version} %source set gcc --rsb-file=%{gcc_expand_name}.tar.gz https://codeload.github.com/RTEMS/gnu-mirror-gcc/tar.gz/%{gcc_version} -%hash sha512 %{gcc_expand_name}.tar.gz 207eedc02ce5426e9b553d72117653a58ceb3f59b3c9413569ee31a4956ee2597e9562cff862c2be88ec0466739c6599f372760d2ad8c1340bb1d2e0ef714a89 +%hash sha512 %{gcc_expand_name}.tar.gz 720e6c878803dd576096b0614c4eaa77f4c1b929e29672adfe2be863e7d6e3b3692c971c8f3eb31561e61d478ecd0c39fa173a610d1109301818d55512981187 %patch add gcc -p1 https://devel.rtems.org/raw-attachment/ticket/4196/0001-Back-port-v5-of-__gcov_info_to_gcda-to-GCC-10.patch %hash sha512 0001-Back-port-v5-of--gcov-info-to-gcda-to-GCC-10.patch 155dcd7b7d2c13a8739b6ce8283e580ac707bad91d02a8fe8b519c483047283fd21d78a0c1f84b8a9b0975988517e7af5b488c359b7de2077b5d8733cc35002e -- 2.31.1 From sebastian.huber at embedded-brains.de Tue Dec 14 19:37:51 2021 From: sebastian.huber at embedded-brains.de (Sebastian Huber) Date: Tue, 14 Dec 2021 20:37:51 +0100 Subject: [PATCH 05/35] libfdt: fix undefined behaviour in fdt_splice_() In-Reply-To: <20211214193821.1334-1-sebastian.huber@embedded-brains.de> References: <20211214193821.1334-1-sebastian.huber@embedded-brains.de> Message-ID: <20211214193821.1334-6-sebastian.huber@embedded-brains.de> From: Jan Beulich libfdt: fix undefined behaviour in fdt_splice_() Along the lines of commit d0b3ab0a0f46 ("libfdt: Fix undefined behaviour in fdt_offset_ptr()"), fdt_splice_() similarly may not use pointer arithmetic to do overflow checks. (The left side of the checks added by d4c7c25c9ed1 ["libfdt: check for potential overrun in _fdt_splice()"] doesn't really lend itself to similar replacement though.) Signed-off-by: Jan Beulich Message-Id: Signed-off-by: David Gibson --- cpukit/dtc/libfdt/fdt_rw.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/cpukit/dtc/libfdt/fdt_rw.c b/cpukit/dtc/libfdt/fdt_rw.c index 13854253ff..524b520c84 100644 --- a/cpukit/dtc/libfdt/fdt_rw.c +++ b/cpukit/dtc/libfdt/fdt_rw.c @@ -46,7 +46,7 @@ static int fdt_rw_probe_(void *fdt) return err_; \ } -static inline int fdt_data_size_(void *fdt) +static inline unsigned int fdt_data_size_(void *fdt) { return fdt_off_dt_strings(fdt) + fdt_size_dt_strings(fdt); } @@ -54,15 +54,16 @@ static inline int fdt_data_size_(void *fdt) static int fdt_splice_(void *fdt, void *splicepoint, int oldlen, int newlen) { char *p = splicepoint; - char *end = (char *)fdt + fdt_data_size_(fdt); + unsigned int dsize = fdt_data_size_(fdt); + size_t soff = p - (char *)fdt; - if (((p + oldlen) < p) || ((p + oldlen) > end)) + if ((oldlen < 0) || (soff + oldlen < soff) || (soff + oldlen > dsize)) return -FDT_ERR_BADOFFSET; - if ((p < (char *)fdt) || ((end - oldlen + newlen) < (char *)fdt)) + if ((p < (char *)fdt) || (dsize + newlen < oldlen)) return -FDT_ERR_BADOFFSET; - if ((end - oldlen + newlen) > ((char *)fdt + fdt_totalsize(fdt))) + if (dsize - oldlen + newlen > fdt_totalsize(fdt)) return -FDT_ERR_NOSPACE; - memmove(p + newlen, p + oldlen, end - p - oldlen); + memmove(p + newlen, p + oldlen, ((char *)fdt + dsize) - (p + oldlen)); return 0; } -- 2.31.1 From sebastian.huber at embedded-brains.de Tue Dec 14 19:37:46 2021 From: sebastian.huber at embedded-brains.de (Sebastian Huber) Date: Tue, 14 Dec 2021 20:37:46 +0100 Subject: [PATCH 00/35] Update libfdt Message-ID: <20211214193821.1334-1-sebastian.huber@embedded-brains.de> This patch set updates libfdt (which is a part of the dtc repository) to the latest version. Andre Przywara (14): libfdt: fdt_offset_ptr(): Fix comparison warnings libfdt: fdt_mem_rsv(): Fix comparison warnings libfdt: fdt_grab_space_(): Fix comparison warning libfdt: fdt_splice_(): Fix comparison warning libfdt: fdt_resize(): Fix comparison warning libfdt: fdt_node_offset_by_phandle(): Fix comparison warning libfdt: fdt_add_string_(): Fix comparison warning libfdt: fdt_move(): Fix comparison warnings libfdt: fdt_create_with_flags(): Fix comparison warning libfdt: libfdt_wip: Fix comparison warning libfdt: fdt_get_string(): Fix sequential write comparison warnings libfdt: fdt_strerror(): Fix comparison warning libfdt: Fix kernel-doc comments fdtget: Fix signedness comparisons warnings David Gibson (3): libfdt: Tweak description of assume-aligned load helpers libfdt: Fix a possible "unchecked return value" warning Fix CID 1461557 Elvira Khabirova (1): libfdt: fix an incorrect integer promotion Frank Mehnert (1): libfdt: fix fdt_check_node_offset_ w/ VALID_INPUT Georg Kotheimer (1): libfdt: Add ALIGNMENT error string Jan Beulich (1): libfdt: fix undefined behaviour in fdt_splice_() Justin Covell (1): Set last_comp_version correctly in new dtb and fix potential version issues in fdt_open_into Patrick Oppenlander (2): libfdt: trivial typo fix libfdt: add extern "C" for C++ Rob Herring (1): libfdt: Add FDT alignment check to fdt_check_header() Sebastian Huber (1): dtc: Update VERSION Simon Glass (6): libfdt: Fix a few typos libfdt: Improve comments in some of the assumptions libfdt: Add support for disabling internal checks libfdt: Use VALID_INPUT for FDT_ERR_BADSTATE checks libfdt: Correct condition for reordering blocks libfdt: fdt_get_string(): Fix comparison warnings Tom Rini (2): libfdt: Check for 8-byte address alignment in fdt_ro_probe_() libfdt: Internally perform potentially unaligned loads Vikram Garhwal (1): libfdt: overlay: make overlay_get_target() public cpukit/dtc/VERSION | 6 +- cpukit/dtc/libfdt/fdt.c | 41 ++++++-- cpukit/dtc/libfdt/fdt_addresses.c | 2 +- cpukit/dtc/libfdt/fdt_ro.c | 44 ++++---- cpukit/dtc/libfdt/fdt_rw.c | 37 ++++--- cpukit/dtc/libfdt/fdt_strerror.c | 5 +- cpukit/dtc/libfdt/fdt_sw.c | 38 ++++--- cpukit/dtc/libfdt/fdt_wip.c | 2 +- cpukit/dtc/libfdt/libfdt_internal.h | 49 +++++++-- cpukit/include/libfdt.h | 157 ++++++++++++++++++++-------- 10 files changed, 264 insertions(+), 117 deletions(-) -- 2.31.1 From sebastian.huber at embedded-brains.de Tue Dec 14 19:37:47 2021 From: sebastian.huber at embedded-brains.de (Sebastian Huber) Date: Tue, 14 Dec 2021 20:37:47 +0100 Subject: [PATCH 01/35] libfdt: Fix a few typos In-Reply-To: <20211214193821.1334-1-sebastian.huber@embedded-brains.de> References: <20211214193821.1334-1-sebastian.huber@embedded-brains.de> Message-ID: <20211214193821.1334-2-sebastian.huber@embedded-brains.de> From: Simon Glass Fix 'saftey' and 'additional' typos noticed in the assumption series. Reword the ASSUME_NO_ROLLBACK slightly to improve clarity. Signed-off-by: Simon Glass Suggested-by: David Gibson Message-Id: <20200302190255.51426-1-sjg at chromium.org> Signed-off-by: David Gibson --- cpukit/dtc/libfdt/libfdt_internal.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cpukit/dtc/libfdt/libfdt_internal.h b/cpukit/dtc/libfdt/libfdt_internal.h index e9913cdfa0..3201678cf6 100644 --- a/cpukit/dtc/libfdt/libfdt_internal.h +++ b/cpukit/dtc/libfdt/libfdt_internal.h @@ -58,7 +58,7 @@ static inline struct fdt_reserve_entry *fdt_mem_rsv_w_(void *fdt, int n) /* * Defines assumptions which can be enabled. Each of these can be enabled - * individually. For maximum saftey, don't enable any assumptions! + * individually. For maximum safety, don't enable any assumptions! * * For minimal code size and no safety, use ASSUME_PERFECT at your own risk. * You should have another method of validating the device tree, such as a @@ -121,8 +121,8 @@ enum { ASSUME_LATEST = 1 << 2, /* - * This assume that it is OK for a failed additional to the device tree - * due to lack of space or some other problem can skip any rollback + * This assumes that it is OK for a failed addition to the device tree, + * due to lack of space or some other problem, to skip any rollback * steps (such as dropping the property name from the string table). * This is safe to enable in most circumstances, even though it may * leave the tree in a sub-optimal state. -- 2.31.1 From sebastian.huber at embedded-brains.de Tue Dec 14 19:37:50 2021 From: sebastian.huber at embedded-brains.de (Sebastian Huber) Date: Tue, 14 Dec 2021 20:37:50 +0100 Subject: [PATCH 04/35] libfdt: Use VALID_INPUT for FDT_ERR_BADSTATE checks In-Reply-To: <20211214193821.1334-1-sebastian.huber@embedded-brains.de> References: <20211214193821.1334-1-sebastian.huber@embedded-brains.de> Message-ID: <20211214193821.1334-5-sebastian.huber@embedded-brains.de> From: Simon Glass This error indicates a logic bug in the code calling libfdt, so VALID_DTB is not really the right check. Update it to use VALID_INPUT instead. Signed-off-by: Simon Glass Suggested-by: David Gibson Message-Id: <20200302190255.51426-4-sjg at chromium.org> Signed-off-by: David Gibson --- cpukit/dtc/libfdt/fdt.c | 2 +- cpukit/dtc/libfdt/fdt_sw.c | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/cpukit/dtc/libfdt/fdt.c b/cpukit/dtc/libfdt/fdt.c index 4419204a86..c28fcc1157 100644 --- a/cpukit/dtc/libfdt/fdt.c +++ b/cpukit/dtc/libfdt/fdt.c @@ -33,7 +33,7 @@ int32_t fdt_ro_probe_(const void *fdt) } } else if (fdt_magic(fdt) == FDT_SW_MAGIC) { /* Unfinished sequential-write blob */ - if (fdt_size_dt_struct(fdt) == 0) + if (!can_assume(VALID_INPUT) && fdt_size_dt_struct(fdt) == 0) return -FDT_ERR_BADSTATE; } else { return -FDT_ERR_BADMAGIC; diff --git a/cpukit/dtc/libfdt/fdt_sw.c b/cpukit/dtc/libfdt/fdt_sw.c index 352193c0a7..26759d5dfb 100644 --- a/cpukit/dtc/libfdt/fdt_sw.c +++ b/cpukit/dtc/libfdt/fdt_sw.c @@ -12,7 +12,7 @@ static int fdt_sw_probe_(void *fdt) { - if (!can_assume(VALID_DTB)) { + if (!can_assume(VALID_INPUT)) { if (fdt_magic(fdt) == FDT_MAGIC) return -FDT_ERR_BADSTATE; else if (fdt_magic(fdt) != FDT_SW_MAGIC) @@ -41,7 +41,7 @@ static int fdt_sw_probe_memrsv_(void *fdt) if (err) return err; - if (!can_assume(VALID_DTB) && fdt_off_dt_strings(fdt) != 0) + if (!can_assume(VALID_INPUT) && fdt_off_dt_strings(fdt) != 0) return -FDT_ERR_BADSTATE; return 0; } @@ -67,7 +67,8 @@ static int fdt_sw_probe_struct_(void *fdt) if (err) return err; - if (fdt_off_dt_strings(fdt) != fdt_totalsize(fdt)) + if (!can_assume(VALID_INPUT) && + fdt_off_dt_strings(fdt) != fdt_totalsize(fdt)) return -FDT_ERR_BADSTATE; return 0; } -- 2.31.1 From sebastian.huber at embedded-brains.de Tue Dec 14 19:37:48 2021 From: sebastian.huber at embedded-brains.de (Sebastian Huber) Date: Tue, 14 Dec 2021 20:37:48 +0100 Subject: [PATCH 02/35] libfdt: Improve comments in some of the assumptions In-Reply-To: <20211214193821.1334-1-sebastian.huber@embedded-brains.de> References: <20211214193821.1334-1-sebastian.huber@embedded-brains.de> Message-ID: <20211214193821.1334-3-sebastian.huber@embedded-brains.de> From: Simon Glass Add a little more detail in a few of these comments. Signed-off-by: Simon Glass Suggested-by: David Gibson Message-Id: <20200302190255.51426-2-sjg at chromium.org> Signed-off-by: David Gibson --- cpukit/dtc/libfdt/libfdt_internal.h | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/cpukit/dtc/libfdt/libfdt_internal.h b/cpukit/dtc/libfdt/libfdt_internal.h index 3201678cf6..7999f6a2d4 100644 --- a/cpukit/dtc/libfdt/libfdt_internal.h +++ b/cpukit/dtc/libfdt/libfdt_internal.h @@ -91,7 +91,9 @@ enum { * * With this assumption enabled, normal device trees produced by libfdt * and the compiler should be handled safely. Malicious device trees and - * complete garbage may cause libfdt to behave badly or crash. + * complete garbage may cause libfdt to behave badly or crash. Truncated + * device trees (e.g. those only partially loaded) can also cause + * problems. * * Note: Only checks that relate exclusively to the device tree itself * (not the parameters passed to libfdt) are disabled by this @@ -130,8 +132,15 @@ enum { ASSUME_NO_ROLLBACK = 1 << 3, /* - * This assumes that the device tree components appear in the correct - * order. As such it disables a check in fdt_open_into() and removes the + * This assumes that the device tree components appear in a 'convenient' + * order, i.e. the memory reservation block first, then the structure + * block and finally the string block. + * + * This order is not specified by the device-tree specification, + * but is expected by libfdt. The device-tree compiler always created + * device trees with this order. + * + * This assumption disables a check in fdt_open_into() and removes the * ability to fix the problem there. This is safe if you know that the * device tree is correctly ordered. See fdt_blocks_misordered_(). */ -- 2.31.1 From sebastian.huber at embedded-brains.de Tue Dec 14 19:37:49 2021 From: sebastian.huber at embedded-brains.de (Sebastian Huber) Date: Tue, 14 Dec 2021 20:37:49 +0100 Subject: [PATCH 03/35] libfdt: Add support for disabling internal checks In-Reply-To: <20211214193821.1334-1-sebastian.huber@embedded-brains.de> References: <20211214193821.1334-1-sebastian.huber@embedded-brains.de> Message-ID: <20211214193821.1334-4-sebastian.huber@embedded-brains.de> From: Simon Glass If libfdt returns -FDT_ERR_INTERNAL that generally indicates a bug in the library. Add a new assumption for these cases since it should be save to disable these checks regardless of the input. Signed-off-by: Simon Glass Suggested-by: David Gibson Message-Id: <20200302190255.51426-3-sjg at chromium.org> Signed-off-by: David Gibson --- cpukit/dtc/libfdt/fdt_ro.c | 4 ++-- cpukit/dtc/libfdt/libfdt_internal.h | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/cpukit/dtc/libfdt/fdt_ro.c b/cpukit/dtc/libfdt/fdt_ro.c index 194550344a..e03570a56e 100644 --- a/cpukit/dtc/libfdt/fdt_ro.c +++ b/cpukit/dtc/libfdt/fdt_ro.c @@ -402,7 +402,7 @@ static const struct fdt_property *fdt_get_property_namelen_(const void *fdt, const struct fdt_property *prop; prop = fdt_get_property_by_offset_(fdt, offset, lenp); - if (!can_assume(VALID_DTB) && !prop) { + if (!can_assume(LIBFDT_FLAWLESS) && !prop) { offset = -FDT_ERR_INTERNAL; break; } @@ -634,7 +634,7 @@ int fdt_node_depth(const void *fdt, int nodeoffset) err = fdt_supernode_atdepth_offset(fdt, nodeoffset, 0, &nodedepth); if (err) - return (can_assume(VALID_INPUT) || err < 0) ? err : + return (can_assume(LIBFDT_FLAWLESS) || err < 0) ? err : -FDT_ERR_INTERNAL; return nodedepth; } diff --git a/cpukit/dtc/libfdt/libfdt_internal.h b/cpukit/dtc/libfdt/libfdt_internal.h index 7999f6a2d4..d4e0bd49c0 100644 --- a/cpukit/dtc/libfdt/libfdt_internal.h +++ b/cpukit/dtc/libfdt/libfdt_internal.h @@ -145,6 +145,15 @@ enum { * device tree is correctly ordered. See fdt_blocks_misordered_(). */ ASSUME_LIBFDT_ORDER = 1 << 4, + + /* + * This assumes that libfdt itself does not have any internal bugs. It + * drops certain checks that should never be needed unless libfdt has an + * undiscovered bug. + * + * This can generally be considered safe to enable. + */ + ASSUME_LIBFDT_FLAWLESS = 1 << 5, }; /** -- 2.31.1 From sebastian.huber at embedded-brains.de Tue Dec 14 19:37:58 2021 From: sebastian.huber at embedded-brains.de (Sebastian Huber) Date: Tue, 14 Dec 2021 20:37:58 +0100 Subject: [PATCH 12/35] libfdt: fdt_grab_space_(): Fix comparison warning In-Reply-To: <20211214193821.1334-1-sebastian.huber@embedded-brains.de> References: <20211214193821.1334-1-sebastian.huber@embedded-brains.de> Message-ID: <20211214193821.1334-13-sebastian.huber@embedded-brains.de> From: Andre Przywara With -Wsign-compare, compilers warn about a mismatching signedness in a comparison in fdt_grab_space_(). All the involved values cannot be negative, so let's switch the types of the local variables to unsigned to make the compiler happy. Signed-off-by: Andre Przywara Message-Id: <20200921165303.9115-4-andre.przywara at arm.com> Signed-off-by: David Gibson --- cpukit/dtc/libfdt/fdt_sw.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cpukit/dtc/libfdt/fdt_sw.c b/cpukit/dtc/libfdt/fdt_sw.c index 94ce4bb91a..d10a720f94 100644 --- a/cpukit/dtc/libfdt/fdt_sw.c +++ b/cpukit/dtc/libfdt/fdt_sw.c @@ -93,8 +93,8 @@ static inline uint32_t sw_flags(void *fdt) static void *fdt_grab_space_(void *fdt, size_t len) { - int offset = fdt_size_dt_struct(fdt); - int spaceleft; + unsigned int offset = fdt_size_dt_struct(fdt); + unsigned int spaceleft; spaceleft = fdt_totalsize(fdt) - fdt_off_dt_struct(fdt) - fdt_size_dt_strings(fdt); -- 2.31.1 From sebastian.huber at embedded-brains.de Tue Dec 14 19:38:10 2021 From: sebastian.huber at embedded-brains.de (Sebastian Huber) Date: Tue, 14 Dec 2021 20:38:10 +0100 Subject: [PATCH 24/35] libfdt: Check for 8-byte address alignment in fdt_ro_probe_() In-Reply-To: <20211214193821.1334-1-sebastian.huber@embedded-brains.de> References: <20211214193821.1334-1-sebastian.huber@embedded-brains.de> Message-ID: <20211214193821.1334-25-sebastian.huber@embedded-brains.de> From: Tom Rini The device tree must be loaded in to memory at an 8-byte aligned address. Add a check for this condition in fdt_ro_probe_() and a new error code to return if we are not. Signed-off-by: Tom Rini Message-Id: <20201104130605.28874-1-trini at konsulko.com> Signed-off-by: David Gibson --- cpukit/dtc/libfdt/fdt.c | 4 ++++ cpukit/include/libfdt.h | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/cpukit/dtc/libfdt/fdt.c b/cpukit/dtc/libfdt/fdt.c index 6cf2fa03b0..3e893073da 100644 --- a/cpukit/dtc/libfdt/fdt.c +++ b/cpukit/dtc/libfdt/fdt.c @@ -22,6 +22,10 @@ int32_t fdt_ro_probe_(const void *fdt) if (can_assume(VALID_DTB)) return totalsize; + /* The device tree must be at an 8-byte aligned address */ + if ((uintptr_t)fdt & 7) + return -FDT_ERR_ALIGNMENT; + if (fdt_magic(fdt) == FDT_MAGIC) { /* Complete tree */ if (!can_assume(LATEST)) { diff --git a/cpukit/include/libfdt.h b/cpukit/include/libfdt.h index 5979832305..89adee3cd7 100644 --- a/cpukit/include/libfdt.h +++ b/cpukit/include/libfdt.h @@ -101,7 +101,11 @@ extern "C" { /* FDT_ERR_BADFLAGS: The function was passed a flags field that * contains invalid flags or an invalid combination of flags. */ -#define FDT_ERR_MAX 18 +#define FDT_ERR_ALIGNMENT 19 + /* FDT_ERR_ALIGNMENT: The device tree base address is not 8-byte + * aligned. */ + +#define FDT_ERR_MAX 19 /* constants */ #define FDT_MAX_PHANDLE 0xfffffffe -- 2.31.1 From sebastian.huber at embedded-brains.de Tue Dec 14 19:38:17 2021 From: sebastian.huber at embedded-brains.de (Sebastian Huber) Date: Tue, 14 Dec 2021 20:38:17 +0100 Subject: [PATCH 31/35] fdtget: Fix signedness comparisons warnings In-Reply-To: <20211214193821.1334-1-sebastian.huber@embedded-brains.de> References: <20211214193821.1334-1-sebastian.huber@embedded-brains.de> Message-ID: <20211214193821.1334-32-sebastian.huber@embedded-brains.de> From: Andre Przywara With -Wsign-compare, compilers warn about a mismatching signedness in the different legs of the conditional operator, in fdtget.c. In the questionable expression, we are constructing a 16-bit value out of two unsigned 8-bit values, however are relying on the compiler's automatic expansion of the uint8_t to a larger type, to survive the left shift. This larger type happens to be an "int", so this part of the expression becomes signed. Fix this by explicitly blowing up the uint8_t to a larger *unsigned* type, before doing the left shift. And while we are at it, convert the hardly readable conditional operator usage into a sane switch/case expression. This fixes "make fdtget", when compiled with -Wsign-compare. Signed-off-by: Andre Przywara Message-Id: <20210618172030.9684-3-andre.przywara at arm.com> Signed-off-by: David Gibson --- cpukit/include/libfdt.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cpukit/include/libfdt.h b/cpukit/include/libfdt.h index 73467f75c5..7f117e8815 100644 --- a/cpukit/include/libfdt.h +++ b/cpukit/include/libfdt.h @@ -131,6 +131,13 @@ uint32_t fdt_next_tag(const void *fdt, int offset, int *nextoffset); * to work even with unaligned pointers on platforms (such as ARMv5) that don't * like unaligned loads and stores. */ +static inline uint16_t fdt16_ld(const fdt16_t *p) +{ + const uint8_t *bp = (const uint8_t *)p; + + return ((uint16_t)bp[0] << 8) | bp[1]; +} + static inline uint32_t fdt32_ld(const fdt32_t *p) { const uint8_t *bp = (const uint8_t *)p; -- 2.31.1 From sebastian.huber at embedded-brains.de Tue Dec 14 19:37:52 2021 From: sebastian.huber at embedded-brains.de (Sebastian Huber) Date: Tue, 14 Dec 2021 20:37:52 +0100 Subject: [PATCH 06/35] libfdt: Correct condition for reordering blocks In-Reply-To: <20211214193821.1334-1-sebastian.huber@embedded-brains.de> References: <20211214193821.1334-1-sebastian.huber@embedded-brains.de> Message-ID: <20211214193821.1334-7-sebastian.huber@embedded-brains.de> From: Simon Glass This condition uses bitwise OR but should be logical OR. Fix it. Signed-off-by: Simon Glass Reported-by: kernel test robot Message-Id: <20200615160033.87328-1-sjg at chromium.org> Signed-off-by: David Gibson --- cpukit/dtc/libfdt/fdt_rw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpukit/dtc/libfdt/fdt_rw.c b/cpukit/dtc/libfdt/fdt_rw.c index 524b520c84..93e4a2b563 100644 --- a/cpukit/dtc/libfdt/fdt_rw.c +++ b/cpukit/dtc/libfdt/fdt_rw.c @@ -436,7 +436,7 @@ int fdt_open_into(const void *fdt, void *buf, int bufsize) return struct_size; } - if (can_assume(LIBFDT_ORDER) | + if (can_assume(LIBFDT_ORDER) || !fdt_blocks_misordered_(fdt, mem_rsv_size, struct_size)) { /* no further work necessary */ err = fdt_move(fdt, buf, bufsize); -- 2.31.1 From sebastian.huber at embedded-brains.de Tue Dec 14 19:37:53 2021 From: sebastian.huber at embedded-brains.de (Sebastian Huber) Date: Tue, 14 Dec 2021 20:37:53 +0100 Subject: [PATCH 07/35] libfdt: trivial typo fix In-Reply-To: <20211214193821.1334-1-sebastian.huber@embedded-brains.de> References: <20211214193821.1334-1-sebastian.huber@embedded-brains.de> Message-ID: <20211214193821.1334-8-sebastian.huber@embedded-brains.de> From: Patrick Oppenlander Signed-off-by: Patrick Oppenlander Message-Id: <20200618042117.131731-1-patrick.oppenlander at gmail.com> Signed-off-by: David Gibson --- cpukit/dtc/libfdt/fdt_sw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpukit/dtc/libfdt/fdt_sw.c b/cpukit/dtc/libfdt/fdt_sw.c index 26759d5dfb..94ce4bb91a 100644 --- a/cpukit/dtc/libfdt/fdt_sw.c +++ b/cpukit/dtc/libfdt/fdt_sw.c @@ -32,7 +32,7 @@ static int fdt_sw_probe_(void *fdt) /* 'memrsv' state: Initial state after fdt_create() * * Allowed functions: - * fdt_add_reservmap_entry() + * fdt_add_reservemap_entry() * fdt_finish_reservemap() [moves to 'struct' state] */ static int fdt_sw_probe_memrsv_(void *fdt) -- 2.31.1 From sebastian.huber at embedded-brains.de Tue Dec 14 19:37:54 2021 From: sebastian.huber at embedded-brains.de (Sebastian Huber) Date: Tue, 14 Dec 2021 20:37:54 +0100 Subject: [PATCH 08/35] libfdt: add extern "C" for C++ In-Reply-To: <20211214193821.1334-1-sebastian.huber@embedded-brains.de> References: <20211214193821.1334-1-sebastian.huber@embedded-brains.de> Message-ID: <20211214193821.1334-9-sebastian.huber@embedded-brains.de> From: Patrick Oppenlander Signed-off-by: Patrick Oppenlander Message-Id: <20200616011217.15253-1-patrick.oppenlander at gmail.com> Signed-off-by: David Gibson --- cpukit/include/libfdt.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cpukit/include/libfdt.h b/cpukit/include/libfdt.h index 48f375c9c1..544d3efff5 100644 --- a/cpukit/include/libfdt.h +++ b/cpukit/include/libfdt.h @@ -9,6 +9,10 @@ #include #include +#ifdef __cplusplus +extern "C" { +#endif + #define FDT_FIRST_SUPPORTED_VERSION 0x02 #define FDT_LAST_SUPPORTED_VERSION 0x11 @@ -2069,4 +2073,8 @@ int fdt_overlay_apply(void *fdt, void *fdto); const char *fdt_strerror(int errval); +#ifdef __cplusplus +} +#endif + #endif /* LIBFDT_H */ -- 2.31.1 From sebastian.huber at embedded-brains.de Tue Dec 14 19:37:55 2021 From: sebastian.huber at embedded-brains.de (Sebastian Huber) Date: Tue, 14 Dec 2021 20:37:55 +0100 Subject: [PATCH 09/35] libfdt: fix fdt_check_node_offset_ w/ VALID_INPUT In-Reply-To: <20211214193821.1334-1-sebastian.huber@embedded-brains.de> References: <20211214193821.1334-1-sebastian.huber@embedded-brains.de> Message-ID: <20211214193821.1334-10-sebastian.huber@embedded-brains.de> From: Frank Mehnert fdt_check_node_offset_() checks for a valid offset but also changes the offset by calling fdt_next_tag(). Hence, do not skip this function if ASSUME_VALID_INPUT is set but only omit the initial offset check in that case. As this function works very similar to fdt_check_prop_offset_(), do the offset check there as well depending on ASSUME_VALID_INPUT. Message-Id: <1913141.TlUzK5foHS at noys4> Signed-off-by: David Gibson --- cpukit/dtc/libfdt/fdt.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/cpukit/dtc/libfdt/fdt.c b/cpukit/dtc/libfdt/fdt.c index c28fcc1157..37b7b93556 100644 --- a/cpukit/dtc/libfdt/fdt.c +++ b/cpukit/dtc/libfdt/fdt.c @@ -206,10 +206,11 @@ uint32_t fdt_next_tag(const void *fdt, int startoffset, int *nextoffset) int fdt_check_node_offset_(const void *fdt, int offset) { - if (can_assume(VALID_INPUT)) - return offset; - if ((offset < 0) || (offset % FDT_TAGSIZE) - || (fdt_next_tag(fdt, offset, &offset) != FDT_BEGIN_NODE)) + if (!can_assume(VALID_INPUT) + && ((offset < 0) || (offset % FDT_TAGSIZE))) + return -FDT_ERR_BADOFFSET; + + if (fdt_next_tag(fdt, offset, &offset) != FDT_BEGIN_NODE) return -FDT_ERR_BADOFFSET; return offset; @@ -217,8 +218,11 @@ int fdt_check_node_offset_(const void *fdt, int offset) int fdt_check_prop_offset_(const void *fdt, int offset) { - if ((offset < 0) || (offset % FDT_TAGSIZE) - || (fdt_next_tag(fdt, offset, &offset) != FDT_PROP)) + if (!can_assume(VALID_INPUT) + && ((offset < 0) || (offset % FDT_TAGSIZE))) + return -FDT_ERR_BADOFFSET; + + if (fdt_next_tag(fdt, offset, &offset) != FDT_PROP) return -FDT_ERR_BADOFFSET; return offset; -- 2.31.1 From sebastian.huber at embedded-brains.de Tue Dec 14 19:37:56 2021 From: sebastian.huber at embedded-brains.de (Sebastian Huber) Date: Tue, 14 Dec 2021 20:37:56 +0100 Subject: [PATCH 10/35] libfdt: fdt_offset_ptr(): Fix comparison warnings In-Reply-To: <20211214193821.1334-1-sebastian.huber@embedded-brains.de> References: <20211214193821.1334-1-sebastian.huber@embedded-brains.de> Message-ID: <20211214193821.1334-11-sebastian.huber@embedded-brains.de> From: Andre Przywara With -Wsign-compare, compilers warn about mismatching signedness in comparisons in fdt_offset_ptr(). This mostly stems from "offset" being passed in as a signed integer, even though the function would not really tolerate negative values. Short of changing the prototype, check that offset is not negative, and use an unsigned type internally. Signed-off-by: Andre Przywara Message-Id: <20200921165303.9115-2-andre.przywara at arm.com> Signed-off-by: David Gibson --- cpukit/dtc/libfdt/fdt.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/cpukit/dtc/libfdt/fdt.c b/cpukit/dtc/libfdt/fdt.c index 37b7b93556..04e1e062f2 100644 --- a/cpukit/dtc/libfdt/fdt.c +++ b/cpukit/dtc/libfdt/fdt.c @@ -134,16 +134,20 @@ int fdt_check_header(const void *fdt) const void *fdt_offset_ptr(const void *fdt, int offset, unsigned int len) { - unsigned absoffset = offset + fdt_off_dt_struct(fdt); + unsigned int uoffset = offset; + unsigned int absoffset = offset + fdt_off_dt_struct(fdt); + + if (offset < 0) + return NULL; if (!can_assume(VALID_INPUT)) - if ((absoffset < offset) + if ((absoffset < uoffset) || ((absoffset + len) < absoffset) || (absoffset + len) > fdt_totalsize(fdt)) return NULL; if (can_assume(LATEST) || fdt_version(fdt) >= 0x11) - if (((offset + len) < offset) + if (((uoffset + len) < uoffset) || ((offset + len) > fdt_size_dt_struct(fdt))) return NULL; -- 2.31.1 From sebastian.huber at embedded-brains.de Tue Dec 14 19:37:57 2021 From: sebastian.huber at embedded-brains.de (Sebastian Huber) Date: Tue, 14 Dec 2021 20:37:57 +0100 Subject: [PATCH 11/35] libfdt: fdt_mem_rsv(): Fix comparison warnings In-Reply-To: <20211214193821.1334-1-sebastian.huber@embedded-brains.de> References: <20211214193821.1334-1-sebastian.huber@embedded-brains.de> Message-ID: <20211214193821.1334-12-sebastian.huber@embedded-brains.de> From: Andre Przywara With -Wsign-compare, compilers warn about a mismatching signedness in comparisons in fdt_mem_rsv(). Since all involved values must be positive, change the used types to be unsigned. Signed-off-by: Andre Przywara Message-Id: <20200921165303.9115-3-andre.przywara at arm.com> Signed-off-by: David Gibson --- cpukit/dtc/libfdt/fdt_ro.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cpukit/dtc/libfdt/fdt_ro.c b/cpukit/dtc/libfdt/fdt_ro.c index e03570a56e..3c8d143db2 100644 --- a/cpukit/dtc/libfdt/fdt_ro.c +++ b/cpukit/dtc/libfdt/fdt_ro.c @@ -157,8 +157,8 @@ int fdt_generate_phandle(const void *fdt, uint32_t *phandle) static const struct fdt_reserve_entry *fdt_mem_rsv(const void *fdt, int n) { - int offset = n * sizeof(struct fdt_reserve_entry); - int absoffset = fdt_off_mem_rsvmap(fdt) + offset; + unsigned int offset = n * sizeof(struct fdt_reserve_entry); + unsigned int absoffset = fdt_off_mem_rsvmap(fdt) + offset; if (!can_assume(VALID_INPUT)) { if (absoffset < fdt_off_mem_rsvmap(fdt)) -- 2.31.1 From sebastian.huber at embedded-brains.de Tue Dec 14 19:37:59 2021 From: sebastian.huber at embedded-brains.de (Sebastian Huber) Date: Tue, 14 Dec 2021 20:37:59 +0100 Subject: [PATCH 13/35] libfdt: fdt_get_string(): Fix comparison warnings In-Reply-To: <20211214193821.1334-1-sebastian.huber@embedded-brains.de> References: <20211214193821.1334-1-sebastian.huber@embedded-brains.de> Message-ID: <20211214193821.1334-14-sebastian.huber@embedded-brains.de> From: Simon Glass With -Wsign-compare, compilers warn about a mismatching signedness in comparisons in fdt_get_string(). In the first two cases, we have just established that the signed values are not negative, so it's safe to cast the values to an unsigned type. Signed-off-by: Simon Glass Signed-off-by: Andre Przywara Message-Id: <20200921165303.9115-7-andre.przywara at arm.com> Signed-off-by: David Gibson --- cpukit/dtc/libfdt/fdt_ro.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cpukit/dtc/libfdt/fdt_ro.c b/cpukit/dtc/libfdt/fdt_ro.c index 3c8d143db2..ddb5a2db28 100644 --- a/cpukit/dtc/libfdt/fdt_ro.c +++ b/cpukit/dtc/libfdt/fdt_ro.c @@ -53,7 +53,7 @@ const char *fdt_get_string(const void *fdt, int stroffset, int *lenp) err = -FDT_ERR_BADOFFSET; absoffset = stroffset + fdt_off_dt_strings(fdt); - if (absoffset >= totalsize) + if (absoffset >= (unsigned)totalsize) goto fail; len = totalsize - absoffset; @@ -61,7 +61,7 @@ const char *fdt_get_string(const void *fdt, int stroffset, int *lenp) if (stroffset < 0) goto fail; if (can_assume(LATEST) || fdt_version(fdt) >= 17) { - if (stroffset >= fdt_size_dt_strings(fdt)) + if ((unsigned)stroffset >= fdt_size_dt_strings(fdt)) goto fail; if ((fdt_size_dt_strings(fdt) - stroffset) < len) len = fdt_size_dt_strings(fdt) - stroffset; -- 2.31.1 From sebastian.huber at embedded-brains.de Tue Dec 14 19:38:00 2021 From: sebastian.huber at embedded-brains.de (Sebastian Huber) Date: Tue, 14 Dec 2021 20:38:00 +0100 Subject: [PATCH 14/35] libfdt: fdt_splice_(): Fix comparison warning In-Reply-To: <20211214193821.1334-1-sebastian.huber@embedded-brains.de> References: <20211214193821.1334-1-sebastian.huber@embedded-brains.de> Message-ID: <20211214193821.1334-15-sebastian.huber@embedded-brains.de> From: Andre Przywara With -Wsign-compare, compilers warn about a mismatching signedness in a comparison in fdt_splice_(). Since we just established that oldlen is not negative, we can safely cast it to an unsigned type. Signed-off-by: Andre Przywara Message-Id: <20200921165303.9115-8-andre.przywara at arm.com> Signed-off-by: David Gibson --- cpukit/dtc/libfdt/fdt_rw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpukit/dtc/libfdt/fdt_rw.c b/cpukit/dtc/libfdt/fdt_rw.c index 93e4a2b563..68887b969a 100644 --- a/cpukit/dtc/libfdt/fdt_rw.c +++ b/cpukit/dtc/libfdt/fdt_rw.c @@ -59,7 +59,7 @@ static int fdt_splice_(void *fdt, void *splicepoint, int oldlen, int newlen) if ((oldlen < 0) || (soff + oldlen < soff) || (soff + oldlen > dsize)) return -FDT_ERR_BADOFFSET; - if ((p < (char *)fdt) || (dsize + newlen < oldlen)) + if ((p < (char *)fdt) || (dsize + newlen < (unsigned)oldlen)) return -FDT_ERR_BADOFFSET; if (dsize - oldlen + newlen > fdt_totalsize(fdt)) return -FDT_ERR_NOSPACE; -- 2.31.1 From sebastian.huber at embedded-brains.de Tue Dec 14 19:38:01 2021 From: sebastian.huber at embedded-brains.de (Sebastian Huber) Date: Tue, 14 Dec 2021 20:38:01 +0100 Subject: [PATCH 15/35] libfdt: fdt_resize(): Fix comparison warning In-Reply-To: <20211214193821.1334-1-sebastian.huber@embedded-brains.de> References: <20211214193821.1334-1-sebastian.huber@embedded-brains.de> Message-ID: <20211214193821.1334-16-sebastian.huber@embedded-brains.de> From: Andre Przywara With -Wsign-compare, compilers warn about a mismatching signedness in a comparison in fdt_resize(). A negative buffer size will surely do us no good, so let's rule this case out first. In the actual comparison we then know that a cast to an unsigned type is safe. Signed-off-by: Andre Przywara Message-Id: <20200921165303.9115-10-andre.przywara at arm.com> Signed-off-by: David Gibson --- cpukit/dtc/libfdt/fdt_sw.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cpukit/dtc/libfdt/fdt_sw.c b/cpukit/dtc/libfdt/fdt_sw.c index d10a720f94..8de18fd4f9 100644 --- a/cpukit/dtc/libfdt/fdt_sw.c +++ b/cpukit/dtc/libfdt/fdt_sw.c @@ -152,6 +152,9 @@ int fdt_resize(void *fdt, void *buf, int bufsize) FDT_SW_PROBE(fdt); + if (bufsize < 0) + return -FDT_ERR_NOSPACE; + headsize = fdt_off_dt_struct(fdt) + fdt_size_dt_struct(fdt); tailsize = fdt_size_dt_strings(fdt); @@ -159,7 +162,7 @@ int fdt_resize(void *fdt, void *buf, int bufsize) headsize + tailsize > fdt_totalsize(fdt)) return -FDT_ERR_INTERNAL; - if ((headsize + tailsize) > bufsize) + if ((headsize + tailsize) > (unsigned)bufsize) return -FDT_ERR_NOSPACE; oldtail = (char *)fdt + fdt_totalsize(fdt) - tailsize; -- 2.31.1 From sebastian.huber at embedded-brains.de Tue Dec 14 19:38:04 2021 From: sebastian.huber at embedded-brains.de (Sebastian Huber) Date: Tue, 14 Dec 2021 20:38:04 +0100 Subject: [PATCH 18/35] libfdt: fdt_move(): Fix comparison warnings In-Reply-To: <20211214193821.1334-1-sebastian.huber@embedded-brains.de> References: <20211214193821.1334-1-sebastian.huber@embedded-brains.de> Message-ID: <20211214193821.1334-19-sebastian.huber@embedded-brains.de> From: Andre Przywara With -Wsign-compare, compilers warn about a mismatching signedness in comparisons in fdt_move(). This stems from "bufsize" being passed in as a signed integer, even though we would expect a buffer size to be positive. Short of changing the prototype, check that bufsize is not negative, and cast it to an unsigned type in the comparison. Signed-off-by: Andre Przywara Message-Id: <20201001164630.4980-3-andre.przywara at arm.com> Signed-off-by: David Gibson --- cpukit/dtc/libfdt/fdt.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cpukit/dtc/libfdt/fdt.c b/cpukit/dtc/libfdt/fdt.c index 04e1e062f2..6cf2fa03b0 100644 --- a/cpukit/dtc/libfdt/fdt.c +++ b/cpukit/dtc/libfdt/fdt.c @@ -314,9 +314,12 @@ const char *fdt_find_string_(const char *strtab, int tabsize, const char *s) int fdt_move(const void *fdt, void *buf, int bufsize) { + if (!can_assume(VALID_INPUT) && bufsize < 0) + return -FDT_ERR_NOSPACE; + FDT_RO_PROBE(fdt); - if (fdt_totalsize(fdt) > bufsize) + if (fdt_totalsize(fdt) > (unsigned int)bufsize) return -FDT_ERR_NOSPACE; memmove(buf, fdt, fdt_totalsize(fdt)); -- 2.31.1 From sebastian.huber at embedded-brains.de Tue Dec 14 19:38:06 2021 From: sebastian.huber at embedded-brains.de (Sebastian Huber) Date: Tue, 14 Dec 2021 20:38:06 +0100 Subject: [PATCH 20/35] libfdt: libfdt_wip: Fix comparison warning In-Reply-To: <20211214193821.1334-1-sebastian.huber@embedded-brains.de> References: <20211214193821.1334-1-sebastian.huber@embedded-brains.de> Message-ID: <20211214193821.1334-21-sebastian.huber@embedded-brains.de> From: Andre Przywara With -Wsign-compare, compilers warn about a mismatching signedness in a comparison in fdt_setprop_inplace_namelen_partial(). fdt_getprop_namelen() will only return negative error values in "proplen" if the return value is NULL. So we can rely on "proplen" being positive in our case and can safely cast it to an unsigned type. Signed-off-by: Andre Przywara Message-Id: <20201001164630.4980-5-andre.przywara at arm.com> Signed-off-by: David Gibson --- cpukit/dtc/libfdt/fdt_wip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpukit/dtc/libfdt/fdt_wip.c b/cpukit/dtc/libfdt/fdt_wip.c index f64139e0b3..c2d7566a67 100644 --- a/cpukit/dtc/libfdt/fdt_wip.c +++ b/cpukit/dtc/libfdt/fdt_wip.c @@ -23,7 +23,7 @@ int fdt_setprop_inplace_namelen_partial(void *fdt, int nodeoffset, if (!propval) return proplen; - if (proplen < (len + idx)) + if ((unsigned)proplen < (len + idx)) return -FDT_ERR_NOSPACE; memcpy((char *)propval + idx, val, len); -- 2.31.1 From sebastian.huber at embedded-brains.de Tue Dec 14 19:38:07 2021 From: sebastian.huber at embedded-brains.de (Sebastian Huber) Date: Tue, 14 Dec 2021 20:38:07 +0100 Subject: [PATCH 21/35] libfdt: fdt_get_string(): Fix sequential write comparison warnings In-Reply-To: <20211214193821.1334-1-sebastian.huber@embedded-brains.de> References: <20211214193821.1334-1-sebastian.huber@embedded-brains.de> Message-ID: <20211214193821.1334-22-sebastian.huber@embedded-brains.de> From: Andre Przywara With -Wsign-compare, compilers warn about a mismatching signedness in comparisons in fdt_get_string(). Introduce a new usigned variable, which holds the actual (negated) stroffset value, so we avoid negating all the other variables and have proper types everywhere. Signed-off-by: Andre Przywara Message-Id: <20201001164630.4980-6-andre.przywara at arm.com> Signed-off-by: David Gibson --- cpukit/dtc/libfdt/fdt_ro.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cpukit/dtc/libfdt/fdt_ro.c b/cpukit/dtc/libfdt/fdt_ro.c index e19218422f..91cc6fefe3 100644 --- a/cpukit/dtc/libfdt/fdt_ro.c +++ b/cpukit/dtc/libfdt/fdt_ro.c @@ -67,11 +67,13 @@ const char *fdt_get_string(const void *fdt, int stroffset, int *lenp) len = fdt_size_dt_strings(fdt) - stroffset; } } else if (fdt_magic(fdt) == FDT_SW_MAGIC) { - if ((stroffset >= 0) - || (stroffset < -fdt_size_dt_strings(fdt))) + unsigned int sw_stroffset = -stroffset; + + if ((stroffset >= 0) || + (sw_stroffset > fdt_size_dt_strings(fdt))) goto fail; - if ((-stroffset) < len) - len = -stroffset; + if (sw_stroffset < len) + len = sw_stroffset; } else { err = -FDT_ERR_INTERNAL; goto fail; -- 2.31.1 From sebastian.huber at embedded-brains.de Tue Dec 14 19:38:11 2021 From: sebastian.huber at embedded-brains.de (Sebastian Huber) Date: Tue, 14 Dec 2021 20:38:11 +0100 Subject: [PATCH 25/35] libfdt: Internally perform potentially unaligned loads In-Reply-To: <20211214193821.1334-1-sebastian.huber@embedded-brains.de> References: <20211214193821.1334-1-sebastian.huber@embedded-brains.de> Message-ID: <20211214193821.1334-26-sebastian.huber@embedded-brains.de> From: Tom Rini Commits 6dcb8ba4 "libfdt: Add helpers for accessing unaligned words" introduced changes to support unaligned reads for ARM platforms and 11738cf01f15 "libfdt: Don't use memcpy to handle unaligned reads on ARM" improved the performance of these helpers. On further discussion, while there are potential cases where we could be used on platforms that do not fixup unaligned reads for us, making this choice the default is very expensive in terms of binary size and access time. To address this, introduce and use new fdt{32,64}_ld_ functions that call fdt{32,64}_to_cpu() as was done prior to the above mentioned commits. Leave the existing load functions as unaligned-safe and include comments in both cases. Reviewed-by: Rob Herring Signed-off-by: Tom Rini Message-Id: <20201211022736.31657-1-trini at konsulko.com> Tested-by: John Paul Adrian Glaubitz Signed-off-by: David Gibson --- cpukit/dtc/libfdt/fdt_ro.c | 20 ++++++++++---------- cpukit/dtc/libfdt/libfdt_internal.h | 19 +++++++++++++++++++ cpukit/include/libfdt.h | 8 +++----- 3 files changed, 32 insertions(+), 15 deletions(-) diff --git a/cpukit/dtc/libfdt/fdt_ro.c b/cpukit/dtc/libfdt/fdt_ro.c index 91cc6fefe3..17584da257 100644 --- a/cpukit/dtc/libfdt/fdt_ro.c +++ b/cpukit/dtc/libfdt/fdt_ro.c @@ -181,8 +181,8 @@ int fdt_get_mem_rsv(const void *fdt, int n, uint64_t *address, uint64_t *size) if (!can_assume(VALID_INPUT) && !re) return -FDT_ERR_BADOFFSET; - *address = fdt64_ld(&re->address); - *size = fdt64_ld(&re->size); + *address = fdt64_ld_(&re->address); + *size = fdt64_ld_(&re->size); return 0; } @@ -192,7 +192,7 @@ int fdt_num_mem_rsv(const void *fdt) const struct fdt_reserve_entry *re; for (i = 0; (re = fdt_mem_rsv(fdt, i)) != NULL; i++) { - if (fdt64_ld(&re->size) == 0) + if (fdt64_ld_(&re->size) == 0) return i; } return -FDT_ERR_TRUNCATED; @@ -370,7 +370,7 @@ static const struct fdt_property *fdt_get_property_by_offset_(const void *fdt, prop = fdt_offset_ptr_(fdt, offset); if (lenp) - *lenp = fdt32_ld(&prop->len); + *lenp = fdt32_ld_(&prop->len); return prop; } @@ -408,7 +408,7 @@ static const struct fdt_property *fdt_get_property_namelen_(const void *fdt, offset = -FDT_ERR_INTERNAL; break; } - if (fdt_string_eq_(fdt, fdt32_ld(&prop->nameoff), + if (fdt_string_eq_(fdt, fdt32_ld_(&prop->nameoff), name, namelen)) { if (poffset) *poffset = offset; @@ -461,7 +461,7 @@ const void *fdt_getprop_namelen(const void *fdt, int nodeoffset, /* Handle realignment */ if (!can_assume(LATEST) && fdt_version(fdt) < 0x10 && - (poffset + sizeof(*prop)) % 8 && fdt32_ld(&prop->len) >= 8) + (poffset + sizeof(*prop)) % 8 && fdt32_ld_(&prop->len) >= 8) return prop->data + 4; return prop->data; } @@ -479,7 +479,7 @@ const void *fdt_getprop_by_offset(const void *fdt, int offset, int namelen; if (!can_assume(VALID_INPUT)) { - name = fdt_get_string(fdt, fdt32_ld(&prop->nameoff), + name = fdt_get_string(fdt, fdt32_ld_(&prop->nameoff), &namelen); if (!name) { if (lenp) @@ -488,13 +488,13 @@ const void *fdt_getprop_by_offset(const void *fdt, int offset, } *namep = name; } else { - *namep = fdt_string(fdt, fdt32_ld(&prop->nameoff)); + *namep = fdt_string(fdt, fdt32_ld_(&prop->nameoff)); } } /* Handle realignment */ if (!can_assume(LATEST) && fdt_version(fdt) < 0x10 && - (offset + sizeof(*prop)) % 8 && fdt32_ld(&prop->len) >= 8) + (offset + sizeof(*prop)) % 8 && fdt32_ld_(&prop->len) >= 8) return prop->data + 4; return prop->data; } @@ -519,7 +519,7 @@ uint32_t fdt_get_phandle(const void *fdt, int nodeoffset) return 0; } - return fdt32_ld(php); + return fdt32_ld_(php); } const char *fdt_get_alias_namelen(const void *fdt, diff --git a/cpukit/dtc/libfdt/libfdt_internal.h b/cpukit/dtc/libfdt/libfdt_internal.h index d4e0bd49c0..8b580aa507 100644 --- a/cpukit/dtc/libfdt/libfdt_internal.h +++ b/cpukit/dtc/libfdt/libfdt_internal.h @@ -46,6 +46,25 @@ static inline struct fdt_reserve_entry *fdt_mem_rsv_w_(void *fdt, int n) return (void *)(uintptr_t)fdt_mem_rsv_(fdt, n); } +/* + * Internal helpers to access tructural elements of the device tree blob + * (rather than for exaple reading integers from within property values). We + * assume that we are either given a naturally aligned address for the platform + * or if we are not, we are on a platform where unaligned memory reads will be + * handled in a graceful manner. If this is not the case there are _unaligned + * versions of these functions that follow and can be used. + * + */ +static inline uint32_t fdt32_ld_(const fdt32_t *p) +{ + return fdt32_to_cpu(*p); +} + +static inline uint64_t fdt64_ld_(const fdt64_t *p) +{ + return fdt64_to_cpu(*p); +} + #define FDT_SW_MAGIC (~FDT_MAGIC) /**********************************************************************/ diff --git a/cpukit/include/libfdt.h b/cpukit/include/libfdt.h index 89adee3cd7..2bc16a8b3f 100644 --- a/cpukit/include/libfdt.h +++ b/cpukit/include/libfdt.h @@ -126,12 +126,10 @@ static inline void *fdt_offset_ptr_w(void *fdt, int offset, int checklen) uint32_t fdt_next_tag(const void *fdt, int offset, int *nextoffset); /* - * Alignment helpers: - * These helpers access words from a device tree blob. They're - * built to work even with unaligned pointers on platforms (ike - * ARM) that don't like unaligned loads and stores + * External helpers to access words from a device tree blob. They're built + * to work even with unaligned pointers on platforms (such as ARMv5) that don't + * like unaligned loads and stores. */ - static inline uint32_t fdt32_ld(const fdt32_t *p) { const uint8_t *bp = (const uint8_t *)p; -- 2.31.1 From sebastian.huber at embedded-brains.de Tue Dec 14 19:38:09 2021 From: sebastian.huber at embedded-brains.de (Sebastian Huber) Date: Tue, 14 Dec 2021 20:38:09 +0100 Subject: [PATCH 23/35] libfdt: Fix kernel-doc comments In-Reply-To: <20211214193821.1334-1-sebastian.huber@embedded-brains.de> References: <20211214193821.1334-1-sebastian.huber@embedded-brains.de> Message-ID: <20211214193821.1334-24-sebastian.huber@embedded-brains.de> From: Andre Przywara The API documentation in libfdt.h seems to follow the Linux kernel's kernel-doc format[1]. Running "scripts/kernel-doc -v -none" on the file reports some problems, mostly missing return values and missing parameter descriptions. Fix those up by providing the missing bits, and fixing the other small issues reported by the script. Signed-off-by: Andre Przywara [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/doc-guide/kernel-doc.rst Message-Id: <20201012165331.25016-1-andre.przywara at arm.com> Signed-off-by: David Gibson --- cpukit/include/libfdt.h | 111 +++++++++++++++++++++++++++------------- 1 file changed, 75 insertions(+), 36 deletions(-) diff --git a/cpukit/include/libfdt.h b/cpukit/include/libfdt.h index 544d3efff5..5979832305 100644 --- a/cpukit/include/libfdt.h +++ b/cpukit/include/libfdt.h @@ -184,23 +184,23 @@ int fdt_next_node(const void *fdt, int offset, int *depth); /** * fdt_first_subnode() - get offset of first direct subnode - * * @fdt: FDT blob * @offset: Offset of node to check - * @return offset of first subnode, or -FDT_ERR_NOTFOUND if there is none + * + * Return: offset of first subnode, or -FDT_ERR_NOTFOUND if there is none */ int fdt_first_subnode(const void *fdt, int offset); /** * fdt_next_subnode() - get offset of next direct subnode + * @fdt: FDT blob + * @offset: Offset of previous subnode * * After first calling fdt_first_subnode(), call this function repeatedly to * get direct subnodes of a parent node. * - * @fdt: FDT blob - * @offset: Offset of previous subnode - * @return offset of next subnode, or -FDT_ERR_NOTFOUND if there are no more - * subnodes + * Return: offset of next subnode, or -FDT_ERR_NOTFOUND if there are no more + * subnodes */ int fdt_next_subnode(const void *fdt, int offset); @@ -225,7 +225,6 @@ int fdt_next_subnode(const void *fdt, int offset); * Note that this is implemented as a macro and @node is used as * iterator in the loop. The parent variable be constant or even a * literal. - * */ #define fdt_for_each_subnode(node, fdt, parent) \ for (node = fdt_first_subnode(fdt, parent); \ @@ -269,17 +268,21 @@ fdt_set_hdr_(size_dt_struct); /** * fdt_header_size - return the size of the tree's header * @fdt: pointer to a flattened device tree + * + * Return: size of DTB header in bytes */ size_t fdt_header_size(const void *fdt); /** - * fdt_header_size_ - internal function which takes a version number + * fdt_header_size_ - internal function to get header size from a version number + * @version: devicetree version number + * + * Return: size of DTB header in bytes */ size_t fdt_header_size_(uint32_t version); /** * fdt_check_header - sanity check a device tree header - * @fdt: pointer to data which might be a flattened device tree * * fdt_check_header() checks that the given buffer contains what @@ -404,8 +407,7 @@ static inline uint32_t fdt_get_max_phandle(const void *fdt) * highest phandle value in the device tree blob) will be returned in the * @phandle parameter. * - * Returns: - * 0 on success or a negative error-code on failure + * Return: 0 on success or a negative error-code on failure */ int fdt_generate_phandle(const void *fdt, uint32_t *phandle); @@ -425,9 +427,11 @@ int fdt_num_mem_rsv(const void *fdt); /** * fdt_get_mem_rsv - retrieve one memory reserve map entry * @fdt: pointer to the device tree blob - * @address, @size: pointers to 64-bit variables + * @n: index of reserve map entry + * @address: pointer to 64-bit variable to hold the start address + * @size: pointer to 64-bit variable to hold the size of the entry * - * On success, *address and *size will contain the address and size of + * On success, @address and @size will contain the address and size of * the n-th reserve map entry from the device tree blob, in * native-endian format. * @@ -450,6 +454,8 @@ int fdt_get_mem_rsv(const void *fdt, int n, uint64_t *address, uint64_t *size); * namelen characters of name for matching the subnode name. This is * useful for finding subnodes based on a portion of a larger string, * such as a full path. + * + * Return: offset of the subnode or -FDT_ERR_NOTFOUND if name not found. */ #ifndef SWIG /* Not available in Python */ int fdt_subnode_offset_namelen(const void *fdt, int parentoffset, @@ -489,6 +495,8 @@ int fdt_subnode_offset(const void *fdt, int parentoffset, const char *name); * * Identical to fdt_path_offset(), but only consider the first namelen * characters of path as the path name. + * + * Return: offset of the node or negative libfdt error value otherwise */ #ifndef SWIG /* Not available in Python */ int fdt_path_offset_namelen(const void *fdt, const char *path, int namelen); @@ -588,9 +596,9 @@ int fdt_next_property_offset(const void *fdt, int offset); /** * fdt_for_each_property_offset - iterate over all properties of a node * - * @property_offset: property offset (int, lvalue) - * @fdt: FDT blob (const void *) - * @node: node offset (int) + * @property: property offset (int, lvalue) + * @fdt: FDT blob (const void *) + * @node: node offset (int) * * This is actually a wrapper around a for loop and would be used like so: * @@ -653,6 +661,9 @@ const struct fdt_property *fdt_get_property_by_offset(const void *fdt, * * Identical to fdt_get_property(), but only examine the first namelen * characters of name for matching the property name. + * + * Return: pointer to the structure representing the property, or NULL + * if not found */ #ifndef SWIG /* Not available in Python */ const struct fdt_property *fdt_get_property_namelen(const void *fdt, @@ -745,6 +756,8 @@ const void *fdt_getprop_by_offset(const void *fdt, int offset, * * Identical to fdt_getprop(), but only examine the first namelen * characters of name for matching the property name. + * + * Return: pointer to the property's value or NULL on error */ #ifndef SWIG /* Not available in Python */ const void *fdt_getprop_namelen(const void *fdt, int nodeoffset, @@ -766,10 +779,10 @@ static inline void *fdt_getprop_namelen_w(void *fdt, int nodeoffset, * @lenp: pointer to an integer variable (will be overwritten) or NULL * * fdt_getprop() retrieves a pointer to the value of the property - * named 'name' of the node at offset nodeoffset (this will be a + * named @name of the node at offset @nodeoffset (this will be a * pointer to within the device blob itself, not a copy of the value). - * If lenp is non-NULL, the length of the property value is also - * returned, in the integer pointed to by lenp. + * If @lenp is non-NULL, the length of the property value is also + * returned, in the integer pointed to by @lenp. * * returns: * pointer to the property's value @@ -814,8 +827,11 @@ uint32_t fdt_get_phandle(const void *fdt, int nodeoffset); * @name: name of the alias th look up * @namelen: number of characters of name to consider * - * Identical to fdt_get_alias(), but only examine the first namelen - * characters of name for matching the alias name. + * Identical to fdt_get_alias(), but only examine the first @namelen + * characters of @name for matching the alias name. + * + * Return: a pointer to the expansion of the alias named @name, if it exists, + * NULL otherwise */ #ifndef SWIG /* Not available in Python */ const char *fdt_get_alias_namelen(const void *fdt, @@ -828,7 +844,7 @@ const char *fdt_get_alias_namelen(const void *fdt, * @name: name of the alias th look up * * fdt_get_alias() retrieves the value of a given alias. That is, the - * value of the property named 'name' in the node /aliases. + * value of the property named @name in the node /aliases. * * returns: * a pointer to the expansion of the alias named 'name', if it exists @@ -1004,14 +1020,13 @@ int fdt_node_offset_by_prop_value(const void *fdt, int startoffset, int fdt_node_offset_by_phandle(const void *fdt, uint32_t phandle); /** - * fdt_node_check_compatible: check a node's compatible property + * fdt_node_check_compatible - check a node's compatible property * @fdt: pointer to the device tree blob * @nodeoffset: offset of a tree node * @compatible: string to match against * - * * fdt_node_check_compatible() returns 0 if the given node contains a - * 'compatible' property with the given string as one of its elements, + * @compatible property with the given string as one of its elements, * it returns non-zero otherwise, or on error. * * returns: @@ -1075,7 +1090,7 @@ int fdt_node_offset_by_compatible(const void *fdt, int startoffset, * one or more strings, each terminated by \0, as is found in a device tree * "compatible" property. * - * @return: 1 if the string is found in the list, 0 not found, or invalid list + * Return: 1 if the string is found in the list, 0 not found, or invalid list */ int fdt_stringlist_contains(const char *strlist, int listlen, const char *str); @@ -1084,7 +1099,8 @@ int fdt_stringlist_contains(const char *strlist, int listlen, const char *str); * @fdt: pointer to the device tree blob * @nodeoffset: offset of a tree node * @property: name of the property containing the string list - * @return: + * + * Return: * the number of strings in the given property * -FDT_ERR_BADVALUE if the property value is not NUL-terminated * -FDT_ERR_NOTFOUND if the property does not exist @@ -1104,7 +1120,7 @@ int fdt_stringlist_count(const void *fdt, int nodeoffset, const char *property); * small-valued cell properties, such as #address-cells, when searching for * the empty string. * - * @return: + * return: * the index of the string in the list of strings * -FDT_ERR_BADVALUE if the property value is not NUL-terminated * -FDT_ERR_NOTFOUND if the property does not exist or does not contain @@ -1128,7 +1144,7 @@ int fdt_stringlist_search(const void *fdt, int nodeoffset, const char *property, * If non-NULL, the length of the string (on success) or a negative error-code * (on failure) will be stored in the integer pointer to by lenp. * - * @return: + * Return: * A pointer to the string at the given index in the string list or NULL on * failure. On success the length of the string will be stored in the memory * location pointed to by the lenp parameter, if non-NULL. On failure one of @@ -1217,6 +1233,8 @@ int fdt_size_cells(const void *fdt, int nodeoffset); * starting from the given index, and using only the first characters * of the name. It is useful when you want to manipulate only one value of * an array and you have a string that doesn't end with \0. + * + * Return: 0 on success, negative libfdt error value otherwise */ #ifndef SWIG /* Not available in Python */ int fdt_setprop_inplace_namelen_partial(void *fdt, int nodeoffset, @@ -1330,8 +1348,13 @@ static inline int fdt_setprop_inplace_u64(void *fdt, int nodeoffset, /** * fdt_setprop_inplace_cell - change the value of a single-cell property + * @fdt: pointer to the device tree blob + * @nodeoffset: offset of the node containing the property + * @name: name of the property to change the value of + * @val: new value of the 32-bit cell * * This is an alternative name for fdt_setprop_inplace_u32() + * Return: 0 on success, negative libfdt error number otherwise. */ static inline int fdt_setprop_inplace_cell(void *fdt, int nodeoffset, const char *name, uint32_t val) @@ -1403,7 +1426,7 @@ int fdt_nop_node(void *fdt, int nodeoffset); /** * fdt_create_with_flags - begin creation of a new fdt - * @fdt: pointer to memory allocated where fdt will be created + * @buf: pointer to memory allocated where fdt will be created * @bufsize: size of the memory space at fdt * @flags: a valid combination of FDT_CREATE_FLAG_ flags, or 0. * @@ -1421,7 +1444,7 @@ int fdt_create_with_flags(void *buf, int bufsize, uint32_t flags); /** * fdt_create - begin creation of a new fdt - * @fdt: pointer to memory allocated where fdt will be created + * @buf: pointer to memory allocated where fdt will be created * @bufsize: size of the memory space at fdt * * fdt_create() is equivalent to fdt_create_with_flags() with flags=0. @@ -1486,7 +1509,8 @@ int fdt_pack(void *fdt); /** * fdt_add_mem_rsv - add one memory reserve map entry * @fdt: pointer to the device tree blob - * @address, @size: 64-bit values (native endian) + * @address: 64-bit start address of the reserve map entry + * @size: 64-bit size of the reserved region * * Adds a reserve map entry to the given blob reserving a region at * address address of length size. @@ -1691,8 +1715,14 @@ static inline int fdt_setprop_u64(void *fdt, int nodeoffset, const char *name, /** * fdt_setprop_cell - set a property to a single cell value + * @fdt: pointer to the device tree blob + * @nodeoffset: offset of the node whose property to change + * @name: name of the property to change + * @val: 32-bit integer value for the property (native endian) * * This is an alternative name for fdt_setprop_u32() + * + * Return: 0 on success, negative libfdt error value otherwise. */ static inline int fdt_setprop_cell(void *fdt, int nodeoffset, const char *name, uint32_t val) @@ -1863,8 +1893,14 @@ static inline int fdt_appendprop_u64(void *fdt, int nodeoffset, /** * fdt_appendprop_cell - append a single cell value to a property + * @fdt: pointer to the device tree blob + * @nodeoffset: offset of the node whose property to change + * @name: name of the property to change + * @val: 32-bit integer value to append to the property (native endian) * * This is an alternative name for fdt_appendprop_u32() + * + * Return: 0 on success, negative libfdt error value otherwise. */ static inline int fdt_appendprop_cell(void *fdt, int nodeoffset, const char *name, uint32_t val) @@ -1967,13 +2003,16 @@ int fdt_delprop(void *fdt, int nodeoffset, const char *name); * fdt_add_subnode_namelen - creates a new node based on substring * @fdt: pointer to the device tree blob * @parentoffset: structure block offset of a node - * @name: name of the subnode to locate + * @name: name of the subnode to create * @namelen: number of characters of name to consider * - * Identical to fdt_add_subnode(), but use only the first namelen - * characters of name as the name of the new node. This is useful for + * Identical to fdt_add_subnode(), but use only the first @namelen + * characters of @name as the name of the new node. This is useful for * creating subnodes based on a portion of a larger string, such as a * full path. + * + * Return: structure block offset of the created subnode (>=0), + * negative libfdt error value otherwise */ #ifndef SWIG /* Not available in Python */ int fdt_add_subnode_namelen(void *fdt, int parentoffset, @@ -1992,7 +2031,7 @@ int fdt_add_subnode_namelen(void *fdt, int parentoffset, * * This function will insert data into the blob, and will therefore * change the offsets of some existing nodes. - + * * returns: * structure block offset of the created nodeequested subnode (>=0), on * success -- 2.31.1 From sebastian.huber at embedded-brains.de Tue Dec 14 19:38:15 2021 From: sebastian.huber at embedded-brains.de (Sebastian Huber) Date: Tue, 14 Dec 2021 20:38:15 +0100 Subject: [PATCH 29/35] libfdt: Add FDT alignment check to fdt_check_header() In-Reply-To: <20211214193821.1334-1-sebastian.huber@embedded-brains.de> References: <20211214193821.1334-1-sebastian.huber@embedded-brains.de> Message-ID: <20211214193821.1334-30-sebastian.huber@embedded-brains.de> From: Rob Herring Only checking the FDT alignment in fdt_ro_probe_() means that fdt_check_header() can pass, but then subsequent API calls fail on alignment checks. Let's add an alignment check to fdt_check_header() so alignment errors are found up front. Cc: Tom Rini Cc: Frank Rowand Signed-off-by: Rob Herring Message-Id: <20210406190712.2118098-1-robh at kernel.org> Signed-off-by: David Gibson --- cpukit/dtc/libfdt/fdt.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cpukit/dtc/libfdt/fdt.c b/cpukit/dtc/libfdt/fdt.c index 3e893073da..9fe7cf4b74 100644 --- a/cpukit/dtc/libfdt/fdt.c +++ b/cpukit/dtc/libfdt/fdt.c @@ -90,6 +90,10 @@ int fdt_check_header(const void *fdt) { size_t hdrsize; + /* The device tree must be at an 8-byte aligned address */ + if ((uintptr_t)fdt & 7) + return -FDT_ERR_ALIGNMENT; + if (fdt_magic(fdt) != FDT_MAGIC) return -FDT_ERR_BADMAGIC; if (!can_assume(LATEST)) { -- 2.31.1 From sebastian.huber at embedded-brains.de Tue Dec 14 19:38:18 2021 From: sebastian.huber at embedded-brains.de (Sebastian Huber) Date: Tue, 14 Dec 2021 20:38:18 +0100 Subject: [PATCH 32/35] libfdt: Add ALIGNMENT error string In-Reply-To: <20211214193821.1334-1-sebastian.huber@embedded-brains.de> References: <20211214193821.1334-1-sebastian.huber@embedded-brains.de> Message-ID: <20211214193821.1334-33-sebastian.huber@embedded-brains.de> From: Georg Kotheimer The ALIGNMENT error was missing a string, leading to being returned. Signed-off-by: Georg Kotheimer Signed-off-by: David Gibson --- cpukit/dtc/libfdt/fdt_strerror.c | 1 + 1 file changed, 1 insertion(+) diff --git a/cpukit/dtc/libfdt/fdt_strerror.c b/cpukit/dtc/libfdt/fdt_strerror.c index b4356931b0..d852b77e81 100644 --- a/cpukit/dtc/libfdt/fdt_strerror.c +++ b/cpukit/dtc/libfdt/fdt_strerror.c @@ -39,6 +39,7 @@ static struct fdt_errtabent fdt_errtable[] = { FDT_ERRTABENT(FDT_ERR_BADOVERLAY), FDT_ERRTABENT(FDT_ERR_NOPHANDLES), FDT_ERRTABENT(FDT_ERR_BADFLAGS), + FDT_ERRTABENT(FDT_ERR_ALIGNMENT), }; #define FDT_ERRTABSIZE ((int)(sizeof(fdt_errtable) / sizeof(fdt_errtable[0]))) -- 2.31.1 From sebastian.huber at embedded-brains.de Tue Dec 14 19:38:20 2021 From: sebastian.huber at embedded-brains.de (Sebastian Huber) Date: Tue, 14 Dec 2021 20:38:20 +0100 Subject: [PATCH 34/35] libfdt: overlay: make overlay_get_target() public In-Reply-To: <20211214193821.1334-1-sebastian.huber@embedded-brains.de> References: <20211214193821.1334-1-sebastian.huber@embedded-brains.de> Message-ID: <20211214193821.1334-35-sebastian.huber@embedded-brains.de> From: Vikram Garhwal This is done to get the target path for the overlay nodes which is very useful in many cases. For example, Xen hypervisor needs it when applying overlays because Xen needs to do further processing of the overlay nodes, e.g. mapping of resources(IRQs and IOMMUs) to other VMs, creation of SMMU pagetables, etc. Signed-off-by: Vikram Garhwal Message-Id: <1637204036-382159-2-git-send-email-fnu.vikram at xilinx.com> Signed-off-by: David Gibson --- cpukit/include/libfdt.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/cpukit/include/libfdt.h b/cpukit/include/libfdt.h index 7f117e8815..a7f432c80c 100644 --- a/cpukit/include/libfdt.h +++ b/cpukit/include/libfdt.h @@ -2116,6 +2116,24 @@ int fdt_del_node(void *fdt, int nodeoffset); */ int fdt_overlay_apply(void *fdt, void *fdto); +/** + * fdt_overlay_target_offset - retrieves the offset of a fragment's target + * @fdt: Base device tree blob + * @fdto: Device tree overlay blob + * @fragment_offset: node offset of the fragment in the overlay + * @pathp: pointer which receives the path of the target (or NULL) + * + * fdt_overlay_target_offset() retrieves the target offset in the base + * device tree of a fragment, no matter how the actual targeting is + * done (through a phandle or a path) + * + * returns: + * the targeted node offset in the base device tree + * Negative error code on error + */ +int fdt_overlay_target_offset(const void *fdt, const void *fdto, + int fragment_offset, char const **pathp); + /**********************************************************************/ /* Debugging / informational functions */ /**********************************************************************/ -- 2.31.1 From sebastian.huber at embedded-brains.de Tue Dec 14 19:38:02 2021 From: sebastian.huber at embedded-brains.de (Sebastian Huber) Date: Tue, 14 Dec 2021 20:38:02 +0100 Subject: [PATCH 16/35] libfdt: fdt_node_offset_by_phandle(): Fix comparison warning In-Reply-To: <20211214193821.1334-1-sebastian.huber@embedded-brains.de> References: <20211214193821.1334-1-sebastian.huber@embedded-brains.de> Message-ID: <20211214193821.1334-17-sebastian.huber@embedded-brains.de> From: Andre Przywara With -Wsign-compare, compilers warn about a mismatching signedness in a comparison in fdt_node_offset_by_phandle(). Uses a better suited bitwise NOT operator to denote the special value of -1, which automatically results in an unsigned type. Signed-off-by: Andre Przywara Message-Id: <20200921165303.9115-14-andre.przywara at arm.com> Signed-off-by: David Gibson --- cpukit/dtc/libfdt/fdt_ro.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpukit/dtc/libfdt/fdt_ro.c b/cpukit/dtc/libfdt/fdt_ro.c index ddb5a2db28..e19218422f 100644 --- a/cpukit/dtc/libfdt/fdt_ro.c +++ b/cpukit/dtc/libfdt/fdt_ro.c @@ -680,7 +680,7 @@ int fdt_node_offset_by_phandle(const void *fdt, uint32_t phandle) { int offset; - if ((phandle == 0) || (phandle == -1)) + if ((phandle == 0) || (phandle == ~0U)) return -FDT_ERR_BADPHANDLE; FDT_RO_PROBE(fdt); -- 2.31.1 From sebastian.huber at embedded-brains.de Tue Dec 14 19:38:03 2021 From: sebastian.huber at embedded-brains.de (Sebastian Huber) Date: Tue, 14 Dec 2021 20:38:03 +0100 Subject: [PATCH 17/35] libfdt: fdt_add_string_(): Fix comparison warning In-Reply-To: <20211214193821.1334-1-sebastian.huber@embedded-brains.de> References: <20211214193821.1334-1-sebastian.huber@embedded-brains.de> Message-ID: <20211214193821.1334-18-sebastian.huber@embedded-brains.de> From: Andre Przywara With -Wsign-compare, compilers warn about a mismatching signedness in a comparison in fdt_add_string_(). Make all variables unsigned, and express the negative offset trick via subtractions in the code. Signed-off-by: Andre Przywara Message-Id: <20201001164630.4980-2-andre.przywara at arm.com> Signed-off-by: David Gibson --- cpukit/dtc/libfdt/fdt_sw.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/cpukit/dtc/libfdt/fdt_sw.c b/cpukit/dtc/libfdt/fdt_sw.c index 8de18fd4f9..354f46674b 100644 --- a/cpukit/dtc/libfdt/fdt_sw.c +++ b/cpukit/dtc/libfdt/fdt_sw.c @@ -250,18 +250,18 @@ int fdt_end_node(void *fdt) static int fdt_add_string_(void *fdt, const char *s) { char *strtab = (char *)fdt + fdt_totalsize(fdt); - int strtabsize = fdt_size_dt_strings(fdt); - int len = strlen(s) + 1; - int struct_top, offset; + unsigned int strtabsize = fdt_size_dt_strings(fdt); + unsigned int len = strlen(s) + 1; + unsigned int struct_top, offset; - offset = -strtabsize - len; + offset = strtabsize + len; struct_top = fdt_off_dt_struct(fdt) + fdt_size_dt_struct(fdt); - if (fdt_totalsize(fdt) + offset < struct_top) + if (fdt_totalsize(fdt) - offset < struct_top) return 0; /* no more room :( */ - memcpy(strtab + offset, s, len); + memcpy(strtab - offset, s, len); fdt_set_size_dt_strings(fdt, strtabsize + len); - return offset; + return -offset; } /* Must only be used to roll back in case of error */ -- 2.31.1 From sebastian.huber at embedded-brains.de Tue Dec 14 19:38:05 2021 From: sebastian.huber at embedded-brains.de (Sebastian Huber) Date: Tue, 14 Dec 2021 20:38:05 +0100 Subject: [PATCH 19/35] libfdt: fdt_create_with_flags(): Fix comparison warning In-Reply-To: <20211214193821.1334-1-sebastian.huber@embedded-brains.de> References: <20211214193821.1334-1-sebastian.huber@embedded-brains.de> Message-ID: <20211214193821.1334-20-sebastian.huber@embedded-brains.de> From: Andre Przywara With -Wsign-compare, compilers warn about a mismatching signedness in a comparison in fdt_create_with_flags(). By making hdrsize a signed integer (we are sure it's a very small number), we avoid all the casts and have matching types. Signed-off-by: Andre Przywara Message-Id: <20201001164630.4980-4-andre.przywara at arm.com> Signed-off-by: David Gibson --- cpukit/dtc/libfdt/fdt_sw.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cpukit/dtc/libfdt/fdt_sw.c b/cpukit/dtc/libfdt/fdt_sw.c index 354f46674b..68b543c4df 100644 --- a/cpukit/dtc/libfdt/fdt_sw.c +++ b/cpukit/dtc/libfdt/fdt_sw.c @@ -108,8 +108,8 @@ static void *fdt_grab_space_(void *fdt, size_t len) int fdt_create_with_flags(void *buf, int bufsize, uint32_t flags) { - const size_t hdrsize = FDT_ALIGN(sizeof(struct fdt_header), - sizeof(struct fdt_reserve_entry)); + const int hdrsize = FDT_ALIGN(sizeof(struct fdt_header), + sizeof(struct fdt_reserve_entry)); void *fdt = buf; if (bufsize < hdrsize) -- 2.31.1 From sebastian.huber at embedded-brains.de Tue Dec 14 19:38:08 2021 From: sebastian.huber at embedded-brains.de (Sebastian Huber) Date: Tue, 14 Dec 2021 20:38:08 +0100 Subject: [PATCH 22/35] libfdt: fdt_strerror(): Fix comparison warning In-Reply-To: <20211214193821.1334-1-sebastian.huber@embedded-brains.de> References: <20211214193821.1334-1-sebastian.huber@embedded-brains.de> Message-ID: <20211214193821.1334-23-sebastian.huber@embedded-brains.de> From: Andre Przywara With -Wsign-compare, compilers warn about a mismatching signedness in a comparison in fdt_strerror(). Force FDT_ERRTABSIZE to be signed (it's surely small enough to fit), so that the types match. Also move the minus sign to errval, as this is actually what we use in the next line. Signed-off-by: Andre Przywara Message-Id: <20201001164630.4980-7-andre.przywara at arm.com> Signed-off-by: David Gibson --- cpukit/dtc/libfdt/fdt_strerror.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cpukit/dtc/libfdt/fdt_strerror.c b/cpukit/dtc/libfdt/fdt_strerror.c index 768db66ead..b4356931b0 100644 --- a/cpukit/dtc/libfdt/fdt_strerror.c +++ b/cpukit/dtc/libfdt/fdt_strerror.c @@ -40,7 +40,7 @@ static struct fdt_errtabent fdt_errtable[] = { FDT_ERRTABENT(FDT_ERR_NOPHANDLES), FDT_ERRTABENT(FDT_ERR_BADFLAGS), }; -#define FDT_ERRTABSIZE (sizeof(fdt_errtable) / sizeof(fdt_errtable[0])) +#define FDT_ERRTABSIZE ((int)(sizeof(fdt_errtable) / sizeof(fdt_errtable[0]))) const char *fdt_strerror(int errval) { @@ -48,7 +48,7 @@ const char *fdt_strerror(int errval) return ""; else if (errval == 0) return ""; - else if (errval > -FDT_ERRTABSIZE) { + else if (-errval < FDT_ERRTABSIZE) { const char *s = fdt_errtable[-errval].str; if (s) -- 2.31.1 From sebastian.huber at embedded-brains.de Tue Dec 14 19:38:12 2021 From: sebastian.huber at embedded-brains.de (Sebastian Huber) Date: Tue, 14 Dec 2021 20:38:12 +0100 Subject: [PATCH 26/35] libfdt: Tweak description of assume-aligned load helpers In-Reply-To: <20211214193821.1334-1-sebastian.huber@embedded-brains.de> References: <20211214193821.1334-1-sebastian.huber@embedded-brains.de> Message-ID: <20211214193821.1334-27-sebastian.huber@embedded-brains.de> From: David Gibson There's a small inaccuracy in the comment describing these new helpers. This corrects it, and reformats while we're there. Fixes: f98f28ab ("libfdt: Internally perform potentially unaligned loads") Signed-off-by: David Gibson --- cpukit/dtc/libfdt/libfdt_internal.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/cpukit/dtc/libfdt/libfdt_internal.h b/cpukit/dtc/libfdt/libfdt_internal.h index 8b580aa507..16bda1906a 100644 --- a/cpukit/dtc/libfdt/libfdt_internal.h +++ b/cpukit/dtc/libfdt/libfdt_internal.h @@ -47,13 +47,13 @@ static inline struct fdt_reserve_entry *fdt_mem_rsv_w_(void *fdt, int n) } /* - * Internal helpers to access tructural elements of the device tree blob - * (rather than for exaple reading integers from within property values). We - * assume that we are either given a naturally aligned address for the platform - * or if we are not, we are on a platform where unaligned memory reads will be - * handled in a graceful manner. If this is not the case there are _unaligned - * versions of these functions that follow and can be used. - * + * Internal helpers to access tructural elements of the device tree + * blob (rather than for exaple reading integers from within property + * values). We assume that we are either given a naturally aligned + * address for the platform or if we are not, we are on a platform + * where unaligned memory reads will be handled in a graceful manner. + * If not the external helpers fdtXX_ld() from libfdt.h can be used + * instead. */ static inline uint32_t fdt32_ld_(const fdt32_t *p) { -- 2.31.1 From sebastian.huber at embedded-brains.de Tue Dec 14 19:38:14 2021 From: sebastian.huber at embedded-brains.de (Sebastian Huber) Date: Tue, 14 Dec 2021 20:38:14 +0100 Subject: [PATCH 28/35] libfdt: Fix a possible "unchecked return value" warning In-Reply-To: <20211214193821.1334-1-sebastian.huber@embedded-brains.de> References: <20211214193821.1334-1-sebastian.huber@embedded-brains.de> Message-ID: <20211214193821.1334-29-sebastian.huber@embedded-brains.de> From: David Gibson Apparently the unchecked return value of the first fdt_next_tag() call in fdt_add_subnode_namelen() is tripping Coverity Scan in some circumstances, although it appears not to for the scan on our project itself. This fdt_next_tag() should always return FDT_BEGIN_NODE, since otherwise the fdt_subnode_offset_namelen() above would have returned BADOFFSET or BADSTRUCTURE. Still, add a check to shut Coverity up, gated by a can_assume() to avoid bloat in small builds. Reported-by: Ryan Long Signed-off-by: David Gibson --- cpukit/dtc/libfdt/fdt_rw.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cpukit/dtc/libfdt/fdt_rw.c b/cpukit/dtc/libfdt/fdt_rw.c index f13458d165..2fbb545f9c 100644 --- a/cpukit/dtc/libfdt/fdt_rw.c +++ b/cpukit/dtc/libfdt/fdt_rw.c @@ -349,7 +349,10 @@ int fdt_add_subnode_namelen(void *fdt, int parentoffset, return offset; /* Try to place the new node after the parent's properties */ - fdt_next_tag(fdt, parentoffset, &nextoffset); /* skip the BEGIN_NODE */ + tag = fdt_next_tag(fdt, parentoffset, &nextoffset); + /* the fdt_subnode_offset_namelen() should ensure this never hits */ + if (!can_assume(LIBFDT_FLAWLESS) && (tag != FDT_BEGIN_NODE)) + return -FDT_ERR_INTERNAL; do { offset = nextoffset; tag = fdt_next_tag(fdt, offset, &nextoffset); -- 2.31.1 From sebastian.huber at embedded-brains.de Tue Dec 14 19:38:16 2021 From: sebastian.huber at embedded-brains.de (Sebastian Huber) Date: Tue, 14 Dec 2021 20:38:16 +0100 Subject: [PATCH 30/35] Fix CID 1461557 In-Reply-To: <20211214193821.1334-1-sebastian.huber@embedded-brains.de> References: <20211214193821.1334-1-sebastian.huber@embedded-brains.de> Message-ID: <20211214193821.1334-31-sebastian.huber@embedded-brains.de> From: David Gibson Coverity gets a bit confused by loading fdt_size_dt_strings() and using it in a memmove(). In fact this is safe because the callers have verified this information (via FDT_RW_PROBE() in fdt_pack() or construction in fdt_open_into()). Passing in strings_size like we already do struct_size seems to get Coverity to follow what's going on here. Signed-off-by: David Gibson --- cpukit/dtc/libfdt/fdt_rw.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/cpukit/dtc/libfdt/fdt_rw.c b/cpukit/dtc/libfdt/fdt_rw.c index 2fbb545f9c..3621d3651d 100644 --- a/cpukit/dtc/libfdt/fdt_rw.c +++ b/cpukit/dtc/libfdt/fdt_rw.c @@ -394,7 +394,9 @@ int fdt_del_node(void *fdt, int nodeoffset) } static void fdt_packblocks_(const char *old, char *new, - int mem_rsv_size, int struct_size) + int mem_rsv_size, + int struct_size, + int strings_size) { int mem_rsv_off, struct_off, strings_off; @@ -409,8 +411,7 @@ static void fdt_packblocks_(const char *old, char *new, fdt_set_off_dt_struct(new, struct_off); fdt_set_size_dt_struct(new, struct_size); - memmove(new + strings_off, old + fdt_off_dt_strings(old), - fdt_size_dt_strings(old)); + memmove(new + strings_off, old + fdt_off_dt_strings(old), strings_size); fdt_set_off_dt_strings(new, strings_off); fdt_set_size_dt_strings(new, fdt_size_dt_strings(old)); } @@ -470,7 +471,8 @@ int fdt_open_into(const void *fdt, void *buf, int bufsize) return -FDT_ERR_NOSPACE; } - fdt_packblocks_(fdt, tmp, mem_rsv_size, struct_size); + fdt_packblocks_(fdt, tmp, mem_rsv_size, struct_size, + fdt_size_dt_strings(fdt)); memmove(buf, tmp, newsize); fdt_set_magic(buf, FDT_MAGIC); @@ -490,7 +492,8 @@ int fdt_pack(void *fdt) mem_rsv_size = (fdt_num_mem_rsv(fdt)+1) * sizeof(struct fdt_reserve_entry); - fdt_packblocks_(fdt, fdt, mem_rsv_size, fdt_size_dt_struct(fdt)); + fdt_packblocks_(fdt, fdt, mem_rsv_size, fdt_size_dt_struct(fdt), + fdt_size_dt_strings(fdt)); fdt_set_totalsize(fdt, fdt_data_size_(fdt)); return 0; -- 2.31.1 From sebastian.huber at embedded-brains.de Tue Dec 14 19:38:19 2021 From: sebastian.huber at embedded-brains.de (Sebastian Huber) Date: Tue, 14 Dec 2021 20:38:19 +0100 Subject: [PATCH 33/35] libfdt: fix an incorrect integer promotion In-Reply-To: <20211214193821.1334-1-sebastian.huber@embedded-brains.de> References: <20211214193821.1334-1-sebastian.huber@embedded-brains.de> Message-ID: <20211214193821.1334-34-sebastian.huber@embedded-brains.de> From: Elvira Khabirova UINT32_MAX is an integer of type unsigned int. UINT32_MAX + 1 overflows unless explicitly computed as unsigned long long. This led to some invalid addresses being treated as valid. Cast UINT32_MAX to uint64_t explicitly. Signed-off-by: Elvira Khabirova --- cpukit/dtc/libfdt/fdt_addresses.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpukit/dtc/libfdt/fdt_addresses.c b/cpukit/dtc/libfdt/fdt_addresses.c index 9a82cd0ba2..c40ba094f1 100644 --- a/cpukit/dtc/libfdt/fdt_addresses.c +++ b/cpukit/dtc/libfdt/fdt_addresses.c @@ -73,7 +73,7 @@ int fdt_appendprop_addrrange(void *fdt, int parent, int nodeoffset, /* check validity of address */ prop = data; if (addr_cells == 1) { - if ((addr > UINT32_MAX) || ((UINT32_MAX + 1 - addr) < size)) + if ((addr > UINT32_MAX) || (((uint64_t) UINT32_MAX + 1 - addr) < size)) return -FDT_ERR_BADVALUE; fdt32_st(prop, (uint32_t)addr); -- 2.31.1 From sebastian.huber at embedded-brains.de Tue Dec 14 19:38:21 2021 From: sebastian.huber at embedded-brains.de (Sebastian Huber) Date: Tue, 14 Dec 2021 20:38:21 +0100 Subject: [PATCH 35/35] dtc: Update VERSION In-Reply-To: <20211214193821.1334-1-sebastian.huber@embedded-brains.de> References: <20211214193821.1334-1-sebastian.huber@embedded-brains.de> Message-ID: <20211214193821.1334-36-sebastian.huber@embedded-brains.de> --- cpukit/dtc/VERSION | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cpukit/dtc/VERSION b/cpukit/dtc/VERSION index a6f7720958..77198ab947 100644 --- a/cpukit/dtc/VERSION +++ b/cpukit/dtc/VERSION @@ -4,15 +4,15 @@ git://git.kernel.org/pub/scm/utils/dtc/dtc.git Commit: -0f61c72dedc4bf11cd19a78fc36a7bde99d653e0 +17739b7ef510917471409d71fb45d8eaf6a1e1fb Date: -Thu Feb 20 14:45:57 2020 -0700 +Thu Dec 9 07:14:20 2021 +0100 Commands to generate update patches: -git format-patch 0f61c72dedc4bf11cd19a78fc36a7bde99d653e0 -- libfdt/fdt_addresses.c libfdt/fdt.c libfdt/fdt_empty_tree.c libfdt/fdt.h libfdt/fdt_ro.c libfdt/fdt_rw.c libfdt/fdt_strerror.c libfdt/fdt_sw.c libfdt/fdt_wip.c libfdt/libfdt_env.h libfdt/libfdt.h libfdt/libfdt_internal.h libfdt/TODO +git format-patch 17739b7ef510917471409d71fb45d8eaf6a1e1fb -- libfdt/fdt_addresses.c libfdt/fdt.c libfdt/fdt_empty_tree.c libfdt/fdt.h libfdt/fdt_ro.c libfdt/fdt_rw.c libfdt/fdt_strerror.c libfdt/fdt_sw.c libfdt/fdt_wip.c libfdt/libfdt_env.h libfdt/libfdt.h libfdt/libfdt_internal.h libfdt/TODO sed -i 's%/libfdt/fdt.h%/cpukit/include/fdt.h%g' 00* sed -i 's%/libfdt/libfdt.h%/cpukit/include/libfdt.h%g' 00* sed -i 's%/libfdt/libfdt_env.h%/cpukit/include/libfdt_env.h%g' 00* -- 2.31.1 From sebastian.huber at embedded-brains.de Tue Dec 14 19:38:13 2021 From: sebastian.huber at embedded-brains.de (Sebastian Huber) Date: Tue, 14 Dec 2021 20:38:13 +0100 Subject: [PATCH 27/35] Set last_comp_version correctly in new dtb and fix potential version issues in fdt_open_into In-Reply-To: <20211214193821.1334-1-sebastian.huber@embedded-brains.de> References: <20211214193821.1334-1-sebastian.huber@embedded-brains.de> Message-ID: <20211214193821.1334-28-sebastian.huber@embedded-brains.de> From: Justin Covell Changes in v3: - Remove noop version sets - Set version correctly on loaded fdt in fdt_open_into Fixes: f1879e1a50eb ("Add limited read-only support for older (V2 and V3) device tree to libfdt.") Signed-off-by: Justin Covell Message-Id: <20201229041749.2187-1-jujugoboom at gmail.com> Signed-off-by: David Gibson --- cpukit/dtc/libfdt/fdt_rw.c | 4 +++- cpukit/dtc/libfdt/fdt_sw.c | 2 +- cpukit/include/libfdt.h | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/cpukit/dtc/libfdt/fdt_rw.c b/cpukit/dtc/libfdt/fdt_rw.c index 68887b969a..f13458d165 100644 --- a/cpukit/dtc/libfdt/fdt_rw.c +++ b/cpukit/dtc/libfdt/fdt_rw.c @@ -428,12 +428,14 @@ int fdt_open_into(const void *fdt, void *buf, int bufsize) if (can_assume(LATEST) || fdt_version(fdt) >= 17) { struct_size = fdt_size_dt_struct(fdt); - } else { + } else if (fdt_version(fdt) == 16) { struct_size = 0; while (fdt_next_tag(fdt, struct_size, &struct_size) != FDT_END) ; if (struct_size < 0) return struct_size; + } else { + return -FDT_ERR_BADVERSION; } if (can_assume(LIBFDT_ORDER) || diff --git a/cpukit/dtc/libfdt/fdt_sw.c b/cpukit/dtc/libfdt/fdt_sw.c index 68b543c4df..4c569ee7eb 100644 --- a/cpukit/dtc/libfdt/fdt_sw.c +++ b/cpukit/dtc/libfdt/fdt_sw.c @@ -377,7 +377,7 @@ int fdt_finish(void *fdt) fdt_set_totalsize(fdt, newstroffset + fdt_size_dt_strings(fdt)); /* And fix up fields that were keeping intermediate state. */ - fdt_set_last_comp_version(fdt, FDT_FIRST_SUPPORTED_VERSION); + fdt_set_last_comp_version(fdt, FDT_LAST_COMPATIBLE_VERSION); fdt_set_magic(fdt, FDT_MAGIC); return 0; diff --git a/cpukit/include/libfdt.h b/cpukit/include/libfdt.h index 2bc16a8b3f..73467f75c5 100644 --- a/cpukit/include/libfdt.h +++ b/cpukit/include/libfdt.h @@ -14,6 +14,7 @@ extern "C" { #endif #define FDT_FIRST_SUPPORTED_VERSION 0x02 +#define FDT_LAST_COMPATIBLE_VERSION 0x10 #define FDT_LAST_SUPPORTED_VERSION 0x11 /* Error codes: informative error codes */ -- 2.31.1 From joel at rtems.org Tue Dec 14 21:19:29 2021 From: joel at rtems.org (Joel Sherrill) Date: Tue, 14 Dec 2021 15:19:29 -0600 Subject: Ten Years of Git Message-ID: Hi Had a memory pop up which noted that today is the tenth anniversary of when we made CVS ready only. That means today there are now 26 years, 7 months, and 4 days of RTEMS history to peruse online. This is the post and original in the RTEMS Users Facebook group. https://www.facebook.com/groups/4847496844/permalink/10158477934211845/ --joel From chrisj at rtems.org Wed Dec 15 05:46:08 2021 From: chrisj at rtems.org (Chris Johns) Date: Wed, 15 Dec 2021 16:46:08 +1100 Subject: New validation test suites In-Reply-To: <6f5145de-94f8-1984-5590-fb05741d282b@embedded-brains.de> References: <5c4d51cb-660d-93ec-7a59-4a98be61d4c1@embedded-brains.de> <514bddac-9f20-5fa6-52a0-57c8f8787c82@rtems.org> <6f5145de-94f8-1984-5590-fb05741d282b@embedded-brains.de> Message-ID: On 14/12/21 6:24 pm, Sebastian Huber wrote: > Hello Chris, > > On 13/12/2021 22:01, Chris Johns wrote: >> On 14/12/21 1:53 am, Sebastian Huber wrote: >>> Hello, >>> >>> the ESA activity to pre-qualify parts of RTEMS according to ECSS requirements is >>> nearly complete. There is a short presentation available here: >>> >>> https://indico.esa.int/event/374/timetable/ >> >> Was the change in memory usage for 4.8 of 23812 bytes to 68896 explained? > > The foot print increase has mainly five reasons: > > * General GCC code generation > > * Chip errata workarounds done by GCC > > * More features used from RTEMS (for example uniprocessor synchronization done > via task priorities vs. mutex synchronization) > > * SMP support of RTEMS > > * New RTEMS features such as transitive priority inheritance > Thanks. >>> We finished the specification of the pre-qualified RTEMS feature set. The >>> specification is available in an RTEMS Project repository: >>> >>> https://git.rtems.org/rtems-central/tree/spec >> >> I had a quick look. Is there a more user friendly view of this data? >> >> I think the term "specification" is a little bit misleading because the data >> files are not easily read by a person. I understand this is the specification >> data set however it is not what I am traditionally use to seeing. > > You can use the "./specview.py" script to get views of the specification.? For > example, this command displays the transition map for the rtems_signal_send() > directive: Is specview.py part of rtems.git? If not part of rtems.git how much data is there for all the output? That is it is generated and held in the repo with the tests? > > ./specview.py --filter=action-table /rtems/signal/req/send > .. table:: > ??? :class: longtable > > ??? ===== ========== ===== ======= ======= ======== ====== ====== ============= > ========= > ??? Entry Descriptor Task? Set???? Handler ASR????? Nested Status Handler?????? > Recursive > ??? ===== ========== ===== ======= ======= ======== ====== ====== ============= > ========= > ??? 0???? 0????????? NoObj Zero??? Invalid Enabled? Yes??? InvNum NoCall??????? No > ??? 1???? 0????????? NoObj Zero??? Invalid Enabled? No???? InvNum NoCall??????? No > ??? 2???? 0????????? NoObj Zero??? Invalid Disabled Yes??? InvNum NoCall??????? No > ??? 3???? 0????????? NoObj Zero??? Invalid Disabled No???? InvNum NoCall??????? No > ??? 4???? 0????????? NoObj Zero??? Valid?? Enabled? Yes??? InvNum NoCall??????? No > ??? 5???? 0????????? NoObj Zero??? Valid?? Enabled? No???? InvNum NoCall??????? No > ??? 6???? 0????????? NoObj Zero??? Valid?? Disabled Yes??? InvNum NoCall??????? No > ??? 7???? 0????????? NoObj Zero??? Valid?? Disabled No???? InvNum NoCall??????? No > ??? 8???? 1????????? NoObj NonZero Invalid Enabled? Yes??? InvId NoCall??????? No > ??? 9???? 1????????? NoObj NonZero Invalid Enabled? No???? InvId NoCall??????? No > ??? 10??? 1????????? NoObj NonZero Invalid Disabled Yes??? InvId NoCall??????? No > ??? 11??? 1????????? NoObj NonZero Invalid Disabled No???? InvId NoCall??????? No > ??? 12??? 1????????? NoObj NonZero Valid?? Enabled? Yes??? InvId NoCall??????? No > ??? 13??? 1????????? NoObj NonZero Valid?? Enabled? No???? InvId NoCall??????? No > ??? 14??? 1????????? NoObj NonZero Valid?? Disabled Yes??? InvId NoCall??????? No > ??? 15??? 1????????? NoObj NonZero Valid?? Disabled No???? InvId NoCall??????? No > ??? 16??? 0????????? Self? Zero??? Invalid Enabled? Yes??? InvNum NoCall??????? No > ??? 17??? 0????????? Self? Zero??? Invalid Enabled? No???? InvNum NoCall??????? No > ??? 18??? 0????????? Self? Zero??? Invalid Disabled Yes??? InvNum NoCall??????? No > ??? 19??? 0????????? Self? Zero??? Invalid Disabled No???? InvNum NoCall??????? No > ??? 20??? 0????????? Self? Zero??? Valid?? Enabled? Yes??? InvNum NoCall??????? No > ??? 21??? 0????????? Self? Zero??? Valid?? Enabled? No???? InvNum NoCall??????? No > ??? 22??? 0????????? Self? Zero??? Valid?? Disabled Yes??? InvNum NoCall??????? No > ??? 23??? 0????????? Self? Zero??? Valid?? Disabled No???? InvNum NoCall??????? No > ??? 24??? 2????????? Self? NonZero Invalid Enabled? Yes??? NotDef NoCall??????? No > ??? 25??? 2????????? Self? NonZero Invalid Enabled? No???? NotDef NoCall??????? No > ??? 26??? 2????????? Self? NonZero Invalid Disabled Yes??? NotDef NoCall??????? No > ??? 27??? 2????????? Self? NonZero Invalid Disabled No???? NotDef NoCall??????? No > ??? 28??? 6????????? Self? NonZero Valid?? Enabled? Yes??? Ok DuringSend??? Yes > ??? 29??? 4????????? Self? NonZero Valid?? Enabled? No???? Ok DuringSend??? No > ??? 30??? 3????????? Self? NonZero Valid?? Disabled Yes??? Ok AfterEnable?? No > ??? 31??? 3????????? Self? NonZero Valid?? Disabled No???? Ok AfterEnable?? No > ??? 32??? 0????????? Other Zero??? Invalid Enabled? Yes??? InvNum NoCall??????? No > ??? 33??? 0????????? Other Zero??? Invalid Enabled? No???? InvNum NoCall??????? No > ??? 34??? 0????????? Other Zero??? Invalid Disabled Yes??? InvNum NoCall??????? No > ??? 35??? 0????????? Other Zero??? Invalid Disabled No???? InvNum NoCall??????? No > ??? 36??? 0????????? Other Zero??? Valid?? Enabled? Yes??? InvNum NoCall??????? No > ??? 37??? 0????????? Other Zero??? Valid?? Enabled? No???? InvNum NoCall??????? No > ??? 38??? 0????????? Other Zero??? Valid?? Disabled Yes??? InvNum NoCall??????? No > ??? 39??? 0????????? Other Zero??? Valid?? Disabled No???? InvNum NoCall??????? No > ??? 40??? 2????????? Other NonZero Invalid Enabled? Yes??? NotDef NoCall??????? No > ??? 41??? 2????????? Other NonZero Invalid Enabled? No???? NotDef NoCall??????? No > ??? 42??? 2????????? Other NonZero Invalid Disabled Yes??? NotDef NoCall??????? No > ??? 43??? 2????????? Other NonZero Invalid Disabled No???? NotDef NoCall??????? No > ??? 44??? 7????????? Other NonZero Valid?? Enabled? Yes??? Ok AfterDispatch Yes > ??? 45??? 5????????? Other NonZero Valid?? Enabled? No???? Ok AfterDispatch No > ??? 46??? 3????????? Other NonZero Valid?? Disabled Yes??? Ok AfterEnable?? No > ??? 47??? 3????????? Other NonZero Valid?? Disabled No???? Ok AfterEnable?? No > ??? ===== ========== ===== ======= ======= ======== ====== ====== ============= > ========= Is the > > Here the same information in a different view, for each post-condition set the > pre-condition sets are displayed: > > ./specview.py --filter=action-list /rtems/signal/req/send > > Status = Ok, Handler = DuringSend, Recursive = Yes > > ??? * Task = Self, Set = NonZero, Handler = Valid, ASR = Enabled, Nested = Yes > > Status = Ok, Handler = DuringSend, Recursive = No > > ??? * Task = Self, Set = NonZero, Handler = Valid, ASR = Enabled, Nested = No > > Status = Ok, Handler = AfterDispatch, Recursive = Yes > > ??? * Task = Other, Set = NonZero, Handler = Valid, ASR = Enabled, Nested = Yes > > Status = Ok, Handler = AfterDispatch, Recursive = No > > ??? * Task = Other, Set = NonZero, Handler = Valid, ASR = Enabled, Nested = No > > Status = Ok, Handler = AfterEnable, Recursive = No > > ??? * Task = { Self, Other }, Set = NonZero, Handler = Valid, ASR = Disabled, > Nested = { Yes, No } > > Status = InvId, Handler = NoCall, Recursive = No > > ??? * Task = NoObj, Set = NonZero, Handler = { Invalid, Valid }, ASR = { > Enabled, Disabled }, Nested = { Yes, No } > > Status = NotDef, Handler = NoCall, Recursive = No > > ??? * Task = { Self, Other }, Set = NonZero, Handler = Invalid, ASR = { Enabled, > Disabled }, Nested = { Yes, No } > > Status = InvNum, Handler = NoCall, Recursive = No > > ??? * Task = { NoObj, Self, Other }, Set = Zero, Handler = { Invalid, Valid }, > ASR = { Enabled, Disabled }, Nested = { Yes, No } > > >> >>> The validation tests are generated from the specification using the >>> "./spec2modules.py" script and end up in the RTEMS sources of a Git submodule. I >>> think the specification and the generation tool is now sufficiently stable so >>> that the validation test code can be integrated in the RTEMS master branch. The >>> patch set is too big for the mailing list, so you can review it here: >>> >>> https://git.rtems.org/sebh/rtems.git/log/?h=validation >> >> The link failed. > > Yes, viewing my personal repository no longer works.? I am not sure if this is a > temporary issue.? This is why I added the github link. It seems to have been temporary. It is back again. > >> >>> https://github.com/sebhub/rtems/tree/validation >> >> The header in a test says the regeneration instructions are in the engineering >> manual but I could not quickly find them? > > https://docs.rtems.org/branches/master/eng/req/howto.html#generate-content-after-changes > > > In an earlier version of the header, we had a link which you didn't like: If I need to look at the formatting rules the heading "Software Development Management" is easy to see and then a click on "Coding Standards" gives me what I am looking for. To generate these headers I click on "Software Requirements Engineering" and then do I just guess until I find it in the "How To" section? I am actually asking this be sorted out so it is not left hanging and we are not left guessing what to do. If it can be rearrange into something meaningful it would help. :) > commit a6689fb147649a29ff5533cec8a53635e2c95ec6 > Author: Sebastian Huber > Date:?? Fri Jan 22 16:01:46 2021 +0100 > > ??? Improve file header comment in generated files > > diff --git a/cpukit/include/rtems/rtems/types.h > b/cpukit/include/rtems/rtems/types.h > index 32b45113c8..a058eedea1 100644 > --- a/cpukit/include/rtems/rtems/types.h > +++ b/cpukit/include/rtems/rtems/types.h > @@ -38,11 +38,15 @@ > ? * worded better please post a report or patch to an RTEMS mailing list > ? * or raise a bug report: > ? * > - * https://docs.rtems.org/branches/master/user/support/bugs.html > + * https://www.rtems.org/bugs.html > ? * > - * For information on updating and regenerating please refer to: > + * For information on updating and regenerating please refer to the How-To > + * section in the Software Requirements Engineering chapter of the > + * RTEMS Software Engineering manual.? The manual is provided as a part of > + * a release.? For development sources please refer to the online > + * documentation at: > ? * > - * https://docs.rtems.org/branches/master/eng/req/howto.html > + * https://docs.rtems.org > ? */ > > ?/* Generated from spec:/rtems/type/if/header */ > I am fine with the header, as we know links to the documentation is really hard long term. >>> The patch set is organized so that general support code for the validation tests >>> is added first and then there are commits for each pre-qualified Classic API >>> Manager or subsystem. >>> >>> I did build all BSPs with the patch set. The validation tests use only >>> statically allocated resources. >> >> Are the validation tests compatible with rtems-test? > > Yes. Great. >> How many test executables does this add to the testsuite? > > If RTEMS_SMP is disabled, then there are 19 new executables in the patch set. If > RTEMS_SMP is enable, then there are 28 new executables. Nice. >> What hardware have the validation tests been run on? Any tier 1 archs? > > I tested with the sparc/leon3 BSPs and the arm/realview_pbx_a9_qemu. Is the leon3 tested on hardware or simulation? > You need a > full implementation of the new Interrupt Manager directives and a working Cache > Manager implementation. Is this documented? I am sorry I do not know the list of archs and bsps that support the new interrupt manager directives. Maybe it would be good to list them? > I noticed an issue with the thread restart on aarch64/a53_lp64_qemu. > > On powerpc/psim there is an issue in one test case, due to: > > #define CPU_ALL_TASKS_ARE_FP CPU_HARDWARE_FP Sorry, I am not following what the issue is? Does this effect all PPC BSPS? > Another issue is that the tm27 interrupt must be independent of the clock driver > interrupt.? This is not the case for powerpc/psim. > > There is definitely some work left to cover all edge cases. Some tests are quite > complicated. Sure. I would like to understand the effects this has? >> Is there anything that interprets the new test output format? It looks like lots >> of great info but a little difficult to read. > > EDISOFT worked on a test report generator, however, it is not yet in a > reviewable state. OK. I think something that handles this data would be good to have. >>> Some low memory targets are not able to link all test suites. >> >> Are these excluded in the normal way? > > Yes: > > https://github.com/sebhub/rtems/commit/2feedb9e7805f483e35b7914b9bd7c808e31a8b4#diff-bf7b325198d4133c9e52f49d77447905ecd3c6ac5159d5cd85e7efeffa6da47e Nice. This looks really good and I like what it provides. It is a fantastic baseline of the interfaces we have however to be useful long term it needs to generate regression notices and so that means we need to know and understand the baselines this brings us now and for which arches. Chris From sebastian.huber at embedded-brains.de Wed Dec 15 07:32:57 2021 From: sebastian.huber at embedded-brains.de (Sebastian Huber) Date: Wed, 15 Dec 2021 08:32:57 +0100 Subject: arm64 support for libbsd Message-ID: <25b18855-9b82-5b40-1be3-888cdb71f41d@embedded-brains.de> Hello Kinsey, I didn't work with libbsd for a while and noticed now that there are changes after calling: ./freebsd-to-rtems.py -R ./freebsd-to-rtems.py git status modified: freebsd/sys/arm64/include/machine/in_cksum.h I don't know how you imported the in_cksum.h, but there should be no modified files after running the script. -- embedded brains GmbH Herr Sebastian HUBER Dornierstr. 4 82178 Puchheim Germany email: sebastian.huber at embedded-brains.de phone: +49-89-18 94 741 - 16 fax: +49-89-18 94 741 - 08 Registergericht: Amtsgericht M?nchen Registernummer: HRB 157899 Vertretungsberechtigte Gesch?ftsf?hrer: Peter Rasmussen, Thomas D?rfler Unsere Datenschutzerkl?rung finden Sie hier: https://embedded-brains.de/datenschutzerklaerung/ From kinsey.moore at oarcorp.com Wed Dec 15 15:10:10 2021 From: kinsey.moore at oarcorp.com (Kinsey Moore) Date: Wed, 15 Dec 2021 09:10:10 -0600 Subject: arm64 support for libbsd In-Reply-To: <25b18855-9b82-5b40-1be3-888cdb71f41d@embedded-brains.de> References: <25b18855-9b82-5b40-1be3-888cdb71f41d@embedded-brains.de> Message-ID: On 12/15/2021 01:32, Sebastian Huber wrote: > Hello Kinsey, > > I didn't work with libbsd for a while and noticed now that there are > changes after calling: > > ./freebsd-to-rtems.py -R > ./freebsd-to-rtems.py > > git status > modified:?? freebsd/sys/arm64/include/machine/in_cksum.h > > I don't know how you imported the in_cksum.h, but there should be no > modified files after running the script. > I could swear I imported that correctly and even verified that the import was clean, but either that wasn't the case or I had a non-clean/correct freebsd-org tree. I've verified that everything still compiles correctly with the changes and will submit patches for the affected branches. Kinsey From joel at rtems.org Wed Dec 15 16:01:59 2021 From: joel at rtems.org (Joel Sherrill) Date: Wed, 15 Dec 2021 10:01:59 -0600 Subject: New validation test suites In-Reply-To: References: <5c4d51cb-660d-93ec-7a59-4a98be61d4c1@embedded-brains.de> <514bddac-9f20-5fa6-52a0-57c8f8787c82@rtems.org> <6f5145de-94f8-1984-5590-fb05741d282b@embedded-brains.de> Message-ID: I waited to reply because Chris got most of my questions in his first response. :) On Tue, Dec 14, 2021 at 11:46 PM Chris Johns wrote: > > On 14/12/21 6:24 pm, Sebastian Huber wrote: > > Hello Chris, > > > > On 13/12/2021 22:01, Chris Johns wrote: > >> On 14/12/21 1:53 am, Sebastian Huber wrote: > >>> Hello, > >>> > >>> the ESA activity to pre-qualify parts of RTEMS according to ECSS requirements is > >>> nearly complete. There is a short presentation available here: > >>> > >>> https://indico.esa.int/event/374/timetable/ > >> > >> Was the change in memory usage for 4.8 of 23812 bytes to 68896 explained? > > > > The foot print increase has mainly five reasons: > > > > * General GCC code generation > > > > * Chip errata workarounds done by GCC > > > > * More features used from RTEMS (for example uniprocessor synchronization done > > via task priorities vs. mutex synchronization) > > > > * SMP support of RTEMS > > > > * New RTEMS features such as transitive priority inheritance > > > > Thanks. If the 4.8 size was based on the Edisoft version, it was also stripped of functionality even within methods in RTEMS itself. Combine that with uniprocessor vs SMP and more robust algorithms in the current RTEMS and it creeps up. It would be interesting to see a straight uniprocessor comparison but even that would not have feature parity. > > >>> We finished the specification of the pre-qualified RTEMS feature set. The > >>> specification is available in an RTEMS Project repository: > >>> > >>> https://git.rtems.org/rtems-central/tree/spec > >> > >> I had a quick look. Is there a more user friendly view of this data? > >> > >> I think the term "specification" is a little bit misleading because the data > >> files are not easily read by a person. I understand this is the specification > >> data set however it is not what I am traditionally use to seeing. > > > > You can use the "./specview.py" script to get views of the specification. For > > example, this command displays the transition map for the rtems_signal_send() > > directive: > > Is specview.py part of rtems.git? > > If not part of rtems.git how much data is there for all the output? That is it > is generated and held in the repo with the tests? > > > > > ./specview.py --filter=action-table /rtems/signal/req/send > > .. table:: > > :class: longtable > > > > ===== ========== ===== ======= ======= ======== ====== ====== ============= > > ========= > > Entry Descriptor Task Set Handler ASR Nested Status Handler > > Recursive > > ===== ========== ===== ======= ======= ======== ====== ====== ============= > > ========= > > 0 0 NoObj Zero Invalid Enabled Yes InvNum NoCall No > > 1 0 NoObj Zero Invalid Enabled No InvNum NoCall No > > 2 0 NoObj Zero Invalid Disabled Yes InvNum NoCall No > > 3 0 NoObj Zero Invalid Disabled No InvNum NoCall No > > 4 0 NoObj Zero Valid Enabled Yes InvNum NoCall No > > 5 0 NoObj Zero Valid Enabled No InvNum NoCall No > > 6 0 NoObj Zero Valid Disabled Yes InvNum NoCall No > > 7 0 NoObj Zero Valid Disabled No InvNum NoCall No > > 8 1 NoObj NonZero Invalid Enabled Yes InvId NoCall No > > 9 1 NoObj NonZero Invalid Enabled No InvId NoCall No > > 10 1 NoObj NonZero Invalid Disabled Yes InvId NoCall No > > 11 1 NoObj NonZero Invalid Disabled No InvId NoCall No > > 12 1 NoObj NonZero Valid Enabled Yes InvId NoCall No > > 13 1 NoObj NonZero Valid Enabled No InvId NoCall No > > 14 1 NoObj NonZero Valid Disabled Yes InvId NoCall No > > 15 1 NoObj NonZero Valid Disabled No InvId NoCall No > > 16 0 Self Zero Invalid Enabled Yes InvNum NoCall No > > 17 0 Self Zero Invalid Enabled No InvNum NoCall No > > 18 0 Self Zero Invalid Disabled Yes InvNum NoCall No > > 19 0 Self Zero Invalid Disabled No InvNum NoCall No > > 20 0 Self Zero Valid Enabled Yes InvNum NoCall No > > 21 0 Self Zero Valid Enabled No InvNum NoCall No > > 22 0 Self Zero Valid Disabled Yes InvNum NoCall No > > 23 0 Self Zero Valid Disabled No InvNum NoCall No > > 24 2 Self NonZero Invalid Enabled Yes NotDef NoCall No > > 25 2 Self NonZero Invalid Enabled No NotDef NoCall No > > 26 2 Self NonZero Invalid Disabled Yes NotDef NoCall No > > 27 2 Self NonZero Invalid Disabled No NotDef NoCall No > > 28 6 Self NonZero Valid Enabled Yes Ok DuringSend Yes > > 29 4 Self NonZero Valid Enabled No Ok DuringSend No > > 30 3 Self NonZero Valid Disabled Yes Ok AfterEnable No > > 31 3 Self NonZero Valid Disabled No Ok AfterEnable No > > 32 0 Other Zero Invalid Enabled Yes InvNum NoCall No > > 33 0 Other Zero Invalid Enabled No InvNum NoCall No > > 34 0 Other Zero Invalid Disabled Yes InvNum NoCall No > > 35 0 Other Zero Invalid Disabled No InvNum NoCall No > > 36 0 Other Zero Valid Enabled Yes InvNum NoCall No > > 37 0 Other Zero Valid Enabled No InvNum NoCall No > > 38 0 Other Zero Valid Disabled Yes InvNum NoCall No > > 39 0 Other Zero Valid Disabled No InvNum NoCall No > > 40 2 Other NonZero Invalid Enabled Yes NotDef NoCall No > > 41 2 Other NonZero Invalid Enabled No NotDef NoCall No > > 42 2 Other NonZero Invalid Disabled Yes NotDef NoCall No > > 43 2 Other NonZero Invalid Disabled No NotDef NoCall No > > 44 7 Other NonZero Valid Enabled Yes Ok AfterDispatch Yes > > 45 5 Other NonZero Valid Enabled No Ok AfterDispatch No > > 46 3 Other NonZero Valid Disabled Yes Ok AfterEnable No > > 47 3 Other NonZero Valid Disabled No Ok AfterEnable No > > ===== ========== ===== ======= ======= ======== ====== ====== ============= > > ========= > > Is the > > > > Here the same information in a different view, for each post-condition set the > > pre-condition sets are displayed: > > > > ./specview.py --filter=action-list /rtems/signal/req/send > > > > Status = Ok, Handler = DuringSend, Recursive = Yes > > > > * Task = Self, Set = NonZero, Handler = Valid, ASR = Enabled, Nested = Yes > > > > Status = Ok, Handler = DuringSend, Recursive = No > > > > * Task = Self, Set = NonZero, Handler = Valid, ASR = Enabled, Nested = No > > > > Status = Ok, Handler = AfterDispatch, Recursive = Yes > > > > * Task = Other, Set = NonZero, Handler = Valid, ASR = Enabled, Nested = Yes > > > > Status = Ok, Handler = AfterDispatch, Recursive = No > > > > * Task = Other, Set = NonZero, Handler = Valid, ASR = Enabled, Nested = No > > > > Status = Ok, Handler = AfterEnable, Recursive = No > > > > * Task = { Self, Other }, Set = NonZero, Handler = Valid, ASR = Disabled, > > Nested = { Yes, No } > > > > Status = InvId, Handler = NoCall, Recursive = No > > > > * Task = NoObj, Set = NonZero, Handler = { Invalid, Valid }, ASR = { > > Enabled, Disabled }, Nested = { Yes, No } > > > > Status = NotDef, Handler = NoCall, Recursive = No > > > > * Task = { Self, Other }, Set = NonZero, Handler = Invalid, ASR = { Enabled, > > Disabled }, Nested = { Yes, No } > > > > Status = InvNum, Handler = NoCall, Recursive = No > > > > * Task = { NoObj, Self, Other }, Set = Zero, Handler = { Invalid, Valid }, > > ASR = { Enabled, Disabled }, Nested = { Yes, No } > > > > > >> > >>> The validation tests are generated from the specification using the > >>> "./spec2modules.py" script and end up in the RTEMS sources of a Git submodule. I > >>> think the specification and the generation tool is now sufficiently stable so > >>> that the validation test code can be integrated in the RTEMS master branch. The > >>> patch set is too big for the mailing list, so you can review it here: > >>> > >>> https://git.rtems.org/sebh/rtems.git/log/?h=validation > >> > >> The link failed. > > > > Yes, viewing my personal repository no longer works. I am not sure if this is a > > temporary issue. This is why I added the github link. > > It seems to have been temporary. It is back again. > > > > >> > >>> https://github.com/sebhub/rtems/tree/validation > >> > >> The header in a test says the regeneration instructions are in the engineering > >> manual but I could not quickly find them? > > > > https://docs.rtems.org/branches/master/eng/req/howto.html#generate-content-after-changes > > > > > > In an earlier version of the header, we had a link which you didn't like: > > If I need to look at the formatting rules the heading "Software Development > Management" is easy to see and then a click on "Coding Standards" gives me what > I am looking for. > > To generate these headers I click on "Software Requirements Engineering" and > then do I just guess until I find it in the "How To" section? I am actually > asking this be sorted out so it is not left hanging and we are not left guessing > what to do. If it can be rearrange into something meaningful it would help. :) Have you had anyone not directly involved in the generation process try this from the instructions? That always seems to be when the holes show up. > > commit a6689fb147649a29ff5533cec8a53635e2c95ec6 > > Author: Sebastian Huber > > Date: Fri Jan 22 16:01:46 2021 +0100 > > > > Improve file header comment in generated files > > > > diff --git a/cpukit/include/rtems/rtems/types.h > > b/cpukit/include/rtems/rtems/types.h > > index 32b45113c8..a058eedea1 100644 > > --- a/cpukit/include/rtems/rtems/types.h > > +++ b/cpukit/include/rtems/rtems/types.h > > @@ -38,11 +38,15 @@ > > * worded better please post a report or patch to an RTEMS mailing list > > * or raise a bug report: > > * > > - * https://docs.rtems.org/branches/master/user/support/bugs.html > > + * https://www.rtems.org/bugs.html > > * > > - * For information on updating and regenerating please refer to: > > + * For information on updating and regenerating please refer to the How-To > > + * section in the Software Requirements Engineering chapter of the > > + * RTEMS Software Engineering manual. The manual is provided as a part of > > + * a release. For development sources please refer to the online > > + * documentation at: > > * > > - * https://docs.rtems.org/branches/master/eng/req/howto.html > > + * https://docs.rtems.org > > */ > > > > /* Generated from spec:/rtems/type/if/header */ > > > > I am fine with the header, as we know links to the documentation is really hard > long term. Early on, we discussed some annotation maybe like SPDX to note that a file had higher rigor with requirements and tests. Is this Generated note implying this? Is it sufficient to note that if you touch this, we would really like you to address the full chain on this? > >>> The patch set is organized so that general support code for the validation tests > >>> is added first and then there are commits for each pre-qualified Classic API > >>> Manager or subsystem. > >>> > >>> I did build all BSPs with the patch set. The validation tests use only > >>> statically allocated resources. > >> > >> Are the validation tests compatible with rtems-test? > > > > Yes. > > Great. > > >> How many test executables does this add to the testsuite? > > > > If RTEMS_SMP is disabled, then there are 19 new executables in the patch set. If > > RTEMS_SMP is enable, then there are 28 new executables. > > Nice. > > >> What hardware have the validation tests been run on? Any tier 1 archs? > > > > I tested with the sparc/leon3 BSPs and the arm/realview_pbx_a9_qemu. > > Is the leon3 tested on hardware or simulation? > > > You need a > > full implementation of the new Interrupt Manager directives and a working Cache > > Manager implementation. > > Is this documented? > > I am sorry I do not know the list of archs and bsps that support the new > interrupt manager directives. Maybe it would be good to list them? Yes. And since you don't know the bsps which don't have the support, what will the tests do? > > I noticed an issue with the thread restart on aarch64/a53_lp64_qemu. I passed this along to Kinsey but it would be helpful if you could start a thread/ticket about this so he knows what to look at. > > > > On powerpc/psim there is an issue in one test case, due to: > > > > #define CPU_ALL_TASKS_ARE_FP CPU_HARDWARE_FP > > Sorry, I am not following what the issue is? Does this effect all PPC BSPS? > > > Another issue is that the tm27 interrupt must be independent of the clock driver > > interrupt. This is not the case for powerpc/psim. This is a change in the design from the original assumptions over 30 years ago. It will break more than psim. Many boards do not have a second source for a counter/timer and it was assumed that the clock hardware could be used since the tmtests do not configure a clock driver. What exactly broke this? > > > > There is definitely some work left to cover all edge cases. Some tests are quite > > complicated. > > Sure. I would like to understand the effects this has? > > >> Is there anything that interprets the new test output format? It looks like lots > >> of great info but a little difficult to read. > > > > EDISOFT worked on a test report generator, however, it is not yet in a > > reviewable state. > > OK. I think something that handles this data would be good to have. > > >>> Some low memory targets are not able to link all test suites. > >> > >> Are these excluded in the normal way? > > > > Yes: > > > > https://github.com/sebhub/rtems/commit/2feedb9e7805f483e35b7914b9bd7c808e31a8b4#diff-bf7b325198d4133c9e52f49d77447905ecd3c6ac5159d5cd85e7efeffa6da47e > > Nice. > > This looks really good and I like what it provides. It is a fantastic baseline > of the interfaces we have however to be useful long term it needs to generate > regression notices and so that means we need to know and understand the > baselines this brings us now and for which arches. Somewhere in this discussion was mention of coverage results. It was mentioned that branches were covered but I would appreciate that being clarified. Is this at the source level or assembly level? How is this done? Is the procedure documented? The coverage reports from rtems-test/covoar are at the assembly language level and report on branch statements being taken and not taken. This is intended to help us exceed MCDC testing. I know you posted some gcov support patches earlier so am guessing that you used that. Some insight would be great. Thanks. --joel > > Chris > _______________________________________________ > devel mailing list > devel at rtems.org > http://lists.rtems.org/mailman/listinfo/devel From kinsey.moore at oarcorp.com Wed Dec 15 16:05:36 2021 From: kinsey.moore at oarcorp.com (Kinsey Moore) Date: Wed, 15 Dec 2021 10:05:36 -0600 Subject: [PATCH rtems-libbsd] Import arm64 in_cksum.h correctly Message-ID: <20211215160536.36884-1-kinsey.moore@oarcorp.com> When this file was brought in, it came from the wrong location or freebsd-org hash. This corrects the file such that freebsd-to-rtems.py runs cleanly. --- freebsd/sys/arm64/include/machine/in_cksum.h | 43 +++----------------- 1 file changed, 6 insertions(+), 37 deletions(-) diff --git a/freebsd/sys/arm64/include/machine/in_cksum.h b/freebsd/sys/arm64/include/machine/in_cksum.h index d55b838b..522ba005 100644 --- a/freebsd/sys/arm64/include/machine/in_cksum.h +++ b/freebsd/sys/arm64/include/machine/in_cksum.h @@ -1,6 +1,4 @@ /*- - * SPDX-License-Identifier: BSD-3-Clause - * * Copyright (c) 1990 The Regents of the University of California. * All rights reserved. * @@ -31,7 +29,6 @@ * from tahoe: in_cksum.c 1.2 86/01/05 * from: @(#)in_cksum.c 1.3 (Berkeley) 1/19/91 * from: Id: in_cksum.c,v 1.8 1995/12/03 18:35:19 bde Exp - * from: src/sys/alpha/include/in_cksum.h,v 1.7 2005/03/02 21:33:20 joerg * $FreeBSD$ */ @@ -40,44 +37,16 @@ #include +#ifdef _KERNEL #define in_cksum(m, len) in_cksum_skip(m, len, 0) - +u_short in_addword(u_short sum, u_short b); +u_short in_cksum_skip(struct mbuf *m, int len, int skip); +u_int do_cksum(const void *, int); #if defined(IPVERSION) && (IPVERSION == 4) -/* - * It it useful to have an Internet checksum routine which is inlineable - * and optimized specifically for the task of computing IP header checksums - * in the normal case (where there are no options and the header length is - * therefore always exactly five 32-bit words. - */ -#ifdef __CC_SUPPORTS___INLINE - -static __inline void -in_cksum_update(struct ip *ip) -{ - int __tmpsum; - __tmpsum = (int)ntohs(ip->ip_sum) + 256; - ip->ip_sum = htons(__tmpsum + (__tmpsum >> 16)); -} - -#else - -#define in_cksum_update(ip) \ - do { \ - int __tmpsum; \ - __tmpsum = (int)ntohs(ip->ip_sum) + 256; \ - ip->ip_sum = htons(__tmpsum + (__tmpsum >> 16)); \ - } while(0) - -#endif +u_int in_cksum_hdr(const struct ip *); #endif -#ifdef _KERNEL -#if defined(IPVERSION) && (IPVERSION == 4) -u_int in_cksum_hdr(const struct ip *ip); -#endif -u_short in_addword(u_short sum, u_short b); u_short in_pseudo(u_int sum, u_int b, u_int c); -u_short in_cksum_skip(struct mbuf *m, int len, int skip); -#endif +#endif /* _KERNEL */ #endif /* _MACHINE_IN_CKSUM_H_ */ -- 2.30.2 From sebastian.huber at embedded-brains.de Wed Dec 15 16:27:19 2021 From: sebastian.huber at embedded-brains.de (Sebastian Huber) Date: Wed, 15 Dec 2021 17:27:19 +0100 Subject: New validation test suites In-Reply-To: References: <5c4d51cb-660d-93ec-7a59-4a98be61d4c1@embedded-brains.de> <514bddac-9f20-5fa6-52a0-57c8f8787c82@rtems.org> <6f5145de-94f8-1984-5590-fb05741d282b@embedded-brains.de> Message-ID: <1f6a827e-818b-5e54-6e8c-98d28a22c25e@embedded-brains.de> On 15/12/2021 06:46, Chris Johns wrote: > On 14/12/21 6:24 pm, Sebastian Huber wrote: >> Hello Chris, >> >> On 13/12/2021 22:01, Chris Johns wrote: >>> On 14/12/21 1:53 am, Sebastian Huber wrote: [...] >>>> We finished the specification of the pre-qualified RTEMS feature set. The >>>> specification is available in an RTEMS Project repository: >>>> >>>> https://git.rtems.org/rtems-central/tree/spec >>> >>> I had a quick look. Is there a more user friendly view of this data? >>> >>> I think the term "specification" is a little bit misleading because the data >>> files are not easily read by a person. I understand this is the specification >>> data set however it is not what I am traditionally use to seeing. >> >> You can use the "./specview.py" script to get views of the specification.? For >> example, this command displays the transition map for the rtems_signal_send() >> directive: > > Is specview.py part of rtems.git? No, this script is in rtems-central. This is also the location of the specification items. > > If not part of rtems.git how much data is there for all the output? That is it > is generated and held in the repo with the tests? In rtems.git, there are only the generated sources. [...] >>>> The validation tests are generated from the specification using the >>>> "./spec2modules.py" script and end up in the RTEMS sources of a Git submodule. I >>>> think the specification and the generation tool is now sufficiently stable so >>>> that the validation test code can be integrated in the RTEMS master branch. The >>>> patch set is too big for the mailing list, so you can review it here: >>>> >>>> https://git.rtems.org/sebh/rtems.git/log/?h=validation >>> >>> The link failed. >> >> Yes, viewing my personal repository no longer works.? I am not sure if this is a >> temporary issue.? This is why I added the github link. > > It seems to have been temporary. It is back again. > >> >>> >>>> https://github.com/sebhub/rtems/tree/validation >>> >>> The header in a test says the regeneration instructions are in the engineering >>> manual but I could not quickly find them? >> >> https://docs.rtems.org/branches/master/eng/req/howto.html#generate-content-after-changes >> >> >> In an earlier version of the header, we had a link which you didn't like: > > If I need to look at the formatting rules the heading "Software Development > Management" is easy to see and then a click on "Coding Standards" gives me what > I am looking for. > > To generate these headers I click on "Software Requirements Engineering" and > then do I just guess until I find it in the "How To" section? I am actually > asking this be sorted out so it is not left hanging and we are not left guessing > what to do. If it can be rearrange into something meaningful it would help. :) Well, if you read the text in the header: * For information on updating and regenerating please refer to the How-To * section in the Software Requirements Engineering chapter of the * RTEMS Software Engineering manual. The manual is provided as a part of * a release. For development sources please refer to the online * documentation at: * * https://docs.rtems.org You should read the How-to section or not? [...] >>> What hardware have the validation tests been run on? Any tier 1 archs? >> >> I tested with the sparc/leon3 BSPs and the arm/realview_pbx_a9_qemu. > > Is the leon3 tested on hardware or simulation? > >> You need a >> full implementation of the new Interrupt Manager directives and a working Cache >> Manager implementation. > > Is this documented? > > I am sorry I do not know the list of archs and bsps that support the new > interrupt manager directives. Maybe it would be good to list them? All BSPs have at least a stub implementation of the new directives. The directives are tested in a dedicated test suite. You will notice failures in this test suite if the directives are not implemented. > >> I noticed an issue with the thread restart on aarch64/a53_lp64_qemu. >> >> On powerpc/psim there is an issue in one test case, due to: >> >> #define CPU_ALL_TASKS_ARE_FP CPU_HARDWARE_FP > > Sorry, I am not following what the issue is? Does this effect all PPC BSPS? Not all, the newer BSPs have no separate floating-point context. This is something which needs to be fixed in the specification. From my point of view this is just a minor issue. > >> Another issue is that the tm27 interrupt must be independent of the clock driver >> interrupt.? This is not the case for powerpc/psim. >> >> There is definitely some work left to cover all edge cases. Some tests are quite >> complicated. > > Sure. I would like to understand the effects this has? Maybe I can rearrange the test cases so that the tm27 support is only used if no clock driver is needed. The tm27 support is used to run handlers in interrupt context. > >>> Is there anything that interprets the new test output format? It looks like lots >>> of great info but a little difficult to read. >> >> EDISOFT worked on a test report generator, however, it is not yet in a >> reviewable state. > > OK. I think something that handles this data would be good to have. Yes, maybe we could let a student work on this. In theory, this is not difficult. Read the report.yaml generated by the RTEMS Tester and convert it to a Python objects representation. Then use this high-level representation to generate a report in format X. [...] -- embedded brains GmbH Herr Sebastian HUBER Dornierstr. 4 82178 Puchheim Germany email: sebastian.huber at embedded-brains.de phone: +49-89-18 94 741 - 16 fax: +49-89-18 94 741 - 08 Registergericht: Amtsgericht M?nchen Registernummer: HRB 157899 Vertretungsberechtigte Gesch?ftsf?hrer: Peter Rasmussen, Thomas D?rfler Unsere Datenschutzerkl?rung finden Sie hier: https://embedded-brains.de/datenschutzerklaerung/ From sebastian.huber at embedded-brains.de Wed Dec 15 16:41:24 2021 From: sebastian.huber at embedded-brains.de (Sebastian Huber) Date: Wed, 15 Dec 2021 17:41:24 +0100 Subject: New validation test suites In-Reply-To: References: <5c4d51cb-660d-93ec-7a59-4a98be61d4c1@embedded-brains.de> <514bddac-9f20-5fa6-52a0-57c8f8787c82@rtems.org> <6f5145de-94f8-1984-5590-fb05741d282b@embedded-brains.de> Message-ID: On 15/12/2021 17:01, Joel Sherrill wrote: > I waited to reply because Chris got most of my questions in his first > response. :) > > On Tue, Dec 14, 2021 at 11:46 PM Chris Johns wrote: >> >> On 14/12/21 6:24 pm, Sebastian Huber wrote: >>> Hello Chris, >>> >>> On 13/12/2021 22:01, Chris Johns wrote: >>>> On 14/12/21 1:53 am, Sebastian Huber wrote: >>>>> Hello, >>>>> >>>>> the ESA activity to pre-qualify parts of RTEMS according to ECSS requirements is >>>>> nearly complete. There is a short presentation available here: >>>>> >>>>> https://indico.esa.int/event/374/timetable/ >>>> >>>> Was the change in memory usage for 4.8 of 23812 bytes to 68896 explained? >>> >>> The foot print increase has mainly five reasons: >>> >>> * General GCC code generation >>> >>> * Chip errata workarounds done by GCC >>> >>> * More features used from RTEMS (for example uniprocessor synchronization done >>> via task priorities vs. mutex synchronization) >>> >>> * SMP support of RTEMS >>> >>> * New RTEMS features such as transitive priority inheritance >>> >> >> Thanks. > > If the 4.8 size was based on the Edisoft version, it was also > stripped of functionality even within methods in RTEMS itself. > Combine that with uniprocessor vs SMP and more robust > algorithms in the current RTEMS and it creeps up. > > It would be interesting to see a straight uniprocessor comparison > but even that would not have feature parity. I didn't have time to do a thorough comparison. The above numbers are obtain from totally different applications. Anyway, reducing the code size would be a difficult task. [...] >>>> The header in a test says the regeneration instructions are in the engineering >>>> manual but I could not quickly find them? >>> >>> https://docs.rtems.org/branches/master/eng/req/howto.html#generate-content-after-changes >>> >>> >>> In an earlier version of the header, we had a link which you didn't like: >> >> If I need to look at the formatting rules the heading "Software Development >> Management" is easy to see and then a click on "Coding Standards" gives me what >> I am looking for. >> >> To generate these headers I click on "Software Requirements Engineering" and >> then do I just guess until I find it in the "How To" section? I am actually >> asking this be sorted out so it is not left hanging and we are not left guessing >> what to do. If it can be rearrange into something meaningful it would help. :) > > Have you had anyone not directly involved in the generation process > try this from the instructions? That always seems to be when the > holes show up. Frank was able to specify (and test) the Timer Manager, Clock Manager, Rate-Monotonic Manager, and Message Manager. You need a bit of time to get accustomed to the work flow. However, the table based specification worked really well for the project. > >>> commit a6689fb147649a29ff5533cec8a53635e2c95ec6 >>> Author: Sebastian Huber >>> Date: Fri Jan 22 16:01:46 2021 +0100 >>> >>> Improve file header comment in generated files >>> >>> diff --git a/cpukit/include/rtems/rtems/types.h >>> b/cpukit/include/rtems/rtems/types.h >>> index 32b45113c8..a058eedea1 100644 >>> --- a/cpukit/include/rtems/rtems/types.h >>> +++ b/cpukit/include/rtems/rtems/types.h >>> @@ -38,11 +38,15 @@ >>> * worded better please post a report or patch to an RTEMS mailing list >>> * or raise a bug report: >>> * >>> - * https://docs.rtems.org/branches/master/user/support/bugs.html >>> + * https://www.rtems.org/bugs.html >>> * >>> - * For information on updating and regenerating please refer to: >>> + * For information on updating and regenerating please refer to the How-To >>> + * section in the Software Requirements Engineering chapter of the >>> + * RTEMS Software Engineering manual. The manual is provided as a part of >>> + * a release. For development sources please refer to the online >>> + * documentation at: >>> * >>> - * https://docs.rtems.org/branches/master/eng/req/howto.html >>> + * https://docs.rtems.org >>> */ >>> >>> /* Generated from spec:/rtems/type/if/header */ >>> >> >> I am fine with the header, as we know links to the documentation is really hard >> long term. > > Early on, we discussed some annotation maybe like SPDX to > note that a file had higher rigor with requirements and tests. > Is this Generated note implying this? Is it sufficient to note that > if you touch this, we would really like you to address the full > chain on this? Yes, this would be great. If you modify API header files through specification items, then you get for example an up to date RTEMS Classic API Guide automatically. > >>>>> The patch set is organized so that general support code for the validation tests >>>>> is added first and then there are commits for each pre-qualified Classic API >>>>> Manager or subsystem. >>>>> >>>>> I did build all BSPs with the patch set. The validation tests use only >>>>> statically allocated resources. >>>> >>>> Are the validation tests compatible with rtems-test? >>> >>> Yes. >> >> Great. >> >>>> How many test executables does this add to the testsuite? >>> >>> If RTEMS_SMP is disabled, then there are 19 new executables in the patch set. If >>> RTEMS_SMP is enable, then there are 28 new executables. >> >> Nice. >> >>>> What hardware have the validation tests been run on? Any tier 1 archs? >>> >>> I tested with the sparc/leon3 BSPs and the arm/realview_pbx_a9_qemu. >> >> Is the leon3 tested on hardware or simulation? >> >>> You need a >>> full implementation of the new Interrupt Manager directives and a working Cache >>> Manager implementation. >> >> Is this documented? >> >> I am sorry I do not know the list of archs and bsps that support the new >> interrupt manager directives. Maybe it would be good to list them? > > Yes. And since you don't know the bsps which don't have the support, > what will the tests do? Some tests fail. >>> I noticed an issue with the thread restart on aarch64/a53_lp64_qemu. > > I passed this along to Kinsey but it would be helpful if you could start > a thread/ticket about this so he knows what to look at. > >>> >>> On powerpc/psim there is an issue in one test case, due to: >>> >>> #define CPU_ALL_TASKS_ARE_FP CPU_HARDWARE_FP >> >> Sorry, I am not following what the issue is? Does this effect all PPC BSPS? >> >>> Another issue is that the tm27 interrupt must be independent of the clock driver >>> interrupt. This is not the case for powerpc/psim. > > This is a change in the design from the original assumptions over 30 years > ago. It will break more than psim. Many boards do not have a second source > for a counter/timer and it was assumed that the clock hardware could be > used since the tmtests do not configure a clock driver. > > What exactly broke this? We don't need a second counter/timer. We just need a software generated interrupt. Maybe I can rearrange the test cases so that the tm27 is only used if no clock driver is needed. > > >>> >>> There is definitely some work left to cover all edge cases. Some tests are quite >>> complicated. >> >> Sure. I would like to understand the effects this has? >> >>>> Is there anything that interprets the new test output format? It looks like lots >>>> of great info but a little difficult to read. >>> >>> EDISOFT worked on a test report generator, however, it is not yet in a >>> reviewable state. >> >> OK. I think something that handles this data would be good to have. >> >>>>> Some low memory targets are not able to link all test suites. >>>> >>>> Are these excluded in the normal way? >>> >>> Yes: >>> >>> https://github.com/sebhub/rtems/commit/2feedb9e7805f483e35b7914b9bd7c808e31a8b4#diff-bf7b325198d4133c9e52f49d77447905ecd3c6ac5159d5cd85e7efeffa6da47e >> >> Nice. >> >> This looks really good and I like what it provides. It is a fantastic baseline >> of the interfaces we have however to be useful long term it needs to generate >> regression notices and so that means we need to know and understand the >> baselines this brings us now and for which arches. > > Somewhere in this discussion was mention of coverage results. > It was mentioned that branches were covered but I would appreciate > that being clarified. Is this at the source level or assembly level? > How is this done? Is the procedure documented? I still have a long RTEMS integration TODO list. The gcov support is just one item. We achieved 100% line and branch coverage at source code level (-O0 with gcov) on a system with at least three processors (about 99.8% on a system with two processors). > > The coverage reports from rtems-test/covoar are at the assembly > language level and report on branch statements being taken and > not taken. This is intended to help us exceed MCDC testing. It would be good to get the coverage data also with -O2 without gcov. So far I haven't figured out how to do this with rtems-test/covoar. I think -O2 without gcov is the better approach, but ESA wanted -O0 with gcov. > > I know you posted some gcov support patches earlier so am guessing > that you used that. Some insight would be great. In general, the gcov support works really nice. After the test run, the gcov information is printed out via the serial test interface. On the host you can read it and convert it to *.gcda files. -- embedded brains GmbH Herr Sebastian HUBER Dornierstr. 4 82178 Puchheim Germany email: sebastian.huber at embedded-brains.de phone: +49-89-18 94 741 - 16 fax: +49-89-18 94 741 - 08 Registergericht: Amtsgericht M?nchen Registernummer: HRB 157899 Vertretungsberechtigte Gesch?ftsf?hrer: Peter Rasmussen, Thomas D?rfler Unsere Datenschutzerkl?rung finden Sie hier: https://embedded-brains.de/datenschutzerklaerung/ From alex.white at oarcorp.com Wed Dec 15 21:32:52 2021 From: alex.white at oarcorp.com (Alex White) Date: Wed, 15 Dec 2021 15:32:52 -0600 Subject: [PATCH rtems-tools 5 1/5] rtemstoolkit/mailer.py: Return full smtp-host arg value In-Reply-To: <20211215213256.189992-1-alex.white@oarcorp.com> References: <20211215213256.189992-1-alex.white@oarcorp.com> Message-ID: <20211215213256.189992-2-alex.white@oarcorp.com> This fixes mail.smtp_host() so that it returns the full argument value rather than just the second character. Updates #4553 --- rtemstoolkit/mailer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rtemstoolkit/mailer.py b/rtemstoolkit/mailer.py index f8f813c..3ea9d98 100644 --- a/rtemstoolkit/mailer.py +++ b/rtemstoolkit/mailer.py @@ -123,7 +123,7 @@ class mail: def smtp_host(self): host = self._get_arg('--smtp-host') if host is not None: - return host[1] + return host if self._args_are_macros(): host = self.opts.defaults.get_value('%{_mail_smtp_host}') if host is not None: -- 2.27.0 From alex.white at oarcorp.com Wed Dec 15 21:32:53 2021 From: alex.white at oarcorp.com (Alex White) Date: Wed, 15 Dec 2021 15:32:53 -0600 Subject: [PATCH rtems-tools 5 2/5] rtemstoolkit: Filter mail options from log output In-Reply-To: <20211215213256.189992-1-alex.white@oarcorp.com> References: <20211215213256.189992-1-alex.white@oarcorp.com> Message-ID: <20211215213256.189992-3-alex.white@oarcorp.com> This filters mail-related options out before logging the command line options. This is needed to prevent leaking potentially sensitive information via logs and emails. Updates #4553 --- rtemstoolkit/options.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/rtemstoolkit/options.py b/rtemstoolkit/options.py index 32a7016..5ebe3bc 100644 --- a/rtemstoolkit/options.py +++ b/rtemstoolkit/options.py @@ -508,7 +508,22 @@ class command_line(object): return None def log_info(self): - log.output(log.info(self.argv)) + # Filter potentially sensitive mail options out. + filtered_args = [ + arg for arg in self.argv + if all( + smtp_opt not in arg + for smtp_opt in [ + '--smtp-host', + '--mail-to', + '--mail-from', + '--smtp-user', + '--smtp-password', + '--smtp-port' + ] + ) + ] + log.output(log.info(filtered_args)) def load(opts): """ -- 2.27.0 From alex.white at oarcorp.com Wed Dec 15 21:32:51 2021 From: alex.white at oarcorp.com (Alex White) Date: Wed, 15 Dec 2021 15:32:51 -0600 Subject: [PATCH rtems-tools 5 0/5] Port mailer.py fixes to rtems-tools 5 branch Message-ID: <20211215213256.189992-1-alex.white@oarcorp.com> Hi, This patch set adds the changes related to report mailing to rtems-tools 5. See #4553 Thanks, Alex White Alex White (5): rtemstoolkit/mailer.py: Return full smtp-host arg value rtemstoolkit: Filter mail options from log output rtemstoolkit/mailer.py: Add SMTP login options rtemstoolkit/mailer.py: Add --use-gitconfig option rtems-bsp-builder: Fix mail support rtemstoolkit/mailer.py | 86 +++++++++++++++++++++++++++++++++++++---- rtemstoolkit/options.py | 17 +++++++- tester/rt/check.py | 17 +++++++- 3 files changed, 111 insertions(+), 9 deletions(-) -- 2.27.0 From alex.white at oarcorp.com Wed Dec 15 21:32:54 2021 From: alex.white at oarcorp.com (Alex White) Date: Wed, 15 Dec 2021 15:32:54 -0600 Subject: [PATCH rtems-tools 5 3/5] rtemstoolkit/mailer.py: Add SMTP login options In-Reply-To: <20211215213256.189992-1-alex.white@oarcorp.com> References: <20211215213256.189992-1-alex.white@oarcorp.com> Message-ID: <20211215213256.189992-4-alex.white@oarcorp.com> This adds more options so that the user can authenticate with the SMTP server. Updates #4553 --- rtemstoolkit/mailer.py | 41 +++++++++++++++++++++++++++++++++++------ 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/rtemstoolkit/mailer.py b/rtemstoolkit/mailer.py index 3ea9d98..aa804ae 100644 --- a/rtemstoolkit/mailer.py +++ b/rtemstoolkit/mailer.py @@ -43,10 +43,13 @@ from rtemstoolkit import options from rtemstoolkit import path _options = { - '--mail' : 'Send email report or results.', - '--smtp-host': 'SMTP host to send via.', - '--mail-to' : 'Email address to send the email too.', - '--mail-from': 'Email address the report is from.' + '--mail' : 'Send email report or results.', + '--mail-to' : 'Email address to send the email to.', + '--mail-from' : 'Email address the report is from.', + '--smtp-host' : 'SMTP host to send via.', + '--smtp-port' : 'SMTP port to send via.', + '--smtp-user' : 'User for SMTP authentication.', + '--smtp-password': 'Password for SMTP authentication.' } def append_options(opts): @@ -55,7 +58,7 @@ def append_options(opts): def add_arguments(argsp): argsp.add_argument('--mail', help = _options['--mail'], action = 'store_true') - for o in ['--smtp-host', '--mail-to', '--mail-from']: + for o in list(_options)[1:]: argsp.add_argument(o, help = _options[o], type = str) class mail: @@ -130,12 +133,38 @@ class mail: return host return 'localhost' + def smtp_port(self): + port = self._get_arg('--smtp-port') + if port is not None: + return port + if self._args_are_macros(): + port = self.opts.defaults.get_value('%{_mail_smtp_port}') + return port + + def smtp_user(self): + return self._get_arg('--smtp-user') + + def smtp_password(self): + return self._get_arg('--smtp-password') + def send(self, to_addr, subject, body): from_addr = self.from_address() msg = "From: %s\r\nTo: %s\r\nSubject: %s\r\n\r\n" % \ (from_addr, to_addr, subject) + body + port = self.smtp_port() + try: - s = smtplib.SMTP(self.smtp_host()) + s = smtplib.SMTP(self.smtp_host(), port, timeout=10) + + password = self.smtp_password() + # If a password is provided, assume that authentication is required. + if password is not None: + user = self.smtp_user() + if user is None: + user = from_addr + s.starttls() + s.login(user, password) + s.sendmail(from_addr, [to_addr], msg) except smtplib.SMTPException as se: raise error.general('sending mail: %s' % (str(se))) -- 2.27.0 From alex.white at oarcorp.com Wed Dec 15 21:32:55 2021 From: alex.white at oarcorp.com (Alex White) Date: Wed, 15 Dec 2021 15:32:55 -0600 Subject: [PATCH rtems-tools 5 4/5] rtemstoolkit/mailer.py: Add --use-gitconfig option In-Reply-To: <20211215213256.189992-1-alex.white@oarcorp.com> References: <20211215213256.189992-1-alex.white@oarcorp.com> Message-ID: <20211215213256.189992-5-alex.white@oarcorp.com> This adds the option to pull mail-related configuration values from the user's git configuration. Updates #4553 --- rtemstoolkit/mailer.py | 46 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/rtemstoolkit/mailer.py b/rtemstoolkit/mailer.py index aa804ae..ae51d78 100644 --- a/rtemstoolkit/mailer.py +++ b/rtemstoolkit/mailer.py @@ -39,11 +39,13 @@ import smtplib import socket from rtemstoolkit import error +from rtemstoolkit import execute from rtemstoolkit import options from rtemstoolkit import path _options = { '--mail' : 'Send email report or results.', + '--use-gitconfig': 'Use mail configuration from git config.', '--mail-to' : 'Email address to send the email to.', '--mail-from' : 'Email address the report is from.', '--smtp-host' : 'SMTP host to send via.', @@ -58,12 +60,22 @@ def append_options(opts): def add_arguments(argsp): argsp.add_argument('--mail', help = _options['--mail'], action = 'store_true') + argsp.add_argument('--use-gitconfig', help = _options['--use-gitconfig'], action = 'store_true') for o in list(_options)[1:]: argsp.add_argument(o, help = _options[o], type = str) class mail: def __init__(self, opts): self.opts = opts + self.gitconfig_lines = None + if opts.find_arg('--use-gitconfig') is not None: + # Read the output of `git config --list` instead of reading the + # .gitconfig file directly because Python 2 ConfigParser does not + # accept tabs at the beginning of lines. + e = execute.capture_execution() + exit_code, proc, output = e.open('git config --list', shell=True) + if exit_code == 0: + self.gitconfig_lines = output.split(os.linesep) def _args_are_macros(self): return isinstance(self.opts, options.command_line) @@ -83,6 +95,16 @@ class mail: value = None return value + def _get_from_gitconfig(self, variable_name): + if self.gitconfig_lines is None: + return None + + for line in self.gitconfig_lines: + if line.startswith(variable_name): + ls = line.split('=') + if len(ls) >= 2: + return ls[1] + def from_address(self): def _clean(l): @@ -97,6 +119,12 @@ class mail: addr = self._get_arg('--mail-from') if addr is not None: return addr + addr = self._get_from_gitconfig('user.email') + if addr is not None: + name = self._get_from_gitconfig('user.name') + if name is not None: + addr = '%s <%s>' % (name, addr) + return addr mailrc = None if 'MAILRC' in os.environ: mailrc = os.environ['MAILRC'] @@ -125,6 +153,9 @@ class mail: def smtp_host(self): host = self._get_arg('--smtp-host') + if host is not None: + return host + host = self._get_from_gitconfig('sendemail.smtpserver') if host is not None: return host if self._args_are_macros(): @@ -135,6 +166,9 @@ class mail: def smtp_port(self): port = self._get_arg('--smtp-port') + if port is not None: + return port + port = self._get_from_gitconfig('sendemail.smtpserverport') if port is not None: return port if self._args_are_macros(): @@ -142,10 +176,18 @@ class mail: return port def smtp_user(self): - return self._get_arg('--smtp-user') + user = self._get_arg('--smtp-user') + if user is not None: + return user + user = self._get_from_gitconfig('sendemail.smtpuser') + return user def smtp_password(self): - return self._get_arg('--smtp-password') + password = self._get_arg('--smtp-password') + if password is not None: + return password + password = self._get_from_gitconfig('sendemail.smtppass') + return password def send(self, to_addr, subject, body): from_addr = self.from_address() -- 2.27.0 From alex.white at oarcorp.com Wed Dec 15 21:32:56 2021 From: alex.white at oarcorp.com (Alex White) Date: Wed, 15 Dec 2021 15:32:56 -0600 Subject: [PATCH rtems-tools 5 5/5] rtems-bsp-builder: Fix mail support In-Reply-To: <20211215213256.189992-1-alex.white@oarcorp.com> References: <20211215213256.189992-1-alex.white@oarcorp.com> Message-ID: <20211215213256.189992-6-alex.white@oarcorp.com> This fixes a problem with mailer options support that occurred because check.py uses argparse.ArgumentParser instead of tester.rt.options. Closes #4553 --- rtemstoolkit/mailer.py | 5 +++-- tester/rt/check.py | 17 ++++++++++++++++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/rtemstoolkit/mailer.py b/rtemstoolkit/mailer.py index ae51d78..09e4a26 100644 --- a/rtemstoolkit/mailer.py +++ b/rtemstoolkit/mailer.py @@ -61,14 +61,15 @@ def append_options(opts): def add_arguments(argsp): argsp.add_argument('--mail', help = _options['--mail'], action = 'store_true') argsp.add_argument('--use-gitconfig', help = _options['--use-gitconfig'], action = 'store_true') - for o in list(_options)[1:]: + no_add = ['--mail', '--use-gitconfig'] + for o in [opt for opt in list(_options) if opt not in no_add]: argsp.add_argument(o, help = _options[o], type = str) class mail: def __init__(self, opts): self.opts = opts self.gitconfig_lines = None - if opts.find_arg('--use-gitconfig') is not None: + if self._get_arg('--use-gitconfig'): # Read the output of `git config --list` instead of reading the # .gitconfig file directly because Python 2 ConfigParser does not # accept tabs at the beginning of lines. diff --git a/tester/rt/check.py b/tester/rt/check.py index 2a38d99..deac19d 100755 --- a/tester/rt/check.py +++ b/tester/rt/check.py @@ -105,7 +105,22 @@ def title(): return 'RTEMS Tools Project - RTEMS Kernel BSP Builder, %s' % (version.string()) def command_line(): - return wrap(('command: ', ' '.join(sys.argv)), lineend = '\\') + # Filter potentially sensitive mail options out. + filtered_args = [ + arg for arg in sys.argv + if all( + smtp_opt not in arg + for smtp_opt in [ + '--smtp-host', + '--mail-to', + '--mail-from', + '--smtp-user', + '--smtp-password', + '--smtp-port' + ] + ) + ] + return wrap(('command: ', ' '.join(filtered_args)), lineend = '\\') def jobs_option_parse(jobs_option): try: -- 2.27.0 From alex.white at oarcorp.com Wed Dec 15 21:38:00 2021 From: alex.white at oarcorp.com (Alex White) Date: Wed, 15 Dec 2021 15:38:00 -0600 Subject: [PATCH RSB 5] sb: Merge mailer changes from rtems-tools Message-ID: <20211215213800.191302-1-alex.white@oarcorp.com> This adds the improved mailer.py script from rtems-tools. Closes #4554 --- source-builder/sb/mailer.py | 194 +++++++++++++++++++++++++++++++++------- source-builder/sb/options.py | 26 +++++- source-builder/sb/setbuilder.py | 2 + 3 files changed, 189 insertions(+), 33 deletions(-) diff --git a/source-builder/sb/mailer.py b/source-builder/sb/mailer.py index 42b4fa6..1d3cbb5 100644 --- a/source-builder/sb/mailer.py +++ b/source-builder/sb/mailer.py @@ -1,21 +1,33 @@ # # RTEMS Tools Project (http://www.rtems.org/) -# Copyright 2013 Chris Johns (chrisj at rtems.org) +# Copyright 2013-2016 Chris Johns (chrisj at rtems.org) +# Copyright (C) 2021 On-Line Applications Research Corporation (OAR) # All rights reserved. # # This file is part of the RTEMS Tools package in 'rtems-tools'. # -# Permission to use, copy, modify, and/or distribute this software for any -# purpose with or without fee is hereby granted, provided that the above -# copyright notice and this permission notice appear in all copies. +# 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 HOLDER 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. # -# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. # # Manage emailing results or reports. @@ -28,18 +40,72 @@ import smtplib import socket import error +import execute import options import path +_options = { + '--mail' : 'Send email report or results.', + '--use-gitconfig': 'Use mail configuration from git config.', + '--mail-to' : 'Email address to send the email to.', + '--mail-from' : 'Email address the report is from.', + '--smtp-host' : 'SMTP host to send via.', + '--smtp-port' : 'SMTP port to send via.', + '--smtp-user' : 'User for SMTP authentication.', + '--smtp-password': 'Password for SMTP authentication.' +} + def append_options(opts): - opts['--mail'] = 'Send email report or results.' - opts['--smtp-host'] = 'SMTP host to send via.' - opts['--mail-to'] = 'Email address to send the email too.' - opts['--mail-from'] = 'Email address the report is from.' + for o in _options: + opts[o] = _options[o] + +def add_arguments(argsp): + argsp.add_argument('--mail', help = _options['--mail'], action = 'store_true') + argsp.add_argument('--use-gitconfig', help = _options['--use-gitconfig'], action = 'store_true') + no_add = ['--mail', '--use-gitconfig'] + for o in [opt for opt in list(_options) if opt not in no_add]: + argsp.add_argument(o, help = _options[o], type = str) class mail: def __init__(self, opts): self.opts = opts + self.gitconfig_lines = None + if opts.find_arg('--use-gitconfig') is not None: + # Read the output of `git config --list` instead of reading the + # .gitconfig file directly because Python 2 ConfigParser does not + # accept tabs at the beginning of lines. + e = execute.capture_execution() + exit_code, proc, output = e.open('git config --list', shell=True) + if exit_code == 0: + self.gitconfig_lines = output.split(os.linesep) + + def _args_are_macros(self): + return isinstance(self.opts, options.command_line) + + def _get_arg(self, arg): + if self._args_are_macros(): + value = self.opts.find_arg(arg) + if value is not None: + value = self.opts.find_arg(arg)[1] + else: + if arg.startswith('--'): + arg = arg[2:] + arg = arg.replace('-', '_') + if arg in vars(self.opts): + value = vars(self.opts)[arg] + else: + value = None + return value + + def _get_from_gitconfig(self, variable_name): + if self.gitconfig_lines is None: + return None + + for line in self.gitconfig_lines: + if line.startswith(variable_name): + ls = line.split('=') + if len(ls) >= 2: + return ls[1] def from_address(self): @@ -52,9 +118,15 @@ class mail: l = l[:l.index('\n')] return l.strip() - addr = self.opts.get_arg('--mail-from') + addr = self._get_arg('--mail-from') if addr is not None: - return addr[1] + return addr + addr = self._get_from_gitconfig('user.email') + if addr is not None: + name = self._get_from_gitconfig('user.name') + if name is not None: + addr = '%s <%s>' % (name, addr) + return addr mailrc = None if 'MAILRC' in os.environ: mailrc = os.environ['MAILRC'] @@ -63,9 +135,8 @@ class mail: if mailrc is not None and path.exists(mailrc): # set from="Joe Blow " try: - mrc = open(mailrc, 'r') - lines = mrc.readlines() - mrc.close() + with open(mailrc, 'r') as mrc: + lines = mrc.readlines() except IOError as err: raise error.general('error reading: %s' % (mailrc)) for l in lines: @@ -76,40 +147,99 @@ class mail: addr = fa[fa.index('=') + 1:].replace('"', ' ').strip() if addr is not None: return addr - addr = self.opts.defaults.get_value('%{_sbgit_mail}') + if self._args_are_macros(): + addr = self.opts.defaults.get_value('%{_sbgit_mail}') + else: + raise error.general('no valid from address for mail') return addr def smtp_host(self): - host = self.opts.get_arg('--smtp-host') + host = self._get_arg('--smtp-host') if host is not None: - return host[1] - host = self.opts.defaults.get_value('%{_mail_smtp_host}') + return host + host = self._get_from_gitconfig('sendemail.smtpserver') + if host is not None: + return host + if self._args_are_macros(): + host = self.opts.defaults.get_value('%{_mail_smtp_host}') if host is not None: return host return 'localhost' + def smtp_port(self): + port = self._get_arg('--smtp-port') + if port is not None: + return port + port = self._get_from_gitconfig('sendemail.smtpserverport') + if port is not None: + return port + if self._args_are_macros(): + port = self.opts.defaults.get_value('%{_mail_smtp_port}') + return port + + def smtp_user(self): + user = self._get_arg('--smtp-user') + if user is not None: + return user + user = self._get_from_gitconfig('sendemail.smtpuser') + return user + + def smtp_password(self): + password = self._get_arg('--smtp-password') + if password is not None: + return password + password = self._get_from_gitconfig('sendemail.smtppass') + return password + def send(self, to_addr, subject, body): from_addr = self.from_address() msg = "From: %s\r\nTo: %s\r\nSubject: %s\r\n\r\n" % \ (from_addr, to_addr, subject) + body - if type(to_addr) is str: - to_addr = to_addr.split(',') - if type(to_addr) is not list: - raise error.general('invalid to_addr type') + port = self.smtp_port() + try: - s = smtplib.SMTP(self.smtp_host()) - s.sendmail(from_addr, to_addr, msg) + s = smtplib.SMTP(self.smtp_host(), port, timeout=10) + + password = self.smtp_password() + # If a password is provided, assume that authentication is required. + if password is not None: + user = self.smtp_user() + if user is None: + user = from_addr + s.starttls() + s.login(user, password) + + s.sendmail(from_addr, [to_addr], msg) except smtplib.SMTPException as se: raise error.general('sending mail: %s' % (str(se))) except socket.error as se: raise error.general('sending mail: %s' % (str(se))) + def send_file_as_body(self, to_addr, subject, name, intro = None): + try: + with open(name, 'r') as f: + body = f.readlines() + except IOError as err: + raise error.general('error reading mail body: %s' % (name)) + if intro is not None: + body = intro + body + self.send(to_addr, from_addr, body) + if __name__ == '__main__': import sys + import macros optargs = {} + rtdir = 'source-builder' + defaults = '%s/defaults.mc' % (rtdir) append_options(optargs) - opts = options.load(sys.argv, optargs = optargs, defaults = 'defaults.mc') + opts = options.command_line(base_path = '.', + argv = sys.argv, + optargs = optargs, + defaults = macros.macros(name = defaults, rtdir = rtdir), + command_path = '.') + options.load(opts) m = mail(opts) print('From: %s' % (m.from_address())) print('SMTP Host: %s' % (m.smtp_host())) - m.send(m.from_address(), 'Test mailer.py', 'This is a test') + if '--mail' in sys.argv: + m.send(m.from_address(), 'Test mailer.py', 'This is a test') diff --git a/source-builder/sb/options.py b/source-builder/sb/options.py index fe4182d..c2f7bb2 100644 --- a/source-builder/sb/options.py +++ b/source-builder/sb/options.py @@ -518,6 +518,15 @@ class command_line: return None return self.parse_args(arg) + def find_arg(self, arg): + if self.optargs is None or arg not in self.optargs: + raise error.internal('bad arg: %s' % (arg)) + for a in self.args: + sa = a.split('=') + if sa[0].startswith(arg): + return sa + return None + def with_arg(self, label, default = 'not-found'): # the default if there is no option for without. result = default @@ -583,7 +592,22 @@ class command_line: self.opts['no-install'] = '1' def info(self): - s = ' Command Line: %s%s' % (' '.join(self.argv), os.linesep) + # Filter potentially sensitive mail options out. + filtered_args = [ + arg for arg in self.argv + if all( + smtp_opt not in arg + for smtp_opt in [ + '--smtp-host', + '--mail-to', + '--mail-from', + '--smtp-user', + '--smtp-password', + '--smtp-port' + ] + ) + ] + s = ' Command Line: %s%s' % (' '.join(filtered_args), os.linesep) s += ' Python: %s' % (sys.version.replace('\n', '')) return s diff --git a/source-builder/sb/setbuilder.py b/source-builder/sb/setbuilder.py index a6efd75..be5a4c4 100644 --- a/source-builder/sb/setbuilder.py +++ b/source-builder/sb/setbuilder.py @@ -696,6 +696,8 @@ def run(): 'log' : '', 'reports': [], 'failure': None } + # Request this now to generate any errors. + smtp_host = mail['mail'].smtp_host() to_addr = opts.get_arg('--mail-to') if to_addr is not None: mail['to'] = to_addr[1] -- 1.8.3.1 From joel at rtems.org Thu Dec 16 01:19:04 2021 From: joel at rtems.org (Joel Sherrill) Date: Wed, 15 Dec 2021 19:19:04 -0600 Subject: How To Turn off Werror for gdb on rtems5 Message-ID: Hi On operating systems with newer gcc versions, gdb 8 fails to compile with warnings that are errors. How can we disable-werror on that branch? Should it be for all architectures or just the offending ones (which might be all)? Help appreciated. Thanks --joel From chrisj at rtems.org Thu Dec 16 03:51:14 2021 From: chrisj at rtems.org (Chris Johns) Date: Thu, 16 Dec 2021 14:51:14 +1100 Subject: New validation test suites In-Reply-To: <1f6a827e-818b-5e54-6e8c-98d28a22c25e@embedded-brains.de> References: <5c4d51cb-660d-93ec-7a59-4a98be61d4c1@embedded-brains.de> <514bddac-9f20-5fa6-52a0-57c8f8787c82@rtems.org> <6f5145de-94f8-1984-5590-fb05741d282b@embedded-brains.de> <1f6a827e-818b-5e54-6e8c-98d28a22c25e@embedded-brains.de> Message-ID: <73f5c494-6879-e2f7-4394-0a25e070b24b@rtems.org> On 16/12/21 3:27 am, Sebastian Huber wrote: > On 15/12/2021 06:46, Chris Johns wrote: >> On 14/12/21 6:24 pm, Sebastian Huber wrote: >>> Hello Chris, >>> >>> On 13/12/2021 22:01, Chris Johns wrote: >>>> On 14/12/21 1:53 am, Sebastian Huber wrote: > [...] >>>>> We finished the specification of the pre-qualified RTEMS feature set. The >>>>> specification is available in an RTEMS Project repository: >>>>> >>>>> https://git.rtems.org/rtems-central/tree/spec >>>> >>>> I had a quick look. Is there a more user friendly view of this data? >>>> >>>> I think the term "specification" is a little bit misleading because the data >>>> files are not easily read by a person. I understand this is the specification >>>> data set however it is not what I am traditionally use to seeing. >>> >>> You can use the "./specview.py" script to get views of the specification.? For >>> example, this command displays the transition map for the rtems_signal_send() >>> directive: >> >> Is specview.py part of rtems.git? > > No, this script is in rtems-central.? This is also the location of the > specification items. I am not sure linking a script from that repo like this is helpful. >> If not part of rtems.git how much data is there for all the output? That is it >> is generated and held in the repo with the tests? > > In rtems.git, there are only the generated sources. > > [...] There should be no reach back to the upstream specs, scripts etc and for good reasons. The information you posted is nice and useful and I do not wish to release manage rtems-central to accommodate these tests in a release. Would capturing that information with the tests be something worth doing? >>>>> The validation tests are generated from the specification using the >>>>> "./spec2modules.py" script and end up in the RTEMS sources of a Git >>>>> submodule. I >>>>> think the specification and the generation tool is now sufficiently stable so >>>>> that the validation test code can be integrated in the RTEMS master branch. >>>>> The >>>>> patch set is too big for the mailing list, so you can review it here: >>>>> >>>>> https://git.rtems.org/sebh/rtems.git/log/?h=validation >>>> >>>> The link failed. >>> >>> Yes, viewing my personal repository no longer works.? I am not sure if this is a >>> temporary issue.? This is why I added the github link. >> >> It seems to have been temporary. It is back again. >> >>> >>>> >>>>> https://github.com/sebhub/rtems/tree/validation >>>> >>>> The header in a test says the regeneration instructions are in the engineering >>>> manual but I could not quickly find them? >>> >>> https://docs.rtems.org/branches/master/eng/req/howto.html#generate-content-after-changes >>> >>> >>> >>> In an earlier version of the header, we had a link which you didn't like: >> >> If I need to look at the formatting rules the heading "Software Development >> Management" is easy to see and then a click on "Coding Standards" gives me what >> I am looking for. >> >> To generate these headers I click on "Software Requirements Engineering" and >> then do I just guess until I find it in the "How To" section? I am actually >> asking this be sorted out so it is not left hanging and we are not left guessing >> what to do. If it can be rearrange into something meaningful it would help. :) > > Well, if you read the text in the header: > > ?* For information on updating and regenerating please refer to the How-To > ?* section in the Software Requirements Engineering chapter of the > ?* RTEMS Software Engineering manual.? The manual is provided as a part of > ?* a release.? For development sources please refer to the online > ?* documentation at: > ?* > ?* https://docs.rtems.org > > You should read the How-to section or not? Yes I should have and thanks for pointing this out but I did not see this and the manual as it stands did not help. I think it should change. It can be performed post this patch set but I think the documentation would read better if changed. >>>> What hardware have the validation tests been run on? Any tier 1 archs? >>> >>> I tested with the sparc/leon3 BSPs and the arm/realview_pbx_a9_qemu. >> >> Is the leon3 tested on hardware or simulation? >> >>> You need a >>> full implementation of the new Interrupt Manager directives and a working Cache >>> Manager implementation. >> >> Is this documented? >> >> I am sorry I do not know the list of archs and bsps that support the new >> interrupt manager directives. Maybe it would be good to list them? > > All BSPs have at least a stub implementation of the new directives. The > directives are tested in a dedicated test suite. You will notice failures in > this test suite if the directives are not implemented. Are these expected failures? >>> I noticed an issue with the thread restart on aarch64/a53_lp64_qemu. >>> >>> On powerpc/psim there is an issue in one test case, due to: >>> >>> #define CPU_ALL_TASKS_ARE_FP CPU_HARDWARE_FP >> >> Sorry, I am not following what the issue is? Does this effect all PPC BSPS? > > Not all, the newer BSPs have no separate floating-point context. Which ones have the issue, the newer BSPs or the older ones? > This is something which needs to be fixed in the specification. Of? < From my point of view this is just a minor issue. As in fixing these tests? >>> Another issue is that the tm27 interrupt must be independent of the clock driver >>> interrupt.? This is not the case for powerpc/psim. >>> >>> There is definitely some work left to cover all edge cases. Some tests are quite >>> complicated. >> >> Sure. I would like to understand the effects this has? > > Maybe I can rearrange the test cases so that the tm27 support is only used if no > clock driver is needed. The tm27 support is used to run handlers in interrupt > context. OK. >>>> Is there anything that interprets the new test output format? It looks like >>>> lots >>>> of great info but a little difficult to read. >>> >>> EDISOFT worked on a test report generator, however, it is not yet in a >>> reviewable state. >> >> OK. I think something that handles this data would be good to have. > > Yes, maybe we could let a student work on this. In theory, this is not > difficult. Read the report.yaml generated by the RTEMS Tester and convert it to > a Python objects representation. Then use this high-level representation to > generate a report in format X. Sounds good. And we need to get all the BSPs baselined with 0 failures so we know where we stand as changes are being made. Chris From chrisj at rtems.org Thu Dec 16 04:06:11 2021 From: chrisj at rtems.org (Chris Johns) Date: Thu, 16 Dec 2021 15:06:11 +1100 Subject: [PATCH rtems-tools 5 0/5] Port mailer.py fixes to rtems-tools 5 branch In-Reply-To: <20211215213256.189992-1-alex.white@oarcorp.com> References: <20211215213256.189992-1-alex.white@oarcorp.com> Message-ID: OK Thanks Chris On 16/12/21 8:32 am, Alex White wrote: > Hi, > > This patch set adds the changes related to report mailing to rtems-tools 5. > > See #4553 > > Thanks, > > Alex White > > Alex White (5): > rtemstoolkit/mailer.py: Return full smtp-host arg value > rtemstoolkit: Filter mail options from log output > rtemstoolkit/mailer.py: Add SMTP login options > rtemstoolkit/mailer.py: Add --use-gitconfig option > rtems-bsp-builder: Fix mail support > > rtemstoolkit/mailer.py | 86 +++++++++++++++++++++++++++++++++++++---- > rtemstoolkit/options.py | 17 +++++++- > tester/rt/check.py | 17 +++++++- > 3 files changed, 111 insertions(+), 9 deletions(-) > From chrisj at rtems.org Thu Dec 16 04:06:29 2021 From: chrisj at rtems.org (Chris Johns) Date: Thu, 16 Dec 2021 15:06:29 +1100 Subject: [PATCH RSB 5] sb: Merge mailer changes from rtems-tools In-Reply-To: <20211215213800.191302-1-alex.white@oarcorp.com> References: <20211215213800.191302-1-alex.white@oarcorp.com> Message-ID: <22883960-e9f5-aac1-c723-8b696cec23d3@rtems.org> OK Thanks Chris On 16/12/21 8:38 am, Alex White wrote: > This adds the improved mailer.py script from rtems-tools. > > Closes #4554 > --- > source-builder/sb/mailer.py | 194 +++++++++++++++++++++++++++++++++------- > source-builder/sb/options.py | 26 +++++- > source-builder/sb/setbuilder.py | 2 + > 3 files changed, 189 insertions(+), 33 deletions(-) > > diff --git a/source-builder/sb/mailer.py b/source-builder/sb/mailer.py > index 42b4fa6..1d3cbb5 100644 > --- a/source-builder/sb/mailer.py > +++ b/source-builder/sb/mailer.py > @@ -1,21 +1,33 @@ > # > # RTEMS Tools Project (http://www.rtems.org/) > -# Copyright 2013 Chris Johns (chrisj at rtems.org) > +# Copyright 2013-2016 Chris Johns (chrisj at rtems.org) > +# Copyright (C) 2021 On-Line Applications Research Corporation (OAR) > # All rights reserved. > # > # This file is part of the RTEMS Tools package in 'rtems-tools'. > # > -# Permission to use, copy, modify, and/or distribute this software for any > -# purpose with or without fee is hereby granted, provided that the above > -# copyright notice and this permission notice appear in all copies. > +# 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 HOLDER 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. > # > -# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES > -# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF > -# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR > -# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES > -# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN > -# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF > -# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. > > # > # Manage emailing results or reports. > @@ -28,18 +40,72 @@ import smtplib > import socket > > import error > +import execute > import options > import path > > +_options = { > + '--mail' : 'Send email report or results.', > + '--use-gitconfig': 'Use mail configuration from git config.', > + '--mail-to' : 'Email address to send the email to.', > + '--mail-from' : 'Email address the report is from.', > + '--smtp-host' : 'SMTP host to send via.', > + '--smtp-port' : 'SMTP port to send via.', > + '--smtp-user' : 'User for SMTP authentication.', > + '--smtp-password': 'Password for SMTP authentication.' > +} > + > def append_options(opts): > - opts['--mail'] = 'Send email report or results.' > - opts['--smtp-host'] = 'SMTP host to send via.' > - opts['--mail-to'] = 'Email address to send the email too.' > - opts['--mail-from'] = 'Email address the report is from.' > + for o in _options: > + opts[o] = _options[o] > + > +def add_arguments(argsp): > + argsp.add_argument('--mail', help = _options['--mail'], action = 'store_true') > + argsp.add_argument('--use-gitconfig', help = _options['--use-gitconfig'], action = 'store_true') > + no_add = ['--mail', '--use-gitconfig'] > + for o in [opt for opt in list(_options) if opt not in no_add]: > + argsp.add_argument(o, help = _options[o], type = str) > > class mail: > def __init__(self, opts): > self.opts = opts > + self.gitconfig_lines = None > + if opts.find_arg('--use-gitconfig') is not None: > + # Read the output of `git config --list` instead of reading the > + # .gitconfig file directly because Python 2 ConfigParser does not > + # accept tabs at the beginning of lines. > + e = execute.capture_execution() > + exit_code, proc, output = e.open('git config --list', shell=True) > + if exit_code == 0: > + self.gitconfig_lines = output.split(os.linesep) > + > + def _args_are_macros(self): > + return isinstance(self.opts, options.command_line) > + > + def _get_arg(self, arg): > + if self._args_are_macros(): > + value = self.opts.find_arg(arg) > + if value is not None: > + value = self.opts.find_arg(arg)[1] > + else: > + if arg.startswith('--'): > + arg = arg[2:] > + arg = arg.replace('-', '_') > + if arg in vars(self.opts): > + value = vars(self.opts)[arg] > + else: > + value = None > + return value > + > + def _get_from_gitconfig(self, variable_name): > + if self.gitconfig_lines is None: > + return None > + > + for line in self.gitconfig_lines: > + if line.startswith(variable_name): > + ls = line.split('=') > + if len(ls) >= 2: > + return ls[1] > > def from_address(self): > > @@ -52,9 +118,15 @@ class mail: > l = l[:l.index('\n')] > return l.strip() > > - addr = self.opts.get_arg('--mail-from') > + addr = self._get_arg('--mail-from') > if addr is not None: > - return addr[1] > + return addr > + addr = self._get_from_gitconfig('user.email') > + if addr is not None: > + name = self._get_from_gitconfig('user.name') > + if name is not None: > + addr = '%s <%s>' % (name, addr) > + return addr > mailrc = None > if 'MAILRC' in os.environ: > mailrc = os.environ['MAILRC'] > @@ -63,9 +135,8 @@ class mail: > if mailrc is not None and path.exists(mailrc): > # set from="Joe Blow " > try: > - mrc = open(mailrc, 'r') > - lines = mrc.readlines() > - mrc.close() > + with open(mailrc, 'r') as mrc: > + lines = mrc.readlines() > except IOError as err: > raise error.general('error reading: %s' % (mailrc)) > for l in lines: > @@ -76,40 +147,99 @@ class mail: > addr = fa[fa.index('=') + 1:].replace('"', ' ').strip() > if addr is not None: > return addr > - addr = self.opts.defaults.get_value('%{_sbgit_mail}') > + if self._args_are_macros(): > + addr = self.opts.defaults.get_value('%{_sbgit_mail}') > + else: > + raise error.general('no valid from address for mail') > return addr > > def smtp_host(self): > - host = self.opts.get_arg('--smtp-host') > + host = self._get_arg('--smtp-host') > if host is not None: > - return host[1] > - host = self.opts.defaults.get_value('%{_mail_smtp_host}') > + return host > + host = self._get_from_gitconfig('sendemail.smtpserver') > + if host is not None: > + return host > + if self._args_are_macros(): > + host = self.opts.defaults.get_value('%{_mail_smtp_host}') > if host is not None: > return host > return 'localhost' > > + def smtp_port(self): > + port = self._get_arg('--smtp-port') > + if port is not None: > + return port > + port = self._get_from_gitconfig('sendemail.smtpserverport') > + if port is not None: > + return port > + if self._args_are_macros(): > + port = self.opts.defaults.get_value('%{_mail_smtp_port}') > + return port > + > + def smtp_user(self): > + user = self._get_arg('--smtp-user') > + if user is not None: > + return user > + user = self._get_from_gitconfig('sendemail.smtpuser') > + return user > + > + def smtp_password(self): > + password = self._get_arg('--smtp-password') > + if password is not None: > + return password > + password = self._get_from_gitconfig('sendemail.smtppass') > + return password > + > def send(self, to_addr, subject, body): > from_addr = self.from_address() > msg = "From: %s\r\nTo: %s\r\nSubject: %s\r\n\r\n" % \ > (from_addr, to_addr, subject) + body > - if type(to_addr) is str: > - to_addr = to_addr.split(',') > - if type(to_addr) is not list: > - raise error.general('invalid to_addr type') > + port = self.smtp_port() > + > try: > - s = smtplib.SMTP(self.smtp_host()) > - s.sendmail(from_addr, to_addr, msg) > + s = smtplib.SMTP(self.smtp_host(), port, timeout=10) > + > + password = self.smtp_password() > + # If a password is provided, assume that authentication is required. > + if password is not None: > + user = self.smtp_user() > + if user is None: > + user = from_addr > + s.starttls() > + s.login(user, password) > + > + s.sendmail(from_addr, [to_addr], msg) > except smtplib.SMTPException as se: > raise error.general('sending mail: %s' % (str(se))) > except socket.error as se: > raise error.general('sending mail: %s' % (str(se))) > > + def send_file_as_body(self, to_addr, subject, name, intro = None): > + try: > + with open(name, 'r') as f: > + body = f.readlines() > + except IOError as err: > + raise error.general('error reading mail body: %s' % (name)) > + if intro is not None: > + body = intro + body > + self.send(to_addr, from_addr, body) > + > if __name__ == '__main__': > import sys > + import macros > optargs = {} > + rtdir = 'source-builder' > + defaults = '%s/defaults.mc' % (rtdir) > append_options(optargs) > - opts = options.load(sys.argv, optargs = optargs, defaults = 'defaults.mc') > + opts = options.command_line(base_path = '.', > + argv = sys.argv, > + optargs = optargs, > + defaults = macros.macros(name = defaults, rtdir = rtdir), > + command_path = '.') > + options.load(opts) > m = mail(opts) > print('From: %s' % (m.from_address())) > print('SMTP Host: %s' % (m.smtp_host())) > - m.send(m.from_address(), 'Test mailer.py', 'This is a test') > + if '--mail' in sys.argv: > + m.send(m.from_address(), 'Test mailer.py', 'This is a test') > diff --git a/source-builder/sb/options.py b/source-builder/sb/options.py > index fe4182d..c2f7bb2 100644 > --- a/source-builder/sb/options.py > +++ b/source-builder/sb/options.py > @@ -518,6 +518,15 @@ class command_line: > return None > return self.parse_args(arg) > > + def find_arg(self, arg): > + if self.optargs is None or arg not in self.optargs: > + raise error.internal('bad arg: %s' % (arg)) > + for a in self.args: > + sa = a.split('=') > + if sa[0].startswith(arg): > + return sa > + return None > + > def with_arg(self, label, default = 'not-found'): > # the default if there is no option for without. > result = default > @@ -583,7 +592,22 @@ class command_line: > self.opts['no-install'] = '1' > > def info(self): > - s = ' Command Line: %s%s' % (' '.join(self.argv), os.linesep) > + # Filter potentially sensitive mail options out. > + filtered_args = [ > + arg for arg in self.argv > + if all( > + smtp_opt not in arg > + for smtp_opt in [ > + '--smtp-host', > + '--mail-to', > + '--mail-from', > + '--smtp-user', > + '--smtp-password', > + '--smtp-port' > + ] > + ) > + ] > + s = ' Command Line: %s%s' % (' '.join(filtered_args), os.linesep) > s += ' Python: %s' % (sys.version.replace('\n', '')) > return s > > diff --git a/source-builder/sb/setbuilder.py b/source-builder/sb/setbuilder.py > index a6efd75..be5a4c4 100644 > --- a/source-builder/sb/setbuilder.py > +++ b/source-builder/sb/setbuilder.py > @@ -696,6 +696,8 @@ def run(): > 'log' : '', > 'reports': [], > 'failure': None } > + # Request this now to generate any errors. > + smtp_host = mail['mail'].smtp_host() > to_addr = opts.get_arg('--mail-to') > if to_addr is not None: > mail['to'] = to_addr[1] From chrisj at rtems.org Thu Dec 16 04:07:08 2021 From: chrisj at rtems.org (Chris Johns) Date: Thu, 16 Dec 2021 15:07:08 +1100 Subject: [PATCH rtems-libbsd] Import arm64 in_cksum.h correctly In-Reply-To: <20211215160536.36884-1-kinsey.moore@oarcorp.com> References: <20211215160536.36884-1-kinsey.moore@oarcorp.com> Message-ID: <33774a60-866d-866d-ba7c-16148e14c8ab@rtems.org> OK Thanks Chris On 16/12/21 3:05 am, Kinsey Moore wrote: > When this file was brought in, it came from the wrong location or > freebsd-org hash. This corrects the file such that freebsd-to-rtems.py > runs cleanly. > --- > freebsd/sys/arm64/include/machine/in_cksum.h | 43 +++----------------- > 1 file changed, 6 insertions(+), 37 deletions(-) > > diff --git a/freebsd/sys/arm64/include/machine/in_cksum.h b/freebsd/sys/arm64/include/machine/in_cksum.h > index d55b838b..522ba005 100644 > --- a/freebsd/sys/arm64/include/machine/in_cksum.h > +++ b/freebsd/sys/arm64/include/machine/in_cksum.h > @@ -1,6 +1,4 @@ > /*- > - * SPDX-License-Identifier: BSD-3-Clause > - * > * Copyright (c) 1990 The Regents of the University of California. > * All rights reserved. > * > @@ -31,7 +29,6 @@ > * from tahoe: in_cksum.c 1.2 86/01/05 > * from: @(#)in_cksum.c 1.3 (Berkeley) 1/19/91 > * from: Id: in_cksum.c,v 1.8 1995/12/03 18:35:19 bde Exp > - * from: src/sys/alpha/include/in_cksum.h,v 1.7 2005/03/02 21:33:20 joerg > * $FreeBSD$ > */ > > @@ -40,44 +37,16 @@ > > #include > > +#ifdef _KERNEL > #define in_cksum(m, len) in_cksum_skip(m, len, 0) > - > +u_short in_addword(u_short sum, u_short b); > +u_short in_cksum_skip(struct mbuf *m, int len, int skip); > +u_int do_cksum(const void *, int); > #if defined(IPVERSION) && (IPVERSION == 4) > -/* > - * It it useful to have an Internet checksum routine which is inlineable > - * and optimized specifically for the task of computing IP header checksums > - * in the normal case (where there are no options and the header length is > - * therefore always exactly five 32-bit words. > - */ > -#ifdef __CC_SUPPORTS___INLINE > - > -static __inline void > -in_cksum_update(struct ip *ip) > -{ > - int __tmpsum; > - __tmpsum = (int)ntohs(ip->ip_sum) + 256; > - ip->ip_sum = htons(__tmpsum + (__tmpsum >> 16)); > -} > - > -#else > - > -#define in_cksum_update(ip) \ > - do { \ > - int __tmpsum; \ > - __tmpsum = (int)ntohs(ip->ip_sum) + 256; \ > - ip->ip_sum = htons(__tmpsum + (__tmpsum >> 16)); \ > - } while(0) > - > -#endif > +u_int in_cksum_hdr(const struct ip *); > #endif > > -#ifdef _KERNEL > -#if defined(IPVERSION) && (IPVERSION == 4) > -u_int in_cksum_hdr(const struct ip *ip); > -#endif > -u_short in_addword(u_short sum, u_short b); > u_short in_pseudo(u_int sum, u_int b, u_int c); > -u_short in_cksum_skip(struct mbuf *m, int len, int skip); > -#endif > > +#endif /* _KERNEL */ > #endif /* _MACHINE_IN_CKSUM_H_ */ From sebastian.huber at embedded-brains.de Thu Dec 16 07:21:12 2021 From: sebastian.huber at embedded-brains.de (Sebastian Huber) Date: Thu, 16 Dec 2021 08:21:12 +0100 Subject: [PATCH] c-user: Clarify time formats Message-ID: <20211216072112.11408-1-sebastian.huber@embedded-brains.de> Update #4572. --- c-user/clock/background.rst | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/c-user/clock/background.rst b/c-user/clock/background.rst index 64e8311..9e76a02 100644 --- a/c-user/clock/background.rst +++ b/c-user/clock/background.rst @@ -1,5 +1,6 @@ .. SPDX-License-Identifier: CC-BY-SA-4.0 +.. Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de) .. Copyright (C) 1988, 2008 On-Line Applications Research Corporation (OAR) Background @@ -29,7 +30,7 @@ and date format: .. code-block:: c - struct rtems_tod_control { + typedef struct { uint32_t year; /* greater than 1987 */ uint32_t month; /* 1 - 12 */ uint32_t day; /* 1 - 31 */ @@ -37,20 +38,28 @@ and date format: uint32_t minute; /* 0 - 59 */ uint32_t second; /* 0 - 59 */ uint32_t ticks; /* elapsed between seconds */ - }; - typedef struct rtems_tod_control rtems_time_of_day; + } rtems_time_of_day; The native date and time format is the only format supported when setting the -system date and time using the ``rtems_clock_set`` directive. Some +system date and time using the :ref:`InterfaceRtemsClockSet` directive. Some applications expect to operate on a *UNIX-style* date and time data structure. -The ``rtems_clock_get_tod_timeval`` always returns the date and time in -``struct timeval`` format. - -The ``struct timeval`` data structure has two fields: ``tv_sec`` and -``tv_usec`` which are seconds and microseconds, respectively. The ``tv_sec`` -field in this data structure is the number of seconds since the POSIX epoch of -*January 1, 1970* but will never be prior to the RTEMS epoch of *January 1, -1988*. +For example, the :ref:`InterfaceRtemsClockGetTodTimeval` returns the date and +time in ``struct timeval`` format. + +Some directives use data structures defined by :term:`POSIX`. The ``struct +timeval`` data structure has two members: ``tv_sec`` and ``tv_usec`` which are +seconds and microseconds, respectively. The ``struct timespec`` data structure +has two members: ``tv_sec`` and ``tv_nsec`` which are seconds and nanoseconds, +respectively. For :term:`CLOCK_REALTIME` time points, the ``tv_sec`` member in +these data structures is the number of seconds since the :term:`Unix epoch` but +will never be prior to the :term:`RTEMS epoch`. + +The ``struct bintime`` and ``sbintime_t`` time formats used by some directives +originate in FreeBSD. The ``struct bintime`` data structure which represents +time in a binary time format has two members: ``sec`` and ``frac`` which are +seconds and fractions of a second in units of :math:`1 / 2^{64}` seconds, +respectively. The ``sbintime_t`` type is a signed 64-bit integer type used to +represent time in units of :math:`1 / 2^{32}` seconds. .. index:: timeslicing -- 2.31.1 From sebastian.huber at embedded-brains.de Thu Dec 16 07:36:04 2021 From: sebastian.huber at embedded-brains.de (Sebastian Huber) Date: Thu, 16 Dec 2021 08:36:04 +0100 Subject: New validation test suites In-Reply-To: <73f5c494-6879-e2f7-4394-0a25e070b24b@rtems.org> References: <5c4d51cb-660d-93ec-7a59-4a98be61d4c1@embedded-brains.de> <514bddac-9f20-5fa6-52a0-57c8f8787c82@rtems.org> <6f5145de-94f8-1984-5590-fb05741d282b@embedded-brains.de> <1f6a827e-818b-5e54-6e8c-98d28a22c25e@embedded-brains.de> <73f5c494-6879-e2f7-4394-0a25e070b24b@rtems.org> Message-ID: <7f29dfbe-b57d-6c70-df2a-6878d7db0efa@embedded-brains.de> On 16/12/2021 04:51, Chris Johns wrote: > On 16/12/21 3:27 am, Sebastian Huber wrote: >> On 15/12/2021 06:46, Chris Johns wrote: >>> On 14/12/21 6:24 pm, Sebastian Huber wrote: >>>> Hello Chris, >>>> >>>> On 13/12/2021 22:01, Chris Johns wrote: >>>>> On 14/12/21 1:53 am, Sebastian Huber wrote: >> [...] >>>>>> We finished the specification of the pre-qualified RTEMS feature set. The >>>>>> specification is available in an RTEMS Project repository: >>>>>> >>>>>> https://git.rtems.org/rtems-central/tree/spec >>>>> >>>>> I had a quick look. Is there a more user friendly view of this data? >>>>> >>>>> I think the term "specification" is a little bit misleading because the data >>>>> files are not easily read by a person. I understand this is the specification >>>>> data set however it is not what I am traditionally use to seeing. >>>> >>>> You can use the "./specview.py" script to get views of the specification.? For >>>> example, this command displays the transition map for the rtems_signal_send() >>>> directive: >>> >>> Is specview.py part of rtems.git? >> >> No, this script is in rtems-central.? This is also the location of the >> specification items. > > I am not sure linking a script from that repo like this is helpful. > >>> If not part of rtems.git how much data is there for all the output? That is it >>> is generated and held in the repo with the tests? >> >> In rtems.git, there are only the generated sources. >> >> [...] > > There should be no reach back to the upstream specs, scripts etc and for good > reasons. The information you posted is nice and useful and I do not wish to > release manage rtems-central to accommodate these tests in a release. > > Would capturing that information with the tests be something worth doing? I don't think it would be useful. If you want to modify the tests you should work with the specification items and the corresponding scripts. Adding the tables as comments would blow up the sources considerably. Some tests have about 50000 table entries and the table entries depend on C preprocessor defines. [...] >>>> In an earlier version of the header, we had a link which you didn't like: >>> >>> If I need to look at the formatting rules the heading "Software Development >>> Management" is easy to see and then a click on "Coding Standards" gives me what >>> I am looking for. >>> >>> To generate these headers I click on "Software Requirements Engineering" and >>> then do I just guess until I find it in the "How To" section? I am actually >>> asking this be sorted out so it is not left hanging and we are not left guessing >>> what to do. If it can be rearrange into something meaningful it would help. :) >> >> Well, if you read the text in the header: >> >> ?* For information on updating and regenerating please refer to the How-To >> ?* section in the Software Requirements Engineering chapter of the >> ?* RTEMS Software Engineering manual.? The manual is provided as a part of >> ?* a release.? For development sources please refer to the online >> ?* documentation at: >> ?* >> ?* https://docs.rtems.org >> >> You should read the How-to section or not? > > Yes I should have and thanks for pointing this out but I did not see this and > the manual as it stands did not help. I think it should change. It can be > performed post this patch set but I think the documentation would read better if > changed. Could you please make a suggestions how the text should be changed? > >>>>> What hardware have the validation tests been run on? Any tier 1 archs? >>>> >>>> I tested with the sparc/leon3 BSPs and the arm/realview_pbx_a9_qemu. >>> >>> Is the leon3 tested on hardware or simulation? >>> >>>> You need a >>>> full implementation of the new Interrupt Manager directives and a working Cache >>>> Manager implementation. >>> >>> Is this documented? >>> >>> I am sorry I do not know the list of archs and bsps that support the new >>> interrupt manager directives. Maybe it would be good to list them? >> >> All BSPs have at least a stub implementation of the new directives. The >> directives are tested in a dedicated test suite. You will notice failures in >> this test suite if the directives are not implemented. > > Are these expected failures? Yes, they would be expected failures. I can add the test information. For which BSPs should I do this? > >>>> I noticed an issue with the thread restart on aarch64/a53_lp64_qemu. >>>> >>>> On powerpc/psim there is an issue in one test case, due to: >>>> >>>> #define CPU_ALL_TASKS_ARE_FP CPU_HARDWARE_FP >>> >>> Sorry, I am not following what the issue is? Does this effect all PPC BSPS? >> >> Not all, the newer BSPs have no separate floating-point context. > > Which ones have the issue, the newer BSPs or the older ones? The older ones. > >> This is something which needs to be fixed in the specification. > > Of? > > < From my point of view this is just a minor issue. > > As in fixing these tests? > >>>> Another issue is that the tm27 interrupt must be independent of the clock driver >>>> interrupt.? This is not the case for powerpc/psim. >>>> >>>> There is definitely some work left to cover all edge cases. Some tests are quite >>>> complicated. >>> >>> Sure. I would like to understand the effects this has? >> >> Maybe I can rearrange the test cases so that the tm27 support is only used if no >> clock driver is needed. The tm27 support is used to run handlers in interrupt >> context. > > OK. I will try to fix these issues, but this will delay the integration for a couple of weeks. > >>>>> Is there anything that interprets the new test output format? It looks like >>>>> lots >>>>> of great info but a little difficult to read. >>>> >>>> EDISOFT worked on a test report generator, however, it is not yet in a >>>> reviewable state. >>> >>> OK. I think something that handles this data would be good to have. >> >> Yes, maybe we could let a student work on this. In theory, this is not >> difficult. Read the report.yaml generated by the RTEMS Tester and convert it to >> a Python objects representation. Then use this high-level representation to >> generate a report in format X. > > Sounds good. > > And we need to get all the BSPs baselined with 0 failures so we know where we > stand as changes are being made. All BSPs is a bit too much. -- embedded brains GmbH Herr Sebastian HUBER Dornierstr. 4 82178 Puchheim Germany email: sebastian.huber at embedded-brains.de phone: +49-89-18 94 741 - 16 fax: +49-89-18 94 741 - 08 Registergericht: Amtsgericht M?nchen Registernummer: HRB 157899 Vertretungsberechtigte Gesch?ftsf?hrer: Peter Rasmussen, Thomas D?rfler Unsere Datenschutzerkl?rung finden Sie hier: https://embedded-brains.de/datenschutzerklaerung/ From joel at rtems.org Thu Dec 16 14:36:00 2021 From: joel at rtems.org (Joel Sherrill) Date: Thu, 16 Dec 2021 08:36:00 -0600 Subject: [PATCH] c-user: Clarify time formats In-Reply-To: <20211216072112.11408-1-sebastian.huber@embedded-brains.de> References: <20211216072112.11408-1-sebastian.huber@embedded-brains.de> Message-ID: This looks good. Will bintime and sbintime show up in the index? On Thu, Dec 16, 2021 at 1:21 AM Sebastian Huber wrote: > > Update #4572. > --- > c-user/clock/background.rst | 33 +++++++++++++++++++++------------ > 1 file changed, 21 insertions(+), 12 deletions(-) > > diff --git a/c-user/clock/background.rst b/c-user/clock/background.rst > index 64e8311..9e76a02 100644 > --- a/c-user/clock/background.rst > +++ b/c-user/clock/background.rst > @@ -1,5 +1,6 @@ > .. SPDX-License-Identifier: CC-BY-SA-4.0 > > +.. Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de) > .. Copyright (C) 1988, 2008 On-Line Applications Research Corporation (OAR) > > Background > @@ -29,7 +30,7 @@ and date format: > > .. code-block:: c > > - struct rtems_tod_control { > + typedef struct { > uint32_t year; /* greater than 1987 */ > uint32_t month; /* 1 - 12 */ > uint32_t day; /* 1 - 31 */ > @@ -37,20 +38,28 @@ and date format: > uint32_t minute; /* 0 - 59 */ > uint32_t second; /* 0 - 59 */ > uint32_t ticks; /* elapsed between seconds */ > - }; > - typedef struct rtems_tod_control rtems_time_of_day; > + } rtems_time_of_day; > > The native date and time format is the only format supported when setting the > -system date and time using the ``rtems_clock_set`` directive. Some > +system date and time using the :ref:`InterfaceRtemsClockSet` directive. Some > applications expect to operate on a *UNIX-style* date and time data structure. > -The ``rtems_clock_get_tod_timeval`` always returns the date and time in > -``struct timeval`` format. > - > -The ``struct timeval`` data structure has two fields: ``tv_sec`` and > -``tv_usec`` which are seconds and microseconds, respectively. The ``tv_sec`` > -field in this data structure is the number of seconds since the POSIX epoch of > -*January 1, 1970* but will never be prior to the RTEMS epoch of *January 1, > -1988*. > +For example, the :ref:`InterfaceRtemsClockGetTodTimeval` returns the date and > +time in ``struct timeval`` format. > + > +Some directives use data structures defined by :term:`POSIX`. The ``struct > +timeval`` data structure has two members: ``tv_sec`` and ``tv_usec`` which are > +seconds and microseconds, respectively. The ``struct timespec`` data structure > +has two members: ``tv_sec`` and ``tv_nsec`` which are seconds and nanoseconds, > +respectively. For :term:`CLOCK_REALTIME` time points, the ``tv_sec`` member in > +these data structures is the number of seconds since the :term:`Unix epoch` but > +will never be prior to the :term:`RTEMS epoch`. > + > +The ``struct bintime`` and ``sbintime_t`` time formats used by some directives > +originate in FreeBSD. The ``struct bintime`` data structure which represents > +time in a binary time format has two members: ``sec`` and ``frac`` which are > +seconds and fractions of a second in units of :math:`1 / 2^{64}` seconds, > +respectively. The ``sbintime_t`` type is a signed 64-bit integer type used to > +represent time in units of :math:`1 / 2^{32}` seconds. > > .. index:: timeslicing > > -- > 2.31.1 > > _______________________________________________ > devel mailing list > devel at rtems.org > http://lists.rtems.org/mailman/listinfo/devel From sebastian.huber at embedded-brains.de Thu Dec 16 14:44:44 2021 From: sebastian.huber at embedded-brains.de (Sebastian Huber) Date: Thu, 16 Dec 2021 15:44:44 +0100 Subject: [PATCH] c-user: Clarify time formats In-Reply-To: References: <20211216072112.11408-1-sebastian.huber@embedded-brains.de> Message-ID: On 16/12/2021 15:36, Joel Sherrill wrote: > Will bintime and sbintime show up in the index? Thanks for the review, I added index entries for them. -- embedded brains GmbH Herr Sebastian HUBER Dornierstr. 4 82178 Puchheim Germany email: sebastian.huber at embedded-brains.de phone: +49-89-18 94 741 - 16 fax: +49-89-18 94 741 - 08 Registergericht: Amtsgericht M?nchen Registernummer: HRB 157899 Vertretungsberechtigte Gesch?ftsf?hrer: Peter Rasmussen, Thomas D?rfler Unsere Datenschutzerkl?rung finden Sie hier: https://embedded-brains.de/datenschutzerklaerung/ From chrisj at rtems.org Fri Dec 17 03:34:58 2021 From: chrisj at rtems.org (Chris Johns) Date: Fri, 17 Dec 2021 14:34:58 +1100 Subject: New validation test suites In-Reply-To: <7f29dfbe-b57d-6c70-df2a-6878d7db0efa@embedded-brains.de> References: <5c4d51cb-660d-93ec-7a59-4a98be61d4c1@embedded-brains.de> <514bddac-9f20-5fa6-52a0-57c8f8787c82@rtems.org> <6f5145de-94f8-1984-5590-fb05741d282b@embedded-brains.de> <1f6a827e-818b-5e54-6e8c-98d28a22c25e@embedded-brains.de> <73f5c494-6879-e2f7-4394-0a25e070b24b@rtems.org> <7f29dfbe-b57d-6c70-df2a-6878d7db0efa@embedded-brains.de> Message-ID: On 16/12/21 6:36 pm, Sebastian Huber wrote: > On 16/12/2021 04:51, Chris Johns wrote: >> On 16/12/21 3:27 am, Sebastian Huber wrote: >>> On 15/12/2021 06:46, Chris Johns wrote: >>>> On 14/12/21 6:24 pm, Sebastian Huber wrote: >>>>> Hello Chris, >>>>> >>>>> On 13/12/2021 22:01, Chris Johns wrote: >>>>>> On 14/12/21 1:53 am, Sebastian Huber wrote: >>> [...] >>>>>>> We finished the specification of the pre-qualified RTEMS feature set. The >>>>>>> specification is available in an RTEMS Project repository: >>>>>>> >>>>>>> https://git.rtems.org/rtems-central/tree/spec >>>>>> >>>>>> I had a quick look. Is there a more user friendly view of this data? >>>>>> >>>>>> I think the term "specification" is a little bit misleading because the data >>>>>> files are not easily read by a person. I understand this is the specification >>>>>> data set however it is not what I am traditionally use to seeing. >>>>> >>>>> You can use the "./specview.py" script to get views of the specification.? For >>>>> example, this command displays the transition map for the rtems_signal_send() >>>>> directive: >>>> >>>> Is specview.py part of rtems.git? >>> >>> No, this script is in rtems-central.? This is also the location of the >>> specification items. >> >> I am not sure linking a script from that repo like this is helpful. >> >>>> If not part of rtems.git how much data is there for all the output? That is it >>>> is generated and held in the repo with the tests? >>> >>> In rtems.git, there are only the generated sources. >>> >>> [...] >> >> There should be no reach back to the upstream specs, scripts etc and for good >> reasons. The information you posted is nice and useful and I do not wish to >> release manage rtems-central to accommodate these tests in a release. >> >> Would capturing that information with the tests be something worth doing? > > I don't think it would be useful. If you want to modify the tests you should > work with the specification items and the corresponding scripts. This is not about modifying the tests. As I previously stated the tests provide little detail on the verification matrix being solved. In relation to where is best to make changes, rtems-central may be the best place however we will accept patches to the tests as they are in rtems.git. How that is pushed back to rtems-central is not a focus here. > Adding the > tables as comments would blow up the sources considerably. Some tests have about > 50000 table entries and the table entries depend on C preprocessor defines. Ah yes I agree and what I was wanting to understand. I think we need to understand what a release will contain because the specs used are not captured with a release. I appreciate the efforts to make this available as a workflow for development and for the pre-qual process but I am now critically examining what this means for a release. For example lets say years after a release someone questions a test, they will only have the test source code in the release package and I think this is a short coming. Adding the rtems-central repo as a package to the releases source may be a solution however this creates further issues. How do I know the master of the rtems-central and the committed sources match when creating the release as separate pieces of rtems.git may have been updated at different commit points in rtems-central? I suggest we get together when we can. Contact me off-line and lets see if we can arrange a time :) > > [...] >>>>> In an earlier version of the header, we had a link which you didn't like: >>>> >>>> If I need to look at the formatting rules the heading "Software Development >>>> Management" is easy to see and then a click on "Coding Standards" gives me what >>>> I am looking for. >>>> >>>> To generate these headers I click on "Software Requirements Engineering" and >>>> then do I just guess until I find it in the "How To" section? I am actually >>>> asking this be sorted out so it is not left hanging and we are not left >>>> guessing >>>> what to do. If it can be rearrange into something meaningful it would help. :) >>> >>> Well, if you read the text in the header: >>> >>> ??* For information on updating and regenerating please refer to the How-To >>> ??* section in the Software Requirements Engineering chapter of the >>> ??* RTEMS Software Engineering manual.? The manual is provided as a part of >>> ??* a release.? For development sources please refer to the online >>> ??* documentation at: >>> ??* >>> ??* https://docs.rtems.org >>> >>> You should read the How-to section or not? >> >> Yes I should have and thanks for pointing this out but I did not see this and >> the manual as it stands did not help. I think it should change. It can be >> performed post this patch set but I think the documentation would read better if >> changed. > > Could you please make a suggestions how the text should be changed? > I am not sure. I have not looked at rtems-central, the scripts or commands it provides. I think at a minimum a section each set of generated sources in rtems.git needs to be covered. >>>>>> What hardware have the validation tests been run on? Any tier 1 archs? >>>>> >>>>> I tested with the sparc/leon3 BSPs and the arm/realview_pbx_a9_qemu. >>>> >>>> Is the leon3 tested on hardware or simulation? >>>> >>>>> You need a >>>>> full implementation of the new Interrupt Manager directives and a working >>>>> Cache >>>>> Manager implementation. >>>> >>>> Is this documented? >>>> >>>> I am sorry I do not know the list of archs and bsps that support the new >>>> interrupt manager directives. Maybe it would be good to list them? >>> >>> All BSPs have at least a stub implementation of the new directives. The >>> directives are tested in a dedicated test suite. You will notice failures in >>> this test suite if the directives are not implemented. >> >> Are these expected failures? > > Yes, they would be expected failures. I can add the test information. For which > BSPs should I do this? Any we know the tests will not run on? >>>>> I noticed an issue with the thread restart on aarch64/a53_lp64_qemu. >>>>> >>>>> On powerpc/psim there is an issue in one test case, due to: >>>>> >>>>> #define CPU_ALL_TASKS_ARE_FP CPU_HARDWARE_FP >>>> >>>> Sorry, I am not following what the issue is? Does this effect all PPC BSPS? >>> >>> Not all, the newer BSPs have no separate floating-point context. >> >> Which ones have the issue, the newer BSPs or the older ones? > > The older ones. > >> >>> This is something which needs to be fixed in the specification. >> >> Of? >> >> < From my point of view this is just a minor issue. >> >> As in fixing these tests? >> >>>>> Another issue is that the tm27 interrupt must be independent of the clock >>>>> driver >>>>> interrupt.? This is not the case for powerpc/psim. >>>>> >>>>> There is definitely some work left to cover all edge cases. Some tests are >>>>> quite >>>>> complicated. >>>> >>>> Sure. I would like to understand the effects this has? >>> >>> Maybe I can rearrange the test cases so that the tm27 support is only used if no >>> clock driver is needed. The tm27 support is used to run handlers in interrupt >>> context. >> >> OK. > > I will try to fix these issues, but this will delay the integration for a couple > of weeks. I am fine with tickets that track the work to be done. >>>>>> Is there anything that interprets the new test output format? It looks like >>>>>> lots >>>>>> of great info but a little difficult to read. >>>>> >>>>> EDISOFT worked on a test report generator, however, it is not yet in a >>>>> reviewable state. >>>> >>>> OK. I think something that handles this data would be good to have. >>> >>> Yes, maybe we could let a student work on this. In theory, this is not >>> difficult. Read the report.yaml generated by the RTEMS Tester and convert it to >>> a Python objects representation. Then use this high-level representation to >>> generate a report in format X. >> >> Sounds good. >> >> And we need to get all the BSPs baselined with 0 failures so we know where we >> stand as changes are being made. > > All BSPs is a bit too much. > Yes sorry I meant all tier 1 BSPs. Chris From joel at rtems.org Fri Dec 17 15:10:54 2021 From: joel at rtems.org (Joel Sherrill) Date: Fri, 17 Dec 2021 09:10:54 -0600 Subject: [PATCH] c-user: Clarify time formats In-Reply-To: References: <20211216072112.11408-1-sebastian.huber@embedded-brains.de> Message-ID: Occurred to me that coarse was also a term in the list that I didn't think was discussed. Sorry for not catching it in the initial review. --joel On Thu, Dec 16, 2021 at 8:44 AM Sebastian Huber wrote: > > On 16/12/2021 15:36, Joel Sherrill wrote: > > Will bintime and sbintime show up in the index? > > Thanks for the review, I added index entries for them. > -- > embedded brains GmbH > Herr Sebastian HUBER > Dornierstr. 4 > 82178 Puchheim > Germany > email: sebastian.huber at embedded-brains.de > phone: +49-89-18 94 741 - 16 > fax: +49-89-18 94 741 - 08 > > Registergericht: Amtsgericht M?nchen > Registernummer: HRB 157899 > Vertretungsberechtigte Gesch?ftsf?hrer: Peter Rasmussen, Thomas D?rfler > Unsere Datenschutzerkl?rung finden Sie hier: > https://embedded-brains.de/datenschutzerklaerung/ From sebastian.huber at embedded-brains.de Fri Dec 17 15:38:31 2021 From: sebastian.huber at embedded-brains.de (Sebastian Huber) Date: Fri, 17 Dec 2021 16:38:31 +0100 Subject: [PATCH] c-user: Clarify time formats In-Reply-To: References: <20211216072112.11408-1-sebastian.huber@embedded-brains.de> Message-ID: <700ce33d-5555-d512-1add-8d4c76284a33@embedded-brains.de> On 17/12/2021 16:10, Joel Sherrill wrote: > Occurred to me that coarse was also a term in the list that I didn't > think was discussed. Yes, but this belongs to another section. -- embedded brains GmbH Herr Sebastian HUBER Dornierstr. 4 82178 Puchheim Germany email: sebastian.huber at embedded-brains.de phone: +49-89-18 94 741 - 16 fax: +49-89-18 94 741 - 08 Registergericht: Amtsgericht M?nchen Registernummer: HRB 157899 Vertretungsberechtigte Gesch?ftsf?hrer: Peter Rasmussen, Thomas D?rfler Unsere Datenschutzerkl?rung finden Sie hier: https://embedded-brains.de/datenschutzerklaerung/ From joel at rtems.org Fri Dec 17 15:40:47 2021 From: joel at rtems.org (Joel Sherrill) Date: Fri, 17 Dec 2021 09:40:47 -0600 Subject: [PATCH] c-user: Clarify time formats In-Reply-To: <700ce33d-5555-d512-1add-8d4c76284a33@embedded-brains.de> References: <20211216072112.11408-1-sebastian.huber@embedded-brains.de> <700ce33d-5555-d512-1add-8d4c76284a33@embedded-brains.de> Message-ID: On Fri, Dec 17, 2021 at 9:38 AM Sebastian Huber wrote: > > On 17/12/2021 16:10, Joel Sherrill wrote: > > Occurred to me that coarse was also a term in the list that I didn't > > think was discussed. > > Yes, but this belongs to another section. OK. Just needs defining. --joel > -- > embedded brains GmbH > Herr Sebastian HUBER > Dornierstr. 4 > 82178 Puchheim > Germany > email: sebastian.huber at embedded-brains.de > phone: +49-89-18 94 741 - 16 > fax: +49-89-18 94 741 - 08 > > Registergericht: Amtsgericht M?nchen > Registernummer: HRB 157899 > Vertretungsberechtigte Gesch?ftsf?hrer: Peter Rasmussen, Thomas D?rfler > Unsere Datenschutzerkl?rung finden Sie hier: > https://embedded-brains.de/datenschutzerklaerung/ From joel at rtems.org Fri Dec 17 16:28:35 2021 From: joel at rtems.org (Joel Sherrill) Date: Fri, 17 Dec 2021 10:28:35 -0600 Subject: [PATCH rtems] Remove powerpc/haleakala board Message-ID: <1639758515-8081-1-git-send-email-joel@rtems.org> Closes #4302. --- bsps/powerpc/haleakala/README | 51 ---- bsps/powerpc/haleakala/config/haleakala.cfg | 27 -- bsps/powerpc/haleakala/include/bsp.h | 107 -------- bsps/powerpc/haleakala/include/bsp/irq.h | 168 ------------ bsps/powerpc/haleakala/include/mmu_405.h | 77 ------ bsps/powerpc/haleakala/include/tm27.h | 1 - bsps/powerpc/haleakala/irq/irq.c | 237 ----------------- bsps/powerpc/haleakala/irq/irq_init.c | 96 ------- bsps/powerpc/haleakala/start/bspstart.c | 190 ------------- bsps/powerpc/haleakala/start/linkcmds | 274 ------------------- bsps/powerpc/haleakala/start/mmu_405.c | 293 --------------------- bsps/powerpc/haleakala/start/mmu_405asm.S | 83 ------ bsps/powerpc/haleakala/start/start.S | 237 ----------------- spec/build/bsps/optconsolebaud.yml | 1 - spec/build/bsps/powerpc/haleakala/abi.yml | 18 -- spec/build/bsps/powerpc/haleakala/bsphaleakala.yml | 72 ----- spec/build/bsps/powerpc/haleakala/optsprg.yml | 15 -- spec/build/bsps/powerpc/haleakala/optvecbase.yml | 16 -- spec/build/bsps/powerpc/haleakala/start.yml | 14 - 19 files changed, 1977 deletions(-) delete mode 100644 bsps/powerpc/haleakala/README delete mode 100644 bsps/powerpc/haleakala/config/haleakala.cfg delete mode 100644 bsps/powerpc/haleakala/include/bsp.h delete mode 100644 bsps/powerpc/haleakala/include/bsp/irq.h delete mode 100644 bsps/powerpc/haleakala/include/mmu_405.h delete mode 100644 bsps/powerpc/haleakala/include/tm27.h delete mode 100644 bsps/powerpc/haleakala/irq/irq.c delete mode 100644 bsps/powerpc/haleakala/irq/irq_init.c delete mode 100644 bsps/powerpc/haleakala/start/bspstart.c delete mode 100644 bsps/powerpc/haleakala/start/linkcmds delete mode 100644 bsps/powerpc/haleakala/start/mmu_405.c delete mode 100644 bsps/powerpc/haleakala/start/mmu_405asm.S delete mode 100644 bsps/powerpc/haleakala/start/start.S delete mode 100644 spec/build/bsps/powerpc/haleakala/abi.yml delete mode 100644 spec/build/bsps/powerpc/haleakala/bsphaleakala.yml delete mode 100644 spec/build/bsps/powerpc/haleakala/optsprg.yml delete mode 100644 spec/build/bsps/powerpc/haleakala/optvecbase.yml delete mode 100644 spec/build/bsps/powerpc/haleakala/start.yml diff --git a/bsps/powerpc/haleakala/README b/bsps/powerpc/haleakala/README deleted file mode 100644 index 115ae63..0000000 --- a/bsps/powerpc/haleakala/README +++ /dev/null @@ -1,51 +0,0 @@ -# Adapted from Virtex BSP - -BSP NAME: Haleakala -BOARD: AMCC/UDTech Haleakala 405Exr eval board -BUS: N/A -CPU FAMILY: ppc -CPU: PowerPC 405EXr -COPROCESSORS: N/A -MODE: 32 bit mode - -DEBUG MONITOR: - -PERIPHERALS -=========== -TIMERS: 405EXr internal -SERIAL PORTS: 405EXr internal -REAL-TIME CLOCK: DS1338 -DMA: 405EXr internal -VIDEO: none -SCSI: none -NETWORKING: 405EXr internal - -DRIVER INFORMATION -================== -CLOCK DRIVER: PPC Decrementer -IOSUPP DRIVER: N/A -SHMSUPP: N/A -TIMER DRIVER: N/A -TTY DRIVER: shared - -STDIO -===== -PORT: Console port 0 -ELECTRICAL: RS-232 -BAUD: 9600-115200 -BITS PER CHARACTER: 8 -PARITY: None -STOP BITS: 1 - -Notes -===== - -Board description ------------------ -clock rate: 400 MHz -ROM: 64MByte FLASH -RAM: 256MByte DDR DRAM - - -Porting -------- diff --git a/bsps/powerpc/haleakala/config/haleakala.cfg b/bsps/powerpc/haleakala/config/haleakala.cfg deleted file mode 100644 index 57feb35..0000000 --- a/bsps/powerpc/haleakala/config/haleakala.cfg +++ /dev/null @@ -1,27 +0,0 @@ -# -# Config file for a PowerPC 405 based card -# mhamel -# - -include $(RTEMS_ROOT)/make/custom/default.cfg - -RTEMS_CPU=powerpc - -# This contains the compiler options necessary to select the CPU model -# and (hopefully) optimize for it. -# -CPU_CFLAGS = -mcpu=405 - -# optimize flag: typically -0, could use -O4 or -fast -# -O4 is ok for RTEMS -# NOTE: some level of -O may be actually required by inline assembler -CFLAGS_OPTIMIZE_V = -O1 -g - -# The following two lines enable compiling and linking on per element. -CFLAGS_OPTIMIZE_V += -ffunction-sections -fdata-sections -LDFLAGS = -Wl,--gc-sections - -define bsp-post-link - $(default-bsp-post-link) - $(OBJCOPY) -O srec $(basename $@)$(EXEEXT) $(basename $@)$(DOWNEXT) -endef diff --git a/bsps/powerpc/haleakala/include/bsp.h b/bsps/powerpc/haleakala/include/bsp.h deleted file mode 100644 index 71ea09b..0000000 --- a/bsps/powerpc/haleakala/include/bsp.h +++ /dev/null @@ -1,107 +0,0 @@ -/** - * @file - * - * @ingroup RTEMSBSPsPowerPCHaleakala - * - * @brief Global BSP definitions. - */ - -/* bsp.h - * - * Generic 405EX bsp.h - * derived from virtex/include/bsp.h - * by Michael Hamel ADInstruments Ltd 2008 - * - * derived from helas403/include/bsp.h: - * Id: bsp.h,v 1.4 2001/06/18 17:01:48 joel Exp - * Author: Thomas Doerfler - * IMD Ingenieurbuero fuer Microcomputertechnik - * - * COPYRIGHT (c) 1998 by IMD - * - * Changes from IMD are covered by the original distributions terms. - * This file has been derived from the papyrus BSP. - * - * Author: Andrew Bray - * - * COPYRIGHT (c) 1995 by i-cubed ltd. - * - * To anyone who acknowledges that this file is provided "AS IS" - * without any express or implied warranty: - * permission to use, copy, modify, and distribute this file - * for any purpose is hereby granted without fee, provided that - * the above copyright notice and this notice appears in all - * copies, and that the name of i-cubed limited not be used in - * advertising or publicity pertaining to distribution of the - * software without specific, written prior permission. - * i-cubed limited makes no representations about the suitability - * of this software for any purpose. - * - * Derived from c/src/lib/libbsp/no_cpu/no_bsp/include/bsp.h - * - * COPYRIGHT (c) 1989-1999. - * 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.org/license/LICENSE. - * - * - * - */ - -#ifndef LIBBSP_POWERPC_HALEAKALA_BSP_H -#define LIBBSP_POWERPC_HALEAKALA_BSP_H - -/** - * @defgroup RTEMSBSPsPowerPCHaleakala Haleakala - * - * @ingroup RTEMSBSPsPowerPC - * - * @brief Haleakala Board Support Package. - * - * @{ - */ - -#include - -#ifdef ASM - - - /* Definition of where to store registers in alignment handler */ - #define ALIGN_REGS 0x0140 - -#else - - #include - #include - #include - #include - #include - - #ifdef __cplusplus - extern "C" { - #endif - - /* Network Defines */ - #define RTEMS_BSP_NETWORK_DRIVER_NAME "eth0" - - struct rtems_bsdnet_ifconfig; - int rtems_emac_driver_attach(struct rtems_bsdnet_ifconfig* config, int attaching); - #define RTEMS_BSP_NETWORK_DRIVER_ATTACH rtems_emac_driver_attach - - #define BSP_UART_IOBASE_COM1 0xEF600200 /* PPC405EX */ - #define BSP_UART_IOBASE_COM2 0xEF600300 - - #define BSP_CONSOLE_PORT BSP_UART_COM1 /* console */ - - #define BSP_UART_BAUD_BASE (11059200 / 16) /* Kilauea ext clock, max speed */ - - #ifdef __cplusplus - } - #endif -#endif /* ASM */ - -/** @} */ - -#endif /* BSP_H */ diff --git a/bsps/powerpc/haleakala/include/bsp/irq.h b/bsps/powerpc/haleakala/include/bsp/irq.h deleted file mode 100644 index d4d1d81..0000000 --- a/bsps/powerpc/haleakala/include/bsp/irq.h +++ /dev/null @@ -1,168 +0,0 @@ -/*===============================================================*\ -| Project: RTEMS Haleakala BSP | -| by Michael Hamel ADInstruments Ltd 2008 | -+-----------------------------------------------------------------+ -| The license and distribution terms for this file may be | -| found in the file LICENSE in this distribution or at | -| | -| http://www.rtems.org/license/LICENSE. | -| | -\*===============================================================*/ - - -#ifndef Haleakala_IRQ_IRQ_H -#define Haleakala_IRQ_IRQ_H - -/* Implemented for us in bsp_irq_dispatch_list */ -#define BSP_SHARED_HANDLER_SUPPORT 1 - -#include - -#ifndef ASM - -#include - -#ifdef __cplusplus -extern "C" { -#endif - - /* Define UIC interrupt numbers; IRQs that cause an external interrupt that needs further decode. - These are arbitrary but it makes things easier if they match the CPU interrupt numbers */ - - /* - - #define BSP_UIC_UART0_GP (BSP_UIC_IRQ_LOWEST_OFFSET + 0) - #define BSP_UIC_UART1 (BSP_UIC_IRQ_LOWEST_OFFSET + 1) - #define BSP_UIC_IIC0 (BSP_UIC_IRQ_LOWEST_OFFSET + 2) - #define BSP_UIC_ExtMaster (BSP_UIC_IRQ_LOWEST_OFFSET + 3) - #define BSP_UIC_PCI (BSP_UIC_IRQ_LOWEST_OFFSET + 4) - #define BSP_UIC_DMA0 (BSP_UIC_IRQ_LOWEST_OFFSET + 5) - #define BSP_UIC_DMA1 (BSP_UIC_IRQ_LOWEST_OFFSET + 6) - #define BSP_UIC_DMA2 (BSP_UIC_IRQ_LOWEST_OFFSET + 7) - #define BSP_UIC_DMA3 (BSP_UIC_IRQ_LOWEST_OFFSET + 8) - #define BSP_UIC_ENetWU (BSP_UIC_IRQ_LOWEST_OFFSET + 9) - #define BSP_UIC_MALSERR (BSP_UIC_IRQ_LOWEST_OFFSET + 10) - #define BSP_UIC_MALTXEOB (BSP_UIC_IRQ_LOWEST_OFFSET + 11) - #define BSP_UIC_MALRXEOB (BSP_UIC_IRQ_LOWEST_OFFSET + 12) - #define BSP_UIC_MALTXDE (BSP_UIC_IRQ_LOWEST_OFFSET + 13) - #define BSP_UIC_MALRXDE (BSP_UIC_IRQ_LOWEST_OFFSET + 14) - #define BSP_UIC_ENet (BSP_UIC_IRQ_LOWEST_OFFSET + 15) - #define BSP_UIC_PCISERR (BSP_UIC_IRQ_LOWEST_OFFSET + 16) - #define BSP_UIC_ECCERR (BSP_UIC_IRQ_LOWEST_OFFSET + 17) - #define BSP_UIC_PCIPower (BSP_UIC_IRQ_LOWEST_OFFSET + 18) - #define BSP_UIC_IRQ0 (BSP_UIC_IRQ_LOWEST_OFFSET + 25) - #define BSP_UIC_IRQ1 (BSP_UIC_IRQ_LOWEST_OFFSET + 26) - #define BSP_UIC_IRQ2 (BSP_UIC_IRQ_LOWEST_OFFSET + 27) - #define BSP_UIC_IRQ3 (BSP_UIC_IRQ_LOWEST_OFFSET + 28) - #define BSP_UIC_IRQ4 (BSP_UIC_IRQ_LOWEST_OFFSET + 29) - #define BSP_UIC_IRQ5 (BSP_UIC_IRQ_LOWEST_OFFSET + 30) - #define BSP_UIC_IRQ6 (BSP_UIC_IRQ_LOWEST_OFFSET + 31) - - #define BSP_UIC_IRQ_NUMBER (32) - - */ - /* PPC405EX interrupt vectors */ - #define BSP_UIC_UART1 (BSP_UIC_IRQ_LOWEST_OFFSET + 1) - #define BSP_UIC_IIC0 (BSP_UIC_IRQ_LOWEST_OFFSET + 2) - #define BSP_UIC_EIPPKP_READY (BSP_UIC_IRQ_LOWEST_OFFSET + 3) - #define BSP_UIC_EIPPKP_TRNG (BSP_UIC_IRQ_LOWEST_OFFSET + 4) - #define BSP_UIC_EBM (BSP_UIC_IRQ_LOWEST_OFFSET + 5) - #define BSP_UIC_OPBtoPLB (BSP_UIC_IRQ_LOWEST_OFFSET + 6) - #define BSP_UIC_IIC1 (BSP_UIC_IRQ_LOWEST_OFFSET + 7) - #define BSP_UIC_SPI (BSP_UIC_IRQ_LOWEST_OFFSET + 8) - #define BSP_UIC_IRQ0 (BSP_UIC_IRQ_LOWEST_OFFSET + 9) - #define BSP_UIC_MALTXEOB (BSP_UIC_IRQ_LOWEST_OFFSET + 10) - #define BSP_UIC_MALRXEOB (BSP_UIC_IRQ_LOWEST_OFFSET + 11) - #define BSP_UIC_DMA0 (BSP_UIC_IRQ_LOWEST_OFFSET + 12) - #define BSP_UIC_DMA1 (BSP_UIC_IRQ_LOWEST_OFFSET + 13) - #define BSP_UIC_DMA2 (BSP_UIC_IRQ_LOWEST_OFFSET + 14) - #define BSP_UIC_DMA3 (BSP_UIC_IRQ_LOWEST_OFFSET + 15) - #define BSP_UIC_PCIe0AL (BSP_UIC_IRQ_LOWEST_OFFSET + 16) - #define BSP_UIC_PCIe0VPD (BSP_UIC_IRQ_LOWEST_OFFSET + 17) - #define BSP_UIC_PCIe0HRst (BSP_UIC_IRQ_LOWEST_OFFSET + 18) - #define BSP_UIC_EIPPKP_PKA (BSP_UIC_IRQ_LOWEST_OFFSET + 19) - #define BSP_UIC_PCIe0TCR (BSP_UIC_IRQ_LOWEST_OFFSET + 20) - #define BSP_UIC_PCIe0VCO (BSP_UIC_IRQ_LOWEST_OFFSET + 21) - #define BSP_UIC_EIPPKP_TRNG_AL (BSP_UIC_IRQ_LOWEST_OFFSET + 22) - #define BSP_UIC_EIP94 (BSP_UIC_IRQ_LOWEST_OFFSET + 23) - #define BSP_UIC_EMAC0 (BSP_UIC_IRQ_LOWEST_OFFSET + 24) - #define BSP_UIC_EMAC1 (BSP_UIC_IRQ_LOWEST_OFFSET + 25) - #define BSP_UIC_UART0 (BSP_UIC_IRQ_LOWEST_OFFSET + 26) - #define BSP_UIC_IRQ4 (BSP_UIC_IRQ_LOWEST_OFFSET + 27) - #define BSP_UIC_UIC2_STD (BSP_UIC_IRQ_LOWEST_OFFSET + 28) - #define BSP_UIC_UIC2_CRIT (BSP_UIC_IRQ_LOWEST_OFFSET + 29) - #define BSP_UIC_UIC1_STD (BSP_UIC_IRQ_LOWEST_OFFSET + 30) - #define BSP_UIC_UIC1_CRIT (BSP_UIC_IRQ_LOWEST_OFFSET + 31) - - #define BSP_UIC1_IRQ_LOWEST_OFFSET (BSP_UIC_IRQ_LOWEST_OFFSET + 32) - #define BSP_UIC_MALSERR (BSP_UIC1_IRQ_LOWEST_OFFSET + 0) - #define BSP_UIC_MALTXDE (BSP_UIC1_IRQ_LOWEST_OFFSET + 1) - #define BSP_UIC_MALRXDE (BSP_UIC1_IRQ_LOWEST_OFFSET + 2) - #define BSP_UIC_PCIe0DCRErr (BSP_UIC1_IRQ_LOWEST_OFFSET + 3) - #define BSP_UIC_PCIe1DCRErr (BSP_UIC1_IRQ_LOWEST_OFFSET + 4) - #define BSP_UIC_ExtBus (BSP_UIC1_IRQ_LOWEST_OFFSET + 5) - #define BSP_UIC_NDFC (BSP_UIC1_IRQ_LOWEST_OFFSET + 6) - #define BSP_UIC_EIPKP_SLAVE (BSP_UIC1_IRQ_LOWEST_OFFSET + 7) - #define BSP_UIC_GPT_TIMER5 (BSP_UIC1_IRQ_LOWEST_OFFSET + 8) - #define BSP_UIC_GPT_TIMER6 (BSP_UIC1_IRQ_LOWEST_OFFSET + 9) - - #define BSP_UIC_GPT_TIMER0 (BSP_UIC1_IRQ_LOWEST_OFFSET + 16) - #define BSP_UIC_GPT_TIMER1 (BSP_UIC1_IRQ_LOWEST_OFFSET + 17) - #define BSP_UIC_IRQ7 (BSP_UIC1_IRQ_LOWEST_OFFSET + 18) - #define BSP_UIC_IRQ8 (BSP_UIC1_IRQ_LOWEST_OFFSET + 19) - #define BSP_UIC_IRQ9 (BSP_UIC1_IRQ_LOWEST_OFFSET + 20) - #define BSP_UIC_GPT_TIMER2 (BSP_UIC1_IRQ_LOWEST_OFFSET + 21) - #define BSP_UIC_GPT_TIMER3 (BSP_UIC1_IRQ_LOWEST_OFFSET + 22) - #define BSP_UIC_GPT_TIMER4 (BSP_UIC1_IRQ_LOWEST_OFFSET + 23) - #define BSP_UIC_SERIAL_ROM (BSP_UIC1_IRQ_LOWEST_OFFSET + 24) - #define BSP_UIC_GPT_DEC (BSP_UIC1_IRQ_LOWEST_OFFSET + 25) - #define BSP_UIC_IRQ2 (BSP_UIC1_IRQ_LOWEST_OFFSET + 26) - #define BSP_UIC_IRQ5 (BSP_UIC1_IRQ_LOWEST_OFFSET + 27) - #define BSP_UIC_IRQ6 (BSP_UIC1_IRQ_LOWEST_OFFSET + 28) - #define BSP_UIC_EMAC0WU (BSP_UIC1_IRQ_LOWEST_OFFSET + 29) - #define BSP_UIC_IRQ1 (BSP_UIC1_IRQ_LOWEST_OFFSET + 30) - #define BSP_UIC_EMAC1WU (BSP_UIC1_IRQ_LOWEST_OFFSET + 31) - - #define BSP_UIC2_IRQ_LOWEST_OFFSET (BSP_UIC_IRQ_LOWEST_OFFSET + 64) - #define BSP_UIC_PCIe0INTA (BSP_UIC2_IRQ_LOWEST_OFFSET + 0) - #define BSP_UIC_PCIe0INTB (BSP_UIC2_IRQ_LOWEST_OFFSET + 1) - #define BSP_UIC_PCIe0INTC (BSP_UIC2_IRQ_LOWEST_OFFSET + 2) - #define BSP_UIC_PCIe0INTD (BSP_UIC2_IRQ_LOWEST_OFFSET + 3) - #define BSP_UIC_IRQ3 (BSP_UIC2_IRQ_LOWEST_OFFSET + 4) - - #define BSP_UIC_USBOTG (BSP_UIC2_IRQ_LOWEST_OFFSET + 30) - - #define BSP_UIC_IRQ_NUMBER (95) - - - #define BSP_UIC_IRQ_LOWEST_OFFSET 0 - #define BSP_UIC_IRQ_MAX_OFFSET (BSP_UIC_IRQ_LOWEST_OFFSET + BSP_UIC_IRQ_NUMBER - 1) - - #define BSP_UART_COM1_IRQ BSP_UIC_UART0 /* Required by shared/console/uart.c */ - #define BSP_UART_COM2_IRQ BSP_UIC_UART1 - - /* Define processor IRQ numbers; IRQs that are handled by the exception vectors */ - - #define BSP_PIT BSP_PROCESSOR_IRQ_LOWEST_OFFSET /* Required by ppc403/clock.c */ - #define BSP_FIT BSP_PROCESSOR_IRQ_LOWEST_OFFSET + 1 - #define BSP_WDOG BSP_PROCESSOR_IRQ_LOWEST_OFFSET + 2 - - #define BSP_PROCESSOR_IRQ_NUMBER (3) - #define BSP_PROCESSOR_IRQ_LOWEST_OFFSET (BSP_UIC_IRQ_MAX_OFFSET + 1) - #define BSP_PROCESSOR_IRQ_MAX_OFFSET (BSP_PROCESSOR_IRQ_LOWEST_OFFSET + BSP_PROCESSOR_IRQ_NUMBER - 1) - - /* Summary and totals */ - - #define BSP_IRQ_NUMBER (BSP_PROCESSOR_IRQ_MAX_OFFSET + 1) - #define BSP_LOWEST_OFFSET (BSP_UIC_IRQ_LOWEST_OFFSET) - #define BSP_MAX_OFFSET (BSP_IRQ_NUMBER - 1) - - extern void BSP_rtems_irq_mng_init(unsigned cpuId); // Implemented in irq_init.c - #include - - #ifdef __cplusplus - } - #endif -#endif /* ASM */ - -#endif /* Haleakala_IRQ_IRQ_H */ diff --git a/bsps/powerpc/haleakala/include/mmu_405.h b/bsps/powerpc/haleakala/include/mmu_405.h deleted file mode 100644 index 344dfe4..0000000 --- a/bsps/powerpc/haleakala/include/mmu_405.h +++ /dev/null @@ -1,77 +0,0 @@ -#ifndef _mmu_405_h -#define _mmu_405_h - -/* - Simple interface to the PowerPC 405 MMU - - The intention here is just to allow the MMU to be used to define cacheability and - read/write/execute permissions in a simple enough way to fit entirely into the - 64-entry TLB cache. - - This code does not do address relocation and does not generate any MMU-related interrupts. - - The process ID support is there for a possible future extension where RTEMS supports - setting the process ID on task switches, which allows per-process stack protection - - This code will call fatal_error() if your add_space() calls overrun the 64 entries - - Michael Hamel ADInstruments 2008 - -*/ - - -#ifdef __cplusplus -extern "C" { -#endif - -#include "stdint.h" - -enum { - kAllProcessIDs = 0 -}; - -typedef enum MMUAccessType { - executable, - readOnlyData, - readOnlyNoCache, - readWriteData, - readWriteNoCache, - readWriteExecutable -} MMUAccessType; - -/* Initialise and clear the MMU */ -void mmu_initialise(void); - -/* Turn on/off data access translation */ -bool mmu_enable_data(bool enable); - -/* Turn on instruction translation */ -bool mmu_enable_code(bool enable); - -/* Define properties for an area of memory (must be 1K-aligned) */ -void mmu_add_space(uint32_t startAddr, uint32_t endAddr, MMUAccessType permissions, uint8_t processID); - -/* Delete a memory property definition */ -void mmu_remove_space(uint32_t startAddr, uint32_t endAddr); - -/* Return number of TLB entries out of total in use */ -int mmu_get_tlb_count(void); - -/* Allocate a new process ID and return it */ -uint8_t mmu_new_processID(void); - -/* Free a process ID that has been in use */ -void mmu_free_processID(uint8_t freeThis); - -/* Return the current process ID */ -uint8_t mmu_current_processID(void); - -/* Change the process ID to ID and return the old value */ -uint8_t mmu_set_processID(uint8_t toID); - - -#ifdef __cplusplus -} -#endif - -#endif //_mmu_405.h diff --git a/bsps/powerpc/haleakala/include/tm27.h b/bsps/powerpc/haleakala/include/tm27.h deleted file mode 100644 index 0dfa7bf..0000000 --- a/bsps/powerpc/haleakala/include/tm27.h +++ /dev/null @@ -1 +0,0 @@ -#include diff --git a/bsps/powerpc/haleakala/irq/irq.c b/bsps/powerpc/haleakala/irq/irq.c deleted file mode 100644 index c9607a0..0000000 --- a/bsps/powerpc/haleakala/irq/irq.c +++ /dev/null @@ -1,237 +0,0 @@ -/* - * - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - * - * Middleware support for PPC405 by M.Hamel ADInstruments Ltd 2008 - */ - -#include -#include -#include -#include -#include -#include - - -/* PPC405EX UIC numbers */ -#define UIC_DCR_BASE 0xc0 -#define UIC0_SR (UIC_DCR_BASE+0x0) /* UIC status */ -#define UIC0_SRS (UIC_DCR_BASE+0x1) /* UIC status set */ -#define UIC0_ER (UIC_DCR_BASE+0x2) /* UIC enable */ -#define UIC0_CR (UIC_DCR_BASE+0x3) /* UIC critical */ -#define UIC0_PR (UIC_DCR_BASE+0x4) /* UIC polarity */ -#define UIC0_TR (UIC_DCR_BASE+0x5) /* UIC triggering */ -#define UIC0_MSR (UIC_DCR_BASE+0x6) /* UIC masked status */ -#define UIC0_VR (UIC_DCR_BASE+0x7) /* UIC vector */ -#define UIC0_VCR (UIC_DCR_BASE+0x8) /* UIC vector configuration */ - -#define UIC1_SR (UIC_DCR_BASE+0x10) /* UIC status */ -#define UIC1_SRS (UIC_DCR_BASE+0x11) /* UIC status set */ -#define UIC1_ER (UIC_DCR_BASE+0x12) /* UIC enable */ -#define UIC1_CR (UIC_DCR_BASE+0x13) /* UIC critical */ -#define UIC1_PR (UIC_DCR_BASE+0x14) /* UIC polarity */ -#define UIC1_TR (UIC_DCR_BASE+0x15) /* UIC triggering */ -#define UIC1_MSR (UIC_DCR_BASE+0x16) /* UIC masked status */ -#define UIC1_VR (UIC_DCR_BASE+0x17) /* UIC vector */ -#define UIC1_VCR (UIC_DCR_BASE+0x18) /* UIC vector configuration */ - -#define UIC2_SR (UIC_DCR_BASE+0x20) /* UIC status */ -#define UIC2_SRS (UIC_DCR_BASE+0x21) /* UIC status set */ -#define UIC2_ER (UIC_DCR_BASE+0x22) /* UIC enable */ -#define UIC2_CR (UIC_DCR_BASE+0x23) /* UIC critical */ -#define UIC2_PR (UIC_DCR_BASE+0x24) /* UIC polarity */ -#define UIC2_TR (UIC_DCR_BASE+0x25) /* UIC triggering */ -#define UIC2_MSR (UIC_DCR_BASE+0x26) /* UIC masked status */ -#define UIC2_VR (UIC_DCR_BASE+0x27) /* UIC vector */ -#define UIC2_VCR (UIC_DCR_BASE+0x28) /* UIC vector configuration */ - -enum { kUICWords = 3 }; - -static rtems_irq_connect_data* rtems_hdl_tblP; -static rtems_irq_connect_data dflt_entry; - -static uint32_t gEnabledInts[kUICWords]; /* 1-bits mean enabled */ -static uint32_t gIntInhibited[kUICWords]; /* 1-bits disable, overriding gEnabledInts because the interrupt - is being processed in C_dispatch_irq_handler */ - -static inline int IsUICIRQ(const rtems_irq_number irqLine) -{ - return (((int) irqLine <= BSP_UIC_IRQ_MAX_OFFSET) && - ((int) irqLine >= BSP_UIC_IRQ_LOWEST_OFFSET) - ); -} - -static void WriteIState(void) -/* Write the gEnabledInts state masked by gIntInhibited to the hardware */ -{ - PPC_SET_DEVICE_CONTROL_REGISTER(UIC0_ER, - gEnabledInts[0] & ~gIntInhibited[0]); - PPC_SET_DEVICE_CONTROL_REGISTER(UIC1_ER, - gEnabledInts[1] & ~gIntInhibited[1]); - PPC_SET_DEVICE_CONTROL_REGISTER(UIC2_ER, - gEnabledInts[2] & ~gIntInhibited[2]); -} - -void -BSP_enable_irq_at_pic(const rtems_irq_number irq) -/* Enable an interrupt; this can be called from inside C_dispatch_irq_handler */ -{ - if (IsUICIRQ(irq)) { - /* Set relevant bit in the state, write state to the UIC */ - gEnabledInts[irq>>5] |= (0x80000000 >> (irq & 0x1F)); - WriteIState(); - } -} - -int -BSP_disable_irq_at_pic(const rtems_irq_number irq) -/* Enable an interrupt; this can be called from inside C_dispatch_irq_handler */ -{ - if (IsUICIRQ(irq)) { - uint32_t oldState; - int iword = irq>>5; - uint32_t mask = (0x80000000 >> (irq & 0x1F)); - - oldState = gEnabledInts[iword] & mask; - gEnabledInts[iword] &= ~mask; - WriteIState(); - return oldState ? 1 : 0; - } else - return -1; -} - -int -BSP_setup_the_pic(rtems_irq_global_settings* config) -{ - int i; - - dflt_entry = config->defaultEntry; - rtems_hdl_tblP = config->irqHdlTbl; - for (i=0; i> bit; - switch (index) { - case 0: - PPC_SET_DEVICE_CONTROL_REGISTER(UIC0_SR, bmask); - break; - case 1: - PPC_SET_DEVICE_CONTROL_REGISTER(UIC1_SR, bmask); - break; - case 2: - PPC_SET_DEVICE_CONTROL_REGISTER(UIC2_SR, bmask); - break; - } - - /* Clear in the active record and gIntInhibited */ - active[index] &= ~bmask; - gIntInhibited[index] &= ~bmask; - }; - - /* Update the hardware again so the interrupts we have handled are unmasked */ - WriteIState(); - return 0; - - } else if (excNum == ASM_DEC_VECTOR) { /* 0x1000 remapped by C_dispatch_dec_handler_bookE */ - bsp_irq_dispatch_list(rtems_hdl_tblP, BSP_PIT, dflt_entry.hdl); - return 0; - - } else if (excNum == ASM_BOOKE_FIT_VECTOR) { /* 0x1010 mapped to 0x13 by ppc_get_vector_addr */ - bsp_irq_dispatch_list(rtems_hdl_tblP, BSP_FIT, dflt_entry.hdl); - return 0; - - } else if (excNum == ASM_BOOKE_WDOG_VECTOR) { /* 0x1020 mapped to 0x14 by ppc_get_vector_addr */ - bsp_irq_dispatch_list(rtems_hdl_tblP, BSP_WDOG, dflt_entry.hdl); - return 0; - - } else - return -1; /* unhandled interrupt, panic time */ -} - diff --git a/bsps/powerpc/haleakala/irq/irq_init.c b/bsps/powerpc/haleakala/irq/irq_init.c deleted file mode 100644 index d48855a..0000000 --- a/bsps/powerpc/haleakala/irq/irq_init.c +++ /dev/null @@ -1,96 +0,0 @@ -/*===============================================================*\ -| Project: RTEMS Haleakala BSP | -| * by Michael Hamel ADInstruments Ltd 2008 | -+-----------------------------------------------------------------+ -| The license and distribution terms for this file may be | -| found in the file LICENSE in this distribution or at | -| | -| http://www.rtems.org/license/LICENSE. | -| | -+-----------------------------------------------------------------+ -| this file contains the irq controller handler | -\*===============================================================*/ -#include -#include -#include -#include -#include -#include - - -/* - * default on/off function - */ -static void nop_func(void) -{ -} - -/* - * default isOn function - */ -static int not_connected(void) -{ - return 0; -} - -static rtems_irq_connect_data rtemsIrq[BSP_IRQ_NUMBER]; -static rtems_irq_global_settings initial_config; -static rtems_irq_connect_data defaultIrq = { - .name = 0, - .hdl = NULL, - .handle = NULL, - .on = (rtems_irq_enable) nop_func, - .off = (rtems_irq_disable) nop_func, - .isOn = (rtems_irq_is_enabled) not_connected, -#ifdef BSP_SHARED_HANDLER_SUPPORT - .next_handler = NULL -#endif -}; - -static rtems_irq_prio irqPrioTable[BSP_IRQ_NUMBER]={ - /* - * Processor exceptions handled as interrupts - */ - 0 -}; - - /* - * This code assumes the exceptions management setup has already - * been done. We just need to replace the exceptions that will - * be handled like interrupt. On mcp750/mpc750 and many PPC processors - * this means the decrementer exception and the external exception. - */ - -void BSP_rtems_irq_mng_init(unsigned cpuId) -{ - int i; - - /* - * re-init the rtemsIrq table - */ - for (i = 0; i < BSP_IRQ_NUMBER; i++) { - rtemsIrq[i] = defaultIrq; - rtemsIrq[i].name = i; - } - /* - * Init initial Interrupt management config - */ - initial_config.irqNb = BSP_IRQ_NUMBER; - initial_config.defaultEntry = defaultIrq; - initial_config.irqHdlTbl = rtemsIrq; - initial_config.irqBase = BSP_LOWEST_OFFSET; - initial_config.irqPrioTbl = irqPrioTable; - - if (!BSP_rtems_irq_mngt_set(&initial_config)) { - /* - * put something here that will show the failure... - */ - rtems_panic( - "Unable to initialize RTEMS interrupt management!!! System locked\n" - ); - } - - #ifdef TRACE_IRQ_INIT - printk("RTEMS IRQ management is now operational\n"); - #endif -} diff --git a/bsps/powerpc/haleakala/start/bspstart.c b/bsps/powerpc/haleakala/start/bspstart.c deleted file mode 100644 index 61fb376..0000000 --- a/bsps/powerpc/haleakala/start/bspstart.c +++ /dev/null @@ -1,190 +0,0 @@ -/* - * This routine does the bulk of the system initialization. - */ - -/* - * Author: Thomas Doerfler - * IMD Ingenieurbuero fuer Microcomputertechnik - * - * COPYRIGHT (c) 1998 by IMD - * - * Changes from IMD are covered by the original distributions terms. - * This file has been derived from the papyrus BSP: - * - * Author: Andrew Bray - * - * COPYRIGHT (c) 1995 by i-cubed ltd. - * - * To anyone who acknowledges that this file is provided "AS IS" - * without any express or implied warranty: - * permission to use, copy, modify, and distribute this file - * for any purpose is hereby granted without fee, provided that - * the above copyright notice and this notice appears in all - * copies, and that the name of i-cubed limited not be used in - * advertising or publicity pertaining to distribution of the - * software without specific, written prior permission. - * i-cubed limited makes no representations about the suitability - * of this software for any purpose. - * - * Modifications for spooling console driver and control of memory layout - * with linker command file by - * Thomas Doerfler - * for these modifications: - * COPYRIGHT (c) 1997 by IMD, Puchheim, Germany. - * - * To anyone who acknowledges that this file is provided "AS IS" - * without any express or implied warranty: - * permission to use, copy, modify, and distribute this file - * for any purpose is hereby granted without fee, provided that - * the above copyright notice and this notice appears in all - * copies. IMD makes no representations about the suitability - * of this software for any purpose. - * - * Derived from c/src/lib/libbsp/no_cpu/no_bsp/startup/bspstart.c: - * - * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994. - * On-Line Applications Research Corporation (OAR). - * - * Modifications for PPC405GP by Dennis Ehlin - * - * Further modified for the PPC405EX Haleakala board by - * Michael Hamel ADInstruments Ltd May 2008 - */ -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -/* - * Driver configuration parameters - */ - -/* Expected by clock.c */ -uint32_t bsp_clicks_per_usec; - -/*-------------------- Haleakala-specific UART setup -------------------------*/ - -static void -EarlyUARTInit(int baudRate) -{ - volatile uint8_t* up = (uint8_t*)(BSP_UART_IOBASE_COM1); - int divider = BSP_UART_BAUD_BASE / baudRate; - up[LCR] = DLAB; /* Access DLM/DLL */ - up[DLL] = divider & 0x0FF; - up[DLM] = divider >> 8; - up[LCR] = CHR_8_BITS; - up[MCR] = DTR | RTS; - up[FCR] = FIFO_EN | XMIT_RESET | RCV_RESET; - up[THR] = '+'; -} - - -static void -InitUARTClock(void) -{ - uint32_t reg; - mfsdr(SDR0_UART0,reg); - reg &= ~0x008000FF; - reg |= 0x00800001; /* Ext clock, div 1 */ - mtsdr(SDR0_UART0,reg); -} - -static void GPIO_AlternateSelect(int bitnum, int source) -/* PPC405EX: select a GPIO function for the specified pin */ -{ - int shift; - unsigned long value, mask; - GPIORegisters* gpioPtr = (GPIORegisters*)(GPIOAddress); - - shift = (31 - bitnum) & 0xF; - value = (source & 3) << (shift*2); - mask = 3 << (shift*2); - if (bitnum <= 15) { - gpioPtr->OSRL = (gpioPtr->OSRL & ~mask) | value; - gpioPtr->TSRL = (gpioPtr->TSRL & ~mask) | value; - } else { - gpioPtr->OSRH = (gpioPtr->OSRH & ~mask) | value; - gpioPtr->TSRH = (gpioPtr->TSRH & ~mask) | value; - } -} - -static void Init_FPGA(void) -{ - /* Have to write to the FPGA to enable the UART drivers */ - /* Have to enable CS2 as an output in GPIO to get the FPGA working */ - mtebc(EBC0_B2CR,0xF0018000); /* Set up CS2 at 0xF0000000 */ - mtebc(EBC0_B2AP,0x9400C800); - GPIO_AlternateSelect(9,1); /* GPIO9 = PerCS2 */ - { - unsigned long *fpgaPtr = (unsigned long*)(0xF0000000); - unsigned long n; - n = *(fpgaPtr); - n &= ~0x00100; /* User LEDs on */ - n |= 0x30000; /* UART 0 and 1 transcievers on! */ - *fpgaPtr = n; - } -} - -/*===================================================================*/ - -static void -DirectUARTWrite(const char c) -{ - volatile uint8_t* up = (uint8_t*)(BSP_UART_IOBASE_COM1); - while ((up[LSR] & THRE) == 0) { ; } - up[THR] = c; -} - -/* We will provide our own printk output function as it may get used early */ -BSP_output_char_function_type BSP_output_char = DirectUARTWrite; -BSP_polling_getchar_function_type BSP_poll_char = NULL; - -uint32_t _CPU_Counter_frequency(void) -{ - return bsp_clicks_per_usec * 1000000; -} - -/*===================================================================*/ - -void bsp_start( void ) -{ - /* Get the UART clock initialized first in case we call printk */ - - InitUARTClock(); - Init_FPGA(); - EarlyUARTInit(115200); - - /* - * Get CPU identification dynamically. Note that the get_ppc_cpu_type() - * function store the result in global variables - * so that it can be used later... - */ - get_ppc_cpu_type(); - get_ppc_cpu_revision(); - - /* - * initialize the device driver parameters - */ - - /* Set globals visible to clock.c */ - /* timebase register ticks/microsecond = CPU Clk in MHz */ - bsp_clicks_per_usec = 400; - - ppc_exc_initialize(); - - /* - * Install our own set of exception vectors - */ - BSP_rtems_irq_mng_init(0); -} diff --git a/bsps/powerpc/haleakala/start/linkcmds b/bsps/powerpc/haleakala/start/linkcmds deleted file mode 100644 index dc5a198..0000000 --- a/bsps/powerpc/haleakala/start/linkcmds +++ /dev/null @@ -1,274 +0,0 @@ -/* - * This file contains directives for the GNU linker which are specific - * to the 405GP/EX - * This file is intended to be used together with dlentry.s - * it will generate downloadable code - * - * Modifications for gen405 by Dennis Ehlin - * Modifications for virtex by Keith, Greg, and Bob - * Modifications for 405GP/EX by Michael Hamel - */ - -OUTPUT_FORMAT("elf32-powerpc", "elf32-powerpc", "elf32-powerpc") -OUTPUT_ARCH(powerpc) -STARTUP(start.o) -ENTRY(download_entry) -EXTERN(__vectors) - -RamBase = DEFINED(RamBase) ? RamBase : 0; -RamSize = DEFINED(RamSize) ? RamSize : 256M; -RamEnd = RamBase + RamSize; -HeapSize = DEFINED(HeapSize) ? HeapSize : 0x0; - -MEMORY { - RAM : ORIGIN = 0, LENGTH = 256M - /*FLASH : ORIGIN = 0xFFE00000, LENGTH = 16M*/ -} - -/* - * Max sdata/bss. - */ -bsp_section_small_data_area_size = 65536; - -SECTIONS -{ - /* First 16K is occupied by exception vectors and anything else we want to put there */ - .text 0x4000: - { - text.start = . ; - *(.entry) - *(.entry2) - *(.text*) - *(.rodata*) - *(.rodata1) - KEEP (*(SORT(.rtemsroset.*))) - - /* - * Special FreeBSD sysctl sections. - */ - . = ALIGN (16); - __start_set_sysctl_set = .; - *(set_sysctl_*); - __stop_set_sysctl_set = ABSOLUTE(.); - *(set_domain_*); - *(set_pseudo_*); - - /* C++ constructors/destructors */ - *(.gnu.linkonce.t*) - - /* Initialization and finalization code. - * - * Various files can provide initialization and finalization functions. - * The bodies of these functions are in .init and .fini sections. We - * accumulate the bodies here, and prepend function prologues from - * ecrti.o and function epilogues from ecrtn.o. ecrti.o must be linked - * first; ecrtn.o must be linked last. Because these are wildcards, it - * doesn't matter if the user does not actually link against ecrti.o and - * ecrtn.o; the linker won't look for a file to match a wildcard. The - * wildcard also means that it doesn't matter which directory ecrti.o - * and ecrtn.o are in. - */ - PROVIDE (_init = .); - *ecrti.o(.init) - *(.init) - *ecrtn.o(.init) - - PROVIDE (_fini = .); - *ecrti.o(.fini) - *(.fini) - *ecrtn.o(.init) - - KEEP (*ecrti.o(.ctors)) - KEEP (*crtbegin.o(.ctors)) - KEEP (*crtbegin?.o(.ctors)) - KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o *ecrtn.o) .ctors)) - KEEP (*(SORT(.ctors.*))) - KEEP (*(.ctors)) - KEEP (*ecrti.o(.dtors)) - KEEP (*crtbegin.o(.dtors)) - KEEP (*crtbegin?.o(.dtors)) - KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o *ecrtn.o) .dtors)) - KEEP (*(SORT(.dtors.*))) - KEEP (*(.dtors)) - - /* Exception frame info */ - *(.eh_frame) - /* Miscellaneous read-only data */ - _rodata_start = . ; - *(.gnu.linkonce.r*) - *(.lit) - *(.shdata) - *(.rodata) - *(.rodata1) - *(.descriptors) - *(rom_ver) - _erodata = .; - - PROVIDE (__EXCEPT_START__ = .); - *(.gcc_except_table*) - PROVIDE (__EXCEPT_END__ = .); - __GOT_START__ = .; - s.got = .; - *(.got.plt) - *(.got) - *(.got1) - PROVIDE (__GOT2_START__ = .); - PROVIDE (_GOT2_START_ = .); - *(.got2) - PROVIDE (__GOT2_END__ = .); - PROVIDE (_GOT2_END_ = .); - - PROVIDE (__FIXUP_START__ = .); - PROVIDE (_FIXUP_START_ = .); - *(.fixup) - PROVIDE (_FIXUP_END_ = .); - PROVIDE (__FIXUP_END__ = .); - - - /* Various possible names for the end of the .text section */ - etext = ALIGN(0x10); - _etext = .; - - *(.lit) - *(.shdata) - _endtext = ALIGN(0x10); - text.end = .; - text.size = text.end - text.start; - } >RAM - - text.size = text.end - text.start; - - .tdata : { - _TLS_Data_begin = .; - *(.tdata .tdata.* .gnu.linkonce.td.*) - _TLS_Data_end = .; - } >RAM - - .tbss : { - _TLS_BSS_begin = .; - *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) - _TLS_BSS_end = .; - } >RAM - - _TLS_Data_size = _TLS_Data_end - _TLS_Data_begin; - _TLS_Data_begin = _TLS_Data_size != 0 ? _TLS_Data_begin : _TLS_BSS_begin; - _TLS_Data_end = _TLS_Data_size != 0 ? _TLS_Data_end : _TLS_BSS_begin; - _TLS_BSS_size = _TLS_BSS_end - _TLS_BSS_begin; - _TLS_Size = _TLS_BSS_end - _TLS_Data_begin; - _TLS_Alignment = MAX (ALIGNOF (.tdata), ALIGNOF (.tbss)); - - .jcr : { KEEP (*(.jcr)) } >RAM - - .rel.dyn : { - *(.rel.init) - *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*) - *(.rel.fini) - *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*) - *(.rel.data.rel.ro* .rel.gnu.linkonce.d.rel.ro.*) - *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*) - *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*) - *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*) - *(.rel.ctors) - *(.rel.dtors) - *(.rel.got) - *(.rel.sdata .rel.sdata.* .rel.gnu.linkonce.s.*) - *(.rel.sbss .rel.sbss.* .rel.gnu.linkonce.sb.*) - *(.rel.sdata2 .rel.sdata2.* .rel.gnu.linkonce.s2.*) - *(.rel.sbss2 .rel.sbss2.* .rel.gnu.linkonce.sb2.*) - *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*) - } >RAM - .rela.dyn : { - *(.rela.init) - *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*) - *(.rela.fini) - *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*) - *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*) - *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*) - *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*) - *(.rela.ctors) - *(.rela.dtors) - *(.rela.got) - *(.rela.got1) - *(.rela.got2) - *(.rela.sdata .rela.sdata.* .rela.gnu.linkonce.s.*) - *(.rela.sbss .rela.sbss.* .rela.gnu.linkonce.sb.*) - *(.rela.sdata2 .rela.sdata2.* .rela.gnu.linkonce.s2.*) - *(.rela.sbss2 .rela.sbss2.* .rela.gnu.linkonce.sb2.*) - *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) - } >RAM - - - /* Initialised large data */ - .data ( . ) : - { - . = ALIGN (4); - data.start = .; - *(.data) - *(.data1) - KEEP (*(SORT(.rtemsrwset.*))) - *(.data.* .gnu.linkonce.d.*) - data.end = .; - } > RAM - - /* Initialised small data addressed as offsets from r13 */ - .sdata : { - . = ALIGN (4); - PROVIDE (__SDATA_START__ = .); - bsp_section_sdata_begin = .; - sdata.start = .; - *(.sdata*) - *(.gnu.linkonce.s.*) - sdata.end = .; - bsp_section_sdata_end = .; - } > RAM - - /* Zeroed small data addressed as offsets from r13 */ - .sbss : { - . = ALIGN (4); - PROVIDE(__SBSS_START__ = .); - bsp_section_sbss_begin = .; - sbss.start = .; - *(.sbss .sbss.* *.gnu.linkonce.sb.*); - sbss.end = .; - bsp_section_sbss_end = .; - bsp_section_sdata_libdl_begin = .; - . = DEFINED(bsp_section_small_data_area_size) ? - bsp_section_sdata_begin + bsp_section_small_data_area_size : .; - bsp_section_sdata_libdl_end = .; - } > RAM - PROVIDE(__SBSS_END__ = .); - - /* Zeroed large data */ - .bss : { - . = ALIGN (4); - bss.start = .; - *(.bss .bss* .gnu.linkonce.b*) - . = ALIGN(4); - bss.end = .; - } > RAM - - bss.size = bss.end - bss.start; - sbss.size = sbss.end - sbss.start; - - .noinit (NOLOAD) : { - *(.noinit*) - } >RAM - - .rtemsstack (NOLOAD) : { - *(SORT(.rtemsstack.*)) - } >RAM - - WorkAreaBase = .; - - /* Debugging information */ - .line 0 : { *(.line) } - .debug 0 : { *(.debug) } - .debug_sfnames 0 : { *(.debug_sfnames) } - .debug_srcinfo 0 : { *(.debug_srcinfo) } - .debug_pubnames 0 : { *(.debug_pubnames) } - .debug_aranges 0 : { *(.debug_aranges) } - .debug_aregion 0 : { *(.debug_aregion) } - .debug_macinfo 0 : { *(.debug_macinfo) } - .stab 0 : { *(.stab) } - .stabstr 0 : { *(.stabstr) } -} diff --git a/bsps/powerpc/haleakala/start/mmu_405.c b/bsps/powerpc/haleakala/start/mmu_405.c deleted file mode 100644 index ea45807..0000000 --- a/bsps/powerpc/haleakala/start/mmu_405.c +++ /dev/null @@ -1,293 +0,0 @@ -/* - * Simple interface to the PowerPC 405 MMU - * - * Michael Hamel ADInstruments 2008 - * - */ - - -#include -#include -#include "mmu_405.h" -#include - -/* #define qLogTLB */ -/* #define qLogTLBDetails */ - - -/*----------------------------- TLB handling -------------------------------- */ -/* The following are in assembler in mmu_405asm.S */ -extern void MMU_GetTLBEntry(uint8_t index, uint32_t* tagword, uint32_t* dataword, uint8_t* pid); -extern void MMU_SetTLBEntry(uint8_t index, uint32_t hiword, uint32_t loword, uint8_t pid); -extern void MMU_ClearTLBs(void); -extern int16_t MMU_FindTLBEntry(uint32_t address); - - -enum { kNTLBs = 64 }; /* for 403GCX and 405 */ - -static bool sFreeTLBs[kNTLBs]; -static uint8_t sLastIndex = 0; -static int sNInUse = 0; - -static void MMUFault(const char* what) -/* Used for all setup faults; these can't really be ignored */ -{ - printk("\n>>>MMU fatal error %s\n",what); - rtems_fatal_error_occurred(RTEMS_INTERNAL_ERROR); -} - -static uint8_t AllocTLB(void) -{ - uint8_t index; - - index = sLastIndex; - do { - index++; - if (index == kNTLBs) - index = 0; - if (index == sLastIndex) - MMUFault("TLB table full"); - } while (! sFreeTLBs[index]); - sFreeTLBs[index] = false; - sLastIndex = index; - sNInUse++; - return index; -} - -static void FreeTLB(uint8_t index) -{ - MMU_SetTLBEntry(index,0,0,0); - sFreeTLBs[index] = true; - sLastIndex = index-1; - sNInUse--; -} - - -/*---------------------------- MMU operations ---------------------------------- */ - -int DataMissException(BSP_Exception_frame *f, unsigned int vector); -int InstructionMissException(BSP_Exception_frame *f, unsigned int vector); -int InstructionFetchException(BSP_Exception_frame *f, unsigned int vector); -void mmu_initialise(void); -int mmu_get_tlb_count(void); -uint8_t mmu_new_processID(void); -uint8_t mmu_current_processID(void); - -void -mmu_initialise(void) -/* Clear the TLBs and set up exception handlers for the MMU miss handlers */ -{ - int i; - - MMU_ClearTLBs(); - for (i=0; i 0) { - /* Find the largest block we can base on this address */ - mask = 0x3FF; - sizeCode = 0; - while (mask < nBytes && ((startAt & mask)==0) && sizeCode < 8) { - mask = (mask<<2) + 3; - sizeCode++; - } - mask >>= 2; - sizeCode--; - - /* Make a TLB entry describing this, ZSEL=0 */ - tagWord = startAt | (sizeCode<<7) | 0x40; - dataWord = startAt | options; - index = AllocTLB(); - MMU_SetTLBEntry( index , tagWord, dataWord, PID); - - { - /* Paranoia: check that we can read that back... */ - uint8_t tdex, oldpid; - - oldpid = mmu_current_processID(); - mmu_set_processID(PID); - tdex = MMU_FindTLBEntry(startAt); - mmu_set_processID(oldpid); - - if (tdex != index) { - printk(" Add TLB %d: At %" PRIx32 " for $%" PRIx32 - " sizecode %d tagWord $%" PRIx32 " ", - index, startAt, mask+1,sizeCode,tagWord); - printk(" -- find failed, %d/%d!\n",tdex,index); - MMU_GetTLBEntry(index, &tagWord, &dataWord, &pid); - printk(" -- reads back $%" PRIx32 " : $%" PRIx32 - ", PID %d\n",tagWord,dataWord,pid); - } else { - #ifdef qLogTLBDetails - printk(" Add TLB %d: At %X for $%X sizecode %d tagWord $%X\n",index, startAt, mask+1,sizeCode,tagWord); - #endif - } - } - - /* Subtract block from startAddr and nBytes */ - mask++; /* Convert to a byte count */ - startAt += mask; - nBytes -= mask; - } - #ifdef qLogTLB - printk(" %d in use\n",sNInUse); - #endif -} - -void -mmu_remove_space(uint32_t startAt, uint32_t endAt) -{ - int16_t index; - int32_t size; - uint32_t tagword, dataword, nBytes; - uint8_t pid, sCode; - - nBytes = endAt - startAt; - - #ifdef qLogTLB - printk("TLB: delete entries for $%X bytes from $%X\n",nBytes,startAt); - #endif - - while (nBytes > 0) { - index = MMU_FindTLBEntry( (uint32_t)startAt ); - size = 1024; - if (index >= 0) { - MMU_GetTLBEntry(index, &tagword, &dataword, &pid); - if ((tagword & 0x40) == 0) - MMUFault("Undefine failed: redundant entries?"); - if ((tagword & 0xFFFFFC00) != (uint32_t)startAt) - MMUFault("Undefine not on TLB boundary"); - FreeTLB(index); - sCode = (tagword >> 7) & 7; - while (sCode > 0) { - size <<= 2; - sCode--; - } - #ifdef qLogTLBDetails - printk(" Free TLB %d: At %X for $%X\n",index, startAt, size); - #endif - } - startAt += size; - nBytes -= size; - } -} - -void -mmu_add_space(uint32_t startAddr, uint32_t endAddr, MMUAccessType permissions, uint8_t processID) -/* Convert accesstype to write-enable, executable, and cache-inhibit bits */ -{ - bool EX, WR, I; - - EX = false; - WR = false; - I = false; - switch (permissions) { - case executable : EX = true; break; - case readOnlyData : break; - case readOnlyNoCache : I = true; break; - case readWriteData : WR = true; break; - case readWriteNoCache : WR = true; I= true; break; - case readWriteExecutable: WR = true; EX = true; break; - } - MakeTLBEntries( (uint32_t)startAddr, (uint32_t)(endAddr-startAddr+1), EX, WR, I, processID); -} - -int -mmu_get_tlb_count(void) -{ - return sNInUse; -} - -/*---------------------------- CPU process ID handling ---------------------------------- - * Really dumb system where we just hand out sequential numbers and eventually fail - * As long as we only use 8-9 processes this isn't a problem */ - -static uint8_t sNextPID = 1; - -#define SPR_PID 0x3B1 - -uint8_t mmu_new_processID(void) -{ - return sNextPID++; -} - -void mmu_free_processID(uint8_t freeThis) -{ -} - -uint8_t mmu_current_processID(void) -{ - return PPC_SPECIAL_PURPOSE_REGISTER(SPR_PID); -} - -uint8_t mmu_set_processID(uint8_t newID) -{ - uint8_t prev = mmu_current_processID(); - PPC_SET_SPECIAL_PURPOSE_REGISTER(SPR_PID,newID); - return prev; -} - - -/* ------------------ Fault handlers ------------------ */ - -#define SPR_ESR 0x3D4 -#define SPR_DEAR 0x3D5 - -enum { kESR_DST = 0x00800000 }; - -int DataMissException(BSP_Exception_frame *f, unsigned int vector) -{ - uint32_t addr, excSyn; - - addr = PPC_SPECIAL_PURPOSE_REGISTER(SPR_DEAR); - excSyn = PPC_SPECIAL_PURPOSE_REGISTER(SPR_ESR); - if (excSyn & kESR_DST) printk("\n---Data write to $%" PRIx32 - " attempted at $%" PRIxPTR "\n",addr,f->EXC_SRR0); - else printk("\n---Data read from $%" PRIx32 " attempted at $%" - PRIxPTR "\n",addr,f->EXC_SRR0); - return -1; -} - -int InstructionMissException(BSP_Exception_frame *f, unsigned int vector) -{ - printk("\n---Instruction fetch attempted from $%" PRIxPTR ", no TLB exists\n", - f->EXC_SRR0); - return -1; -} - -int InstructionFetchException(BSP_Exception_frame *f, unsigned int vector) -{ - printk("\n---Instruction fetch attempted from $%" PRIxPTR - ", TLB is no-execute\n",f->EXC_SRR0); - return -1; -} diff --git a/bsps/powerpc/haleakala/start/mmu_405asm.S b/bsps/powerpc/haleakala/start/mmu_405asm.S deleted file mode 100644 index 5fef5fb..0000000 --- a/bsps/powerpc/haleakala/start/mmu_405asm.S +++ /dev/null @@ -1,83 +0,0 @@ -/* - -Low-level interface to the PPC405 MMU - -M.Hamel ADInstruments 2008 - -*/ - -#include - -/* Useful MMU SPR values */ - -#define SPR_ZPR 0x3B0 -#define SPR_PID 0x3B1 - - .text - -/* void MMU_ClearTLBs(); */ - PUBLIC_VAR(MMU_ClearTLBs) -SYM (MMU_ClearTLBs): - tlbia - isync - lis r3,0x5555 // *** Gratuitous fiddle of ZPR to 0101010101 to take it out of - mtspr SPR_ZPR,r3 // the picture - blr - -/* void MMU_SetTLBEntry(UInt8 index, UInt32 tagword, UInt32 dataword, UInt8 SPR_PID) */ - PUBLIC_VAR(MMU_SetTLBEntry) -SYM (MMU_SetTLBEntry): - mfspr r7,SPR_PID // Save the current SPR_PID - mtspr SPR_PID,r6 // Write to SPR_PID - tlbwehi r4,r3 // Write hiword - mtspr SPR_PID,r7 // Restore the SPR_PID - tlbwelo r5,r3 // Write loword - isync - blr - -/* void MMU_GetTLBEntry(UInt8 index, UInt32& tagword, UInt32& dataword, UInt8& SPR_PID) */ - PUBLIC_VAR(MMU_GetTLBEntry) -SYM (MMU_GetTLBEntry): - mfspr r7,SPR_PID // Save the current SPR_PID - tlbrehi r8,r3 // Read hiword & SPR_PID - mfspr r9,SPR_PID // Copy the SPR_PID - mtspr SPR_PID,r7 // Restore original SPR_PID so we can proceed - stw r8,0(r4) // Write to r4 pointer - stb r9,0(r6) // Write to r6 pointer - tlbrelo r8,r3 // Read loword - stw r8,0(r5) // Write to r5 pointer - blr - -/* SInt16 MMU_FindTLBEntry(UInt32 address) */ -/* Returns index of covering TLB entry (0..63), or -1 if there isn't one */ - PUBLIC_VAR(MMU_FindTLBEntry) -SYM (MMU_FindTLBEntry): - tlbsx. r3,0,r3 - beqlr - li r3,0xFFFFFFFF - blr - -/* bool mmu_enable_code(bool enable); */ - PUBLIC_VAR(mmu_enable_code) -SYM (mmu_enable_code): - li r5,0x20 // IR bit - b msrbits - -/* bool mmu_enable_data(bool enable); */ - PUBLIC_VAR(mmu_enable_data) -SYM (mmu_enable_data): - li r5,0x10 // DR bit -msrbits: cmpwi r3,0 // Common code: parameter 0? - mfmsr r4 // r4 = MSR state - beq clrBit - or r6,r4,r5 // If 1, r6 = MSR with bit set - b setmsr -clrBit: andc r6,r4,r5 // If 0 r6 = MSR with bit clear -setmsr: mtmsr r6 // Write new MSR - and. r3,r4,r5 // Result = old MSR bit - beqlr // If zero return zero - li r3,0xFF // If nonzero return byte -1 - blr - - - diff --git a/bsps/powerpc/haleakala/start/start.S b/bsps/powerpc/haleakala/start/start.S deleted file mode 100644 index 43dde91..0000000 --- a/bsps/powerpc/haleakala/start/start.S +++ /dev/null @@ -1,237 +0,0 @@ -/* dlentry.s - * - * This file contains the entry code for RTEMS programs starting - * after download to RAM - * - * Author: Thomas Doerfler - * IMD Ingenieurbuero fuer Microcomputertechnik - * - * COPYRIGHT (c) 1998 by IMD - * - * Changes from IMD are covered by the original distributions terms. - * This file has been derived from the papyrus BSP: - * - * This file contains the entry veneer for RTEMS programs - * downloaded to Papyrus. - * - * Author: Andrew Bray - * - * COPYRIGHT (c) 1995 by i-cubed ltd. - * - * To anyone who acknowledges that this file is provided "AS IS" - * without any express or implied warranty: - * permission to use, copy, modify, and distribute this file - * for any purpose is hereby granted without fee, provided that - * the above copyright notice and this notice appears in all - * copies, and that the name of i-cubed limited not be used in - * advertising or publicity pertaining to distribution of the - * software without specific, written prior permission. - * i-cubed limited makes no representations about the suitability - * of this software for any purpose. - * - * derived from "helas403/dlentry.S": - * - * Further changes to derive for the PPC405CR/GP/GPr/EX/EXr - * by Michael Hamel ADInstruments Ltd 2008 - */ - -#include - -/* - * The virtex ELF link scripts support three special sections: - * .entry The actual entry point - * .vectors The section containing the interrupt entry veneers. - */ - -/* - * Downloaded code loads the vectors separately to 0x00000100, - * so .entry can be over 256 bytes. - * - * The other sections are linked in the following order: - * .entry - * .text - * .data - * .bss - * see linker command file for section placement - * - * The initial stack is set to _ISR_Stack_area_end. - * - * All the entry veneer has to do is to clear the BSS. - */ - -/* - * GDB likes to have debugging information for the entry veneer. - * Here was some DWARF information. IMD removed it, because we - * could not check, whether it was still correct. Sorry. - - */ - - - .section .entry - - PUBLIC_VAR (start) - PUBLIC_VAR (download_entry) - PUBLIC_VAR (__rtems_entry_point) - -SYM(start): -SYM(download_entry): -SYM(__rtems_entry_point): - - .extern SYM (boot_card) - - bl .startup /* First word is branch to reset_entry */ - - -/*--------------------------------------------------------------------------- - * Parameters from linker - *--------------------------------------------------------------------------*/ - -base_addr: -toc_pointer: - .long s.got -bss_length: - .long bss.size -bss_addr: - .long bss.start -sbss_length: - .long sbss.size -sbss_addr: - .long sbss.start -stack_top: - .long _ISR_Stack_area_end -PUBLIC_VAR (text_addr) -text_addr: - .long text.start -PUBLIC_VAR (text_length) -text_length: - .long text.size - -/*--------------------------------------------------------------------------- - * Reset_entry. - *--------------------------------------------------------------------------*/ -.startup: - /* Get entrypoint address in R1 so we can find linker variables */ - mflr r1 - - /* Initialise procesor registers generally */ - bl init405 - - /* Clear .bss and .sbss */ - bl bssclr - - /*------------------------------------------------------------------- - * C_setup. - *------------------------------------------------------------------*/ - lwz r1,stack_top - base_addr(r1) /* Now set R1 to stack_top */ - addi r1,r1,-56-4 /* start stack at text_addr - 56 */ - li r3,0 - stw r3, 0(r1) /* Clear stack chain */ - stw r3, 4(r1) - stw r3, 8(r1) - stw r3, 12(r1) - - bl __eabi /* Initialise EABI: sets up r2 & r13 */ - - li r3, 0 /* command line */ - - b SYM (boot_card) /* call the first C routine */ - -/*--------------------------------------------------------------------------- - * bssclr. - *--------------------------------------------------------------------------*/ -bssclr: lwz r2,bss_addr-base_addr(r1) /* start of bss set by loader */ - lwz r3,bss_length-base_addr(r1) /* bss length */ - srwi. r3,r3,2 /* div 4 to get # of words */ - li r0,0 - beq dosbss /* no bss */ - mtctr r3 /* set ctr reg */ - subi r2,r2,4 -clear_bss: stwu r0,4(r2) - bdnz clear_bss /* decrement counter and loop */ - -dosbss: lwz r2,sbss_addr-base_addr(r1) /* start of sbss set by loader */ - lwz r3,sbss_length-base_addr(r1) /* sbss length */ - slwi. r3,r3,2 /* div 4 to get # of words */ - subi r2,r2,4 - beqlr /* no sbss */ - mtctr r3 /* set ctr reg */ -clear_sbss: stwu r0,4(r2) - bdnz clear_sbss /* decrement counter and loop */ - - blr /* return */ - - -/*--------------------------------------------------------------------------- - * Generic 405 register setup - *--------------------------------------------------------------------------*/ -init405: - li r0, 0 - mtmsr r0 - mticcr r0 - mtdccr r0 - - li r3,0x7FFC # 405EX-specific - mtsgr r3 # Clear guarded mode on all storage except PCIe region - - mtsler r0 # Storage is all big-endian - mtsu0r r0 # and uncompressed - - iccci r3,0 # Invalidate the instruction cache - li r3,1 # Enable F800 0000 to FFFF FFFF - oris r3,r3,0xC000 # Enable 0000 0000 to 0FFF FFFF - mticcr r3 - isync - - li r3,0 - li r4,256 # 405 has 128 or 256 32-byte lines: do 256 - mtctr r4 # set loop ctr -dcloop: dccci 0,r3 # invalidate line - addi r3,r3,0x20 # bump to next line - bdnz dcloop - mtdcwr r0 # Select write-back caching - lis r3,0xC000 # Enable 0000 0000 to 0FFF FFFF - # mtdccr r3 # Enable data cache - - mtevpr r0 - mtesr r0 - mtxer r0 - - lwarx r3,r0,r0 # get some data/set resv bit - stwcx. r3,r0,r0 # store out and clear resv bit - - lis r3,0xDEAD - ori r3,r3,0xBEEF # Make distintive uninitialised value - mr r4, r3 - mr r5, r3 - mr r6, r3 - mr r7, r3 - mr r8, r3 - mr r9, r3 - mr r10, r3 - mr r11, r3 - mr r12, r3 - mr r13, r3 - mr r14, r3 - mr r15, r3 - mr r16, r3 - mr r17, r3 - mr r18, r3 - mr r19, r3 - mr r20, r3 - mr r21, r3 - mr r22, r3 - mr r23, r3 - mr r24, r3 - mr r25, r3 - mr r26, r3 - mr r27, r3 - mr r28, r3 - mr r29, r3 - mr r30, r3 - mr r31, r3 - - blr - -.L_text_e: - - .comm environ,4,4 diff --git a/spec/build/bsps/optconsolebaud.yml b/spec/build/bsps/optconsolebaud.yml index 0233fdd..b32dfb8 100644 --- a/spec/build/bsps/optconsolebaud.yml +++ b/spec/build/bsps/optconsolebaud.yml @@ -13,7 +13,6 @@ default-by-variant: - m68k/m5484FireEngine - powerpc/hsc_cm01 - powerpc/beatnik - - powerpc/haleakala - powerpc/mvme3100 - powerpc/mvme5500 - value: 19200 diff --git a/spec/build/bsps/powerpc/haleakala/abi.yml b/spec/build/bsps/powerpc/haleakala/abi.yml deleted file mode 100644 index 1fc318b..0000000 --- a/spec/build/bsps/powerpc/haleakala/abi.yml +++ /dev/null @@ -1,18 +0,0 @@ -SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause -actions: -- get-string: null -- split: null -- env-append: null -build-type: option -copyrights: -- Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de) -default: -- -Dppc405 -- -mcpu=405 -default-by-variant: [] -description: | - ABI flags -enabled-by: true -links: [] -name: ABI_FLAGS -type: build diff --git a/spec/build/bsps/powerpc/haleakala/bsphaleakala.yml b/spec/build/bsps/powerpc/haleakala/bsphaleakala.yml deleted file mode 100644 index 18ff252..0000000 --- a/spec/build/bsps/powerpc/haleakala/bsphaleakala.yml +++ /dev/null @@ -1,72 +0,0 @@ -SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause -arch: powerpc -bsp: haleakala -build-type: bsp -cflags: [] -copyrights: -- Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de) -cppflags: [] -enabled-by: true -family: haleakala -includes: [] -install: -- destination: ${BSP_INCLUDEDIR} - source: - - bsps/powerpc/haleakala/include/bsp.h - - bsps/powerpc/haleakala/include/mmu_405.h - - bsps/powerpc/haleakala/include/tm27.h -- destination: ${BSP_INCLUDEDIR}/bsp - source: - - bsps/powerpc/haleakala/include/bsp/irq.h -- destination: ${BSP_LIBDIR} - source: - - bsps/powerpc/haleakala/start/linkcmds -links: -- role: build-dependency - uid: ../../obj -- role: build-dependency - uid: ../../objirqdflt -- role: build-dependency - uid: ../../opto1 -- role: build-dependency - uid: ../crti -- role: build-dependency - uid: ../crtn -- role: build-dependency - uid: ../grp -- role: build-dependency - uid: abi -- role: build-dependency - uid: ../../optconsolebaud -- role: build-dependency - uid: optsprg -- role: build-dependency - uid: optvecbase -- role: build-dependency - uid: start -- role: build-dependency - uid: ../obj -- role: build-dependency - uid: ../objexc -- role: build-dependency - uid: ../../objmem -- role: build-dependency - uid: ../../bspopts -source: -- bsps/powerpc/haleakala/irq/irq.c -- bsps/powerpc/haleakala/irq/irq_init.c -- bsps/powerpc/haleakala/start/bspstart.c -- bsps/powerpc/haleakala/start/mmu_405.c -- bsps/powerpc/haleakala/start/mmu_405asm.S -- bsps/powerpc/shared/btimer/btimer-ppc-dec.c -- bsps/powerpc/shared/cache/cache.c -- bsps/powerpc/shared/clock/clock-ppc403.c -- bsps/powerpc/shared/console/console.c -- bsps/powerpc/shared/console/uart.c -- bsps/powerpc/shared/irq/ppc-irq-legacy.c -- bsps/shared/dev/getentropy/getentropy-cpucounter.c -- bsps/shared/start/bspfatal-default.c -- bsps/shared/start/bspreset-loop.c -- bsps/shared/start/gettargethash-default.c -- bsps/shared/start/sbrk.c -type: build diff --git a/spec/build/bsps/powerpc/haleakala/optsprg.yml b/spec/build/bsps/powerpc/haleakala/optsprg.yml deleted file mode 100644 index 1e1a112..0000000 --- a/spec/build/bsps/powerpc/haleakala/optsprg.yml +++ /dev/null @@ -1,15 +0,0 @@ -SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause -actions: -- get-boolean: null -- define-condition: null -build-type: option -copyrights: -- Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de) -default: true -default-by-variant: [] -description: | - If defined, then the PowerPC specific code in RTEMS will use some of the special purpose registers to slightly optimize interrupt response time. The use of these registers can conflict with other tools like debuggers. -enabled-by: true -links: [] -name: PPC_USE_SPRG -type: build diff --git a/spec/build/bsps/powerpc/haleakala/optvecbase.yml b/spec/build/bsps/powerpc/haleakala/optvecbase.yml deleted file mode 100644 index 93812ff..0000000 --- a/spec/build/bsps/powerpc/haleakala/optvecbase.yml +++ /dev/null @@ -1,16 +0,0 @@ -SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause -actions: -- get-integer: null -- define: null -build-type: option -copyrights: -- Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de) -default: 256 -default-by-variant: [] -description: | - This defines the base address of the exception table. NOTE: Vectors are actually at 0xFFF00000 but file starts at offset. -enabled-by: true -format: '{:#010x}' -links: [] -name: PPC_VECTOR_FILE_BASE -type: build diff --git a/spec/build/bsps/powerpc/haleakala/start.yml b/spec/build/bsps/powerpc/haleakala/start.yml deleted file mode 100644 index 204dfd4..0000000 --- a/spec/build/bsps/powerpc/haleakala/start.yml +++ /dev/null @@ -1,14 +0,0 @@ -SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause -asflags: [] -build-type: start-file -copyrights: -- Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de) -cppflags: [] -enabled-by: true -includes: [] -install-path: ${BSP_LIBDIR} -links: [] -source: -- bsps/powerpc/haleakala/start/start.S -target: start.o -type: build -- 1.8.3.1 From joel.sherrill at gmail.com Fri Dec 17 17:05:51 2021 From: joel.sherrill at gmail.com (Joel Sherrill) Date: Fri, 17 Dec 2021 11:05:51 -0600 Subject: Ticket 4503 In-Reply-To: References: Message-ID: Zack, did you ever make any progress on this? I'm just looking at tickets and wondered. On Sat, Dec 11, 2021 at 9:41 AM Gedare Bloom wrote: > > On Thu, Nov 18, 2021 at 7:22 PM zack leung wrote: > > > > bump > > > > On Mon, 18 Oct 2021 at 23:58, zack leung wrote: > > > > > bump > > > > > > > > > On Sat, 25 Sept 2021 at 00:26, zack leung > > > wrote: > > > > > >> bump > > >> > > >> On Thu, 9 Sept 2021 at 02:17, zack leung > > >> wrote: > > >> > > >>> >Thanks! I guess i'm really unsure about how the pointer relates to the > > >>> amount of memory that you can use. I assume the Malloc keeps track of the > > >>> sections being used in the heap. Does this function Allocate 2 blocks since > > >>> the pointer is set to > > >>> > > >>> (uintptr_t) next_block + HEAP_ALLOC_BONUS - alloc_begin; > > >>> > > No, this is calculating the size of 'this block' considering that it's > allocated memory starts at "alloc_begin" and it ends at the > "next_block" heap block metadata or header. You should read about how > malloc implementations generally work. The allocated memory has some > metadata before it to implement the linked data structures necessary > to support dynamic allocation. So a block is the header + allocated > range. Only the allocated range plus any excess before the next > block's header is considered usable. > > > >>> >(I know it's a bit naive to assume this given my first question) > > >>> > > >>> think the method is _Heap_Size_of_alloc_area. It may need a wrapper > > >>> added to the protected heap wrapper for safety. I don't know if it has one. > > >>> It should be the equivalent functionality. > > >>> > How would i implement a wrapper and what safety measures need to be > > >>> implemented. So far it's checking if : the block is not in the heap and if > > >>> it's been previously used. Is the usable memory in the heap calculated by: > > >>> the size of the block * # of blocks? > > >>> > > You would have to see if the Protected Heap implementation has some > additional metadata between the end of an allocated range in one block > and the block header in the next. I don't think it matters too much > because most of the 'protected' aspects have to do with free block > management. But that should be confirmed. > > The check is not "if it's been previously used" I suggest that you > look at what the invoked function does and how it is documented. Avoid > making assumptions based on names. > > The usable memory is NOT the size of the block * # of blocks, because > the size of the block includes the header. > > > >>> Thanks, Zack > > >>> > > >>> ---------- Forwarded message --------- > > >>> From: Joel Sherrill > > >>> Date: Wed, 8 Sept 2021 at 20:30 > > >>> Subject: Re: Ticket 4503 > > >>> To: Gedare Bloom > > >>> Cc: zack leung , rtems-devel at rtems.org < > > >>> devel at rtems.org> > > >>> > > >>> > > >>> > > >>> > > >>> On Wed, Sep 8, 2021 at 11:02 AM Gedare Bloom wrote: > > >>> > > >>>> Hi Zack, > > >>>> > > >>>> https://devel.rtems.org/ticket/4503 > > >>>> > > >>>> The malloc implementation exists in the score as the Heap Manager. > > >>>> search for "Heap_" within cpukit to get some ideas where to look. > > >>>> > > >>> > > >>> I think the method is _Heap_Size_of_alloc_area. It may need a wrapper > > >>> added to the protected heap wrapper for safety. I don't know if it has one. > > >>> It should be the equivalent functionality. > > >>> > > >>> newlib's malloc.h will need looking at to make sure we provide the right > > >>> methods. > > >>> > > >>> > > >>> > > >>>> > > >>>> @Joel are these two tickets duplicates? > > >>>> https://devel.rtems.org/ticket/4503 > > >>>> https://devel.rtems.org/ticket/4271 > > >>>> > > >>> > > >>> Yes. Closed #4271 and merged comments. > > >>> > > >>> --joel > > >>> > > >>> > > >>>> > > >>>> > > >>>> -Gedare > > >>>> > > >>>> On Tue, Sep 7, 2021 at 7:14 PM zack leung > > >>>> wrote: > > >>>> > > >>>>> I was wondering about ticket 4503. I was wondering where The required > > >>>>> functionality should be in the underlying score/ capability used can be > > >>>>> found to write this function. Also how does this relate to > > >>>>> > > >>>>> Add common malloc family extension method malloc_usable_size() > > >>>>> ? > > >>>>> Thanks > > >>>>> Zack > > >>>>> _______________________________________________ > > >>>>> devel mailing list > > >>>>> devel at rtems.org > > >>>>> http://lists.rtems.org/mailman/listinfo/devel > > >>>> > > >>>> > > _______________________________________________ > > devel mailing list > > devel at rtems.org > > http://lists.rtems.org/mailman/listinfo/devel > _______________________________________________ > devel mailing list > devel at rtems.org > http://lists.rtems.org/mailman/listinfo/devel From ryan.long at oarcorp.com Fri Dec 17 21:35:19 2021 From: ryan.long at oarcorp.com (Ryan Long) Date: Fri, 17 Dec 2021 16:35:19 -0500 Subject: [PATCH rtems-docs] Update package list for Ubuntu Message-ID: <1639776919-4720-1-git-send-email-ryan.long@oarcorp.com> Updated the latest version referenced of Ubuntu to 21.04, updated package list, and identified what packages need to still be installed afterwards to pass sb-check. Closes #4110 --- user/hosts/posix.rst | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/user/hosts/posix.rst b/user/hosts/posix.rst index 818eb25..6fbf401 100644 --- a/user/hosts/posix.rst +++ b/user/hosts/posix.rst @@ -137,23 +137,23 @@ prefix under your home directory as recommended and end up on the SD card. Ubuntu ~~~~~~ -The latest version is Ubuntu 18.04.1 LTS 64-bit. This section also includes +The latest version is Ubuntu 21.04.1 LTS 64-bit. This section also includes Xubuntu. A minimal installation was used and the following packages installed: .. code-block:: none - $ sudo apt-get build-dep build-essential gcc-defaults g++ gdb git \ - unzip pax bison flex texinfo unzip python3-dev libpython-dev \ - libncurses5-dev zlib1g-dev + $ sudo apt-get build-dep build-essential gcc-defaults g++ gdb unzip \ + pax bison flex texinfo python3-dev libpython2-dev libncurses5-dev \ + zlib1g-dev -Note that in previous versions of Ubuntu, the package libpython-dev was +Note that in previous versions of Ubuntu, the package libpython2-dev was python2.7-dev. The name of packages changes over time. You need the package with Python development libraries for C/C++ programs. The following is needed for recent versions: .. code-block:: none - $ sudo apt-get install python-dev + $ sudo apt-get install python git It is likely necessary that you will have to enable the Ubuntu Source Repositories. Users have suggested the following web pages which have -- 1.8.3.1 From karel at functional.vision Fri Dec 17 21:49:32 2021 From: karel at functional.vision (Karel Gardas) Date: Fri, 17 Dec 2021 22:49:32 +0100 Subject: [PATCH rtems-docs] Update package list for Ubuntu In-Reply-To: <1639776919-4720-1-git-send-email-ryan.long@oarcorp.com> References: <1639776919-4720-1-git-send-email-ryan.long@oarcorp.com> Message-ID: On 12/17/21 10:35 PM, Ryan Long wrote: > diff --git a/user/hosts/posix.rst b/user/hosts/posix.rst > index 818eb25..6fbf401 100644 > --- a/user/hosts/posix.rst > +++ b/user/hosts/posix.rst > @@ -137,23 +137,23 @@ prefix under your home directory as recommended and end up on the SD card. > Ubuntu > ~~~~~~ > > -The latest version is Ubuntu 18.04.1 LTS 64-bit. This section also includes > +The latest version is Ubuntu 21.04.1 LTS 64-bit. This section also includes This is certainly not correct. Either you mean 20.04.03 LTS or you mean regular Ubuntu which is 21.10 of this time (and no "LTS" attached!). Simply your version "21.04.1 LTS" is non existent in this galaxy... Cheers, Karel From ral051 at oarcorp.com Fri Dec 17 21:52:55 2021 From: ral051 at oarcorp.com (Ryan Long) Date: Fri, 17 Dec 2021 15:52:55 -0600 Subject: [PATCH rtems-docs] Update package list for Ubuntu In-Reply-To: References: <1639776919-4720-1-git-send-email-ryan.long@oarcorp.com> Message-ID: <34e33a48-8a61-aeea-b7b1-d5bdad96f35a@oarcorp.com> Ah, I thought they only put the .04 on the LTS releases. I'll change that and send in V2. On 12/17/2021 3:49 PM, Karel Gardas wrote: > On 12/17/21 10:35 PM, Ryan Long wrote: >> diff --git a/user/hosts/posix.rst b/user/hosts/posix.rst >> index 818eb25..6fbf401 100644 >> --- a/user/hosts/posix.rst >> +++ b/user/hosts/posix.rst >> @@ -137,23 +137,23 @@ prefix under your home directory as recommended and end up on the SD card. >> Ubuntu >> ~~~~~~ >> >> -The latest version is Ubuntu 18.04.1 LTS 64-bit. This section also includes >> +The latest version is Ubuntu 21.04.1 LTS 64-bit. This section also includes > This is certainly not correct. Either you mean 20.04.03 LTS or you mean > regular Ubuntu which is 21.10 of this time (and no "LTS" attached!). > > Simply your version "21.04.1 LTS" is non existent in this galaxy... > > Cheers, > Karel From karel at functional.vision Fri Dec 17 21:53:12 2021 From: karel at functional.vision (Karel Gardas) Date: Fri, 17 Dec 2021 22:53:12 +0100 Subject: [PATCH rtems-docs] Update package list for Ubuntu In-Reply-To: References: <1639776919-4720-1-git-send-email-ryan.long@oarcorp.com> Message-ID: <1b0286c5-2cc2-fbf6-0c2e-0662f74ce0ce@functional.vision> On 12/17/21 10:49 PM, Karel Gardas wrote: > On 12/17/21 10:35 PM, Ryan Long wrote: >> diff --git a/user/hosts/posix.rst b/user/hosts/posix.rst >> index 818eb25..6fbf401 100644 >> --- a/user/hosts/posix.rst >> +++ b/user/hosts/posix.rst >> @@ -137,23 +137,23 @@ prefix under your home directory as recommended and end up on the SD card. >> Ubuntu >> ~~~~~~ >> >> -The latest version is Ubuntu 18.04.1 LTS 64-bit. This section also includes >> +The latest version is Ubuntu 21.04.1 LTS 64-bit. This section also includes > > This is certainly not correct. Either you mean 20.04.03 LTS or you mean Sorry typo, zero should not be in 03. Here is what I run: $ cat /etc/os-release |grep PRETTY_NAME PRETTY_NAME="Ubuntu 20.04.3 LTS" and is canonical name of the distro... Karel From karel at functional.vision Fri Dec 17 21:56:54 2021 From: karel at functional.vision (Karel Gardas) Date: Fri, 17 Dec 2021 22:56:54 +0100 Subject: [PATCH rtems-docs] Update package list for Ubuntu In-Reply-To: <34e33a48-8a61-aeea-b7b1-d5bdad96f35a@oarcorp.com> References: <1639776919-4720-1-git-send-email-ryan.long@oarcorp.com> <34e33a48-8a61-aeea-b7b1-d5bdad96f35a@oarcorp.com> Message-ID: <7c033609-0ef7-1a87-3197-9d80a349de9d@functional.vision> On 12/17/21 10:52 PM, Ryan Long wrote: > Ah, I thought they only put the .04 on the LTS releases. I'll change > that and send in V2. No LTS line is 12.04, 14.04, 16.04, 18.04, 20.04 and next future is 22.04. Always released in April of the year (hence .04) and the number before it is obviously year number. Basically since LTS does not change that much or should not besides security fixes and perhaps hardware support, then you can freely use "Ubuntu 20.04.x LTS" since I guess RTEMS will not find difference between .1, .2, .3 spins of 20.04. Thanks, Karel > > On 12/17/2021 3:49 PM, Karel Gardas wrote: >> On 12/17/21 10:35 PM, Ryan Long wrote: >>> diff --git a/user/hosts/posix.rst b/user/hosts/posix.rst >>> index 818eb25..6fbf401 100644 >>> --- a/user/hosts/posix.rst >>> +++ b/user/hosts/posix.rst >>> @@ -137,23 +137,23 @@ prefix under your home directory as recommended >>> and end up on the SD card. >>> ? Ubuntu >>> ? ~~~~~~ >>> ? -The latest version is Ubuntu 18.04.1 LTS 64-bit. This section also >>> includes >>> +The latest version is Ubuntu 21.04.1 LTS 64-bit. This section also >>> includes >> This is certainly not correct. Either you mean 20.04.03 LTS or you mean >> regular Ubuntu which is 21.10 of this time (and no "LTS" attached!). >> >> Simply your version "21.04.1 LTS" is non existent in this galaxy... >> >> Cheers, >> Karel From joel at rtems.org Fri Dec 17 22:36:16 2021 From: joel at rtems.org (Joel Sherrill) Date: Fri, 17 Dec 2021 16:36:16 -0600 Subject: rtems.org downtime this weekend Message-ID: Hi Amar is planning on doing some upgrades over the weekend and various rtems.org services will be up and down as he works. We will let you know when it is done. --joel From joel at rtems.org Sun Dec 19 23:52:03 2021 From: joel at rtems.org (Joel Sherrill) Date: Sun, 19 Dec 2021 17:52:03 -0600 Subject: qemu (gettext) build failure on FreeBSD 12 Message-ID: Hi Any FreeBSD users have an idea how to resolve this build failure? Thanks /bin/sh ../libtool --tag=CC --mode=link /usr/bin/cc -O2 -pipe -fbracket-depth=1024 -I/usr/home/tester/rtems-cron-6/rtems-source-builder/bare/build/tmp/sb-1002/devel/qemu/home/tester/rtems-cron-6/tools/6/include -no-undefined ../intl/libintl.la -fopenmp -release 0.18.3 -L/usr/home/tester/rtems-cron-6/rtems-source-builder/bare/build/tmp/sb-1002/devel/qemu/home/tester/rtems-cron-6/tools/6/lib -lglib-2.0 -lpthread -L/usr/home/tester/rtems-cron-6/rtems-source-builder/bare/build/tmp/sb-1002/devel/qemu/home/tester/rtems-cron-6/tools/6/lib -lintl -R/usr/home/tester/rtems-cron-6/rtems-source-builder/bare/build/tmp/sb-1002/devel/qemu/home/tester/rtems-cron-6/tools/6/lib -lncurses -L/usr/home/tester/rtems-cron-6/rtems-source-builder/bare/build/tmp/sb-1002/devel/qemu/home/tester/rtems-cron-6/tools/6/lib -o libgettextlib.la -rpath /home/tester/rtems-cron-6/tools/6/lib copy-acl.lo set-acl.lo allocator.lo areadlink.lo argmatch.lo gl_array_list.lo backupfile.lo addext.lo basename.l o binary-io.lo c-ctype.lo c-strcasecmp.lo c-strncasecmp.lo c-strcasestr.lo c-strstr.lo careadlinkat.lo classpath.lo clean-temp.lo cloexec.lo closeout.lo concat-filename.lo copy-file.lo csharpcomp.lo csharpexec.lo error-progname.lo execute.lo exitfail.lo fatal-signal.lo fd-hook.lo fd-ostream.lo fd-safer-flag.lo dup-safer-flag.lo file-ostream.lo findprog.lo fstrcmp.lo full-write.lo fwriteerror.lo gcd.lo hash.lo html-ostream.lo html-styled-ostream.lo javacomp.lo javaexec.lo javaversion.lo gl_linkedhash_list.lo gl_list.lo localcharset.lo localename.lo glthread/lock.lo malloca.lo mbchar.lo mbiter.lo mbslen.lo mbsstr.lo mbswidth.lo mbuiter.lo ostream.lo pipe-filter-ii.lo pipe-filter-aux.lo pipe2.lo pipe2-safer.lo progname.lo propername.lo acl-errno-valid.lo file-has-acl.lo qcopy-acl.lo qset-acl.lo quotearg.lo safe-read.lo safe-write.lo sh-quote.lo sig-handler.lo spawn-pipe.lo striconv.lo striconveh.lo striconveha.lo strnlen1.lo styled-ostream.lo tempname.lo term-ostream.lo term-styled-o stream.lo glthread/threadlib.lo glthread/tls.lo tmpdir.lo trim.lo uniconv/u8-conv-from-enc.lo unilbrk/lbrktables.lo unilbrk/u8-possible-linebreaks.lo unilbrk/u8-width-linebreaks.lo unilbrk/ulc-common.lo unilbrk/ulc-width-linebreaks.lo uniname/uniname.lo unistd.lo dup-safer.lo fd-safer.lo pipe-safer.lo unistr/u16-mbtouc.lo unistr/u16-mbtouc-aux.lo unistr/u8-check.lo unistr/u8-mblen.lo unistr/u8-mbtouc.lo unistr/u8-mbtouc-aux.lo unistr/u8-mbtouc-unsafe.lo unistr/u8-mbtouc-unsafe-aux.lo unistr/u8-mbtoucr.lo unistr/u8-prev.lo unistr/u8-uctomb.lo unistr/u8-uctomb-aux.lo uniwidth/width.lo wait-process.lo wctype-h.lo xmalloc.lo xstrdup.lo xconcat-filename.lo xerror.lo gl_xlist.lo xmalloca.lo xreadlink.lo xsetenv.lo xsize.lo xstriconv.lo xstriconveh.lo xvasprintf.lo xasprintf.lo acl_entries.lo asnprintf.lo canonicalize-lgpl.lo error.lo getopt.lo getopt1.lo obstack.lo printf-args.lo printf-parse.lo rawmemchr.lo secure_getenv.lo spawn_faction_addclose.lo spawn_faction_adddup2.lo spawn_factio n_addopen.lo vasnprintf.lo libcroco_rpl.la libxml_rpl.la libtool: link: warning: library `/usr/home/tester/rtems-cron-6/rtems-source-builder/bare/build/tmp/sb-1002/devel/qemu/home/tester/rtems-cron-6/tools/6/lib/libglib-2.0.la' was moved. grep: /home/tester/rtems-cron-6/tools/6/lib/libintl.la: No such file or directory /usr/bin/sed: can't read /home/tester/rtems-cron-6/tools/6/lib/libintl.la: No such file or directory libtool: link: `/home/tester/rtems-cron-6/tools/6/lib/libintl.la' is not a valid libtool archive gmake[4]: *** [Makefile:2507: libgettextlib.la] Error 1 From sebastian.huber at embedded-brains.de Mon Dec 20 12:59:45 2021 From: sebastian.huber at embedded-brains.de (Sebastian Huber) Date: Mon, 20 Dec 2021 13:59:45 +0100 Subject: Alternative download paths for RSB? Message-ID: <0a59e7c7-37e2-24d0-70c3-31a326a8f75e@embedded-brains.de> Hello, it seems the GNU web server is down: download: https://ftp.gnu.org/gnu/mpfr/mpfr-3.1.4.tar.bz2 -> sources/mpfr-3.1.4.tar.bz2 download: https://ftp.gnu.org/gnu/mpfr/mpfr-3.1.4.tar.bz2: error: error: downloading https://ftp.gnu.org/gnu/mpfr/mpfr-3.1.4.tar.bz2: all paths have failed, giving up Build FAILED error: downloading https://ftp.gnu.org/gnu/mpfr/mpfr-3.1.4.tar.bz2: all paths have failed, giving up Build Set: Time 0:04:23.318509 Build FAILED The error message suggests that it is possible to add alternative download sources. How can I do this? This didn't work: diff --git a/source-builder/config/gcc-9.cfg b/source-builder/config/gcc-9.cfg index f8cf69b..1d7c716 100644 --- a/source-builder/config/gcc-9.cfg +++ b/source-builder/config/gcc-9.cfg @@ -21,4 +21,8 @@ %source set gmp https://ftp.gnu.org/gnu/gmp/gmp-%{gmp_version}.tar.bz2 %source set mpfr https://ftp.gnu.org/gnu/mpfr/mpfr-%{mpfr_version}.tar.bz2 +%source set mpc https://ftp.mpi-inf.mpg.de/pub/mirrors/gnu/mirror/gcc.gnu.org/pub/gcc/infrastructure/mpc-%{mpc_version}.tar.gz +%source set gmp https://ftp.mpi-inf.mpg.de/pub/mirrors/gnu/mirror/gcc.gnu.org/pub/gcc/infrastructure/gmp-%{gmp_version}.tar.bz2 +%source set mpfr https://ftp.mpi-inf.mpg.de/pub/mirrors/gnu/mirror/gcc.gnu.org/pub/gcc/infrastructure/mpfr-%{mpfr_version}.tar.bz2 + %include %{_configdir}/gcc-common-1.cfg -- embedded brains GmbH Herr Sebastian HUBER Dornierstr. 4 82178 Puchheim Germany email: sebastian.huber at embedded-brains.de phone: +49-89-18 94 741 - 16 fax: +49-89-18 94 741 - 08 Registergericht: Amtsgericht M?nchen Registernummer: HRB 157899 Vertretungsberechtigte Gesch?ftsf?hrer: Peter Rasmussen, Thomas D?rfler Unsere Datenschutzerkl?rung finden Sie hier: https://embedded-brains.de/datenschutzerklaerung/ From joel at rtems.org Mon Dec 20 14:54:59 2021 From: joel at rtems.org (Joel Sherrill) Date: Mon, 20 Dec 2021 08:54:59 -0600 Subject: Alternative download paths for RSB? In-Reply-To: <0a59e7c7-37e2-24d0-70c3-31a326a8f75e@embedded-brains.de> References: <0a59e7c7-37e2-24d0-70c3-31a326a8f75e@embedded-brains.de> Message-ID: On Mon, Dec 20, 2021 at 6:59 AM Sebastian Huber wrote: > > Hello, > > it seems the GNU web server is down: Yep. Still down. i reached out to the sourceware admins to see if they knew who to contact. I couldn't find a gnu.org address. > > download: https://ftp.gnu.org/gnu/mpfr/mpfr-3.1.4.tar.bz2 -> > sources/mpfr-3.1.4.tar.bz2 > download: https://ftp.gnu.org/gnu/mpfr/mpfr-3.1.4.tar.bz2: error: > > error: downloading https://ftp.gnu.org/gnu/mpfr/mpfr-3.1.4.tar.bz2: all > paths have failed, giving up > Build FAILED > error: downloading https://ftp.gnu.org/gnu/mpfr/mpfr-3.1.4.tar.bz2: all > paths have failed, giving up > Build Set: Time 0:04:23.318509 > Build FAILED > > The error message suggests that it is possible to add alternative > download sources. How can I do this? This didn't work: > > diff --git a/source-builder/config/gcc-9.cfg > b/source-builder/config/gcc-9.cfg > index f8cf69b..1d7c716 100644 > --- a/source-builder/config/gcc-9.cfg > +++ b/source-builder/config/gcc-9.cfg > @@ -21,4 +21,8 @@ > %source set gmp https://ftp.gnu.org/gnu/gmp/gmp-%{gmp_version}.tar.bz2 > %source set mpfr https://ftp.gnu.org/gnu/mpfr/mpfr-%{mpfr_version}.tar.bz2 > > +%source set mpc > https://ftp.mpi-inf.mpg.de/pub/mirrors/gnu/mirror/gcc.gnu.org/pub/gcc/infrastructure/mpc-%{mpc_version}.tar.gz > +%source set gmp > https://ftp.mpi-inf.mpg.de/pub/mirrors/gnu/mirror/gcc.gnu.org/pub/gcc/infrastructure/gmp-%{gmp_version}.tar.bz2 > +%source set mpfr > https://ftp.mpi-inf.mpg.de/pub/mirrors/gnu/mirror/gcc.gnu.org/pub/gcc/infrastructure/mpfr-%{mpfr_version}.tar.bz2 > + > %include %{_configdir}/gcc-common-1.cfg This would be Chris' department. Sorry > -- > embedded brains GmbH > Herr Sebastian HUBER > Dornierstr. 4 > 82178 Puchheim > Germany > email: sebastian.huber at embedded-brains.de > phone: +49-89-18 94 741 - 16 > fax: +49-89-18 94 741 - 08 > > Registergericht: Amtsgericht M?nchen > Registernummer: HRB 157899 > Vertretungsberechtigte Gesch?ftsf?hrer: Peter Rasmussen, Thomas D?rfler > Unsere Datenschutzerkl?rung finden Sie hier: > https://embedded-brains.de/datenschutzerklaerung/ > _______________________________________________ > devel mailing list > devel at rtems.org > http://lists.rtems.org/mailman/listinfo/devel From ryan.long at oarcorp.com Mon Dec 20 15:22:33 2021 From: ryan.long at oarcorp.com (Ryan Long) Date: Mon, 20 Dec 2021 10:22:33 -0500 Subject: [PATCH rtems-docs v2] Update package list for Ubuntu Message-ID: <1640013753-3995-1-git-send-email-ryan.long@oarcorp.com> Updated the latest version referenced of Ubuntu to 21.04, updated package list, and identified what packages need to still be installed afterwards to pass sb-check. Closes #4110 --- user/hosts/posix.rst | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/user/hosts/posix.rst b/user/hosts/posix.rst index 818eb25..8bcb3bd 100644 --- a/user/hosts/posix.rst +++ b/user/hosts/posix.rst @@ -137,23 +137,23 @@ prefix under your home directory as recommended and end up on the SD card. Ubuntu ~~~~~~ -The latest version is Ubuntu 18.04.1 LTS 64-bit. This section also includes +The latest version is Ubuntu 20.04.3 LTS 64-bit. This section also includes Xubuntu. A minimal installation was used and the following packages installed: .. code-block:: none - $ sudo apt-get build-dep build-essential gcc-defaults g++ gdb git \ - unzip pax bison flex texinfo unzip python3-dev libpython-dev \ - libncurses5-dev zlib1g-dev + $ sudo apt-get build-dep build-essential gcc-defaults g++ gdb unzip \ + pax bison flex texinfo python3-dev libpython2-dev libncurses5-dev \ + zlib1g-dev -Note that in previous versions of Ubuntu, the package libpython-dev was +Note that in previous versions of Ubuntu, the package libpython2-dev was python2.7-dev. The name of packages changes over time. You need the package with Python development libraries for C/C++ programs. The following is needed for recent versions: .. code-block:: none - $ sudo apt-get install python-dev + $ sudo apt-get install python git It is likely necessary that you will have to enable the Ubuntu Source Repositories. Users have suggested the following web pages which have -- 1.8.3.1 From joel at rtems.org Mon Dec 20 15:33:27 2021 From: joel at rtems.org (Joel Sherrill) Date: Mon, 20 Dec 2021 09:33:27 -0600 Subject: Alternative download paths for RSB? In-Reply-To: References: <0a59e7c7-37e2-24d0-70c3-31a326a8f75e@embedded-brains.de> Message-ID: On Mon, Dec 20, 2021 at 8:54 AM Joel Sherrill wrote: > > On Mon, Dec 20, 2021 at 6:59 AM Sebastian Huber > wrote: > > > > Hello, > > > > it seems the GNU web server is down: > > Yep. Still down. > > i reached out to the sourceware admins to see if they knew who to > contact. I couldn't find a gnu.org address. Social media post from FSF forwarded by one of the sourceware admins about a general outage at the FSF: https://hostux.social/@fsfstatus/107479476196064925 Looks to be up now. RSB handling mirrors would be good. Although it would seem to be complex to ensure that all entries and mirrors are correct. > > > > > download: https://ftp.gnu.org/gnu/mpfr/mpfr-3.1.4.tar.bz2 -> > > sources/mpfr-3.1.4.tar.bz2 > > download: https://ftp.gnu.org/gnu/mpfr/mpfr-3.1.4.tar.bz2: error: > > > > error: downloading https://ftp.gnu.org/gnu/mpfr/mpfr-3.1.4.tar.bz2: all > > paths have failed, giving up > > Build FAILED > > error: downloading https://ftp.gnu.org/gnu/mpfr/mpfr-3.1.4.tar.bz2: all > > paths have failed, giving up > > Build Set: Time 0:04:23.318509 > > Build FAILED > > > > The error message suggests that it is possible to add alternative > > download sources. How can I do this? This didn't work: > > > > diff --git a/source-builder/config/gcc-9.cfg > > b/source-builder/config/gcc-9.cfg > > index f8cf69b..1d7c716 100644 > > --- a/source-builder/config/gcc-9.cfg > > +++ b/source-builder/config/gcc-9.cfg > > @@ -21,4 +21,8 @@ > > %source set gmp https://ftp.gnu.org/gnu/gmp/gmp-%{gmp_version}.tar.bz2 > > %source set mpfr https://ftp.gnu.org/gnu/mpfr/mpfr-%{mpfr_version}.tar.bz2 > > > > +%source set mpc > > https://ftp.mpi-inf.mpg.de/pub/mirrors/gnu/mirror/gcc.gnu.org/pub/gcc/infrastructure/mpc-%{mpc_version}.tar.gz > > +%source set gmp > > https://ftp.mpi-inf.mpg.de/pub/mirrors/gnu/mirror/gcc.gnu.org/pub/gcc/infrastructure/gmp-%{gmp_version}.tar.bz2 > > +%source set mpfr > > https://ftp.mpi-inf.mpg.de/pub/mirrors/gnu/mirror/gcc.gnu.org/pub/gcc/infrastructure/mpfr-%{mpfr_version}.tar.bz2 > > + > > %include %{_configdir}/gcc-common-1.cfg > > This would be Chris' department. Sorry > > > -- > > embedded brains GmbH > > Herr Sebastian HUBER > > Dornierstr. 4 > > 82178 Puchheim > > Germany > > email: sebastian.huber at embedded-brains.de > > phone: +49-89-18 94 741 - 16 > > fax: +49-89-18 94 741 - 08 > > > > Registergericht: Amtsgericht M?nchen > > Registernummer: HRB 157899 > > Vertretungsberechtigte Gesch?ftsf?hrer: Peter Rasmussen, Thomas D?rfler > > Unsere Datenschutzerkl?rung finden Sie hier: > > https://embedded-brains.de/datenschutzerklaerung/ > > _______________________________________________ > > devel mailing list > > devel at rtems.org > > http://lists.rtems.org/mailman/listinfo/devel From ryan.long at oarcorp.com Mon Dec 20 20:24:55 2021 From: ryan.long at oarcorp.com (Ryan Long) Date: Mon, 20 Dec 2021 15:24:55 -0500 Subject: [PATCH rtems-tools v1] ReportsBase: Change raw pointer to unique_ptr Message-ID: <1640031895-29199-1-git-send-email-ryan.long@oarcorp.com> Replaced raw pointer used with ReportsBase-derived classes to make code cleaner and make it to where pointers do not have to be manually deleted. Closes #4376 --- tester/covoar/ReportsBase.cc | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/tester/covoar/ReportsBase.cc b/tester/covoar/ReportsBase.cc index 219e5af..8ec65c0 100644 --- a/tester/covoar/ReportsBase.cc +++ b/tester/covoar/ReportsBase.cc @@ -591,17 +591,16 @@ void GenerateReports( bool branchInfoAvailable ) { - typedef std::list reportList_t; + typedef std::vector> reportList_t; reportList_t reportList; reportList_t::iterator ritr; std::string reportName; - ReportsBase* reports; time_t timestamp; timestamp = time( NULL ); /* get current cal time */ - reports = new ReportsText( + reportList.emplace_back(new ReportsText( timestamp, symbolSetName, allExplanations, @@ -609,9 +608,8 @@ void GenerateReports( outputDirectory, symbolsToAnalyze, branchInfoAvailable - ); - reportList.push_back( reports ); - reports = new ReportsHtml( + )); + reportList.emplace_back(new ReportsHtml( timestamp, symbolSetName, allExplanations, @@ -619,11 +617,9 @@ void GenerateReports( outputDirectory, symbolsToAnalyze, branchInfoAvailable - ); - reportList.push_back( reports ); + )); - for ( ritr = reportList.begin(); ritr != reportList.end(); ritr++ ) { - reports = *ritr; + for ( auto& reports: reportList ) { reportName = "index" + reports->ReportExtension(); if ( verbose ) { @@ -662,11 +658,6 @@ void GenerateReports( reports->WriteSymbolSummaryReport( reportName, symbolsToAnalyze ); } - for ( ritr = reportList.begin(); ritr != reportList.end(); ritr++ ) { - reports = *ritr; - delete reports; - } - ReportsBase::WriteSummaryReport( "summary.txt", symbolSetName, -- 1.8.3.1 From chrisj at rtems.org Mon Dec 20 21:52:23 2021 From: chrisj at rtems.org (Chris Johns) Date: Tue, 21 Dec 2021 08:52:23 +1100 Subject: Alternative download paths for RSB? In-Reply-To: References: <0a59e7c7-37e2-24d0-70c3-31a326a8f75e@embedded-brains.de> Message-ID: On 21/12/21 2:33 am, Joel Sherrill wrote: > On Mon, Dec 20, 2021 at 8:54 AM Joel Sherrill wrote: >> >> On Mon, Dec 20, 2021 at 6:59 AM Sebastian Huber >> wrote: >>> >>> Hello, >>> >>> it seems the GNU web server is down: >> >> Yep. Still down. >> >> i reached out to the sourceware admins to see if they knew who to >> contact. I couldn't find a gnu.org address. > > Social media post from FSF forwarded by one of the sourceware admins > about a general outage at the FSF: > https://hostux.social/@fsfstatus/107479476196064925 > > Looks to be up now. RSB handling mirrors would be good. Although > it would seem to be complex to ensure that all entries and mirrors are > correct. > >> >>> >>> download: https://ftp.gnu.org/gnu/mpfr/mpfr-3.1.4.tar.bz2 -> >>> sources/mpfr-3.1.4.tar.bz2 >>> download: https://ftp.gnu.org/gnu/mpfr/mpfr-3.1.4.tar.bz2: error: >>> >>> error: downloading https://ftp.gnu.org/gnu/mpfr/mpfr-3.1.4.tar.bz2: all >>> paths have failed, giving up >>> Build FAILED >>> error: downloading https://ftp.gnu.org/gnu/mpfr/mpfr-3.1.4.tar.bz2: all >>> paths have failed, giving up >>> Build Set: Time 0:04:23.318509 >>> Build FAILED >>> >>> The error message suggests that it is possible to add alternative >>> download sources. How can I do this? This didn't work: >>> >>> diff --git a/source-builder/config/gcc-9.cfg >>> b/source-builder/config/gcc-9.cfg >>> index f8cf69b..1d7c716 100644 >>> --- a/source-builder/config/gcc-9.cfg >>> +++ b/source-builder/config/gcc-9.cfg >>> @@ -21,4 +21,8 @@ >>> %source set gmp https://ftp.gnu.org/gnu/gmp/gmp-%{gmp_version}.tar.bz2 >>> %source set mpfr https://ftp.gnu.org/gnu/mpfr/mpfr-%{mpfr_version}.tar.bz2 >>> >>> +%source set mpc >>> https://ftp.mpi-inf.mpg.de/pub/mirrors/gnu/mirror/gcc.gnu.org/pub/gcc/infrastructure/mpc-%{mpc_version}.tar.gz >>> +%source set gmp >>> https://ftp.mpi-inf.mpg.de/pub/mirrors/gnu/mirror/gcc.gnu.org/pub/gcc/infrastructure/gmp-%{gmp_version}.tar.bz2 >>> +%source set mpfr >>> https://ftp.mpi-inf.mpg.de/pub/mirrors/gnu/mirror/gcc.gnu.org/pub/gcc/infrastructure/mpfr-%{mpfr_version}.tar.bz2 >>> + >>> %include %{_configdir}/gcc-common-1.cfg >> >> This would be Chris' department. Sorry I would update the `%source` keyword to accept: %source mirror mpc 1 https://ftp.mpi-inf.mpg.de/../mpc-%{mpc_version}.tar.gz where `1` is an integer priority and 1 is highest. The code is here: https://git.rtems.org/rtems-source-builder/tree/source-builder/sb/sources.py#n55 There is no such thing as a list in the macros so I suspect you would need to dereference the source where the results of `_make_key` would reference another series of macro keys that are the mirrors. Do we want to start maintaining lists of mirrors in RSB configurations? I am undecided. As developers we do not notice the online status due to the RSB cache. For sites and users would deployment be a better long term solution? Chris From chrisj at rtems.org Mon Dec 20 23:03:12 2021 From: chrisj at rtems.org (Chris Johns) Date: Tue, 21 Dec 2021 10:03:12 +1100 Subject: [PATCH rtems-tools v1] ReportsBase: Change raw pointer to unique_ptr In-Reply-To: <1640031895-29199-1-git-send-email-ryan.long@oarcorp.com> References: <1640031895-29199-1-git-send-email-ryan.long@oarcorp.com> Message-ID: <78f3052f-8ec7-0638-d088-b5f14c479a62@rtems.org> On 21/12/21 7:24 am, Ryan Long wrote: > Replaced raw pointer used with ReportsBase-derived classes to make code > cleaner and make it to where pointers do not have to be manually > deleted. > > Closes #4376 > --- > tester/covoar/ReportsBase.cc | 21 ++++++--------------- > 1 file changed, 6 insertions(+), 15 deletions(-) > > diff --git a/tester/covoar/ReportsBase.cc b/tester/covoar/ReportsBase.cc > index 219e5af..8ec65c0 100644 > --- a/tester/covoar/ReportsBase.cc > +++ b/tester/covoar/ReportsBase.cc > @@ -591,17 +591,16 @@ void GenerateReports( > bool branchInfoAvailable > ) > { > - typedef std::list reportList_t; > + typedef std::vector> reportList_t; Are we OK to use `*_t` in types? Plus I have moved to ... using reportList = std::vector> so I would use the following to avoid '>>': using reportList_ptr = std::unique_ptr; using reportLists = std::vector; The vector is a container of report lists and not a container of report list singular. A minor point, I do not embed the container type into the type alias because someone may decide to change this to `std::deque` or `std::forward_list` and the name becomes misleading. > reportList_t reportList; Then make this `reports`. > reportList_t::iterator ritr; > std::string reportName; > - ReportsBase* reports; > time_t timestamp; > > > timestamp = time( NULL ); /* get current cal time */ > - reports = new ReportsText( > + reportList.emplace_back(new ReportsText( Should `std::make_unique(...)` be used? Thanks Chris > timestamp, > symbolSetName, > allExplanations, > @@ -609,9 +608,8 @@ void GenerateReports( > outputDirectory, > symbolsToAnalyze, > branchInfoAvailable > - ); > - reportList.push_back( reports ); > - reports = new ReportsHtml( > + )); > + reportList.emplace_back(new ReportsHtml( > timestamp, > symbolSetName, > allExplanations, > @@ -619,11 +617,9 @@ void GenerateReports( > outputDirectory, > symbolsToAnalyze, > branchInfoAvailable > - ); > - reportList.push_back( reports ); > + )); > > - for ( ritr = reportList.begin(); ritr != reportList.end(); ritr++ ) { > - reports = *ritr; > + for ( auto& reports: reportList ) { > > reportName = "index" + reports->ReportExtension(); > if ( verbose ) { > @@ -662,11 +658,6 @@ void GenerateReports( > reports->WriteSymbolSummaryReport( reportName, symbolsToAnalyze ); > } > > - for ( ritr = reportList.begin(); ritr != reportList.end(); ritr++ ) { > - reports = *ritr; > - delete reports; > - } > - > ReportsBase::WriteSummaryReport( > "summary.txt", > symbolSetName, From ral051 at oarcorp.com Mon Dec 20 23:08:07 2021 From: ral051 at oarcorp.com (Ryan Long) Date: Mon, 20 Dec 2021 17:08:07 -0600 Subject: [PATCH rtems-tools v1] ReportsBase: Change raw pointer to unique_ptr In-Reply-To: <78f3052f-8ec7-0638-d088-b5f14c479a62@rtems.org> References: <1640031895-29199-1-git-send-email-ryan.long@oarcorp.com> <78f3052f-8ec7-0638-d088-b5f14c479a62@rtems.org> Message-ID: <6061abb7-3f0e-2b3a-8ec5-8bfe5380473c@oarcorp.com> On 12/20/2021 5:03 PM, Chris Johns wrote: > > On 21/12/21 7:24 am, Ryan Long wrote: >> Replaced raw pointer used with ReportsBase-derived classes to make code >> cleaner and make it to where pointers do not have to be manually >> deleted. >> >> Closes #4376 >> --- >> tester/covoar/ReportsBase.cc | 21 ++++++--------------- >> 1 file changed, 6 insertions(+), 15 deletions(-) >> >> diff --git a/tester/covoar/ReportsBase.cc b/tester/covoar/ReportsBase.cc >> index 219e5af..8ec65c0 100644 >> --- a/tester/covoar/ReportsBase.cc >> +++ b/tester/covoar/ReportsBase.cc >> @@ -591,17 +591,16 @@ void GenerateReports( >> bool branchInfoAvailable >> ) >> { >> - typedef std::list reportList_t; >> + typedef std::vector> reportList_t; > Are we OK to use `*_t` in types? > > Plus I have moved to ... > > using reportList = std::vector> > > so I would use the following to avoid '>>': > > using reportList_ptr = std::unique_ptr; > using reportLists = std::vector; I'll put this in V2. > > The vector is a container of report lists and not a container of report list > singular. > > A minor point, I do not embed the container type into the type alias because > someone may decide to change this to `std::deque` or `std::forward_list` and the > name becomes misleading. > >> reportList_t reportList; > Then make this `reports`. > >> reportList_t::iterator ritr; >> std::string reportName; >> - ReportsBase* reports; >> time_t timestamp; >> >> >> timestamp = time( NULL ); /* get current cal time */ >> - reports = new ReportsText( >> + reportList.emplace_back(new ReportsText( > Should `std::make_unique(...)` be used? I was going to use this, but it was added in c++14. > > Thanks > Chris > >> timestamp, >> symbolSetName, >> allExplanations, >> @@ -609,9 +608,8 @@ void GenerateReports( >> outputDirectory, >> symbolsToAnalyze, >> branchInfoAvailable >> - ); >> - reportList.push_back( reports ); >> - reports = new ReportsHtml( >> + )); >> + reportList.emplace_back(new ReportsHtml( >> timestamp, >> symbolSetName, >> allExplanations, >> @@ -619,11 +617,9 @@ void GenerateReports( >> outputDirectory, >> symbolsToAnalyze, >> branchInfoAvailable >> - ); >> - reportList.push_back( reports ); >> + )); >> >> - for ( ritr = reportList.begin(); ritr != reportList.end(); ritr++ ) { >> - reports = *ritr; >> + for ( auto& reports: reportList ) { >> >> reportName = "index" + reports->ReportExtension(); >> if ( verbose ) { >> @@ -662,11 +658,6 @@ void GenerateReports( >> reports->WriteSymbolSummaryReport( reportName, symbolsToAnalyze ); >> } >> >> - for ( ritr = reportList.begin(); ritr != reportList.end(); ritr++ ) { >> - reports = *ritr; >> - delete reports; >> - } >> - >> ReportsBase::WriteSummaryReport( >> "summary.txt", >> symbolSetName, From chrisj at rtems.org Mon Dec 20 23:14:05 2021 From: chrisj at rtems.org (Chris Johns) Date: Tue, 21 Dec 2021 10:14:05 +1100 Subject: [PATCH rtems-tools v1] ReportsBase: Change raw pointer to unique_ptr In-Reply-To: <6061abb7-3f0e-2b3a-8ec5-8bfe5380473c@oarcorp.com> References: <1640031895-29199-1-git-send-email-ryan.long@oarcorp.com> <78f3052f-8ec7-0638-d088-b5f14c479a62@rtems.org> <6061abb7-3f0e-2b3a-8ec5-8bfe5380473c@oarcorp.com> Message-ID: On 21/12/21 10:08 am, Ryan Long wrote: > On 12/20/2021 5:03 PM, Chris Johns wrote: >> On 21/12/21 7:24 am, Ryan Long wrote: >> >>> ??? reportList_t?????????? reportList; >> Then make this `reports`. >> >>> ??? reportList_t::iterator ritr; >>> ??? std::string??????????? reportName; >>> -? ReportsBase*?????????? reports; >>> ??? time_t???????????????? timestamp; >>> ? ? ??? timestamp = time( NULL ); /* get current cal time */ >>> -? reports = new ReportsText( >>> +? reportList.emplace_back(new ReportsText( >> Should `std::make_unique(...)` be used? > I was going to use this, but it was added in c++14. Ak OK and thanks. I am using c++14 these days and had not noticed. I will leave this with you. Chris From sebastian.huber at embedded-brains.de Tue Dec 21 06:33:47 2021 From: sebastian.huber at embedded-brains.de (Sebastian Huber) Date: Tue, 21 Dec 2021 07:33:47 +0100 Subject: Alternative download paths for RSB? In-Reply-To: References: <0a59e7c7-37e2-24d0-70c3-31a326a8f75e@embedded-brains.de> Message-ID: <465506dd-e355-f5f9-c997-9bdc8707da8f@embedded-brains.de> On 20/12/2021 22:52, Chris Johns wrote: > On 21/12/21 2:33 am, Joel Sherrill wrote: >> On Mon, Dec 20, 2021 at 8:54 AM Joel Sherrill wrote: >>> >>> On Mon, Dec 20, 2021 at 6:59 AM Sebastian Huber >>> wrote: >>>> >>>> Hello, >>>> >>>> it seems the GNU web server is down: >>> >>> Yep. Still down. >>> >>> i reached out to the sourceware admins to see if they knew who to >>> contact. I couldn't find a gnu.org address. >> >> Social media post from FSF forwarded by one of the sourceware admins >> about a general outage at the FSF: >> https://hostux.social/@fsfstatus/107479476196064925 >> >> Looks to be up now. RSB handling mirrors would be good. Although >> it would seem to be complex to ensure that all entries and mirrors are >> correct. >> >>> >>>> >>>> download: https://ftp.gnu.org/gnu/mpfr/mpfr-3.1.4.tar.bz2 -> >>>> sources/mpfr-3.1.4.tar.bz2 >>>> download: https://ftp.gnu.org/gnu/mpfr/mpfr-3.1.4.tar.bz2: error: >>>> >>>> error: downloading https://ftp.gnu.org/gnu/mpfr/mpfr-3.1.4.tar.bz2: all >>>> paths have failed, giving up >>>> Build FAILED >>>> error: downloading https://ftp.gnu.org/gnu/mpfr/mpfr-3.1.4.tar.bz2: all >>>> paths have failed, giving up >>>> Build Set: Time 0:04:23.318509 >>>> Build FAILED >>>> >>>> The error message suggests that it is possible to add alternative >>>> download sources. How can I do this? This didn't work: >>>> >>>> diff --git a/source-builder/config/gcc-9.cfg >>>> b/source-builder/config/gcc-9.cfg >>>> index f8cf69b..1d7c716 100644 >>>> --- a/source-builder/config/gcc-9.cfg >>>> +++ b/source-builder/config/gcc-9.cfg >>>> @@ -21,4 +21,8 @@ >>>> %source set gmp https://ftp.gnu.org/gnu/gmp/gmp-%{gmp_version}.tar.bz2 >>>> %source set mpfr https://ftp.gnu.org/gnu/mpfr/mpfr-%{mpfr_version}.tar.bz2 >>>> >>>> +%source set mpc >>>> https://ftp.mpi-inf.mpg.de/pub/mirrors/gnu/mirror/gcc.gnu.org/pub/gcc/infrastructure/mpc-%{mpc_version}.tar.gz >>>> +%source set gmp >>>> https://ftp.mpi-inf.mpg.de/pub/mirrors/gnu/mirror/gcc.gnu.org/pub/gcc/infrastructure/gmp-%{gmp_version}.tar.bz2 >>>> +%source set mpfr >>>> https://ftp.mpi-inf.mpg.de/pub/mirrors/gnu/mirror/gcc.gnu.org/pub/gcc/infrastructure/mpfr-%{mpfr_version}.tar.bz2 >>>> + >>>> %include %{_configdir}/gcc-common-1.cfg >>> >>> This would be Chris' department. Sorry > > I would update the `%source` keyword to accept: > > %source mirror mpc 1 https://ftp.mpi-inf.mpg.de/../mpc-%{mpc_version}.tar.gz > > where `1` is an integer priority and 1 is highest. The code is here: > > https://git.rtems.org/rtems-source-builder/tree/source-builder/sb/sources.py#n55 > > There is no such thing as a list in the macros so I suspect you would need to > dereference the source where the results of `_make_key` would reference another > series of macro keys that are the mirrors. > > Do we want to start maintaining lists of mirrors in RSB configurations? I am > undecided. As developers we do not notice the online status due to the RSB > cache. For sites and users would deployment be a better long term solution? Thanks for the hints. I added a ticket for this: https://devel.rtems.org/ticket/4573 -- embedded brains GmbH Herr Sebastian HUBER Dornierstr. 4 82178 Puchheim Germany email: sebastian.huber at embedded-brains.de phone: +49-89-18 94 741 - 16 fax: +49-89-18 94 741 - 08 Registergericht: Amtsgericht M?nchen Registernummer: HRB 157899 Vertretungsberechtigte Gesch?ftsf?hrer: Peter Rasmussen, Thomas D?rfler Unsere Datenschutzerkl?rung finden Sie hier: https://embedded-brains.de/datenschutzerklaerung/ From joel at rtems.org Tue Dec 21 14:45:08 2021 From: joel at rtems.org (Joel Sherrill) Date: Tue, 21 Dec 2021 08:45:08 -0600 Subject: Alternative download paths for RSB? In-Reply-To: <465506dd-e355-f5f9-c997-9bdc8707da8f@embedded-brains.de> References: <0a59e7c7-37e2-24d0-70c3-31a326a8f75e@embedded-brains.de> <465506dd-e355-f5f9-c997-9bdc8707da8f@embedded-brains.de> Message-ID: On Tue, Dec 21, 2021 at 12:33 AM Sebastian Huber wrote: > > On 20/12/2021 22:52, Chris Johns wrote: > > On 21/12/21 2:33 am, Joel Sherrill wrote: > >> On Mon, Dec 20, 2021 at 8:54 AM Joel Sherrill wrote: > >>> > >>> On Mon, Dec 20, 2021 at 6:59 AM Sebastian Huber > >>> wrote: > >>>> > >>>> Hello, > >>>> > >>>> it seems the GNU web server is down: > >>> > >>> Yep. Still down. > >>> > >>> i reached out to the sourceware admins to see if they knew who to > >>> contact. I couldn't find a gnu.org address. > >> > >> Social media post from FSF forwarded by one of the sourceware admins > >> about a general outage at the FSF: > >> https://hostux.social/@fsfstatus/107479476196064925 > >> > >> Looks to be up now. RSB handling mirrors would be good. Although > >> it would seem to be complex to ensure that all entries and mirrors are > >> correct. > >> > >>> > >>>> > >>>> download: https://ftp.gnu.org/gnu/mpfr/mpfr-3.1.4.tar.bz2 -> > >>>> sources/mpfr-3.1.4.tar.bz2 > >>>> download: https://ftp.gnu.org/gnu/mpfr/mpfr-3.1.4.tar.bz2: error: > >>>> > >>>> error: downloading https://ftp.gnu.org/gnu/mpfr/mpfr-3.1.4.tar.bz2: all > >>>> paths have failed, giving up > >>>> Build FAILED > >>>> error: downloading https://ftp.gnu.org/gnu/mpfr/mpfr-3.1.4.tar.bz2: all > >>>> paths have failed, giving up > >>>> Build Set: Time 0:04:23.318509 > >>>> Build FAILED > >>>> > >>>> The error message suggests that it is possible to add alternative > >>>> download sources. How can I do this? This didn't work: > >>>> > >>>> diff --git a/source-builder/config/gcc-9.cfg > >>>> b/source-builder/config/gcc-9.cfg > >>>> index f8cf69b..1d7c716 100644 > >>>> --- a/source-builder/config/gcc-9.cfg > >>>> +++ b/source-builder/config/gcc-9.cfg > >>>> @@ -21,4 +21,8 @@ > >>>> %source set gmp https://ftp.gnu.org/gnu/gmp/gmp-%{gmp_version}.tar.bz2 > >>>> %source set mpfr https://ftp.gnu.org/gnu/mpfr/mpfr-%{mpfr_version}.tar.bz2 > >>>> > >>>> +%source set mpc > >>>> https://ftp.mpi-inf.mpg.de/pub/mirrors/gnu/mirror/gcc.gnu.org/pub/gcc/infrastructure/mpc-%{mpc_version}.tar.gz > >>>> +%source set gmp > >>>> https://ftp.mpi-inf.mpg.de/pub/mirrors/gnu/mirror/gcc.gnu.org/pub/gcc/infrastructure/gmp-%{gmp_version}.tar.bz2 > >>>> +%source set mpfr > >>>> https://ftp.mpi-inf.mpg.de/pub/mirrors/gnu/mirror/gcc.gnu.org/pub/gcc/infrastructure/mpfr-%{mpfr_version}.tar.bz2 > >>>> + > >>>> %include %{_configdir}/gcc-common-1.cfg > >>> > >>> This would be Chris' department. Sorry > > > > I would update the `%source` keyword to accept: > > > > %source mirror mpc 1 https://ftp.mpi-inf.mpg.de/../mpc-%{mpc_version}.tar.gz > > > > where `1` is an integer priority and 1 is highest. The code is here: > > > > https://git.rtems.org/rtems-source-builder/tree/source-builder/sb/sources.py#n55 > > > > There is no such thing as a list in the macros so I suspect you would need to > > dereference the source where the results of `_make_key` would reference another > > series of macro keys that are the mirrors. > > > > Do we want to start maintaining lists of mirrors in RSB configurations? I am > > undecided. As developers we do not notice the online status due to the RSB > > cache. For sites and users would deployment be a better long term solution? > > Thanks for the hints. I added a ticket for this: > > https://devel.rtems.org/ticket/4573 How can we ensure that all mirrors listed work? --joel > > -- > embedded brains GmbH > Herr Sebastian HUBER > Dornierstr. 4 > 82178 Puchheim > Germany > email: sebastian.huber at embedded-brains.de > phone: +49-89-18 94 741 - 16 > fax: +49-89-18 94 741 - 08 > > Registergericht: Amtsgericht M?nchen > Registernummer: HRB 157899 > Vertretungsberechtigte Gesch?ftsf?hrer: Peter Rasmussen, Thomas D?rfler > Unsere Datenschutzerkl?rung finden Sie hier: > https://embedded-brains.de/datenschutzerklaerung/ From sebastian.huber at embedded-brains.de Tue Dec 21 16:01:13 2021 From: sebastian.huber at embedded-brains.de (Sebastian Huber) Date: Tue, 21 Dec 2021 17:01:13 +0100 Subject: [PATCH 1/2] c-user: Clarify Clock Manager dependencies Message-ID: <20211221160114.19364-1-sebastian.huber@embedded-brains.de> Update #4572. --- c-user/clock/background.rst | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/c-user/clock/background.rst b/c-user/clock/background.rst index 759a976..cffab3c 100644 --- a/c-user/clock/background.rst +++ b/c-user/clock/background.rst @@ -9,20 +9,28 @@ Background Required Support ---------------- -For the features provided by the clock manager to be utilized, periodic timer -interrupts are required. Therefore, a real-time clock or hardware timer is -necessary to create the timer interrupts. The clock tick directive -is normally called by the timer ISR to announce to RTEMS that a system clock -tick has occurred. Elapsed time is measured in ticks. A tick is defined to be -an integral number of microseconds which is specified by the user in the -Configuration Table. +For the features provided by the Clock Manager to be utilized, a :term:`Clock +Driver` is required. The Clock Driver usually provides a clock interrupt which +is serviced on each configured processor at each :term:`clock tick`. In +addition, the Clock Driver provides three clock sources: + +* clock tick + +* :term:`CLOCK_REALTIME` + +* :term:`CLOCK_MONOTONIC` + +The time of these clock sources advances at each clock tick. This yields the +time of the clock sources in a coarse resolution. To get the time of the +``CLOCK_REALTIME`` or ``CLOCK_MONOTONIC`` clock sources in a higher resolution, +the Clock Driver may use a clock device to get the time between clock ticks. .. _Time and Date Data Structures: Time and Date Data Structures ----------------------------- -The clock facilities of the clock manager operate upon calendar time. These +The clock facilities of the Clock Manager operate upon calendar time. These directives utilize the following date and time structure for the native time and date format: -- 2.31.1 From sebastian.huber at embedded-brains.de Tue Dec 21 16:01:14 2021 From: sebastian.huber at embedded-brains.de (Sebastian Huber) Date: Tue, 21 Dec 2021 17:01:14 +0100 Subject: [PATCH 2/2] c-user: Use document internal links In-Reply-To: <20211221160114.19364-1-sebastian.huber@embedded-brains.de> References: <20211221160114.19364-1-sebastian.huber@embedded-brains.de> Message-ID: <20211221160114.19364-2-sebastian.huber@embedded-brains.de> --- c-user/clock/background.rst | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/c-user/clock/background.rst b/c-user/clock/background.rst index cffab3c..ded0461 100644 --- a/c-user/clock/background.rst +++ b/c-user/clock/background.rst @@ -87,8 +87,9 @@ scheduling algorithm. The length of time allocated to each task is known as the quantum or timeslice. The system's timeslice is defined as an integral number of ticks, and is -specified in the Configuration Table. The timeslice is defined for the entire -system of tasks, but timeslicing is enabled and disabled on a per task basis. +specified by the :ref:`CONFIGURE_TICKS_PER_TIMESLICE` application configuration +option. The timeslice is defined for the entire system of tasks, but +timeslicing is enabled and disabled on a per task basis. The clock tick directives implement timeslicing by decrementing the running task's time-remaining counter when both timeslicing and preemption are @@ -102,10 +103,10 @@ Delays A sleep timer allows a task to delay for a given interval or up until a given time, and then wake and continue execution. This type of timer is created -automatically by the ``rtems_task_wake_after`` and ``rtems_task_wake_when`` -directives and, as a result, does not have an RTEMS ID. Once activated, a -sleep timer cannot be explicitly deleted. Each task may activate one and only -one sleep timer at a time. +automatically by the :ref:`InterfaceRtemsTaskWakeAfter` and +:ref:`InterfaceRtemsTaskWakeWhen` directives and, as a result, does not have an +object identifier. Once activated, a sleep timer cannot be explicitly deleted. +Each task may activate one and only one sleep timer at a time. .. index:: timeouts @@ -113,7 +114,8 @@ Timeouts -------- Timeouts are a special type of timer automatically created when the timeout -option is used on the ``rtems_message_queue_receive``, ``rtems_event_receive``, -``rtems_semaphore_obtain`` and ``rtems_region_get_segment`` directives. Each -task may have one and only one timeout active at a time. When a timeout -expires, it unblocks the task with a timeout status code. +option is used on the :ref:`InterfaceRtemsBarrierWait`, +:ref:`InterfaceRtemsEventReceive`, :ref:`InterfaceRtemsMessageQueueReceive`, +:ref:`InterfaceRtemsRegionGetSegment`, and :ref:`InterfaceRtemsSemaphoreObtain` +directives. Each task may have one and only one timeout active at a time. +When a timeout expires, it unblocks the task with a timeout status code. -- 2.31.1 From chrisj at rtems.org Tue Dec 21 18:45:17 2021 From: chrisj at rtems.org (Chris Johns) Date: Wed, 22 Dec 2021 05:45:17 +1100 Subject: Alternative download paths for RSB? In-Reply-To: References: <0a59e7c7-37e2-24d0-70c3-31a326a8f75e@embedded-brains.de> <465506dd-e355-f5f9-c997-9bdc8707da8f@embedded-brains.de> Message-ID: <3b71e4f0-ab14-ed40-3cec-ba0540cf2204@rtems.org> On 22/12/21 1:45 am, Joel Sherrill wrote: > On Tue, Dec 21, 2021 at 12:33 AM Sebastian Huber > wrote: >> >> On 20/12/2021 22:52, Chris Johns wrote: >>> On 21/12/21 2:33 am, Joel Sherrill wrote: >>>> On Mon, Dec 20, 2021 at 8:54 AM Joel Sherrill wrote: >>>>> >>>>> On Mon, Dec 20, 2021 at 6:59 AM Sebastian Huber >>>>> wrote: >>>>>> >>>>>> Hello, >>>>>> >>>>>> it seems the GNU web server is down: >>>>> >>>>> Yep. Still down. >>>>> >>>>> i reached out to the sourceware admins to see if they knew who to >>>>> contact. I couldn't find a gnu.org address. >>>> >>>> Social media post from FSF forwarded by one of the sourceware admins >>>> about a general outage at the FSF: >>>> https://hostux.social/@fsfstatus/107479476196064925 >>>> >>>> Looks to be up now. RSB handling mirrors would be good. Although >>>> it would seem to be complex to ensure that all entries and mirrors are >>>> correct. >>>> >>>>> >>>>>> >>>>>> download: https://ftp.gnu.org/gnu/mpfr/mpfr-3.1.4.tar.bz2 -> >>>>>> sources/mpfr-3.1.4.tar.bz2 >>>>>> download: https://ftp.gnu.org/gnu/mpfr/mpfr-3.1.4.tar.bz2: error: >>>>>> >>>>>> error: downloading https://ftp.gnu.org/gnu/mpfr/mpfr-3.1.4.tar.bz2: all >>>>>> paths have failed, giving up >>>>>> Build FAILED >>>>>> error: downloading https://ftp.gnu.org/gnu/mpfr/mpfr-3.1.4.tar.bz2: all >>>>>> paths have failed, giving up >>>>>> Build Set: Time 0:04:23.318509 >>>>>> Build FAILED >>>>>> >>>>>> The error message suggests that it is possible to add alternative >>>>>> download sources. How can I do this? This didn't work: >>>>>> >>>>>> diff --git a/source-builder/config/gcc-9.cfg >>>>>> b/source-builder/config/gcc-9.cfg >>>>>> index f8cf69b..1d7c716 100644 >>>>>> --- a/source-builder/config/gcc-9.cfg >>>>>> +++ b/source-builder/config/gcc-9.cfg >>>>>> @@ -21,4 +21,8 @@ >>>>>> %source set gmp https://ftp.gnu.org/gnu/gmp/gmp-%{gmp_version}.tar.bz2 >>>>>> %source set mpfr https://ftp.gnu.org/gnu/mpfr/mpfr-%{mpfr_version}.tar.bz2 >>>>>> >>>>>> +%source set mpc >>>>>> https://ftp.mpi-inf.mpg.de/pub/mirrors/gnu/mirror/gcc.gnu.org/pub/gcc/infrastructure/mpc-%{mpc_version}.tar.gz >>>>>> +%source set gmp >>>>>> https://ftp.mpi-inf.mpg.de/pub/mirrors/gnu/mirror/gcc.gnu.org/pub/gcc/infrastructure/gmp-%{gmp_version}.tar.bz2 >>>>>> +%source set mpfr >>>>>> https://ftp.mpi-inf.mpg.de/pub/mirrors/gnu/mirror/gcc.gnu.org/pub/gcc/infrastructure/mpfr-%{mpfr_version}.tar.bz2 >>>>>> + >>>>>> %include %{_configdir}/gcc-common-1.cfg >>>>> >>>>> This would be Chris' department. Sorry >>> >>> I would update the `%source` keyword to accept: >>> >>> %source mirror mpc 1 https://ftp.mpi-inf.mpg.de/../mpc-%{mpc_version}.tar.gz >>> >>> where `1` is an integer priority and 1 is highest. The code is here: >>> >>> https://git.rtems.org/rtems-source-builder/tree/source-builder/sb/sources.py#n55 >>> >>> There is no such thing as a list in the macros so I suspect you would need to >>> dereference the source where the results of `_make_key` would reference another >>> series of macro keys that are the mirrors. >>> >>> Do we want to start maintaining lists of mirrors in RSB configurations? I am >>> undecided. As developers we do not notice the online status due to the RSB >>> cache. For sites and users would deployment be a better long term solution? >> >> Thanks for the hints. I added a ticket for this: >> >> https://devel.rtems.org/ticket/4573 > > How can we ensure that all mirrors listed work? They would need to be tested and that means more code in the RSB to do it. Chris From joel at rtems.org Tue Dec 21 19:37:22 2021 From: joel at rtems.org (Joel Sherrill) Date: Tue, 21 Dec 2021 13:37:22 -0600 Subject: Alternative download paths for RSB? In-Reply-To: <3b71e4f0-ab14-ed40-3cec-ba0540cf2204@rtems.org> References: <0a59e7c7-37e2-24d0-70c3-31a326a8f75e@embedded-brains.de> <465506dd-e355-f5f9-c997-9bdc8707da8f@embedded-brains.de> <3b71e4f0-ab14-ed40-3cec-ba0540cf2204@rtems.org> Message-ID: On Tue, Dec 21, 2021, 12:45 PM Chris Johns wrote: > On 22/12/21 1:45 am, Joel Sherrill wrote: > > On Tue, Dec 21, 2021 at 12:33 AM Sebastian Huber > > wrote: > >> > >> On 20/12/2021 22:52, Chris Johns wrote: > >>> On 21/12/21 2:33 am, Joel Sherrill wrote: > >>>> On Mon, Dec 20, 2021 at 8:54 AM Joel Sherrill wrote: > >>>>> > >>>>> On Mon, Dec 20, 2021 at 6:59 AM Sebastian Huber > >>>>> wrote: > >>>>>> > >>>>>> Hello, > >>>>>> > >>>>>> it seems the GNU web server is down: > >>>>> > >>>>> Yep. Still down. > >>>>> > >>>>> i reached out to the sourceware admins to see if they knew who to > >>>>> contact. I couldn't find a gnu.org address. > >>>> > >>>> Social media post from FSF forwarded by one of the sourceware admins > >>>> about a general outage at the FSF: > >>>> https://hostux.social/@fsfstatus/107479476196064925 > >>>> > >>>> Looks to be up now. RSB handling mirrors would be good. Although > >>>> it would seem to be complex to ensure that all entries and mirrors are > >>>> correct. > >>>> > >>>>> > >>>>>> > >>>>>> download: https://ftp.gnu.org/gnu/mpfr/mpfr-3.1.4.tar.bz2 -> > >>>>>> sources/mpfr-3.1.4.tar.bz2 > >>>>>> download: https://ftp.gnu.org/gnu/mpfr/mpfr-3.1.4.tar.bz2: error: > >>>>>> > >>>>>> error: downloading https://ftp.gnu.org/gnu/mpfr/mpfr-3.1.4.tar.bz2: > all > >>>>>> paths have failed, giving up > >>>>>> Build FAILED > >>>>>> error: downloading https://ftp.gnu.org/gnu/mpfr/mpfr-3.1.4.tar.bz2: > all > >>>>>> paths have failed, giving up > >>>>>> Build Set: Time 0:04:23.318509 > >>>>>> Build FAILED > >>>>>> > >>>>>> The error message suggests that it is possible to add alternative > >>>>>> download sources. How can I do this? This didn't work: > >>>>>> > >>>>>> diff --git a/source-builder/config/gcc-9.cfg > >>>>>> b/source-builder/config/gcc-9.cfg > >>>>>> index f8cf69b..1d7c716 100644 > >>>>>> --- a/source-builder/config/gcc-9.cfg > >>>>>> +++ b/source-builder/config/gcc-9.cfg > >>>>>> @@ -21,4 +21,8 @@ > >>>>>> %source set gmp > https://ftp.gnu.org/gnu/gmp/gmp-%{gmp_version}.tar.bz2 > >>>>>> %source set mpfr > https://ftp.gnu.org/gnu/mpfr/mpfr-%{mpfr_version}.tar.bz2 > >>>>>> > >>>>>> +%source set mpc > >>>>>> > https://ftp.mpi-inf.mpg.de/pub/mirrors/gnu/mirror/gcc.gnu.org/pub/gcc/infrastructure/mpc-%{mpc_version}.tar.gz > >>>>>> +%source set gmp > >>>>>> > https://ftp.mpi-inf.mpg.de/pub/mirrors/gnu/mirror/gcc.gnu.org/pub/gcc/infrastructure/gmp-%{gmp_version}.tar.bz2 > >>>>>> +%source set mpfr > >>>>>> > https://ftp.mpi-inf.mpg.de/pub/mirrors/gnu/mirror/gcc.gnu.org/pub/gcc/infrastructure/mpfr-%{mpfr_version}.tar.bz2 > >>>>>> + > >>>>>> %include %{_configdir}/gcc-common-1.cfg > >>>>> > >>>>> This would be Chris' department. Sorry > >>> > >>> I would update the `%source` keyword to accept: > >>> > >>> %source mirror mpc 1 > https://ftp.mpi-inf.mpg.de/../mpc-%{mpc_version}.tar.gz > >>> > >>> where `1` is an integer priority and 1 is highest. The code is here: > >>> > >>> > https://git.rtems.org/rtems-source-builder/tree/source-builder/sb/sources.py#n55 > >>> > >>> There is no such thing as a list in the macros so I suspect you would > need to > >>> dereference the source where the results of `_make_key` would > reference another > >>> series of macro keys that are the mirrors. > >>> > >>> Do we want to start maintaining lists of mirrors in RSB > configurations? I am > >>> undecided. As developers we do not notice the online status due to the > RSB > >>> cache. For sites and users would deployment be a better long term > solution? > >> > >> Thanks for the hints. I added a ticket for this: > >> > >> https://devel.rtems.org/ticket/4573 > > > > How can we ensure that all mirrors listed work? > > They would need to be tested and that means more code in the RSB to do it. > And another thing to check. Worries me. > > Chris > From ryan.long at oarcorp.com Tue Dec 21 20:49:38 2021 From: ryan.long at oarcorp.com (Ryan Long) Date: Tue, 21 Dec 2021 15:49:38 -0500 Subject: [PATCH v2] ReportsBase: Change raw pointer to unique_ptr Message-ID: <1640119778-11652-1-git-send-email-ryan.long@oarcorp.com> Replaced raw pointer used with ReportsBase-derived classes to make code cleaner and make it to where pointers do not have to be manually deleted. Closes #4376 --- tester/covoar/ReportsBase.cc | 77 +++++++++++++++++++++----------------------- 1 file changed, 36 insertions(+), 41 deletions(-) diff --git a/tester/covoar/ReportsBase.cc b/tester/covoar/ReportsBase.cc index 219e5af..0fb9ce0 100644 --- a/tester/covoar/ReportsBase.cc +++ b/tester/covoar/ReportsBase.cc @@ -591,80 +591,75 @@ void GenerateReports( bool branchInfoAvailable ) { - typedef std::list reportList_t; + using reportList_ptr = std::unique_ptr; + using reportList = std::vector; - reportList_t reportList; - reportList_t::iterator ritr; + reportList reports; std::string reportName; - ReportsBase* reports; time_t timestamp; timestamp = time( NULL ); /* get current cal time */ - reports = new ReportsText( - timestamp, - symbolSetName, - allExplanations, - projectName, - outputDirectory, - symbolsToAnalyze, - branchInfoAvailable + reports.emplace_back( + new ReportsText( + timestamp, + symbolSetName, + allExplanations, + projectName, + outputDirectory, + symbolsToAnalyze, + branchInfoAvailable + ) ); - reportList.push_back( reports ); - reports = new ReportsHtml( - timestamp, - symbolSetName, - allExplanations, - projectName, - outputDirectory, - symbolsToAnalyze, - branchInfoAvailable + reports.emplace_back( + new ReportsHtml( + timestamp, + symbolSetName, + allExplanations, + projectName, + outputDirectory, + symbolsToAnalyze, + branchInfoAvailable + ) ); - reportList.push_back( reports ); - for ( ritr = reportList.begin(); ritr != reportList.end(); ritr++ ) { - reports = *ritr; + for ( auto& report: reports ) { - reportName = "index" + reports->ReportExtension(); + reportName = "index" + report->ReportExtension(); if ( verbose ) { std::cerr << "Generate " << reportName << std::endl; } - reports->WriteIndex( reportName ); + report->WriteIndex( reportName ); - reportName = "annotated" + reports->ReportExtension(); + reportName = "annotated" + report->ReportExtension(); if ( verbose ) { std::cerr << "Generate " << reportName << std::endl; } - reports->WriteAnnotatedReport( reportName ); + report->WriteAnnotatedReport( reportName ); - reportName = "branch" + reports->ReportExtension(); + reportName = "branch" + report->ReportExtension(); if ( verbose ) { std::cerr << "Generate " << reportName << std::endl; } - reports->WriteBranchReport( reportName ); + report->WriteBranchReport( reportName ); - reportName = "uncovered" + reports->ReportExtension(); + reportName = "uncovered" + report->ReportExtension(); if ( verbose ) { std::cerr << "Generate " << reportName << std::endl; } - reports->WriteCoverageReport( reportName ); + report->WriteCoverageReport( reportName ); - reportName = "sizes" + reports->ReportExtension(); + reportName = "sizes" + report->ReportExtension(); if ( verbose ) { std::cerr << "Generate " << reportName << std::endl; } - reports->WriteSizeReport( reportName ); + report->WriteSizeReport( reportName ); - reportName = "symbolSummary" + reports->ReportExtension(); + reportName = "symbolSummary" + report->ReportExtension(); if ( verbose ) { std::cerr << "Generate " << reportName << std::endl; } - reports->WriteSymbolSummaryReport( reportName, symbolsToAnalyze ); - } - - for ( ritr = reportList.begin(); ritr != reportList.end(); ritr++ ) { - reports = *ritr; - delete reports; + report->WriteSymbolSummaryReport( reportName, symbolsToAnalyze ); } ReportsBase::WriteSummaryReport( -- 1.8.3.1 From chrisj at rtems.org Wed Dec 22 03:58:55 2021 From: chrisj at rtems.org (Chris Johns) Date: Wed, 22 Dec 2021 14:58:55 +1100 Subject: [PATCH v2] ReportsBase: Change raw pointer to unique_ptr In-Reply-To: <1640119778-11652-1-git-send-email-ryan.long@oarcorp.com> References: <1640119778-11652-1-git-send-email-ryan.long@oarcorp.com> Message-ID: OK Thanks Chris On 22/12/21 7:49 am, Ryan Long wrote: > Replaced raw pointer used with ReportsBase-derived classes to make code > cleaner and make it to where pointers do not have to be manually > deleted. > > Closes #4376 > --- > tester/covoar/ReportsBase.cc | 77 +++++++++++++++++++++----------------------- > 1 file changed, 36 insertions(+), 41 deletions(-) > > diff --git a/tester/covoar/ReportsBase.cc b/tester/covoar/ReportsBase.cc > index 219e5af..0fb9ce0 100644 > --- a/tester/covoar/ReportsBase.cc > +++ b/tester/covoar/ReportsBase.cc > @@ -591,80 +591,75 @@ void GenerateReports( > bool branchInfoAvailable > ) > { > - typedef std::list reportList_t; > + using reportList_ptr = std::unique_ptr; > + using reportList = std::vector; > > - reportList_t reportList; > - reportList_t::iterator ritr; > + reportList reports; > std::string reportName; > - ReportsBase* reports; > time_t timestamp; > > > timestamp = time( NULL ); /* get current cal time */ > - reports = new ReportsText( > - timestamp, > - symbolSetName, > - allExplanations, > - projectName, > - outputDirectory, > - symbolsToAnalyze, > - branchInfoAvailable > + reports.emplace_back( > + new ReportsText( > + timestamp, > + symbolSetName, > + allExplanations, > + projectName, > + outputDirectory, > + symbolsToAnalyze, > + branchInfoAvailable > + ) > ); > - reportList.push_back( reports ); > - reports = new ReportsHtml( > - timestamp, > - symbolSetName, > - allExplanations, > - projectName, > - outputDirectory, > - symbolsToAnalyze, > - branchInfoAvailable > + reports.emplace_back( > + new ReportsHtml( > + timestamp, > + symbolSetName, > + allExplanations, > + projectName, > + outputDirectory, > + symbolsToAnalyze, > + branchInfoAvailable > + ) > ); > - reportList.push_back( reports ); > > - for ( ritr = reportList.begin(); ritr != reportList.end(); ritr++ ) { > - reports = *ritr; > + for ( auto& report: reports ) { > > - reportName = "index" + reports->ReportExtension(); > + reportName = "index" + report->ReportExtension(); > if ( verbose ) { > std::cerr << "Generate " << reportName << std::endl; > } > - reports->WriteIndex( reportName ); > + report->WriteIndex( reportName ); > > - reportName = "annotated" + reports->ReportExtension(); > + reportName = "annotated" + report->ReportExtension(); > if ( verbose ) { > std::cerr << "Generate " << reportName << std::endl; > } > - reports->WriteAnnotatedReport( reportName ); > + report->WriteAnnotatedReport( reportName ); > > - reportName = "branch" + reports->ReportExtension(); > + reportName = "branch" + report->ReportExtension(); > if ( verbose ) { > std::cerr << "Generate " << reportName << std::endl; > } > - reports->WriteBranchReport( reportName ); > + report->WriteBranchReport( reportName ); > > - reportName = "uncovered" + reports->ReportExtension(); > + reportName = "uncovered" + report->ReportExtension(); > if ( verbose ) { > std::cerr << "Generate " << reportName << std::endl; > } > - reports->WriteCoverageReport( reportName ); > + report->WriteCoverageReport( reportName ); > > - reportName = "sizes" + reports->ReportExtension(); > + reportName = "sizes" + report->ReportExtension(); > if ( verbose ) { > std::cerr << "Generate " << reportName << std::endl; > } > - reports->WriteSizeReport( reportName ); > + report->WriteSizeReport( reportName ); > > - reportName = "symbolSummary" + reports->ReportExtension(); > + reportName = "symbolSummary" + report->ReportExtension(); > if ( verbose ) { > std::cerr << "Generate " << reportName << std::endl; > } > - reports->WriteSymbolSummaryReport( reportName, symbolsToAnalyze ); > - } > - > - for ( ritr = reportList.begin(); ritr != reportList.end(); ritr++ ) { > - reports = *ritr; > - delete reports; > + report->WriteSymbolSummaryReport( reportName, symbolsToAnalyze ); > } > > ReportsBase::WriteSummaryReport( From chrisj at rtems.org Wed Dec 22 04:05:23 2021 From: chrisj at rtems.org (Chris Johns) Date: Wed, 22 Dec 2021 15:05:23 +1100 Subject: Alternative download paths for RSB? In-Reply-To: References: <0a59e7c7-37e2-24d0-70c3-31a326a8f75e@embedded-brains.de> <465506dd-e355-f5f9-c997-9bdc8707da8f@embedded-brains.de> <3b71e4f0-ab14-ed40-3cec-ba0540cf2204@rtems.org> Message-ID: <5c167962-b02a-c06f-3780-f1778b3f597b@rtems.org> On 22/12/21 6:37 am, Joel Sherrill wrote: > On Tue, Dec 21, 2021, 12:45 PM Chris Johns > wrote: > > How can we ensure that all mirrors listed work? > > They would need to be tested and that means more code in the RSB to do it. > > And another thing to check. Worries me. Yes. What about fetching all the packages on each git commit to a spot on our ftp server the RSB checks? The hashes will make sure things are OK to use and it will avoid download when is present. Chris From Anders.Montonen at iki.fi Wed Dec 22 11:34:56 2021 From: Anders.Montonen at iki.fi (Anders Montonen) Date: Wed, 22 Dec 2021 13:34:56 +0200 Subject: [PATCH rtems-docs v2] Update package list for Ubuntu In-Reply-To: <1640013753-3995-1-git-send-email-ryan.long@oarcorp.com> References: <1640013753-3995-1-git-send-email-ryan.long@oarcorp.com> Message-ID: <1F91412E-692A-4DE1-B508-BFBFADC47F2F@iki.fi> Hi, > On 20 Dec 2021, at 17:22, Ryan Long wrote: > > Updated the latest version referenced of Ubuntu to 21.04, updated > package list, and identified what packages need to still be installed > afterwards to pass sb-check. This should be 20.04, to match the patch > -The latest version is Ubuntu 18.04.1 LTS 64-bit. This section also includes > +The latest version is Ubuntu 20.04.3 LTS 64-bit. This section also includes Regards, Anders Montonen From ryan.long at oarcorp.com Wed Dec 22 12:04:06 2021 From: ryan.long at oarcorp.com (Ryan Long) Date: Wed, 22 Dec 2021 12:04:06 +0000 Subject: [rtems-tools] tester: Update jobs configuration In-Reply-To: References: <1634760357-27539-1-git-send-email-ryan.long@oarcorp.com> Message-ID: ping -----Original Message----- From: Ryan Long Sent: Wednesday, December 8, 2021 9:29 AM To: devel at rtems.org Subject: Re: [rtems-tools] tester: Update jobs configuration ping On 11/1/2021 5:31 PM, Ryan Long wrote: > ping > > -----Original Message----- > From: Ryan Long > Sent: Wednesday, October 20, 2021 3:06 PM > To: devel at rtems.org > Cc: Ryan Long > Subject: [rtems-tools] tester: Update jobs configuration > > Allow for default_jobs and max_jobs to be specified in the BSP's configuration file. > --- > rtemstoolkit/options.py | 45 +++++++++++++--------- > tester/rtems/testing/bsps/beagleboardxm.ini | 2 +- > tester/rtems/testing/bsps/beagleboneblack.ini | 2 +- > tester/rtems/testing/bsps/imx7.ini | 2 +- > tester/rtems/testing/bsps/mcf5235.ini | 2 +- > tester/rtems/testing/bsps/mvme2307.ini | 2 +- > tester/rtems/testing/bsps/pc.ini | 2 +- > tester/rtems/testing/bsps/qoriq_e500.ini | 2 +- > tester/rtems/testing/bsps/qoriq_e6500_32.ini | 2 +- > tester/rtems/testing/bsps/qoriq_e6500_64.ini | 2 +- > tester/rtems/testing/bsps/raspberrypi2.ini | 2 +- > tester/rtems/testing/bsps/xilinx_versal_vck190.ini | 2 +- .../rtems/testing/bsps/xilinx_zynq_a9_qemu_smp.ini | 2 +- > tester/rtems/testing/bsps/xilinx_zynq_zc706.ini | 2 +- > tester/rtems/testing/bsps/xilinx_zynq_zedboard.ini | 2 +- > .../testing/bsps/xilinx_zynqmp_ilp32_zu3eg.ini | 2 +- > .../testing/bsps/xilinx_zynqmp_lp64_zu3eg.ini | 2 +- > tester/rtems/testing/defaults.mc | 2 + > 18 files changed, 45 insertions(+), 34 deletions(-) > > diff --git a/rtemstoolkit/options.py b/rtemstoolkit/options.py index > 5ebe3bc..4b7a93a 100644 > --- a/rtemstoolkit/options.py > +++ b/rtemstoolkit/options.py > @@ -102,7 +102,7 @@ class command_line(object): > '--no-clean': 'Do not clean up the build tree', > '--always-clean': 'Always clean the build tree, even with an error', > '--keep-going': 'Do not stop on an error.', > - '--jobs=[0..n,none,half,full]': 'Run with specified number of jobs, default: num CPUs.', > + '--jobs=[0..n,none,half,full]': 'Run with specified > + number of jobs (default: defined in configuration file)', > '--macros file[,file]': 'Macro format files to load after the defaults', > '--log file': 'Log file where all build output is written to', > } > @@ -327,6 +327,11 @@ class command_line(object): > # Handle the jobs for make > if '_ncpus' not in self.defaults: > raise error.general('host number of CPUs not set') > + if self.defaults['default_jobs'] != '0': > + print( > + 'default_jobs is %d and the default is %d' % > + (self.defaults['default_jobs'], 0) > + ) > ncpus = self.jobs(self.defaults['_ncpus']) > if ncpus > 1: > self.defaults['_smp_mflags'] = '-j %d' % (ncpus) @@ -427,28 +432,25 @@ class command_line(object): > um += [m] > return um if len(um) else None > > - def jobs(self, cpus): > + def jobs(self, num_cpus): > try: > - cpus = int(cpus) > + cpus = int(num_cpus) > except: > raise error.general('invalid host cpu value') > opt_jobs = self.opts['jobs'] > if opt_jobs == 'default': > - _jobs = self.defaults.get_value('jobs') > - if _jobs is not None: > - if _jobs == 'none': > - cpus = 0 > - elif _jobs == 'max': > - pass > - elif _jobs == 'half': > - cpus = cpus / 2 > - else: > - try: > - cpus = int(_jobs) > - except: > - raise error.general('invalid %%{jobs} value: %s' % (_jobs)) > + _jobs = self.defaults.get_value('default_jobs') > + if _jobs == 'none': > + cpus = 0 > + elif _jobs == 'max': > + pass > + elif _jobs == 'half': > + cpus = cpus / 2 > else: > - opt_jobs = 'max' > + try: > + cpus = int(_jobs) > + except: > + raise error.general('invalid %%{jobs} value: %s' > + % > + (_jobs)) > if opt_jobs != 'default': > if opt_jobs == 'none': > cpus = 0 > @@ -474,7 +476,14 @@ class command_line(object): > if not ok: > raise error.internal('bad jobs option: %s' % (opt_jobs)) > if cpus <= 0: > - cpu = 1 > + cpus = 1 > + max_jobs = int(self.defaults.get_value('max_jobs')) > + if max_jobs == 0: > + max_jobs = cpus > + if cpus > max_jobs: > + raise error.internal( > + 'exceeded maximum number of jobs: %d > %d' % (cpus, max_jobs) > + ) > return cpus > > def params(self): > diff --git a/tester/rtems/testing/bsps/beagleboardxm.ini > b/tester/rtems/testing/bsps/beagleboardxm.ini > index e8a79a6..72e6e8f 100644 > --- a/tester/rtems/testing/bsps/beagleboardxm.ini > +++ b/tester/rtems/testing/bsps/beagleboardxm.ini > @@ -36,7 +36,7 @@ > [beagleboardxm] > bsp = beagleboardxm > arch = arm > -jobs = 1 > +max_jobs = 1 > tester = %{_rtscripts}/gdb.cfg > gdb_script = bsp_gdb_script > requires = bsp_tty_dev, bsp_gdb_script > diff --git a/tester/rtems/testing/bsps/beagleboneblack.ini > b/tester/rtems/testing/bsps/beagleboneblack.ini > index 4bf850f..346d859 100644 > --- a/tester/rtems/testing/bsps/beagleboneblack.ini > +++ b/tester/rtems/testing/bsps/beagleboneblack.ini > @@ -35,7 +35,7 @@ > [beagleboneblack] > bsp = beagleboneblack > arch = arm > -jobs = 1 > +max_jobs = 1 > tester = %{_rtscripts}/tftp.cfg > test_restarts = 3 > target_reset_regex = ^No ethernet found.*|BOOTP broadcast > 6.*|^ERROR: can.t get kernel image diff --git > a/tester/rtems/testing/bsps/imx7.ini > b/tester/rtems/testing/bsps/imx7.ini > index 0a56ba8..28dd77f 100644 > --- a/tester/rtems/testing/bsps/imx7.ini > +++ b/tester/rtems/testing/bsps/imx7.ini > @@ -35,7 +35,7 @@ > [imx7] > bsp = imx7 > arch = arm > -jobs = 1 > +max_jobs = 1 > tester = %{_rtscripts}/tftp.cfg > test_restarts = 3 > target_start_regex = Hit any key to stop autoboot: > diff --git a/tester/rtems/testing/bsps/mcf5235.ini > b/tester/rtems/testing/bsps/mcf5235.ini > index 00f6a26..5023275 100644 > --- a/tester/rtems/testing/bsps/mcf5235.ini > +++ b/tester/rtems/testing/bsps/mcf5235.ini > @@ -34,6 +34,6 @@ > [mcf5235] > bsp = mcf5235 > arch = m68k > -jobs = 1 > +max_jobs = 1 > tester = %{_rtscripts}/gdb.cfg > requires = bsp_tty_dev, gdb_script > diff --git a/tester/rtems/testing/bsps/mvme2307.ini > b/tester/rtems/testing/bsps/mvme2307.ini > index b142aa9..bb7e15f 100644 > --- a/tester/rtems/testing/bsps/mvme2307.ini > +++ b/tester/rtems/testing/bsps/mvme2307.ini > @@ -52,7 +52,7 @@ > [mvme2307] > bsp = mvme2307 > arch = powerpc > -jobs = 1 > +max_jobs = 1 > test_restarts = 3 > tester = %{_rtscripts}/wait.cfg > target_start_regex = ^Copyright Motorola Inc.*, All Rights Reserved > diff --git a/tester/rtems/testing/bsps/pc.ini > b/tester/rtems/testing/bsps/pc.ini > index 93a5dae..5f81336 100644 > --- a/tester/rtems/testing/bsps/pc.ini > +++ b/tester/rtems/testing/bsps/pc.ini > @@ -31,7 +31,7 @@ > [pc] > bsp = pc686 > arch = i386 > -jobs = 1 > +max_jobs = 1 > tester = %{_rtscripts}/tftp.cfg > test_restarts = 3 > requires = bsp_tty_dev, target_on_command, target_off_command, target_reset_command > diff --git a/tester/rtems/testing/bsps/qoriq_e500.ini > b/tester/rtems/testing/bsps/qoriq_e500.ini > index 322069b..1756bcd 100644 > --- a/tester/rtems/testing/bsps/qoriq_e500.ini > +++ b/tester/rtems/testing/bsps/qoriq_e500.ini > @@ -35,7 +35,7 @@ > [qoriq_e500] > bsp = qoriq_e500 > arch = powerpc > -jobs = 1 > +max_jobs = 1 > tester = %{_rtscripts}/tftp.cfg > test_restarts = 3 > target_start_regex = U-Boot > diff --git a/tester/rtems/testing/bsps/qoriq_e6500_32.ini > b/tester/rtems/testing/bsps/qoriq_e6500_32.ini > index 26ee3ae..daf564e 100644 > --- a/tester/rtems/testing/bsps/qoriq_e6500_32.ini > +++ b/tester/rtems/testing/bsps/qoriq_e6500_32.ini > @@ -36,7 +36,7 @@ > [qoriq_e6500_32] > bsp = qoriq_e6500_32 > arch = powerpc > -jobs = 1 > +max_jobs = 1 > tester = %{_rtscripts}/tftp.cfg > test_restarts = 3 > target_start_regex = U-Boot > diff --git a/tester/rtems/testing/bsps/qoriq_e6500_64.ini > b/tester/rtems/testing/bsps/qoriq_e6500_64.ini > index c9b6ab7..e507032 100644 > --- a/tester/rtems/testing/bsps/qoriq_e6500_64.ini > +++ b/tester/rtems/testing/bsps/qoriq_e6500_64.ini > @@ -36,7 +36,7 @@ > [qoriq_e6500_64] > bsp = qoriq_e6500_64 > arch = powerpc > -jobs = 1 > +max_jobs = 1 > tester = %{_rtscripts}/tftp.cfg > test_restarts = 3 > target_start_regex = U-Boot > diff --git a/tester/rtems/testing/bsps/raspberrypi2.ini > b/tester/rtems/testing/bsps/raspberrypi2.ini > index e8043ac..f7f3c8c 100644 > --- a/tester/rtems/testing/bsps/raspberrypi2.ini > +++ b/tester/rtems/testing/bsps/raspberrypi2.ini > @@ -35,7 +35,7 @@ > [raspberrypi2] > bsp = raspberrypi2 > arch = arm > -jobs = 1 > +max_jobs = 1 > tester = %{_rtscripts}/tftp.cfg > test_restarts = 3 > target_reset_regex = BOOTP broadcast 6.*|^ERROR: can.t get kernel > image diff --git a/tester/rtems/testing/bsps/xilinx_versal_vck190.ini > b/tester/rtems/testing/bsps/xilinx_versal_vck190.ini > index 3bdd6be..a7695a7 100644 > --- a/tester/rtems/testing/bsps/xilinx_versal_vck190.ini > +++ b/tester/rtems/testing/bsps/xilinx_versal_vck190.ini > @@ -36,7 +36,7 @@ > bsp = xilinx_versal_vck190 > arch = aarch64 > tester = %{_rtscripts}/tftp.cfg > -jobs = 1 > +max_jobs = 1 > test_restarts = 3 > target_reset_regex = ^No ethernet found.*|^BOOTP broadcast > 6.*|^.+complete\.+ TIMEOUT.* target_start_regex = .* PSCI Power > Domain Map:$|^U-Boot .* diff --git > a/tester/rtems/testing/bsps/xilinx_zynq_a9_qemu_smp.ini > b/tester/rtems/testing/bsps/xilinx_zynq_a9_qemu_smp.ini > index 4366ffc..b6b39b6 100644 > --- a/tester/rtems/testing/bsps/xilinx_zynq_a9_qemu_smp.ini > +++ b/tester/rtems/testing/bsps/xilinx_zynq_a9_qemu_smp.ini > @@ -34,6 +34,6 @@ > [xilinx_zynq_a9_qemu_smp] > bsp = xilinx_zynq_a9_qemu > arch = arm > -jobs = half > +default_jobs = half > tester = %{_rtscripts}/qemu.cfg > bsp_qemu_opts = %{qemu_opts_base} %{qemu_opts_no_net} > %{qemu_opts_serial} -M xilinx-zynq-a9 -m 256M -smp cpus=2 diff --git > a/tester/rtems/testing/bsps/xilinx_zynq_zc706.ini > b/tester/rtems/testing/bsps/xilinx_zynq_zc706.ini > index e543022..844776d 100644 > --- a/tester/rtems/testing/bsps/xilinx_zynq_zc706.ini > +++ b/tester/rtems/testing/bsps/xilinx_zynq_zc706.ini > @@ -35,7 +35,7 @@ > [xilinx_zynq_zc706] > bsp = xilinx_zynq_zc706 > arch = arm > -jobs = 1 > +max_jobs = 1 > tester = %{_rtscripts}/gdb.cfg > gdb_script = bsp_gdb_script > requires = bsp_tty_dev, bsp_gdb_script > diff --git a/tester/rtems/testing/bsps/xilinx_zynq_zedboard.ini > b/tester/rtems/testing/bsps/xilinx_zynq_zedboard.ini > index 14b4d94..5c2451b 100644 > --- a/tester/rtems/testing/bsps/xilinx_zynq_zedboard.ini > +++ b/tester/rtems/testing/bsps/xilinx_zynq_zedboard.ini > @@ -36,7 +36,7 @@ > bsp = xilinx_zynq_zedboard > arch = arm > tester = %{_rtscripts}/tftp.cfg > -jobs = 1 > +max_jobs = 1 > test_restarts = 3 > target_reset_regex = ^No ethernet found.*|^BOOTP broadcast > 6.*|^.+complete\.+ TIMEOUT.* target_start_regex = ^U-Boot SPL .* diff > --git a/tester/rtems/testing/bsps/xilinx_zynqmp_ilp32_zu3eg.ini > b/tester/rtems/testing/bsps/xilinx_zynqmp_ilp32_zu3eg.ini > index 8c1c839..eefe173 100644 > --- a/tester/rtems/testing/bsps/xilinx_zynqmp_ilp32_zu3eg.ini > +++ b/tester/rtems/testing/bsps/xilinx_zynqmp_ilp32_zu3eg.ini > @@ -35,7 +35,7 @@ > bsp = xilinx_zynqmp_ilp32_zu3eg > arch = aarch64 > tester = %{_rtscripts}/tftp.cfg > -jobs = 1 > +max_jobs = 1 > test_restarts = 3 > target_reset_regex = ^No ethernet found.*|^.*: No link\..* > target_start_regex = ^.*Xilinx Zynq MP First Stage Boot Loader.* diff > --git a/tester/rtems/testing/bsps/xilinx_zynqmp_lp64_zu3eg.ini > b/tester/rtems/testing/bsps/xilinx_zynqmp_lp64_zu3eg.ini > index 663e5de..1fa35e5 100644 > --- a/tester/rtems/testing/bsps/xilinx_zynqmp_lp64_zu3eg.ini > +++ b/tester/rtems/testing/bsps/xilinx_zynqmp_lp64_zu3eg.ini > @@ -35,7 +35,7 @@ > bsp = xilinx_zynqmp_lp64_zu3eg > arch = aarch64 > tester = %{_rtscripts}/tftp.cfg > -jobs = 1 > +max_jobs = 1 > test_restarts = 3 > target_reset_regex = ^No ethernet found.*|^.*: No link\..* > target_start_regex = ^.*Xilinx Zynq MP First Stage Boot Loader.* diff > --git a/tester/rtems/testing/defaults.mc > b/tester/rtems/testing/defaults.mc > index d3e16a9..830b377 100644 > --- a/tester/rtems/testing/defaults.mc > +++ b/tester/rtems/testing/defaults.mc > @@ -116,6 +116,8 @@ __xz: exe, required, '/usr/bin/xz' > > # Default settings > _target: none, none, '%{nil}' > +max_jobs: none, none, '0' > +default_jobs: none, none, '0' > > # Paths > _rtbase: none, none, '%{_rtdir}' > -- > 1.8.3.1 > > _______________________________________________ > devel mailing list > devel at rtems.org > http://lists.rtems.org/mailman/listinfo/devel From joel at rtems.org Wed Dec 22 14:51:26 2021 From: joel at rtems.org (Joel Sherrill) Date: Wed, 22 Dec 2021 08:51:26 -0600 Subject: i386 and epiphany on FreeBSD 13 for rtems 5 Message-ID: Hi Both i386 and epiphany rtems 5 GCC fail to build on FreeBSD 13. It appears that the newer compiler on FreeBSD 13 does not like some code from the older GCC. Logs linked here: epiphany - https://lists.rtems.org/pipermail/build/2021-December/030627.html i386 - https://lists.rtems.org/pipermail/build/2021-December/030628.html I only see two fixes. (1) Add --disable-werror to these targets on rtems5 or (2) update the gcc on rtems5. We always are resistant to (2) so I guess that leaves us with option (1). Thoughts, comments, jokes, concurrence? --joel From sebastian.huber at embedded-brains.de Wed Dec 22 15:27:22 2021 From: sebastian.huber at embedded-brains.de (Sebastian Huber) Date: Wed, 22 Dec 2021 16:27:22 +0100 Subject: New validation test suites In-Reply-To: References: <5c4d51cb-660d-93ec-7a59-4a98be61d4c1@embedded-brains.de> <514bddac-9f20-5fa6-52a0-57c8f8787c82@rtems.org> <6f5145de-94f8-1984-5590-fb05741d282b@embedded-brains.de> <1f6a827e-818b-5e54-6e8c-98d28a22c25e@embedded-brains.de> <73f5c494-6879-e2f7-4394-0a25e070b24b@rtems.org> <7f29dfbe-b57d-6c70-df2a-6878d7db0efa@embedded-brains.de> Message-ID: On 17/12/2021 04:34, Chris Johns wrote: > On 16/12/21 6:36 pm, Sebastian Huber wrote: >> On 16/12/2021 04:51, Chris Johns wrote: >>> On 16/12/21 3:27 am, Sebastian Huber wrote: >>>> On 15/12/2021 06:46, Chris Johns wrote: >>>>> On 14/12/21 6:24 pm, Sebastian Huber wrote: >>>>>> Hello Chris, >>>>>> >>>>>> On 13/12/2021 22:01, Chris Johns wrote: >>>>>>> On 14/12/21 1:53 am, Sebastian Huber wrote: >>>> [...] >>>>>>>> We finished the specification of the pre-qualified RTEMS feature set. The >>>>>>>> specification is available in an RTEMS Project repository: >>>>>>>> >>>>>>>> https://git.rtems.org/rtems-central/tree/spec >>>>>>> >>>>>>> I had a quick look. Is there a more user friendly view of this data? >>>>>>> >>>>>>> I think the term "specification" is a little bit misleading because the data >>>>>>> files are not easily read by a person. I understand this is the specification >>>>>>> data set however it is not what I am traditionally use to seeing. >>>>>> >>>>>> You can use the "./specview.py" script to get views of the specification.? For >>>>>> example, this command displays the transition map for the rtems_signal_send() >>>>>> directive: >>>>> >>>>> Is specview.py part of rtems.git? >>>> >>>> No, this script is in rtems-central.? This is also the location of the >>>> specification items. >>> >>> I am not sure linking a script from that repo like this is helpful. >>> >>>>> If not part of rtems.git how much data is there for all the output? That is it >>>>> is generated and held in the repo with the tests? >>>> >>>> In rtems.git, there are only the generated sources. >>>> >>>> [...] >>> >>> There should be no reach back to the upstream specs, scripts etc and for good >>> reasons. The information you posted is nice and useful and I do not wish to >>> release manage rtems-central to accommodate these tests in a release. >>> >>> Would capturing that information with the tests be something worth doing? >> >> I don't think it would be useful. If you want to modify the tests you should >> work with the specification items and the corresponding scripts. > > This is not about modifying the tests. As I previously stated the tests provide > little detail on the verification matrix being solved. > > In relation to where is best to make changes, rtems-central may be the best > place however we will accept patches to the tests as they are in rtems.git. How > that is pushed back to rtems-central is not a focus here. In theory, you can change the tests by hand, however, this is very difficult. I had to compact the preconditions to postconditions table to reduce the data size of the tests. It looks now like this: static const ScoreSchedReqYield_Entry ScoreSchedReqYield_Entries[] = { #if !defined(RTEMS_SMP) { 1, 0, 0, 0, 0, 0, ScoreSchedReqYield_Post_HomeSchedulerState_NA, ScoreSchedReqYield_Post_AskForHelp_NA }, #else { 1, 0, 0, 0, 0, 0, ScoreSchedReqYield_Post_HomeSchedulerState_NA, ScoreSchedReqYield_Post_AskForHelp_NA }, #endif { 1, 0, 0, 0, 0, 0, ScoreSchedReqYield_Post_HomeSchedulerState_NA, ScoreSchedReqYield_Post_AskForHelp_NA }, [...] #if !defined(RTEMS_SMP) { 1, 0, 0, 0, 0, 0, ScoreSchedReqYield_Post_HomeSchedulerState_NA, ScoreSchedReqYield_Post_AskForHelp_NA } #else { 0, 0, 0, 0, 0, 0, ScoreSchedReqYield_Post_HomeSchedulerState_Idle, ScoreSchedReqYield_Post_AskForHelp_No } #endif }; static const uint8_t ScoreSchedReqYield_Map[] = { 0, 0, 2, 2, 3, 8, 10, 11, 0, 0, 2, 2, 4, 4, 1, 1, 5, 5, 1, 1, 5, 5, 1, 1, 0, 0, 6, 6, 12, 8, 13, 14, 0, 0, 6, 6, 4, 4, 9, 9, 3, 15, 7, 7, 3, 3, 7, 7 }; If you want to work with these tests, then you definitely should do this via rtems-central. > >> Adding the >> tables as comments would blow up the sources considerably. Some tests have about >> 50000 table entries and the table entries depend on C preprocessor defines. > > Ah yes I agree and what I was wanting to understand. > > I think we need to understand what a release will contain because the specs used > are not captured with a release. I appreciate the efforts to make this available > as a workflow for development and for the pre-qual process but I am now > critically examining what this means for a release. For example lets say years > after a release someone questions a test, they will only have the test source > code in the release package and I think this is a short coming. Adding the > rtems-central repo as a package to the releases source may be a solution however > this creates further issues. How do I know the master of the rtems-central and > the committed sources match when creating the release as separate pieces of > rtems.git may have been updated at different commit points in rtems-central? > > I suggest we get together when we can. Contact me off-line and lets see if we > can arrange a time :) We can add a release branch to rtems-central. The RTEMS sources are included as a Git submodule. > >> >> [...] >>>>>> In an earlier version of the header, we had a link which you didn't like: >>>>> >>>>> If I need to look at the formatting rules the heading "Software Development >>>>> Management" is easy to see and then a click on "Coding Standards" gives me what >>>>> I am looking for. >>>>> >>>>> To generate these headers I click on "Software Requirements Engineering" and >>>>> then do I just guess until I find it in the "How To" section? I am actually >>>>> asking this be sorted out so it is not left hanging and we are not left >>>>> guessing >>>>> what to do. If it can be rearrange into something meaningful it would help. :) >>>> >>>> Well, if you read the text in the header: >>>> >>>> ??* For information on updating and regenerating please refer to the How-To >>>> ??* section in the Software Requirements Engineering chapter of the >>>> ??* RTEMS Software Engineering manual.? The manual is provided as a part of >>>> ??* a release.? For development sources please refer to the online >>>> ??* documentation at: >>>> ??* >>>> ??* https://docs.rtems.org >>>> >>>> You should read the How-to section or not? >>> >>> Yes I should have and thanks for pointing this out but I did not see this and >>> the manual as it stands did not help. I think it should change. It can be >>> performed post this patch set but I think the documentation would read better if >>> changed. >> >> Could you please make a suggestions how the text should be changed? >> > > I am not sure. I have not looked at rtems-central, the scripts or commands it > provides. I think at a minimum a section each set of generated sources in > rtems.git needs to be covered. Ok, I will add a short description of the scripts to the How-to section. > >>>>>>> What hardware have the validation tests been run on? Any tier 1 archs? >>>>>> >>>>>> I tested with the sparc/leon3 BSPs and the arm/realview_pbx_a9_qemu. >>>>> >>>>> Is the leon3 tested on hardware or simulation? >>>>> >>>>>> You need a >>>>>> full implementation of the new Interrupt Manager directives and a working >>>>>> Cache >>>>>> Manager implementation. >>>>> >>>>> Is this documented? >>>>> >>>>> I am sorry I do not know the list of archs and bsps that support the new >>>>> interrupt manager directives. Maybe it would be good to list them? >>>> >>>> All BSPs have at least a stub implementation of the new directives. The >>>> directives are tested in a dedicated test suite. You will notice failures in >>>> this test suite if the directives are not implemented. >>> >>> Are these expected failures? >> >> Yes, they would be expected failures. I can add the test information. For which >> BSPs should I do this? > > Any we know the tests will not run on? I rearranged the test case to test suites distribution. Now, the tm27 support is no longer used if a clock driver is enabled. > >>>>>> I noticed an issue with the thread restart on aarch64/a53_lp64_qemu. This issue is now fixed. It was an error in the test. >>>>>> >>>>>> On powerpc/psim there is an issue in one test case, due to: >>>>>> >>>>>> #define CPU_ALL_TASKS_ARE_FP CPU_HARDWARE_FP >>>>> >>>>> Sorry, I am not following what the issue is? Does this effect all PPC BSPS? >>>> >>>> Not all, the newer BSPs have no separate floating-point context. >>> >>> Which ones have the issue, the newer BSPs or the older ones? >> >> The older ones. I fixed this issue in the tests. However, a new issue popped up. The setjmp() doesn't work in interrupt context for psim since the FPU is disabled. >> >>> >>>> This is something which needs to be fixed in the specification. >>> >>> Of? >>> >>> < From my point of view this is just a minor issue. >>> >>> As in fixing these tests? >>> >>>>>> Another issue is that the tm27 interrupt must be independent of the clock >>>>>> driver >>>>>> interrupt.? This is not the case for powerpc/psim. >>>>>> >>>>>> There is definitely some work left to cover all edge cases. Some tests are >>>>>> quite >>>>>> complicated. >>>>> >>>>> Sure. I would like to understand the effects this has? >>>> >>>> Maybe I can rearrange the test cases so that the tm27 support is only used if no >>>> clock driver is needed. The tm27 support is used to run handlers in interrupt >>>> context. >>> >>> OK. >> >> I will try to fix these issues, but this will delay the integration for a couple >> of weeks. > > I am fine with tickets that track the work to be done. > >>>>>>> Is there anything that interprets the new test output format? It looks like >>>>>>> lots >>>>>>> of great info but a little difficult to read. >>>>>> >>>>>> EDISOFT worked on a test report generator, however, it is not yet in a >>>>>> reviewable state. >>>>> >>>>> OK. I think something that handles this data would be good to have. >>>> >>>> Yes, maybe we could let a student work on this. In theory, this is not >>>> difficult. Read the report.yaml generated by the RTEMS Tester and convert it to >>>> a Python objects representation. Then use this high-level representation to >>>> generate a report in format X. >>> >>> Sounds good. >>> >>> And we need to get all the BSPs baselined with 0 failures so we know where we >>> stand as changes are being made. >> >> All BSPs is a bit too much. >> > > Yes sorry I meant all tier 1 BSPs. I can add tickets for the current tier 1 BSP for things which are missing. All tier 1 BSPs lack support for the new Interrupt Manager directives for example. -- embedded brains GmbH Herr Sebastian HUBER Dornierstr. 4 82178 Puchheim Germany email: sebastian.huber at embedded-brains.de phone: +49-89-18 94 741 - 16 fax: +49-89-18 94 741 - 08 Registergericht: Amtsgericht M?nchen Registernummer: HRB 157899 Vertretungsberechtigte Gesch?ftsf?hrer: Peter Rasmussen, Thomas D?rfler Unsere Datenschutzerkl?rung finden Sie hier: https://embedded-brains.de/datenschutzerklaerung/ From karel at functional.vision Wed Dec 22 15:38:34 2021 From: karel at functional.vision (Karel Gardas) Date: Wed, 22 Dec 2021 16:38:34 +0100 Subject: i386 and epiphany on FreeBSD 13 for rtems 5 In-Reply-To: References: Message-ID: On 12/22/21 3:51 PM, Joel Sherrill wrote: > Hi > > Both i386 and epiphany rtems 5 GCC fail to build on FreeBSD 13. It > appears that the newer compiler on FreeBSD 13 does not like some code > from the older GCC. > > Logs linked here: > > epiphany - https://lists.rtems.org/pipermail/build/2021-December/030627.html > > i386 - https://lists.rtems.org/pipermail/build/2021-December/030628.html > > I only see two fixes. (1) Add --disable-werror to these targets on > rtems5 or (2) update the gcc on rtems5. We always are resistant to (2) > so I guess that leaves us with option (1). > > Thoughts, comments, jokes, concurrence? joke? Here is one: what about to bootstrap native gcc 7.5.0 with --disable-werror and then use that to compile i386 cross-compiler? Remark: looks like you will not be able to keep tools from past working on modern systems indefinitely which means you can also declare rtems5 tools support for FreeBSD 12.x max. Or, what about to require installed gcc able to bootstrap cross-compiler without issues? My pretty current FreeBSD 14 provides following gccs: $ pkg search gcc|grep "GNU Compiler Collection"|grep -v "Cross" aarch64-none-elf-gcc-8.4.0_3 GNU Compiler Collection for bare metal aarch64 cross-development arm-none-eabi-gcc-8.4.0_3 GNU Compiler Collection for bare metal arm cross-development arm-none-eabi-gcc492-4.9.2_5 GNU Compiler Collection for bare metal arm cross-development gcc-10_4 Meta-port for the default version of the GNU Compiler Collection gcc10-10.3.0 GNU Compiler Collection 10 gcc10-devel-10.3.1.s20211008 GNU Compiler Collection 10 gcc11-11.2.0 GNU Compiler Collection 11 gcc11-devel-11.2.1.s20211009 GNU Compiler Collection 11 gcc12-devel-12.0.0.s20211128 GNU Compiler Collection 12 gcc48-4.8.5_14 GNU Compiler Collection 4.8 gcc8-8.5.0_1 GNU Compiler Collection 8 gcc9-9.4.0 GNU Compiler Collection 9 gcc9-devel-9.4.1.s20211007 GNU Compiler Collection 9 riscv32-unknown-elf-gcc-8.4.0_3 GNU Compiler Collection for bare metal riscv32 cross-development riscv64-none-elf-gcc-8.4.0_3 GNU Compiler Collection for bare metal riscv64 cross-development I guess this is more than enough to throw away system wide clang and use one of those? Karel From vijay at rtems.org Thu Dec 23 00:17:24 2021 From: vijay at rtems.org (Vijay Kumar Banerjee) Date: Wed, 22 Dec 2021 17:17:24 -0700 Subject: [PATCH v3 2/2] update README with instructions for stm32 patch In-Reply-To: References: <20211024105432.1207059-1-robin.mueller.m@gmail.com> Message-ID: Hi Robin, Looks like this patch answers one of my questions in the other patch. This looks good and can be merged after the first patch. Thanks! On Sun, Oct 24, 2021 at 4:59 AM Robin M?ller wrote: > > Hi, > > This patch now contains all files which have the problematic license so the > RTMES LwIP code stays free of them. > Actually, it probably would be a better idea if the patch is applied as > part of the build process.. Does anyone have experience how to do this with > waf? > > Kind Regards > Robin M?ller > > On Sun, 24 Oct 2021 at 12:54, Robin Mueller > wrote: > > > --- > > README.md | 10 ++++++++++ > > 1 file changed, 10 insertions(+) > > > > diff --git a/README.md b/README.md > > index ebbef12..3653b67 100644 > > --- a/README.md > > +++ b/README.md > > @@ -17,6 +17,16 @@ It is recommended that the user supplies the > > `lwipopts.h` configuration file. Th > > contain template option files to get started. The user can copy and > > rename this files into the > > application and then pass the include path to the build system using the > > `--lwip-opts` option. > > > > +# Applying the STM32 patch file > > + > > +Some STM32 files are problematic due to the used license. Therefore, they > > are applied in form of > > +a patch. You need to perform the following steps in order to use the > > STM32H7 BSP: > > + > > +```sh > > +wget -O stm32.patch > > https://raw.githubusercontent.com/robamu-org/rtems-stm32-lwip-port-patch/main/stm32-bsp-eth-dhcp-files.patch > > +git am stm32.patch > > +``` > > + > > # Building with waf > > > > It is assumed that the path(s) containing the `lwipopts.h` file was > > stored in the environmental > > -- > > 2.32.0 > > > > > _______________________________________________ > devel mailing list > devel at rtems.org > http://lists.rtems.org/mailman/listinfo/devel From joel at rtems.org Fri Dec 24 17:56:19 2021 From: joel at rtems.org (Joel Sherrill) Date: Fri, 24 Dec 2021 11:56:19 -0600 Subject: i386 and epiphany on FreeBSD 13 for rtems 5 In-Reply-To: References: Message-ID: On Wed, Dec 22, 2021 at 9:38 AM Karel Gardas wrote: > > On 12/22/21 3:51 PM, Joel Sherrill wrote: > > Hi > > > > Both i386 and epiphany rtems 5 GCC fail to build on FreeBSD 13. It > > appears that the newer compiler on FreeBSD 13 does not like some code > > from the older GCC. > > > > Logs linked here: > > > > epiphany - https://lists.rtems.org/pipermail/build/2021-December/030627.html > > > > i386 - https://lists.rtems.org/pipermail/build/2021-December/030628.html > > > > I only see two fixes. (1) Add --disable-werror to these targets on > > rtems5 or (2) update the gcc on rtems5. We always are resistant to (2) > > so I guess that leaves us with option (1). > > > > Thoughts, comments, jokes, concurrence? > > joke? Here is one: what about to bootstrap native gcc 7.5.0 with > --disable-werror and then use that to compile i386 cross-compiler? The RSB does actually have native gcc bsets. But they have not been updated to be more recent than 4.9. If there isn't a native OS package for an older gcc, updating these would be a good option. > Remark: looks like you will not be able to keep tools from past working > on modern systems indefinitely which means you can also declare rtems5 > tools support for FreeBSD 12.x max. Yep. > Or, what about to require installed gcc able to bootstrap cross-compiler > without issues? My pretty current FreeBSD 14 provides following gccs: Are these installed in a special directory where they can be ignored for rtems 6 or 7 tool builds? Sorry to ask but we want this FreeBSD 13 VM to be easily in the preferred state for 5, 6, and 7 test sweeps. For rtems 6 and 7, using clang would be preferred. > $ pkg search gcc|grep "GNU Compiler Collection"|grep -v "Cross" > aarch64-none-elf-gcc-8.4.0_3 GNU Compiler Collection for bare metal > aarch64 cross-development > arm-none-eabi-gcc-8.4.0_3 GNU Compiler Collection for bare metal > arm cross-development > arm-none-eabi-gcc492-4.9.2_5 GNU Compiler Collection for bare metal > arm cross-development > gcc-10_4 Meta-port for the default version of the > GNU Compiler Collection > gcc10-10.3.0 GNU Compiler Collection 10 > gcc10-devel-10.3.1.s20211008 GNU Compiler Collection 10 > gcc11-11.2.0 GNU Compiler Collection 11 > gcc11-devel-11.2.1.s20211009 GNU Compiler Collection 11 > gcc12-devel-12.0.0.s20211128 GNU Compiler Collection 12 > gcc48-4.8.5_14 GNU Compiler Collection 4.8 > gcc8-8.5.0_1 GNU Compiler Collection 8 One of these last two should be the best choices. gcc 8 or 48 if that doesn't work. > gcc9-9.4.0 GNU Compiler Collection 9 > gcc9-devel-9.4.1.s20211007 GNU Compiler Collection 9 > riscv32-unknown-elf-gcc-8.4.0_3 GNU Compiler Collection for bare metal > riscv32 cross-development > riscv64-none-elf-gcc-8.4.0_3 GNU Compiler Collection for bare metal > riscv64 cross-development > > > I guess this is more than enough to throw away system wide clang and use > one of those? Except for using the same VM with different options/paths to build rtems 5, 6, and 7 in the preferred way. Help on that is appreciated. --joel > Karel From karel at functional.vision Mon Dec 27 01:36:43 2021 From: karel at functional.vision (Karel Gardas) Date: Mon, 27 Dec 2021 02:36:43 +0100 Subject: i386 and epiphany on FreeBSD 13 for rtems 5 In-Reply-To: References: Message-ID: <3fe6ce9f-e9d7-0775-4dcf-461ab9f38d78@functional.vision> On 12/24/21 6:56 PM, Joel Sherrill wrote: >> Remark: looks like you will not be able to keep tools from past working >> on modern systems indefinitely which means you can also declare rtems5 >> tools support for FreeBSD 12.x max. > > Yep. > >> Or, what about to require installed gcc able to bootstrap cross-compiler >> without issues? My pretty current FreeBSD 14 provides following gccs: > > Are these installed in a special directory where they can be ignored > for rtems 6 or 7 tool builds? Sorry to ask but we want this FreeBSD 13 > VM to be easily in the preferred state for 5, 6, and 7 test sweeps. Yes, in fact any version X (where X == 48, 8, 10 etc) installed results in gccX binary (and other tools) in /usr/local/bin and in /usr/local/lib/gccX directory for runtime libraries so README recommends to: To ensure binaries built with this toolchain find appropriate versions of the necessary run-time libraries, you may want to link using -Wl,-rpath=/usr/local/lib/gccX >> I guess this is more than enough to throw away system wide clang and use >> one of those? > > Except for using the same VM with different options/paths to build rtems > 5, 6, and 7 in the preferred way. Help on that is appreciated. Well, I guess it's always an option to modify PATH and create a rsb own bin dir just for bootstrap where you can link all the required tools. It's a question if it make sense to modify rsp directly for rtems5 to support that automatically or just document requirements and few hints how and what to do exactly in this case on modern FreeBSD. Karel