From 8ccbc766a451f875289559a0cf530bbbb1223ec1 Mon Sep 17 00:00:00 2001 From: Björn Stenberg Date: Thu, 5 Sep 2002 15:25:08 +0000 Subject: Now uses READ MULTIPLE command. Also corrected some return values. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2186 a1c6a512-1295-4272-9138-f99709370657 --- firmware/drivers/ata.c | 85 ++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 62 insertions(+), 23 deletions(-) diff --git a/firmware/drivers/ata.c b/firmware/drivers/ata.c index 2f867d20b1..8d892788a9 100644 --- a/firmware/drivers/ata.c +++ b/firmware/drivers/ata.c @@ -70,8 +70,12 @@ #define CMD_READ_SECTORS 0x20 #define CMD_WRITE_SECTORS 0x30 +#define CMD_READ_MULTIPLE 0xC4 +#define CMD_WRITE_MULTIPLE 0xC5 +#define CMD_SET_MULTIPLE_MODE 0xC6 #define CMD_STANDBY_IMMEDIATE 0xE0 #define CMD_STANDBY 0xE2 +#define CMD_IDENTIFY 0xEC #define CMD_SLEEP 0xE6 #define CMD_SECURITY_FREEZE_LOCK 0xF5 @@ -96,6 +100,9 @@ static int delayed_sector_num; static long last_user_activity = -1; static long last_disk_activity = -1; +static int multisectors; /* number of supported multisectors */ +static unsigned short identify_info[SECTOR_SIZE]; + #ifdef USE_POWEROFF static int ata_power_on(void); #endif @@ -110,13 +117,9 @@ static int wait_for_bsy(void) yield(); if (TIME_BEFORE(current_tick, timeout)) - { return 1; - } else - { return 0; /* timeout */ - } } static int wait_for_rdy(void) __attribute__ ((section (".icode"))); @@ -134,13 +137,9 @@ static int wait_for_rdy(void) yield(); if (TIME_BEFORE(current_tick, timeout)) - { return STATUS_RDY; - } else - { return 0; /* timeout */ - } } static int wait_for_start_of_transfer(void) __attribute__ ((section (".icode"))); @@ -166,7 +165,6 @@ int ata_read_sectors(unsigned long start, int count, void* buf) { - int i; int ret = 0; last_disk_activity = current_tick; @@ -193,7 +191,7 @@ int ata_read_sectors(unsigned long start, if (!wait_for_rdy()) { mutex_unlock(&ata_mtx); - return -1; + return -2; } led(true); @@ -207,27 +205,36 @@ int ata_read_sectors(unsigned long start, ATA_LCYL = (start >> 8) & 0xff; ATA_HCYL = (start >> 16) & 0xff; ATA_SELECT = ((start >> 24) & 0xf) | SELECT_LBA | ata_device; - ATA_COMMAND = CMD_READ_SECTORS; + ATA_COMMAND = CMD_READ_MULTIPLE; - for (i=0; i= multisectors ) + sectors = multisectors; + else + sectors = count; + if ( (unsigned int)buf & 1 ) { - for (j=0; j> 8; ((unsigned char*)buf)[j*2+1] = tmp & 0xff; } } else { - for (j=0; j