freemyipod r601 - Code Review

Jump to: navigation, search
Repository:freemyipod
Revision:r600‎ | r601 | r602 >
Date:22:15, 12 February 2011
Author:theseven
Status:new
Tags:
Comment:
emCORE: Lock the ATA driver mutex on the iPod Classic before attempting to access the raw disk through target-specific monitor commands
Modified paths:
  • /emcore/trunk/target/ipodclassic/storage_ata-target.h (modified) (history)
  • /emcore/trunk/target/ipodclassic/storage_ata.c (modified) (history)
  • /emcore/trunk/target/ipodclassic/usbtarget.c (modified) (history)

Diff [purge]

Index: emcore/trunk/target/ipodclassic/usbtarget.c
@@ -25,6 +25,7 @@
2626 #include "usb/usbtarget.h"
2727 #include "usb/usbdrv.h"
2828 #include "storage_ata-target.h"
 29+#include "thread.h"
2930
3031
3132 int usb_target_handle_request(uint32_t* buffer, int bufsize)
@@ -54,6 +55,7 @@
5556 }
5657 case 0xffff0002: // LOWLEVEL DISK ACCESS
5758 {
 59+ mutex_lock(&ata_mutex, TIMEOUT_BLOCK);
5860 #ifdef ATA_HAVE_BBT
5961 int rc = ata_rw_sectors_internal((((uint64_t)(buffer[3])) << 32) | buffer[2],
6062 buffer[4], (void*)(buffer[5]), (bool)(buffer[1]));
@@ -61,6 +63,7 @@
6264 int rc = ata_rw_sectors((((uint64_t)(buffer[3])) << 32) | buffer[2],
6365 buffer[4], (void*)(buffer[5]), (bool)(buffer[1]));
6466 #endif
 67+ mutex_unlock(&ata_mutex);
6568 buffer[0] = 1;
6669 buffer[1] = (uint32_t)rc;
6770 size = 16;
Index: emcore/trunk/target/ipodclassic/storage_ata-target.h
@@ -29,6 +29,7 @@
3030
3131 extern uint16_t ata_identify_data[0x100];
3232 extern uint64_t ata_total_sectors;
 33+extern struct mutex ata_mutex;
3334
3435 #ifdef ATA_HAVE_BBT
3536 extern uint16_t (*ata_bbt)[0x20];
Index: emcore/trunk/target/ipodclassic/storage_ata.c
@@ -31,7 +31,7 @@
3232 bool ata_lba48;
3333 bool ata_dma;
3434 uint64_t ata_total_sectors;
35 -static struct mutex ata_mutex;
 35+struct mutex ata_mutex;
3636 static struct wakeup ata_wakeup;
3737 static uint32_t ata_dma_flags;
3838 static long ata_last_activity_value = -1;