* Re: need a fast byteorder changing routine
[not found] <Xx969281867387.18796@webmail1.inner-21cn.com>
@ 2003-07-18 6:26 ` Wojciech Kromer
0 siblings, 0 replies; 4+ messages in thread
From: Wojciech Kromer @ 2003-07-18 6:26 UTC (permalink / raw)
To: Linuxppc-Embedded (E-mail)
Użytkownik li napisał:
>Hi all,
>i need do a lot of byteorder changing operation from big-endian to little-endian. cpu_to_le32 is not fast enough for me, does anyone have such a routine written in asm.?
>PS: here is an ugly asm function do such thing:
>void swapbyte(unsigned long *val, unsigned long offset,
> unsigned long value)
>{
>
> asm ("lis 3 %0@ha" : "=r" (val));
> asm ("lwz 3,%0@l(3)" : "=r" (val));
> asm ("stw %1, 0(4)" : "=r" (offset));
> asm ("stw %2, 0(5)" : "=r" (value));
> asm ("stwbrx 5, 3, 4");
>}val is the address of value. i used to set this function as inline, but kernel said:
>Oops: kernel access of bad area, sig: 11
>Any comments
>Best Regards!
>Li
>
>
>
>
>
try DIRECT using out_le16/32 in_le16/32 from <asm/io.h>,
this takes same time as one big endian write/read
--
* * * * * * * * * * * *
* per pedes ad astra! *
* * * * * * * * * * * * mailto:krom@dgt-lab.com.pl
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: need a fast byteorder changing routine
2003-07-18 13:24 Wells, Charles
@ 2003-07-18 14:35 ` Peter Barada
0 siblings, 0 replies; 4+ messages in thread
From: Peter Barada @ 2003-07-18 14:35 UTC (permalink / raw)
To: Charles.Wells; +Cc: slowforce, linuxppc-embedded
>Li,
>
>If you must do it one word at a time, the following works.
>
>long SwapBytes(long* p)
>{
> __asm__(" lwbrx 3,0,3");
>}
>
>Charlie
And if you want it inlined:
static inline unsigned long loadWordAndSwapBytes(unsigned long *p)
{
unsigned long val;
__asm__ ("lwbrx %0,0,%1" : "=r" (val) : "r" (p));
return val;
}
--
Peter Barada Peter.Barada@motorola.com
Wizard 781-852-2768 (direct)
WaveMark Solutions(A Motorola Company) 781-270-0193 (fax)
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: need a fast byteorder changing routine
@ 2003-07-18 13:24 Wells, Charles
2003-07-18 14:35 ` Peter Barada
0 siblings, 1 reply; 4+ messages in thread
From: Wells, Charles @ 2003-07-18 13:24 UTC (permalink / raw)
To: 'li'; +Cc: linuxppc-embedded
Li,
If you must do it one word at a time, the following works.
long SwapBytes(long* p)
{
__asm__(" lwbrx 3,0,3");
}
Charlie
-----Original Message-----
From: Wells, Charles [mailto:Charles.Wells@nielsenmedia.com]
Sent: Friday, July 18, 2003 9:04 AM
To: 'li'
Cc: linuxppc-embedded@lists.linuxppc.org
Subject: RE: need a fast byteorder changing routine
Li,
There's several ways of doing it. This way is pretty fast and makes few
assumptions about the buffer.
void FixEndian(long* buf, unsigned long num_longs)
{
__asm__(" addi 3,3,-4");
__asm__(" mtspr 9,4");
__asm__(" lwzu 4,4(3)");
__asm__(" stwbrx 4,0,3");
__asm__(" bc 16,0,$-8");
}
Charlie
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: need a fast byteorder changing routine
@ 2003-07-18 13:03 Wells, Charles
0 siblings, 0 replies; 4+ messages in thread
From: Wells, Charles @ 2003-07-18 13:03 UTC (permalink / raw)
To: 'li'; +Cc: linuxppc-embedded
Li,
There's several ways of doing it. This way is pretty fast and makes few
assumptions about the buffer.
void FixEndian(long* buf, unsigned long num_longs)
{
__asm__(" addi 3,3,-4");
__asm__(" mtspr 9,4");
__asm__(" lwzu 4,4(3)");
__asm__(" stwbrx 4,0,3");
__asm__(" bc 16,0,$-8");
}
Charlie
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2003-07-18 14:35 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <Xx969281867387.18796@webmail1.inner-21cn.com>
2003-07-18 6:26 ` need a fast byteorder changing routine Wojciech Kromer
2003-07-18 13:03 Wells, Charles
2003-07-18 13:24 Wells, Charles
2003-07-18 14:35 ` Peter Barada
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.