Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EBD3EC4708D for ; Fri, 6 Jan 2023 15:53:10 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B7FCC85408; Fri, 6 Jan 2023 16:53:08 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (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 (2048-bit key; secure) header.d=gmx.de header.i=@gmx.de header.b="iBD9Kzlj"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 481658549F; Fri, 6 Jan 2023 16:53:07 +0100 (CET) Received: from mout.gmx.net (mout.gmx.net [212.227.15.18]) (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 5C38E853E0 for ; Fri, 6 Jan 2023 16:53:04 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (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.de; s=s31663417; t=1673020383; bh=k9+z7jsgZB1ytNb62xO0nqKRhkRwJTRgnTRlylHjxmI=; h=X-UI-Sender-Class:Date:Subject:To:Cc:References:From:In-Reply-To; b=iBD9KzljXdOXycqkc7aFwjYlX4Cdl9LE6fhwxKGPX+XeIhjkvgLyt5c4OwRXLfRE8 sHjsMgGhYSc4wIMDqEGai2LCqstYdI+Su9HPio1PWc4zytEaqkDp4TMPBL0u8GDcO4 i9TEnEayHhjfr8wkbbMoxQaxGjxYsIJztpS/W6shwZAbxYAXiqu93rZvWt6iJul09g nshS8OMqRHoO1A892dItpHaoHhAPgTrl+fXxIshUW1MmRgeSmDGBXoVLDWZJOIUM9j 90aYCkMCRE3XFKoIHaKErwmK/uOo7fBfaoL9s4vEn3yGRHDc2Oa/Cfh9uvM8QwogJt Wd18/090QN/tQ== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from [192.168.123.67] ([88.152.145.137]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1N0oBr-1otHpa0Nd7-00wj9D; Fri, 06 Jan 2023 16:53:03 +0100 Message-ID: <05842fd7-0b91-7fed-bf71-d64f9607cf64@gmx.de> Date: Fri, 6 Jan 2023 16:53:02 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.0 Subject: Re: [PATCH v3 03/25] bootmenu: Add a few comments Content-Language: en-US To: Simon Glass Cc: Anatolij Gustschin , Tom Rini , U-Boot Mailing List References: <20230106145243.411626-1-sjg@chromium.org> <20230106145243.411626-4-sjg@chromium.org> From: Heinrich Schuchardt In-Reply-To: <20230106145243.411626-4-sjg@chromium.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:20BQhjrmVuU55EdxyoVGHMETnJvkjeLGabnFECdv/l1ah/odyTF qSntU2rSldD8Ej2Pus+jJQFd/ggIYFyxADKD9MKMB32k2fOY90tA2pUT5coPLxbdvKdY0v2 1JFUkwgkkC2NTnfCDZNjjzV51okGmCRjrc2oMe4QE1n68KYayJ4S9TrD6cQiu4jw4vn0VVF seLbq4TitpQRtm5fLma0Q== UI-OutboundReport: notjunk:1;M01:P0:6OJXJ6SDOfU=;DgmYR0CKFN2oDmycvauP/hAdDoI zLuGwr5Vf+G8xDwpNP0UdcL5HXjV8834AtWd/8AvPWeH43H+N9WCVTLqXmvlANjeSN/NRbp+m wroFMSDFRTbX7neiVVjwrp3FieMDpiIRYQ69UImRuv52zQUgjmJuvoNEcxnlBqTis/7uVl52Q 9Hai6GsRzhuHY60PUfts0YsWXoWtud5eUBe0Qy2R8CaL0bnfyZ95DojTH9M/Q5U9s18+O8hBr cAnbydNol7FgLn8K2hY1C6kcXZQRhpioiVKr2DSfUHlEfn4DpV2HsE1KLl15dcqkTg1+98bBz LbI9kVZrxElEgGD7/CQuvp8izeWXzIV2g+8FQC65wpPGCE85VTjz33zUe8tiAshD4Klb2jWVJ LJ1/RQYEEqnOw7ufZZzJmeYkwyt4C97Bg+NGXxPW4mEYlOz4Z/MInDW340beblj/KB2AM8YYL RvaDyE4kK7BGvockI4fdDafXSB1BrdmYBTxPpqo5oyN4sQmSSPNIf7p7hIBaKepIAJFnkQSNA 4kp6QcdsqkbHQ5uFYZUr/SdDHefbhVSAImDnrQ6P3gUCRCfoORbBHG5nY0uoFAHu9LhD/Wg8w GQt5gOazvx6yM7IgSUShXJeqTCpNwLTIkU0p8XB7QAv0W24ynorc7t9wY6CHWgviHVrkGOrHn xVjT40qpWYLlr9Ka7IS4EtSMtHerd0BlfNwzumCeMvQn3zmB52u1q0rqFhF2LYlmHJRX8ZYlG YA6uoq5ztxr7LqHXPsE1GS9AHU4vKAitDipsiAuUp1qe1IVF+/Luw3Q7RvEeA6Ow9XEFgddNP HbSx87uyJI9DV/LEvb4/f9cGOxaXunL/h/XOehd5tx2qzr1xNJaPvnbomLtteAJnJ93ofna+r 6vXLsgq9ejLXSqIyk5GJddAZXw22v5QA2mgdU5cr7sguz36RLTYKka57SEOQq8q5c3r5m86bG UH6NavyTFEGHfH+oD/d5qWiFfN0= X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.6 at phobos.denx.de X-Virus-Status: Clean On 1/6/23 15:52, Simon Glass wrote: > The behaviour of these two functions is completely undocumented. Add som= e > notes so the poor, suffering dev can figure out what is going on. > > Signed-off-by: Simon Glass > --- > > (no changes since v1) > > include/menu.h | 42 ++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 42 insertions(+) > > diff --git a/include/menu.h b/include/menu.h > index 702aacb170c..0b4d9734149 100644 > --- a/include/menu.h > +++ b/include/menu.h > @@ -42,6 +42,7 @@ struct bootmenu_data { > struct bootmenu_entry *first; /* first menu entry */ > }; > > +/** enum bootmenu_key - keys that can be returned by the bootmenu */ > enum bootmenu_key { > KEY_NONE =3D 0, > KEY_UP, > @@ -53,8 +54,49 @@ enum bootmenu_key { > KEY_SPACE, > }; > > +/** > + * bootmenu_autoboot_loop() - handle autobooting if no key is pressed > + * > + * This shows a prompt to allow the user to press a key to interrupt au= to boot > + * of the first menu option. > + * > + * It then waits for the required time (menu->delay in seconds) for a k= ey to be > + * pressed. If nothing is pressed in that time, @key returns KEY_SELECT > + * indicating that the current option should be chosen. > + * > + * @menu: Menu being processed > + * @key: Returns the code for the key the user pressed: > + * enter: KEY_SELECT > + * Ctrl-C: KEY_QUIT > + * anything else: KEY_NONE > + * @esc: Set to 1 if the escape key is pressed, otherwise not updated > + */ > void bootmenu_autoboot_loop(struct bootmenu_data *menu, > enum bootmenu_key *key, int *esc); > + > +/** > + * bootmenu_loop() - handle waiting for a keypress when autoboot is dis= abled > + * > + * This is used when the menu delay is negative, indicating that the de= lay has > + * elapsed, or there was no delay to begin with. > + * > + * It reads a character and processes it, returning a menu-key code if = a > + * character is recognised > + * > + * @menu: Menu being processed > + * @key: Returns the code for the key the user pressed: > + * enter: KEY_SELECT > + * Ctrl-C: KEY_QUIT > + * Up arrow: KEY_UP > + * Down arrow: KEY_DOWN > + * Escape (by itself): KEY_QUIT > + * Plus: KEY_PLUS > + * Minus: KEY_MINUS > + * Space: KEY_SPACE > + * @esc: On input, a non-zero value indicates that an escape sequence h= as > + * resulted in that many characters so far. On exit this is updated to = the > + * new number of characters > + */ > void bootmenu_loop(struct bootmenu_data *menu, > enum bootmenu_key *key, int *esc); This should not be an exported function. The program part that wants to display a menu should not have to deal with navigation keys. Best regards Heinrich