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 C1D47C4708D for ; Fri, 6 Jan 2023 14:54:21 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A49CC855FF; Fri, 6 Jan 2023 15:53:12 +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="JMF/K3Gi"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id BF7E6855F8; Fri, 6 Jan 2023 15:53:06 +0100 (CET) Received: from mail-il1-x131.google.com (mail-il1-x131.google.com [IPv6:2607:f8b0:4864:20::131]) (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 E1E5E855F5 for ; Fri, 6 Jan 2023 15:52:54 +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@chromium.org Received: by mail-il1-x131.google.com with SMTP id i16so563967ilq.9 for ; Fri, 06 Jan 2023 06:52:54 -0800 (PST) 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=/qQ2vfk1Z80ru4NrZJJlm6Impb5XATVrKXt9lcqJJLM=; b=JMF/K3GiCUQcYeanuG9sA8H5AHI3E9750gkv1pol+fHZa6TBDbm1rVqSa+i1See+yN oTzRogGga4VP/mAuSN40gavleUFw9ddZR685QN48yEpgO6BTmCdcDMPju4V2pOU1YDQF GXjDkf9Jv70C7Gk52OdAGifngJgTbRXI+bvsE= 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=/qQ2vfk1Z80ru4NrZJJlm6Impb5XATVrKXt9lcqJJLM=; b=wB3nTJ7BK+lBreYqKjwfdowQ+ff6ZE9bdTxodLeYqOOpUDv9BduOkHgDXYxxfqXEwf EKXRyzdexX80JDHQIRmuXZX1O5bfUp3//2be2tct2YjDp4uR2HWpcZViIauW8b9G20za exTVfzVqLZxtY8II6kbYNthoPsKdsKFjugcvXL09TQR6MYrFmfvKp6r3hLHdVgPHp2uo 3BDoiEaYO7dKWYJUlhOmpkZI3+u1ACCtswHsGsND7dub+GdSoq1VzpuYJpaWO5dyLK78 WhFu8MMnjqrX9xhM/00bKbI5pE1YIWf9ZlLQR1gLmEiQlDNc+A1xYJGiiuxHpuu3SmUf SHRw== X-Gm-Message-State: AFqh2kqBbpTgKbqBaPGENdnT9xiJrcWmM66MSVq2gO15WT6pgT3Fdmna zBWRgo1N9bIf9l+UR2bfizbLlJWAGv/wO3DIVhw= X-Google-Smtp-Source: AMrXdXuMkZVBjv0UvLxF8JYrVLtzBQ1z603WyJgg1PrwydhzDQuVU2kYxqVkm12his8X8yG9DuWb+g== X-Received: by 2002:a05:6e02:502:b0:30d:899f:aeda with SMTP id d2-20020a056e02050200b0030d899faedamr1892279ils.28.1673016773398; Fri, 06 Jan 2023 06:52:53 -0800 (PST) Received: from sjg1.lan (c-71-56-217-229.hsd1.co.comcast.net. [71.56.217.229]) by smtp.gmail.com with ESMTPSA id w20-20020a05663800d400b00375783003fcsm360273jao.136.2023.01.06.06.52.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Jan 2023 06:52:53 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Anatolij Gustschin , Tom Rini , Heinrich Schuchardt , Simon Glass Subject: [PATCH v3 03/25] bootmenu: Add a few comments Date: Fri, 6 Jan 2023 08:52:21 -0600 Message-Id: <20230106145243.411626-4-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog In-Reply-To: <20230106145243.411626-1-sjg@chromium.org> References: <20230106145243.411626-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 --- (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); -- 2.39.0.314.g84b9a713c41-goog