Subject: non-swapping bus_space_read/write()
To: None <>
From: Manuel Bouyer <>
List: tech-kern
Date: 03/18/2004 23:38:45
I finally fixed the if_ti driver to work on big-endian systems.
The problem was quite simple: bus_space_read/write4() convert data
to little-endian (which is expected as it's a PCI bus), but the tigon
can run in big-endian mode. The only fix needed was to add extra
htole32() to the bus_space_read/write_4() calls in the driver, so that
data are really read or written as big-endian from/to the chip.

Of course this is a ugly hack. I can see 2 solutions:
1) very few chips can operate in big-endian mode, so we ignore the issue
  at the bus_space level and implement specific hacks in the drivers that
  needs this
2) we extent the bus_space API to add non-byteswapping versions of

or maybe something else I didn't think at.
1) is ugly and has performance impacts as we end up byteswapping the data
2) is clean, but require to change the bus_space implementation of all
   platforms with a PCI bus at last (obviously for little-endian platforms
   the change is trivial), for the benefit of very few (1 ?) drivers.

I suggest we go with 2.  What names should be used ? I suggest

Manuel Bouyer <>
     NetBSD: 26 ans d'experience feront toujours la difference