diff options
Diffstat (limited to 'firmware/target/arm/tms320dm320/creative-zvm/ata-creativezvm.c')
-rw-r--r-- | firmware/target/arm/tms320dm320/creative-zvm/ata-creativezvm.c | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/firmware/target/arm/tms320dm320/creative-zvm/ata-creativezvm.c b/firmware/target/arm/tms320dm320/creative-zvm/ata-creativezvm.c index afb8d5cf62..ad10502f2d 100644 --- a/firmware/target/arm/tms320dm320/creative-zvm/ata-creativezvm.c +++ b/firmware/target/arm/tms320dm320/creative-zvm/ata-creativezvm.c | |||
@@ -30,7 +30,7 @@ | |||
30 | #include "dm320.h" | 30 | #include "dm320.h" |
31 | #include "ata.h" | 31 | #include "ata.h" |
32 | #include "string.h" | 32 | #include "string.h" |
33 | #include "buffer.h" | 33 | #include "core_alloc.h" |
34 | #include "logf.h" | 34 | #include "logf.h" |
35 | #include "ata-defines.h" | 35 | #include "ata-defines.h" |
36 | 36 | ||
@@ -202,7 +202,11 @@ struct cfs_direntry_item | |||
202 | 202 | ||
203 | static bool cfs_inited = false; | 203 | static bool cfs_inited = false; |
204 | static unsigned long cfs_start; | 204 | static unsigned long cfs_start; |
205 | #ifdef BOOTLOADER | ||
205 | static unsigned long *sectors; | 206 | static unsigned long *sectors; |
207 | #else | ||
208 | static int sectors_handle; | ||
209 | #endif | ||
206 | 210 | ||
207 | #define CFS_START ( ((hdr->partitions[1].start*hdr->sector_size) & ~0xFFFF) + 0x10000 ) | 211 | #define CFS_START ( ((hdr->partitions[1].start*hdr->sector_size) & ~0xFFFF) + 0x10000 ) |
208 | #define CFS_CLUSTER2CLUSTER(x) ( (CFS_START/512)+((x)-1)*64 ) | 212 | #define CFS_CLUSTER2CLUSTER(x) ( (CFS_START/512)+((x)-1)*64 ) |
@@ -299,7 +303,8 @@ static void cfs_init(void) | |||
299 | _ata_read_sectors(CFS_CLUSTER2CLUSTER(vfat_inodes_nr[1]), 1, §or); | 303 | _ata_read_sectors(CFS_CLUSTER2CLUSTER(vfat_inodes_nr[1]), 1, §or); |
300 | inode = (struct cfs_inode*)§or; | 304 | inode = (struct cfs_inode*)§or; |
301 | #ifndef BOOTLOADER | 305 | #ifndef BOOTLOADER |
302 | sectors = (unsigned long*)buffer_alloc(VFAT_SECTOR_SIZE(inode->filesize)); | 306 | sectors_handle = core_alloc("ata sectors", VFAT_SECTOR_SIZE(inode->filesize)); |
307 | unsigned long *sectors = core_get_data(sectors_handle); | ||
303 | #else | 308 | #else |
304 | static unsigned long _sector[VFAT_SECTOR_SIZE(1024*1024*1024)]; /* 1GB guess */ | 309 | static unsigned long _sector[VFAT_SECTOR_SIZE(1024*1024*1024)]; /* 1GB guess */ |
305 | sectors = _sector; | 310 | sectors = _sector; |
@@ -322,6 +327,9 @@ static void cfs_init(void) | |||
322 | _ata_read_sectors(CFS_CLUSTER2CLUSTER(inode->second_class_chain_second_cluster), 64, &vfat_data[1]); | 327 | _ata_read_sectors(CFS_CLUSTER2CLUSTER(inode->second_class_chain_second_cluster), 64, &vfat_data[1]); |
323 | 328 | ||
324 | /* First class chain */ | 329 | /* First class chain */ |
330 | #ifndef BOOTLOADER | ||
331 | sectors = core_get_data(sectors_handle); | ||
332 | #endif | ||
325 | for(j=0; j<12; j++) | 333 | for(j=0; j<12; j++) |
326 | { | 334 | { |
327 | if( (inode->first_class_chain[j] & 0xFFFF) != 0xFFFF && | 335 | if( (inode->first_class_chain[j] & 0xFFFF) != 0xFFFF && |
@@ -331,6 +339,9 @@ static void cfs_init(void) | |||
331 | } | 339 | } |
332 | 340 | ||
333 | /* Second class chain */ | 341 | /* Second class chain */ |
342 | #ifndef BOOTLOADER | ||
343 | sectors = core_get_data(sectors_handle); | ||
344 | #endif | ||
334 | for(j=0; j<0x8000/4; j++) | 345 | for(j=0; j<0x8000/4; j++) |
335 | { | 346 | { |
336 | if( (vfat_data[0][j] & 0xFFFF) != 0xFFFF && | 347 | if( (vfat_data[0][j] & 0xFFFF) != 0xFFFF && |
@@ -351,6 +362,9 @@ static void cfs_init(void) | |||
351 | /* Read third class subchain(s) */ | 362 | /* Read third class subchain(s) */ |
352 | _ata_read_sectors(CFS_CLUSTER2CLUSTER(vfat_data[1][j]), 64, &vfat_data[0]); | 363 | _ata_read_sectors(CFS_CLUSTER2CLUSTER(vfat_data[1][j]), 64, &vfat_data[0]); |
353 | 364 | ||
365 | #ifndef BOOTLOADER | ||
366 | sectors = core_get_data(sectors_handle); | ||
367 | #endif | ||
354 | for(k=0; k<0x8000/4; k++) | 368 | for(k=0; k<0x8000/4; k++) |
355 | { | 369 | { |
356 | if( (vfat_data[0][k] & 0xFFFF) != 0xFFFF && | 370 | if( (vfat_data[0][k] & 0xFFFF) != 0xFFFF && |
@@ -376,6 +390,9 @@ static inline unsigned long map_sector(unsigned long sector) | |||
376 | * Sector mapping: start of CFS + FAT_SECTOR2CFS_SECTOR(sector) + missing part | 390 | * Sector mapping: start of CFS + FAT_SECTOR2CFS_SECTOR(sector) + missing part |
377 | * FAT works with sectors of 0x200 bytes, CFS with sectors of 0x8000 bytes. | 391 | * FAT works with sectors of 0x200 bytes, CFS with sectors of 0x8000 bytes. |
378 | */ | 392 | */ |
393 | #ifndef BOOTLOADER | ||
394 | unsigned long *sectors = core_get_data(sectors_handle); | ||
395 | #endif | ||
379 | return cfs_start+sectors[sector/64]*64+sector%64; | 396 | return cfs_start+sectors[sector/64]*64+sector%64; |
380 | } | 397 | } |
381 | 398 | ||