Subject: Re: am79900.c assumes little-endian processor?
To: David Edelsohn <dje@watson.ibm.com>
From: Matthias Drochner <M.Drochner@fz-juelich.de>
List: tech-net
Date: 11/09/1999 19:04:54
dje@watson.ibm.com said:
> 	The aspect of the am79900.c driver which does not byte-reverse values
> is the assignment to the initialization block (am79900_meminit), for
> example.  If the controller is accessing the values as little-endian,
> then the addresses for its ring buffers and descriptors would be
> jumbled and the adapter would scibble over incorrect pieces of memory,
> which could explain what I am experiencing. 

Right, that's probably the problem.

I'm however successfully using the am79900.c code in an mc68040 based VME
board. The chip is the original 79900 "ILACC" - I didn't find documentation
for it, so it took some reengineering...
The initialization code sets a "byte swap" bit (LE_C3_BSWP) in csr3.
I don't know whether this bit is implemented in all PCI chips, but
the '973 has it. So it might be as simple as
#if (BYTE_ORDER == BIG_ENDIAN)
	sc->sc_conf3 = LE_C3_BSWP;
#else
	sc->sc_conf3 = 0;
#endif
to make it work.
If it doesn't for whatever reason, the descriptors would have
to be swapped indeed. Should be straightforward however.

> 	I am somewhat surprised that no one else has tried to use a Lance
> Ethernet 79900 on a big-endian system with NetBSD device drivers and
> encountered this problem.  I am hoping that I am mistaken and severely
> confused.  What am I missing? 

Perhaps I was the only one... Possible also that the openfirmware
access got it right.
Your findings are right however - As the PCI attached driver looks
now, it can't work on be machines.

best regards
Matthias