public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Eric Nelson <eric.nelson@boundarydevices.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] itest: Add bitwise and operator
Date: Fri, 03 May 2013 12:22:33 -0700	[thread overview]
Message-ID: <51840E79.3040309@boundarydevices.com> (raw)
In-Reply-To: <20130503190808.9404C38044A@gemini.denx.de>

Hi Wolfgang,

On 05/03/2013 12:08 PM, Wolfgang Denk wrote:
> Dear Eric Nelson,
>
> In message <1367606863-14846-1-git-send-email-eric.nelson@boundarydevices.com> you wrote:
>> Signed-off-by: Eric Nelson <eric.nelson@boundarydevices.com>
>> ---
>>   common/cmd_itest.c        |    4 ++++
>>   doc/README.commands.itest |   10 +++++++++-
>>   2 files changed, 13 insertions(+), 1 deletion(-)
>>
>> diff --git a/common/cmd_itest.c b/common/cmd_itest.c
>> index 2c8e5d0..0629b09 100644
>> --- a/common/cmd_itest.c
>> +++ b/common/cmd_itest.c
>> @@ -38,6 +38,7 @@
>>   #define GT	3
>>   #define LE	4
>>   #define GE	5
>> +#define AND	6
>
> It does not make much sense to me to add AND, when you not also add
> OR (and eventually XOR).
>

I only needed to test a bit.

> Also, now the help message is no longer correct - it says:
>
> 189 U_BOOT_CMD(
> 190         itest, 4, 0, do_itest,
> 191         "return true/false on integer compare",
> 192         "[.b, .w, .l, .s] [*]value1 <op> [*]value2"
> 193 );
>
> but we no longer compare...
>
> Hm, re-reading this I think this is the wrong approach.  This stuff
> does not belong into the "itest" command which really is for
> comparing, and NOT for operations on the arguments.
>
> If you need operations, then please use "setexpr" - which already has
> all of this, and more.
>

As always, thanks for the guidance.

I hadn't noticed that setexpr supported indirection.

In case this helps someone else, I was looking for
a way to detect Android "recovery" mode, which is
flagged by bit seven in the SRC_GPR10 register
(address 0x020d8044).

And setexpr can be used like so:

	U-Boot > md.l 0x020d8044
	020d8044: 00000080                               ....
	U-Boot > setexpr rval *0x020D8044 \& 0x80
	U-Boot > print rval
	rval=80
	U-Boot > setexpr rval *0x020D8044 \& 0x40
	U-Boot > print rval
	rval=0

Regards,


Eric

      reply	other threads:[~2013-05-03 19:22 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-03 18:47 [U-Boot] [PATCH] itest: Add bitwise and operator Eric Nelson
2013-05-03 19:08 ` Wolfgang Denk
2013-05-03 19:22   ` Eric Nelson [this message]

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=51840E79.3040309@boundarydevices.com \
    --to=eric.nelson@boundarydevices.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox