浏览代码

Blackfin: move section length calculation to linker script

The length of the sections is fixed at link time, so let the linker do the
calculation rather than doing it ourselves at runtime.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Mike Frysinger 15 年之前
父节点
当前提交
b1e2c5519a
共有 3 个文件被更改,包括 30 次插入23 次删除
  1. 5 6
      cpu/blackfin/cpu.c
  2. 8 10
      cpu/blackfin/start.S
  3. 17 7
      lib_blackfin/u-boot.lds.S

+ 5 - 6
cpu/blackfin/cpu.c

@@ -25,13 +25,12 @@ ulong bfin_poweron_retx;
 __attribute__ ((__noreturn__))
 __attribute__ ((__noreturn__))
 void cpu_init_f(ulong bootflag, ulong loaded_from_ldr)
 void cpu_init_f(ulong bootflag, ulong loaded_from_ldr)
 {
 {
-	extern char _stext_l1;
 #ifndef CONFIG_BFIN_BOOTROM_USES_EVT1
 #ifndef CONFIG_BFIN_BOOTROM_USES_EVT1
 	/* Build a NOP slide over the LDR jump block.  Whee! */
 	/* Build a NOP slide over the LDR jump block.  Whee! */
 	char nops[0xC];
 	char nops[0xC];
 	serial_early_puts("NOP Slide\n");
 	serial_early_puts("NOP Slide\n");
 	memset(nops, 0x00, sizeof(nops));
 	memset(nops, 0x00, sizeof(nops));
-	memcpy(&_stext_l1 - sizeof(nops), nops, sizeof(nops));
+	memcpy((void *)L1_INST_SRAM, nops, sizeof(nops));
 #endif
 #endif
 
 
 	if (!loaded_from_ldr) {
 	if (!loaded_from_ldr) {
@@ -40,10 +39,10 @@ void cpu_init_f(ulong bootflag, ulong loaded_from_ldr)
 		 * checking at build time.
 		 * checking at build time.
 		 */
 		 */
 		serial_early_puts("L1 Relocate\n");
 		serial_early_puts("L1 Relocate\n");
-		extern char _stext_l1, _etext_l1, _stext_l1_lma;
-		memcpy(&_stext_l1, &_stext_l1_lma, (&_etext_l1 - &_stext_l1));
-		extern char _sdata_l1, _edata_l1, _sdata_l1_lma;
-		memcpy(&_sdata_l1, &_sdata_l1_lma, (&_edata_l1 - &_sdata_l1));
+		extern char _stext_l1[], _text_l1_lma[], _text_l1_len[];
+		memcpy(&_stext_l1, &_text_l1_lma, (unsigned long)_text_l1_len);
+		extern char _sdata_l1[], _data_l1_lma[], _data_l1_len[];
+		memcpy(&_sdata_l1, &_data_l1_lma, (unsigned long)_data_l1_len);
 	}
 	}
 #if defined(__ADSPBF537__) || defined(__ADSPBF536__) || defined(__ADSPBF534__)
 #if defined(__ADSPBF537__) || defined(__ADSPBF536__) || defined(__ADSPBF534__)
 	/* The BF537 bootrom will reset the EBIU_AMGCTL register on us
 	/* The BF537 bootrom will reset the EBIU_AMGCTL register on us

+ 8 - 10
cpu/blackfin/start.S

@@ -139,11 +139,10 @@ ENTRY(_start)
 .Ldma_and_reprogram:
 .Ldma_and_reprogram:
 	r0.l = LO(L1_INST_SRAM);
 	r0.l = LO(L1_INST_SRAM);
 	r0.h = HI(L1_INST_SRAM);
 	r0.h = HI(L1_INST_SRAM);
-	r1.l = __initcode_start;
-	r1.h = __initcode_start;
-	r2.l = __initcode_end;
-	r2.h = __initcode_end;
-	r2 = r2 - r1;	/* convert r2 into length of initcode */
+	r1.l = __initcode_lma;
+	r1.h = __initcode_lma;
+	r2.l = __initcode_len;
+	r2.h = __initcode_len;
 	r1 = r1 - r4;	/* convert r1 from load address of initcode ... */
 	r1 = r1 - r4;	/* convert r1 from load address of initcode ... */
 	r1 = r1 + r5;	/* ... to current (not load) address of initcode */
 	r1 = r1 + r5;	/* ... to current (not load) address of initcode */
 	p3 = r0;
 	p3 = r0;
@@ -173,12 +172,11 @@ ENTRY(_start)
 	 * takes care of clearing things for us.
 	 * takes care of clearing things for us.
 	 */
 	 */
 	serial_early_puts("Zero BSS");
 	serial_early_puts("Zero BSS");
-	r0.l = __bss_start;
-	r0.h = __bss_start;
+	r0.l = __bss_vma;
+	r0.h = __bss_vma;
 	r1 = 0 (x);
 	r1 = 0 (x);
-	r2.l = __bss_end;
-	r2.h = __bss_end;
-	r2 = r2 - r0;
+	r2.l = __bss_len;
+	r2.h = __bss_len;
 	call _memset;
 	call _memset;
 
 
 .Lnorelocate:
 .Lnorelocate:

+ 17 - 7
lib_blackfin/u-boot.lds.S

@@ -65,16 +65,22 @@ MEMORY
 ENTRY(_start)
 ENTRY(_start)
 SECTIONS
 SECTIONS
 {
 {
-	.text :
+	.text.pre :
 	{
 	{
 		cpu/blackfin/start.o (.text .text.*)
 		cpu/blackfin/start.o (.text .text.*)
 
 
 		LDS_BOARD_TEXT
 		LDS_BOARD_TEXT
+	} >ram_code
 
 
-		__initcode_start = .;
+	.text.init :
+	{
 		cpu/blackfin/initcode.o (.text .text.*)
 		cpu/blackfin/initcode.o (.text .text.*)
-		__initcode_end = .;
+	} >ram_code
+	__initcode_lma = LOADADDR(.text.init);
+	__initcode_len = SIZEOF(.text.init);
 
 
+	.text :
+	{
 		*(.text .text.*)
 		*(.text .text.*)
 	} >ram
 	} >ram
 
 
@@ -113,7 +119,9 @@ SECTIONS
 		. = ALIGN(4);
 		. = ALIGN(4);
 		__etext_l1 = .;
 		__etext_l1 = .;
 	} >l1_code AT>ram
 	} >l1_code AT>ram
-	__stext_l1_lma = LOADADDR(.text_l1);
+	__text_l1_lma = LOADADDR(.text_l1);
+	__text_l1_len = SIZEOF(.text_l1);
+	ASSERT (__text_l1_len <= L1_INST_SRAM_SIZE, "L1 text overflow!")
 
 
 	.data_l1 :
 	.data_l1 :
 	{
 	{
@@ -124,16 +132,18 @@ SECTIONS
 		. = ALIGN(4);
 		. = ALIGN(4);
 		__edata_l1 = .;
 		__edata_l1 = .;
 	} >l1_data AT>ram
 	} >l1_data AT>ram
-	__sdata_l1_lma = LOADADDR(.data_l1);
+	__data_l1_lma = LOADADDR(.data_l1);
+	__data_l1_len = SIZEOF(.data_l1);
+	ASSERT (__data_l1_len <= L1_DATA_B_SRAM_SIZE, "L1 data B overflow!")
 
 
 	.bss :
 	.bss :
 	{
 	{
 		. = ALIGN(4);
 		. = ALIGN(4);
-		__bss_start = .;
 		*(.sbss) *(.scommon)
 		*(.sbss) *(.scommon)
 		*(.dynbss)
 		*(.dynbss)
 		*(.bss .bss.*)
 		*(.bss .bss.*)
 		*(COMMON)
 		*(COMMON)
-		__bss_end = .;
 	} >ram
 	} >ram
+	__bss_vma = ADDR(.bss);
+	__bss_len = SIZEOF(.bss);
 }
 }