qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Scott Wood <scottwood@freescale.com>
To: Fabien Chouteau <chouteau@adacore.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH V2] [PowerPC][RFC] booke timers
Date: Tue, 5 Jul 2011 11:02:22 -0500	[thread overview]
Message-ID: <20110705110222.1ef56c46@schlenkerla.am.freescale.net> (raw)
In-Reply-To: <4E11D70E.4070808@adacore.com>

On Mon, 4 Jul 2011 17:06:54 +0200
Fabien Chouteau <chouteau@adacore.com> wrote:

> On 01/07/2011 22:22, Scott Wood wrote:
> > On Fri, 1 Jul 2011 16:13:41 +0200
> > Fabien Chouteau <chouteau@adacore.com> wrote:
> >> +static void booke_update_fixed_timer(CPUState         *env,
> >> +                                     uint8_t           target_bit,
> >> +                                     uint64_t          *next,
> >> +                                     struct QEMUTimer *timer)
> >> +{
> >> +    ppc_tb_t *tb_env = env->tb_env;
> >> +    uint64_t lapse;
> >> +    uint64_t tb;
> >> +    uint64_t period = 1 << (target_bit + 1);
> >> +    uint64_t now;
> >> +
> >> +    now = qemu_get_clock_ns(vm_clock);
> >> +    tb  = cpu_ppc_get_tb(tb_env, now, tb_env->tb_offset);
> >> +
> >> +    if (tb <= (1 << target_bit)) {
> >> +        lapse = (1 << target_bit) - tb;
> >> +    } else {
> >> +        lapse = period - ((tb - (1 << target_bit)) % period);
> > 
> > We know period is a power of two, so just do "& (period - 1)".
> > 
> > That should let you get rid of the special case for
> > "tb <= (1 << target_bit)" as well.
> > 
> 
> Do you mean "lapse = period - ((tb - (1 << target_bit)) & (period - 1));" ?

Yes.

Or more simply:

lapse = period - ((tb - period) & (period - 1));

> I don't see how this solves the "tb <= (1 << target_bit)" case.

Actually, since everything is unsigned the special case shouldn't be needed
regardless.

-Scott

  reply	other threads:[~2011-07-05 16:03 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-01 14:13 [Qemu-devel] [PATCH V2] [PowerPC][RFC] booke timers Fabien Chouteau
2011-07-01 20:22 ` Scott Wood
2011-07-04 15:06   ` Fabien Chouteau
2011-07-05 16:02     ` Scott Wood [this message]
2011-07-05 16:41       ` Fabien Chouteau
2011-07-05 18:05         ` Scott Wood

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=20110705110222.1ef56c46@schlenkerla.am.freescale.net \
    --to=scottwood@freescale.com \
    --cc=chouteau@adacore.com \
    --cc=qemu-devel@nongnu.org \
    /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;
as well as URLs for NNTP newsgroup(s).