Linux MIPS Architecture development
 help / color / mirror / Atom feed
* Questions?
@ 2002-03-06 17:25 Marc Karasek
  2002-03-06 18:20 ` Questions? Steven J. Hill
                   ` (5 more replies)
  0 siblings, 6 replies; 19+ messages in thread
From: Marc Karasek @ 2002-03-06 17:25 UTC (permalink / raw)
  To: Linux MIPS

I have some general questions for all:

How many of you are involved with embedded linux development using a
MIPS processor? 

What endianess have you chosen for your project and why? 

If you have not guessed it, I am involved with a MIPS/Linux embedded
project and we are trying to determine if there are any pros or cons in
one endianess over the other.  

-- 
/*************************
Marc Karasek
Sr. Firmware Engineer
iVivity Inc.
marc_karasek@ivivity.com
678.990.1550 x238
678.990.1551 Fax
*************************/

^ permalink raw reply	[flat|nested] 19+ messages in thread
* RE: Questions?
@ 2002-03-06 20:40 Marc Karasek
  2002-03-06 20:41 ` Questions? Matthew Dharm
  0 siblings, 1 reply; 19+ messages in thread
From: Marc Karasek @ 2002-03-06 20:40 UTC (permalink / raw)
  To: 'Matthew Dharm', Linux MIPS

What kernel/tools do you provide?

-----Original Message-----
From: Matthew Dharm [mailto:mdharm@momenco.com]
Sent: Wednesday, March 06, 2002 2:45 PM
To: Marc Karasek; Linux MIPS
Subject: RE: Questions?


My company develops embedded MIPS systems, and Linux is one of our
supported operating systems.

We chose big-endian, mostly because it seemed the right choice given
the state of the tree.  Some customers have recompiled our code to run
little-endian with little problem, tho.

Matt

--
Matthew D. Dharm                            Senior Software Designer
Momentum Computer Inc.                      1815 Aston Ave.  Suite 107
(760) 431-8663 X-115                        Carlsbad, CA 92008-7310
Momentum Works For You                      www.momenco.com

> -----Original Message-----
> From: owner-linux-mips@oss.sgi.com
> [mailto:owner-linux-mips@oss.sgi.com]On Behalf Of Marc Karasek
> Sent: Wednesday, March 06, 2002 9:25 AM
> To: Linux MIPS
> Subject: Questions?
>
>
> I have some general questions for all:
>
> How many of you are involved with embedded linux development using a
> MIPS processor?
>
> What endianess have you chosen for your project and why?
>
> If you have not guessed it, I am involved with a MIPS/Linux embedded
> project and we are trying to determine if there are any
> pros or cons in
> one endianess over the other.
>
> --
> /*************************
> Marc Karasek
> Sr. Firmware Engineer
> iVivity Inc.
> marc_karasek@ivivity.com
> 678.990.1550 x238
> 678.990.1551 Fax
> *************************/
>

^ permalink raw reply	[flat|nested] 19+ messages in thread
* RE: Questions?
@ 2002-03-07 19:19 Siders, Keith
  2002-03-07 21:00 ` Questions? Richard Hodges
  0 siblings, 1 reply; 19+ messages in thread
From: Siders, Keith @ 2002-03-07 19:19 UTC (permalink / raw)
  To: Linux MIPS

You can get that down to 5 instructions. You could either use a typecast, or
for portability, use a union definition. For that matter you could even
typecast *mptr as a pointer to the union and extract the data from the
string however you choose. But it still takes 5 instructions, unless you're
pulling the data into another buffer, in which case you're down to 4.

Keith

-> -----Original Message-----
-> From: Richard Hodges [mailto:rh@matriplex.com]
-> Sent: Thursday, March 07, 2002 11:57 AM
-> To: Ralf Baechle
-> Cc: Linux MIPS
-> Subject: Re: Questions?
-> 
-> 
-> On Thu, 7 Mar 2002, Ralf Baechle wrote:
-> 
-> > The MIPS ABI only covers big endian systems - every "real" 
-> MIPS UNIX
-> > system is big endian.  Everything else is a GNU extension. 
->  There is
-> > hardly any reason to choose a particular byteorder as 
-> usually endianess
-> > swapping takes so little CPU time that it isn't even 
-> meassurable but so
-> > I'm told there are exceptions.
-> 
-> To me, byte swapping on MIPS actually seems rather 
-> expensive.  The code
-> for htonl (linux/byteorder/swab.h) ends up something like this:
-> 
->         srl     $5,$4,8
->         andi    $5,$5,0xff00
->         srl     $2,$4,24
->         andi    $3,$4,0xff00
->         or      $2,$2,$5
->         sll     $3,$3,8
->         or      $2,$2,$3
->         sll     $4,$4,24
-> 
-> This may not be an issue if it is only needed a few times 
-> per packet, but
-> my system must byte-swap (LE to BE) about 500KB (or 4mb) per second.
-> Actually, I save a bit of work by combining the byte 
-> swapping with the
-> memory move, just after copy_from_user, and looks something like:
-> 
->     unsigned char a, b, c, d, *mptr;
-> 	a = mptr[0];
-> 	b = mptr[1];
-> 	c = mptr[2];
-> 	d = mptr[3];
-> 	mptr[0] = d;
-> 	mptr[1] = c;
-> 	mptr[2] = b;
-> 	mptr[3] = a;
-> 
-> This method works, but it is still 8 instructions per word.  
-> Yuck!  Does
-> anyone know of a _decent_ way to handle this on MIPS?
-> 
-> All the best,
-> 
-> -Richard
-> 

