This is an automated email from the ASF dual-hosted git repository.

xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 45c657fb6675fa85b6339902fce91c73b41f0f4f
Author: Parthiban Nallathambi <[email protected]>
AuthorDate: Sat Oct 31 18:32:15 2026 +0530

    boards/rh850: add the qemu-rh850-u2c board.
    
    Add a board for the rh850-u2c machine of qemu-rh850
    (github.com/linumiz/qemu-rh850), with an nsh configuration.  With
    QEMU_RH850_U2C_TEST_EXIT, a test run stops QEMU with its exit status, so
    a failed test or a panic shows up as a non-zero exit code.
    
    Co-authored-by: Saravanan Sekar <[email protected]>
    Signed-off-by: Parthiban Nallathambi <[email protected]>
---
 boards/Kconfig                                     |  13 ++
 boards/rh850/u2c/qemu-rh850-u2c/CMakeLists.txt     |  23 ++++
 boards/rh850/u2c/qemu-rh850-u2c/Kconfig            |  20 +++
 .../rh850/u2c/qemu-rh850-u2c/configs/nsh/defconfig |  34 ++++++
 boards/rh850/u2c/qemu-rh850-u2c/include/board.h    |  26 ++++
 boards/rh850/u2c/qemu-rh850-u2c/scripts/Make.defs  |  34 ++++++
 .../u2c/qemu-rh850-u2c/scripts/qemu-rh850-u2c.ld   | 125 +++++++++++++++++++
 boards/rh850/u2c/qemu-rh850-u2c/src/CMakeLists.txt |  28 +++++
 boards/rh850/u2c/qemu-rh850-u2c/src/Makefile       |  27 +++++
 .../qemu-rh850-u2c/src/qemu_rh850_u2c_appinit.c    |  46 +++++++
 .../qemu-rh850-u2c/src/qemu_rh850_u2c_boardinit.c  | 135 +++++++++++++++++++++
 11 files changed, 511 insertions(+)

diff --git a/boards/Kconfig b/boards/Kconfig
index c2383bc2415..0360b2e58d8 100644
--- a/boards/Kconfig
+++ b/boards/Kconfig
@@ -2861,6 +2861,15 @@ config ARCH_BOARD_SABRE_6QUAD
                This options selects support for NuttX on the NXP/Freescale 
Sabre
                board featuring the iMX 6Quad CPU.
 
+config ARCH_BOARD_QEMU_RH850_U2C
+       bool "QEMU rh850-u2c machine"
+       depends on ARCH_CHIP_R7F702600
+       select ARCH_HAVE_POWEROFF
+       select ARCH_HAVE_RESET
+       ---help---
+               This options selects support for NuttX on the QEMU rh850-u2c
+               machine, the Renesas RH850/U2C8 (R7F702600) with its G4KH CPU0.
+
 config ARCH_BOARD_A2G_TC397_5V_TFT
        bool "Infineon's AURIX TC397 board: KIT_A2G_TC397_5V_TFT"
        depends on ARCH_CHIP_TC39X
@@ -4481,6 +4490,7 @@ config ARCH_BOARD
        default "starpro64"                    if ARCH_BOARD_EIC7700X_STARPRO64
        default "eic7700-evb"                  if ARCH_BOARD_EIC7700X_EVB
        default "sabre-6quad"                  if ARCH_BOARD_SABRE_6QUAD
+       default "qemu-rh850-u2c"               if ARCH_BOARD_QEMU_RH850_U2C
        default "a2g-tc397-5v-tft"             if ARCH_BOARD_A2G_TC397_5V_TFT
        default "triboard_tc4x9_com"           if ARCH_BOARD_TRIBOARD_TC4X9_COM
        default "qemu-armv7a"                  if ARCH_BOARD_QEMU_ARMV7A
@@ -4728,6 +4738,9 @@ endif
 if ARCH_BOARD_SABRE_6QUAD
 source "boards/arm/imx6/sabre-6quad/Kconfig"
 endif
+if ARCH_BOARD_QEMU_RH850_U2C
+source "boards/rh850/u2c/qemu-rh850-u2c/Kconfig"
+endif
 if ARCH_BOARD_A2G_TC397_5V_TFT
 source "boards/tricore/tc3xx/a2g-tc397-5v-tft/Kconfig"
 endif
