[U-Boot-Users] IDE and x86 port

Juergen Beisert jbeisert at eurodsn.de
Thu Aug 14 18:22:43 CEST 2003


Hello Marc,

Am Donnerstag, 14. August 2003 17:43 schrieb Marc Singer:
>         /* 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;

Perhaps

	dev_desc->lba = __le32_to_cpu(iop->lba_capacity);

would be easier?

In the ide buffer I see at address &iop->lba_capacity:
        0->0x00 1->0xe9 2->0x01 3->0x00.
It looks like little endian, because my CompactFlash has 125184 (0x0001E900) 
sectors.

I have changed my ident_cpy() to:

static void ident_cpy (unsigned char *dest, unsigned char *src, unsigned int 
len)
{
unsigned short *pus,us;
unsigned char *pc;

	pus=(unsigned short*)src;
	pc=dest;
	len &= -4;

	while (len) {
		us=__le16_to_cpu(*pus);	/* swap bytes in word */
		if (!(*pc++=us>>8))
			break;
		if (!(*pc++=us))
			break;
		pus++;
		len-=2;
	}
	*pc='\0';

	pc=dest;
	while(*pc == ' ')			/* skip trailing whitespace */
		pc++;
	while(*pc)					/* copy text itself */
		*dest++=*pc++;
	*dest--=*pc;				/* don't forget the \0! */
	while(*dest==' ')			/* skip leading whitespace */
		*dest--='\0';
}

And I also think the members
 - unsigned char revision[8];
 - unsigned char vendor[40];
 - unsigned char product[20];
in structure block_dev_desc have to increase by one char, because the string 
readed from the ide buffer could have the same size (without a leading 
'\0'!). And in this case, where to place the terminating '\0'?

Hope it helps

Regards
Juergen Beisert
-- 
*********************************
EuroDesign
embedded technologies GmbH
Waldstr. 4a
85414 Kirchdorf a.d. Amper/Germany

Tel: +49/8166/99495-77
Fax: +49/8166/99495-81

EMAIL: jbeisert at eurodsn.de
Web: http://www.eurodsn.de
*********************************




More information about the U-Boot mailing list