PCI endianess

Anil K Prasad aprasad at in.ibm.com
Tue Sep 3 19:54:48 EST 2002

>> >as far as I know, the PCI bus is little endian, even on big endian
>> machines.
>> >Is this true for RS6000 (44p/270) too ?
>> Yes, even on RS6K machines its little endian.
>> You should write to PCI mapped register in little endian byte order.

>So commands/data to my memory-mapped PCI card need to be converted, right
>E.g. if the cards memory has a structure like
>struct {
>  u16 command;
>  u32 length;
>  u32 data[128];

>I need to convert all data to that structure ?
If you need to copy this data from system memory to card memory (or other
way), you need to convert it from big-endian to little-endian(or reverse).
For example if structure is something like

x.command = 0x1234;
x.length = 0x567890AB;
where is x is an instance of above struct.

and assume X is at address 0x10000000 in system memory,
Then following will give view of structure in system memory

0x10000000 --> 0x12
0x10000001 --> 0x34 (0x10000002 and 0x10000002 will unused because of
0x10000004 --> 0x56
0x10000005 --> 0x78
0x10000006 --> 0x90
0x10000007 --> 0xAB;

Inside Card memory  this structure should look like(lets assume address of
structure is 0xf0000000)

0xf0000000 --> 0x34
0xf0000001 --> 0x12

0xf0000003 --> 0xAB
0xf0000004 --> 0x90
0xf0000005 --> 0x78
0xf0000006 --> 0x56


** Sent via the linuxppc64-dev mail list. See http://lists.linuxppc.org/

More information about the Linuxppc64-dev mailing list