1
0
Fork 0
forked from len0rd/rockbox

Optimized ata_read_sectors() a little

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2213 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Linus Nielsen Feltzing 2002-09-06 16:02:19 +00:00
parent 8b01f614a8
commit e82f701fa4

View file

@ -210,6 +210,7 @@ int ata_read_sectors(unsigned long start,
while (count) { while (count) {
int j; int j;
int sectors; int sectors;
int wordcount;
if (!wait_for_start_of_transfer()) if (!wait_for_start_of_transfer())
{ {
@ -226,15 +227,17 @@ int ata_read_sectors(unsigned long start,
else else
sectors = count; sectors = count;
wordcount = sectors * SECTOR_SIZE / 2;
if ( (unsigned int)buf & 1 ) { if ( (unsigned int)buf & 1 ) {
for (j=0; j < sectors * SECTOR_SIZE / 2; j++) { for (j=0; j < wordcount; j++) {
unsigned short tmp = SWAB16(ATA_DATA); unsigned short tmp = SWAB16(ATA_DATA);
((unsigned char*)buf)[j*2] = tmp >> 8; ((unsigned char*)buf)[j*2] = tmp >> 8;
((unsigned char*)buf)[j*2+1] = tmp & 0xff; ((unsigned char*)buf)[j*2+1] = tmp & 0xff;
} }
} }
else { else {
for (j=0; j < sectors * SECTOR_SIZE / 2; j++) for (j=0; j < wordcount; j++)
((unsigned short*)buf)[j] = SWAB16(ATA_DATA); ((unsigned short*)buf)[j] = SWAB16(ATA_DATA);
} }
@ -242,7 +245,7 @@ int ata_read_sectors(unsigned long start,
/* reading the status register clears the interrupt */ /* reading the status register clears the interrupt */
j = ATA_STATUS; j = ATA_STATUS;
#endif #endif
buf += sectors * SECTOR_SIZE; /* Advance one sector */ buf += sectors * SECTOR_SIZE; /* Advance one chunk of sectors */
count -= sectors; count -= sectors;
} }