changeset 82:6afaa5cb7392

linker script for gcc fw build: initial version put together
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 20 Jul 2018 17:33:14 +0000
parents 4ab736fdbdba
children 92fde62400ef
files gcc/flash.m4 gcc/ld-script.src gcc/xram.m4
diffstat 3 files changed, 143 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gcc/flash.m4	Fri Jul 20 17:33:14 2018 +0000
@@ -0,0 +1,2 @@
+define(`Buildmem',`FLASH')dnl
+define(`Put_in_flash',`AT> FLASH')dnl
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gcc/ld-script.src	Fri Jul 20 17:33:14 2018 +0000
@@ -0,0 +1,139 @@
+dnl This ld script source is fed through m4 in order to fill in
+dnl those settings which depend on the configuration.
+dnl Two include files are fed to m4 before this main body:
+dnl the appropriate targets/*.m4 file defining the memory config
+dnl of the hardware, and one of flash.m4 or xram.m4 to select
+dnl the build type.
+
+/*
+ * FreeCalypso Selenite ld script for the Buildmem build
+ */
+
+ENTRY(_Firmware_boot_entry)
+
+MEMORY {
+ifelse(Buildmem-FLASH_BOOT_VIA_BOOTROM,FLASH-1,
+`	FLASH_OVERLAY : ORIGIN = 0, LENGTH = 0x2000')
+ifelse(Buildmem,FLASH,
+`	FLASH : ORIGIN = FLASHIMAGE_BASE_ADDR,
+		LENGTH = CONFIG_FWFLASH_SIZE - FLASHIMAGE_BASE_ADDR')
+	IRAM : ORIGIN = 0x00800000, LENGTH = CONFIG_IRAM_SIZE
+	XRAM : ORIGIN = 0x01000000, LENGTH = CONFIG_XRAM_SIZE
+}
+
+SECTIONS {
+dnl The following sections exist only in the flashImage build,
+dnl and only on targets that use the Calypso boot ROM.
+ifelse(Buildmem-FLASH_BOOT_VIA_BOOTROM,FLASH-1,
+`	/* Part of flash overlaid by the boot ROM */
+	bootrom.overlay 0 : {
+		*(bootrom.overlay)
+	} > FLASH_OVERLAY
+
+	/* code that enables the boot ROM and jumps to it */
+	bootrom.switch : {
+		*(bootrom.switch)
+	} > IRAM AT> FLASH_OVERLAY
+	__romswitch_ram_addr = ADDR(bootrom.switch);
+	__romswitch_flash_addr = LOADADDR(bootrom.switch);
+	__romswitch_size = SIZEOF(bootrom.switch);
+')dnl
+
+	/* boot entry code, going into flash or XRAM emulating flash */
+	.inttext : {
+		*(.inttext)
+	} > Buildmem
+
+	/* copy-to-IRAM code */
+	iram.text 0x80001C : {
+		/* the 7 exception and interrupt vectors @ 0x80001C */
+		*(.ramvecs)
+		*_ir.a:(.text*)
+		*_int.a:(.text*)
+		*_intram.a:(.text*)
+		*osx_na7_db.a:(.text*)
+		*tpudrv.a:(.text*)
+		*drivers_flash.a:niq32.o(.text*)
+		*sim_drv.a:sim32.o(.text*)
+		*libc.a:(.text*)
+		*libgcc.a:(.text*)
+	} > IRAM Put_in_flash
+ifelse(Buildmem,FLASH,
+`	__iramtext_ram_addr = ADDR(iram.text);
+	__iramtext_flash_addr = LOADADDR(iram.text);
+	__iramtext_size = SIZEOF(iram.text);
+')dnl
+
+	/* XIP code, going into flash or XRAM emulating flash */
+	xip.text : {
+		*(.text*)
+		/* let's put the ARM->Thumb veneers in the XIP section */
+		*(.glue_7)
+	} > Buildmem
+
+	/* all .rodata will stay in flash */
+	.rodata : {
+		*(.rodata*)
+	} > Buildmem
+
+	/*
+	 * All .data will go into XRAM.
+	 * For the flash build we'll have a step that copies
+	 * the .data section from flash to XRAM; for the RAM-only
+	 * build it goes directly into XRAM and stays there.
+	 */
+	.data : {
+		*(.data*)
+	} > XRAM Put_in_flash
+ifelse(Buildmem,FLASH,
+`	__initdata_ram_addr = ADDR(.data);
+	__initdata_flash_addr = LOADADDR(.data);
+	__initdata_size = SIZEOF(.data);
+')dnl
+
+	.bss_dar (NOLOAD) : {
+		*dar_gbl_var.a:(.bss* COMMON)
+	} > XRAM
+
+	/* we have two kinds of BSS: internal and external */
+	int.bss (NOLOAD) : {
+		*(.l1s_global)
+		*_ir.a:(.bss* COMMON)
+		*_int.a:(.bss* COMMON)
+		*_intram.a:(.bss* COMMON)
+		*osx_na7_db.a:(.bss* COMMON)
+		*tpudrv.a:(.bss* COMMON)
+		*libc.a:(.bss* COMMON)
+		*libgcc.a:(.bss* COMMON)
+		*(.API_HISR_stack)
+		. = ALIGN(4);
+	} > IRAM
+	__intbss_start = ADDR(int.bss);
+	__intbss_size = SIZEOF(int.bss);
+
+	ext.bss (NOLOAD) : {
+		*(.bss* COMMON)
+		. = ALIGN(4);
+	} > XRAM
+	__extbss_start = ADDR(ext.bss);
+	__extbss_size = SIZEOF(ext.bss);
+
+	.stack (NOLOAD) : {
+		/* Leave 20 32bit words for register pushes. */
+		. = ALIGN(8);
+		. += 20 * 4;
+
+		/* Stack for abort and/or undefined modes. */
+		_Except_Stack_SP = .;
+
+		/* Leave 38 32bit words for state saving on exceptions. */
+		xdump_buffer = .;
+		. += 38 * 4;
+		. = ALIGN(8);
+
+		/* Beginning of stacks and heap area - 2.75 kbytes (int.s) */
+		_Stack_segment_start = .;
+		. += 0xB00;
+		_Stack_segment_end = .;
+	} > XRAM
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gcc/xram.m4	Fri Jul 20 17:33:14 2018 +0000
@@ -0,0 +1,2 @@
+define(`Buildmem',`XRAM')dnl
+define(`Put_in_flash',`/* no AT> for RAM-only build */')dnl