ENTRY( __ucps2_init ) ;
PROVIDE(__ucps2_istack_bottom = (0x40000 - 0x40)) ;
PROVIDE(__ucps2_dstack_bottom = (0x400000 - 0x40)) ;/* DM7 */
PROVIDE(__ucps2_heap_bottom = (0x40000 - 0x40)) ;
PROVIDE(__ucps2_d0heap_bottom = 0x23C000) ;
PROVIDE(__ucps2_d1heap_bottom = 0x280000) ;
PROVIDE(__ucps2_d2heap_bottom = 0x2c0000) ;
PROVIDE(__ucps2_d3heap_bottom = 0x300000) ;
PROVIDE(__ucps2_d4heap_bottom = 0x340000) ;
PROVIDE(__ucps2_d5heap_bottom = 0x380000) ;
PROVIDE(__ucps2_d6heap_bottom = 0x3c0000) ;
PROVIDE(__ucps2_d7heap_bottom = 0x3FF000) ;/* SPU Vector Stack = 4KB, no MPU Stack */

CORE(ape1);
CACHE_SIZE(128);

/****************************************************************
 * The segments definition, which affect the load address of the
 * elf.
 */

/* All text code & data are in IM */
SECTIONS {
  /* All .data & .bss are located in IM */
  . = 0x20000; /* icache size: 128KB */

  /* tag start point for bss */
	__ucps2_bss_start = ALIGN(0x4);
  .sbss     :  {   *(.sbss.1*)  }
  .sbss     :  {   *(.sbss.2*)  }
  .sbss     :  {   *(.sbss.4*)  }
  .sbss     :  {   *(.sbss.8*)  }
  .sbss     :  {   *(.sbss*)
                  ASSERT((. <= 0x40000), "Error: No room for .sbss");
               }
  .bss     	:  {   *(.bss*)
                  ASSERT((. <= 0x40000), "Error: No room for .bss");
               }
	__ucps2_bss_end = ALIGN(0x4);
  .sdata	  :  {   *(.sdata.1*)  }
  .sdata	  :  {   *(.sdata.2*)  }
  .sdata	  :  {   *(.sdata.4*)  }
  .sdata	  :  {   *(.sdata.8*)  }
  .sdata	  :  {   *(.sdata*)
                  ASSERT((. <= 0x40000), "Error: No room for .sdata");
               }
  HIDDEN(__section_end = ALIGN(4));

  /* tag start point for heap */
	__ucps2_heap_start = ALIGN(0x8);

  . = 0x40000;
  HIDDEN(__section_start = .);
  .text 	  :	 AT(__section_end) {   *(.text.m0)
                  ASSERT((. <= 0x80000), "Error: No room for MPU's .text");
               }
  HIDDEN(__section_end = ALIGN(4) - __section_start + __section_end);

  /********************************************/
  . = 0x200000;
  HIDDEN(__section_start = .);
  .DM0 :  AT(__section_end) { *( .DM0 )
           ASSERT((. <= 0x23C000), "Error: No room for .DM0");
         }
  HIDDEN(__section_end = ALIGN(4) - __section_start + __section_end);
  /* tag start point for heap in DM0 */
	__ucps2_d0heap_start = ALIGN(0x8);

  . = 0x240000;
  HIDDEN(__section_start = .);
  .DM1 :  AT(__section_end) { *( .DM1 )
           ASSERT((. <= 0x280000), "Error: No room for .DM1");
         }
  HIDDEN(__section_end = ALIGN(4) - __section_start + __section_end);
  /* tag start point for heap in DM1 */
	__ucps2_d1heap_start = ALIGN(0x8);

  . = 0x280000;
  HIDDEN(__section_start = .);
  .DM2 :  AT(__section_end) { *( .DM2 )
           ASSERT((. <= 0x2c0000), "Error: No room for .DM2");
         }
  HIDDEN(__section_end = ALIGN(4) - __section_start + __section_end);
  /* tag start point for heap in DM2 */
	__ucps2_d2heap_start = ALIGN(0x8);

  . = 0x2c0000;
  HIDDEN(__section_start = .);
  .DM3 :  AT(__section_end) { *( .DM3 )
           ASSERT((. <= 0x300000), "Error: No room for .DM3");
         }
  HIDDEN(__section_end = ALIGN(4) - __section_start + __section_end);
  /* tag start point for heap in DM3*/
	__ucps2_d3heap_start = ALIGN(0x8);

  . = 0x300000;
  HIDDEN(__section_start = .);
  .DM4 :  AT(__section_end) { *( .DM4 )
           ASSERT((. <= 0x340000), "Error: No room for .DM4");
         }
  HIDDEN(__section_end = ALIGN(4) - __section_start + __section_end);
  /* tag start point for heap in DM4*/
	__ucps2_d4heap_start = ALIGN(0x8);

  . = 0x340000;
  HIDDEN(__section_start = .);
  .DM5 :  AT(__section_end) { *( .DM5 )
           ASSERT((. <= 0x380000), "Error: No room for .DM5");
         }
  HIDDEN(__section_end = ALIGN(4) - __section_start + __section_end);
  /* tag start point for heap in DM5*/
	__ucps2_d5heap_start = ALIGN(0x8);

  . = 0x380000;
  HIDDEN(__section_start = .);
  .DM6 :  AT(__section_end) { *( .DM6 )
           ASSERT((. <= 0x3c0000), "Error: No room for .DM6");
         }
  HIDDEN(__section_end = ALIGN(4) - __section_start + __section_end);
  /* tag start point for heap in DM6*/
	__ucps2_d6heap_start = ALIGN(0x8);
  
  . = 0x3C0000;
  HIDDEN(__section_start = .);
  .DM7 :  AT(__section_end) { *( .DM7 )
           ASSERT((. <= 0x3FF000), "Error: No room for .DM7");
         }
  .rodata :{   *(.rodata*)
                  ASSERT((. <= 0x3FF000), "Error: No room for .rodata");
               }
  HIDDEN(__section_end = ALIGN(4) - __section_start + __section_end);
  /* tag start point for heap in DM7*/
  __ucps2_d7heap_start = ALIGN(0x8);

  . = 0x04000000;
  HIDDEN(__section_start = .);
  .virt.sm  :  AT(__section_end) { *(.virt.sm)
                 ASSERT((. <= 0x04200000), "Error: No room for virtual share memory");
              }
  .noinit.MREG :
  {
    *(noinit.MREG)
  }
  HIDDEN(__section_end = ALIGN(4) - __section_start + __section_end);

  /* Place .LOG section in DDR */
  . = 0xB7500000;
  HIDDEN(__section_start = .);
  .log  :  AT(__section_end) { *( .LOG )
                 ASSERT((. <= 0xB7600000), "Error: No room for log");
              }
  HIDDEN(__section_end = ALIGN(4) - __section_start + __section_end);
  . = 0x9cc00000;
  HIDDEN(__section_start = .);
  .text 	  :	 AT(__section_end) {   *(.text.start)
                  ASSERT((. <= 0x9d000000), "Error: No room for SPU start .text");
               }
  .text 	  :	 {   *(.text*)
                  ASSERT((. <= 0x9d000000), "Error: No room for SPU's .text");
              }
  HIDDEN(__section_end = ALIGN(4) - __section_start + __section_end);

  HIDDEN(__section_start = 0xffffffff);
  HIDDEN(__section_end = 0xffffffff);
}

