From: Marc Singer <elf@buici.com>
To: u-boot@lists.denx.de
Subject: [U-Boot-Users] IDE and x86 port
Date: Thu, 14 Aug 2003 08:43:33 -0700 [thread overview]
Message-ID: <20030814154333.GD1468@buici.com> (raw)
In-Reply-To: <20030814090441.28A5AC59E4@atlas.denx.de>
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.
next prev parent reply other threads:[~2003-08-14 15:43 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-08-14 7:26 [U-Boot-Users] IDE and x86 port Juergen Beisert
2003-08-14 9:04 ` Wolfgang Denk
2003-08-14 15:43 ` Marc Singer [this message]
2003-08-14 16:17 ` Wolfgang Denk
2003-08-14 16:24 ` Marc Singer
2003-08-14 16:22 ` Juergen Beisert
2003-08-14 16:26 ` Marc Singer
2003-08-14 15:12 ` Marc Singer
[not found] <20030814170613.GA15834@buici.com>
2003-08-14 18:42 ` Wolfgang Denk
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20030814154333.GD1468@buici.com \
--to=elf@buici.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox