Currently, there is not a good way to control script flow based on bitwise values. This initially led to NI adding the ability to read a specific bit from a port-mapped register to control bootflow.
Here, we add a more generic ability to test the bitwise AND of a value available to the grub scripting environment. This obviates the need for the inbit command (which is currently OOT). Signed-off-by: Brad Mouring <brad.mour...@ni.com> --- docs/grub.texi | 2 ++ grub-core/commands/test.c | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/docs/grub.texi b/docs/grub.texi index 82f6fa4..f28063e 100644 --- a/docs/grub.texi +++ b/docs/grub.texi @@ -5019,6 +5019,8 @@ the strings are not equal @var{integer1} is less than @var{integer2} @item @var{integer1} @code{-ne} @var{integer2} @var{integer1} is not equal to @var{integer2} +@item @var{integer1} @code{-bwa} @var{integer2} +Performs a bitwise AND between @var{integer1} and @var{integer2} @item @var{prefix}@var{integer1} @code{-pgt} @var{prefix}@var{integer2} @var{integer1} is greater than @var{integer2} after stripping off common non-numeric @var{prefix}. @item @var{prefix}@var{integer1} @code{-plt} @var{prefix}@var{integer2} diff --git a/grub-core/commands/test.c b/grub-core/commands/test.c index 5f06642..af4fad7 100644 --- a/grub-core/commands/test.c +++ b/grub-core/commands/test.c @@ -290,6 +290,16 @@ test_parse (char **args, int *argn, int argc) continue; } + /* GRUB extension: bitwise AND */ + if (grub_strcmp (args[*argn + 1], "-bwa") == 0) + { + update_val (grub_strtoul (args[*argn], 0, 0) + & grub_strtoul (args[*argn + 2], 0, 0), &ctx); + (*argn) += 3; + continue; + } + + /* -nt and -ot tests. GRUB extension: when doing -?t<bias> bias will be added to the first mtime. */ if (grub_memcmp (args[*argn + 1], "-nt", 3) == 0 -- 2.9.0 _______________________________________________ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel