From: Lukasz Majewski <lukma@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v1 2/5] bootcount: Add function wrappers to handle bootcount increment and error checking
Date: Sat, 10 Feb 2018 11:20:29 +0100 [thread overview]
Message-ID: <20180210102032.315-3-lukma@denx.de> (raw)
In-Reply-To: <20180210102032.315-1-lukma@denx.de>
Those two functions can be used in either SPL or U-boot proper to provide
easy bootcount management.
Signed-off-by: Lukasz Majewski <lukma@denx.de>
---
include/bootcount.h | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/include/bootcount.h b/include/bootcount.h
index 06fb4d3578..534875a5a5 100644
--- a/include/bootcount.h
+++ b/include/bootcount.h
@@ -38,3 +38,28 @@ static inline u32 raw_bootcount_load(volatile u32 *addr)
return in_be32(addr);
}
#endif
+
+#ifdef CONFIG_SPL_BOOTCOUNT_LIMIT
+static inline bool bootcount_error(void)
+{
+ unsigned long bootcount = bootcount_load();
+ unsigned long bootlimit = env_get_ulong("bootlimit", 10, 0);
+
+ if (bootlimit && (bootcount >= bootlimit)) {
+ printf("Warning: Bootlimit (%lu) exceeded.\n", bootcount);
+ return true;
+ }
+
+ return false;
+}
+
+static inline void bootcount_inc(void)
+{
+ unsigned long bootcount = bootcount_load();
+
+ bootcount_store(++bootcount);
+}
+#else
+static inline bool bootcount_error(void) { return false; }
+static inline void bootcount_inc(void) {}
+#endif /* CONFIG_SPL_BOOTCOUNT_LIMIT */
--
2.11.0
next prev parent reply other threads:[~2018-02-10 10:20 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-10 10:20 [U-Boot] [PATCH v1 0/5] Provide SPL support for bootcount (in the case of using falcon boot mode) Lukasz Majewski
2018-02-10 10:20 ` [U-Boot] [PATCH v1 1/5] bootcount: config: Make the SYS_BOOTCOUNT_ADDR available also for non EXT setups Lukasz Majewski
2018-02-12 7:31 ` [U-Boot] EXT: " Ray, Ian
2018-02-10 10:20 ` Lukasz Majewski [this message]
2018-02-10 10:20 ` [U-Boot] [PATCH v1 3/5] spl: bootcount: Enable bootcount support in SPL Lukasz Majewski
2018-02-10 10:20 ` [U-Boot] [PATCH v1 4/5] config: display5: Enable boot count feature in the display5 board Lukasz Majewski
2018-02-10 10:20 ` [U-Boot] [PATCH v1 5/5] arm: display5: Extend SPL to support bootcount checking Lukasz Majewski
-- strict thread matches above, loose matches on Subject: below --
2018-02-26 12:22 [U-Boot] [PATCH v1 0/5] Provide SPL support for bootcount (in the case of using falcon boot mode) Lukasz Majewski
2018-02-26 12:22 ` [U-Boot] [PATCH v1 2/5] bootcount: Add function wrappers to handle bootcount increment and error checking Lukasz Majewski
2018-02-26 14:27 ` Tom Rini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180210102032.315-3-lukma@denx.de \
--to=lukma@denx.de \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.