diff options
author | Thomas Martitz <kugel@rockbox.org> | 2011-08-30 14:01:33 +0000 |
---|---|---|
committer | Thomas Martitz <kugel@rockbox.org> | 2011-08-30 14:01:33 +0000 |
commit | d0b72e25903574acb1cf9184a6052cdd646dbc37 (patch) | |
tree | 5be8db5ee00b2a727e4821cf51a5f7bcf3991073 /firmware/target/arm/ata-nand-telechips.c | |
parent | c940811ade7d99a0e0d414df7c6509672413684a (diff) | |
download | rockbox-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/ata-nand-telechips.c')
-rw-r--r-- | firmware/target/arm/ata-nand-telechips.c | 15 |
1 files changed, 11 insertions, 4 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 |
123 | static struct lpt_entry lpt_lookup[MAX_SEGMENTS]; | 122 | static 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 */ |
126 | static struct lpt_entry* lpt_lookup = NULL; | 125 | #include "core_alloc.h" |
126 | static 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 | { |