diff options
Diffstat (limited to 'firmware/target/arm/s5l8702/ipod6g')
-rw-r--r-- | firmware/target/arm/s5l8702/ipod6g/storage_ata-ipod6g.c | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/firmware/target/arm/s5l8702/ipod6g/storage_ata-ipod6g.c b/firmware/target/arm/s5l8702/ipod6g/storage_ata-ipod6g.c index 395c0f49e6..0fd74787d1 100644 --- a/firmware/target/arm/s5l8702/ipod6g/storage_ata-ipod6g.c +++ b/firmware/target/arm/s5l8702/ipod6g/storage_ata-ipod6g.c | |||
@@ -32,7 +32,7 @@ | |||
32 | #include "s5l8702.h" | 32 | #include "s5l8702.h" |
33 | #include "led.h" | 33 | #include "led.h" |
34 | #include "ata_idle_notify.h" | 34 | #include "ata_idle_notify.h" |
35 | #include "fat.h" | 35 | #include "disk_cache.h" |
36 | #include "splash.h" | 36 | #include "splash.h" |
37 | 37 | ||
38 | 38 | ||
@@ -68,6 +68,7 @@ static struct semaphore mmc_wakeup; | |||
68 | static struct semaphore mmc_comp_wakeup; | 68 | static struct semaphore mmc_comp_wakeup; |
69 | static int spinup_time = 0; | 69 | static int spinup_time = 0; |
70 | static int dma_mode = 0; | 70 | static int dma_mode = 0; |
71 | static char aligned_buffer[SECTOR_SIZE] __attribute__((aligned(0x10))); | ||
71 | 72 | ||
72 | 73 | ||
73 | #ifdef ATA_HAVE_BBT | 74 | #ifdef ATA_HAVE_BBT |
@@ -857,8 +858,25 @@ int ata_bbt_translate(uint64_t sector, uint32_t count, uint64_t* phys, uint32_t* | |||
857 | static int ata_rw_sectors(uint64_t sector, uint32_t count, void* buffer, bool write) | 858 | static int ata_rw_sectors(uint64_t sector, uint32_t count, void* buffer, bool write) |
858 | { | 859 | { |
859 | if (((uint32_t)buffer) & 0xf) | 860 | if (((uint32_t)buffer) & 0xf) |
860 | panicf("ATA: Misaligned data buffer at %08X (sector %lu, count %lu)", | 861 | { |
861 | (unsigned int)buffer, (long unsigned int)sector, (long unsigned int)count); | 862 | while (count) |
863 | { | ||
864 | if (write) | ||
865 | memcpy(aligned_buffer, buffer, SECTOR_SIZE); | ||
866 | |||
867 | PASS_RC(ata_rw_sectors(sector, 1, aligned_buffer, write), 0, 0); | ||
868 | |||
869 | if (!write) | ||
870 | memcpy(buffer, aligned_buffer, SECTOR_SIZE); | ||
871 | |||
872 | buffer += SECTOR_SIZE; | ||
873 | sector++; | ||
874 | count--; | ||
875 | } | ||
876 | |||
877 | return 0; | ||
878 | } | ||
879 | |||
862 | #ifdef ATA_HAVE_BBT | 880 | #ifdef ATA_HAVE_BBT |
863 | if (sector + count > ata_virtual_sectors) RET_ERR(0); | 881 | if (sector + count > ata_virtual_sectors) RET_ERR(0); |
864 | if (ata_bbt) | 882 | if (ata_bbt) |
@@ -1117,14 +1135,13 @@ int ata_init(void) | |||
1117 | -- Michael Sparmann (theseven), 2011-10-22 */ | 1135 | -- Michael Sparmann (theseven), 2011-10-22 */ |
1118 | if (!ceata) | 1136 | if (!ceata) |
1119 | { | 1137 | { |
1120 | unsigned char* sector = fat_get_sector_buffer(); | 1138 | unsigned char* sector = aligned_buffer; |
1121 | ata_rw_sectors(0, 1, sector, false); | 1139 | ata_rw_sectors(0, 1, sector, false); |
1122 | if (sector[510] == 0xaa && sector[511] == 0x55) | 1140 | if (sector[510] == 0xaa && sector[511] == 0x55) |
1123 | { | 1141 | { |
1124 | ata_swap = true; | 1142 | ata_swap = true; |
1125 | splashf(5000, "Wrong HDD endianness, please update your emCORE version!"); | 1143 | splashf(5000, "Wrong HDD endianness, please update your emCORE version!"); |
1126 | } | 1144 | } |
1127 | fat_release_sector_buffer(); | ||
1128 | } | 1145 | } |
1129 | 1146 | ||
1130 | create_thread(ata_thread, ata_stack, | 1147 | create_thread(ata_thread, ata_stack, |