summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2008-04-06 04:34:57 +0000
committerMichael Sevakis <jethead71@rockbox.org>2008-04-06 04:34:57 +0000
commit05099149f193cac0c81b0129c17feb78b1a9681a (patch)
tree3dd5494dd494bcb4490ddcedef99e9f3a895cd3f
parentbe698f086de4641a45dffd9289671588c2391a3c (diff)
downloadrockbox-05099149f193cac0c81b0129c17feb78b1a9681a.tar.gz
rockbox-05099149f193cac0c81b0129c17feb78b1a9681a.zip
Enable nocache sections using the linker. PP5022/4 must use SW_CORELOCK now with shared variables in DRAM (it seems swp(b) is at least partially broken on all PP or I'm doing something very wrong here :\). For core-shared data use SHAREDBSS/DATA_ATTR. NOCACHEBSS/DATA_ATTR is available whether or not single core is forced for static peripheral-DMA buffer allocation without use of the UNCACHED_ADDR macro in code and is likely useful on a non-PP target with a data cache (although not actually enabled in config.h and the .lds's in this commit).
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16981 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/codecs/spc.c2
-rw-r--r--apps/codecs/spc/spc_codec.h8
-rw-r--r--apps/playback.c16
-rw-r--r--apps/plugins/mpegplayer/alloc.c8
-rw-r--r--apps/plugins/mpegplayer/audio_thread.c4
-rw-r--r--apps/plugins/mpegplayer/disk_buf.c10
-rw-r--r--apps/plugins/mpegplayer/disk_buf.h2
-rw-r--r--apps/plugins/mpegplayer/mpeg_parser.c2
-rw-r--r--apps/plugins/mpegplayer/stream_mgr.c6
-rw-r--r--apps/plugins/mpegplayer/stream_mgr.h2
-rw-r--r--apps/plugins/mpegplayer/video_out_rockbox.c2
-rw-r--r--apps/plugins/mpegplayer/video_thread.c4
-rw-r--r--apps/plugins/plugin.lds47
-rw-r--r--apps/voice_thread.c10
-rw-r--r--firmware/drivers/ata.c2
-rw-r--r--firmware/drivers/fat.c2
-rw-r--r--firmware/export/config.h24
-rw-r--r--firmware/kernel.c4
-rw-r--r--firmware/pcm.c14
-rw-r--r--firmware/pcm_record.c4
-rw-r--r--firmware/system.c8
-rw-r--r--firmware/target/arm/i2c-pp.c2
-rw-r--r--firmware/target/arm/ipod/1g2g/adc-ipod-1g2g.c2
-rw-r--r--firmware/target/arm/ipod/app.lds56
-rw-r--r--firmware/target/arm/ipod/boot.lds2
-rw-r--r--firmware/target/arm/iriver/app.lds56
-rw-r--r--firmware/target/arm/iriver/boot.lds2
-rw-r--r--firmware/target/arm/iriver/h10/lcd-h10_20gb.c2
-rw-r--r--firmware/target/arm/olympus/app.lds56
-rw-r--r--firmware/target/arm/olympus/boot.lds2
-rw-r--r--firmware/target/arm/pcm-pp.c6
-rw-r--r--firmware/target/arm/sandisk/app.lds56
-rw-r--r--firmware/target/arm/sandisk/ata-c200_e200.c2
-rw-r--r--firmware/target/arm/sandisk/boot.lds2
-rw-r--r--firmware/target/arm/sandisk/sansa-c200/lcd-c200.c2
-rw-r--r--firmware/target/arm/sandisk/sansa-e200/lcd-e200.c4
-rw-r--r--firmware/target/arm/system-target.h2
-rw-r--r--firmware/target/arm/tcc780x/ata-nand-tcc780x.c2
-rw-r--r--firmware/thread.c4
-rw-r--r--firmware/timer.c6
40 files changed, 322 insertions, 125 deletions
diff --git a/apps/codecs/spc.c b/apps/codecs/spc.c
index 0a608dfa4a..948a05edd8 100644
--- a/apps/codecs/spc.c
+++ b/apps/codecs/spc.c
@@ -231,7 +231,7 @@ static struct
231 struct event emu_evt_reply; 231 struct event emu_evt_reply;
232 intptr_t retval; 232 intptr_t retval;
233 struct sample_queue_chunk wav_chunk[WAV_NUM_CHUNKS]; 233 struct sample_queue_chunk wav_chunk[WAV_NUM_CHUNKS];
234} sample_queue NOCACHEBSS_ATTR; 234} sample_queue SHAREDBSS_ATTR;
235 235
236static inline void samples_release_wrbuf(void) 236static inline void samples_release_wrbuf(void)
237{ 237{
diff --git a/apps/codecs/spc/spc_codec.h b/apps/codecs/spc/spc_codec.h
index a18aece645..f9127ef778 100644
--- a/apps/codecs/spc/spc_codec.h
+++ b/apps/codecs/spc/spc_codec.h
@@ -97,10 +97,10 @@
97#endif 97#endif
98 98
99#if SPC_DUAL_CORE 99#if SPC_DUAL_CORE
100 #undef NOCACHEBSS_ATTR 100 #undef SHAREDBSS_ATTR
101 #define NOCACHEBSS_ATTR __attribute__ ((section(".ibss"))) 101 #define SHAREDBSS_ATTR __attribute__ ((section(".ibss")))
102 #undef NOCACHEDATA_ATTR 102 #undef SHAREDDATA_ATTR
103 #define NOCACHEDATA_ATTR __attribute__((section(".idata"))) 103 #define SHAREDDATA_ATTR __attribute__((section(".idata")))
104#endif 104#endif
105#endif 105#endif
106 106
diff --git a/apps/playback.c b/apps/playback.c
index b145823485..8fa94468fb 100644
--- a/apps/playback.c
+++ b/apps/playback.c
@@ -172,7 +172,7 @@ enum filling_state {
172#endif 172#endif
173 173
174bool audio_is_initialized = false; 174bool audio_is_initialized = false;
175static bool audio_thread_ready NOCACHEBSS_ATTR = false; 175static bool audio_thread_ready SHAREDBSS_ATTR = false;
176 176
177/* Variables are commented with the threads that use them: * 177/* Variables are commented with the threads that use them: *
178 * A=audio, C=codec, V=voice. A suffix of - indicates that * 178 * A=audio, C=codec, V=voice. A suffix of - indicates that *
@@ -180,9 +180,9 @@ static bool audio_thread_ready NOCACHEBSS_ATTR = false;
180/* TBD: Split out "audio" and "playback" (ie. calling) threads */ 180/* TBD: Split out "audio" and "playback" (ie. calling) threads */
181 181
182/* Main state control */ 182/* Main state control */
183static volatile bool audio_codec_loaded NOCACHEBSS_ATTR = false; /* Codec loaded? (C/A-) */ 183static volatile bool audio_codec_loaded SHAREDBSS_ATTR = false; /* Codec loaded? (C/A-) */
184static volatile bool playing NOCACHEBSS_ATTR = false; /* Is audio playing? (A) */ 184static volatile bool playing SHAREDBSS_ATTR = false; /* Is audio playing? (A) */
185static volatile bool paused NOCACHEBSS_ATTR = false; /* Is audio paused? (A/C-) */ 185static volatile bool paused SHAREDBSS_ATTR = false; /* Is audio paused? (A/C-) */
186 186
187/* Ring buffer where compressed audio and codecs are loaded */ 187/* Ring buffer where compressed audio and codecs are loaded */
188static unsigned char *filebuf = NULL; /* Start of buffer (A/C-) */ 188static unsigned char *filebuf = NULL; /* Start of buffer (A/C-) */
@@ -261,8 +261,8 @@ static size_t buffer_margin = 0; /* Buffer margin aka anti-skip buffer (A/C-) *
261static void set_filebuf_watermark(int seconds, size_t max); 261static void set_filebuf_watermark(int seconds, size_t max);
262 262
263/* Audio thread */ 263/* Audio thread */
264static struct event_queue audio_queue NOCACHEBSS_ATTR; 264static struct event_queue audio_queue SHAREDBSS_ATTR;
265static struct queue_sender_list audio_queue_sender_list NOCACHEBSS_ATTR; 265static struct queue_sender_list audio_queue_sender_list SHAREDBSS_ATTR;
266static long audio_stack[(DEFAULT_STACK_SIZE + 0x1000)/sizeof(long)]; 266static long audio_stack[(DEFAULT_STACK_SIZE + 0x1000)/sizeof(long)];
267static const char audio_thread_name[] = "audio"; 267static const char audio_thread_name[] = "audio";
268 268
@@ -273,7 +273,7 @@ static void audio_reset_buffer(void);
273 273
274/* Codec thread */ 274/* Codec thread */
275extern struct codec_api ci; 275extern struct codec_api ci;
276static struct event_queue codec_queue NOCACHEBSS_ATTR; 276static struct event_queue codec_queue SHAREDBSS_ATTR;
277static struct queue_sender_list codec_queue_sender_list; 277static struct queue_sender_list codec_queue_sender_list;
278static long codec_stack[(DEFAULT_STACK_SIZE + 0x2000)/sizeof(long)] 278static long codec_stack[(DEFAULT_STACK_SIZE + 0x2000)/sizeof(long)]
279IBSS_ATTR; 279IBSS_ATTR;
@@ -281,7 +281,7 @@ static const char codec_thread_name[] = "codec";
281struct thread_entry *codec_thread_p; /* For modifying thread priority later. */ 281struct thread_entry *codec_thread_p; /* For modifying thread priority later. */
282 282
283/* PCM buffer messaging */ 283/* PCM buffer messaging */
284static struct event_queue pcmbuf_queue NOCACHEBSS_ATTR; 284static struct event_queue pcmbuf_queue SHAREDBSS_ATTR;
285 285
286/* Function to be called by pcm buffer callbacks. 286/* Function to be called by pcm buffer callbacks.
287 * Permissible Context(s): Audio interrupt 287 * Permissible Context(s): Audio interrupt
diff --git a/apps/plugins/mpegplayer/alloc.c b/apps/plugins/mpegplayer/alloc.c
index f6661d4632..7ad8644e59 100644
--- a/apps/plugins/mpegplayer/alloc.c
+++ b/apps/plugins/mpegplayer/alloc.c
@@ -30,10 +30,10 @@ static size_t bufsize;
30static unsigned char* mallocbuf; 30static unsigned char* mallocbuf;
31 31
32/* libmpeg2 allocator */ 32/* libmpeg2 allocator */
33static off_t mpeg2_mem_ptr NOCACHEBSS_ATTR; 33static off_t mpeg2_mem_ptr SHAREDBSS_ATTR;
34static size_t mpeg2_bufsize NOCACHEBSS_ATTR; 34static size_t mpeg2_bufsize SHAREDBSS_ATTR;
35static unsigned char *mpeg2_mallocbuf NOCACHEBSS_ATTR; 35static unsigned char *mpeg2_mallocbuf SHAREDBSS_ATTR;
36static unsigned char *mpeg2_bufallocbuf NOCACHEBSS_ATTR; 36static unsigned char *mpeg2_bufallocbuf SHAREDBSS_ATTR;
37 37
38#if defined(DEBUG) || defined(SIMULATOR) 38#if defined(DEBUG) || defined(SIMULATOR)
39const char * mpeg_get_reason_str(int reason) 39const char * mpeg_get_reason_str(int reason)
diff --git a/apps/plugins/mpegplayer/audio_thread.c b/apps/plugins/mpegplayer/audio_thread.c
index 7d2f849a44..1fcd1424ff 100644
--- a/apps/plugins/mpegplayer/audio_thread.c
+++ b/apps/plugins/mpegplayer/audio_thread.c
@@ -44,8 +44,8 @@ static size_t audio_stack_size; /* Keep gcc happy and init */
44#ifndef SIMULATOR 44#ifndef SIMULATOR
45static uint32_t codec_stack_copy[AUDIO_STACKSIZE / sizeof(uint32_t)]; 45static uint32_t codec_stack_copy[AUDIO_STACKSIZE / sizeof(uint32_t)];
46#endif 46#endif
47static struct event_queue audio_str_queue NOCACHEBSS_ATTR; 47static struct event_queue audio_str_queue SHAREDBSS_ATTR;
48static struct queue_sender_list audio_str_queue_send NOCACHEBSS_ATTR; 48static struct queue_sender_list audio_str_queue_send SHAREDBSS_ATTR;
49struct stream audio_str IBSS_ATTR; 49struct stream audio_str IBSS_ATTR;
50 50
51/* libmad related definitions */ 51/* libmad related definitions */
diff --git a/apps/plugins/mpegplayer/disk_buf.c b/apps/plugins/mpegplayer/disk_buf.c
index 289918fc63..46a060221d 100644
--- a/apps/plugins/mpegplayer/disk_buf.c
+++ b/apps/plugins/mpegplayer/disk_buf.c
@@ -21,12 +21,12 @@
21#include "plugin.h" 21#include "plugin.h"
22#include "mpegplayer.h" 22#include "mpegplayer.h"
23 23
24static struct mutex disk_buf_mtx NOCACHEBSS_ATTR; 24static struct mutex disk_buf_mtx SHAREDBSS_ATTR;
25static struct event_queue disk_buf_queue NOCACHEBSS_ATTR; 25static struct event_queue disk_buf_queue SHAREDBSS_ATTR;
26static struct queue_sender_list disk_buf_queue_send NOCACHEBSS_ATTR; 26static struct queue_sender_list disk_buf_queue_send SHAREDBSS_ATTR;
27static uint32_t disk_buf_stack[DEFAULT_STACK_SIZE*2/sizeof(uint32_t)]; 27static uint32_t disk_buf_stack[DEFAULT_STACK_SIZE*2/sizeof(uint32_t)];
28 28
29struct disk_buf disk_buf NOCACHEBSS_ATTR; 29struct disk_buf disk_buf SHAREDBSS_ATTR;
30static struct list_item nf_list; 30static struct list_item nf_list;
31 31
32static inline void disk_buf_lock(void) 32static inline void disk_buf_lock(void)
@@ -566,7 +566,7 @@ static int disk_buf_probe(off_t start, size_t length,
566 { 566 {
567 if (disk_buf.cache[page] != tag) 567 if (disk_buf.cache[page] != tag)
568 { 568 {
569 static struct dbuf_range rng NOCACHEBSS_ATTR; 569 static struct dbuf_range rng IBSS_ATTR;
570 DEBUGF("disk_buf: cache miss\n"); 570 DEBUGF("disk_buf: cache miss\n");
571 rng.tag_start = tag; 571 rng.tag_start = tag;
572 rng.tag_end = tag_end; 572 rng.tag_end = tag_end;
diff --git a/apps/plugins/mpegplayer/disk_buf.h b/apps/plugins/mpegplayer/disk_buf.h
index 79c3328535..04b4675768 100644
--- a/apps/plugins/mpegplayer/disk_buf.h
+++ b/apps/plugins/mpegplayer/disk_buf.h
@@ -84,7 +84,7 @@ struct disk_buf
84 bool need_seek; /* Need to seek because a read was not contiguous */ 84 bool need_seek; /* Need to seek because a read was not contiguous */
85}; 85};
86 86
87extern struct disk_buf disk_buf NOCACHEBSS_ATTR; 87extern struct disk_buf disk_buf SHAREDBSS_ATTR;
88 88
89static inline bool disk_buf_is_data_ready(struct stream_hdr *sh, 89static inline bool disk_buf_is_data_ready(struct stream_hdr *sh,
90 ssize_t margin) 90 ssize_t margin)
diff --git a/apps/plugins/mpegplayer/mpeg_parser.c b/apps/plugins/mpegplayer/mpeg_parser.c
index cd54e84452..617b7fe9f9 100644
--- a/apps/plugins/mpegplayer/mpeg_parser.c
+++ b/apps/plugins/mpegplayer/mpeg_parser.c
@@ -21,7 +21,7 @@
21#include "plugin.h" 21#include "plugin.h"
22#include "mpegplayer.h" 22#include "mpegplayer.h"
23 23
24struct stream_parser str_parser NOCACHEBSS_ATTR; 24struct stream_parser str_parser SHAREDBSS_ATTR;
25 25
26static void parser_init_state(void) 26static void parser_init_state(void)
27{ 27{
diff --git a/apps/plugins/mpegplayer/stream_mgr.c b/apps/plugins/mpegplayer/stream_mgr.c
index 778ed0df83..24e820b0af 100644
--- a/apps/plugins/mpegplayer/stream_mgr.c
+++ b/apps/plugins/mpegplayer/stream_mgr.c
@@ -27,11 +27,11 @@
27GREY_INFO_STRUCT_IRAM 27GREY_INFO_STRUCT_IRAM
28#endif 28#endif
29 29
30static struct event_queue stream_mgr_queue NOCACHEBSS_ATTR; 30static struct event_queue stream_mgr_queue SHAREDBSS_ATTR;
31static struct queue_sender_list stream_mgr_queue_send NOCACHEBSS_ATTR; 31static struct queue_sender_list stream_mgr_queue_send SHAREDBSS_ATTR;
32static uint32_t stream_mgr_thread_stack[DEFAULT_STACK_SIZE*2/sizeof(uint32_t)]; 32static uint32_t stream_mgr_thread_stack[DEFAULT_STACK_SIZE*2/sizeof(uint32_t)];
33 33
34struct stream_mgr stream_mgr NOCACHEBSS_ATTR; 34struct stream_mgr stream_mgr SHAREDBSS_ATTR;
35 35
36/* Forward decs */ 36/* Forward decs */
37static int stream_on_close(void); 37static int stream_on_close(void);
diff --git a/apps/plugins/mpegplayer/stream_mgr.h b/apps/plugins/mpegplayer/stream_mgr.h
index 339af17182..f577e5c2ce 100644
--- a/apps/plugins/mpegplayer/stream_mgr.h
+++ b/apps/plugins/mpegplayer/stream_mgr.h
@@ -44,7 +44,7 @@ struct stream_mgr
44 } parms; 44 } parms;
45}; 45};
46 46
47extern struct stream_mgr stream_mgr NOCACHEBSS_ATTR; 47extern struct stream_mgr stream_mgr SHAREDBSS_ATTR;
48 48
49struct stream_window 49struct stream_window
50{ 50{
diff --git a/apps/plugins/mpegplayer/video_out_rockbox.c b/apps/plugins/mpegplayer/video_out_rockbox.c
index c8245cc1bf..547768887a 100644
--- a/apps/plugins/mpegplayer/video_out_rockbox.c
+++ b/apps/plugins/mpegplayer/video_out_rockbox.c
@@ -52,7 +52,7 @@ static struct vo_data vo;
52#endif 52#endif
53 53
54#if NUM_CORES > 1 54#if NUM_CORES > 1
55static struct mutex vo_mtx NOCACHEBSS_ATTR; 55static struct mutex vo_mtx SHAREDBSS_ATTR;
56#endif 56#endif
57 57
58static inline void video_lock_init(void) 58static inline void video_lock_init(void)
diff --git a/apps/plugins/mpegplayer/video_thread.c b/apps/plugins/mpegplayer/video_thread.c
index d16eb771b0..6e7c9aea15 100644
--- a/apps/plugins/mpegplayer/video_thread.c
+++ b/apps/plugins/mpegplayer/video_thread.c
@@ -54,8 +54,8 @@ struct video_thread_data
54 so maybe we can reduce it. */ 54 so maybe we can reduce it. */
55#define VIDEO_STACKSIZE (4*1024) 55#define VIDEO_STACKSIZE (4*1024)
56static uint32_t video_stack[VIDEO_STACKSIZE / sizeof(uint32_t)] IBSS_ATTR; 56static uint32_t video_stack[VIDEO_STACKSIZE / sizeof(uint32_t)] IBSS_ATTR;
57static struct event_queue video_str_queue NOCACHEBSS_ATTR; 57static struct event_queue video_str_queue SHAREDBSS_ATTR;
58static struct queue_sender_list video_str_queue_send NOCACHEBSS_ATTR; 58static struct queue_sender_list video_str_queue_send SHAREDBSS_ATTR;
59struct stream video_str IBSS_ATTR; 59struct stream video_str IBSS_ATTR;
60 60
61static void draw_fps(struct video_thread_data *td) 61static void draw_fps(struct video_thread_data *td)
diff --git a/apps/plugins/plugin.lds b/apps/plugins/plugin.lds
index 9659412730..8699ca1c25 100644
--- a/apps/plugins/plugin.lds
+++ b/apps/plugins/plugin.lds
@@ -16,6 +16,20 @@ OUTPUT_FORMAT(elf32-sh)
16#define STUBOFFSET 0 16#define STUBOFFSET 0
17#endif 17#endif
18 18
19#if defined(CPU_PP)
20#ifdef CPU_PP502x
21#define NOCACHE_BASE 0x10000000
22#else
23#define NOCACHE_BASE 0x28000000
24#endif /* CPU_* */
25#define CACHEALIGN_SIZE 16
26#endif /* CPU_PP */
27
28#ifndef NOCACHE_BASE
29/* Default to no offset if target doesn't define this */
30#define NOCACHE_BASE 0x00000000
31#endif
32
19#if CONFIG_CPU==S3C2440 33#if CONFIG_CPU==S3C2440
20#include "s3c2440.h" 34#include "s3c2440.h"
21#define DRAMSIZE (MEMORYSIZE * 0x100000) - 0x100 - PLUGIN_BUFFER_SIZE - STUBOFFSET - CODEC_SIZE - LCD_BUFFER_SIZE - TTB_SIZE 35#define DRAMSIZE (MEMORYSIZE * 0x100000) - 0x100 - PLUGIN_BUFFER_SIZE - STUBOFFSET - CODEC_SIZE - LCD_BUFFER_SIZE - TTB_SIZE
@@ -119,10 +133,20 @@ SECTIONS
119 .data : 133 .data :
120 { 134 {
121 *(.data*) 135 *(.data*)
136 } > PLUGIN_RAM
137
138#if NOCACHE_BASE != 0
139 .ncdata . + NOCACHE_BASE :
140 {
141 . = ALIGN(CACHEALIGN_SIZE);
142 *(.ncdata*)
143 . = ALIGN(CACHEALIGN_SIZE);
144 } AT> PLUGIN_RAM
145#endif
146
122#if defined(IRAMSIZE) 147#if defined(IRAMSIZE)
123 iramcopy = .; 148 iramcopy = . - NOCACHE_BASE;
124#endif 149#endif
125 } > PLUGIN_RAM
126 150
127 /DISCARD/ : 151 /DISCARD/ :
128 { 152 {
@@ -139,6 +163,7 @@ SECTIONS
139 iramend = .; 163 iramend = .;
140 } > PLUGIN_IRAM 164 } > PLUGIN_IRAM
141 165
166
142 .ibss (NOLOAD) : 167 .ibss (NOLOAD) :
143 { 168 {
144 iedata = .; 169 iedata = .;
@@ -150,13 +175,27 @@ SECTIONS
150 175
151 .bss (NOLOAD) : 176 .bss (NOLOAD) :
152 { 177 {
153 plugin_bss_start = .; 178 plugin_bss_start = .;
154 *(.bss*) 179 *(.bss*)
155 *(COMMON) 180 *(COMMON)
156 . = ALIGN(0x4); 181 . = ALIGN(0x4);
182 } > PLUGIN_RAM
183
184#if NOCACHE_BASE != 0
185 .ncbss . + NOCACHE_BASE (NOLOAD) :
186 {
187 . = ALIGN(CACHEALIGN_SIZE);
188 *(.ncbss*)
189 . = ALIGN(CACHEALIGN_SIZE);
190 } AT> PLUGIN_RAM
191#endif
192
193 /* Restore . */
194 .pluginend . - NOCACHE_BASE :
195 {
157 _plugin_end_addr = .; 196 _plugin_end_addr = .;
158 plugin_end_addr = .; 197 plugin_end_addr = .;
159 } > PLUGIN_RAM 198 }
160 199
161 /* Special trick to avoid a linker error when no other sections are 200 /* Special trick to avoid a linker error when no other sections are
162 left after garbage collection (plugin not for this platform) */ 201 left after garbage collection (plugin not for this platform) */
diff --git a/apps/voice_thread.c b/apps/voice_thread.c
index 0da441191f..c59089d672 100644
--- a/apps/voice_thread.c
+++ b/apps/voice_thread.c
@@ -57,10 +57,10 @@ static long voice_stack[0x7c0/sizeof(long)] IBSS_ATTR_VOICE_STACK;
57static const char voice_thread_name[] = "voice"; 57static const char voice_thread_name[] = "voice";
58 58
59/* Voice thread synchronization objects */ 59/* Voice thread synchronization objects */
60static struct event_queue voice_queue NOCACHEBSS_ATTR; 60static struct event_queue voice_queue SHAREDBSS_ATTR;
61static struct mutex voice_mutex NOCACHEBSS_ATTR; 61static struct mutex voice_mutex SHAREDBSS_ATTR;
62static struct event voice_event NOCACHEBSS_ATTR; 62static struct event voice_event SHAREDBSS_ATTR;
63static struct queue_sender_list voice_queue_sender_list NOCACHEBSS_ATTR; 63static struct queue_sender_list voice_queue_sender_list SHAREDBSS_ATTR;
64 64
65/* Buffer for decoded samples */ 65/* Buffer for decoded samples */
66static spx_int16_t voice_output_buf[VOICE_FRAME_SIZE] CACHEALIGN_ATTR; 66static spx_int16_t voice_output_buf[VOICE_FRAME_SIZE] CACHEALIGN_ATTR;
@@ -115,7 +115,7 @@ void mp3_play_data(const unsigned char* start, int size,
115{ 115{
116 /* Shared struct to get data to the thread - once it replies, it has 116 /* Shared struct to get data to the thread - once it replies, it has
117 * safely cached it in its own private data */ 117 * safely cached it in its own private data */
118 static struct voice_info voice_clip NOCACHEBSS_ATTR; 118 static struct voice_info voice_clip SHAREDBSS_ATTR;
119 119
120 if (get_more != NULL && start != NULL && (ssize_t)size > 0) 120 if (get_more != NULL && start != NULL && (ssize_t)size > 0)
121 { 121 {
diff --git a/firmware/drivers/ata.c b/firmware/drivers/ata.c
index 681160cf01..57164c4749 100644
--- a/firmware/drivers/ata.c
+++ b/firmware/drivers/ata.c
@@ -134,7 +134,7 @@ static void ata_lock_unlock(struct ata_lock *l)
134#define mutex_unlock ata_lock_unlock 134#define mutex_unlock ata_lock_unlock
135#endif /* MAX_PHYS_SECTOR_SIZE */ 135#endif /* MAX_PHYS_SECTOR_SIZE */
136 136
137static struct mutex ata_mtx NOCACHEBSS_ATTR; 137static struct mutex ata_mtx SHAREDBSS_ATTR;
138int ata_device; /* device 0 (master) or 1 (slave) */ 138int ata_device; /* device 0 (master) or 1 (slave) */
139 139
140int ata_spinup_time = 0; 140int ata_spinup_time = 0;
diff --git a/firmware/drivers/fat.c b/firmware/drivers/fat.c
index a538b92695..002e100405 100644
--- a/firmware/drivers/fat.c
+++ b/firmware/drivers/fat.c
@@ -201,7 +201,7 @@ struct fat_cache_entry
201 201
202static char fat_cache_sectors[FAT_CACHE_SIZE][SECTOR_SIZE]; 202static char fat_cache_sectors[FAT_CACHE_SIZE][SECTOR_SIZE];
203static struct fat_cache_entry fat_cache[FAT_CACHE_SIZE]; 203static struct fat_cache_entry fat_cache[FAT_CACHE_SIZE];
204static struct mutex cache_mutex NOCACHEBSS_ATTR; 204static struct mutex cache_mutex SHAREDBSS_ATTR;
205 205
206#if defined(HAVE_HOTSWAP) && !defined(HAVE_MMC) /* A better condition ?? */ 206#if defined(HAVE_HOTSWAP) && !defined(HAVE_MMC) /* A better condition ?? */
207void fat_lock(void) 207void fat_lock(void)
diff --git a/firmware/export/config.h b/firmware/export/config.h
index cd98fc9dca..a93152b5e7 100644
--- a/firmware/export/config.h
+++ b/firmware/export/config.h
@@ -457,25 +457,30 @@
457 and not a special semaphore instruction */ 457 and not a special semaphore instruction */
458#define CORELOCK_SWAP 2 /* A swap (exchange) instruction */ 458#define CORELOCK_SWAP 2 /* A swap (exchange) instruction */
459 459
460/* Dual core support - not yet working on the 1G/2G and 3G iPod */
461#if defined(CPU_PP) 460#if defined(CPU_PP)
462#define IDLE_STACK_SIZE 0x80 461#define IDLE_STACK_SIZE 0x80
463#define IDLE_STACK_WORDS 0x20 462#define IDLE_STACK_WORDS 0x20
464 463
464/* Attributes to place data in uncached DRAM */
465/* These are useful beyond dual-core and ultimately beyond PP since they may
466 * be used for DMA buffers and such without cache maintenence calls. */
467#define NOCACHEBSS_ATTR __attribute__((section(".ncbss"),nocommon))
468#define NOCACHEDATA_ATTR __attribute__((section(".ncdata"),nocommon))
469
465#if !defined(FORCE_SINGLE_CORE) 470#if !defined(FORCE_SINGLE_CORE)
466 471
467#define NUM_CORES 2 472#define NUM_CORES 2
468#define CURRENT_CORE current_core() 473#define CURRENT_CORE current_core()
469/* Use IRAM for variables shared across cores - large memory buffers should 474/* Attributes for core-shared data in DRAM where IRAM is better used for other
470 * use UNCACHED_ADDR(a) and be appropriately aligned and padded */ 475 * purposes. */
471#define NOCACHEBSS_ATTR IBSS_ATTR 476#define SHAREDBSS_ATTR NOCACHEBSS_ATTR
472#define NOCACHEDATA_ATTR IDATA_ATTR 477#define SHAREDDATA_ATTR NOCACHEDATA_ATTR
473 478
474#define IF_COP(...) __VA_ARGS__ 479#define IF_COP(...) __VA_ARGS__
475#define IF_COP_VOID(...) __VA_ARGS__ 480#define IF_COP_VOID(...) __VA_ARGS__
476#define IF_COP_CORE(core) core 481#define IF_COP_CORE(core) core
477 482
478#if CONFIG_CPU == PP5020 || CONFIG_CPU == PP5002 483#ifdef CPU_PP
479#define CONFIG_CORELOCK SW_CORELOCK /* SWP(B) is broken */ 484#define CONFIG_CORELOCK SW_CORELOCK /* SWP(B) is broken */
480#else 485#else
481#define CONFIG_CORELOCK CORELOCK_SWAP 486#define CONFIG_CORELOCK CORELOCK_SWAP
@@ -500,9 +505,10 @@
500#ifndef NUM_CORES 505#ifndef NUM_CORES
501/* Default to single core */ 506/* Default to single core */
502#define NUM_CORES 1 507#define NUM_CORES 1
503#define CURRENT_CORE CPU 508#define CURRENT_CORE CPU
504#define NOCACHEBSS_ATTR 509/* Attributes for core-shared data in DRAM - no caching considerations */
505#define NOCACHEDATA_ATTR 510#define SHAREDBSS_ATTR
511#define SHAREDDATA_ATTR
506#define CONFIG_CORELOCK CORELOCK_NONE 512#define CONFIG_CORELOCK CORELOCK_NONE
507 513
508#define IF_COP(...) 514#define IF_COP(...)
diff --git a/firmware/kernel.c b/firmware/kernel.c
index 1882855985..8ee553e121 100644
--- a/firmware/kernel.c
+++ b/firmware/kernel.c
@@ -49,7 +49,7 @@
49#endif 49#endif
50 50
51#if !defined(CPU_PP) || !defined(BOOTLOADER) 51#if !defined(CPU_PP) || !defined(BOOTLOADER)
52volatile long current_tick NOCACHEDATA_ATTR = 0; 52volatile long current_tick SHAREDDATA_ATTR = 0;
53#endif 53#endif
54 54
55void (*tick_funcs[MAX_NUM_TICK_TASKS])(void); 55void (*tick_funcs[MAX_NUM_TICK_TASKS])(void);
@@ -62,7 +62,7 @@ static struct
62 int count; 62 int count;
63 struct event_queue *queues[MAX_NUM_QUEUES]; 63 struct event_queue *queues[MAX_NUM_QUEUES];
64 IF_COP( struct corelock cl; ) 64 IF_COP( struct corelock cl; )
65} all_queues NOCACHEBSS_ATTR; 65} all_queues SHAREDBSS_ATTR;
66 66
67/**************************************************************************** 67/****************************************************************************
68 * Standard kernel stuff 68 * Standard kernel stuff
diff --git a/firmware/pcm.c b/firmware/pcm.c
index 9f354f1e40..a4e107ad4d 100644
--- a/firmware/pcm.c
+++ b/firmware/pcm.c
@@ -67,13 +67,13 @@
67 67
68/* the registered callback function to ask for more mp3 data */ 68/* the registered callback function to ask for more mp3 data */
69volatile pcm_more_callback_type pcm_callback_for_more 69volatile pcm_more_callback_type pcm_callback_for_more
70 NOCACHEBSS_ATTR = NULL; 70 SHAREDBSS_ATTR = NULL;
71/* PCM playback state */ 71/* PCM playback state */
72volatile bool pcm_playing NOCACHEBSS_ATTR = false; 72volatile bool pcm_playing SHAREDBSS_ATTR = false;
73/* PCM paused state. paused implies playing */ 73/* PCM paused state. paused implies playing */
74volatile bool pcm_paused NOCACHEBSS_ATTR = false; 74volatile bool pcm_paused SHAREDBSS_ATTR = false;
75/* samplerate of currently playing audio - undefined if stopped */ 75/* samplerate of currently playing audio - undefined if stopped */
76unsigned long pcm_curr_sampr NOCACHEBSS_ATTR = 0; 76unsigned long pcm_curr_sampr SHAREDBSS_ATTR = 0;
77 77
78/** 78/**
79 * Do peak calculation using distance squared from axis and save a lot 79 * Do peak calculation using distance squared from axis and save a lot
@@ -312,12 +312,12 @@ void pcm_mute(bool mute)
312/** Low level pcm recording apis **/ 312/** Low level pcm recording apis **/
313 313
314/* Next start for recording peaks */ 314/* Next start for recording peaks */
315const volatile void *pcm_rec_peak_addr NOCACHEBSS_ATTR = NULL; 315const volatile void *pcm_rec_peak_addr SHAREDBSS_ATTR = NULL;
316/* the registered callback function for when more data is available */ 316/* the registered callback function for when more data is available */
317volatile pcm_more_callback_type2 317volatile pcm_more_callback_type2
318 pcm_callback_more_ready NOCACHEBSS_ATTR = NULL; 318 pcm_callback_more_ready SHAREDBSS_ATTR = NULL;
319/* DMA transfer in is currently active */ 319/* DMA transfer in is currently active */
320volatile bool pcm_recording NOCACHEBSS_ATTR = false; 320volatile bool pcm_recording SHAREDBSS_ATTR = false;
321 321
322/** 322/**
323 * Return recording peaks - From the end of the last peak up to 323 * Return recording peaks - From the end of the last peak up to
diff --git a/firmware/pcm_record.c b/firmware/pcm_record.c
index 49da257c08..6e65e678a3 100644
--- a/firmware/pcm_record.c
+++ b/firmware/pcm_record.c
@@ -212,8 +212,8 @@ enum
212 212
213/***************************************************************************/ 213/***************************************************************************/
214 214
215static struct event_queue pcmrec_queue NOCACHEBSS_ATTR; 215static struct event_queue pcmrec_queue SHAREDBSS_ATTR;
216static struct queue_sender_list pcmrec_queue_send NOCACHEBSS_ATTR; 216static struct queue_sender_list pcmrec_queue_send SHAREDBSS_ATTR;
217static long pcmrec_stack[3*DEFAULT_STACK_SIZE/sizeof(long)]; 217static long pcmrec_stack[3*DEFAULT_STACK_SIZE/sizeof(long)];
218static const char pcmrec_thread_name[] = "pcmrec"; 218static const char pcmrec_thread_name[] = "pcmrec";
219static struct thread_entry *pcmrec_thread_p; 219static struct thread_entry *pcmrec_thread_p;
diff --git a/firmware/system.c b/firmware/system.c
index 65478e724b..15eb77eada 100644
--- a/firmware/system.c
+++ b/firmware/system.c
@@ -29,14 +29,14 @@
29#include "string.h" 29#include "string.h"
30 30
31#ifndef SIMULATOR 31#ifndef SIMULATOR
32long cpu_frequency NOCACHEBSS_ATTR = CPU_FREQ; 32long cpu_frequency SHAREDBSS_ATTR = CPU_FREQ;
33#endif 33#endif
34 34
35#ifdef HAVE_ADJUSTABLE_CPU_FREQ 35#ifdef HAVE_ADJUSTABLE_CPU_FREQ
36static int boost_counter NOCACHEBSS_ATTR = 0; 36static int boost_counter SHAREDBSS_ATTR = 0;
37static bool cpu_idle NOCACHEBSS_ATTR = false; 37static bool cpu_idle SHAREDBSS_ATTR = false;
38#if NUM_CORES > 1 38#if NUM_CORES > 1
39struct spinlock boostctrl_spin NOCACHEBSS_ATTR; 39struct spinlock boostctrl_spin SHAREDBSS_ATTR;
40void cpu_boost_init(void) 40void cpu_boost_init(void)
41{ 41{
42 spinlock_init(&boostctrl_spin); 42 spinlock_init(&boostctrl_spin);
diff --git a/firmware/target/arm/i2c-pp.c b/firmware/target/arm/i2c-pp.c
index 450effc32d..40eb80cfe1 100644
--- a/firmware/target/arm/i2c-pp.c
+++ b/firmware/target/arm/i2c-pp.c
@@ -33,7 +33,7 @@
33#include "as3514.h" 33#include "as3514.h"
34 34
35/* Local functions definitions */ 35/* Local functions definitions */
36static struct mutex i2c_mtx NOCACHEBSS_ATTR; 36static struct mutex i2c_mtx SHAREDBSS_ATTR;
37 37
38#define POLL_TIMEOUT (HZ) 38#define POLL_TIMEOUT (HZ)
39 39
diff --git a/firmware/target/arm/ipod/1g2g/adc-ipod-1g2g.c b/firmware/target/arm/ipod/1g2g/adc-ipod-1g2g.c
index f80412023d..564eb2e642 100644
--- a/firmware/target/arm/ipod/1g2g/adc-ipod-1g2g.c
+++ b/firmware/target/arm/ipod/1g2g/adc-ipod-1g2g.c
@@ -22,7 +22,7 @@
22#include "hwcompat.h" 22#include "hwcompat.h"
23#include "kernel.h" 23#include "kernel.h"
24 24
25static struct mutex adc_mtx NOCACHEBSS_ATTR; 25static struct mutex adc_mtx SHAREDBSS_ATTR;
26 26
27/* used in the 2nd gen ADC interrupt */ 27/* used in the 2nd gen ADC interrupt */
28static unsigned int_data; 28static unsigned int_data;
diff --git a/firmware/target/arm/ipod/app.lds b/firmware/target/arm/ipod/app.lds
index 765a5f0389..54af494d72 100644
--- a/firmware/target/arm/ipod/app.lds
+++ b/firmware/target/arm/ipod/app.lds
@@ -21,6 +21,14 @@ INPUT(target/arm/crt0-pp.o)
21#define IRAMORIG 0x40000000 21#define IRAMORIG 0x40000000
22#define IRAMSIZE 0xc000 22#define IRAMSIZE 0xc000
23 23
24#ifdef CPU_PP502x
25#define NOCACHE_BASE 0x10000000
26#else
27#define NOCACHE_BASE 0x28000000
28#endif
29
30#define CACHEALIGN_SIZE 16
31
24/* End of the audio buffer, where the codec buffer starts */ 32/* End of the audio buffer, where the codec buffer starts */
25#define ENDAUDIOADDR (DRAMORIG + DRAMSIZE) 33#define ENDAUDIOADDR (DRAMORIG + DRAMSIZE)
26 34
@@ -70,6 +78,18 @@ SECTIONS
70 _dataend = .; 78 _dataend = .;
71 } > DRAM 79 } > DRAM
72 80
81#if NOCACHE_BASE != 0
82 /* .ncdata section is placed at uncached physical alias address and is
83 * loaded at the proper cached virtual address - no copying is
84 * performed in the init code */
85 .ncdata . + NOCACHE_BASE :
86 {
87 . = ALIGN(CACHEALIGN_SIZE);
88 *(.ncdata*)
89 . = ALIGN(CACHEALIGN_SIZE);
90 } AT> DRAM
91#endif
92
73 /DISCARD/ : 93 /DISCARD/ :
74 { 94 {
75 *(.eh_frame) 95 *(.eh_frame)
@@ -103,7 +123,7 @@ SECTIONS
103 _iend = .; 123 _iend = .;
104 } > IRAM 124 } > IRAM
105 125
106 .idle_stacks : 126 .idle_stacks (NOLOAD) :
107 { 127 {
108 *(.idle_stacks) 128 *(.idle_stacks)
109#if NUM_CORES > 1 129#if NUM_CORES > 1
@@ -116,7 +136,7 @@ SECTIONS
116 cop_idlestackend = .; 136 cop_idlestackend = .;
117 } > IRAM 137 } > IRAM
118 138
119 .stack : 139 .stack (NOLOAD) :
120 { 140 {
121 *(.stack) 141 *(.stack)
122 stackbegin = .; 142 stackbegin = .;
@@ -124,37 +144,53 @@ SECTIONS
124 stackend = .; 144 stackend = .;
125 } > IRAM 145 } > IRAM
126 146
127 .bss ADDR(.data) + SIZEOF(.data) + SIZEOF(.iram) + SIZEOF(.vectors): 147 /* .bss and .ncbss are treated as a single section to use one init loop to
148 * zero it - note "_edata" and "_end" */
149 .bss ADDR(.data) + SIZEOF(.data) + SIZEOF(.ncdata) +\
150 SIZEOF(.iram) + SIZEOF(.vectors) (NOLOAD) :
128 { 151 {
129 _edata = .; 152 _edata = .;
130 *(.bss*) 153 *(.bss*)
131 *(COMMON) 154 *(COMMON)
132 . = ALIGN(0x4); 155 . = ALIGN(0x4);
133 _end = .;
134 } > DRAM 156 } > DRAM
135 157
136 .audiobuf ALIGN(4) : 158#if NOCACHE_BASE != 0
159 .ncbss . + NOCACHE_BASE (NOLOAD):
160 {
161 . = ALIGN(CACHEALIGN_SIZE);
162 *(.ncbss*)
163 . = ALIGN(CACHEALIGN_SIZE);
164 } AT> DRAM
165#endif
166
167 /* This will be aligned by preceding alignments */
168 .endaddr . - NOCACHE_BASE (NOLOAD) :
169 {
170 _end = .;
171 } > DRAM
172
173 .audiobuf (NOLOAD) :
137 { 174 {
138 _audiobuffer = .; 175 _audiobuffer = .;
139 audiobuffer = .; 176 audiobuffer = .;
140 } > DRAM 177 } > DRAM
141 178
142 .audiobufend ENDAUDIOADDR: 179 .audiobufend ENDAUDIOADDR (NOLOAD) :
143 { 180 {
144 audiobufend = .; 181 audiobufend = .;
145 _audiobufend = .; 182 _audiobufend = .;
146 } > DRAM 183 } > DRAM
147 184
148 .codec ENDAUDIOADDR: 185 .codec ENDAUDIOADDR (NOLOAD) :
149 { 186 {
150 codecbuf = .; 187 codecbuf = .;
151 _codecbuf = .; 188 _codecbuf = .;
152 } 189 }
153 190
154 .plugin ENDADDR: 191 .plugin ENDADDR (NOLOAD) :
155 { 192 {
156 _pluginbuf = .; 193 _pluginbuf = .;
157 pluginbuf = .; 194 pluginbuf = .;
158 } 195 }
159} 196}
160
diff --git a/firmware/target/arm/ipod/boot.lds b/firmware/target/arm/ipod/boot.lds
index 2f2f4f91a1..1f9c65d31c 100644
--- a/firmware/target/arm/ipod/boot.lds
+++ b/firmware/target/arm/ipod/boot.lds
@@ -43,6 +43,7 @@ SECTIONS
43 *(.irodata) 43 *(.irodata)
44 *(.idata) 44 *(.idata)
45 *(.data*) 45 *(.data*)
46 *(.ncdata*);
46 _dataend = . ; 47 _dataend = . ;
47 } 48 }
48 49
@@ -64,6 +65,7 @@ SECTIONS
64 _edata = .; 65 _edata = .;
65 *(.bss*); 66 *(.bss*);
66 *(.ibss); 67 *(.ibss);
68 *(.ncbss*);
67 _end = .; 69 _end = .;
68 } 70 }
69} 71}
diff --git a/firmware/target/arm/iriver/app.lds b/firmware/target/arm/iriver/app.lds
index 765a5f0389..54af494d72 100644
--- a/firmware/target/arm/iriver/app.lds
+++ b/firmware/target/arm/iriver/app.lds
@@ -21,6 +21,14 @@ INPUT(target/arm/crt0-pp.o)
21#define IRAMORIG 0x40000000 21#define IRAMORIG 0x40000000
22#define IRAMSIZE 0xc000 22#define IRAMSIZE 0xc000
23 23
24#ifdef CPU_PP502x
25#define NOCACHE_BASE 0x10000000
26#else
27#define NOCACHE_BASE 0x28000000
28#endif
29
30#define CACHEALIGN_SIZE 16
31
24/* End of the audio buffer, where the codec buffer starts */ 32/* End of the audio buffer, where the codec buffer starts */
25#define ENDAUDIOADDR (DRAMORIG + DRAMSIZE) 33#define ENDAUDIOADDR (DRAMORIG + DRAMSIZE)
26 34
@@ -70,6 +78,18 @@ SECTIONS
70 _dataend = .; 78 _dataend = .;
71 } > DRAM 79 } > DRAM
72 80
81#if NOCACHE_BASE != 0
82 /* .ncdata section is placed at uncached physical alias address and is
83 * loaded at the proper cached virtual address - no copying is
84 * performed in the init code */
85 .ncdata . + NOCACHE_BASE :
86 {
87 . = ALIGN(CACHEALIGN_SIZE);
88 *(.ncdata*)
89 . = ALIGN(CACHEALIGN_SIZE);
90 } AT> DRAM
91#endif
92
73 /DISCARD/ : 93 /DISCARD/ :
74 { 94 {
75 *(.eh_frame) 95 *(.eh_frame)
@@ -103,7 +123,7 @@ SECTIONS
103 _iend = .; 123 _iend = .;
104 } > IRAM 124 } > IRAM
105 125
106 .idle_stacks : 126 .idle_stacks (NOLOAD) :
107 { 127 {
108 *(.idle_stacks) 128 *(.idle_stacks)
109#if NUM_CORES > 1 129#if NUM_CORES > 1
@@ -116,7 +136,7 @@ SECTIONS
116 cop_idlestackend = .; 136 cop_idlestackend = .;
117 } > IRAM 137 } > IRAM
118 138
119 .stack : 139 .stack (NOLOAD) :
120 { 140 {
121 *(.stack) 141 *(.stack)
122 stackbegin = .; 142 stackbegin = .;
@@ -124,37 +144,53 @@ SECTIONS
124 stackend = .; 144 stackend = .;
125 } > IRAM 145 } > IRAM
126 146
127 .bss ADDR(.data) + SIZEOF(.data) + SIZEOF(.iram) + SIZEOF(.vectors): 147 /* .bss and .ncbss are treated as a single section to use one init loop to
148 * zero it - note "_edata" and "_end" */
149 .bss ADDR(.data) + SIZEOF(.data) + SIZEOF(.ncdata) +\
150 SIZEOF(.iram) + SIZEOF(.vectors) (NOLOAD) :
128 { 151 {
129 _edata = .; 152 _edata = .;
130 *(.bss*) 153 *(.bss*)
131 *(COMMON) 154 *(COMMON)
132 . = ALIGN(0x4); 155 . = ALIGN(0x4);
133 _end = .;
134 } > DRAM 156 } > DRAM
135 157
136 .audiobuf ALIGN(4) : 158#if NOCACHE_BASE != 0
159 .ncbss . + NOCACHE_BASE (NOLOAD):
160 {
161 . = ALIGN(CACHEALIGN_SIZE);
162 *(.ncbss*)
163 . = ALIGN(CACHEALIGN_SIZE);
164 } AT> DRAM
165#endif
166
167 /* This will be aligned by preceding alignments */
168 .endaddr . - NOCACHE_BASE (NOLOAD) :
169 {
170 _end = .;
171 } > DRAM
172
173 .audiobuf (NOLOAD) :
137 { 174 {
138 _audiobuffer = .; 175 _audiobuffer = .;
139 audiobuffer = .; 176 audiobuffer = .;
140 } > DRAM 177 } > DRAM
141 178
142 .audiobufend ENDAUDIOADDR: 179 .audiobufend ENDAUDIOADDR (NOLOAD) :
143 { 180 {
144 audiobufend = .; 181 audiobufend = .;
145 _audiobufend = .; 182 _audiobufend = .;
146 } > DRAM 183 } > DRAM
147 184
148 .codec ENDAUDIOADDR: 185 .codec ENDAUDIOADDR (NOLOAD) :
149 { 186 {
150 codecbuf = .; 187 codecbuf = .;
151 _codecbuf = .; 188 _codecbuf = .;
152 } 189 }
153 190
154 .plugin ENDADDR: 191 .plugin ENDADDR (NOLOAD) :
155 { 192 {
156 _pluginbuf = .; 193 _pluginbuf = .;
157 pluginbuf = .; 194 pluginbuf = .;
158 } 195 }
159} 196}
160
diff --git a/firmware/target/arm/iriver/boot.lds b/firmware/target/arm/iriver/boot.lds
index 5fbe999333..971ec6627b 100644
--- a/firmware/target/arm/iriver/boot.lds
+++ b/firmware/target/arm/iriver/boot.lds
@@ -27,6 +27,7 @@ SECTIONS
27 *(.irodata) 27 *(.irodata)
28 *(.idata) 28 *(.idata)
29 *(.data*) 29 *(.data*)
30 *(.ncdata*);
30 _dataend = . ; 31 _dataend = . ;
31 } 32 }
32 33
@@ -48,6 +49,7 @@ SECTIONS
48 _edata = .; 49 _edata = .;
49 *(.bss*); 50 *(.bss*);
50 *(.ibss); 51 *(.ibss);
52 *(.ncbss*);
51 _end = .; 53 _end = .;
52 } 54 }
53} 55}
diff --git a/firmware/target/arm/iriver/h10/lcd-h10_20gb.c b/firmware/target/arm/iriver/h10/lcd-h10_20gb.c
index 1c4116d2e7..1ee43c390f 100644
--- a/firmware/target/arm/iriver/h10/lcd-h10_20gb.c
+++ b/firmware/target/arm/iriver/h10/lcd-h10_20gb.c
@@ -34,7 +34,7 @@ static unsigned short disp_control_rev;
34/* Contrast setting << 8 */ 34/* Contrast setting << 8 */
35static int lcd_contrast; 35static int lcd_contrast;
36 36
37static unsigned lcd_yuv_options NOCACHEBSS_ATTR = 0; 37static unsigned lcd_yuv_options SHAREDBSS_ATTR = 0;
38 38
39/* Forward declarations */ 39/* Forward declarations */
40static void lcd_display_off(void); 40static void lcd_display_off(void);
diff --git a/firmware/target/arm/olympus/app.lds b/firmware/target/arm/olympus/app.lds
index 765a5f0389..54af494d72 100644
--- a/firmware/target/arm/olympus/app.lds
+++ b/firmware/target/arm/olympus/app.lds
@@ -21,6 +21,14 @@ INPUT(target/arm/crt0-pp.o)
21#define IRAMORIG 0x40000000 21#define IRAMORIG 0x40000000
22#define IRAMSIZE 0xc000 22#define IRAMSIZE 0xc000
23 23
24#ifdef CPU_PP502x
25#define NOCACHE_BASE 0x10000000
26#else
27#define NOCACHE_BASE 0x28000000
28#endif
29
30#define CACHEALIGN_SIZE 16
31
24/* End of the audio buffer, where the codec buffer starts */ 32/* End of the audio buffer, where the codec buffer starts */
25#define ENDAUDIOADDR (DRAMORIG + DRAMSIZE) 33#define ENDAUDIOADDR (DRAMORIG + DRAMSIZE)
26 34
@@ -70,6 +78,18 @@ SECTIONS
70 _dataend = .; 78 _dataend = .;
71 } > DRAM 79 } > DRAM
72 80
81#if NOCACHE_BASE != 0
82 /* .ncdata section is placed at uncached physical alias address and is
83 * loaded at the proper cached virtual address - no copying is
84 * performed in the init code */
85 .ncdata . + NOCACHE_BASE :
86 {
87 . = ALIGN(CACHEALIGN_SIZE);
88 *(.ncdata*)
89 . = ALIGN(CACHEALIGN_SIZE);
90 } AT> DRAM
91#endif
92
73 /DISCARD/ : 93 /DISCARD/ :
74 { 94 {
75 *(.eh_frame) 95 *(.eh_frame)
@@ -103,7 +123,7 @@ SECTIONS
103 _iend = .; 123 _iend = .;
104 } > IRAM 124 } > IRAM
105 125
106 .idle_stacks : 126 .idle_stacks (NOLOAD) :
107 { 127 {
108 *(.idle_stacks) 128 *(.idle_stacks)
109#if NUM_CORES > 1 129#if NUM_CORES > 1
@@ -116,7 +136,7 @@ SECTIONS
116 cop_idlestackend = .; 136 cop_idlestackend = .;
117 } > IRAM 137 } > IRAM
118 138
119 .stack : 139 .stack (NOLOAD) :
120 { 140 {
121 *(.stack) 141 *(.stack)
122 stackbegin = .; 142 stackbegin = .;
@@ -124,37 +144,53 @@ SECTIONS
124 stackend = .; 144 stackend = .;
125 } > IRAM 145 } > IRAM
126 146
127 .bss ADDR(.data) + SIZEOF(.data) + SIZEOF(.iram) + SIZEOF(.vectors): 147 /* .bss and .ncbss are treated as a single section to use one init loop to
148 * zero it - note "_edata" and "_end" */
149 .bss ADDR(.data) + SIZEOF(.data) + SIZEOF(.ncdata) +\
150 SIZEOF(.iram) + SIZEOF(.vectors) (NOLOAD) :
128 { 151 {
129 _edata = .; 152 _edata = .;
130 *(.bss*) 153 *(.bss*)
131 *(COMMON) 154 *(COMMON)
132 . = ALIGN(0x4); 155 . = ALIGN(0x4);
133 _end = .;
134 } > DRAM 156 } > DRAM
135 157
136 .audiobuf ALIGN(4) : 158#if NOCACHE_BASE != 0
159 .ncbss . + NOCACHE_BASE (NOLOAD):
160 {
161 . = ALIGN(CACHEALIGN_SIZE);
162 *(.ncbss*)
163 . = ALIGN(CACHEALIGN_SIZE);
164 } AT> DRAM
165#endif
166
167 /* This will be aligned by preceding alignments */
168 .endaddr . - NOCACHE_BASE (NOLOAD) :
169 {
170 _end = .;
171 } > DRAM
172
173 .audiobuf (NOLOAD) :
137 { 174 {
138 _audiobuffer = .; 175 _audiobuffer = .;
139 audiobuffer = .; 176 audiobuffer = .;
140 } > DRAM 177 } > DRAM
141 178
142 .audiobufend ENDAUDIOADDR: 179 .audiobufend ENDAUDIOADDR (NOLOAD) :
143 { 180 {
144 audiobufend = .; 181 audiobufend = .;
145 _audiobufend = .; 182 _audiobufend = .;
146 } > DRAM 183 } > DRAM
147 184
148 .codec ENDAUDIOADDR: 185 .codec ENDAUDIOADDR (NOLOAD) :
149 { 186 {
150 codecbuf = .; 187 codecbuf = .;
151 _codecbuf = .; 188 _codecbuf = .;
152 } 189 }
153 190
154 .plugin ENDADDR: 191 .plugin ENDADDR (NOLOAD) :
155 { 192 {
156 _pluginbuf = .; 193 _pluginbuf = .;
157 pluginbuf = .; 194 pluginbuf = .;
158 } 195 }
159} 196}
160
diff --git a/firmware/target/arm/olympus/boot.lds b/firmware/target/arm/olympus/boot.lds
index 5fbe999333..2c0245072c 100644
--- a/firmware/target/arm/olympus/boot.lds
+++ b/firmware/target/arm/olympus/boot.lds
@@ -27,6 +27,7 @@ SECTIONS
27 *(.irodata) 27 *(.irodata)
28 *(.idata) 28 *(.idata)
29 *(.data*) 29 *(.data*)
30 *(.ncdata*)
30 _dataend = . ; 31 _dataend = . ;
31 } 32 }
32 33
@@ -48,6 +49,7 @@ SECTIONS
48 _edata = .; 49 _edata = .;
49 *(.bss*); 50 *(.bss*);
50 *(.ibss); 51 *(.ibss);
52 *(.ncbss*);
51 _end = .; 53 _end = .;
52 } 54 }
53} 55}
diff --git a/firmware/target/arm/pcm-pp.c b/firmware/target/arm/pcm-pp.c
index 433e6e1e4f..64c6d0cdc8 100644
--- a/firmware/target/arm/pcm-pp.c
+++ b/firmware/target/arm/pcm-pp.c
@@ -72,7 +72,7 @@ void fiq_handler(void)
72/**************************************************************************** 72/****************************************************************************
73 ** Playback DMA transfer 73 ** Playback DMA transfer
74 **/ 74 **/
75struct dma_data dma_play_data NOCACHEBSS_ATTR = 75struct dma_data dma_play_data SHAREDBSS_ATTR =
76{ 76{
77 /* Initialize to a locked, stopped state */ 77 /* Initialize to a locked, stopped state */
78 .p = NULL, 78 .p = NULL,
@@ -84,7 +84,7 @@ struct dma_data dma_play_data NOCACHEBSS_ATTR =
84 .state = 0 84 .state = 0
85}; 85};
86 86
87static unsigned long pcm_freq NOCACHEDATA_ATTR = HW_SAMPR_DEFAULT; /* 44.1 is default */ 87static unsigned long pcm_freq SHAREDDATA_ATTR = HW_SAMPR_DEFAULT; /* 44.1 is default */
88#ifdef HAVE_WM8751 88#ifdef HAVE_WM8751
89/* Samplerate control for audio codec */ 89/* Samplerate control for audio codec */
90static int sr_ctrl = MROBE100_44100HZ; 90static int sr_ctrl = MROBE100_44100HZ;
@@ -356,7 +356,7 @@ const void * pcm_play_dma_get_peak_buffer(int *count)
356 **/ 356 **/
357#ifdef HAVE_RECORDING 357#ifdef HAVE_RECORDING
358/* PCM recording interrupt routine lockout */ 358/* PCM recording interrupt routine lockout */
359static struct dma_data dma_rec_data NOCACHEBSS_ATTR = 359static struct dma_data dma_rec_data SHAREDBSS_ATTR =
360{ 360{
361 /* Initialize to a locked, stopped state */ 361 /* Initialize to a locked, stopped state */
362 .p = NULL, 362 .p = NULL,
diff --git a/firmware/target/arm/sandisk/app.lds b/firmware/target/arm/sandisk/app.lds
index 765a5f0389..54af494d72 100644
--- a/firmware/target/arm/sandisk/app.lds
+++ b/firmware/target/arm/sandisk/app.lds
@@ -21,6 +21,14 @@ INPUT(target/arm/crt0-pp.o)
21#define IRAMORIG 0x40000000 21#define IRAMORIG 0x40000000
22#define IRAMSIZE 0xc000 22#define IRAMSIZE 0xc000
23 23
24#ifdef CPU_PP502x
25#define NOCACHE_BASE 0x10000000
26#else
27#define NOCACHE_BASE 0x28000000
28#endif
29
30#define CACHEALIGN_SIZE 16
31
24/* End of the audio buffer, where the codec buffer starts */ 32/* End of the audio buffer, where the codec buffer starts */
25#define ENDAUDIOADDR (DRAMORIG + DRAMSIZE) 33#define ENDAUDIOADDR (DRAMORIG + DRAMSIZE)
26 34
@@ -70,6 +78,18 @@ SECTIONS
70 _dataend = .; 78 _dataend = .;
71 } > DRAM 79 } > DRAM
72 80
81#if NOCACHE_BASE != 0
82 /* .ncdata section is placed at uncached physical alias address and is
83 * loaded at the proper cached virtual address - no copying is
84 * performed in the init code */
85 .ncdata . + NOCACHE_BASE :
86 {
87 . = ALIGN(CACHEALIGN_SIZE);
88 *(.ncdata*)
89 . = ALIGN(CACHEALIGN_SIZE);
90 } AT> DRAM
91#endif
92
73 /DISCARD/ : 93 /DISCARD/ :
74 { 94 {
75 *(.eh_frame) 95 *(.eh_frame)
@@ -103,7 +123,7 @@ SECTIONS
103 _iend = .; 123 _iend = .;
104 } > IRAM 124 } > IRAM
105 125
106 .idle_stacks : 126 .idle_stacks (NOLOAD) :
107 { 127 {
108 *(.idle_stacks) 128 *(.idle_stacks)
109#if NUM_CORES > 1 129#if NUM_CORES > 1
@@ -116,7 +136,7 @@ SECTIONS
116 cop_idlestackend = .; 136 cop_idlestackend = .;
117 } > IRAM 137 } > IRAM
118 138
119 .stack : 139 .stack (NOLOAD) :
120 { 140 {
121 *(.stack) 141 *(.stack)
122 stackbegin = .; 142 stackbegin = .;
@@ -124,37 +144,53 @@ SECTIONS
124 stackend = .; 144 stackend = .;
125 } > IRAM 145 } > IRAM
126 146
127 .bss ADDR(.data) + SIZEOF(.data) + SIZEOF(.iram) + SIZEOF(.vectors): 147 /* .bss and .ncbss are treated as a single section to use one init loop to
148 * zero it - note "_edata" and "_end" */
149 .bss ADDR(.data) + SIZEOF(.data) + SIZEOF(.ncdata) +\
150 SIZEOF(.iram) + SIZEOF(.vectors) (NOLOAD) :
128 { 151 {
129 _edata = .; 152 _edata = .;
130 *(.bss*) 153 *(.bss*)
131 *(COMMON) 154 *(COMMON)
132 . = ALIGN(0x4); 155 . = ALIGN(0x4);
133 _end = .;
134 } > DRAM 156 } > DRAM
135 157
136 .audiobuf ALIGN(4) : 158#if NOCACHE_BASE != 0
159 .ncbss . + NOCACHE_BASE (NOLOAD):
160 {
161 . = ALIGN(CACHEALIGN_SIZE);
162 *(.ncbss*)
163 . = ALIGN(CACHEALIGN_SIZE);
164 } AT> DRAM
165#endif
166
167 /* This will be aligned by preceding alignments */
168 .endaddr . - NOCACHE_BASE (NOLOAD) :
169 {
170 _end = .;
171 } > DRAM
172
173 .audiobuf (NOLOAD) :
137 { 174 {
138 _audiobuffer = .; 175 _audiobuffer = .;
139 audiobuffer = .; 176 audiobuffer = .;
140 } > DRAM 177 } > DRAM
141 178
142 .audiobufend ENDAUDIOADDR: 179 .audiobufend ENDAUDIOADDR (NOLOAD) :
143 { 180 {
144 audiobufend = .; 181 audiobufend = .;
145 _audiobufend = .; 182 _audiobufend = .;
146 } > DRAM 183 } > DRAM
147 184
148 .codec ENDAUDIOADDR: 185 .codec ENDAUDIOADDR (NOLOAD) :
149 { 186 {
150 codecbuf = .; 187 codecbuf = .;
151 _codecbuf = .; 188 _codecbuf = .;
152 } 189 }
153 190
154 .plugin ENDADDR: 191 .plugin ENDADDR (NOLOAD) :
155 { 192 {
156 _pluginbuf = .; 193 _pluginbuf = .;
157 pluginbuf = .; 194 pluginbuf = .;
158 } 195 }
159} 196}
160
diff --git a/firmware/target/arm/sandisk/ata-c200_e200.c b/firmware/target/arm/sandisk/ata-c200_e200.c
index 747cb17ca1..e4a5388978 100644
--- a/firmware/target/arm/sandisk/ata-c200_e200.c
+++ b/firmware/target/arm/sandisk/ata-c200_e200.c
@@ -165,7 +165,7 @@ static struct sd_card_status sd_status[NUM_VOLUMES] =
165/* Shoot for around 75% usage */ 165/* Shoot for around 75% usage */
166static long sd_stack [(DEFAULT_STACK_SIZE*2 + 0x1c0)/sizeof(long)]; 166static long sd_stack [(DEFAULT_STACK_SIZE*2 + 0x1c0)/sizeof(long)];
167static const char sd_thread_name[] = "ata/sd"; 167static const char sd_thread_name[] = "ata/sd";
168static struct mutex sd_mtx NOCACHEBSS_ATTR; 168static struct mutex sd_mtx SHAREDBSS_ATTR;
169static struct event_queue sd_queue; 169static struct event_queue sd_queue;
170 170
171/* Posted when card plugged status has changed */ 171/* Posted when card plugged status has changed */
diff --git a/firmware/target/arm/sandisk/boot.lds b/firmware/target/arm/sandisk/boot.lds
index a087a7250d..1c1066895f 100644
--- a/firmware/target/arm/sandisk/boot.lds
+++ b/firmware/target/arm/sandisk/boot.lds
@@ -30,6 +30,7 @@ SECTIONS
30 *(.irodata) 30 *(.irodata)
31 *(.idata) 31 *(.idata)
32 *(.data*) 32 *(.data*)
33 *(.ncdata*)
33 _dataend = . ; 34 _dataend = . ;
34 } 35 }
35 36
@@ -51,6 +52,7 @@ SECTIONS
51 _edata = .; 52 _edata = .;
52 *(.bss*); 53 *(.bss*);
53 *(.ibss); 54 *(.ibss);
55 *(.ncbss*);
54 _end = .; 56 _end = .;
55 } 57 }
56} 58}
diff --git a/firmware/target/arm/sandisk/sansa-c200/lcd-c200.c b/firmware/target/arm/sandisk/sansa-c200/lcd-c200.c
index a629739d50..a2110f7e66 100644
--- a/firmware/target/arm/sandisk/sansa-c200/lcd-c200.c
+++ b/firmware/target/arm/sandisk/sansa-c200/lcd-c200.c
@@ -23,7 +23,7 @@
23#include "system.h" 23#include "system.h"
24 24
25/* Display status */ 25/* Display status */
26static unsigned lcd_yuv_options NOCACHEBSS_ATTR = 0; 26static unsigned lcd_yuv_options SHAREDBSS_ATTR = 0;
27 27
28/* LCD command set for Samsung S6B33B2 */ 28/* LCD command set for Samsung S6B33B2 */
29 29
diff --git a/firmware/target/arm/sandisk/sansa-e200/lcd-e200.c b/firmware/target/arm/sandisk/sansa-e200/lcd-e200.c
index f2689eabbf..15263b5533 100644
--- a/firmware/target/arm/sandisk/sansa-e200/lcd-e200.c
+++ b/firmware/target/arm/sandisk/sansa-e200/lcd-e200.c
@@ -28,8 +28,8 @@
28 28
29/* Power and display status */ 29/* Power and display status */
30static bool power_on = false; /* Is the power turned on? */ 30static bool power_on = false; /* Is the power turned on? */
31static bool display_on NOCACHEBSS_ATTR = false; /* Is the display turned on? */ 31static bool display_on SHAREDBSS_ATTR = false; /* Is the display turned on? */
32static unsigned lcd_yuv_options NOCACHEBSS_ATTR = 0; 32static unsigned lcd_yuv_options SHAREDBSS_ATTR = 0;
33 33
34/* Reverse Flag */ 34/* Reverse Flag */
35#define R_DISP_CONTROL_NORMAL 0x0004 35#define R_DISP_CONTROL_NORMAL 0x0004
diff --git a/firmware/target/arm/system-target.h b/firmware/target/arm/system-target.h
index 8dcbf0f9da..2a72b524f7 100644
--- a/firmware/target/arm/system-target.h
+++ b/firmware/target/arm/system-target.h
@@ -108,7 +108,7 @@ static inline unsigned int processor_id(void)
108/* Certain data needs to be out of the way of cache line interference 108/* Certain data needs to be out of the way of cache line interference
109 * such as data for COP use or for use with UNCACHED_ADDR */ 109 * such as data for COP use or for use with UNCACHED_ADDR */
110#define PROC_NEEDS_CACHEALIGN 110#define PROC_NEEDS_CACHEALIGN
111#define CACHEALIGN_BITS (5) /* 2^5 = 32 bytes */ 111#define CACHEALIGN_BITS (4) /* 2^4 = 16 bytes */
112 112
113/** cache functions **/ 113/** cache functions **/
114#ifndef BOOTLOADER 114#ifndef BOOTLOADER
diff --git a/firmware/target/arm/tcc780x/ata-nand-tcc780x.c b/firmware/target/arm/tcc780x/ata-nand-tcc780x.c
index f6d1df96ce..b47444f3a8 100644
--- a/firmware/target/arm/tcc780x/ata-nand-tcc780x.c
+++ b/firmware/target/arm/tcc780x/ata-nand-tcc780x.c
@@ -42,7 +42,7 @@ static bool initialized = false;
42static long next_yield = 0; 42static long next_yield = 0;
43#define MIN_YIELD_PERIOD 2000 43#define MIN_YIELD_PERIOD 2000
44 44
45static struct mutex ata_mtx NOCACHEBSS_ATTR; 45static struct mutex ata_mtx SHAREDBSS_ATTR;
46 46
47#define SECTOR_SIZE 512 47#define SECTOR_SIZE 512
48 48
diff --git a/firmware/thread.c b/firmware/thread.c
index e6ab0e4a71..040818f31c 100644
--- a/firmware/thread.c
+++ b/firmware/thread.c
@@ -235,7 +235,7 @@ extern uintptr_t cpu_idlestackbegin[];
235extern uintptr_t cpu_idlestackend[]; 235extern uintptr_t cpu_idlestackend[];
236extern uintptr_t cop_idlestackbegin[]; 236extern uintptr_t cop_idlestackbegin[];
237extern uintptr_t cop_idlestackend[]; 237extern uintptr_t cop_idlestackend[];
238static uintptr_t * const idle_stacks[NUM_CORES] NOCACHEDATA_ATTR = 238static uintptr_t * const idle_stacks[NUM_CORES] =
239{ 239{
240 [CPU] = cpu_idlestackbegin, 240 [CPU] = cpu_idlestackbegin,
241 [COP] = cop_idlestackbegin 241 [COP] = cop_idlestackbegin
@@ -251,7 +251,7 @@ struct core_semaphores
251 volatile uint8_t unused; /* 03h */ 251 volatile uint8_t unused; /* 03h */
252}; 252};
253 253
254static struct core_semaphores core_semaphores[NUM_CORES] NOCACHEBSS_ATTR; 254static struct core_semaphores core_semaphores[NUM_CORES] IBSS_ATTR;
255#endif /* CONFIG_CPU == PP5002 */ 255#endif /* CONFIG_CPU == PP5002 */
256 256
257#endif /* NUM_CORES */ 257#endif /* NUM_CORES */
diff --git a/firmware/timer.c b/firmware/timer.c
index 23df271220..c803048744 100644
--- a/firmware/timer.c
+++ b/firmware/timer.c
@@ -25,12 +25,12 @@
25#include "logf.h" 25#include "logf.h"
26 26
27static int timer_prio = -1; 27static int timer_prio = -1;
28void NOCACHEBSS_ATTR (*pfn_timer)(void) = NULL; /* timer callback */ 28void SHAREDBSS_ATTR (*pfn_timer)(void) = NULL; /* timer callback */
29void NOCACHEBSS_ATTR (*pfn_unregister)(void) = NULL; /* unregister callback */ 29void SHAREDBSS_ATTR (*pfn_unregister)(void) = NULL; /* unregister callback */
30#ifdef CPU_COLDFIRE 30#ifdef CPU_COLDFIRE
31static int base_prescale; 31static int base_prescale;
32#elif defined CPU_PP || CONFIG_CPU == PNX0101 32#elif defined CPU_PP || CONFIG_CPU == PNX0101
33static long NOCACHEBSS_ATTR cycles_new = 0; 33static long SHAREDBSS_ATTR cycles_new = 0;
34#endif 34#endif
35 35
36/* interrupt handler */ 36/* interrupt handler */