Endianess problem

Hi,

I am writing a driver for a ethernet controller. The controller i connected to the io memory and expects data to be in the Little endia format (will call it LE now and BE for big endian). The main cpu whic runs the driver code is a BE machine. During the startup I write th descriptors into the io memory in the LE format. In the send and receiv routine which is called by the IP stack I have pointers that access th descriptors. The pointers are actually pointing to data which is in L format, so if I want to access a bit(a part of the desc bit field) lik ptr->own_bit it will refer to the wrong bit. How can I come over thi problem.

wr, Sid

Reply to
sid1977
Loading thread data ...

You have identified the problem. To overcome it, fix the code.

Reply to
Ivanna Pee

I thought the comm data was in Big-Endian order. Are you talking about control and status registers' content?

----------------------------------------------------------------------- "Big-Endian byte order is known as 'normal', 'intuitive', or 'obvious'. Little-Endian is sometimes called 'perverse', 'annoying', 'dysfunctional', or 'stupid'. These designations do not, of course, imply any bias or preference."

Christopher R. Hertel, "Implementing CIFS" 2004

Reply to
Everett M. Greene

There is also the possibility that the two machines/compilers will allocate bit fields in a different order. Fortunately for me, the Keil 8051 and MSVC86 compilers both allocate bit fields from LS bit up. This only matters if you are hoping to share structure definitions between machines.

Reply to
Bill Davy

In the past I have written alternate forms of struct definitions, with the bitfields appropriately adjusted to align. One machine uses one definition and the other processor uses the other. An #ifdef selected the proper form based on the target.

--
Thad
Reply to
Thad Smith

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.