From: Heinrich Schuchardt <xypron.glpk@gmx.de>
To: u-boot@lists.denx.de
Subject: [PATCH 4/5] sandbox: implement reset
Date: Tue, 27 Oct 2020 09:02:28 +0100 [thread overview]
Message-ID: <3d7f163f-092d-059f-39be-ad817fda5808@gmx.de> (raw)
In-Reply-To: <CAPnjgZ2qX2tf66r5G-zy9H2qofs=J0UW5HLO0YANtw0BohP_FQ@mail.gmail.com>
On 27.10.20 05:52, Simon Glass wrote:
> Hi Heinrich,
>
> On Sun, 25 Oct 2020 at 00:04, Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:
>>
>> Up to now the sandbox would shutdown upon a cold reset request. Instead it
>> should be reset.
>>
>> In our coding we use static variables. The only safe way to return to an
>> initial state is to relaunch the U-Boot binary.
>
> This is unfortunate, but I suspect you may be right. Have you looked at it?
>
>>
>> The reset implementation uses a longjmp() to return to the main() function
>> and then relaunches U-Boot using execv().
>>
>> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
>> ---
>> arch/sandbox/cpu/os.c | 14 ++++++++++++++
>> arch/sandbox/cpu/start.c | 22 ++++++++++++++++++++++
>> arch/sandbox/cpu/state.c | 1 +
>> arch/sandbox/include/asm/u-boot-sandbox.h | 3 +++
>> drivers/sysreset/sysreset_sandbox.c | 3 +++
>> include/os.h | 5 +++++
>> 6 files changed, 48 insertions(+)
>>
>> diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c
>> index c461fb0db0..ed044e87fb 100644
>> --- a/arch/sandbox/cpu/os.c
>> +++ b/arch/sandbox/cpu/os.c
>> @@ -817,3 +817,17 @@ void *os_find_text_base(void)
>>
>> return base;
>> }
>> +
>> +void os_relaunch(int argc, char *argv[])
>> +{
>> + char **args;
>> +
>> + args = calloc(argc + 1, sizeof(char *));
>> + if (!args)
>> + goto out;
>> + memcpy(args, argv, sizeof(char *) * argc);
>> + args[argc] = NULL;
>> + execv(args[0], args);
>> +out:
>> + os_exit(1);
>> +}
>> diff --git a/arch/sandbox/cpu/start.c b/arch/sandbox/cpu/start.c
>> index c6a2bbe468..ee1d4b9581 100644
>> --- a/arch/sandbox/cpu/start.c
>> +++ b/arch/sandbox/cpu/start.c
>> @@ -5,6 +5,7 @@
>>
>> #include <common.h>
>> #include <command.h>
>> +#include <dm/root.h>
>
> Put before linux/ below
https://www.denx.de/wiki/U-Boot/CodingStyle does not allow this. It
requires: "Within that order, sort your includes.". Alphabetically dm/*
goes before errno.h.
Should the driver model require anything else, please, update the coding
style guideline accordingly. Looking at dm/root.h I cannot see any such
requirement.
I think we should move the code style guideline to the HTML
documentation and get rid of the Wiki page.
Best regards
Heinrich
>
>> #include <errno.h>
>> #include <init.h>
>> #include <os.h>
>> @@ -14,11 +15,15 @@
>> #include <asm/io.h>
>> #include <asm/malloc.h>
>> #include <asm/sections.h>
>> +#include <asm/setjmp.h>
>> #include <asm/state.h>
>> #include <linux/ctype.h>
>>
>> DECLARE_GLOBAL_DATA_PTR;
next prev parent reply other threads:[~2020-10-27 8:02 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-25 6:04 [PATCH 0/5] sandbox: implement cold reset Heinrich Schuchardt
2020-10-25 6:04 ` [PATCH 1/5] sandbox: eth-raw: do not close the console input Heinrich Schuchardt
2020-10-27 4:52 ` Simon Glass
2020-10-25 6:04 ` [PATCH 2/5] sandbox: enable poweroff command Heinrich Schuchardt
2020-10-27 4:52 ` Simon Glass
2020-10-25 6:04 ` [PATCH 3/5] test/py: test poweroff Heinrich Schuchardt
2020-10-27 4:52 ` Simon Glass
2020-10-25 6:04 ` [PATCH 4/5] sandbox: implement reset Heinrich Schuchardt
2020-10-27 4:52 ` Simon Glass
2020-10-27 7:29 ` Heinrich Schuchardt
2020-10-27 8:02 ` Heinrich Schuchardt [this message]
2020-10-27 12:12 ` Rasmus Villemoes
2020-10-27 13:33 ` Heinrich Schuchardt
2020-10-27 14:36 ` Rasmus Villemoes
2020-10-27 15:38 ` Heinrich Schuchardt
2020-10-25 6:04 ` [PATCH 5/5] test: adjust sysreset tests Heinrich Schuchardt
2020-10-27 4:52 ` Simon Glass
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3d7f163f-092d-059f-39be-ad817fda5808@gmx.de \
--to=xypron.glpk@gmx.de \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox