[U-Boot-Users] Endian patch for AU1x00

Wolfgang Denk wd at denx.de
Fri Jan 2 15:05:12 CET 2004


Dear Ed,

in message <Pine.LNX.4.44.0312071846560.17468-200000 at dallas.texasconnect.net> you wrote:
> 
> Attached is an patch to cmd_ide.c that fixes endian issues for the AU1x00
> family of processors.  Previously these processors could only read Compact
> Flash cards (and perhaps other IDE devices) if the drive was byte swapped
> from what is written by a standard PC.  With this patch they can now read
> them without the bytes needing to be swapped.
> 

Thanks (and sorry for the delay).

--- ../../u-boot/common/cmd_ide.c	2003-11-07 05:42:26.000000000 -0800
+++ cmd_ide.c	2003-11-30 13:13:53.000000000 -0800
@@ -172,7 +172,7 @@ static void __inline__ ide_outb(int dev,
 static unsigned char __inline__ ide_inb(int dev, int port);
 static void input_data(int dev, ulong *sect_buf, int words);
 static void output_data(int dev, ulong *sect_buf, int words);
-static void ident_cpy (unsigned char *dest, unsigned char *src, unsigned int len);
+static void ident_cpy (unsigned char *dest, unsigned char *src, unsigned int len, int swap);
 
...
 
-	ident_cpy (dev_desc->revision, iop->fw_rev, sizeof(dev_desc->revision));
-	ident_cpy (dev_desc->vendor, iop->model, sizeof(dev_desc->vendor));
-	ident_cpy (dev_desc->product, iop->serial_no, sizeof(dev_desc->product));
-
+#if defined(__LITTLE_ENDIAN)
+	ident_cpy (dev_desc->revision, iop->fw_rev, sizeof(dev_desc->revision), 1);
+	ident_cpy (dev_desc->vendor, iop->model, sizeof(dev_desc->vendor), 1);
+#else
+	ident_cpy (dev_desc->revision, iop->fw_rev, sizeof(dev_desc->revision), 0);
+	ident_cpy (dev_desc->vendor, iop->model, sizeof(dev_desc->vendor), 0);
+#endif
+	ident_cpy (dev_desc->product, iop->serial_no, sizeof(dev_desc->product), 0);

It seems to me that all information about endianess of the system  is
(and  has  to be) know at compile time. In this case we should #ifdef
the code instead of passing additional (constant,  known  at  compile
time) parameters.

Please re-work the patch.

Best regards, and a Happy New Year!

Wolfgang Denk

-- 
Software Engineering:  Embedded and Realtime Systems,  Embedded Linux
Phone: (+49)-8142-4596-87  Fax: (+49)-8142-4596-88  Email: wd at denx.de
Man is the best computer we can put aboard a spacecraft ...  and  the
only one that can be mass produced with unskilled labor.
                                                  - Wernher von Braun




More information about the U-Boot mailing list