From patchwork Tue Oct 27 18:46:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 1388882 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=gmx.de Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=gmx.net header.i=@gmx.net header.a=rsa-sha256 header.s=badeba3b8450 header.b=X/r1O9qX; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CLLL84Bpkz9sSs for ; Wed, 28 Oct 2020 05:47:44 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C082D82430; Tue, 27 Oct 2020 19:47:23 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=gmx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; secure) header.d=gmx.net header.i=@gmx.net header.b="X/r1O9qX"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6359182483; Tue, 27 Oct 2020 19:47:19 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_FROM,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id D772782361 for ; Tue, 27 Oct 2020 19:47:16 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=gmx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=xypron.glpk@gmx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1603824434; bh=VJ++wRGzt3aWI8k8u9ANVI932skibUa5hkAhzzlpNvQ=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=X/r1O9qXXJNJI1lbisZ5SQuXOd7qI/W7bfqvJ7v1xky7JKctQBw6hjOvxp2VkOUCd uOyBGrEpz8nauYdcUY1dyqpLxBNtcZi5tYpSlve7bX8gzbuvqR1B7eixJ1t0Pdx3Yw CEe8RYST4j+/PYRy7WqndCf9XbkOpCgaHt8ijNvE= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from workstation4.fritz.box ([178.202.41.107]) by mail.gmx.com (mrgmx105 [212.227.17.174]) with ESMTPSA (Nemesis) id 1MDQic-1khtqu31wk-00AWL7; Tue, 27 Oct 2020 19:47:14 +0100 From: Heinrich Schuchardt To: Simon Glass Cc: Rasmus Villemoes , u-boot@lists.denx.de, Heinrich Schuchardt Subject: [PATCH v2 1/8] sandbox: eth-raw: do not close the console input Date: Tue, 27 Oct 2020 19:46:57 +0100 Message-Id: <20201027184704.15910-2-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201027184704.15910-1-xypron.glpk@gmx.de> References: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R5DLNqZ0FZN/MobNWD6bwI+TnOD2PhEDX7XddYQAE4qh81IASKVP99rFFpkL7tdQ370TG RMX6qzGXd+o6n23J8m1lrJHuNc5siA05kTUM8NohKyM2YrMoNuRBLSLQyXBfSLkEKp7CULI7f unQaRY5jdd6CaSXwEHaw== X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.3 at phobos.denx.de X-Virus-Status: Clean When the sandbox eth-raw device host_lo is removed this leads to closing the console input. Do not call close(0). Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- v2: no change --- arch/sandbox/cpu/eth-raw-os.c | 8 ++++---- arch/sandbox/cpu/os.c | 5 ++++- 2 files changed, 8 insertions(+), 5 deletions(-) -- 2.28.0 diff --git a/arch/sandbox/cpu/eth-raw-os.c b/arch/sandbox/cpu/eth-raw-os.c index da01d1addf..6a8d809756 100644 --- a/arch/sandbox/cpu/eth-raw-os.c +++ b/arch/sandbox/cpu/eth-raw-os.c @@ -53,7 +53,7 @@ int sandbox_eth_raw_os_is_local(const char *ifname) } ret = !!(ifr.ifr_flags & IFF_LOOPBACK); out: - close(fd); + os_close(fd); return ret; } @@ -220,7 +220,7 @@ int sandbox_eth_raw_os_send(void *packet, int length, struct sockaddr_in addr; if (priv->local_bind_sd != -1) - close(priv->local_bind_sd); + os_close(priv->local_bind_sd); /* A normal UDP socket is required to bind */ priv->local_bind_sd = socket(AF_INET, SOCK_DGRAM, 0); @@ -284,11 +284,11 @@ void sandbox_eth_raw_os_stop(struct eth_sandbox_raw_priv *priv) { free(priv->device); priv->device = NULL; - close(priv->sd); + os_close(priv->sd); priv->sd = -1; if (priv->local) { if (priv->local_bind_sd != -1) - close(priv->local_bind_sd); + os_close(priv->local_bind_sd); priv->local_bind_sd = -1; priv->local_bind_udp_port = 0; } diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c index e7ec892bdf..c461fb0db0 100644 --- a/arch/sandbox/cpu/os.c +++ b/arch/sandbox/cpu/os.c @@ -86,7 +86,10 @@ int os_open(const char *pathname, int os_flags) int os_close(int fd) { - return close(fd); + /* Do not close the console input */ + if (fd) + return close(fd); + return -1; } int os_unlink(const char *pathname) From patchwork Tue Oct 27 18:46:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 1388884 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=gmx.de Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=gmx.net header.i=@gmx.net header.a=rsa-sha256 header.s=badeba3b8450 header.b=dcE5kyxf; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CLLLS6trKz9sSs for ; Wed, 28 Oct 2020 05:48:00 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id DE2C7824BB; Tue, 27 Oct 2020 19:47:25 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=gmx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; secure) header.d=gmx.net header.i=@gmx.net header.b="dcE5kyxf"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 66EC08249E; Tue, 27 Oct 2020 19:47:21 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_FROM,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 429AF823E3 for ; Tue, 27 Oct 2020 19:47:17 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=gmx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=xypron.glpk@gmx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1603824435; bh=pBlsqFS1y83FrUqBDM81vLV3yFfWL51LQBIxE11QCNk=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=dcE5kyxfRjiZNZrXjILV8L57exmrmyPa88yIizt/f/NpFtXFdN/zPu+Qx3bOSMNnn Di5mFSUHKGPA7ZUtrKaOFQ2vxluFO1+iRU+fDCLrlMg3DidUyHCDFXGOGqoT81rLn7 RF4Mo5BGlhaciVSiDvPnVmtChbhyJ2B6ySExdkts= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from workstation4.fritz.box ([178.202.41.107]) by mail.gmx.com (mrgmx105 [212.227.17.174]) with ESMTPSA (Nemesis) id 1MUGeB-1kybFx406F-00REF6; Tue, 27 Oct 2020 19:47:15 +0100 From: Heinrich Schuchardt To: Simon Glass Cc: Rasmus Villemoes , u-boot@lists.denx.de, Heinrich Schuchardt Subject: [PATCH v2 2/8] sandbox: enable poweroff command Date: Tue, 27 Oct 2020 19:46:58 +0100 Message-Id: <20201027184704.15910-3-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201027184704.15910-1-xypron.glpk@gmx.de> References: <20201027184704.15910-1-xypron.glpk@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:kbeje4nYVwPuGQC6DN0x9BUVRNBT3K0hvyLUbIGxHvUtra02481 HoekO0q8NIpslJflwoFQNn8hRSiLma60FTGV1MoufzbPecO5Npm3zWoB4htUkl+nW/2vuiU yMBgADqBUVLHh+vGHW5IFIyR14AYiEbBuCUgYCETO2jPyuBtpBKmJ+bPITHv4XOtgxfCw55 wOItEHDFdoOqZZ9YMuVNA== X-UI-Out-Filterresults: notjunk:1;V03:K0:vril/ajIXc4=:gbHCxCEe2nck9xv8EqB+LF IDR1mSVQ0FeDa7J5X5dEloLEpo4Cz/WkT8Yw2WxHA1JHB4DlOhvoqoYXmphnVRrzLPgo/LdJe dvdcj04+d/F06NnvVZTOrhTWn5Q+TfV99qQ0DmBrRoDCSyyPKP7tpLY5ZxTzaYXmZ1+Z9BKK7 gSImgkOuQNC4bk5dfIMs0ihyNoSCiiYVzgSMx+usXK3C2Cnz9pLz2wQiqCojEQZ3nUGSNDbPt u+4ZIabmi4kVYDrhqSem7jZJOAFAjsfjqWvv0vMnn0VdC+TMcxDidhtN70WpUOdsqEDJkGXeY Upqz8jGNdNLeaHyeKkQY3a/WI2M/z3VSxsW1VOs33LfLt6SFVmMVapoB33675IUv33rG5++d0 75Ldmrl2fVc03qToIAJqu52fG3lo1gd3MjGBWqDc5ZNhxPPsZdOQrWnqIBQawyTLyIDO7Q7ys 6qVzjxKPYK/FeozWIbIZ4YycIznr5kWKsgWbOwbcXoY4GuynsK/uvu5ykk/o3Cu1iT/i9xOKn ieESDMex9NmVcdEki37KZnD154ayT9bK2hm+R5eY71OJamGc9MI+f3/rUCErLg3xokTUszJfF IbzZtAFcM4fAjAwQIXvsWVnlLKQryCB2rW3YiXZ6D6oKB7VILHymAu89yzUsWIxySbkgw6OxK JBKCYrcq5fvug45SByTN6ZizbGrBn6yD8FvfkRyopLurjWcY1wbZNkfEd6kn7+wlR4hA0sE/q PC+K0ZaR6b1mF+pn6yU+xQrHEFAPcWWm6wsjQYXzPTDRo4ko7mJDRihxwm29ZheSC5htSd0nQ iRNtm6Qm/pmLBKjNf5XSNNRdsYqFA+4oAvS6VM4a69KAkv/cO8kOadkzhP0xh/HNxFSMyugBH ZYv3x7UjvQAiuTC3uNOw== X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.3 at phobos.denx.de X-Virus-Status: Clean The command to shut down a device is 'poweroff'. It is a deficit of the sandbox that it does not support resetting yet but shuts down upong seeing the 'reset' command. Once the sandbox properly supports reset we need the 'poweroff' command to leave the sandbox. Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- v2: no change --- arch/Kconfig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- 2.28.0 diff --git a/arch/Kconfig b/arch/Kconfig index 683e384319..63e9d725b7 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -87,6 +87,7 @@ config SANDBOX bool "Sandbox" select BOARD_LATE_INIT select BZIP2 + select CMD_POWEROFF select DM select DM_GPIO select DM_I2C @@ -102,7 +103,7 @@ config SANDBOX select PCI_ENDPOINT select SPI select SUPPORT_OF_CONTROL - select SYSRESET_CMD_POWEROFF if CMD_POWEROFF + select SYSRESET_CMD_POWEROFF imply BITREVERSE select BLOBLIST imply CMD_DM From patchwork Tue Oct 27 18:46:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 1388887 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=gmx.de Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=gmx.net header.i=@gmx.net header.a=rsa-sha256 header.s=badeba3b8450 header.b=axK0zI/+; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CLLLz10dCz9sSs for ; Wed, 28 Oct 2020 05:48:27 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6AE36824D4; Tue, 27 Oct 2020 19:47:28 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=gmx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; secure) header.d=gmx.net header.i=@gmx.net header.b="axK0zI/+"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E04768249C; Tue, 27 Oct 2020 19:47:21 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_FROM,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 163FB823DD for ; Tue, 27 Oct 2020 19:47:17 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=gmx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=xypron.glpk@gmx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1603824435; bh=Ri0RTP57dQDFV826HpVEv53CntQWp12ubDFnBLBgVUA=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=axK0zI/+chs/JKT99immPMjMThT+5VB+0dyTlX8uRoQQhMwUisN15qor5JZQdud4C 5FvPa3vdJ2OxVjhcRXD131tJY2kmb2fGlRhNdf+WMTcaOtwobz41mcUusOZzG4u+/y 3JoBfXnI4u/IgeJ8ULFE/1F8XxkNdQDToz24R2yQ= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from workstation4.fritz.box ([178.202.41.107]) by mail.gmx.com (mrgmx105 [212.227.17.174]) with ESMTPSA (Nemesis) id 1MD9T7-1kgWPK0mUT-0099A2; Tue, 27 Oct 2020 19:47:15 +0100 From: Heinrich Schuchardt To: Simon Glass Cc: Rasmus Villemoes , u-boot@lists.denx.de, Heinrich Schuchardt Subject: [PATCH v2 3/8] test/py: test poweroff Date: Tue, 27 Oct 2020 19:46:59 +0100 Message-Id: <20201027184704.15910-4-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201027184704.15910-1-xypron.glpk@gmx.de> References: <20201027184704.15910-1-xypron.glpk@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:E7Jc7preHmPqHmwm0+1Dr+sMQAyCqv/DIKZbWrFrBodynvF+N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7BiVrkirYl4nXFO7igfBgQmlOIhKnMrx7Pw N0PDBZ6Blj3XYTb3/Rgw== X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.3 at phobos.denx.de X-Virus-Status: Clean It is the 'poweroff' and not the 'reset' command that should shut down the sandbox. Adjust the unit test accordingly Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- v2: no change --- test/py/tests/test_sandbox_exit.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) -- 2.28.0 diff --git a/test/py/tests/test_sandbox_exit.py b/test/py/tests/test_sandbox_exit.py index a301f4b559..2d242ae0f6 100644 --- a/test/py/tests/test_sandbox_exit.py +++ b/test/py/tests/test_sandbox_exit.py @@ -6,11 +6,11 @@ import pytest import signal @pytest.mark.boardspec('sandbox') -@pytest.mark.buildconfigspec('sysreset') -def test_reset(u_boot_console): - """Test that the "reset" command exits sandbox process.""" +@pytest.mark.buildconfigspec('sysreset_cmd_poweroff') +def test_poweroff(u_boot_console): + """Test that the "poweroff" command exits sandbox process.""" - u_boot_console.run_command('reset', wait_for_prompt=False) + u_boot_console.run_command('poweroff', wait_for_prompt=False) assert(u_boot_console.validate_exited()) @pytest.mark.boardspec('sandbox') From patchwork Tue Oct 27 18:47:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 1388883 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=gmx.de Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=gmx.net header.i=@gmx.net header.a=rsa-sha256 header.s=badeba3b8450 header.b=iIFNvYBb; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CLLLF2kz7z9sV0 for ; Wed, 28 Oct 2020 05:47:49 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id CD022824A4; Tue, 27 Oct 2020 19:47:24 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=gmx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; secure) header.d=gmx.net header.i=@gmx.net header.b="iIFNvYBb"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4C9FE824A7; Tue, 27 Oct 2020 19:47:21 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_FROM,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 9EC2E823F4 for ; Tue, 27 Oct 2020 19:47:17 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=gmx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=xypron.glpk@gmx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1603824435; bh=OO/4eaKygKoBDlaTNqGojfV5WnFM6VKZUYLRJkbPf+I=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=iIFNvYBbk+62BPqsqKu7H0XQktMcPIQlmQg/aQ+2ZqpMqUqjO+5H+fV8eVquIeZhI aKuA5W94+jYmpeiGnGRth2MjWyOLhlFT+dGIDXZmny5TLdlA8kgj3zcF2M9CzBPXzH nK/PVY8wdgHhRkHFT+sA5mXmNBuOL8aQwYRe1e4Q= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from workstation4.fritz.box ([178.202.41.107]) by mail.gmx.com (mrgmx105 [212.227.17.174]) with ESMTPSA (Nemesis) id 1MN5eX-1kqOKU1nV7-00J0W6; Tue, 27 Oct 2020 19:47:15 +0100 From: Heinrich Schuchardt To: Simon Glass Cc: Rasmus Villemoes , u-boot@lists.denx.de, Heinrich Schuchardt Subject: [PATCH v2 4/8] sandbox: use O_CLOEXEC in os_open() Date: Tue, 27 Oct 2020 19:47:00 +0100 Message-Id: <20201027184704.15910-5-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201027184704.15910-1-xypron.glpk@gmx.de> References: <20201027184704.15910-1-xypron.glpk@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:sO1AIXzDFX4wb9bheXfDCQmXgEavXcR/s9t8+W3zXIVZ2T8fouu Ua/vLPteH/Wc9TcpkAXv61eQismhQci1bHitNtkHkjC+y5Yo2rB/HmQUK7qe4cJ92zTvRYY MkWEuTVUVAxJs3F/6FakQTnpj6L+sqnN/IAdBJ41qjprwu5+UEWclQEGX4OoUMnS4yvr9ZB hp35kkFeXvyWCkx0GMK1Q== X-UI-Out-Filterresults: notjunk:1;V03:K0:npNWgUqhm8g=:dD1RPj6/uEI5Rav16FAe74 dxWv5iWYPWxRkViD+Hj2qO6fhwiAEBF3N8w/OmpuScsv38F4Cof+E2bVmN2lCRJ4PSS32lmKB koN5toypor7iKUV3hDgHGrmBg3iB/uDEbkQN8LSF20oaLP8I/sJe2yhirTvNBK0+iqyHlotRM MehqpKhqxvpW2poReJeNExID4xt5KNpb1oI+2uFWDIczqkbM7e0LdBfGUH+cfFK2gW11QSKpo 8i9deU16L176u+h3DjGjEMu/gpI/gCBjQFWXVVc6WVcGjhrqeQMMqxZkkkPTB974MslYr2DEV 7XHuP6EAonHy6yVvkZM/x50W/wwH1iv3UZXUuM9n4BQU1FFxuU55pFtHD9RsrQ/2J/7seID3F vFET7KB8NbaHwj3A3I7IM10iZq/oHanu3/VlHKMMv+Vnj1G1llWogJFHDBvTD5f1ejfGCxN+M g4B4zoqvIirFz0tWUTa5SNaUUx0cRRfA+s44FC2Fg2ZYEvtGs6IrhI6MOJw1U7y6GA3vQhzwR E2N06j1fxbKZcrDSwfkurPlxuERJuaLltV2Szcrye8Xk/ky7IELYyT89CZ9hlU/FGg13oPeTK Rf2DAKS0yxCS/trMtKVOg7pEjMTKntgls8VSO9wV/Q2Xv6fxctDDHU4j0LZOCByZievitdwSE 58qRxg/k1k61Cm34BYSFyr/Rm5Pc/Nom+afxIA2vbt+IiuR6L1q9gb9Sd87mSV1IgoFWqNkeX W3lA/SAvbe5OwXOBDbv25vEixRu3uPELUAYTe3OnsF02cbbhMwimCOSvpQoHFAMwISdidj4GX DZFbn7pgKrpHBuG92/c6ezmF4ti8J6EecNyFWqQSBGxiYBFXo9iPpVxlQUsmlWJFae9FG4z/D OdCg9l3xlHgLGBU0a93w== X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.3 at phobos.denx.de X-Virus-Status: Clean During a cold reset execv() is used to relaunch the U-Boot binary. We must ensure that all files are closed in this case. Signed-off-by: Heinrich Schuchardt --- v2: new patch --- arch/sandbox/cpu/os.c | 5 +++++ 1 file changed, 5 insertions(+) -- 2.28.0 diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c index c461fb0db0..7e474d6364 100644 --- a/arch/sandbox/cpu/os.c +++ b/arch/sandbox/cpu/os.c @@ -80,6 +80,11 @@ int os_open(const char *pathname, int os_flags) flags |= O_CREAT; if (os_flags & OS_O_TRUNC) flags |= O_TRUNC; + /* + * During a cold reset execv() is used to relaunch the U-Boot binary. + * We must ensure that all files are closed in this case. + */ + flags |= O_CLOEXEC; return open(pathname, flags, 0777); } From patchwork Tue Oct 27 18:47:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 1388891 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=gmx.de Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=gmx.net header.i=@gmx.net header.a=rsa-sha256 header.s=badeba3b8450 header.b=MYz7hIgg; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CLLMb2c6Dz9sSf for ; Wed, 28 Oct 2020 05:48:59 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 33219824FC; Tue, 27 Oct 2020 19:47:39 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=gmx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; secure) header.d=gmx.net header.i=@gmx.net header.b="MYz7hIgg"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E45DE823E3; Tue, 27 Oct 2020 19:47:23 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_FROM,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 5C86582496 for ; Tue, 27 Oct 2020 19:47:18 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=gmx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=xypron.glpk@gmx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1603824435; bh=lWTJ1nhoS03MCsq2/cE4VRU1V3GL4BqJfMZlM63UxyQ=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=MYz7hIggO+vFfJRSAw3wuzCKoT4WeU9QfvslF4K4yo9ihrri76TIhuhiHwunxPH2m KaJ9AyT1KJdze5Fcya2+PLnI8wD0+w2BOQ5Rk8b9Sgv1EoQpNQ7+lMX7i4eMSpQxVW C2DkSwC6K6H24yfvV3uBgL8AnTAS6GN3NavUKGWs= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from workstation4.fritz.box ([178.202.41.107]) by mail.gmx.com (mrgmx105 [212.227.17.174]) with ESMTPSA (Nemesis) id 1MoO6C-1k0b512obA-00oplr; Tue, 27 Oct 2020 19:47:15 +0100 From: Heinrich Schuchardt To: Simon Glass Cc: Rasmus Villemoes , u-boot@lists.denx.de, Heinrich Schuchardt Subject: [PATCH v2 5/8] sandbox: implement reset Date: Tue, 27 Oct 2020 19:47:01 +0100 Message-Id: <20201027184704.15910-6-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201027184704.15910-1-xypron.glpk@gmx.de> References: <20201027184704.15910-1-xypron.glpk@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:mCGgnxYcvBYT6uqB+bIQnl98WZR3TLYQZxhHvjGUtCJ4ku7nsEm DYNE8Znp9mpSD1pdoi0CluNkfikJ1pul12suMa/vIz4vsl7a3odKbSvDMGiwp/uyNBkVVB5 Xe+lrSGip8HjQpMZ06dTN2tjKoTvsrIhZtoFafs05/0Bri89N/JvSNJitmZIRa/ARQdAWNY Etlq0BpJCe3xz+KZ01mLQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:d9s/ZICzoHs=:Kqrs6vORia464k6jGvOokP hTm5bUDFB506KVloPpCQ5TbuBM3fClr+76JDLkZ0HNCRot+cHxUXXfzwNKkeb84Kaht8cQzfr oppcDDJKdUSaTVF5u033xJCgVMsOQpXnwbOaUT9RCyK/1zrdctxt2vDDFUBHIWmAdIw2CWY5m +r6ntqh1zy5SYu8fihMC2TRxO0rkPZZyxNZHf6Yn45D7g5q2lxfxn7A0t71l0zJIbf2NPBgVJ kmegmjXGBcm1XiODUsH8n4iAig+O/L0fAfPU6ck3HRqsDdhhNOQyTuAmRsrhJtryLvj5RGC6N k6ocXm+B98sB/ekl3tPeIg+Z6LDAd7XFFeNf2sNHSxu+ios7h72xyYOeb/oPFufcO9O6LL1yc MwXen1sZluV3DDEp9iWxjHlCktToGruwuw3XLH4117cLjgxdh4cQJ2Sb7GoJsmqs1XJa8Buiu eNp4/iagatkQPQIph7LRXB304Kd7QjMfU+bmO6QEilxfTK1BXhuLSS04fG0/2gkivJdGvzILz i9VD3FzCrQmuh+G1peQGwcS7jWPIAk6zmKWLzoV1w3fey0otWWOeCxsJIE+NKdXEPDE6ZX77U BEQHd0VAvR6Ma/I8P1JgK0I7MyUx15iIlt6z1NR9esfihsQRvFKy7dGb8NYJDQmKf11XFjtWB 4lF0+d2DTBSkbaJBKq0Tv6GTLLEH4MERmh0rHZuwqum5F0kSqGqR1jTakozAhfxRPgt/H1yZp 0wz0o+aBXDkc+v6gMY4xgQ3HDxwWplUQV5t7ziYYEHqYXeU+7Nu7jIZHKZSFhbONbbnrqpJh4 O2iC92opZF2jefl/M2ZgLC+4ONWm9rHS1wbwKGZ0i7DFZicrNCNRFxwc7nPnffBPU41qqm2BS Fo5/Qwrg8zSfaJ02eUXg== X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.3 at phobos.denx.de X-Virus-Status: Clean Up to now the sandbox would shutdown upon a cold reset request. Instead it should be reset. In our coding we use static variables like LIST_HEAD(efi_obj_list). A reset can occur at any time, e.g. via an UEFI binary calling the reset service. The only safe way to return to an initial state is to relaunch the U-Boot binary. The reset implementation uses a longjmp() to return to the main() function and then relaunches U-Boot using execv(). Signed-off-by: Heinrich Schuchardt --- v2: avoid longjmp() add more comments --- arch/sandbox/cpu/os.c | 6 ++++++ arch/sandbox/cpu/start.c | 26 +++++++++++++++++++++++ arch/sandbox/cpu/state.c | 1 + arch/sandbox/include/asm/u-boot-sandbox.h | 10 +++++++++ drivers/sysreset/sysreset_sandbox.c | 3 +++ include/os.h | 15 +++++++++++++ 6 files changed, 61 insertions(+) -- 2.28.0 diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c index 7e474d6364..0d8efd83f6 100644 --- a/arch/sandbox/cpu/os.c +++ b/arch/sandbox/cpu/os.c @@ -822,3 +822,9 @@ void *os_find_text_base(void) return base; } + +void os_relaunch(char *argv[]) +{ + execv(argv[0], argv); + os_exit(1); +} diff --git a/arch/sandbox/cpu/start.c b/arch/sandbox/cpu/start.c index c6a2bbe468..cc47b28d1d 100644 --- a/arch/sandbox/cpu/start.c +++ b/arch/sandbox/cpu/start.c @@ -5,6 +5,7 @@ #include #include +#include #include #include #include @@ -19,6 +20,8 @@ DECLARE_GLOBAL_DATA_PTR; +static char **os_argv; + /* Compare two options so that they can be sorted into alphabetical order */ static int h_compare_opt(const void *p1, const void *p2) { @@ -394,12 +397,35 @@ void state_show(struct sandbox_state *state) printf("\n"); } +void sandbox_reset(void) +{ + /* Do this here while it still has an effect */ + os_fd_restore(); + if (state_uninit()) + os_exit(2); + + if (dm_uninit()) + os_exit(2); + + /* Restart U-Boot */ + os_relaunch(os_argv); +} + int main(int argc, char *argv[]) { struct sandbox_state *state; gd_t data; int ret; + /* + * Copy argv[] so that we can pass the arguments in the original + * sequence when resetting the sandbox. + */ + os_argv = calloc(argc + 1, sizeof(char *)); + if (!os_argv) + os_exit(1); + memcpy(os_argv, argv, sizeof(char *) * (argc + 1)); + memset(&data, '\0', sizeof(data)); gd = &data; gd->arch.text_base = os_find_text_base(); diff --git a/arch/sandbox/cpu/state.c b/arch/sandbox/cpu/state.c index 34b6fff7e7..59f37fab0b 100644 --- a/arch/sandbox/cpu/state.c +++ b/arch/sandbox/cpu/state.c @@ -358,6 +358,7 @@ void state_reset_for_test(struct sandbox_state *state) /* No reset yet, so mark it as such. Always allow power reset */ state->last_sysreset = SYSRESET_COUNT; state->sysreset_allowed[SYSRESET_POWER_OFF] = true; + state->sysreset_allowed[SYSRESET_COLD] = true; state->allow_memio = false; memset(&state->wdt, '\0', sizeof(state->wdt)); diff --git a/arch/sandbox/include/asm/u-boot-sandbox.h b/arch/sandbox/include/asm/u-boot-sandbox.h index 798d003077..73b1897191 100644 --- a/arch/sandbox/include/asm/u-boot-sandbox.h +++ b/arch/sandbox/include/asm/u-boot-sandbox.h @@ -84,6 +84,16 @@ void sandbox_set_enable_pci_map(int enable); */ int sandbox_read_fdt_from_file(void); +/** + * sandbox_reset() - reset sandbox + * + * This functions implements the cold reboot of the sandbox. It relaunches the + * U-Boot binary with the same command line parameters as the original call. + * The PID of the process stays the same. All file descriptors that have not + * been opened with O_CLOEXEC stay open including stdin, stdout, stderr. + */ +void sandbox_reset(void); + /* Exit sandbox (quit U-Boot) */ void sandbox_exit(void); diff --git a/drivers/sysreset/sysreset_sandbox.c b/drivers/sysreset/sysreset_sandbox.c index 69c22a7000..c92132798c 100644 --- a/drivers/sysreset/sysreset_sandbox.c +++ b/drivers/sysreset/sysreset_sandbox.c @@ -56,6 +56,9 @@ static int sandbox_sysreset_request(struct udevice *dev, enum sysreset_t type) switch (type) { case SYSRESET_COLD: state->last_sysreset = type; + if (!state->sysreset_allowed[type]) + return -EACCES; + sandbox_reset(); break; case SYSRESET_POWER_OFF: state->last_sysreset = type; diff --git a/include/os.h b/include/os.h index 1874ae674f..88dfb71c1a 100644 --- a/include/os.h +++ b/include/os.h @@ -355,4 +355,19 @@ int os_read_file(const char *name, void **bufp, int *sizep); */ void *os_find_text_base(void); +/** + * os_relaunch() - restart the sandbox + * + * This functions is used to implement the cold reboot of the sand box. + * @argv[0] specifies the binary that is started while the calling process + * stops immediately. If the new binary cannot be started, the process is + * terminated and 1 is set as shell return code. + * + * The PID of the process stays the same. All file descriptors that have not + * been opened with O_CLOEXEC stay open including stdin, stdout, stderr. + * + * @argv: NULL terminated list of command line parameters + */ +void os_relaunch(char *argv[]); + #endif From patchwork Tue Oct 27 18:47:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 1388890 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=gmx.de Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=gmx.net header.i=@gmx.net header.a=rsa-sha256 header.s=badeba3b8450 header.b=T717JrUf; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CLLMN4tZMz9sSf for ; Wed, 28 Oct 2020 05:48:48 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 468A0824F1; Tue, 27 Oct 2020 19:47:38 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=gmx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; secure) header.d=gmx.net header.i=@gmx.net header.b="T717JrUf"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D398E8249C; Tue, 27 Oct 2020 19:47:23 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_FROM,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, T_FILL_THIS_FORM_SHORT,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 455A58247D for ; Tue, 27 Oct 2020 19:47:18 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=gmx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=xypron.glpk@gmx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1603824436; bh=QDiH2/Dje7M0p71mZ116prXXtCq8fBunE158PePmdfA=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=T717JrUf7KUUzvbr9WmSNOavjTSljJfgieYao0kpna3KrKpLfhvCySGEuQEMWKtNb smcVHDigo0BLQkbFiOnXfxChjaJdcejmK6uQbR8MrCKVfdTPxU+BZwq2JyKyUtCzCA Xa9VLKCyGHGbkRR4BkrHnuuEPVA5XI2MIddNxJKQ= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from workstation4.fritz.box ([178.202.41.107]) by mail.gmx.com (mrgmx105 [212.227.17.174]) with ESMTPSA (Nemesis) id 1McY8T-1jxaow3sFh-00d1PC; Tue, 27 Oct 2020 19:47:16 +0100 From: Heinrich Schuchardt To: Simon Glass Cc: Rasmus Villemoes , u-boot@lists.denx.de, Heinrich Schuchardt Subject: [PATCH v2 6/8] test: adjust sysreset tests Date: Tue, 27 Oct 2020 19:47:02 +0100 Message-Id: <20201027184704.15910-7-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201027184704.15910-1-xypron.glpk@gmx.de> References: <20201027184704.15910-1-xypron.glpk@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:l0NkhvS3eVVeYXddYzeN5S1tmpmj4DhiK8ekBlExyI6Bc6efcxk N3oGSNqd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V9LjNW/LqRUnC0fi2agaNSQM nfpQlwp6rgkL8mxB1wLw== X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.3 at phobos.denx.de X-Virus-Status: Clean As we have a working COLD_RESET on the sandbox the sysreset test has to be adjusted. Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- v2: no change --- test/dm/sysreset.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) -- 2.28.0 diff --git a/test/dm/sysreset.c b/test/dm/sysreset.c index aec97b1cbb..691683c567 100644 --- a/test/dm/sysreset.c +++ b/test/dm/sysreset.c @@ -37,7 +37,9 @@ static int dm_test_sysreset_base(struct unit_test_state *uts) /* Device 2 is the cold sysreset device */ ut_assertok(uclass_get_device(UCLASS_SYSRESET, 2, &dev)); ut_asserteq(-ENOSYS, sysreset_request(dev, SYSRESET_WARM)); + state->sysreset_allowed[SYSRESET_COLD] = false; ut_asserteq(-EACCES, sysreset_request(dev, SYSRESET_COLD)); + state->sysreset_allowed[SYSRESET_COLD] = true; state->sysreset_allowed[SYSRESET_POWER] = false; ut_asserteq(-EACCES, sysreset_request(dev, SYSRESET_POWER)); state->sysreset_allowed[SYSRESET_POWER] = true; @@ -71,22 +73,25 @@ static int dm_test_sysreset_walk(struct unit_test_state *uts) struct sandbox_state *state = state_get_current(); /* If we generate a power sysreset, we will exit sandbox! */ + state->sysreset_allowed[SYSRESET_WARM] = false; + state->sysreset_allowed[SYSRESET_COLD] = false; state->sysreset_allowed[SYSRESET_POWER] = false; state->sysreset_allowed[SYSRESET_POWER_OFF] = false; ut_asserteq(-EACCES, sysreset_walk(SYSRESET_WARM)); ut_asserteq(-EACCES, sysreset_walk(SYSRESET_COLD)); ut_asserteq(-EACCES, sysreset_walk(SYSRESET_POWER)); + ut_asserteq(-EACCES, sysreset_walk(SYSRESET_POWER_OFF)); /* * Enable cold system reset - this should make cold system reset work, * plus a warm system reset should be promoted to cold, since this is * the next step along. */ - state->sysreset_allowed[SYSRESET_COLD] = true; + state->sysreset_allowed[SYSRESET_WARM] = true; ut_asserteq(-EINPROGRESS, sysreset_walk(SYSRESET_WARM)); - ut_asserteq(-EINPROGRESS, sysreset_walk(SYSRESET_COLD)); + ut_asserteq(-EACCES, sysreset_walk(SYSRESET_COLD)); ut_asserteq(-EACCES, sysreset_walk(SYSRESET_POWER)); - state->sysreset_allowed[SYSRESET_COLD] = false; + state->sysreset_allowed[SYSRESET_COLD] = true; state->sysreset_allowed[SYSRESET_POWER] = true; return 0; From patchwork Tue Oct 27 18:47:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 1388888 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=gmx.de Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=gmx.net header.i=@gmx.net header.a=rsa-sha256 header.s=badeba3b8450 header.b=cWaXeimb; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CLLM949lbz9sSs for ; Wed, 28 Oct 2020 05:48:37 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 400D9824E0; Tue, 27 Oct 2020 19:47:29 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=gmx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; secure) header.d=gmx.net header.i=@gmx.net header.b="cWaXeimb"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3CF43823E3; Tue, 27 Oct 2020 19:47:22 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_FROM,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id C95E482430 for ; Tue, 27 Oct 2020 19:47:17 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=gmx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=xypron.glpk@gmx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1603824436; bh=tCXmq1JyZL8+uWr1MIBEePO++JuNPk/caiyaRd3gn4k=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=cWaXeimbBHw3Ze64SffyYjUOsZZn6KzhQlvqHwmji5M65CD11zeXguFVM1tFeiuUk ENCrKNMYv77Tip8VVb/zqLtIN7KIpt7ChEnTU4fAyhQprkVJGqfWxm9dmgZVbhRDjC r7X7VAE/QCxo8i7ZAGbhjwoe77bmekiwH4a39Nao= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from workstation4.fritz.box ([178.202.41.107]) by mail.gmx.com (mrgmx105 [212.227.17.174]) with ESMTPSA (Nemesis) id 1Mqs0X-1k34z70qzR-00mtpa; Tue, 27 Oct 2020 19:47:16 +0100 From: Heinrich Schuchardt To: Simon Glass Cc: Rasmus Villemoes , u-boot@lists.denx.de, Heinrich Schuchardt Subject: [PATCH v2 7/8] sandbox: update function descriptions in os.h Date: Tue, 27 Oct 2020 19:47:03 +0100 Message-Id: <20201027184704.15910-8-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201027184704.15910-1-xypron.glpk@gmx.de> References: <20201027184704.15910-1-xypron.glpk@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:Q9h56AKSgYdROAYm9bJKNV3q+QvI4bngKv9h/S4OwmlUzCZH9p+ o0fbLMzXBwrVpiaT5ktVm5vwIYhExH1Br67kasb2pggbv0/HG5fw/OVHGcSwm7fd9o+1L98 3CJMnrjtKpastrwmAP30xxEI5YtENKGOO5hrHoJ6QjqiJPzJAs5AKJIl/MRiaeEvCGLJg5/ oMm6wjGFDbxHyX7rpkwmQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:UfZASHO8yps=:uGuWo8ki+CyWGZfFHKfwJ7 4Og0S/q64kZI1Skm18DE6iUzwwXyAyQjz3Y7brPwPYbFSHRSuGL+YzZrh9sUEvJ+yDS33Ihuw 3JUSEPtnj5lAHPeHrsWzssMOzr3qhVWgu11NBEjSXZCSsYnG4h/X8zuofeyIb2560GztbF05A a58twI1AgxwO7zHSQVRqZDVRHBG4biLUGa4/RN70gEqRM7EOPe/ohxd0XUnz4HLoUe33kM7Rv DPl58i7mHzFV4KtV2Kwr827+GxUR0+qkGBx2sMByhkwtZhm1TXbBIyTP3FplAAbIT50fe6QcY PjjWCsfnlehhG1QKdGjzlaYOAT7iZ++RKarPfzanbhey7bWDN8AO7FwkOZ/ojoaUmvqy7Fi0l TqTaX4vATd36R3OjgwRgMzlXea5KKhiLBvxaUQnsc9pcBfpLnGWk4GqJe7S+yJ9dqVOwIGeRN 1jm6jcuhQ7WFNR0Y8kN9ktkKDUgLAprlHpQ5Z/f2R85k2wkw31MO/xs/I1GyI3tooG67cyaX7 ViTVf6OL3+93krUUygMmUZO51oXDaOMpwPqMfq0pn75YwyZHHZWQ5cpXrrJyzvRpFA6hPH2Zs qRxKK/SfxFlsZHjhuokUW+bgiOS8/2AK4/e4uOGB130ZhWgYostLYPaRZl8STMYu+sbMFjGtM bQJTPBTSIYHr1+0UG5L6KbKFyYIDucdLzrSwZo1n9V3bHFwsYlJdVA+xJ+4EQcRWAgWWDW1JN BBE3k8RfvYNFtLzcyZAJxi/u2OJma+a0tph2qFMGo5FRdvWNV0fQFae13gU/AHJT4Ql98F0RI R617nteJEdWDuAsPD+XPySCNMhxtljLr2fM/zGPQIibHwMuKGf5XCVCum9uyYhkpGJJ+bQPza sR/j9xYXlUVof6kyVn2w== X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.3 at phobos.denx.de X-Virus-Status: Clean Use Sphinx style function descriptions. Signed-off-by: Heinrich Schuchardt --- v2: new patch --- include/os.h | 223 ++++++++++++++++++++++++++++++--------------------- 1 file changed, 130 insertions(+), 93 deletions(-) -- 2.28.0 diff --git a/include/os.h b/include/os.h index 88dfb71c1a..1fe44f3510 100644 --- a/include/os.h +++ b/include/os.h @@ -19,30 +19,30 @@ struct sandbox_state; /** * Access to the OS read() system call * - * \param fd File descriptor as returned by os_open() - * \param buf Buffer to place data - * \param count Number of bytes to read - * \return number of bytes read, or -1 on error + * @fd: File descriptor as returned by os_open() + * @buf: Buffer to place data + * @count: Number of bytes to read + * Return: number of bytes read, or -1 on error */ ssize_t os_read(int fd, void *buf, size_t count); /** * Access to the OS write() system call * - * \param fd File descriptor as returned by os_open() - * \param buf Buffer containing data to write - * \param count Number of bytes to write - * \return number of bytes written, or -1 on error + * @fd: File descriptor as returned by os_open() + * @buf: Buffer containing data to write + * @count: Number of bytes to write + * Return: number of bytes written, or -1 on error */ ssize_t os_write(int fd, const void *buf, size_t count); /** * Access to the OS lseek() system call * - * \param fd File descriptor as returned by os_open() - * \param offset File offset (based on whence) - * \param whence Position offset is relative to (see below) - * \return new file offset + * @fd: File descriptor as returned by os_open() + * @offset: File offset (based on whence) + * @whence: Position offset is relative to (see below) + * Return: new file offset */ off_t os_lseek(int fd, off_t offset, int whence); @@ -54,9 +54,9 @@ off_t os_lseek(int fd, off_t offset, int whence); /** * Access to the OS open() system call * - * \param pathname Pathname of file to open - * \param flags Flags, like OS_O_RDONLY, OS_O_RDWR - * \return file descriptor, or -1 on error + * @pathname: Pathname of file to open + * @flags: Flags, like OS_O_RDONLY, OS_O_RDWR + * Return: file descriptor, or -1 on error */ int os_open(const char *pathname, int flags); @@ -68,42 +68,42 @@ int os_open(const char *pathname, int flags); #define OS_O_TRUNC 01000 /** - * Access to the OS close() system call + * os_close() - access to the OS close() system call * - * \param fd File descriptor to close - * \return 0 on success, -1 on error + * @fd: File descriptor to close + * Return: 0 on success, -1 on error */ int os_close(int fd); /** - * Access to the OS unlink() system call + * os_unlink() - access to the OS unlink() system call * - * \param pathname Path of file to delete - * \return 0 for success, other for error + * @pathname: Path of file to delete + * Return: 0 for success, other for error */ int os_unlink(const char *pathname); /** - * Access to the OS exit() system call + * os_exit() - access to the OS exit() system call * * This exits with the supplied return code, which should be 0 to indicate * success. * - * @param exit_code exit code for U-Boot + * @exit_code: exit code for U-Boot */ void os_exit(int exit_code) __attribute__((noreturn)); /** - * Put tty into raw mode to mimic serial console better + * os_tty_raw() - put tty into raw mode to mimic serial console better * - * @param fd File descriptor of stdin (normally 0) - * @param allow_sigs Allow Ctrl-C, Ctrl-Z to generate signals rather than - * be handled by U-Boot + * @fd: File descriptor of stdin (normally 0) + * @allow_sigs: Allow Ctrl-C, Ctrl-Z to generate signals rather than + * be handled by U-Boot */ void os_tty_raw(int fd, bool allow_sigs); /** - * Restore the tty to its original mode + * os_fs_restore() - restore the tty to its original mode * * Call this to restore the original terminal mode, after it has been changed * by os_tty_raw(). This is an internal function. @@ -111,144 +111,180 @@ void os_tty_raw(int fd, bool allow_sigs); void os_fd_restore(void); /** - * Acquires some memory from the underlying os. + * os_malloc() - aquires some memory from the underlying os. * - * \param length Number of bytes to be allocated - * \return Pointer to length bytes or NULL on error + * @length: Number of bytes to be allocated + * Return: Pointer to length bytes or NULL on error */ void *os_malloc(size_t length); /** - * Free memory previous allocated with os_malloc() + * os_free() - free memory previous allocated with os_malloc() * * This returns the memory to the OS. * - * \param ptr Pointer to memory block to free + * @ptr: Pointer to memory block to free */ void os_free(void *ptr); /** - * Access to the usleep function of the os + * os_usleep() - access to the usleep function of the os * - * \param usec Time to sleep in micro seconds + * @usec: time to sleep in micro seconds */ void os_usleep(unsigned long usec); /** * Gets a monotonic increasing number of nano seconds from the OS * - * \return A monotonic increasing time scaled in nano seconds + * Return: a monotonic increasing time scaled in nano seconds */ uint64_t os_get_nsec(void); /** * Parse arguments and update sandbox state. * - * @param state Sandbox state to update - * @param argc Argument count - * @param argv Argument vector - * @return 0 if ok, and program should continue; - * 1 if ok, but program should stop; - * -1 on error: program should terminate. + * @state: sandbox state to update + * @argc: argument count + * @argv: argument vector + * Return: + * * 0 if ok, and program should continue + * * 1 if ok, but program should stop + * * -1 on error: program should terminate */ int os_parse_args(struct sandbox_state *state, int argc, char *argv[]); /* + * enum os_dirent_t - type of directory entry + * * Types of directory entry that we support. See also os_dirent_typename in * the C file. */ enum os_dirent_t { - OS_FILET_REG, /* Regular file */ - OS_FILET_LNK, /* Symbolic link */ - OS_FILET_DIR, /* Directory */ - OS_FILET_UNKNOWN, /* Something else */ - + /** + * @OS_FILET_REG: regular file + */ + OS_FILET_REG, + /** + * @OS_FILET_LNK: symbolic link + */ + OS_FILET_LNK, + /** + * @OS_FILET_DIR: directory + */ + OS_FILET_DIR, + /** + * @OS_FILET_UNKNOWN: something else + */ + OS_FILET_UNKNOWN, + /** + * @OS_FILET_COUNT: number of directory entry types + */ OS_FILET_COUNT, }; -/** A directory entry node, containing information about a single dirent */ +/** + * struct os_dirent_node - directory node + * + * A directory entry node, containing information about a single dirent + * + */ struct os_dirent_node { - struct os_dirent_node *next; /* Pointer to next node, or NULL */ - ulong size; /* Size of file in bytes */ - enum os_dirent_t type; /* Type of entry */ - char name[0]; /* Name of entry */ + /** + * @next: pointer to next node, or NULL + */ + struct os_dirent_node *next; + /** + * @size: size of file in bytes + */ + ulong size; + /** + * @type: type of entry + */ + enum os_dirent_t type; + /** + * @name: name of entry + */ + char name[0]; }; /** - * Get a directionry listing + * os_dirent_ls() - get a directory listing * * This allocates and returns a linked list containing the directory listing. * - * @param dirname Directory to examine - * @param headp Returns pointer to head of linked list, or NULL if none - * @return 0 if ok, -ve on error + * @dirname: directory to examine + * @headp: on return pointer to head of linked list, or NULL if none + * Return: 0 if ok, -ve on error */ int os_dirent_ls(const char *dirname, struct os_dirent_node **headp); /** - * Free directory list + * os_dirent_free() - free directory list * * This frees a linked list containing a directory listing. * - * @param node Pointer to head of linked list + * @node: pointer to head of linked list */ void os_dirent_free(struct os_dirent_node *node); /** - * Get the name of a directory entry type + * os_dirent_get_typename() - get the name of a directory entry type * - * @param type Type to check - * @return string containing the name of that type, or "???" if none/invalid + * @type: type to check + * Return: + * string containing the name of that type, + * or "???" if none/invalid */ const char *os_dirent_get_typename(enum os_dirent_t type); /** - * Get the size of a file + * os_get_filesize() - get the size of a file * - * @param fname Filename to check - * @param size size of file is returned if no error - * @return 0 on success or -1 if an error ocurred + * @fname: filename to check + * @size: size of file is returned if no error + * Return: 0 on success or -1 if an error ocurred */ int os_get_filesize(const char *fname, loff_t *size); /** - * Write a character to the controlling OS terminal + * os_putc() - write a character to the controlling OS terminal * * This bypasses the U-Boot console support and writes directly to the OS * stdout file descriptor. * - * @param ch Character to write + * @ch: haracter to write */ void os_putc(int ch); /** - * Write a string to the controlling OS terminal + * os_puts() - write a string to the controlling OS terminal * * This bypasses the U-Boot console support and writes directly to the OS * stdout file descriptor. * - * @param str String to write (note that \n is not appended) + * @str: string to write (note that \n is not appended) */ void os_puts(const char *str); /** - * Write the sandbox RAM buffer to a existing file + * os_write_ram_buf() - write the sandbox RAM buffer to a existing file * - * @param fname Filename to write memory to (simple binary format) - * @return 0 if OK, -ve on error + * @fname: filename to write memory to (simple binary format) + * Return: 0 if OK, -ve on error */ int os_write_ram_buf(const char *fname); /** - * Read the sandbox RAM buffer from an existing file + * os_read_ram_buf() - read the sandbox RAM buffer from an existing file * - * @param fname Filename containing memory (simple binary format) - * @return 0 if OK, -ve on error + * @fname: filename containing memory (simple binary format) + * Return: 0 if OK, -ve on error */ int os_read_ram_buf(const char *fname); /** - * Jump to a new executable image + * os_jump_to_image() - jump to a new executable image * * This uses exec() to run a new executable image, after putting it in a * temporary file. The same arguments and environment are passed to this @@ -261,22 +297,23 @@ int os_read_ram_buf(const char *fname); * have access to this. It also means that the original * memory filename passed to U-Boot will be left intact. * - * @param dest Buffer containing executable image - * @param size Size of buffer + * @dest: buffer containing executable image + * @size: size of buffer + * Return: 0 if OK, -ve on error */ int os_jump_to_image(const void *dest, int size); /** - * os_find_u_boot() - Determine the path to U-Boot proper + * os_find_u_boot() - determine the path to U-Boot proper * * This function is intended to be called from within sandbox SPL. It uses * a few heuristics to find U-Boot proper. Normally it is either in the same * directory, or the directory above (since u-boot-spl is normally in an * spl/ subdirectory when built). * - * @fname: Place to put full path to U-Boot - * @maxlen: Maximum size of @fname - * @return 0 if OK, -NOSPC if the filename is too large, -ENOENT if not found + * @fname: place to put full path to U-Boot + * @maxlen: maximum size of @fname + * Return: 0 if OK, -NOSPC if the filename is too large, -ENOENT if not found */ int os_find_u_boot(char *fname, int maxlen); @@ -286,23 +323,23 @@ int os_find_u_boot(char *fname, int maxlen); * When called from SPL, this runs U-Boot proper. The filename is obtained by * calling os_find_u_boot(). * - * @fname: Full pathname to U-Boot executable - * @return 0 if OK, -ve on error + * @fname: full pathname to U-Boot executable + * Return: 0 if OK, -ve on error */ int os_spl_to_uboot(const char *fname); /** - * Read the current system time + * os_localtime() - read the current system time * * This reads the current Local Time and places it into the provided * structure. * - * @param rt Place to put system time + * @rt: place to put system time */ void os_localtime(struct rtc_time *rt); /** - * os_abort() - Raise SIGABRT to exit sandbox (e.g. to debugger) + * os_abort() - raise SIGABRT to exit sandbox (e.g. to debugger) */ void os_abort(void); @@ -313,12 +350,12 @@ void os_abort(void); * * @start: Region start * @len: Region length in bytes - * @return 0 if OK, -1 on error from mprotect() + * Return: 0 if OK, -1 on error from mprotect() */ int os_mprotect_allow(void *start, size_t len); /** - * os_write_file() - Write a file to the host filesystem + * os_write_file() - write a file to the host filesystem * * This can be useful when debugging for writing data out of sandbox for * inspection by external tools. @@ -326,7 +363,7 @@ int os_mprotect_allow(void *start, size_t len); * @name: File path to write to * @buf: Data to write * @size: Size of data to write - * @return 0 if OK, -ve on error + * Return: 0 if OK, -ve on error */ int os_write_file(const char *name, const void *buf, int size); @@ -340,7 +377,7 @@ int os_write_file(const char *name, const void *buf, int size); * @name: File path to read from * @bufp: Returns buffer containing data read * @sizep: Returns size of data - * @return 0 if OK, -ve on error + * Return: 0 if OK, -ve on error */ int os_read_file(const char *name, void **bufp, int *sizep); @@ -351,7 +388,7 @@ int os_read_file(const char *name, void **bufp, int *sizep); * It can be useful to map the address of functions to the address listed in * the u-boot.map file. * - * @return address if found, else NULL + * Return: address if found, else NULL */ void *os_find_text_base(void); @@ -359,7 +396,7 @@ void *os_find_text_base(void); * os_relaunch() - restart the sandbox * * This functions is used to implement the cold reboot of the sand box. - * @argv[0] specifies the binary that is started while the calling process + * @argv\[0] specifies the binary that is started while the calling process * stops immediately. If the new binary cannot be started, the process is * terminated and 1 is set as shell return code. * From patchwork Tue Oct 27 18:47:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 1388885 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=gmx.de Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=gmx.net header.i=@gmx.net header.a=rsa-sha256 header.s=badeba3b8450 header.b=FzxFWdGS; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CLLLk0Cpqz9sSs for ; Wed, 28 Oct 2020 05:48:13 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 414EC82496; Tue, 27 Oct 2020 19:47:27 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=gmx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; secure) header.d=gmx.net header.i=@gmx.net header.b="FzxFWdGS"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id AE2CF823F4; Tue, 27 Oct 2020 19:47:21 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_FROM,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 338DA8246A for ; Tue, 27 Oct 2020 19:47:18 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=gmx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=xypron.glpk@gmx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1603824436; bh=vHzYcnkqsFXwt6ZcP9CdVMOvaVPuUi5qPj4rez0NDIc=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=FzxFWdGSSmhhBQhv8m20qdftqSsjJCFaxPQaD5mK+OafKpIeaTjoDldNBJKFEjXGf bGbaO+sF5aO8jOeSPLGDkKsM12rRTB+O9BCSs5zwroU0lEu2bgNSPh10RPZkf3PEE1 T7e/lHutpVAbkmDRgFZO6Aihf3Gz4XTRWQRzX+ZE= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from workstation4.fritz.box ([178.202.41.107]) by mail.gmx.com (mrgmx105 [212.227.17.174]) with ESMTPSA (Nemesis) id 1MVvLB-1kz9kn1ouL-00RlwU; Tue, 27 Oct 2020 19:47:16 +0100 From: Heinrich Schuchardt To: Simon Glass Cc: Rasmus Villemoes , u-boot@lists.denx.de, Heinrich Schuchardt Subject: [PATCH v2 8/8] doc: add sandbox API Date: Tue, 27 Oct 2020 19:47:04 +0100 Message-Id: <20201027184704.15910-9-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201027184704.15910-1-xypron.glpk@gmx.de> References: <20201027184704.15910-1-xypron.glpk@gmx.de> MIME-Version: 1.0 X-Provags-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3A+9grjH7y2 lS/Opz4Q4Cpu+l2oP1MiDJpVki2TL620MUaG4j2A67PHj/yRsc9u6LwfUJaJffPTgDmeKFxpq pkgFwafGLZ8aQdi4AcYw== X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.3 at phobos.denx.de X-Virus-Status: Clean Add sandbox API to generated HTML documentation Signed-off-by: Heinrich Schuchardt --- v2: new patch --- doc/api/index.rst | 1 + doc/api/sandbox.rst | 9 +++++++++ 2 files changed, 10 insertions(+) create mode 100644 doc/api/sandbox.rst -- 2.28.0 diff --git a/doc/api/index.rst b/doc/api/index.rst index 787b6778e5..cc3bce494e 100644 --- a/doc/api/index.rst +++ b/doc/api/index.rst @@ -11,6 +11,7 @@ U-Boot API documentation linker_lists pinctrl rng + sandbox serial timer unicode diff --git a/doc/api/sandbox.rst b/doc/api/sandbox.rst new file mode 100644 index 0000000000..724776399b --- /dev/null +++ b/doc/api/sandbox.rst @@ -0,0 +1,9 @@ +.. SPDX-License-Identifier: GPL-2.0+ + +Sandbox +======= + +The following API routines are used to implement the U-Boot sandbox. + +.. kernel-doc:: include/os.h + :internal: