[U-Boot-Users] IDE and x86 port
Marc Singer
elf at buici.com
Thu Aug 14 17:43:33 CEST 2003
On Thu, Aug 14, 2003 at 11:04:36AM +0200, Wolfgang Denk wrote:
> > But the device is a "SunDisk SDCFB-4" and has a capacity of only 7872 sectors.
>
> This is obviously an endianess problem:
>
> "uSDnsi kDSFC-B 4" => "SunDisk SDCFB-4 "
>
> 1 2 3 4 => 2 1 4 3
>
> > The swap seems the right way, but results into a wrong value (perhaps only on
> > my port). Little endian <-> Big endian problem?
>
> Yes, definitely.
It isn't endianness as we might expect it. Hardware accesses are in
16 bit half-words. So, we might expect to need to do some swapping as
we read data from the IDE interface on LSB CPUs. Yet, this isn't the
case because the IO, which is nearly all 16 bit, is already done in an
ordering-neutral manner.
There are two necessary changes to the IDE code. First, the ident_cpy
routine does need to swap bytes. This is because the alignment of the
string characters in memory is important whereas the alignment of
bytes within an integer is not.
The other change appears below. For some reason, the existing IDE
code reorders the half-words of the capacity value read from the IDE
device. I don't have any MSB CPUs, so I cannot verify the need for
this. AFAICT, it should not be necessary.
I'd make the conditional test hinge on endianness if I knew that was
the reason for the swapping. So, either we add an __X86__ check, or
we change the conditional.
@@ -1056,7 +1099,12 @@
#endif /* CONFIG_ATAPI */
/* swap shorts */
+#if !defined (__ARM__)
dev_desc->lba = (iop->lba_capacity << 16) | (iop->lba_capacity >> 16);
+#else
+ /* elf: it isn't clear why this code swaps the words. There's nothing i
n the spec about it. */
+ dev_desc->lba = iop->lba_capacity;
+#endif
/* assuming HD */
dev_desc->type=DEV_TYPE_HARDDISK;
dev_desc->blksz=ATA_BLOCKSIZE;
Cheers.
More information about the U-Boot
mailing list