summaryrefslogtreecommitdiff
path: root/firmware/target/arm/tms320dm320/creative-zvm
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2011-08-30 14:01:33 +0000
committerThomas Martitz <kugel@rockbox.org>2011-08-30 14:01:33 +0000
commitd0b72e25903574acb1cf9184a6052cdd646dbc37 (patch)
tree5be8db5ee00b2a727e4821cf51a5f7bcf3991073 /firmware/target/arm/tms320dm320/creative-zvm
parentc940811ade7d99a0e0d414df7c6509672413684a (diff)
downloadrockbox-d0b72e25903574acb1cf9184a6052cdd646dbc37.tar.gz
rockbox-d0b72e25903574acb1cf9184a6052cdd646dbc37.zip
GSoC/Buflib: Add buflib memory alocator to the core.
The buflib memory allocator is handle based and can free and compact, move or resize memory on demand. This allows to effeciently allocate memory dynamically without an MMU, by avoiding fragmentation through memory compaction. This patch adds the buflib library to the core, along with convinience wrappers to omit the context parameter. Compaction is not yet enabled, but will be in a later patch. Therefore, this acts as a replacement for buffer_alloc/buffer_get_buffer() with the benifit of a debug menu. See buflib.h for some API documentation. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30380 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/arm/tms320dm320/creative-zvm')
-rw-r--r--firmware/target/arm/tms320dm320/creative-zvm/ata-creativezvm.c21
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
203static bool cfs_inited = false; 203static bool cfs_inited = false;
204static unsigned long cfs_start; 204static unsigned long cfs_start;
205#ifdef BOOTLOADER
205static unsigned long *sectors; 206static unsigned long *sectors;
207#else
208static 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, &sector); 303 _ata_read_sectors(CFS_CLUSTER2CLUSTER(vfat_inodes_nr[1]), 1, &sector);
300 inode = (struct cfs_inode*)&sector; 304 inode = (struct cfs_inode*)&sector;
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