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

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


The following commit(s) were added to refs/heads/master by this push:
     new d6bcf3ced09 boards/qemu-intel64: Add board_power_off()
d6bcf3ced09 is described below

commit d6bcf3ced092150099df5161c9aed95cd24d550a
Author: Marco Casaroli <[email protected]>
AuthorDate: Tue Nov 3 23:20:22 2026 +0100

    boards/qemu-intel64: Add board_power_off()
    
    With CONFIG_BOARDCTL_POWEROFF the link fails: boardctl() calls
    board_power_off(), which the board does not have.  x86_64 has
    up_systempoweroff() (the ACPI sleep state S5, intel64_systempoweroff.c,
    built with CONFIG_BOARDCTL_POWEROFF), and the QEMU PC machines stop when
    it is entered.
    
    Add qemu_power.c with board_power_off(), as qemu-armv8a has.
    
    Assisted-by: Claude Code:claude-opus-5-5
    Signed-off-by: Marco Casaroli <[email protected]>
---
 boards/x86_64/qemu/qemu-intel64/src/CMakeLists.txt |  4 ++
 boards/x86_64/qemu/qemu-intel64/src/Makefile       |  4 ++
 boards/x86_64/qemu/qemu-intel64/src/qemu_power.c   | 56 ++++++++++++++++++++++
 3 files changed, 64 insertions(+)

diff --git a/boards/x86_64/qemu/qemu-intel64/src/CMakeLists.txt 
b/boards/x86_64/qemu/qemu-intel64/src/CMakeLists.txt
index 3c4dbdd438d..146cef8732b 100644
--- a/boards/x86_64/qemu/qemu-intel64/src/CMakeLists.txt
+++ b/boards/x86_64/qemu/qemu-intel64/src/CMakeLists.txt
@@ -26,6 +26,10 @@ if(CONFIG_BOARDCTL_RESET)
   list(APPEND SRCS qemu_reset.c)
 endif()
 
+if(CONFIG_BOARDCTL_POWEROFF)
+  list(APPEND SRCS qemu_power.c)
+endif()
+
 if(CONFIG_BUILD_KERNEL)
   # Pack the standalone application binaries into the ROMFS image registered by
   # qemu_boardinit.c. The application targets are not known yet when this
diff --git a/boards/x86_64/qemu/qemu-intel64/src/Makefile 
b/boards/x86_64/qemu/qemu-intel64/src/Makefile
index 9d8fc57f968..658e4cf76ee 100644
--- a/boards/x86_64/qemu/qemu-intel64/src/Makefile
+++ b/boards/x86_64/qemu/qemu-intel64/src/Makefile
@@ -32,6 +32,10 @@ ifeq ($(CONFIG_BOARDCTL_RESET),y)
   CSRCS += qemu_reset.c
 endif
 
+ifeq ($(CONFIG_BOARDCTL_POWEROFF),y)
+  CSRCS += qemu_power.c
+endif
+
 ifeq ($(CONFIG_ETC_ROMFS),y)
 ifeq ($(CONFIG_SYSTEM_NXINIT),y)
   RCSRCS += etc/init.d/init.rc
diff --git a/boards/x86_64/qemu/qemu-intel64/src/qemu_power.c 
b/boards/x86_64/qemu/qemu-intel64/src/qemu_power.c
new file mode 100644
index 00000000000..2f8bb15a050
--- /dev/null
+++ b/boards/x86_64/qemu/qemu-intel64/src/qemu_power.c
@@ -0,0 +1,56 @@
+/****************************************************************************
+ * boards/x86_64/qemu/qemu-intel64/src/qemu_power.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/board.h>
+#include <nuttx/arch.h>
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: board_power_off
+ *
+ * Description:
+ *   Power off the board.  Support for this function is required by
+ *   board-level logic if CONFIG_BOARDCTL_POWEROFF is selected.  QEMU
+ *   stops when the ACPI sleep state S5 is entered (up_systempoweroff()).
+ *
+ * Input Parameters:
+ *   status - Status information provided with the power off event.
+ *
+ * Returned Value:
+ *   If this function returns, then it was not possible to power-off the
+ *   board due to some constraints.  The return value in this case is a
+ *   board-specific reason for the failure to shutdown.
+ *
+ ****************************************************************************/
+
+int board_power_off(int status)
+{
+  up_systempoweroff();
+  return 0;
+}

Reply via email to