Date: Wed, 14 Jun 2006 23:49:34 GMT From: Warner Losh <imp@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 99264 for review Message-ID: <200606142349.k5ENnYdj058346@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=99264 Change 99264 by imp@imp_lighthouse on 2006/06/14 23:49:23 quick hack: the MCI part has a problem with byte order. It stores the bytes in the wrong order with a word in the buffers it reads and does a similar thing for write. Cope. Affected files ... .. //depot/projects/arm/src/sys/boot/arm/at91/bootspi/sd-card.c#3 edit Differences ... ==== //depot/projects/arm/src/sys/boot/arm/at91/bootspi/sd-card.c#3 (text+ko) ==== @@ -126,6 +126,13 @@ } #endif +inline static unsigned int +swap(unsigned int a) +{ + return (((a & 0xff) << 24) | ((a & 0xff00) << 8) | ((a & 0xff0000) >> 8) + | ((a & 0xff000000) >> 24)); +} + int MCI_read (char* dest, unsigned source, unsigned length) { @@ -134,6 +141,7 @@ unsigned offset = (unsigned)source % sectorLength; AT91S_MCIDeviceStatus status; int sizeToRead; + unsigned int *walker; //See if we are requested to read partial sectors, and have the capability to do so if ((length % sectorLength) && !(MCI_Device_Features.Read_Partial)) @@ -160,6 +168,13 @@ if (status != AT91C_READ_OK) return -1; + //* Wait MCI Device Ready + AT91F_MCIDeviceWaitReady(AT91C_MCI_TIMEOUT); + // Fix erratum in MCI part + for (walker = (unsigned int *)dest; + walker < (unsigned int *)(dest + sizeToRead); walker++) + *walker = swap(*walker); + //Update counters & pointers length -= sizeToRead; dest += sizeToRead; @@ -183,6 +198,14 @@ if (status != AT91C_READ_OK) return -1; + //* Wait MCI Device Ready + AT91F_MCIDeviceWaitReady(AT91C_MCI_TIMEOUT); + + // Fix erratum in MCI part + for (walker = (unsigned int *)dest; + walker < (unsigned int *)(dest + sizeToRead); walker++) + *walker = swap(*walker); + //Update counters & pointers length -= sizeToRead; dest += sizeToRead;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200606142349.k5ENnYdj058346>