From patchwork Tue Oct 27 19:29:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 1388940 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=B7yAJqmM; 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) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CLMGn0B6Pz9sV1 for ; Wed, 28 Oct 2020 06:29:52 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8AFBE82361; Tue, 27 Oct 2020 20:29:49 +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="B7yAJqmM"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5E289824BC; Tue, 27 Oct 2020 20:29:48 +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 044BE801D8 for ; Tue, 27 Oct 2020 20:29:46 +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=1603826984; bh=PoutpLhQ7gQTkH9SFIHLMLBEZqefv7sVh7q/0Et5ja8=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=B7yAJqmMuJ3TEs7CUtAllrwgQ9Q/aWYCBKiviziEPDtF/TzuOM6NP41Cr9xaskSaC hXORRvXncXjKsk0URoG7Br4v5xmi4/SGE3dy/k9yHRAiBRc10kIIWPN8HPCvpurZ7b DhuTG+/b1lb/5RBEFqOkbVD3EsgxI0QtFHVOWAZM= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from workstation4.fritz.box ([178.202.41.107]) by mail.gmx.com (mrgmx104 [212.227.17.174]) with ESMTPSA (Nemesis) id 1MacOQ-1jwnKc0qqY-00cA7U; Tue, 27 Oct 2020 20:29:44 +0100 From: Heinrich Schuchardt To: Simon Glass Cc: Rasmus Villemoes , u-boot@lists.denx.de, Heinrich Schuchardt Subject: [PATCH v3 1/8] sandbox: eth-raw: do not close the console input Date: Tue, 27 Oct 2020 20:29:21 +0100 Message-Id: <20201027192928.16508-2-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201027192928.16508-1-xypron.glpk@gmx.de> References: <20201027192928.16508-1-xypron.glpk@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:8ShR+0gWOK9nT2iCx46HS45e7T4TYH7h/UiiMpEifIN25dyWt34 vsK+juC0uU07NaBm+pgYWHyS7k4qMhcI+uzSi5+bnLfpeVUq9b0rGWVBTUpBSMMslz7y7NI 2tfhNh8pcDD4fTvHEq/+25Bwa3tQjZO3SfHmcJD7iR8eo70pP2R1Yaqn4BLMX+VpS0kbIlL cROZ/CcCwqyQ26OgXM5gQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:wFv7Fqh6rAg=:apBvz9+Xmpy1UwmT4iG1rE yG9Jl17ZNKvF30kKjrerY1MVaZ1eCkpjNMwYSnvUjnLPvE8gTr/LVBlx+/uDZdqqj+/G4etUY 5LPbrXRvSmgvzo0qidm32/U/zKAbt2N0MukCG6YdSM1ESwbadCiTCIevTeGDahFKggMT1ecuD guoH0yEXkJHfbD6KksrxwB99o3DWbaVlnXeafZnrKIQxOtrtQCOVbvVfui2XV3BIQkccR7MX5 B/mn9n2RLSQcrhMIaADSwYfvcomF55VKQrzVdT5xQoW0p8AEETLvzTgLWS/gQlH3l0deY3L5K Rj5MUWQOiq6a2si4hTKXuaKREMgBnlnKoLT/OYwlEhyhOe0QKQ5sbURwFQSeaOp3jqLYDWgtV cEQFDIxVWgmo/KcyhCfQzGmQS7dpDNpxvTWLQfetrVAkLeKUbGfrBNW7+TcPHO1E3D3hlQwH5 dWDRiGC/0DZULlFEEPdzGwseIjLcKcknj6KZbVuHXZnhen4CFmt5gro7g+Y+noKtVb1UKNlM9 Cy0cHYmh2CRR7u4MzdmdEKm1U3/0ICvRzDbkCInJWlDzdbnzTxFvuvWmadY5yfL1fE+nY8/35 u/Lej80TxzFu3fJFIlLrRfLsVOTTzh+YpcSGA0DNbi+TW3ahFDuw4ZKBXkwClcEiXKFtTwsfP fhg8mCU6DDYu1FXO0Id7+dgyu1s/8lIY6q1Y6nbP//uufbVViyaYSKcSr70yjHmbyXgDstsZL 0q9Vx3MUbi8Z3ZD7qqMnsvtmEw2PRzijEjPLt6un1B6L1zudJDmxwUT1Pdx3VJj+1MfYPOToI VnDaCdfhWpPoN9RGydZ/WRd0MzGGjMk7PXfUSJQTHwCM38Ufpg9UWNDqkgNn1EE3kfpuNS3T+ sjlaSHyjpeISh7dsAjsg== 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 Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- v3: no change 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 19:29:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 1388944 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=CZuDCkCY; 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 4CLMHQ6Fhgz9sV0 for ; Wed, 28 Oct 2020 06:30:26 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4E646824D3; Tue, 27 Oct 2020 20:29:57 +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="CZuDCkCY"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 15302824DA; Tue, 27 Oct 2020 20:29:51 +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 80E2782483 for ; Tue, 27 Oct 2020 20:29:46 +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=1603826984; bh=IPaDZxxLQH9km/X0tOjjKxjy2s8kjoZu4akiS0XU4jI=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=CZuDCkCYOUbUxn69/bwMBoVVjT9lIvbv0Z8JWxCNWh72kb3hcxuH+TQOZ3PTlBEaG 5yk03tOuM1zPAMX5g2VGMi17h/PumO9t824kNLTzaZFHQXzecvU3kipNirBgXSM9zh CR6vgqsOAu/n+swBitHPLaHeuySYOzRhmfUcJeJg= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from workstation4.fritz.box ([178.202.41.107]) by mail.gmx.com (mrgmx104 [212.227.17.174]) with ESMTPSA (Nemesis) id 1MV63q-1kzR8Q1tdW-00S5OW; Tue, 27 Oct 2020 20:29:44 +0100 From: Heinrich Schuchardt To: Simon Glass Cc: Rasmus Villemoes , u-boot@lists.denx.de, Heinrich Schuchardt Subject: [PATCH v3 2/8] sandbox: enable poweroff command Date: Tue, 27 Oct 2020 20:29:22 +0100 Message-Id: <20201027192928.16508-3-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201027192928.16508-1-xypron.glpk@gmx.de> References: <20201027192928.16508-1-xypron.glpk@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:kkhQ/Xv/dPcX58WOAFxNWEKnJH/2XN3YcPx5W6q8FumSCzIITDU edtQIcScyvpJY9S2s2i8velfP6bZH7FynIWoybx4NTXmYqlD0kh3a3MmYKwky2VMxfmoINo tL4Jgtjh/vnvXl3ix5pYzxYQqY+y4mYj4hs3rbu6/kvuqISNM5kuojTjQHIdDh64se8E3PE XST7qVYSV+PVnoCIDYq9Q== X-UI-Out-Filterresults: notjunk:1;V03:K0:5Ov4SZNVIgw=:ZBBangWIh3+gxHlQ8J+3EY iJ5u2FJYKMYZ1lDr1rewHSuxA4EiuOA60aKRyaeRaDQ+lNcZ7NE6n0XC2ipWejHscREl5Mw/X ulHqusbvbRLRANJzchRSCZQ9TUoDHmxpeqoFTGkM3DIw9li9wNzm7Y2qKAZffQ8rvRsJGZ5Mh 6H8TLZIj/uissVkr+GVtPVTcx2UZ01/9TPSGbS43aqkHiMARCHCbEtKAtfoVNiKvPmlQQzHJq YSGIdsuoT94pIDzjXl+q/H4iB65/KmO6+HX9rCS+6BxZ1EzO2x3cRlcr1U7Xi0SohFsCsbfBW 7fLwxmk1kA/jkJPRdJYdj0+ftpgAcj1EnmNdsvhW73r+DKc79IYOQZnItyrCeqfqvi1/ZeIqe FzGDLqN9kjRmrSiYwtoQ+KtJ2uRnkBtRSYYs3mGikHl6SXgJhlMec0u06fkqw8pjEM3EBmMnO k9Zwe9cGcHzRnxTMStCBpR5JYtfNitvUTT+O5BnCLwhMF2+R79T5Tb3lmg8aLwF71VtmJYSjg R9VFnLFNpffl0wGW/ikCSETr4Yq5HjVfDkWagSVKMol+HEjC8PvP/Vy3zKU6LgGFDtDauYmvd NzQQ6MHPlFlmqflsJ9ouj8Ekq+HRYbgWkCicS1o05S/UxT97VY/G7DW0QAL2awmXldwhCS13k raapfgT32HGMUcyZLem8zB/E8eX/OmtRcugpwNYuHMMPqC/DaEgUgqe3D70LAxypCXxEEgjyf 6Izs59EAHcaUoX1Y3mh13cFEYg7BPfXhX3pFsgfEB04301O3AF2C5AYTZEhdWLPKSxyiN66vd kEyRlzM9j/jWM0JQgvcuxFna6jBi5kSX6gIMUqu/6uEJB0C8KQMY1kzC+3xnm0M3IwlKIYbaD q8dCeNeZUXZug/CSjkDA== 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 Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- v3: no change 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 19:29:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 1388945 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=iKFlogaq; 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 4CLMHf4mlGz9sV1 for ; Wed, 28 Oct 2020 06:30:38 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 25706824E1; Tue, 27 Oct 2020 20:29:58 +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="iKFlogaq"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2856C8248F; Tue, 27 Oct 2020 20:29:51 +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 41E35823E3 for ; Tue, 27 Oct 2020 20:29:46 +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=1603826984; bh=lbF/eJXpiR1p9PNCykWVr91fX9iyAED56Dt/11PT3Hk=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=iKFlogaqbBv43coYLp7v7+DEjpZR05jJdMkgWScBgO9Z67s1GEuFvU+vPNscX96vR nQAh9T5QnCV9fJJUzAgudlmFXpk61j5P9Eirl6QVnngjMeFifBSvyyZKI0kf/2yyxu eAblObQCwqp+h41iPY6cCL93z1jRKHibRbo7AoXM= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from workstation4.fritz.box ([178.202.41.107]) by mail.gmx.com (mrgmx104 [212.227.17.174]) with ESMTPSA (Nemesis) id 1Mi2O1-1juI6D2pqz-00e6CJ; Tue, 27 Oct 2020 20:29:44 +0100 From: Heinrich Schuchardt To: Simon Glass Cc: Rasmus Villemoes , u-boot@lists.denx.de, Heinrich Schuchardt Subject: [PATCH v3 3/8] test/py: test poweroff Date: Tue, 27 Oct 2020 20:29:23 +0100 Message-Id: <20201027192928.16508-4-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201027192928.16508-1-xypron.glpk@gmx.de> References: <20201027192928.16508-1-xypron.glpk@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:z6pM2AyP2zhyU9JM6hv1QdQKvm49MT7pzasWWMf3Wb5RjhGkex2 B2kWEgu5UV0V6qoyJTwZHaTSeKh9JwugXWUV/hZ75CH8Upq5tpkmEoO+LHx9v88sJBPYtym jxv+BJfhASK+Cwjay+/BKniKMREx9TgvWSBFRcDlVG/ijjhnSXLmlFdNxJBEyyAUBIaH6pH w9Pg/aS7AANFGAVwKTtow== X-UI-Out-Filterresults: notjunk:1;V03:K0:eiiE4cHhu20=:wsvFD7ClsFMwhVNhZYyvvs L3Xg7zu2D9Ajf43GySkK6PHwhMt4IJf1rqAnoXjcaOWa0Xq1cq7yTJMlmAW+cqqxD31gOGEJw VSr0d+PW1culCKN00NFGBr6BvEuQ2dBgR0fuTXItvQKvkAgqttLNMlTJeFib+qo3RVqKnQrTi U11BPDogzQlvJNLvj69hwTVJScQbwFDQId10+O8Fmn2lbcIms1cpz58y83C5LnCFxAU27izt1 O3dDE+FZSFhnJsBHxaoAdhINI0t/qx8P6sLaPvBK8CcfvayUEO1MNASX8D1pYeMKMlU+5hZgX mUg47lJy4YieW8Jgd6fNY4G7itFKXSARmXDUetaZBlfnNhCAmqbFO45nr52MBoFcY7I3RJuY7 Z5+Lnetm2c9UidR5hGJtSbOnC0YaCqgDCk51P3uwuW7hLySDTL95LsiUrlg5v4+IRR1DzH67L vIkdBNO3PAiRvYN2+lxavz0a7U722KuA0ya4kEPaO6G0wSTxtvabXb+ZgCqgTs9hx54+nomyN mYRYuSckhOn8liM81o9TrJNLy9JA53cKF+Q7XqODd1+2dRRaPa4bYabzoF5k3dEu6FRUnbyqx ajdCTmlCPt+XOhS5DXrdF8GxyxqZP5J6Wmaqwjey2GgQNUr+qUiEPisKlwD8OSO87NJgMnmJp gxJjU3MJVzQ0QLC7x4fkqTqxdr3/82grhXQJ3d1ZcpktPqhWu1iYoESOP70snuf64SpZDlum0 yqCtCsJL2DSCPI/UQPnVUtB8aQW5oauiwWFNogf/1EXPPgReANjYqW0fkWoV1OLzw8MDpk2Ew YXqZcj07knvW0SUcxZtAJwX9llc6rO9F39pJQZ5D/F/7fC0gJSbMP+/apwu7W9HSNkBVudQb5 akq8SZBrF1j4vBDiPbmA== 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 Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- v3: no change 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 19:29:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 1388942 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=BTxoX060; 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 4CLMH90XLMz9sV7 for ; Wed, 28 Oct 2020 06:30:13 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 656958249C; Tue, 27 Oct 2020 20:29:56 +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="BTxoX060"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id F136D824E0; Tue, 27 Oct 2020 20:29:50 +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 BB97F8248B for ; Tue, 27 Oct 2020 20:29:46 +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=1603826985; bh=07GxynJmdutdoAMYXCVpXo92u4XqFCDKl0VjGJEjKFw=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=BTxoX060CQyMVVU+1ORbVtgDJWDrehzBT+PbDDqouWk7YEj77lMI6pCG01nvHiGZD VCkMw7QAiEKep/7WPcb/+URLAuJ8CJj8vDgQqRLNrBp5AFfEbh+9b8l1B2Bz9p98JP eRUUwzm1wNLJNowslqWKxEHd+p+JSzEBXIWhuojs= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from workstation4.fritz.box ([178.202.41.107]) by mail.gmx.com (mrgmx104 [212.227.17.174]) with ESMTPSA (Nemesis) id 1N3KPq-1kPHVC3r4k-010JkW; Tue, 27 Oct 2020 20:29:45 +0100 From: Heinrich Schuchardt To: Simon Glass Cc: Rasmus Villemoes , u-boot@lists.denx.de, Heinrich Schuchardt Subject: [PATCH v3 4/8] sandbox: use O_CLOEXEC in os_open() Date: Tue, 27 Oct 2020 20:29:24 +0100 Message-Id: <20201027192928.16508-5-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201027192928.16508-1-xypron.glpk@gmx.de> References: <20201027192928.16508-1-xypron.glpk@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:QnYWXBwx65m0UAyIbp/lL5zeQqJpwlKu1HGyDPHpR3am676miQl 1+ebp0PP+i3T2MHoWJ7KyeFp4p6Nf4RAOTCPYXlRfrXhdQHl1ofZD6MIHjod4ximfheDcwv MFkyPP+J5Y6k5opMMaHgSq2YVEkMFDYtpMIT8A6JtM3VmQuFFAcI4zBXGxGDBUFx8S3PubU vdJ4dQK82aEpLpnpIwlig== X-UI-Out-Filterresults: notjunk:1;V03:K0:nIlJyNiwYjI=:5bzJHyt6PM+OlC8MU3a6Lb VEW3DLoTGMPy7ZrFHBAErPQ4XiKSyrxIYg2E+ykgt1tFfei8LHg5whfutlTrFf8AecoZXJn7D 8EmgX4pis1WmM21B+sc3OdX3CRFelrVHgq4Jkf4iOGOkP0U1qNgIOZ7BjwicgNE/1hB2MpcN6 yneIGRcXutguYGwHG6wMG+6OEJViSkFHBXdbKDluZjOx8tQBsSVMrL4c48/ZOk0yBd7v71X8E m9PWWtajMeCWj7XC+hjuQi8UclZzZdl5Pb3Ka8g/8w26tSIdw6yfSXqWfpt9gZZ/OocpBNBSC TVKbvvzEC5DPcSyZrnX/mkNZiu3njhPuKTn8jNrDRQPo5JYKqjDGZEQVGKFpwBlAwnUCJMm8+ sq0+MO1oQZXafdrRoP4hDYR7JuRJb+UmNUBu5BCRQ1oEFeDiRzfd19onN7QoCsqtLJ/gYVXCr UpUZkDtbwV6uKTjBsyQPXLXGazybcZ5O/E49pmfF+NUTo6/hIq6B/EuENQIUCE0XnyiH+lNcM /ivugQcdyYI1n4sSVfD3m0bYLa3Y6+mfxXRmE4dVS2f0hbf36f9QOrGaKu3ROM0bR3WJpElMc ohX5QXMuf0H7KG5RmI17Zl6y6bwoyg723bxEeqXYlCZa257os8YZT8pkVFxQ4toPm/COtA46a ppUnnlBVGwfqGo1t7YGNGApiqj/z/mVXilIeYuCl8S2dXz9z5V4nskQPRFREMv7mp3NP+BhS9 FPE6+Tb1m/4iJ0K+39VJf0kCnxVTJbI+T+wWTL8Jvp0pcfcujecjuKvvu71iO1aQpeLZEFAHu lfTFc3byJIVPRv6c2zd+oHpvCFSv67BVUNrqXkBYWksVhMFlfmjokVNhL8IRsIdxgtXYBgFFU bPfK7npBhYjgKr0+6sCA== 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 Reviewed-by: Simon Glass Reviewed-by: Simon Glass --- v3: no change 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 19:29:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 1388946 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=KIcsrmXi; 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 4CLMHx5mxGz9sVX for ; Wed, 28 Oct 2020 06:30:52 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2BE01824EE; Tue, 27 Oct 2020 20:29:59 +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="KIcsrmXi"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 67DF5824D3; Tue, 27 Oct 2020 20:29:51 +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 2D0998249C for ; Tue, 27 Oct 2020 20:29:47 +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=1603826985; bh=HfFaMk2rWLzLKFcZMOSrgSoVDP9HRps0txQZPWZFRUk=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=KIcsrmXiJRX20CZNKQYm/oO5N1Qm7y7PtSlEvSb5nVU3eHh1FH7FItn0sXgaqsYEA 23btse2tngTedt2Mdr1VtgTaHPRwdGd9amHGBDh7QZtB5HYZNIEdtGIxenxKCkyYwG 7sk7e6UMmNEoVjawETIwHmISOxp3d6eHTa7jPVUI= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from workstation4.fritz.box ([178.202.41.107]) by mail.gmx.com (mrgmx104 [212.227.17.174]) with ESMTPSA (Nemesis) id 1MSt8Q-1kxFH50f7O-00UIJw; Tue, 27 Oct 2020 20:29:45 +0100 From: Heinrich Schuchardt To: Simon Glass Cc: Rasmus Villemoes , u-boot@lists.denx.de, Heinrich Schuchardt Subject: [PATCH v3 5/8] sandbox: implement reset Date: Tue, 27 Oct 2020 20:29:25 +0100 Message-Id: <20201027192928.16508-6-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201027192928.16508-1-xypron.glpk@gmx.de> References: <20201027192928.16508-1-xypron.glpk@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:IMV73ixQixuR7EMOHXfPedi9hpS68ZRsV4/VZQYEO53phiquNeR BVnn7c2yTCJWwELsUYwNcnZR7m8NPv5rz+CHYU6TuMTu181Hym2lRqbDD9W9DUnIEtwcUtQ OBUYcpDxVIVC+BxxBYuh1gF/mQi4SlAknP7Sdy6E57oXurhaUVMdVx52ZvnMwRKDM6/Y0Bs 7OIJTMZvM2YfMY4oGM0dA== X-UI-Out-Filterresults: notjunk:1;V03:K0:m3esObKTtwI=:/tY/F9Z9MXv7H1L4WWt61B MygUZXGY9d8Z24KN6enKZ2h9CBG5039glH2ViYX6LU22cV87y2xKty0lQcY6tXqyM4+CUvNDq st9dzPwOd16oh7MPwrLR4h8MKQ3t/ev2DG089Pl8bmT/xJY3xUAWvIOar7okFlc1a3SoSaYcq 8wEEFgHXViONPTq7JuFQOq0M4DsmT0Vnmd6/gV+lVko8+FfFeihaP076UNGMrZkoKC+ATX/8K 7Na9+GVH0HDSK2sg1X1+lVhzGJenns3/xIG9mo/L8lX+p9ShsRRnilSuQrAIePkERQt46WYUy Rdo6ZZvWezRFeJ7yh+sblqknqwCiPEtca9FB5JbUZVDm0P3lhCsFc2on4Q0qzi+Dvi2l0yH2x N866y5iytvHp0ajIAlnj/Nqw6DjDypZjxkxl7CkMbNkBhIHlRpIrMSdyr8ISieHdIoP1GCANl SyJ9FKIrcVzHLWrmX+l66vhh79GYxPL+S4ENJ/YfYJGfxz5Amw/KMZxqWyuqaQoCUPKR6W+AO zC+xiIYdAOQj+3b/ESHuK1gvxh8jOtXoZzySYOb80L7GwvbggZG6ueVwFPrKoTjjAw15d01RV ZYT1QSVK2xgc54L0knyg0DFHUfUoFR4HvXneOwR6w7+j27OgoDt9J8QCwEwj+fbQHIimaz94E IwDbh+1NG7fbQhCINO2TuWdLci7f3QwQQ4e2WM6hu92EFuNXq17M1U8eJZJD8DrnI3+mjjVZ4 4mtoM7euOfCt4zfAFzkKxurQ/kitzOVpMVUcfLTHeMWGMfCSRBzaHQQwzGiztdPiQZrJFVTvP J0TKkFutHi7iRSv+aA3RSgjENzigqnRqGjC3bFu0qdUBdrX/pwH0hFdxeyDRtUhSvHWObrOPo 1rTsKqyu5px550OQIaJA== 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 execv() to relaunch U-Boot. Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass Reviewed-by: Simon Glass --- v3: update commit message 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 19:29:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 1388947 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=TYfgVVdG; 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 4CLMJ81S1cz9sV0 for ; Wed, 28 Oct 2020 06:31:04 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6856F824F7; Tue, 27 Oct 2020 20:30:00 +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="TYfgVVdG"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 045F98249C; Tue, 27 Oct 2020 20:29:51 +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.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 6C82D8249E for ; Tue, 27 Oct 2020 20:29:47 +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=1603826985; bh=Vq7ZXRWEeWyzGmY5c9MDelZiF1eEtC2Cg7/C5imrZcM=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=TYfgVVdGtCMp9ydIS05mE/XB8qUqpmD55VtqyWZR3lMy6n6sO3bCQsn+I2+lQuomy 3ZzpR2wgp+kC8itRx/yl/F5G9B7xufZnXTSAI+YT17vhlBchGmBNhcj69l4658GOjK 9Y01bTvKQYKSjPHSuXXXORxbL+ISlM2SyQk5B2ho= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from workstation4.fritz.box ([178.202.41.107]) by mail.gmx.com (mrgmx104 [212.227.17.174]) with ESMTPSA (Nemesis) id 1MkYXm-1k6egh1gnm-00m6Hs; Tue, 27 Oct 2020 20:29:45 +0100 From: Heinrich Schuchardt To: Simon Glass Cc: Rasmus Villemoes , u-boot@lists.denx.de, Heinrich Schuchardt Subject: [PATCH v3 6/8] test: adjust sysreset tests Date: Tue, 27 Oct 2020 20:29:26 +0100 Message-Id: <20201027192928.16508-7-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201027192928.16508-1-xypron.glpk@gmx.de> References: <20201027192928.16508-1-xypron.glpk@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:PqoCeZqP785UW48MHAiUyjzOqfk/8lEvl82ovbZf74EKFY6S8kW zKzyXkpwUA9rBXncPiIUuJHxnaYmei4yuRjlgznnHNwPoZayVv0SxlohlH6dGoDzoVUTczc uVRpBFKZIQaM5tuB/Mj3Oqv78+/pJ5nRmtLNQUwrbbMiqYWsVhOdykCBz2dZtQ4NbQAr5zt Bc4iKNceLR2w5owA1JuOw== X-UI-Out-Filterresults: notjunk:1;V03:K0:nonTKHhSJLg=:U1SBISsY/lL2kC4p7RR9+D FAzdtUfRFboiacSg7wfObcO2+hdTXtTf4FlAYCxLiiN8k7ro5oFFVQzBUxRgLLW1wR3eBa7/j gXvsZD4gej/gUvAJrgChLVnv2Aelhjb4oPEkH/1dTZgn7H86/2YOjlrOoxVwgO8qHU2BMlaB3 0paB/oHE+/UYs61F5LAXm9vKazd6iGJEoeyWE3v6xSo4ZeHQ2OZEJOLxZtSU3XnmoavvncVTB 3kbzRCxKKlxiDpCQ1arqZ8W0dljJ5ETyiUh5oJozbzaePwhMm3+P213CWYhFeVGkmJI0qTNde dCqpVTmZMyWXXrjivCFT112jWBcu1/7P/GuB/lSwP+CivYtjk9D7l48e/vtqIHGnSxQbO9WnE uF++pHW09F3QKmkYaGYjNs7dnjyr2NaVYT6taso6UndU5anccZyJppshuHRzX6LuzITpbOmnt NuGv4WyvbmXym5Iq9bjGm575wvhvUzYMpOvDab92fusfXB4I4hsq2Atdz8mayT+ZCkAbu3Czr RBcgBmopkv7X5vNivOoSlOR0S1PHoqCUnxTTnTADVJvivlHh03zEOdN4uY8jQD8EvvGVInVyd GEEasJZ+FwoD+Op2+8H47feuQr+zuWTEb6OVj4+fm/NeK+rmZ0HDUqnbK/qWrVSLgtPR1bu7b 7xcXwGyizNgl3FKSJTjk+NnrZ95tdveUy5EgEMkUyzmocmKNiyI64gIiC63slyeXm0BEBPtVk 4pC/QXK5M5n7lQpkxwwhFKxwDtFX/f3TpM7jY6OfNlxaNnkCpyC/5EjYrfN14xFw/ivGSwc86 9i3NLXJj/xiO64xu/VWB5h1jVmdZOLSQITK0m1e6LR8TqQFg90FGN5l+xM/G7kYBvIoP6yTfs 2YLbMAN7vlSBoyv6pUjg== 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 Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- v3: no change 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 19:29:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 1388949 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=T3mwM771; 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 4CLMJX3RHDz9sV1 for ; Wed, 28 Oct 2020 06:31:24 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C9E7582513; Tue, 27 Oct 2020 20:30:04 +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="T3mwM771"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7338E824DA; Tue, 27 Oct 2020 20:29:54 +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 B2E02824AD for ; Tue, 27 Oct 2020 20:29:47 +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=1603826985; bh=x+M9mKnH2XdI1WbzSsh6N+Lv4QXClCQb02ZeHvY2b7k=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=T3mwM77107MxkWqGsTTa/ZOc2OqmS155YxnNNKxcQ56vVvK8mfdmJOAg+42b3FOa+ 0tMxM+9ZoK0MEksdZ6UsFoU0HqJQ0ufUZiGKDa8dmArIxC/wdNi/DrLQ9SMIp9FSD2 J0nB1nvSVLDB6MNWcafamfogMZXssz7k3BXDI9iU= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from workstation4.fritz.box ([178.202.41.107]) by mail.gmx.com (mrgmx104 [212.227.17.174]) with ESMTPSA (Nemesis) id 1N49lJ-1kP0Fk2f5N-0102tv; Tue, 27 Oct 2020 20:29:45 +0100 From: Heinrich Schuchardt To: Simon Glass Cc: Rasmus Villemoes , u-boot@lists.denx.de, Heinrich Schuchardt Subject: [PATCH v3 7/8] sandbox: update function descriptions in os.h Date: Tue, 27 Oct 2020 20:29:27 +0100 Message-Id: <20201027192928.16508-8-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201027192928.16508-1-xypron.glpk@gmx.de> References: <20201027192928.16508-1-xypron.glpk@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:qPqeE3zpqSrgMt8L8kXKxXfH6ux692PO4koViWrWGpEUDW/Rw17 +8hzmIEYZYbqKsZZjNKBUH49HVNILPE63tkR6QrE+pIDG/dbQrtHdfZTy+UfuiU+x4pefmQ IRRBrdyiD7k7VDMIEWf0BUKJZqmFC4USJ+YQjRSVgP+6SDHPSBG/RrB9f5MDoFowxrjkMC5 6cQXj/hdX5jNmGByoN6kA== X-UI-Out-Filterresults: notjunk:1;V03:K0:vDEpJX/tIhY=:c++xuWS/Wn+gBRdnD2E/s8 3XsM6ZLGnZFJ+kX9X2IwQy+Tpm5mGfOLF1jD9lVHrHnMAnWXrj0ZTkQRn+vjkXThbzadcfLcQ AhLwU9RJKGSlkRy+T3GoDz4d1mH0/8WtOksveFxZy/rppvEqsgOxQIz2JzpvhWTopnnhS5Htl zVivqlIlMCYKlnvSj/Yua77ddQACKZoCUBLap9OaCxqZcjwMVmEtDjHaZ3cL0csyxbQb5vPR3 5SH9kvQF/yET6VdRayIJPYEvKTMDuZ6PkCdFXr9TGAANG1jZIi4YqyXp+9r3xf/D17C6L7ErF qCs8qY1adjXjxxp4jxNBdjWaIYS3JRuqMk9BQ6MWoK56VpIStCoAUIbl/PX5ohTJ3wVoyvwrg xNVJ952GFiAA6NMeI68Cqk9sirgRWo9SeI05db5rZyxDRLpsBISU5muREY5WeOD3008aJ1Q41 9Gq8TV0KjOMO7Iw2blr1ftRjP2YAIEAs0fxSRZJWg7kxGrwSQIzYSCqDWQ5/IpbaknmgcrHyq XPM3s5hzqZqBxCM8cCj5GK+LBvuiPsDVv6ycJwGogwLoeOPFTy/JxzprTrM/YHxtjlh2H5+66 J0lZ6Fg4ZTeoT/1nQ73ipMIEFv6XQIIuLRREfXUvtPG7HPm7krDitdZy2aD0qLzRnjE6lK938 PasQ02SrfzzsvRUuCqV6Nsr8SzSeviozqm5rFj0ku+RsSpdcsXuYfyj3z35/7hyMAw7Jlrdda Tr4uftLB43yLsRmnj3W+r6wPsfW+dN4bpXJXw4XhJ6XTVH3xfrpSTJWwH5L4k8rX0e9Hukzyr k9s3qsWnlR26mCHesVdeLeIe2Xf+U6ewW0BR2d2TKw5A5Z2rxJJ/G8xUaZ3JH+hMMT+R5FBZK J9+np7snmkywTkXe0fCg== 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 Reviewed-by: Simon Glass --- v3: no change 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 19:29:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 1388948 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=QC4idFJ8; 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 4CLMJL2zsQz9sV0 for ; Wed, 28 Oct 2020 06:31:14 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3947E8250A; Tue, 27 Oct 2020 20:30:03 +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="QC4idFJ8"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9D0E3824DA; Tue, 27 Oct 2020 20:29:53 +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 CAE8D824C5 for ; Tue, 27 Oct 2020 20:29:47 +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=1603826986; bh=iywQLVAUkECYX3kXLtLXo2Rcszj2Wz5v7PmtPGj9X0E=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=QC4idFJ8T6SRpBpbBkPyMivwkp2wlwP29qkH4kHle47+qBplnEjEN9eNN1khSLLIx EF4xamrIRHqQsiJVntJGfuaZ9D5/ZcskUlwdNh2wOtEnNPG8Zs6Wlg6dYUM6xFMQFi jNx7ieG1o5YiahptS3Wog3iCxBfINtlaBkfQqsNg= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from workstation4.fritz.box ([178.202.41.107]) by mail.gmx.com (mrgmx104 [212.227.17.174]) with ESMTPSA (Nemesis) id 1MatVb-1jx4JW3fCN-00cREf; Tue, 27 Oct 2020 20:29:45 +0100 From: Heinrich Schuchardt To: Simon Glass Cc: Rasmus Villemoes , u-boot@lists.denx.de, Heinrich Schuchardt Subject: [PATCH v3 8/8] doc: add sandbox API Date: Tue, 27 Oct 2020 20:29:28 +0100 Message-Id: <20201027192928.16508-9-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201027192928.16508-1-xypron.glpk@gmx.de> References: <20201027192928.16508-1-xypron.glpk@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:6BGBlfcx0ua0vqw0PEl7YkrPZBW3uMnGV8EXNlI2ubDriU/xfZt zTB5Ha0WSYEXYOxlvV6HOtl5MrXvRq3geNvvtLB+QHLn5XmN/8KKUXTrH7ntU9fEXfgDVYh wE6LaETlsfvkRCgeGj0DqospM1dF7edJl0wLgenmVv5ANwIxvfoLJx4r1wUBHTgK10nVshK 2jW0mBDVuI8IWNO37qMGA== X-UI-Out-Filterresults: notjunk:1;V03:K0:nD8Fgx87mSc=:dEmakpScoqMWNXWwcjpaoL fOPyHX4TjEhLImliVOZX/JAcfYp0vTGIwiT2mYnh2QmZyCfakuRPuxd0Fnw4jS96t+ZnPOHqK Afu+CBqt4lL/yFDhH2thXa/qKwcNVyGV+VsOXdBQAQ+zpXbiUnyYJLnTfeIYCRNPXW7VsMBhT L5dDn0bMENtEzl8uqFY8yp2g0xstJ1Hcjbll+QunaM60OIyYicEqUHEk75QWUOSLFBiH4ipOb ehKSP0KPtQ78vD9lg8+tbB1zahLjti1qqzoIdFD60ji6P4aHijYooZoGq51ZmImCqtqbKh+bI zwxh0G/EzIBqvL6KAeJ0SG00p4S2NxbsewmjuNIp0zQ+GwZrHFdzr0RaXyJeP/HCB+fQcVjo8 wQJZd3yml6i16WeXbQ4AMu8JvaC25uNLALgoxoFBMVdX+G2ASYyehMCIqjWi3bHWiX8sqXYMl qiNjjpDljdW+7YnxNoJ2npgguugEjY6zgfit7gF78sk2azRcZwD0dguD5viUCV+55uLY3+cq6 0JCV5GCAQRMM/b8dnwrSiWlk9FU5H5uowjsVz312nuTd4jYXVMfGD/sgyhxkKf/bORQMP9PjI PIDS+7TsaNEUdCQh5EkvzFvD+Q/QdDaAI4wttExIWMf2wSrUz4tMmJR5a5U8fARiPGvmAKJRt DDt/TIGug5a1NZ+AD/7IdD/x2SY5MYzgr9pH1ABleiJ2o1R48FLJhRTutdCFANC8hIRwOnWTO /BDoB59BcO/pidk3SffhH0i4hLfklK1nCTezqeJDP5wpQ3ocL7xHsoj4dc5r3H6l+ji/IJWyp K44PKNO7V7xdlZbdI+luAkeLWRFCWKMlVURzwxqZmMkjWDgiFj3iGH+88nr7wx4DucGmppef8 3/+6O1yyEb2gDTTx9cVQ== 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 Reviewed-by: Simon Glass Reviewed-by: Simon Glass --- v3: no change 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: