Subversion Repositories freemyipod

Rev

Rev 337 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 337 Rev 339
Line 20... Line 20...
20
 ****************************************************************************/
20
 ****************************************************************************/
21
#include "global.h"
21
#include "global.h"
22
#include "thread.h"
22
#include "thread.h"
23
#include "disk.h"
23
#include "disk.h"
24
#include "storage.h"
24
#include "storage.h"
-
 
25
#include "storage_ata-target.h"
25
#include "timer.h"
26
#include "timer.h"
26
#include "../ipodnano3g/s5l8702.h"
27
#include "../ipodnano3g/s5l8702.h"
27
 
28
 
28
/** static, private data **/ 
29
/** static, private data **/ 
29
uint16_t ata_identify_data[0x100];
30
uint16_t ata_identify_data[0x100];
Line 39... Line 40...
39
static bool ata_powered;
40
static bool ata_powered;
40
 
41
 
41
#ifdef ATA_HAVE_BBT
42
#ifdef ATA_HAVE_BBT
42
#include "panic.h"
43
#include "panic.h"
43
uint16_t ata_bbt[ATA_BBT_PAGES][0x20];
44
uint16_t ata_bbt[ATA_BBT_PAGES][0x20];
44
uint32_t ata_virtual_sectors;
45
uint64_t ata_virtual_sectors;
45
uint32_t ata_last_offset;
46
uint32_t ata_last_offset;
46
uint64_t ata_last_phys;
47
uint64_t ata_last_phys;
47
 
48
 
48
int ata_rw_sectors_internal(uint64_t sector, uint32_t count, void* buffer, bool write);
-
 
49
 
-
 
50
void ata_bbt_read_sectors(uint32_t sector, uint32_t count, void* buffer)
49
void ata_bbt_read_sectors(uint32_t sector, uint32_t count, void* buffer)
51
{
50
{
52
    int rc = ata_rw_sectors_internal(sector, count, buffer, false);
51
    int rc = ata_rw_sectors_internal(sector, count, buffer, false);
53
    if (IS_ERR(rc))
52
    if (IS_ERR(rc))
54
        panicf(PANIC_KILLTHREAD, "ATA: Error %08X while reading BBT (sector %d, count %d)\n",
53
        panicf(PANIC_KILLTHREAD, "ATA: Error %08X while reading BBT (sector %d, count %d)\n",
Line 531... Line 530...
531
    ata_power_up();
530
    ata_power_up();
532
    uint32_t* buf = (uint32_t*)(ata_bbt[ARRAYLEN(ata_bbt) - 64]);
531
    uint32_t* buf = (uint32_t*)(ata_bbt[ARRAYLEN(ata_bbt) - 64]);
533
    ata_bbt_read_sectors(0, 1, buf);
532
    ata_bbt_read_sectors(0, 1, buf);
534
    if (!memcmp(buf, "emBIbbth", 8))
533
    if (!memcmp(buf, "emBIbbth", 8))
535
    {
534
    {
536
        ata_virtual_sectors = buf[0x1fe];
535
        ata_virtual_sectors = (((uint64_t)buf[0x1fd]) << 32) | buf[0x1fc];
537
        uint32_t count = buf[0x1ff];
536
        uint32_t count = buf[0x1ff];
538
        if (count > (ATA_BBT_PAGES >> 6))
537
        if (count > (ATA_BBT_PAGES >> 6))
539
            panicf(PANIC_KILLTHREAD, "ATA: BBT too big! (%d pages, limit: %d)\n", count << 6, ATA_BBT_PAGES);
538
            panicf(PANIC_KILLTHREAD, "ATA: BBT too big! (%d pages, limit: %d)\n", count << 6, ATA_BBT_PAGES);
540
        uint32_t i;
539
        uint32_t i;
541
        uint32_t cnt;
540
        uint32_t cnt;