diff --git a/boards/rh850/u2c/qemu-rh850-u2c/CMakeLists.txt 
b/boards/rh850/u2c/qemu-rh850-u2c/CMakeLists.txt
new file mode 100644
index 00000000000..41faedd3f8e
--- /dev/null
+++ b/boards/rh850/u2c/qemu-rh850-u2c/CMakeLists.txt
@@ -0,0 +1,23 @@
+# 
##############################################################################
+# boards/rh850/u2c/qemu-rh850-u2c/CMakeLists.txt
+#
+# SPDX-License-Identifier: Apache-2.0
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more 
contributor
+# license agreements.  See the NOTICE file distributed with this work for
+# additional information regarding copyright ownership.  The ASF licenses this
+# file to you under the Apache License, Version 2.0 (the "License"); you may 
not
+# use this file except in compliance with the License.  You may obtain a copy 
of
+# the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+# License for the specific language governing permissions and limitations under
+# the License.
+#
+# 
##############################################################################
+
+add_subdirectory(src)
diff --git a/boards/rh850/u2c/qemu-rh850-u2c/Kconfig 
b/boards/rh850/u2c/qemu-rh850-u2c/Kconfig
new file mode 100644
index 00000000000..5e0ece823d8
--- /dev/null
+++ b/boards/rh850/u2c/qemu-rh850-u2c/Kconfig
@@ -0,0 +1,20 @@
+#
+# For a description of the syntax of this configuration file,
+# see the file kconfig-language.txt in the NuttX tools repository.
+#
+
+
+if ARCH_BOARD_QEMU_RH850_U2C
+
+config QEMU_RH850_U2C_TEST_EXIT
+       bool "Stop QEMU on a reset with an error status"
+       default n
+       depends on BOARDCTL_RESET
+       ---help---
+               board_reset() with a non-zero status (the PANIC path with
+               BOARD_RESET_ON_ASSERT) writes the QEMU test-exit device at
+               0x40000000, so QEMU exits with that status.  Needs
+               -M rh850-u2c,test-exit=on.  Without it, and for status 0,
+               board_reset() starts a software system reset.
+
+endif
diff --git a/boards/rh850/u2c/qemu-rh850-u2c/configs/nsh/defconfig 
b/boards/rh850/u2c/qemu-rh850-u2c/configs/nsh/defconfig
new file mode 100644
index 00000000000..02a8e34eaec
--- /dev/null
+++ b/boards/rh850/u2c/qemu-rh850-u2c/configs/nsh/defconfig
@@ -0,0 +1,34 @@
+#
+# This file is autogenerated: PLEASE DO NOT EDIT IT.
+#
+# You can use "make menuconfig" to make any modifications to the installed 
.config file.
+# You can then do "make savedefconfig" to generate a new defconfig file that 
includes your
+# modifications.
+#
+CONFIG_ARCH="rh850"
+CONFIG_ARCH_BOARD="qemu-rh850-u2c"
+CONFIG_ARCH_BOARD_QEMU_RH850_U2C=y
+CONFIG_ARCH_CHIP="u2c"
+CONFIG_ARCH_CHIP_R7F702600=y
+CONFIG_ARCH_CHIP_U2C=y
+CONFIG_ARCH_INTERRUPTSTACK=2048
+CONFIG_ARCH_RH850=y
+CONFIG_BOARDCTL_RESET=y
+CONFIG_BOARD_LOOPSPERMSEC=8906
+CONFIG_BUILTIN=y
+CONFIG_DEBUG_FULLOPT=y
+CONFIG_DEBUG_SYMBOLS=y
+CONFIG_FS_PROCFS=y
+CONFIG_IDLETHREAD_STACKSIZE=2048
+CONFIG_INIT_ENTRYPOINT="nsh_main"
+CONFIG_INIT_STACKSIZE=3072
+CONFIG_LIBM=y
+CONFIG_LINE_MAX=256
+CONFIG_NSH_BUILTIN_APPS=y
+CONFIG_NSH_READLINE=y
+CONFIG_RAM_SIZE=131072
+CONFIG_RAM_START=0xfdc00000
+CONFIG_SCHED_WAITPID=y
+CONFIG_STACK_COLORATION=y
+CONFIG_SYSTEM_NSH=y
+CONFIG_UART0_SERIAL_CONSOLE=y
diff --git a/boards/rh850/u2c/qemu-rh850-u2c/include/board.h 
b/boards/rh850/u2c/qemu-rh850-u2c/include/board.h
new file mode 100644
index 00000000000..2cd5c424438
--- /dev/null
+++ b/boards/rh850/u2c/qemu-rh850-u2c/include/board.h
@@ -0,0 +1,26 @@
+/****************************************************************************
+ * boards/rh850/u2c/qemu-rh850-u2c/include/board.h
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+#ifndef __BOARDS_RH850_U2C_QEMU_RH850_U2C_INCLUDE_BOARD_H
+#define __BOARDS_RH850_U2C_QEMU_RH850_U2C_INCLUDE_BOARD_H
+
+#endif /* __BOARDS_RH850_U2C_QEMU_RH850_U2C_INCLUDE_BOARD_H */
diff --git a/boards/rh850/u2c/qemu-rh850-u2c/scripts/Make.defs 
b/boards/rh850/u2c/qemu-rh850-u2c/scripts/Make.defs
new file mode 100644
index 00000000000..9ea454f7055
--- /dev/null
+++ b/boards/rh850/u2c/qemu-rh850-u2c/scripts/Make.defs
@@ -0,0 +1,34 @@
+############################################################################
+# boards/rh850/u2c/qemu-rh850-u2c/scripts/Make.defs
+#
+# SPDX-License-Identifier: Apache-2.0
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.  The
+# ASF licenses this file to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance with the
+# License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+# License for the specific language governing permissions and limitations
+# under the License.
+#
+############################################################################
+
+include $(TOPDIR)/.config
+include $(TOPDIR)/tools/Config.mk
+include $(TOPDIR)/arch/rh850/src/common/Toolchain.defs
+
+ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)qemu-rh850-u2c.ld
+
+CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) 
$(ARCHDEFINES) $(EXTRAFLAGS)
+CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS)
+CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) 
$(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS)
+CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS)
+CPPFLAGS := $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS)
+AFLAGS += $(CFLAGS) -D__ASSEMBLY__
diff --git a/boards/rh850/u2c/qemu-rh850-u2c/scripts/qemu-rh850-u2c.ld 
b/boards/rh850/u2c/qemu-rh850-u2c/scripts/qemu-rh850-u2c.ld
new file mode 100644
index 00000000000..63c081965a5
--- /dev/null
+++ b/boards/rh850/u2c/qemu-rh850-u2c/scripts/qemu-rh850-u2c.ld
@@ -0,0 +1,125 @@
+/****************************************************************************
+ * boards/rh850/u2c/qemu-rh850-u2c/scripts/qemu-rh850-u2c.ld
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+/* GCC prefixes C symbols with "_": a symbol used by C is defined both as
+ * _name (C name) and as __name (C _name).
+ */
+
+MEMORY
+{
+  flash (rx)  : ORIGIN = 0x00000000, LENGTH = 8M
+  lram  (rwx) : ORIGIN = 0xfdc00000, LENGTH = 128K
+}
+
+OUTPUT_ARCH(v850:rh850)
+ENTRY(__start)
+
+SECTIONS
+{
+  .text :
+  {
+    _stext = ABSOLUTE(.);
+    __stext = ABSOLUTE(_stext);
+    KEEP(*(.vectors))
+    *(.text .text.*)
+    *(.gnu.linkonce.t.*)
+    _etext = ABSOLUTE(.);
+    __etext = ABSOLUTE(_etext);
+  } > flash
+
+  .rodata :
+  {
+    *(.rodata .rodata.*)
+    *(.rosdata .rosdata.*)
+    *(.rozdata .rozdata.*)
+    *(.gnu.linkonce.r.*)
+  } > flash
+
+  .init_section :
+  {
+    _sinit = ABSOLUTE(.);
+    __sinit = ABSOLUTE(_sinit);
+    KEEP(*(SORT_BY_INIT_PRIORITY(.init_array.*) 
SORT_BY_INIT_PRIORITY(.ctors.*)))
+    KEEP(*(.init_array .ctors))
+    _einit = ABSOLUTE(.);
+    __einit = ABSOLUTE(_einit);
+  } > flash
+
+  _eronly = LOADADDR(.data);
+  __eronly = ABSOLUTE(_eronly);
+
+  .data : ALIGN(4)
+  {
+    _sdata = ABSOLUTE(.);
+    __sdata = ABSOLUTE(_sdata);
+    *(.data .data.*)
+    *(.sdata .sdata.*)
+    *(.tdata .tdata.*)
+    *(.zdata .zdata.*)
+    *(.gnu.linkonce.d.*)
+    . = ALIGN(4);
+    _edata = ABSOLUTE(.);
+    __edata = ABSOLUTE(_edata);
+  } > lram AT > flash
+
+  .bss (NOLOAD) : ALIGN(4)
+  {
+    _sbss = ABSOLUTE(.);
+    __sbss = ABSOLUTE(_sbss);
+    *(.bss .bss.*)
+    *(.sbss .sbss.*)
+    *(.tbss .tbss.*)
+    *(.zbss .zbss.*)
+    *(.gnu.linkonce.b.*)
+    *(COMMON)
+    . = ALIGN(4);
+    _ebss = ABSOLUTE(.);
+    __ebss = ABSOLUTE(_ebss);
+  } > lram AT > lram
+
+  /* Idle thread stack above .bss, the heap above it.  NOLOAD sections
+   * keep LMA = VMA so that loaders do not place them in flash.
+   */
+
+  .idle_stack (NOLOAD) : ALIGN(4)
+  {
+    . += CONFIG_IDLETHREAD_STACKSIZE;
+    _g_idle_topstack = ABSOLUTE(.);
+  } > lram AT > lram
+
+  /* Stabs debugging sections */
+
+  .stab 0 : { *(.stab) }
+  .stabstr 0 : { *(.stabstr) }
+  .stab.excl 0 : { *(.stab.excl) }
+  .stab.exclstr 0 : { *(.stab.exclstr) }
+  .stab.index 0 : { *(.stab.index) }
+  .stab.indexstr 0 : { *(.stab.indexstr) }
+  .comment 0 : { *(.comment) }
+  .debug_abbrev 0 : { *(.debug_abbrev) }
+  .debug_info 0 : { *(.debug_info) }
+  .debug_line 0 : { *(.debug_line) }
+  .debug_pubnames 0 : { *(.debug_pubnames) }
+  .debug_aranges 0 : { *(.debug_aranges) }
+}
diff --git a/boards/rh850/u2c/qemu-rh850-u2c/src/CMakeLists.txt 
b/boards/rh850/u2c/qemu-rh850-u2c/src/CMakeLists.txt
new file mode 100644
index 00000000000..3ea9bbbb7ce
--- /dev/null
+++ b/boards/rh850/u2c/qemu-rh850-u2c/src/CMakeLists.txt
@@ -0,0 +1,28 @@
+# 
##############################################################################
+# boards/rh850/u2c/qemu-rh850-u2c/src/CMakeLists.txt
+#
+# SPDX-License-Identifier: Apache-2.0
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more 
contributor
+# license agreements.  See the NOTICE file distributed with this work for
+# additional information regarding copyright ownership.  The ASF licenses this
+# file to you under the Apache License, Version 2.0 (the "License"); you may 
not
+# use this file except in compliance with the License.  You may obtain a copy 
of
+# the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+# License for the specific language governing permissions and limitations under
+# the License.
+#
+# 
##############################################################################
+
+set(SRCS qemu_rh850_u2c_appinit.c qemu_rh850_u2c_boardinit.c)
+
+target_sources(board PRIVATE ${SRCS})
+
+set_property(GLOBAL PROPERTY LD_SCRIPT
+                             "${NUTTX_BOARD_DIR}/scripts/qemu-rh850-u2c.ld")
diff --git a/boards/rh850/u2c/qemu-rh850-u2c/src/Makefile 
b/boards/rh850/u2c/qemu-rh850-u2c/src/Makefile
new file mode 100644
index 00000000000..7377f53f5f3
--- /dev/null
+++ b/boards/rh850/u2c/qemu-rh850-u2c/src/Makefile
@@ -0,0 +1,27 @@
+############################################################################
+# boards/rh850/u2c/qemu-rh850-u2c/src/Makefile
+#
+# SPDX-License-Identifier: Apache-2.0
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.  The
+# ASF licenses this file to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance with the
+# License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+# License for the specific language governing permissions and limitations
+# under the License.
+#
+############################################################################
+
+include $(TOPDIR)/Make.defs
+
+CSRCS = qemu_rh850_u2c_appinit.c qemu_rh850_u2c_boardinit.c
+
+include $(TOPDIR)/boards/Board.mk
diff --git a/boards/rh850/u2c/qemu-rh850-u2c/src/qemu_rh850_u2c_appinit.c 
b/boards/rh850/u2c/qemu-rh850-u2c/src/qemu_rh850_u2c_appinit.c
new file mode 100644
index 00000000000..742b29979bb
--- /dev/null
+++ b/boards/rh850/u2c/qemu-rh850-u2c/src/qemu_rh850_u2c_appinit.c
@@ -0,0 +1,46 @@
+/****************************************************************************
+ * boards/rh850/u2c/qemu-rh850-u2c/src/qemu_rh850_u2c_appinit.c
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/types.h>
+
+#include <nuttx/board.h>
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: board_app_initialize
+ ****************************************************************************/
+
+#ifdef CONFIG_BOARDCTL
+int board_app_initialize(uintptr_t arg)
+{
+  return OK;
+}
+#endif
diff --git a/boards/rh850/u2c/qemu-rh850-u2c/src/qemu_rh850_u2c_boardinit.c 
b/boards/rh850/u2c/qemu-rh850-u2c/src/qemu_rh850_u2c_boardinit.c
new file mode 100644
index 00000000000..4efe785d9fd
--- /dev/null
+++ b/boards/rh850/u2c/qemu-rh850-u2c/src/qemu_rh850_u2c_boardinit.c
@@ -0,0 +1,135 @@
+/****************************************************************************
+ * boards/rh850/u2c/qemu-rh850-u2c/src/qemu_rh850_u2c_boardinit.c
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <syslog.h>
+
+#include <nuttx/board.h>
+#include <nuttx/fs/fs.h>
+
+#include "rh850_internal.h"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/* QEMU rh850-u2c test-exit device (machine property test-exit=on) */
+
+#define QEMU_TEST_EXIT_BASE  0x40000000
+#define QEMU_TEST_EXIT_PASS  0x5555
+#define QEMU_TEST_EXIT_FAIL  0x3333
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+#if defined(CONFIG_BOARDCTL_POWEROFF) || 
defined(CONFIG_QEMU_RH850_U2C_TEST_EXIT)
+static void qemu_test_exit(int status, uint32_t zero)
+{
+  uint32_t value = zero;
+
+  if (status != 0)
+    {
+      value = ((uint32_t)(status & 0xffff) << 16) | QEMU_TEST_EXIT_FAIL;
+    }
+
+  *(volatile uint32_t *)QEMU_TEST_EXIT_BASE = value;
+
+  for (; ; )
+    {
+    }
+}
+#endif
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: board_late_initialize
+ *
+ * Description:
+ *   Board initialization after the OS is up: mount procfs.
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_BOARD_LATE_INITIALIZE
+void board_late_initialize(void)
+{
+#ifdef CONFIG_FS_PROCFS
+  int ret;
+
+  ret = nx_mount(NULL, "/proc", "procfs", 0, NULL);
+  if (ret < 0)
+    {
+      syslog(LOG_ERR, "ERROR: Failed to mount procfs: %d\n", ret);
+    }
+#endif
+}
+#endif
+
+/****************************************************************************
+ * Name: board_power_off
+ *
+ * Description:
+ *   Stop QEMU through the test-exit device: exit code 0 for status 0, else
+ *   the status.  Without the device the write has no effect.
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_BOARDCTL_POWEROFF
+int board_power_off(int status)
+{
+  qemu_test_exit(status, QEMU_TEST_EXIT_PASS);
+  return 0;
+}
+#endif
+
+/****************************************************************************
+ * Name: board_reset
+ *
+ * Description:
+ *   Software system reset.  With QEMU_RH850_U2C_TEST_EXIT a non-zero status
+ *   (the PANIC path) stops QEMU with that exit code instead.
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_BOARDCTL_RESET
+int board_reset(int status)
+{
+#ifdef CONFIG_QEMU_RH850_U2C_TEST_EXIT
+  if (status != 0)
+    {
+      qemu_test_exit(status, QEMU_TEST_EXIT_PASS);
+    }
+#endif
+
+  up_systemreset();
+  return 0;
+}
+#endif

Reply via email to