This is the mail archive of the
ecos-discuss@sourceware.org
mailing list for the eCos project.
ns/dp83902a (NE2000) driver: endianness
- From: Rutger Hofman <rutger at cs dot vu dot nl>
- To: eCos Discuss List <ecos-discuss at ecos dot sourceware dot org>
- Date: Thu, 10 Dec 2009 16:32:28 +0100
- Subject: [ECOS] ns/dp83902a (NE2000) driver: endianness
(Context: I am porting a driver for the ASIX AX88796B Ethernet chip that
is an NE2000-compatible; it is used on our new board, see
http://www.rfidguardian.org)
If I read the NS DP83902A datasheet correctly, that chip is
little-endian. It appears to me, however, that the driver was developed
on a big-endian platform: it byteswaps all 16bit accesses.
Some varieties of NE2000-derived drivers already swap bytes again to fix
this endianness issue. In 2003, Mikael Starvik also reported that the
endianness was wrong for him
(http://sourceware.org/ml/ecos-discuss/2003-03/msg00356.html).
I think the correct approach is to use the CPU's endianness macros, and
byteswap only when the CPU is big-endian.
Shall I change the driver this way and send in a patch? Which derived
Ethernet drivers are candidates to be broken by such a change?
Rutger Hofman
VU Amsterdam
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss