Re: [PATCH] score: Simplify _Thread_Try_initialize()
ok On Tue, Sep 21, 2021 at 5:25 AM Sebastian Huber wrote: > > Move a code block to its own new function > _Thread_Initialize_scheduler_and_wait_nodes(). Add comments. > --- > cpukit/score/src/threadinitialize.c | 180 +--- > 1 file changed, 108 insertions(+), 72 deletions(-) > > diff --git a/cpukit/score/src/threadinitialize.c > b/cpukit/score/src/threadinitialize.c > index 9c1b809c3a..e10eb1af88 100644 > --- a/cpukit/score/src/threadinitialize.c > +++ b/cpukit/score/src/threadinitialize.c > @@ -96,6 +96,113 @@ void _Thread_Free( >_Objects_Free( &information->Objects, &the_thread->Object ); > } > > +static void _Thread_Initialize_scheduler_and_wait_nodes( > + Thread_Control *the_thread, > + const Thread_Configuration *config > +) > +{ > + Scheduler_Node *scheduler_node; > +#if defined(RTEMS_SMP) > + Scheduler_Node *scheduler_node_for_index; > + const Scheduler_Control *scheduler_for_index; > + size_t scheduler_index; > +#endif > + > +#if defined(RTEMS_SMP) > + scheduler_node = NULL; > + scheduler_node_for_index = the_thread->Scheduler.nodes; > + scheduler_for_index = &_Scheduler_Table[ 0 ]; > + scheduler_index = 0; > + > + /* > + * In SMP configurations, the thread has exactly one scheduler node for > each > + * configured scheduler. Initialize the scheduler nodes of each scheduler. > + * The application configuration ensures that we have at least one > scheduler > + * configured. > + */ > + while ( scheduler_index < _Scheduler_Count ) { > +Priority_Control priority_for_index; > + > +if ( scheduler_for_index == config->scheduler ) { > + priority_for_index = config->priority; > + scheduler_node = scheduler_node_for_index; > +} else { > + /* > + * Use the idle thread priority for the non-home scheduler instances by > + * default. > + */ > + priority_for_index = _Scheduler_Map_priority( > +scheduler_for_index, > +scheduler_for_index->maximum_priority > + ); > +} > + > +_Scheduler_Node_initialize( > + scheduler_for_index, > + scheduler_node_for_index, > + the_thread, > + priority_for_index > +); > + > +/* > + * Since the size of a scheduler node depends on the application > + * configuration, the _Scheduler_Node_size constant is used to get the > next > + * scheduler node. Using sizeof( Scheduler_Node ) would be wrong. > + */ > +scheduler_node_for_index = (Scheduler_Node *) > + ( (uintptr_t) scheduler_node_for_index + _Scheduler_Node_size ); > +++scheduler_for_index; > +++scheduler_index; > + } > + > + /* > + * The thread is initialized to use exactly one scheduler node which is > + * provided by its home scheduler. > + */ > + _Assert( scheduler_node != NULL ); > + _Chain_Initialize_one( > +&the_thread->Scheduler.Wait_nodes, > +&scheduler_node->Thread.Wait_node > + ); > + _Chain_Initialize_one( > +&the_thread->Scheduler.Scheduler_nodes, > +&scheduler_node->Thread.Scheduler_node.Chain > + ); > +#else > + /* > + * In uniprocessor configurations, the thread has exactly one scheduler > node. > + */ > + scheduler_node = _Thread_Scheduler_get_home_node( the_thread ); > + _Scheduler_Node_initialize( > +config->scheduler, > +scheduler_node, > +the_thread, > +config->priority > + ); > +#endif > + > + /* > + * The current priority of the thread is initialized to exactly the real > + * priority of the thread. During the lifetime of the thread, it may gain > + * more priority nodes, for example through locking protocols such as > + * priority inheritance or priority ceiling. > + */ > + _Priority_Node_initialize( &the_thread->Real_priority, config->priority ); > + _Priority_Initialize_one( > +&scheduler_node->Wait.Priority, > +&the_thread->Real_priority > + ); > + > +#if defined(RTEMS_SMP) > + RTEMS_STATIC_ASSERT( THREAD_SCHEDULER_BLOCKED == 0, Scheduler_state ); > + the_thread->Scheduler.home_scheduler = config->scheduler; > + _ISR_lock_Initialize( &the_thread->Scheduler.Lock, "Thread Scheduler" ); > + _ISR_lock_Initialize( &the_thread->Wait.Lock.Default, "Thread Wait > Default" ); > + _Thread_queue_Gate_open( &the_thread->Wait.Lock.Tranquilizer ); > + _RBTree_Initialize_node( &the_thread->Wait.Link.Registry_node ); > +#endif > +} > + > static bool _Thread_Try_initialize( >Thread_Information *information, >Thread_Control *the_thread, > @@ -107,12 +214,6 @@ static bool _Thread_Try_initialize( >char*stack_begin; >char*stack_end; >uintptr_tstack_align; > - Scheduler_Node *scheduler_node; > -#if defined(RTEMS_SMP) > - Scheduler_Node *scheduler_node_for_index; > - const Scheduler_Control *scheduler_for_index; > - size_t scheduler_index; > -#endif >Per_CPU_Contro
Re: [PATCH] score: Improve variable names in thread init
ok On Tue, Sep 21, 2021 at 5:36 AM Sebastian Huber wrote: > > --- > cpukit/score/src/threadinitialize.c | 50 ++--- > 1 file changed, 25 insertions(+), 25 deletions(-) > > diff --git a/cpukit/score/src/threadinitialize.c > b/cpukit/score/src/threadinitialize.c > index e10eb1af88..81199a7044 100644 > --- a/cpukit/score/src/threadinitialize.c > +++ b/cpukit/score/src/threadinitialize.c > @@ -101,17 +101,17 @@ static void _Thread_Initialize_scheduler_and_wait_nodes( >const Thread_Configuration *config > ) > { > - Scheduler_Node *scheduler_node; > + Scheduler_Node *home_scheduler_node; > #if defined(RTEMS_SMP) > - Scheduler_Node *scheduler_node_for_index; > - const Scheduler_Control *scheduler_for_index; > + Scheduler_Node *scheduler_node; > + const Scheduler_Control *scheduler; >size_t scheduler_index; > #endif > > #if defined(RTEMS_SMP) > - scheduler_node = NULL; > - scheduler_node_for_index = the_thread->Scheduler.nodes; > - scheduler_for_index = &_Scheduler_Table[ 0 ]; > + home_scheduler_node = NULL; > + scheduler_node = the_thread->Scheduler.nodes; > + scheduler = &_Scheduler_Table[ 0 ]; >scheduler_index = 0; > >/* > @@ -121,27 +121,27 @@ static void _Thread_Initialize_scheduler_and_wait_nodes( > * configured. > */ >while ( scheduler_index < _Scheduler_Count ) { > -Priority_Control priority_for_index; > +Priority_Control priority; > > -if ( scheduler_for_index == config->scheduler ) { > - priority_for_index = config->priority; > - scheduler_node = scheduler_node_for_index; > +if ( scheduler == config->scheduler ) { > + priority = config->priority; > + home_scheduler_node = scheduler_node; > } else { >/* > * Use the idle thread priority for the non-home scheduler instances by > * default. > */ > - priority_for_index = _Scheduler_Map_priority( > -scheduler_for_index, > -scheduler_for_index->maximum_priority > + priority = _Scheduler_Map_priority( > +scheduler, > +scheduler->maximum_priority >); > } > > _Scheduler_Node_initialize( > - scheduler_for_index, > - scheduler_node_for_index, > + scheduler, > + scheduler_node, >the_thread, > - priority_for_index > + priority > ); > > /* > @@ -149,9 +149,9 @@ static void _Thread_Initialize_scheduler_and_wait_nodes( > * configuration, the _Scheduler_Node_size constant is used to get the > next > * scheduler node. Using sizeof( Scheduler_Node ) would be wrong. > */ > -scheduler_node_for_index = (Scheduler_Node *) > - ( (uintptr_t) scheduler_node_for_index + _Scheduler_Node_size ); > -++scheduler_for_index; > +scheduler_node = (Scheduler_Node *) > + ( (uintptr_t) scheduler_node + _Scheduler_Node_size ); > +++scheduler; > ++scheduler_index; >} > > @@ -159,23 +159,23 @@ static void _Thread_Initialize_scheduler_and_wait_nodes( > * The thread is initialized to use exactly one scheduler node which is > * provided by its home scheduler. > */ > - _Assert( scheduler_node != NULL ); > + _Assert( home_scheduler_node != NULL ); >_Chain_Initialize_one( > &the_thread->Scheduler.Wait_nodes, > -&scheduler_node->Thread.Wait_node > +&home_scheduler_node->Thread.Wait_node >); >_Chain_Initialize_one( > &the_thread->Scheduler.Scheduler_nodes, > -&scheduler_node->Thread.Scheduler_node.Chain > +&home_scheduler_node->Thread.Scheduler_node.Chain >); > #else >/* > * In uniprocessor configurations, the thread has exactly one scheduler > node. > */ > - scheduler_node = _Thread_Scheduler_get_home_node( the_thread ); > + home_scheduler_node = _Thread_Scheduler_get_home_node( the_thread ); >_Scheduler_Node_initialize( > config->scheduler, > -scheduler_node, > +home_scheduler_node, > the_thread, > config->priority >); > @@ -189,7 +189,7 @@ static void _Thread_Initialize_scheduler_and_wait_nodes( > */ >_Priority_Node_initialize( &the_thread->Real_priority, config->priority ); >_Priority_Initialize_one( > -&scheduler_node->Wait.Priority, > +&home_scheduler_node->Wait.Priority, > &the_thread->Real_priority >); > > -- > 2.31.1 > > ___ > devel mailing list > devel@rtems.org > http://lists.rtems.org/mailman/listinfo/devel ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
Re: [PATCH rtems-tools 3/3] tester/mvme2307: Add support for the MVME2307 (MVME2700) BSP
ok On Tue, Sep 21, 2021 at 1:42 AM wrote: > > From: Chris Johns > > - Assumes a stand alone TFTP server > --- > tester/rtems/testing/bsps/mvme2307.ini | 59 ++ > 1 file changed, 59 insertions(+) > create mode 100644 tester/rtems/testing/bsps/mvme2307.ini > > diff --git a/tester/rtems/testing/bsps/mvme2307.ini > b/tester/rtems/testing/bsps/mvme2307.ini > new file mode 100644 > index 000..b142aa9 > --- /dev/null > +++ b/tester/rtems/testing/bsps/mvme2307.ini > @@ -0,0 +1,59 @@ > +# > +# RTEMS Tools Project (http://www.rtems.org/) > +# Copyright 2021 Chris Johns (chr...@rtems.org) > +# All rights reserved. > +# > +# This file is part of the RTEMS Tools package in 'rtems-tools'. > +# > +# 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 MVME2307 BSP > +# > +# This BSP uses the bootloader's network autoboot to boot the board. It > +# does nothing but sleep for the test's timeout period. > +# > +# You need to: > +# > +# 1. Set up a TFTP server and provide a suitable path to copy the > +# bootable image to. > +# > +# 2. Use the `env` command to enable network autoboot: > +# Network Auto Boot Enable [Y/N] = N? y > +# > +# 3. Provide a script to power cycle the board > +# > +# 4. Provide a telnet connection to the serial port > +# > +# 5. Create a script that converts the executable to the > +# bootable image and copy the image to the TFTP server. > +# > +[mvme2307] > +bsp= mvme2307 > +arch = powerpc > +jobs = 1 > +test_restarts = 3 > +tester = %{_rtscripts}/wait.cfg > +target_start_regex = ^Copyright Motorola Inc.*, All Rights Reserved > +requires = target_on_command, target_off_command, > target_reset_command, bsp_tty_dev > -- > 2.24.1 > > ___ > devel mailing list > devel@rtems.org > http://lists.rtems.org/mailman/listinfo/devel ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
Re: [PATCHv5] improve the format error reporting on i386
On Tue, Sep 21, 2021 at 4:06 PM zack leung wrote: > > all hex values now have 8 character width > thread id is now hex > --- > cpukit/score/cpu/i386/cpu.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/cpukit/score/cpu/i386/cpu.c b/cpukit/score/cpu/i386/cpu.c > index 77b7a7161c..786cf8b0b6 100644 > --- a/cpukit/score/cpu/i386/cpu.c > +++ b/cpukit/score/cpu/i386/cpu.c > @@ -215,16 +215,16 @@ void _CPU_Exception_frame_print (const > CPU_Exception_frame *ctx) > { >unsigned int faultAddr = 0; >printk("--\n"); > - printk("Exception %" PRIu32 " caught at PC %" PRIx32 " by thread %" > PRId32 "\n", > + printk("Exception %" PRIu32 " caught at PC %" PRIx32 " by thread %" > PRIx32 "\n", The thread ID does not have 8 character fixed width. > ctx->idtIndex, > ctx->eip, > _Thread_Executing->Object.id); >printk("--\n"); >printk("Processor execution context at time of the fault was :\n"); >printk("--\n"); > - printk(" EAX = %" PRIx32 "EBX = %" PRIx32 "ECX = %" PRIx32 " > EDX = %" PRIx32 "\n", > + printk(" EAX = 0x%08" PRIx32 "EBX = 0x%08" PRIx32 "ECX = > 0x%08" PRIx32 "EDX = 0x%08" PRIx32 "\n", > ctx->eax, ctx->ebx, ctx->ecx, ctx->edx); > - printk(" ESI = %" PRIx32 "EDI = %" PRIx32 "EBP = %" PRIx32 " > ESP = %" PRIx32 "\n", > + printk(" ESI = 0x%08" PRIx32 "EDI = 0x%08" PRIx32 "EBP = > 0x%08" PRIx32 "ESP = 0x%08" PRIx32 "\n", > ctx->esi, ctx->edi, ctx->ebp, ctx->esp0); >printk("--\n"); >printk("Error code pushed by processor itself (if not 0) = %" PRIx32 > "\n", > -- > 2.33.0 > ___ > devel mailing list > devel@rtems.org > http://lists.rtems.org/mailman/listinfo/devel ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
RE: [PATCH rtems-tools v1 4/7] TraceReaderLogQEMU.cc: Fix formatting
I changed the definition of discardBuff to char discardBuff[100]{}; So that every element will be initialized to \0. This function is only used in TraceReaderLogQEMU.cc, and the values that are passed in are #define QEMU_LOG_IN_KEY "IN: " #define QEMU_LOG_SECTION_END "" Neither are close to going over the size of discardBuff, but I can add a check and return false if it does happen to go over that length. -Original Message- From: Chris Johns Sent: Tuesday, September 21, 2021 6:16 PM To: Ryan Long ; devel@rtems.org Subject: Re: [PATCH rtems-tools v1 4/7] TraceReaderLogQEMU.cc: Fix formatting On 22/9/21 2:45 am, Ryan Long wrote: > --- > tester/covoar/TraceReaderLogQEMU.cc | 25 + > 1 file changed, 13 insertions(+), 12 deletions(-) > > diff --git a/tester/covoar/TraceReaderLogQEMU.cc > b/tester/covoar/TraceReaderLogQEMU.cc > index c303d08..91ed5c7 100644 > --- a/tester/covoar/TraceReaderLogQEMU.cc > +++ b/tester/covoar/TraceReaderLogQEMU.cc > @@ -53,8 +53,8 @@ > > bool ReadUntilFound( std::ifstream& file, const char* line ) { > - char discardBuff[100]; > - size_t len = strlen( line ); > + char discardBuff[100]; 100 bytes on the stack and not initialised ... > + size_t len = strlen( line );> >do { > file.read( discardBuff, 99 ); Read one less than the buffer so index 99 is still not initialised ... > @@ -62,9 +62,11 @@ bool ReadUntilFound( std::ifstream& file, const char* line > ) >return false; > } > > -if ( strncmp( discardBuff, line, len ) == 0 ) > +if ( strncmp( discardBuff, line, len ) == 0 ) { Making a call that assumes index 99 is '\0'! Does the discard buffer need to be memset to 0? What if the length of line is greater than 100? Is that a valid find and so a partial match is OK? Do the lengths need to match? Chris ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
[PATCHv5] improve the format error reporting on i386
ll hex values now have 8 character width thread id is now hex updates #4203 --- cpukit/score/cpu/i386/cpu.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cpukit/score/cpu/i386/cpu.c b/cpukit/score/cpu/i386/cpu.c index 77b7a7161c..786cf8b0b6 100644 --- a/cpukit/score/cpu/i386/cpu.c +++ b/cpukit/score/cpu/i386/cpu.c @@ -215,16 +215,16 @@ void _CPU_Exception_frame_print (const CPU_Exception_frame *ctx) { unsigned int faultAddr = 0; printk("--\n"); - printk("Exception %" PRIu32 " caught at PC %" PRIx32 " by thread %" PRId32 "\n", + printk("Exception %" PRIu32 " caught at PC %" PRIx32 " by thread 0x%08" PRIx32 "\n", ctx->idtIndex, ctx->eip, _Thread_Executing->Object.id); printk("--\n"); printk("Processor execution context at time of the fault was :\n"); printk("--\n"); - printk(" EAX = %" PRIx32 "EBX = %" PRIx32 "ECX = %" PRIx32 " EDX = %" PRIx32 "\n", + printk(" EAX = 0x%08" PRIx32 "EBX = 0x%08" PRIx32 "ECX = 0x%08" PRIx32 "EDX = 0x%08" PRIx32 "\n", ctx->eax, ctx->ebx, ctx->ecx, ctx->edx); - printk(" ESI = %" PRIx32 "EDI = %" PRIx32 "EBP = %" PRIx32 " ESP = %" PRIx32 "\n", + printk(" ESI = 0x%08" PRIx32 "EDI = 0x%08" PRIx32 "EBP = 0x%08" PRIx32 "ESP = 0x%08" PRIx32 "\n", ctx->esi, ctx->edi, ctx->ebp, ctx->esp0); printk("--\n"); printk("Error code pushed by processor itself (if not 0) = %" PRIx32 "\n", -- 2.33.0 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
Re: [PATCHv5] improve the format error reporting on i386
Joel, This looks good to me. I don't know if you can easily test it? Gedare On Wed, Sep 22, 2021 at 11:26 AM zack leung wrote: > > ll hex values now have 8 character width > thread id is now hex > updates #4203 > --- > cpukit/score/cpu/i386/cpu.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/cpukit/score/cpu/i386/cpu.c b/cpukit/score/cpu/i386/cpu.c > index 77b7a7161c..786cf8b0b6 100644 > --- a/cpukit/score/cpu/i386/cpu.c > +++ b/cpukit/score/cpu/i386/cpu.c > @@ -215,16 +215,16 @@ void _CPU_Exception_frame_print (const > CPU_Exception_frame *ctx) > { >unsigned int faultAddr = 0; >printk("--\n"); > - printk("Exception %" PRIu32 " caught at PC %" PRIx32 " by thread %" > PRId32 "\n", > + printk("Exception %" PRIu32 " caught at PC %" PRIx32 " by thread 0x%08" > PRIx32 "\n", > ctx->idtIndex, > ctx->eip, > _Thread_Executing->Object.id); >printk("--\n"); >printk("Processor execution context at time of the fault was :\n"); >printk("--\n"); > - printk(" EAX = %" PRIx32 "EBX = %" PRIx32 "ECX = %" PRIx32 " > EDX = %" PRIx32 "\n", > + printk(" EAX = 0x%08" PRIx32 "EBX = 0x%08" PRIx32 "ECX = > 0x%08" PRIx32 "EDX = 0x%08" PRIx32 "\n", > ctx->eax, ctx->ebx, ctx->ecx, ctx->edx); > - printk(" ESI = %" PRIx32 "EDI = %" PRIx32 "EBP = %" PRIx32 " > ESP = %" PRIx32 "\n", > + printk(" ESI = 0x%08" PRIx32 "EDI = 0x%08" PRIx32 "EBP = > 0x%08" PRIx32 "ESP = 0x%08" PRIx32 "\n", > ctx->esi, ctx->edi, ctx->ebp, ctx->esp0); >printk("--\n"); >printk("Error code pushed by processor itself (if not 0) = %" PRIx32 > "\n", > -- > 2.33.0 > ___ > devel mailing list > devel@rtems.org > http://lists.rtems.org/mailman/listinfo/devel ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
[PATCH v2 0/6] Exception Management and Recovery
This is a reworked patch set for management of recoverable exceptions. The assembly that would have followed the exception handler has been moved to a pair of epilogue functions to avoid the appearance of dead code following the fatal error handlers and the signal mapping code has been refactored into a fatal error handler. A test has been added to test resumption of execution after an unknown instruction exception occurs. ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
[PATCH v2 2/6] cpukit: Add Exception Manager
This adds the framework necessary to allow more generic handling of machine exceptions. This initial patch offers the ability to get the class of exception from the CPU_Exception_frame provided. Future extensions of the Exception Manager could include the ability to get the address of the exception if applicable or to resume execution at the next instruction or an arbitrary location. --- cpukit/include/rtems/exception.h | 166 ++ spec/build/cpukit/cpuopts.yml | 2 + spec/build/cpukit/librtemscpu.yml | 1 + spec/build/cpukit/optexceptionmanager.yml | 17 +++ 4 files changed, 186 insertions(+) create mode 100644 cpukit/include/rtems/exception.h create mode 100644 spec/build/cpukit/optexceptionmanager.yml diff --git a/cpukit/include/rtems/exception.h b/cpukit/include/rtems/exception.h new file mode 100644 index 00..89edfd02b4 --- /dev/null +++ b/cpukit/include/rtems/exception.h @@ -0,0 +1,166 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @brief This header file defines the Exception Manager API. + */ + +/* + * Copyright (C) 2021 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. + */ + +#ifndef _RTEMS_EXCEPTION_H +#define _RTEMS_EXCEPTION_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup RTEMSAPIClassicException Exception Manager + * + * @ingroup RTEMSAPIClassic + * + * @brief The Exception Manager processes all machine exceptions and passes + * any unhandled exceptions to the Fatal Error Manager. + */ + +/** + * The following lists the generic exception classes supported by the Exception + * Management API. + */ +typedef enum { + EXCEPTION_UNKNOWN, + EXCEPTION_FPU, + EXCEPTION_TAGGED_OVERFLOW, + EXCEPTION_DIV_ZERO, + EXCEPTION_DATA_ABORT_READ, + EXCEPTION_DATA_ABORT_WRITE, + EXCEPTION_DATA_ABORT_UNSPECIFIED, + EXCEPTION_INSTRUCTION_ABORT, + EXCEPTION_MMU_UNSPECIFIED, + EXCEPTION_ACCESS_ALIGNMENT, + EXCEPTION_SUPERVISOR, + EXCEPTION_TRAPPED_INSTRUCTION, + EXCEPTION_PC_ALIGNMENT, + EXCEPTION_SP_ALIGNMENT, + EXCEPTION_BREAKPOINT, + EXCEPTION_BREAK_INSTRUCTION, + EXCEPTION_STEP, + EXCEPTION_WATCHPOINT, + EXCEPTION_MAX +} Exception_Class; + +/** + * @brief Resumes normal execution using the provided exception frame. + * + * This routine helps to avoid dead code in the exception handler epilogue and + * does not return. This routine may assume that the provided pointer is valid + * for resetting the exception stack. + * + * @param exception_frame The CPU_Exception_frame describing the machine + * exception. + */ +RTEMS_NO_RETURN void Exception_Manager_resume( CPU_Exception_frame *ef ); + +/** + * @brief Performs thread dispatch and resumes normal execution. + * + * This routine helps to avoid dead code in the exception handler epilogue and + * does not return. This routine may assume that the provided pointer is valid + * for resetting the exception stack. This function is expected to decrement + * the ISR nest level and thread dispatch disable level in the Per_CPU_Control + * structure. + * + * @param exception_frame The CPU_Exception_frame describing the machine + * exception. + */ +RTEMS_NO_RETURN void Exception_Manager_dispatch_and_resume( CPU_Exception_frame *ef ); + +/** + * @brief Disables thread dispatch. + * + * This must be called before calling Exception_Manager_dispatch_and_resume + * since that function is expected to reduce the levels incremented below. + * + * @param exception_frame The CPU_Exception_frame describing the machine + * exception. + */ +static inline void Exception_Manager_disable_thread_dispatch( void ) +{ + Per_CPU_Control *cpu_sel
[PATCH v2 4/6] testsuite: Add machine exception resume test
Add a test to verify that intercepted exceptions can be resolved and execution can be resumed. --- spec/build/testsuites/sptests/grp.yml | 2 + spec/build/testsuites/sptests/spfatal35.yml | 20 + testsuites/sptests/spfatal35/init.c | 93 + testsuites/sptests/spfatal35/spfatal35.doc | 7 ++ testsuites/sptests/spfatal35/spfatal35.scn | 2 + 5 files changed, 124 insertions(+) create mode 100644 spec/build/testsuites/sptests/spfatal35.yml create mode 100644 testsuites/sptests/spfatal35/init.c create mode 100644 testsuites/sptests/spfatal35/spfatal35.doc create mode 100644 testsuites/sptests/spfatal35/spfatal35.scn diff --git a/spec/build/testsuites/sptests/grp.yml b/spec/build/testsuites/sptests/grp.yml index d3cd53fb4a..550336c56d 100644 --- a/spec/build/testsuites/sptests/grp.yml +++ b/spec/build/testsuites/sptests/grp.yml @@ -257,6 +257,8 @@ links: uid: spfatal33 - role: build-dependency uid: spfatal34 +- role: build-dependency + uid: spfatal35 - role: build-dependency uid: spfifo01 - role: build-dependency diff --git a/spec/build/testsuites/sptests/spfatal35.yml b/spec/build/testsuites/sptests/spfatal35.yml new file mode 100644 index 00..668e26a22a --- /dev/null +++ b/spec/build/testsuites/sptests/spfatal35.yml @@ -0,0 +1,20 @@ +SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause +build-type: test-program +cflags: [] +copyrights: +- Copyright (C) 2021 On-Line Applications Research (OAR) +cppflags: [] +cxxflags: [] +enabled-by: +- RTEMS_EXCEPTION_MANAGER +features: c cprogram +includes: [] +ldflags: [] +links: [] +source: +- testsuites/sptests/spfatal35/init.c +stlib: [] +target: testsuites/sptests/spfatal35.exe +type: build +use-after: [] +use-before: [] diff --git a/testsuites/sptests/spfatal35/init.c b/testsuites/sptests/spfatal35/init.c new file mode 100644 index 00..e2246588ec --- /dev/null +++ b/testsuites/sptests/spfatal35/init.c @@ -0,0 +1,93 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup sptests + */ + +/* + * Copyright (C) 2021 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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include + +#include + +const char rtems_test_name[] = "SPFATAL 35"; + +static void Init( rtems_task_argument arg ) +{ + TEST_BEGIN(); + _CPU_Instruction_illegal(); + TEST_END(); + rtems_test_exit(0); +} + +static void fatal_extension( + rtems_fatal_source source, + bool always_set_to_false, + rtems_fatal_code code +) +{ + CPU_Exception_frame *ef; + Exception_Class eClass; + + if ( source != RTEMS_FATAL_SOURCE_EXCEPTION ) { +return; + } + + rtems_test_assert( !always_set_to_false ); + + ef = (rtems_exception_frame *) code; + eClass = Exception_Manager_Get_class( ef ); + + rtems_test_assert( eClass == EXCEPTION_UNKNOWN ); + + Exception_Manager_Set_resume_next_instruction( ef ); + + Exception_Manager_resume( ef ); +} + +#define CONFIGURE_INITIAL_EXTENSIONS \ + { .fatal = fatal_extension }, \ + RTEMS_TEST_INITIAL_EXTENSION + +#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER + +#define CONFIGURE_APPLICATION_DISABLE_FILESYSTEM + +#define CONFIGURE_MAXIMUM_TASKS 1 + +#define CONFIGURE_RTEMS_INIT_TASKS_TABLE + +#define CONFIGURE_INIT + +#include diff --git a/testsuites/sptests/spfatal35/spfatal35.doc b/testsuites/sptests/spfatal35/spfatal35.doc new file mode 100644 index 00..e041f21391 --- /dev/null +++ b/testsuites/sptests/spfatal35/spfatal35.doc @@ -0,0 +1,7 @@ +This file describes the concepts tested by this test set. + +test set name: spfatal35 + +concepts: + + - Ensure that a RTEMS_FATAL_S
[PATCH v2 3/6] cpukit/aarch64: Add Exception Manager support
This adds the call and support functions necessary to add Exception Manager support to AArch64. --- .../cpu/aarch64/aarch64-exception-default.S | 81 + .../cpu/aarch64/aarch64-exception-default.c | 62 +++ .../cpu/aarch64/aarch64-exception-interrupt.S | 165 ++ spec/build/cpukit/optexceptionmanager.yml | 4 + 4 files changed, 238 insertions(+), 74 deletions(-) diff --git a/cpukit/score/cpu/aarch64/aarch64-exception-default.S b/cpukit/score/cpu/aarch64/aarch64-exception-default.S index 2a4ddbcc61..ef95619fb1 100644 --- a/cpukit/score/cpu/aarch64/aarch64-exception-default.S +++ b/cpukit/score/cpu/aarch64/aarch64-exception-default.S @@ -203,14 +203,13 @@ curr_el_spx_sync_get_pc: /* The current PC is now in LR */ /* Store the vector */ str lr, [sp, #AARCH64_EXCEPTION_FRAME_REGISTER_VECTOR_OFFSET] mov x0, sp - blr x1 -/* bl to CEF restore routine (doesn't restore lr) */ - bl .pop_exception_context - ldr lr, [sp, #AARCH64_EXCEPTION_FRAME_REGISTER_LR_OFFSET] /* get lr from CEF */ -/* drop space reserved for CEF and clear exclusive */ - add sp, sp, #AARCH64_EXCEPTION_FRAME_SIZE - msr spsel, #1 /* switch to thread stack */ - eret/* exception return */ +/* Not expected to return */ + br x1 + nop + nop + nop + nop + nop nop nop nop @@ -475,69 +474,3 @@ twiddle: stp q30, q31, [sp, #(AARCH64_EXCEPTION_FRAME_REGISTER_Q0_OFFSET + 0x1e0)] /* Done, return to exception handler */ ret - -/* - * Apply the exception frame to the current register status, SP points to the EF - */ -.pop_exception_context: -/* Pop daif and spsr */ - ldp x2, x3, [sp, #AARCH64_EXCEPTION_FRAME_REGISTER_DAIF_OFFSET] -/* Restore daif and spsr */ - msr DAIF, x2 - msr SPSR_EL1, x3 -/* Pop FAR and ESR */ - ldp x2, x3, [sp, #AARCH64_EXCEPTION_FRAME_REGISTER_SYNDROME_OFFSET] -/* Restore ESR and FAR */ - msr ESR_EL1, x2 - msr FAR_EL1, x3 -/* Pop fpcr and fpsr */ - ldp x2, x3, [sp, #AARCH64_EXCEPTION_FRAME_REGISTER_FPSR_OFFSET] -/* Restore fpcr and fpsr */ - msr FPSR, x2 - msr FPCR, x3 -/* Pop VFP registers */ - ldp q0, q1, [sp, #(AARCH64_EXCEPTION_FRAME_REGISTER_Q0_OFFSET + 0x000)] - ldp q2, q3, [sp, #(AARCH64_EXCEPTION_FRAME_REGISTER_Q0_OFFSET + 0x020)] - ldp q4, q5, [sp, #(AARCH64_EXCEPTION_FRAME_REGISTER_Q0_OFFSET + 0x040)] - ldp q6, q7, [sp, #(AARCH64_EXCEPTION_FRAME_REGISTER_Q0_OFFSET + 0x060)] - ldp q8, q9, [sp, #(AARCH64_EXCEPTION_FRAME_REGISTER_Q0_OFFSET + 0x080)] - ldp q10, q11, [sp, #(AARCH64_EXCEPTION_FRAME_REGISTER_Q0_OFFSET + 0x0a0)] - ldp q12, q13, [sp, #(AARCH64_EXCEPTION_FRAME_REGISTER_Q0_OFFSET + 0x0c0)] - ldp q14, q15, [sp, #(AARCH64_EXCEPTION_FRAME_REGISTER_Q0_OFFSET + 0x0e0)] - ldp q16, q17, [sp, #(AARCH64_EXCEPTION_FRAME_REGISTER_Q0_OFFSET + 0x100)] - ldp q18, q19, [sp, #(AARCH64_EXCEPTION_FRAME_REGISTER_Q0_OFFSET + 0x120)] - ldp q20, q21, [sp, #(AARCH64_EXCEPTION_FRAME_REGISTER_Q0_OFFSET + 0x140)] - ldp q22, q23, [sp, #(AARCH64_EXCEPTION_FRAME_REGISTER_Q0_OFFSET + 0x160)] - ldp q24, q25, [sp, #(AARCH64_EXCEPTION_FRAME_REGISTER_Q0_OFFSET + 0x180)] - ldp q26, q27, [sp, #(AARCH64_EXCEPTION_FRAME_REGISTER_Q0_OFFSET + 0x1a0)] - ldp q28, q29, [sp, #(AARCH64_EXCEPTION_FRAME_REGISTER_Q0_OFFSET + 0x1c0)] - ldp q30, q31, [sp, #(AARCH64_EXCEPTION_FRAME_REGISTER_Q0_OFFSET + 0x1e0)] -/* Pop x0-x29(fp) */ - ldp x2, x3, [sp, #0x10] - ldp x4, x5, [sp, #0x20] - ldp x6, x7, [sp, #0x30] - ldp x8, x9, [sp, #0x40] - ldp x10, x11, [sp, #0x50] - ldp x12, x13, [sp, #0x60] - ldp x14, x15, [sp, #0x70] - ldp x16, x17, [sp, #0x80] - ldp x18, x19, [sp, #0x90] - ldp x20, x21, [sp, #0xa0] - ldp x22, x23, [sp, #0xb0] - ldp x24, x25, [sp, #0xc0] - ldp x26, x27, [sp, #0xd0] - ldp x28, x29, [sp, #0xe0] -/* Pop sp and ELR */ - ldp x0, x1, [sp, #AARCH64_EXCEPTION_FRAME_REGISTER_SP_OFFSET] -/* Restore thread SP */ - msr spsel, #1 - mov sp, x0 - msr spsel, #0 -/* Restore exception LR */ - msr ELR_EL1, x1 - ldp x0, x1, [sp, #0x00] - -/* We must clear reservations to ensure consistency with atomic operations */ - clrex - - ret diff --git a/cpukit/score/cpu/aarch64/aarch64-exception-default.c b/cpukit/score/cpu/aarch64/aarch64-exception-default.c index 2ebb3dee9f..4e7484f718 100644 --- a/cpukit/score/cpu/aarch64/aarch64-exception-default.c +++ b/cpukit/score/cpu/aarch64/aarch64-exception-default.c @@ -43,8 +43,70 @@ #include #include +#include void _AArch64_Exception_default( CPU_Exception_frame *frame ) { rtems_fatal( RTEMS_FATAL_SOURCE_EXCEPTION, (rtems_fatal_code) frame ); } + +void Excepti
[PATCH v2 1/6] cpukit/aarch64: Use correct interrupt level types
All other architectures use uint32_t for interrupt levels and there is no reason not to do so on AArch64. --- cpukit/score/cpu/aarch64/cpu.c | 4 ++-- cpukit/score/cpu/aarch64/include/rtems/score/cpu.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cpukit/score/cpu/aarch64/cpu.c b/cpukit/score/cpu/aarch64/cpu.c index d09403a349..b36f55ae17 100644 --- a/cpukit/score/cpu/aarch64/cpu.c +++ b/cpukit/score/cpu/aarch64/cpu.c @@ -146,7 +146,7 @@ void _CPU_Context_Initialize( } } -void _CPU_ISR_Set_level( uint64_t level ) +void _CPU_ISR_Set_level( uint32_t level ) { /* Set the mask bit if interrupts are disabled */ level = level ? AARCH64_PSTATE_I : 0; @@ -156,7 +156,7 @@ void _CPU_ISR_Set_level( uint64_t level ) ); } -uint64_t _CPU_ISR_Get_level( void ) +uint32_t _CPU_ISR_Get_level( void ) { uint64_t level; diff --git a/cpukit/score/cpu/aarch64/include/rtems/score/cpu.h b/cpukit/score/cpu/aarch64/include/rtems/score/cpu.h index 82f74193a2..ae7e2bdcba 100644 --- a/cpukit/score/cpu/aarch64/include/rtems/score/cpu.h +++ b/cpukit/score/cpu/aarch64/include/rtems/score/cpu.h @@ -204,9 +204,9 @@ static inline void _AARCH64_Instruction_synchronization_barrier( void ) __asm__ volatile ( "isb" : : : "memory" ); } -void _CPU_ISR_Set_level( uint64_t level ); +void _CPU_ISR_Set_level( uint32_t level ); -uint64_t _CPU_ISR_Get_level( void ); +uint32_t _CPU_ISR_Get_level( void ); #if defined(AARCH64_DISABLE_INLINE_ISR_DISABLE_ENABLE) uint64_t AArch64_interrupt_disable( void ); -- 2.30.2 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
[PATCH v2 5/6] cpukit: Add signal mapping support
This adds a confdef option allowing an application to request mapping machine exceptions to POSIX signals. This is required for some languages such as Ada. --- cpukit/doxygen/appl-config.h | 25 - cpukit/include/rtems/confdefs/extensions.h | 7 ++ cpukit/include/rtems/exception.h | 12 +++ cpukit/score/src/exceptionmapping.c| 106 + spec/build/cpukit/librtemscpu.yml | 2 + spec/build/cpukit/objexceptionmapping.yml | 15 +++ 6 files changed, 166 insertions(+), 1 deletion(-) create mode 100644 cpukit/score/src/exceptionmapping.c create mode 100644 spec/build/cpukit/objexceptionmapping.yml diff --git a/cpukit/doxygen/appl-config.h b/cpukit/doxygen/appl-config.h index bbeb438bec..8ad3a3c70e 100644 --- a/cpukit/doxygen/appl-config.h +++ b/cpukit/doxygen/appl-config.h @@ -3,7 +3,7 @@ /* * Copyright (C) 2019, 2021 embedded brains GmbH (http://www.embedded-brains.de) * Copyright (C) 2010 Gedare Bloom - * Copyright (C) 1988, 2008 On-Line Applications Research Corporation (OAR) + * Copyright (C) 1988, 2021 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 @@ -1773,6 +1773,29 @@ */ #define CONFIGURE_ATA_DRIVER_TASK_PRIORITY +/* Generated from spec:/acfg/if/exception-to-signal-mapping */ + +/** + * @brief This configuration option is a boolean feature define. + * + * In case this configuration option is defined, then the machine exception to + * POSIX signal mapping is configured during system initialization. + * + * @par Default Configuration + * If this configuration option is undefined, then the described feature is not + * enabled. + * + * @par Notes + * @parblock + * This device driver is responsible for setting up a mapping from machine + * exceptions to POSIX signals so that applications may consume them and alter + * task execution as necessary. + * + * This is especially useful for applications written in Ada or C++. + * @endparblock + */ +#define CONFIGURE_EXCEPTION_TO_SIGNAL_MAPPING + /* Generated from spec:/acfg/if/max-drivers */ /** diff --git a/cpukit/include/rtems/confdefs/extensions.h b/cpukit/include/rtems/confdefs/extensions.h index 83d690d50a..767c9028d1 100644 --- a/cpukit/include/rtems/confdefs/extensions.h +++ b/cpukit/include/rtems/confdefs/extensions.h @@ -93,6 +93,10 @@ #include #endif +#ifdef CONFIGURE_EXCEPTION_TO_SIGNAL_MAPPING + #include +#endif + #ifdef __cplusplus extern "C" { #endif @@ -103,6 +107,9 @@ extern "C" { || defined(CONFIGURE_INITIAL_EXTENSIONS) \ || defined(BSP_INITIAL_EXTENSION) const User_extensions_Table _User_extensions_Initial_extensions[] = { +#ifdef CONFIGURE_EXCEPTION_TO_SIGNAL_MAPPING + { .fatal = _Exception_map_signal }, +#endif #ifdef _CONFIGURE_RECORD_NEED_EXTENSION { #ifdef CONFIGURE_RECORD_EXTENSIONS_ENABLED diff --git a/cpukit/include/rtems/exception.h b/cpukit/include/rtems/exception.h index 89edfd02b4..547d7c42c2 100644 --- a/cpukit/include/rtems/exception.h +++ b/cpukit/include/rtems/exception.h @@ -159,6 +159,18 @@ void Exception_Manager_Copy_CPU_Exception_frame( CPU_Exception_frame *old_ef ); +/** + * @brief Handle an exception frame for mapping signals + * + * See CONFIGURE_EXCEPTION_TO_SIGNAL_MAPPING documentation in the + * "RTEMS Classic API Guide". + */ +void _Exception_map_signal( + Internal_errors_Source source, + bool always_set_to_false, + Internal_errors_t code +); + #ifdef __cplusplus } #endif diff --git a/cpukit/score/src/exceptionmapping.c b/cpukit/score/src/exceptionmapping.c new file mode 100644 index 00..a1b1146d1c --- /dev/null +++ b/cpukit/score/src/exceptionmapping.c @@ -0,0 +1,106 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSScoreExceptionMapping + * + * @brief AArch64 machine exception to POSIX signal mapping. + */ + +/* + * Copyright (C) 2021 On-Line Applications Research Corporation (OAR) + * Written by Kinsey Moore + * + * 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 DIR
[PATCH v2 6/6] testsuite: Add machine exception signal map test
Add a test to verify that mapping of machine exceptions to POSIX signals operates properly when the application requests it. --- spec/build/testsuites/psxtests/grp.yml| 2 + .../build/testsuites/psxtests/psxsignal09.yml | 22 ++ testsuites/psxtests/psxsignal09/init.c| 73 +++ .../psxtests/psxsignal09/psxsignal09.doc | 7 ++ .../psxtests/psxsignal09/psxsignal09.scn | 3 + testsuites/psxtests/psxsignal09/system.h | 55 ++ 6 files changed, 162 insertions(+) create mode 100644 spec/build/testsuites/psxtests/psxsignal09.yml create mode 100644 testsuites/psxtests/psxsignal09/init.c create mode 100644 testsuites/psxtests/psxsignal09/psxsignal09.doc create mode 100644 testsuites/psxtests/psxsignal09/psxsignal09.scn create mode 100644 testsuites/psxtests/psxsignal09/system.h diff --git a/spec/build/testsuites/psxtests/grp.yml b/spec/build/testsuites/psxtests/grp.yml index 9a0cb189fb..3ebd6a3373 100644 --- a/spec/build/testsuites/psxtests/grp.yml +++ b/spec/build/testsuites/psxtests/grp.yml @@ -208,6 +208,8 @@ links: uid: psxsignal07 - role: build-dependency uid: psxsignal08 +- role: build-dependency + uid: psxsignal09 - role: build-dependency uid: psxspin01 - role: build-dependency diff --git a/spec/build/testsuites/psxtests/psxsignal09.yml b/spec/build/testsuites/psxtests/psxsignal09.yml new file mode 100644 index 00..b09e2d62ce --- /dev/null +++ b/spec/build/testsuites/psxtests/psxsignal09.yml @@ -0,0 +1,22 @@ +SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause +build-type: test-program +cflags: [] +copyrights: +- Copyright (C) 2021 On-Line Applications Research (OAR) +cppflags: [] +cxxflags: [] +enabled-by: +- and: + - RTEMS_EXCEPTION_MANAGER + - RTEMS_POSIX_API +features: c cprogram +includes: [] +ldflags: [] +links: [] +source: +- testsuites/psxtests/psxsignal09/init.c +stlib: [] +target: testsuites/psxtests/psxsignal09.exe +type: build +use-after: [] +use-before: [] diff --git a/testsuites/psxtests/psxsignal09/init.c b/testsuites/psxtests/psxsignal09/init.c new file mode 100644 index 00..12883cc28c --- /dev/null +++ b/testsuites/psxtests/psxsignal09/init.c @@ -0,0 +1,73 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup psxtests + */ + +/* + * Copyright (C) 2021 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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#define CONFIGURE_INIT +#include "system.h" +#include +#include +#include + +const char rtems_test_name[] = "PSXSIGNAL 9"; + +static void Handler_1( int signo ) +{ + TEST_END(); + rtems_test_exit(0); +} + +void *POSIX_Init( void *argument ) +{ + int status; + struct sigaction act; + + TEST_BEGIN(); + + /* Hook signals that can be generated from machine exceptions */ + act.sa_handler = Handler_1; + act.sa_flags = 0; + status = sigaction( SIGFPE, &act, NULL ); + rtems_test_assert( !status ); + status = sigaction( SIGILL, &act, NULL ); + rtems_test_assert( !status ); + status = sigaction( SIGSEGV, &act, NULL ); + rtems_test_assert( !status ); + + /* Generate machine exception */ + _CPU_Instruction_illegal(); + + return NULL; +} diff --git a/testsuites/psxtests/psxsignal09/psxsignal09.doc b/testsuites/psxtests/psxsignal09/psxsignal09.doc new file mode 100644 index 00..5375ee6c20 --- /dev/null +++ b/testsuites/psxtests/psxsignal09/psxsignal09.doc @@ -0,0 +1,7 @@ +# COPYRIGHT (c) 2021. +# On-Line Applications Research Corporation (OAR). +# +# SPDX-License-Identifier: BSD-2-Clause + +This test ensures that machine exceptions are mapped to POSIX signals when +required
Re: [PATCHv5] improve the format error reporting on i386
I can send an example of the exception if you want. zack On Wed, 22 Sept 2021 at 18:01, Gedare Bloom wrote: > Joel, > > This looks good to me. I don't know if you can easily test it? > > Gedare > > On Wed, Sep 22, 2021 at 11:26 AM zack leung > wrote: > > > > ll hex values now have 8 character width > > thread id is now hex > > updates #4203 > > --- > > cpukit/score/cpu/i386/cpu.c | 6 +++--- > > 1 file changed, 3 insertions(+), 3 deletions(-) > > > > diff --git a/cpukit/score/cpu/i386/cpu.c b/cpukit/score/cpu/i386/cpu.c > > index 77b7a7161c..786cf8b0b6 100644 > > --- a/cpukit/score/cpu/i386/cpu.c > > +++ b/cpukit/score/cpu/i386/cpu.c > > @@ -215,16 +215,16 @@ void _CPU_Exception_frame_print (const > > CPU_Exception_frame *ctx) > > { > >unsigned int faultAddr = 0; > > > printk("--\n"); > > - printk("Exception %" PRIu32 " caught at PC %" PRIx32 " by thread %" > > PRId32 "\n", > > + printk("Exception %" PRIu32 " caught at PC %" PRIx32 " by thread > 0x%08" > > PRIx32 "\n", > > ctx->idtIndex, > > ctx->eip, > > _Thread_Executing->Object.id); > > > printk("--\n"); > >printk("Processor execution context at time of the fault was :\n"); > > > printk("--\n"); > > - printk(" EAX = %" PRIx32 "EBX = %" PRIx32 "ECX = %" PRIx32 " > > EDX = %" PRIx32 "\n", > > + printk(" EAX = 0x%08" PRIx32 "EBX = 0x%08" PRIx32 "ECX = > > 0x%08" PRIx32 "EDX = 0x%08" PRIx32 "\n", > > ctx->eax, ctx->ebx, ctx->ecx, ctx->edx); > > - printk(" ESI = %" PRIx32 "EDI = %" PRIx32 "EBP = %" PRIx32 " > > ESP = %" PRIx32 "\n", > > + printk(" ESI = 0x%08" PRIx32 "EDI = 0x%08" PRIx32 "EBP = > > 0x%08" PRIx32 "ESP = 0x%08" PRIx32 "\n", > > ctx->esi, ctx->edi, ctx->ebp, ctx->esp0); > > > printk("--\n"); > >printk("Error code pushed by processor itself (if not 0) = %" PRIx32 > > "\n", > > -- > > 2.33.0 > > ___ > > devel mailing list > > devel@rtems.org > > http://lists.rtems.org/mailman/listinfo/devel > ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
Re: [PATCH rtems-tools v1 4/7] TraceReaderLogQEMU.cc: Fix formatting
On 23/9/21 12:35 am, Ryan Long wrote: > I changed the definition of discardBuff to > > char discardBuff[100]{}; char discardBuff[100] = {}; ? > So that every element will be initialized to \0. This function is only used > in TraceReaderLogQEMU.cc, and the values that are passed in are > > #define QEMU_LOG_IN_KEY "IN: " > #define QEMU_LOG_SECTION_END "" > > Neither are close to going over the size of discardBuff, but I can add a > check and return false if it does happen to go over that length. Checking how the call is being used is cheating ... :) Lets make the code robust and if someone makes a change and makes a mistake it is caught. Chris ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
Re: [PATCH v2 5/6] cpukit: Add signal mapping support
On 23/9/21 10:16 am, Kinsey Moore wrote: > This adds a confdef option allowing an application to request mapping > machine exceptions to POSIX signals. This is required for some languages > such as Ada.> --- a/cpukit/include/rtems/confdefs/extensions.h > +++ b/cpukit/include/rtems/confdefs/extensions.h > @@ -93,6 +93,10 @@ >#include > #endif > > +#ifdef CONFIGURE_EXCEPTION_TO_SIGNAL_MAPPING > + #include > +#endif > + > #ifdef __cplusplus > extern "C" { > #endif > @@ -103,6 +107,9 @@ extern "C" { >|| defined(CONFIGURE_INITIAL_EXTENSIONS) \ >|| defined(BSP_INITIAL_EXTENSION) >const User_extensions_Table _User_extensions_Initial_extensions[] = { > +#ifdef CONFIGURE_EXCEPTION_TO_SIGNAL_MAPPING > + { .fatal = _Exception_map_signal }, There is something amiss adding a recoverable interface and support that hooks `.fatal`. Either this field is now badly named or should there be something else added? Another extension? I do not know. What happens to my default fatal handler if I decide to enable this support? Chris ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
Re: [PATCH v2 5/6] cpukit: Add signal mapping support
On 9/22/2021 21:06, Chris Johns wrote: On 23/9/21 10:16 am, Kinsey Moore wrote: This adds a confdef option allowing an application to request mapping machine exceptions to POSIX signals. This is required for some languages such as Ada.> --- a/cpukit/include/rtems/confdefs/extensions.h +++ b/cpukit/include/rtems/confdefs/extensions.h @@ -93,6 +93,10 @@ #include #endif +#ifdef CONFIGURE_EXCEPTION_TO_SIGNAL_MAPPING + #include +#endif + #ifdef __cplusplus extern "C" { #endif @@ -103,6 +107,9 @@ extern "C" { || defined(CONFIGURE_INITIAL_EXTENSIONS) \ || defined(BSP_INITIAL_EXTENSION) const User_extensions_Table _User_extensions_Initial_extensions[] = { +#ifdef CONFIGURE_EXCEPTION_TO_SIGNAL_MAPPING + { .fatal = _Exception_map_signal }, There is something amiss adding a recoverable interface and support that hooks `.fatal`. Either this field is now badly named or should there be something else added? Another extension? I do not know. I agree and that's partially the reason my previous patch had this split out into a different extension type. This API is not something I feel comfortable breaking for users, so I'd lean away from renaming it. My takeaway from our discussion was that this should be implemented as a fatal error extension with an epilogue function to break out of the normal call stack and perform exception cleanup tasks. What happens to my default fatal handler if I decide to enable this support? If you enable this support, some fatal errors will be deemed recoverable and recovered errors will not propagate to further fatal error handlers. If enabled, handlers of this variety must run first to avoid any side effects on the system caused by other fatal handlers taking final actions on what they expect is a dead system. Kinsey ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
[PATCH rtems-libbsd] rtemsbsd/open: Correctly open a mount directory
From: Chris Johns - If the open is for a directory and it is the root of the mounted file system open from the pseudo's root node. --- rtemsbsd/rtems/rtems-bsd-syscall-api.c | 62 ++ rtemsbsd/rtems/rtems-kernel-vfs.c | 3 ++ testsuite/nfs01/test_main.c| 5 +++ 3 files changed, 52 insertions(+), 18 deletions(-) diff --git a/rtemsbsd/rtems/rtems-bsd-syscall-api.c b/rtemsbsd/rtems/rtems-bsd-syscall-api.c index 434cacbd..3ff73dc1 100644 --- a/rtemsbsd/rtems/rtems-bsd-syscall-api.c +++ b/rtemsbsd/rtems/rtems-bsd-syscall-api.c @@ -61,6 +61,8 @@ static int rtems_bsd_sysgen_open_error( rtems_libio_t *iop, const char *path, int oflag, mode_t mode); +static int rtems_bsd_sysgen_opendir( +rtems_libio_t *iop, const char *path, int oflag, mode_t mode); static int rtems_bsd_sysgen_open( rtems_libio_t *iop, const char *path, int oflag, mode_t mode); static int rtems_bsd_sysgen_close(rtems_libio_t *iop); @@ -90,7 +92,7 @@ static int rtems_bsd_sysgen_poll(rtems_libio_t *iop, int events); static int rtems_bsd_sysgen_kqfilter(rtems_libio_t *iop, struct knote *kn); const rtems_filesystem_file_handlers_r rtems_bsd_sysgen_dirops = { - .open_h = rtems_bsd_sysgen_open, + .open_h = rtems_bsd_sysgen_opendir, .close_h = rtems_bsd_sysgen_close, .read_h = rtems_bsd_sysgen_read, .write_h = rtems_filesystem_default_write, @@ -928,9 +930,9 @@ rtems_bsd_sysgen_open_error( return rtems_bsd_error_to_status_and_errno(ENXIO); } -int -rtems_bsd_sysgen_open( -rtems_libio_t *iop, const char *path, int oflag, mode_t mode) +static int +rtems_bsd_sysgen_open_node( + rtems_libio_t *iop, const char *path, int oflag, mode_t mode, bool isdir) { struct thread *td = rtems_bsd_get_curthread_or_null(); struct filedesc *fdp; @@ -954,13 +956,13 @@ rtems_bsd_sysgen_open( /* * There is no easy or clean means to open a vnode and follow the -* POSIX open semantics. You can open a vnode but the extra -* functionality such as create and truncate are not part of the -* basic vnode open. All the calls that provide that functionality -* take a path as the argument. As a result find the last token in -* the path and use the parent directory vnode to position ourselves -* in the parent directory. The pathloc vnode points to the '.' or -* '..' directory. +* POSIX open semantics. See `kern_openat`. You can open a vnode but +* the extra functionality such as the file pointer, descriptor, +* create and truncate are not part of the basic vnode open. All the +* calls that provide that functionality take a path as the +* argument. As a result find the last token in the path and use the +* parent directory vnode to position ourselves in the parent +* directory. The pathloc vnode points to the '.' or '..' directory. */ opath = path + strlen(path); opathlen = 0; @@ -982,10 +984,20 @@ rtems_bsd_sysgen_open( rtems_filesystem_location_info_t *rootloc = &iop->pathinfo.mt_entry->mt_fs_root->location; cdir = rtems_bsd_libio_loc_to_vnode_dir(&iop->pathinfo); - if (fdp->fd_cdir == NULL || - rtems_bsd_libio_loc_to_vnode(&iop->pathinfo) == - rtems_bsd_libio_loc_to_vnode(rootloc)) { + if (fdp->fd_cdir == NULL) { cdir = rtems_bsd_libio_loc_to_vnode(rootloc); + } else if (rtems_bsd_libio_loc_to_vnode(&iop->pathinfo) == + rtems_bsd_libio_loc_to_vnode(rootloc)) { + /* +* If this is a directory and this is the root node of +* the mounted file system we need to move up the +* hidden pseudo file system node. +*/ + if (isdir) { + cdir = rootvnode; + } else { + cdir = rtems_bsd_libio_loc_to_vnode(rootloc); + } } } @@ -999,10 +1011,10 @@ rtems_bsd_sysgen_open( if (RTEMS_BSD_SYSCALL_TRACE) { printf("bsd: sys: open: path=%s opath=%s vn=%p cwd=%p" - " flags=%08x mode=%08x\n", + " flags=%08x mode=%08x isdir=%s\n", path, opath, creat ? NULL : rtems_bsd_libio_loc_to_vnode(&iop->pathinfo), - fdp->fd_cdir, oflag, mode); + fdp->fd_cdir, oflag, mode, isdir ? "yes" : "no"); } VREF(fdp->fd_cdir); @@ -1047,6 +1059,20 @@ rtems_bsd_sysgen_open( return 0; } +int +rtems_bsd_sysgen_opendir( +rtems_libio_t *iop, const char *path, int oflag, mode_t mode) +{ +return rtems_bsd_sysgen_open_
[PATCH rtems-docs] user/testing: Add the %wait directive
From: Chris Johns --- user/testing/configuration.rst | 84 +++--- user/testing/tftp.rst | 12 +++-- 2 files changed, 86 insertions(+), 10 deletions(-) diff --git a/user/testing/configuration.rst b/user/testing/configuration.rst index 9c65506..4d67482 100644 --- a/user/testing/configuration.rst +++ b/user/testing/configuration.rst @@ -1,6 +1,6 @@ .. SPDX-License-Identifier: CC-BY-SA-4.0 -.. Copyright (C) 2018 Chris Johns +.. Copyright (C) 2018,2021 Chris Johns Tester Configuration @@ -226,9 +226,10 @@ supported directives are: - ``%execute`` - ``%gdb`` - ``%tftp`` +- ``%wait`` -.. _tester-config-console: .. index:: Console, %console +.. _tester-config-console: Console ~~~ @@ -278,10 +279,12 @@ configuration script. If the ``%{console_stdio}`` is defined the console will be ``stdio`` else the console will be the BSP console or ``%{bsp_tty_dev}``. Telnet can be combined with the ``ser2net`` daemon to remotely access a -target's physical serial UART interface. +target's physical serial UART interface. The syntax is ``host:port``:: + + %define bsp_tty_dev 1.2.3.4:8989 -.. _tester-config-execute: .. index:: Execute, %execute +.. _tester-config-execute: Execute ~~~ @@ -297,8 +300,8 @@ An example is:: %execute %{run_cmd} %{run_opts} %{test_executable} %{test_executable_opts} -.. _tester-config-gdb: .. index:: GDB, %gdb +.. _tester-config-gdb: GDB ~~~ @@ -313,8 +316,8 @@ An example is:: %gdb %{gdb_cmd} %{test_executable} %{gdb_script} -.. _tester-config-tftp: .. index:: TFTP, %tftp +.. _tester-config-tftp: TFTP @@ -328,3 +331,72 @@ board running the test. An example is:: %tftp %{test_executable} %{tftp_port} + +The RTEMS Tester contains a TFTP server so an external TFTP is not +needed. It is recommended a TFTP Proxy is set up to handle the TFTP +sessions for your network. The internal TFTP server ignores the +requrest file and serves the next executable. If the target requires +the executable ne in a specific format provide a script via the +``target_pretest_command`` option in your user configuration file. + +The RTEMS Tools provides a TFTP protocol proxy server. It takes a list +of MAC addresses and proxies TFTP sessions for that MAC address to +another IP address and port. A proxy provides the following benefits: + +1. The TFTP proxy server is the only software required to run as root + +2. All hardware targets can be configured to serve from a single + machine and the proxy can distribute the sessions out to developer + machines + +3. There is no need to provide a globally writable file system a + central TFTP server acceses + +If you have a central TFTP server refer to the ``%wait`` directive. + +.. index:: Wait, %wait +.. _tester-config-wait: + +Wait + + +The ``%wait`` directive waits the timeout period for a test to +complete. The directive monitors the console output and resets the +timeout timer if console output is seen. If the test runs for too long +while outputing data an error is reported. + +The wait directive can be used in systems where there is an external +mechanism being used to send the executable to the target hardware. + +An example is:: + + %wait + +Wait has no options. The timeouts are controlled in other ways. + +If you have an external system wide TFTP server with global access +wait can used by providing a `` script that places the file in the +location the TFTP server can see. This is done as the test start so if +networking loading there is normally enough time to get the executable +image in place before the transfer starts. The MVME2700 +(``powerpc/mvme2307``) is a BSP that supports the ``%wait`` directive. + +The following is an example user configuration file (see +``--user-config``):: + + # + # MVME2700 (mvme2307) + # + [mvme2307] + bsp_tty_dev= 1.2.3.4:5678 + target_pretest_command = mk-mvme2307-img @EXE@ /tftp/cjohns/rtems.img + target_exe_filter = /\.exe/.exe.img/ + target_on_command = pw-ctl 1.2.3.4 toggle-on 3 1 + target_off_command = pw-ctl 1.2.3.4 off 3 + target_reset_command = pw-ctl 1.2.3.4 toggle-on 3 1 + +The script ``mk-mvme2307-img`` converts the RTEMS ELF executable into +the PowerPC prep bootloader format and copies the file to the TFTP +server's network wide location. The MVME2700 is configured to request +``rtems.img`` from this location. The command ``pw-ctl`` is a command +to control the power to the board. diff --git a/user/testing/tftp.rst b/user/testing/tftp.rst index ade8f9a..4cb16ef 100644 --- a/user/testing/tftp.rst +++ b/user/testing/tftp.rst @@ -10,10 +10,14 @@ TFTP and U-Boot .. index:: TFTP, U-Boot, Testing TFTP and U-Boot provides a simple way to test RTEMS on a network capable -target. The RTEMS Tester starts a TFTP server for each test and the target's -boot monitor, in this case U-Boot request a file, any file, which the TFTP -server supplies. U-Boot loads
[PATCH] score: Avoid dead code in thread queue surrender
For uniprocessor configurations, this patch removes dead code in the _Thread_queue_Surrender() and _Thread_queue_Surrender_priority_ceiling() functions. Dead code is removed from _Thread_queue_Surrender_sticky(). --- cpukit/score/src/threadqenqueue.c | 79 ++- 1 file changed, 67 insertions(+), 12 deletions(-) diff --git a/cpukit/score/src/threadqenqueue.c b/cpukit/score/src/threadqenqueue.c index 4b138ba4d1..1b8b82eab9 100644 --- a/cpukit/score/src/threadqenqueue.c +++ b/cpukit/score/src/threadqenqueue.c @@ -544,6 +544,16 @@ static bool _Thread_queue_MP_set_callout( } #endif +static void _Thread_queue_Force_ready_again( Thread_Control *the_thread ) +{ + /* + * We must set the wait flags under protection of the current thread lock, + * otherwise a _Thread_Timeout() running on another processor may interfere. + */ + _Thread_Wait_flags_set( the_thread, THREAD_QUEUE_READY_AGAIN ); + _Thread_Wait_restore_default( the_thread ); +} + static bool _Thread_queue_Make_ready_again( Thread_Control *the_thread ) { bool success; @@ -570,6 +580,45 @@ static bool _Thread_queue_Make_ready_again( Thread_Control *the_thread ) return unblock; } +/* + * This function is used instead of _Thread_queue_Make_ready_again() in + * _Thread_queue_Surrender() and _Thread_queue_Surrender_priority_ceiling() + * since only the previous owner thread is allowed to surrender the thread + * queue. + * + * In uniprocessor configurations, there is only one executing thread (in this + * case the previous owner), so the new owner thread must be fully blocked. + * + * In SMP configurations, the new owner may execute on another processor in + * parallel, so we have to use _Thread_queue_Make_ready_again(). + */ +static bool _Thread_queue_Make_new_owner_ready_again( Thread_Control *new_owner ) +{ +#if defined(RTEMS_SMP) + return _Thread_queue_Make_ready_again( new_owner ); +#else + _Assert( _Thread_Wait_flags_get( new_owner ) == THREAD_QUEUE_BLOCKED ); + _Thread_queue_Force_ready_again( new_owner ); + return false; +#endif +} + +static void _Thread_queue_Unblock_new_owner_and_remove_timer( + Thread_queue_Queue *queue, + Thread_Control *new_owner, + boolunblock +) +{ +#if defined(RTEMS_SMP) + if ( unblock ) { +_Thread_Remove_timer_and_unblock( new_owner, queue ); + } +#else + (void) unblock; + _Thread_Remove_timer_and_unblock( new_owner, queue ); +#endif +} + bool _Thread_queue_Extract_locked( Thread_queue_Queue*queue, const Thread_queue_Operations *operations, @@ -673,7 +722,7 @@ void _Thread_queue_Surrender( _Thread_Resource_count_increment( new_owner ); } - unblock = _Thread_queue_Make_ready_again( new_owner ); + unblock = _Thread_queue_Make_new_owner_ready_again( new_owner ); cpu_self = _Thread_queue_Dispatch_disable( queue_context ); _Thread_queue_Queue_release( @@ -682,10 +731,11 @@ void _Thread_queue_Surrender( ); _Thread_Priority_update( queue_context ); - - if ( unblock ) { -_Thread_Remove_timer_and_unblock( new_owner, queue ); - } + _Thread_queue_Unblock_new_owner_and_remove_timer( +queue, +new_owner, +unblock + ); _Thread_Dispatch_enable( cpu_self ); } @@ -771,7 +821,7 @@ Status_Control _Thread_queue_Surrender_priority_ceiling( queue->owner = new_owner; - unblock = _Thread_queue_Make_ready_again( new_owner ); + unblock = _Thread_queue_Make_new_owner_ready_again( new_owner ); #if defined(RTEMS_MULTIPROCESSING) if ( _Objects_Is_local_id( new_owner->Object.id ) ) @@ -790,10 +840,11 @@ Status_Control _Thread_queue_Surrender_priority_ceiling( ); _Thread_Priority_update( queue_context ); - - if ( unblock ) { -_Thread_Remove_timer_and_unblock( new_owner, queue ); - } + _Thread_queue_Unblock_new_owner_and_remove_timer( +queue, +new_owner, +unblock + ); _Thread_Dispatch_direct( cpu_self ); return STATUS_SUCCESSFUL; @@ -823,11 +874,15 @@ void _Thread_queue_Surrender_sticky( queue->owner = new_owner; /* - * There is no need to check the unblock status, since in the corresponding + * There is no need to unblock the thread, since in the corresponding * _Thread_queue_Enqueue_sticky() the thread is not blocked by the scheduler. * Instead, the thread busy waits for a change of its thread wait flags. + * Timeouts cannot interfere since we hold the thread queue lock. */ - (void) _Thread_queue_Make_ready_again( new_owner ); + _Assert( +_Thread_Wait_flags_get( new_owner ) == THREAD_QUEUE_INTEND_TO_BLOCK + ); + _Thread_queue_Force_ready_again( new_owner ); cpu_self = _Thread_queue_Dispatch_disable( queue_context ); _Thread_queue_Queue_release( -- 2.31.1 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
[PATCH rtems-libbsd] rtemsbsd/syscalls: Remove pipe()
From: Chris Johns - This call is provided by RTEMS and that is preferred Closes #4518 --- rtemsbsd/rtems/rtems-bsd-syscall-api.c | 52 testsuite/selectpollkqueue01/test_main.c | 155 --- 2 files changed, 207 deletions(-) diff --git a/rtemsbsd/rtems/rtems-bsd-syscall-api.c b/rtemsbsd/rtems/rtems-bsd-syscall-api.c index 3ff73dc1..76fc8ad7 100644 --- a/rtemsbsd/rtems/rtems-bsd-syscall-api.c +++ b/rtemsbsd/rtems/rtems-bsd-syscall-api.c @@ -441,58 +441,6 @@ listen(int socket, int backlog) return rtems_bsd_error_to_status_and_errno(error); } -int -pipe(int fildes[2]) -{ - struct thread *td = rtems_bsd_get_curthread_or_null(); - rtems_libio_t *iop[2]; - int error; - if (RTEMS_BSD_SYSCALL_TRACE) { - printf("bsd: sys: pipe: %d\n", socket); - } - if (td == NULL) { - return rtems_bsd_error_to_status_and_errno(ENOMEM); - } - iop[0] = rtems_bsd_libio_iop_allocate(); - if (iop[0] == NULL) { - return rtems_bsd_error_to_status_and_errno(ENFILE); - } - iop[1] = rtems_bsd_libio_iop_allocate(); - if (iop[1] == NULL) { - rtems_bsd_libio_iop_free(iop[0]); - return rtems_bsd_error_to_status_and_errno(ENFILE); - } - error = kern_pipe(td, fildes, 0, NULL, NULL); - if (error != 0) { - goto out; - } - error = rtems_bsd_libio_iop_set_bsd_fd( - td, fildes[0], iop[0], &rtems_bsd_sysgen_nodeops); - if (error != 0) { - goto out; - } - error = rtems_bsd_libio_iop_set_bsd_fd( - td, fildes[1], iop[1], &rtems_bsd_sysgen_nodeops); - if (error == 0) { - fildes[0] = rtems_libio_iop_to_descriptor(iop[0]); - fildes[1] = rtems_libio_iop_to_descriptor(iop[1]); - if (RTEMS_BSD_SYSCALL_TRACE) { - printf("bsd: sys: pipe: %d -> %d, %d -> %d\n", - fildes[0], - rtems_bsd_libio_iop_to_descriptor(iop[0]), - fildes[1], - rtems_bsd_libio_iop_to_descriptor(iop[1])); - } - return 0; - } -out: - kern_close(td, rtems_bsd_libio_iop_to_descriptor(iop[0])); - kern_close(td, rtems_bsd_libio_iop_to_descriptor(iop[1])); - rtems_bsd_libio_iop_free(iop[0]); - rtems_bsd_libio_iop_free(iop[1]); - return rtems_bsd_error_to_status_and_errno(error); -} - int poll(struct pollfd fds[], nfds_t nfds, int timeout) { diff --git a/testsuite/selectpollkqueue01/test_main.c b/testsuite/selectpollkqueue01/test_main.c index 1c481517..fe114189 100755 --- a/testsuite/selectpollkqueue01/test_main.c +++ b/testsuite/selectpollkqueue01/test_main.c @@ -1095,156 +1095,6 @@ test_kqueue_user(test_context *ctx) assert(rv == 0); } -static void -test_pipe_timeout(test_context *ctx) -{ - struct pipe_poll_events - { - short event; - int rv; - }; - const struct pipe_poll_events events[] = { - { POLLIN, 0 }, - { POLLPRI, 0 }, - { POLLOUT, 1 }, - { POLLRDNORM, 0 }, - { POLLWRNORM, 1 }, - { POLLRDBAND, 0 }, - { POLLWRBAND, 0 }, - { POLLINIGNEOF, 0 } - }; - - int timeout = 100; - struct pollfd pfd; - size_t i; - int rv; - - puts("test pipe timeout"); - - rv = pipe(ctx->pfd); - assert(rv == 0); - - pfd.fd = ctx->pfd[1]; - - for (i = 0; i < nitems(events); ++i) { - int rv; - - pfd.events = events[i].event; - pfd.revents = 0; - - rv = poll(&pfd, 1, timeout); - assert(rv == events[i].rv); - } -} - -static void -test_pipe_read(test_context *ctx) -{ - int rfd = ctx->pfd[0]; - int wfd = ctx->pfd[1]; - struct pollfd pfd = { - .fd = rfd, - .events = POLLIN - }; - int timeout = -1; - int rv; - ssize_t n; - - puts("test pipe read"); - - assert(rfd >= 0); - assert(wfd >= 0); - - ctx->wfd = wfd; - ctx->wbuf = &msg[0]; - ctx->wn = sizeof(msg); - send_events(ctx, EVENT_WRITE); - - set_non_blocking(rfd, 1); - - errno = 0; - n = read(rfd, &ctx->buf[0], sizeof(ctx->buf)); - assert(n == -1); - assert(errno == EAGAIN); - - rv = poll(&pfd, 1, timeout); - assert(rv == 1); - assert(pfd.revents == POLLIN); - - n = read(rfd, &ctx->buf[0], sizeof(ctx->buf)); - assert(n == (ssize_t) sizeof(msg)); - assert(memcmp(&msg[0], &ctx->buf[0], sizeof(msg)) == 0); -} - -static void -test_pipe_write(test_context *ctx) -{ - int rfd = ctx->pfd[0]; - int wfd = ctx->pfd[1]; - struct pollfd pfd = { - .fd = wfd, -
Re: [PATCH rtems-libbsd] rtemsbsd/syscalls: Remove pipe()
On 23/09/2021 07:43, chr...@rtems.org wrote: From: Chris Johns - This call is provided by RTEMS and that is preferred Closes #4518 This removes the kqueue() support for pipe(). -- embedded brains GmbH Herr Sebastian HUBER Dornierstr. 4 82178 Puchheim Germany email: sebastian.hu...@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@rtems.org http://lists.rtems.org/mailman/listinfo/devel