summaryrefslogtreecommitdiff
path: root/firmware/target/arm
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
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')
-rw-r--r--firmware/target/arm/ata-nand-telechips.c15
-rw-r--r--firmware/target/arm/tms320dm320/creative-zvm/ata-creativezvm.c21
2 files changed, 30 insertions, 6 deletions
diff --git a/firmware/target/arm/ata-nand-telechips.c b/firmware/target/arm/ata-nand-telechips.c
index 81dde33938..2ae425f4c6 100644
--- a/firmware/target/arm/ata-nand-telechips.c
+++ b/firmware/target/arm/ata-nand-telechips.c
@@ -26,7 +26,6 @@
26#include "panic.h" 26#include "panic.h"
27#include "nand_id.h" 27#include "nand_id.h"
28#include "storage.h" 28#include "storage.h"
29#include "buffer.h"
30 29
31#define SECTOR_SIZE 512 30#define SECTOR_SIZE 512
32 31
@@ -122,8 +121,9 @@ struct lpt_entry
122#ifdef BOOTLOADER 121#ifdef BOOTLOADER
123static struct lpt_entry lpt_lookup[MAX_SEGMENTS]; 122static struct lpt_entry lpt_lookup[MAX_SEGMENTS];
124#else 123#else
125/* buffer_alloc'd in nand_init() when the correct size has been determined */ 124/* core_alloc()'d in nand_init() when the correct size has been determined */
126static struct lpt_entry* lpt_lookup = NULL; 125#include "core_alloc.h"
126static int lpt_handle;
127#endif 127#endif
128 128
129/* Write Caches */ 129/* Write Caches */
@@ -607,6 +607,9 @@ static bool nand_read_sector_of_logical_segment(int log_segment, int sector,
607 int page_in_segment = sector / sectors_per_page; 607 int page_in_segment = sector / sectors_per_page;
608 int sector_in_page = sector % sectors_per_page; 608 int sector_in_page = sector % sectors_per_page;
609 609
610#ifndef BOOTLOADER
611 struct lpt_entry* lpt_lookup = core_get_data(lpt_handle);
612#endif
610 int bank = lpt_lookup[log_segment].bank; 613 int bank = lpt_lookup[log_segment].bank;
611 int phys_segment = lpt_lookup[log_segment].phys_segment; 614 int phys_segment = lpt_lookup[log_segment].phys_segment;
612 615
@@ -918,7 +921,8 @@ int nand_init(void)
918#ifndef BOOTLOADER 921#ifndef BOOTLOADER
919 /* Use chip info to allocate the correct size LPT buffer */ 922 /* Use chip info to allocate the correct size LPT buffer */
920 lptbuf_size = sizeof(struct lpt_entry) * segments_per_bank * total_banks; 923 lptbuf_size = sizeof(struct lpt_entry) * segments_per_bank * total_banks;
921 lpt_lookup = buffer_alloc(lptbuf_size); 924 lpt_handle = core_alloc("lpt lookup", lptbuf_size);
925 struct lpt_entry* lpt_lookup = core_get_data(lpt_handle);
922#else 926#else
923 /* Use a static array in the bootloader */ 927 /* Use a static array in the bootloader */
924 lptbuf_size = sizeof(lpt_lookup); 928 lptbuf_size = sizeof(lpt_lookup);
@@ -968,6 +972,9 @@ int nand_init(void)
968 972
969 if (log_segment < segments_per_bank * total_banks) 973 if (log_segment < segments_per_bank * total_banks)
970 { 974 {
975#ifndef BOOTLOADER
976 lpt_lookup = core_get_data(lpt_handle);
977#endif
971 if (lpt_lookup[log_segment].bank == -1 || 978 if (lpt_lookup[log_segment].bank == -1 ||
972 lpt_lookup[log_segment].phys_segment == -1) 979 lpt_lookup[log_segment].phys_segment == -1)
973 { 980 {
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