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 55825C433FE for ; Mon, 17 Oct 2022 20:31:41 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2F5E484F4B; Mon, 17 Oct 2022 22:30:34 +0200 (CEST) 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="LGd4SiVO"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 60BA584F81; Mon, 17 Oct 2022 22:30:28 +0200 (CEST) Received: from mail-il1-x129.google.com (mail-il1-x129.google.com [IPv6:2607:f8b0:4864:20::129]) (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 D3F2F84F4E for ; Mon, 17 Oct 2022 22:30:17 +0200 (CEST) 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@chromium.org Received: by mail-il1-x129.google.com with SMTP id a17so6464054ilq.1 for ; Mon, 17 Oct 2022 13:30:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ProtsPaRANv79ObvEufNYvoUfHaoxrKUAiH7qQ82Qbk=; b=LGd4SiVORN3W63Lo7WWKvNrA3Xmz8o/inDOw1dG5hp3HFO/Hi62zLvwaanJv7bZ2Kd yOzCnEe31VYtil03uZ551Q9/JYKxDjyg+gOZLxulXrJLVAY5FE2NHIZJFsFu92TEU2sQ 9um4TDIKJR24Rkoigw1tQBCv1Pm8l9uglm9Yo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ProtsPaRANv79ObvEufNYvoUfHaoxrKUAiH7qQ82Qbk=; b=tkTlGqu+z0f7oaLYF9WBUCgMANbvMZ8gjbwG5ZKmsZQtDc9PXYDRGdFCE1cjyGLley ubDZUCk0G336pEc6MZIQe/rXjuPHDuXdyqBNYblfU5ev3AJBjNS45k/1iGdK+WdewjFp BU78bYi6KrzLadWxA9RA7/8VkqQpw8pwe0Pwpa3yxUrIgoAjdyA3T8/233wq5TCEkMwh 9Gn+ukgBzMNmAp49d3IEliVO+8NUn5lLxTaADNTpjuZXcE9Gpx6Qc6QQKC0LutzwlRcn rqRwer4JG35DdHa+pLEJH0gaH3VKeXkmPEMqmlbvuYhy0aIlrToEct8QDJHXFWh+n4yM 3cRg== X-Gm-Message-State: ACrzQf3/6blKbOf4mIjTNWa4QqTAztEWmTu6KPjaUNSD3GDf9UxqUGF/ e8lkiwIhnzvndL4qUu5SvIKEhT+5NNJcjQ== X-Google-Smtp-Source: AMsMyM7CQ25Gn2x400ov8ttPR4NpXeeXNWj2sQAvYTy1aEcoLiRSzMUnRUhGZO5whwripKr0doGIGg== X-Received: by 2002:a92:504:0:b0:2fb:43d:2271 with SMTP id q4-20020a920504000000b002fb043d2271mr5852636ile.256.1666038615964; Mon, 17 Oct 2022 13:30:15 -0700 (PDT) Received: from kea.bld.corp.google.com ([2620:15c:183:200:91e:7804:2764:d161]) by smtp.gmail.com with ESMTPSA id j9-20020a926e09000000b002e939413e83sm258071ilc.48.2022.10.17.13.30.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Oct 2022 13:30:15 -0700 (PDT) From: Simon Glass To: u-boot@lists.denx.de Cc: Anatolij Gustschin , Tom Rini , Simon Glass , Heinrich Schuchardt , Ilias Apalodimas , Masahisa Kojima Subject: [PATCH 03/24] bootmenu: Add a few comments Date: Mon, 17 Oct 2022 14:29:39 -0600 Message-Id: <20221017203000.2207887-4-sjg@chromium.org> X-Mailer: git-send-email 2.38.0.413.g74048e4d9e-goog In-Reply-To: <20221017203000.2207887-1-sjg@chromium.org> References: <20221017203000.2207887-1-sjg@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 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 --- 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); -- 2.38.0.413.g74048e4d9e-goog