freemyipod r339 - Code Review

Jump to: navigation, search
Repository:freemyipod
Revision:r338‎ | r339 | r340 >
Date:20:06, 19 December 2010
Author:theseven
Status:new
Tags:
Comment:
emBIOS: iPod Classic: Support drives with up to 2^64 sectors in the block remapping layer (maximum number of bad sectors: 2^28)
Modified paths:
  • /embios/trunk/target/ipodclassic/storage_ata-target.h (added) (history)
  • /embios/trunk/target/ipodclassic/storage_ata.c (modified) (history)
  • /embios/trunk/tools/genbbt.c (modified) (history)

Diff [purge]

Index: embios/trunk/tools/genbbt.c
@@ -165,7 +165,7 @@
166166 l0count, l1count, l2count, l3count);
167167 printf("User data sectors: %d (%d KiB)\n", logical, logical << 2);
168168 memcpy(bbt, "emBIbbth", 8);
169 - ((uint32_t*)bbt)[0x1fe] = logical;
 169+ ((uint32_t*)bbt)[0x1fc] = logical;
170170 ((uint32_t*)bbt)[0x1ff] = (bbtpages >> 6) - 1;
171171 break;
172172 }
Index: embios/trunk/target/ipodclassic/storage_ata-target.h
@@ -0,0 +1,38 @@
 2+//
 3+//
 4+// Copyright 2010 TheSeven
 5+//
 6+//
 7+// This file is part of emBIOS.
 8+//
 9+// emBIOS is free software: you can redistribute it and/or
 10+// modify it under the terms of the GNU General Public License as
 11+// published by the Free Software Foundation, either version 2 of the
 12+// License, or (at your option) any later version.
 13+//
 14+// emBIOS is distributed in the hope that it will be useful,
 15+// but WITHOUT ANY WARRANTY; without even the implied warranty of
 16+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 17+// See the GNU General Public License for more details.
 18+//
 19+// You should have received a copy of the GNU General Public License along
 20+// with emBIOS. If not, see <http://www.gnu.org/licenses/>.
 21+//
 22+//
 23+
 24+
 25+#ifndef __STORAGE_ATA_TARGET_H__
 26+#define __STORAGE_ATA_TARGET_H__
 27+
 28+#include "global.h"
 29+
 30+
 31+extern uint16_t ata_identify_data[0x100];
 32+extern uint64_t ata_total_sectors;
 33+extern uint16_t ata_bbt[ATA_BBT_PAGES][0x20];
 34+extern uint64_t ata_virtual_sectors;
 35+
 36+int ata_rw_sectors_internal(uint64_t sector, uint32_t count, void* buffer, bool write);
 37+
 38+
 39+#endif
Index: embios/trunk/target/ipodclassic/storage_ata.c
@@ -22,6 +22,7 @@
2323 #include "thread.h"
2424 #include "disk.h"
2525 #include "storage.h"
 26+#include "storage_ata-target.h"
2627 #include "timer.h"
2728 #include "../ipodnano3g/s5l8702.h"
2829
@@ -41,12 +42,10 @@
4243 #ifdef ATA_HAVE_BBT
4344 #include "panic.h"
4445 uint16_t ata_bbt[ATA_BBT_PAGES][0x20];
45 -uint32_t ata_virtual_sectors;
 46+uint64_t ata_virtual_sectors;
4647 uint32_t ata_last_offset;
4748 uint64_t ata_last_phys;
4849
49 -int ata_rw_sectors_internal(uint64_t sector, uint32_t count, void* buffer, bool write);
50 -
5150 void ata_bbt_read_sectors(uint32_t sector, uint32_t count, void* buffer)
5251 {
5352 int rc = ata_rw_sectors_internal(sector, count, buffer, false);
@@ -533,7 +532,7 @@
534533 ata_bbt_read_sectors(0, 1, buf);
535534 if (!memcmp(buf, "emBIbbth", 8))
536535 {
537 - ata_virtual_sectors = buf[0x1fe];
 536+ ata_virtual_sectors = (((uint64_t)buf[0x1fd]) << 32) | buf[0x1fc];
538537 uint32_t count = buf[0x1ff];
539538 if (count > (ATA_BBT_PAGES >> 6))
540539 panicf(PANIC_KILLTHREAD, "ATA: BBT too big! (%d pages, limit: %d)\n", count << 6, ATA_BBT_PAGES);