From mboxrd@z Thu Jan 1 00:00:00 1970 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 1872DC5479D for ; Sat, 7 Jan 2023 00:13:46 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4178185254; Sat, 7 Jan 2023 01:13:44 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org 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; unprotected) header.d=chromium.org header.i=@chromium.org header.b="YB/vp/5I"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0174385254; Sat, 7 Jan 2023 01:13:42 +0100 (CET) Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id F201381581 for ; Sat, 7 Jan 2023 01:13:38 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@google.com Received: by mail-ej1-x632.google.com with SMTP id vm8so7029219ejc.2 for ; Fri, 06 Jan 2023 16:13:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=WvQspZzOv0WFZ+ARNfD0dbA+GSfyVWEzTvJg+y18zXs=; b=YB/vp/5Id913c68G/Fbh644izHWo+dD+4Fg7gzZo6//02wWCukkxsUsoKhjW5oXHbG KiQdokKc7niCkqAfDvNrr1Sof/MQrWL9xkDqv/VVqJQOQWLgCoXqjIz7n0wwsBBxOWcV rxzRh+NnRqyaQ1fTt/NI5VQWAAu9idhwSi7Pk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=WvQspZzOv0WFZ+ARNfD0dbA+GSfyVWEzTvJg+y18zXs=; b=q2+XnSQu5opv72vF6NqKdDnL0IutKlyno8gbyG8QvJL7865jw64HF4H3Eop1grNSVy GfRguA4m2YjxxoRhK4tv0kFSFORFymZtf9+mDTCXheMunXeeg6AgNnzPyibL23EYxWSf COj1s9kWoAbwcXsG3rNvycfOkXxFULoPpxUOQGZHnYu3MyJIt0EQxrpMnU43DW8FfYg4 0Kg3osL7FeS30TMbMyCaaVruS/In3dSuKLC06qVqHsOau9qRpGnBVxiGlGzjyh545Gwq TRn5v79PYrSrLzfgWjDE3mTP9l6ZJdsz5rb6eTC6faPlRoKdDMafk9JYpFmL4HCnQ6f7 crHg== X-Gm-Message-State: AFqh2krkC3iqag3yeBmQ3PtelneYglU8jOHn2U7oDu+JhR1+Oo5ccKbi V/YxBDgqWjaZAxfBNnejwSBw4tqYVa8lVcyT+/81lA== X-Google-Smtp-Source: AMrXdXs4eGXniDAqZLWPREkNtUeSCeukCSxHvOSGtoA0o4mFTWKrmY9c5JRNJOEe0O2NS9OTQ52cPh1PgLmPpnBKA8U= X-Received: by 2002:a17:906:cb85:b0:7ea:608f:23bd with SMTP id mf5-20020a170906cb8500b007ea608f23bdmr6214650ejb.221.1673050418296; Fri, 06 Jan 2023 16:13:38 -0800 (PST) MIME-Version: 1.0 References: <20230106145243.411626-1-sjg@chromium.org> <20230106145243.411626-4-sjg@chromium.org> <05842fd7-0b91-7fed-bf71-d64f9607cf64@gmx.de> In-Reply-To: <05842fd7-0b91-7fed-bf71-d64f9607cf64@gmx.de> From: Simon Glass Date: Fri, 6 Jan 2023 17:13:24 -0700 Message-ID: Subject: Re: [PATCH v3 03/25] bootmenu: Add a few comments To: Heinrich Schuchardt Cc: Anatolij Gustschin , Tom Rini , U-Boot Mailing List Content-Type: text/plain; charset="UTF-8" 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 Hi Heinrich, On Fri, 6 Jan 2023 at 09:53, Heinrich Schuchardt wrote: > > On 1/6/23 15:52, Simon Glass wrote: > > The behaviour of these two functions is completely undocumented. Add some > > 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 = 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 auto boot > > + * of the first menu option. > > + * > > + * It then waits for the required time (menu->delay in seconds) for a key 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 disabled > > + * > > + * This is used when the menu delay is negative, indicating that the delay 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 has > > + * 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. This is a patch to add comments to code which is not otherwise addressed in this series. We need comments so that we know what things do. We can always adjust the logic later. My intent with this series is to add a new menu which is more flexible. Regards, Simon