Re: New resources - pls, explain :-(

Jakub Jelinek (jj@sunsite.ms.mff.cuni.cz)
Fri, 13 Aug 1999 13:53:42 +0200


On Fri, Aug 13, 1999 at 02:21:23AM -0700, Mitchell Blank Jr wrote:
> Linus Torvalds wrote:
> > But the point is _still_ that the driver needs to know.
>
> Definately
>
> > The the drivers that know about the issue might
> > do something like this:
> [...]
> > #ifdef BIG_ENDIAN
> > #define gfx_readl(x) bigendian_readl(x)
> > #define gfx_writel(x,y) bigendian_writel(x,y)
> > #else
> > #define gfx_readl(x) readl(x)
> > #define gfx_writel(x,y) writel(x,y)
> > #endif
>
> Yes, but if you are going to need that boilerplate in every such driver
> why not just put it in one place? Then your API is just:
> readl_le(), writel_le() /* Little endian */
> readl_be(), writel_be() /* Big endian */
> readl_ne(), writel_ne() /* Native endian */
> readl(), writel() /* aliased to *_le() for comaptibility */

Actually, I think it is a bad idea to call the routines readl_*, because
the name is pure intelism. It would be much better to have some more
descriptive names, like:

read_le16(), write_le16()
...
read_le32(), write_le32()
read_be32(), write_be32()
read_ne32(), write_ne32()
...
#define readw read_le16
#define writew write_le16
...
#define readl read_le32
#define writel write_le32

32bit chunks are called differently on different platforms.
On sparc, it is a word, 64bit type is an extended word.
On intel, a word is 16bit, long is 32bit.

Cheers,
Jakub
___________________________________________________________________
Jakub Jelinek | jj@sunsite.mff.cuni.cz | http://sunsite.mff.cuni.cz
Administrator of SunSITE Czech Republic, MFF, Charles University
___________________________________________________________________
UltraLinux | http://ultra.linux.cz/ | http://ultra.penguin.cz/
Linux version 2.3.13 on a sparc64 machine (1343.49 BogoMips)
___________________________________________________________________

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/