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 8383AC433FE for ; Fri, 4 Nov 2022 22:50:20 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 82D8485191; Fri, 4 Nov 2022 23:49:19 +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="eS8vQKL/"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 03E63851E0; Fri, 4 Nov 2022 23:49:16 +0100 (CET) Received: from mail-io1-xd2c.google.com (mail-io1-xd2c.google.com [IPv6:2607:f8b0:4864:20::d2c]) (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 101818515A for ; Fri, 4 Nov 2022 23:49:10 +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-io1-xd2c.google.com with SMTP id 63so4920638iov.8 for ; Fri, 04 Nov 2022 15:49:09 -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=wD8yathGHSRBt8TWae2xRMB2tfvjm2qagyttCQ4miSo=; b=eS8vQKL/W6JM2+9yeOPyWq5rKJTMgvVkxefQSOS1lcRjWmEBqD1jnUn8dySV+HaDY9 TQLgUt3fMO911GNkCXSL11LO9UUCxSWV1pjSdWMkRU1g5UBD92h8sI432/bAMR0x1CkC PtzUAMnG3sBxZq6IFq3Otedu0S6kyG6KXkBCE= 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=wD8yathGHSRBt8TWae2xRMB2tfvjm2qagyttCQ4miSo=; b=Zg++cmLQ3fHPKyTdpS39cKIlx2+cVKb9pFVCYxdgROuTINDj95lQI44N3jFhREd4Ar a9aR2O1VesiRncb7lA5r62ILry+IOHRkYxa7/fP7obhpbFjkRIgg9mnI6U1GIyUDD0d9 qcfBcoaH0HUBMWtdaTJuJX9W4px5j/SHkLEQxNT34zqKUVTXB6MY1+K8sZnSNRgdVegd eQRLDXVbxLZBd3BNHbAgzhWWt8Mnye0nZSd/zfPE6xG07OBbOvnsNLs9Az8I1oOA58VW h6B3Tz950uB1yy3lGt4nfmqk/5qrNaQ/gHH7Mu3246gJfCjnI7zssm7QUTnlIchl9syM lJoA== X-Gm-Message-State: ACrzQf0tCLW3Bm6cIesuu2kIakoTABGIy418kxnlz7CpgvuCW3zGN090 74+ZGVKamnstcnJLwaXcrYHPFuChqj8hYw== X-Google-Smtp-Source: AMsMyM5PeEDY3Ik3eshB7xzMbqHohUF98/s9zqlkJ8r0lyfyRQssDLp5iNcPp/k31ExyNGa5W7jD6Q== X-Received: by 2002:a05:6602:2d8c:b0:6d4:cc5d:b94b with SMTP id k12-20020a0566022d8c00b006d4cc5db94bmr8840614iow.94.1667602148442; Fri, 04 Nov 2022 15:49:08 -0700 (PDT) Received: from sjg1.roam.corp.google.com (c-67-190-102-125.hsd1.co.comcast.net. [67.190.102.125]) by smtp.gmail.com with ESMTPSA id w24-20020a05663800d800b003734c4d01d2sm95189jao.61.2022.11.04.15.49.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Nov 2022 15:49:08 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Heinrich Schuchardt , Anatolij Gustschin , Simon Glass , Ilias Apalodimas , Masahisa Kojima Subject: [PATCH v2 03/25] bootmenu: Add a few comments Date: Fri, 4 Nov 2022 16:48:21 -0600 Message-Id: <20221104224844.467576-4-sjg@chromium.org> X-Mailer: git-send-email 2.38.1.431.g37b22c650d-goog In-Reply-To: <20221104224844.467576-1-sjg@chromium.org> References: <20221104224844.467576-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.38.1.431.g37b22c650d-goog