diff --git a/bsps/moxie/moxiesim/console/syscalls.S b/bsps/moxie/moxiesim/console/syscalls.S index f9a63a29b5..87fcf587aa 100644 --- a/bsps/moxie/moxiesim/console/syscalls.S +++ b/bsps/moxie/moxiesim/console/syscalls.S @@ -4,6 +4,7 @@ * COPYRIGHT (c) 2011 Anthony Green */ +#define SYS_exit 1 #define SYS_write 5 .section .text @@ -12,4 +13,13 @@ _sys_write: swi SYS_write ret + +/* + * Terminate the simulator. The exit status is passed in $r0. + */ + .align 2 + .global _sys_exit +_sys_exit: + swi SYS_exit + ret .end diff --git a/bsps/moxie/moxiesim/start/bspreset.c b/bsps/moxie/moxiesim/start/bspreset.c new file mode 100644 index 0000000000..38354747c2 --- /dev/null +++ b/bsps/moxie/moxiesim/start/bspreset.c @@ -0,0 +1,56 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSBSPsMoxieMoxieSim + * + * @brief Moxiesim Reset Support + * + * The Moxie GDB simulator terminates on the SYS_exit system call. Nothing + * else stops it, and it flushes its buffered console output only when it + * terminates. + */ + +/* + * Copyright (C) 2026 embedded brains GmbH & Co. KG + * + * 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. + */ + +#include + +void _sys_exit( int status ); + +void bsp_reset( rtems_fatal_source source, rtems_fatal_code code ) +{ + int status; + + if ( source == RTEMS_FATAL_SOURCE_EXIT && code == 0 ) { + status = 0; + } else { + status = 1; + } + + _sys_exit( status ); + RTEMS_UNREACHABLE(); +} diff --git a/spec/build/bsps/moxie/moxiesim/bspmoxiesim.yml b/spec/build/bsps/moxie/moxiesim/bspmoxiesim.yml index f414083a96..2dbf3dbe80 100644 --- a/spec/build/bsps/moxie/moxiesim/bspmoxiesim.yml +++ b/spec/build/bsps/moxie/moxiesim/bspmoxiesim.yml @@ -43,12 +43,12 @@ links: source: - bsps/moxie/moxiesim/console/console-io.c - bsps/moxie/moxiesim/console/syscalls.S +- bsps/moxie/moxiesim/start/bspreset.c - bsps/shared/cache/nocache.c - bsps/shared/dev/btimer/btimer-cpucounter.c - bsps/shared/dev/clock/clock-simidle.c - bsps/shared/dev/getentropy/getentropy-cpucounter.c - bsps/shared/dev/serial/console-polled.c -- bsps/shared/start/bspreset-loop.c - bsps/shared/start/bspstart-empty.c - bsps/shared/start/gettargethash-default.c - bsps/shared/start/sbrk.c