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 1AADDC4332F for ; Mon, 17 Oct 2022 21:42:01 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9A3A284F41; Mon, 17 Oct 2022 23:41:59 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (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="Qp3BvO+I"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5587684F64; Mon, 17 Oct 2022 23:41:57 +0200 (CEST) Received: from mout.gmx.net (mout.gmx.net [212.227.15.15]) (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 8D23B84EAF for ; Mon, 17 Oct 2022 23:41:54 +0200 (CEST) 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.net; s=badeba3b8450; t=1666042913; bh=fcfrKZCLL2KA8/Iw3ALOBAuJgei3Mewotw3jhbGECSA=; h=X-UI-Sender-Class:Date:Subject:To:Cc:References:From:In-Reply-To; b=Qp3BvO+IQv3jaTWpS7pSlaaCEXvWAJqGHnjpQ7+Tfu0Km/3JjU4mtyCko8BfS3+zH Go6oqKxaE9ztGEu5Ps2ow7D6oX241PNj8KmELiCClfPdU1q/HJYjzTI3K1fdoGzd4R TBJkEmpsDshvuofxefTYl39jeHKSMTHFNwQu2tqg= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [192.168.123.94] ([84.118.157.2]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MC34h-1opnBs0LSH-00CUHp; Mon, 17 Oct 2022 23:41:53 +0200 Message-ID: <013cdc48-da87-d716-b6e7-8a8dfe08af5b@gmx.de> Date: Mon, 17 Oct 2022 23:41:52 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.3.3 Subject: Re: [PATCH 03/24] bootmenu: Add a few comments Content-Language: en-US To: Simon Glass Cc: Anatolij Gustschin , Tom Rini , Heinrich Schuchardt , Ilias Apalodimas , Masahisa Kojima , u-boot@lists.denx.de References: <20221017203000.2207887-1-sjg@chromium.org> <20221017203000.2207887-4-sjg@chromium.org> From: Heinrich Schuchardt In-Reply-To: <20221017203000.2207887-4-sjg@chromium.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:mmzMd7wJZdfTs8l/rSS4p8TsjrDe8osaaVo2xB+KhqlGTUuAazI XMoobrYOvsjjUauSbmBMM1WLu+NR7mefooQaPO6doMqeYl+hYEF55Ck4qOkT9am+83ZaESo Qq9LvRDKqkGotjkKl6yaOLlEPMJiB5w1LqxbbquE70UzBv8WVd5ohx6XyQnUXbEc5oOodMZ sRfU5VY7GUswKQRCio6Eg== X-UI-Out-Filterresults: notjunk:1;V03:K0:yBnEO+XATHY=:MeHFjAbQmBVWrtlh1MCXiJ RrCEseux51DwE/t5hN0oviBlambDOatrnYDEGtGT7cNCO5XOp4JS/TpFKqrL3reBNQj6cDUMY +46+FGILCTzndVnADPDNopvpOdtzgXbbwfJXqOsbTjbzbXBoLUY+ngp3X5Lw+alTtKYAXJlit qFafthoI4T84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MiX1N3OquLWae rK/XyBycLwc0GqBtoKqlpnhgbauNOvk34PzsI2ewodMBBpD1FOWolW2+jJqtTEifAm8IpHKmO +lNLpz0D8HvCr6tBoS2ijWuhgXntTvhpkGKTkMbQsC9dZeoavANX5hA/ai/M/2cpkhp7/Frl8 9PC9/2ttn/JeBfVeRqys0229kIYsSV0SU1cMt8/PuuBvms5PMQn7QqH2M/kVdWryceyztr2tp kUh0eIKvfr3jfoOphCqrqZtfpLKzArqgfVYDFgp9VRVA25bWZf7NgsywWJC0+6R89mtpqvHSz 5iXYpIoPpkBOogXlaB9UKYQd7VHuJuoWpsJo2J7LWGz/r 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 10/17/22 22:29, 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 > --- > > 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. Unfortunately the description does not match the code. This function is entered if some key was pressed, so autoboot was stopped. When the delay elapses the default action is taken by the caller. > + * > + * 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 We already discussed that this list is to change. We should support accelerator keys in menus. > + * @esc: On input, a non-zero value indicates that an escape sequence h= as 1 indicates that the ESC key has been pressed. All other values indicate that the ESC key has not been pressed. =2D- The whole design is broken in that the concept of a menu is not properly encapsulated. A function like bootmenu_autoboot_loop() should not be exported. The view side of a menu should be in a function that takes the following arguments: - the location (x,y) on the screen - the size (dx, dy) of the displayed menu (further items should be viewed by vertical scrolling, more characters by horizontal scrolling) - a list of menu items to display - a event function called whenever the selected menu item changes (or NULL= ) Such an event function will allow to display extra information for a menu item. The model would be an array of utf-8 strings. The controller will invoke the view function and receive the index of the selected item as the return value (or -1 if ESC is pressed). Best regards Heinrich > + * 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); >