^ permalink raw reply	[flat|nested] 19+ messages in thread
* RE: Questions?
@ 2002-03-07 21:44 Siders, Keith
  0 siblings, 0 replies; 19+ messages in thread
From: Siders, Keith @ 2002-03-07 21:44 UTC (permalink / raw)
  To: 'Richard Hodges'; +Cc: Linux MIPS

Hmm, assembly or C? Your original message had examples in both. In C the
large part is the definitions in the union. 

If you define

struct le_bitfield {
	unsigned long low:8;
	unsigned long lmid:8;
	unsigned long hmid:8;
	unsigned long high:8;
};

struct be_bitfield {
	unsigned long high:8;
	unsigned long hmid:8;
	unsigned long lmid:8;
	unsigned long low:8;
};

union byte_swap {
	unsigned long original;
	struct le_bitfield le;
	struct be_bitfield be;
}swapper;

Now you can use your previous char pointer

	swapper.original = *((unsigned long *)mptr);
	mptr[0] = swapper.le.low;
	mptr[1] = swapper.le.lmid;
	mptr[2] = swapper.le.hmid;
	mptr[3] = swapper.le.high;

5 instructions in C.

To swap the other way, just use swapper.be.xxxx. If this still translates to
8 assembly instructions (or worse), oh well... just trying to help. ;)



-> -----Original Message-----
-> From: Richard Hodges [mailto:rh@matriplex.com]
-> Sent: Thursday, March 07, 2002 3:00 PM
-> To: Siders, Keith
-> Cc: Linux MIPS
-> Subject: RE: Questions?
-> 
-> 
-> On Thu, 7 Mar 2002, Siders, Keith wrote:
-> 
-> > You can get that down to 5 instructions. You could either 
-> use a typecast, or
-> > for portability, use a union definition. For that matter 
-> you could even
-> > typecast *mptr as a pointer to the union and extract the 
-> data from the
-> > string however you choose. But it still takes 5 
-> instructions, unless you're
-> > pulling the data into another buffer, in which case you're 
-> down to 4.
-> 
-> Which 5 instructions are those?  For htonl from memory, the 
-> only sequence
-> I can think of is the "obvious" one of lbu/shift (7 
-> instructions).  And
-> for swapping BE-LE in memory (an important thing for me), I 
-> do not see any
-> method better than the "obvious" one I mentioned earlier:
-> 
->     90c50000        lbu     a1,0(a2)
->     90c40001        lbu     a0,1(a2)
->     90c30002        lbu     v1,2(a2)
->     90c20003        lbu     v0,3(a2)
->     a0c20000        sb      v0,0(a2)
->     a0c30001        sb      v1,1(a2)
->     a0c40002        sb      a0,2(a2)
->     a0c50003        sb      a1,3(a2)
-> 
-> Thanks,
-> 
-> -Richard
-> 
-> > -> From: Richard Hodges [mailto:rh@matriplex.com]
-> 
-> > -> To me, byte swapping on MIPS actually seems rather 
-> > -> expensive.  The code
-> > -> for htonl (linux/byteorder/swab.h) ends up something like this:
-> > -> 
-> > ->         srl     $5,$4,8
-> > ->         andi    $5,$5,0xff00
-> > ->         srl     $2,$4,24
-> > ->         andi    $3,$4,0xff00
-> > ->         or      $2,$2,$5
-> > ->         sll     $3,$3,8
-> > ->         or      $2,$2,$3
-> > ->         sll     $4,$4,24
-> 
-> 

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2002-03-08 10:59 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-03-06 17:25 Questions? Marc Karasek
2002-03-06 18:20 ` Questions? Steven J. Hill
2002-03-06 18:43   ` Questions? Marc Karasek
2002-03-06 18:54     ` Questions? Hartvig Ekner
2002-03-06 18:54       ` Questions? Hartvig Ekner
2002-03-06 19:06 ` Questions? Mike McDonald
2002-03-06 19:44 ` Questions? Matthew Dharm
2002-03-06 20:32 ` Questions? Bradley D. LaRonde
2002-03-07 10:59 ` Questions? Dominic Sweetman
2002-03-07 13:07 ` Questions? Ralf Baechle
2002-03-07 13:11   ` Questions? Geert Uytterhoeven
2002-03-07 13:18     ` Questions? Ralf Baechle
2002-03-07 17:56   ` Questions? Richard Hodges
2002-03-08  9:58   ` Questions? Dominic Sweetman
  -- strict thread matches above, loose matches on Subject: below --
2002-03-06 20:40 Questions? Marc Karasek
2002-03-06 20:41 ` Questions? Matthew Dharm
2002-03-07 19:19 Questions? Siders, Keith
2002-03-07 21:00 ` Questions? Richard Hodges
2002-03-07 21:44 Questions? Siders, Keith

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox