From: Thiemo Seufer <ths@networkno.de>
To: Bin Chen <binary.chen@gmail.com>
Cc: linux-mips@linux-mips.org
Subject: Re: why not put 64 bit value directly to register
Date: Wed, 26 Apr 2006 12:28:09 +0100 [thread overview]
Message-ID: <20060426112809.GD29550@networkno.de> (raw)
In-Reply-To: <5800c1cc0604252149i55ab181ax7d9355a869a9b251@mail.gmail.com>
Bin Chen wrote:
> Hi,
>
> This code is snip from u-boot, I don't know why the 32bit-64bit conversion
> is needed, why not put val directly to register but do the transform?
>
> static void cvmx_write_cop0_entry_lo_0(uint64_t val)
> {
> uint32_t val_low = val & 0xffffffff;
> uint32_t val_high = val >> 32;
>
> uint32_t tmp; /* temp register */
>
> asm volatile (
> " .set mips64 \n"
> " .set noreorder \n"
> /* Standard twin 32 bit -> 64 bit construction */
> " dsll %[valh], 32 \n"
> " dla %[tmp], 0xffffffff \n"
> " and %[vall], %[tmp], %[vall] \n"
> " daddu %[valh], %[valh], %[vall] \n"
> /* Combined value is in valh */
> " dmtc0 %[valh],$2,0 \n"
> " .set reorder \n"
> :[tmp] "=&r" (tmp) : [valh] "r" (val_high), [vall] "r" (val_low) );
> }
This will convert on a 64bit capable MIPS CPU an o32 ABI register pair
holding a long long to a 64bit register value, and write that to a CP0
register.
It will break if an exception happens in between unless the exception
handlers save/restore the upper half as well.
Thiemo
prev parent reply other threads:[~2006-04-26 11:20 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-04-26 4:49 why not put 64 bit value directly to register Bin Chen
2006-04-26 11:28 ` Thiemo Seufer [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=20060426112809.GD29550@networkno.de \
--to=ths@networkno.de \
--cc=binary.chen@gmail.com \
--cc=linux-mips@linux-mips.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