Re:kernel programming - big endian and little endian issues

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Om. escribió:
On 7/27/06, Martin Röhricht <ml@xxxxxxxxxxx> wrote:
Am Donnerstag, den 27.07.2006, 23:14 +0530 schrieb Gaurav Dhiman:
> Can someone point me the use of these funtions in kernel, and why we
> use them, does not the compiler handle the machine specific endian
> issues ??

Consider using networking packets. To interpret them in the correct way
they need to be specified for one order. The Bluetooth specification for
example specifies it's packets in little endian order. If you didn't use
Another example is PCI specification. All the data put onto the pci
buses should be little endian. Assuming we are running on PPC, every
read/write to pci must be converted back and forth.

You can find the examples in almost all pci device drivers
Regards,
Om.

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/



I think that the most easy way of understanding the endianess problem is something like this... Suppose a system where an int in a 16 bit type, and byte is a 8 bit type...

int a = 300; //(that is 1*256 + 44).

byte b =  *((byte*)(&a));

So... If I get the contents of the first byte of the address in which a is stored... Am I getting a 1 or a 44...?


The problem arises when we store the data in a format (structures for example), and try to read them in another format... usually each byte at a time.


Miguel Ángel
----------------------------------------- PLEASE NOTE -------------------------------------------
This message, along with any attachments, may be confidential or legally privileged. It is intended only for the named person(s), who is/are the only authorized recipients.
If this message has reached you in error, kindly destroy it without review and notify the sender immediately.
Thank you for your help.
µSysCom uses virus scanning software but excludes any liability for viruses contained in any attachment.

------------------------------------ ROGAMOS LEA ESTE TEXTO -------------------------------
Este mensaje y sus anexos pueden contener información confidencial y/o con derecho legal. Está dirigido únicamente a la/s persona/s o entidad/es reseñadas como único destinatario autorizado. Si este mensaje le hubiera llegado por error, por favor elimínelo sin revisarlo ni reenviarlo y notifíquelo inmediatamente al remitente. Gracias por su colaboración. µSysCom utiliza software antivirus, pero no se hace responsable de los virus contenidos en los ficheros anexos.

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux