@@ -25,10 +25,27 @@ OUTPUT_ARCH(xtensa)
2525PROVIDE (__memctl_default = 0x00000000 );
2626PROVIDE (_MemErrorHandler = 0x00000000 );
2727
28- #define RAMABLE_REGION ram :ram_phdr
29- #define ROMABLE_REGION ram :ram_phdr
3028#define LP_SRAM_REGION lpram
3129
30+ /* DSP RAM regions (all of them) are mapped twice on the DSP: once in
31+ * a 512MB region from 0x80000000-0x9fffffff and again from
32+ * 0xa0000000-0xbfffffff. The first mapping is set up to bypass the
33+ * L1 cache, so it must be used when multiprocessor coherence is
34+ * desired, where the latter mapping is best used for processor-local
35+ * data (e.g. stacks) or shared data that is managed with explicit
36+ * cache flush/invalidate operations.
37+ *
38+ * These macros will set up a segment start address correctly,
39+ * including alignment to a cache line. Be sure to also emit the
40+ * section to ">ram :ram_phdr" or ">ucram :ucram_phdr" as
41+ * appropriate. (Forgetting the correct PHDR will actually work, as
42+ * the output tooling ignores it, but it will cause the linker to emit
43+ * 512MB of unused data into the output file!)
44+ *
45+ */
46+ #define SEGSTART_CACHED (ALIGN(64 ) | 0x20000000 )
47+ #define SEGSTART_UNCACHED (ALIGN(64 ) & ~0x20000000 )
48+
3249MEMORY
3350{
3451 vector_memory_lit :
@@ -97,6 +114,9 @@ MEMORY
97114 ram :
98115 org = RAM_BASE,
99116 len = RAM_SIZE
117+ ucram :
118+ org = RAM_BASE - 0x20000000 ,
119+ len = RAM_SIZE
100120#ifdef CONFIG_GEN_ISR_TABLES
101121 IDT_LIST :
102122 org = IDT_BASE,
@@ -145,7 +165,7 @@ PHDRS
145165 vector_double_lit_phdr PT_LOAD;
146166 vector_double_text_phdr PT_LOAD;
147167 ram_phdr PT_LOAD;
148-
168+ ucram_phdr PT_LOAD;
149169 static_uuid_entries_phdr PT_NOTE;
150170 static_log_entries_phdr PT_NOTE;
151171 metadata_entries_phdr PT_NOTE;
@@ -190,16 +210,7 @@ _memmap_cacheattr_bp_allvalid = 0x22222222;
190210 * as cacheattr_set macro sets them both to the same set of
191211 * attributes.
192212 */
193- #ifndef CONFIG_SMP
194213_memmap_cacheattr_intel_cavs20_adsp = 0xFF42FFF2 ;
195- #else
196- /*
197- * FIXME: Make 0xA0000000 - 0xBFFFFFFF to bypass cache under SMP
198- * since there is no data cache manipulation for spinlock, kernel
199- * object, scheduler, etc...
200- */
201- _memmap_cacheattr_intel_cavs20_adsp = 0xFF22FFF2 ;
202- #endif
203214
204215PROVIDE (_memmap_cacheattr_reset = _memmap_cacheattr_intel_cavs20_adsp);
205216SECTIONS
@@ -391,13 +402,16 @@ SECTIONS
391402 _bss_table_end = ABSOLUTE (.);
392403 _rodata_end = ABSOLUTE (.);
393404 } >ram :ram_phdr
405+
394406 .module_init : ALIGN (4 )
395407 {
396408 _module_init_start = ABSOLUTE (.);
397409 *(*.module_init )
398410 _module_init_end = ABSOLUTE (.);
399411 } >ram :ram_phdr
400412
413+ #define RAMABLE_REGION ram :ram_phdr
414+ #define ROMABLE_REGION ram :ram_phdr
401415#include < linker/common-rom.ld>
402416
403417 .fw_ready : ALIGN (4 )
@@ -406,13 +420,13 @@ SECTIONS
406420 KEEP (*(.fw_ready_metadata ))
407421 } >ram :ram_phdr
408422
409- .noinit : ALIGN (4 )
423+ .noinit SEGSTART_UNCACHED : ALIGN (4 )
410424 {
411425 *(.noinit )
412426 *(.noinit .*)
413- } >ram :ram_phdr
427+ } >ucram :ucram_phdr
414428
415- .data : ALIGN (4 )
429+ .data SEGSTART_UNCACHED : ALIGN (4 )
416430 {
417431 _data_start = ABSOLUTE (.);
418432 *(.data )
@@ -431,8 +445,9 @@ SECTIONS
431445 *(.gna_model )
432446 _data_end = ABSOLUTE (.);
433447 . = ALIGN (4096 );
434- } >ram :ram_phdr
435- .lit4 : ALIGN (4 )
448+ } >ucram :ucram_phdr
449+
450+ .lit4 SEGSTART_CACHED : ALIGN (4 )
436451 {
437452 _lit4_start = ABSOLUTE (.);
438453 *(*.lit4 )
@@ -444,6 +459,18 @@ SECTIONS
444459 {
445460 *(.cached .cached .*)
446461 } >ram :ram_phdr
462+
463+ /* These values need to change in our scheme, where the common-ram
464+ * sections need to be linked in safe/uncached memory but common-rom
465+ * wants to use the cache
466+ */
467+
468+ . = SEGSTART_UNCACHED;
469+
470+ #undef RAMABLE_REGION
471+ #undef ROMABLE_REGION
472+ #define RAMABLE_REGION ucram :ucram_phdr
473+ #define ROMABLE_REGION ucram :ucram_phdr
447474#include < linker/common-ram.ld>
448475
449476 .tm_clone_table :
@@ -470,20 +497,30 @@ SECTIONS
470497 *(COMMON)
471498 . = ALIGN (8 );
472499 _bss_end = ABSOLUTE (.);
473- } >ram :ram_phdr
500+ } >ucram :ucram_phdr
474501
475- /* stack */
502+ . = SEGSTART_UNCACHED;
476503 _end = ALIGN (8 );
477504 PROVIDE (end = ALIGN (8 ));
505+
506+ /* Re-adjust to the upper mapping for the final symbols below */
507+ . = SEGSTART_CACHED;
478508 __stack = L2_SRAM_BASE + L2_SRAM_SIZE;
509+
510+ . = SEGSTART_UNCACHED;
511+
479512 /* dma buffers */
480513 .lpbuf (NOLOAD) : ALIGN (4 )
481514 {
482515 _dma_buf_start = ABSOLUTE (.);
483516 *(.dma_buffers )
484517 _dma_buf_end = ABSOLUTE (.);
485518 } >LP_SRAM_REGION
486- _heap_sentry = L2_SRAM_BASE + L2_SRAM_SIZE;
519+
520+ . = L2_SRAM_BASE + L2_SRAM_SIZE;
521+ . = SEGSTART_UNCACHED;
522+ _heap_sentry = .;
523+
487524 .comment 0 : { *(.comment ) }
488525 .debug 0 : { *(.debug ) }
489526 .line 0 : { *(.line ) }
0 commit comments