xref: /rk3399_rockchip-uboot/arch/xtensa/cpu/u-boot.lds (revision c978b52410016b0ab5a213f235596340af8d45f7)
1*c978b524SChris Zankel/*
2*c978b524SChris Zankel * (C) Copyright 2008 - 2013 Tensilica, Inc.
3*c978b524SChris Zankel * (C) Copyright 2014 - 2016 Cadence Design Systems Inc.
4*c978b524SChris Zankel *
5*c978b524SChris Zankel * SPDX-License-Identifier:	GPL-2.0+
6*c978b524SChris Zankel */
7*c978b524SChris Zankel
8*c978b524SChris Zankel#include <config.h>
9*c978b524SChris Zankel#include <asm/ldscript.h>
10*c978b524SChris Zankel#include <asm/arch/core.h>
11*c978b524SChris Zankel#include <asm/addrspace.h>
12*c978b524SChris Zankel#include <asm-offsets.h>
13*c978b524SChris Zankel
14*c978b524SChris ZankelOUTPUT_ARCH(xtensa)
15*c978b524SChris ZankelENTRY(_start)
16*c978b524SChris Zankel
17*c978b524SChris Zankel/*
18*c978b524SChris Zankel * U-Boot resets from SYSROM and unpacks itself from a ROM store to RAM.
19*c978b524SChris Zankel * The reset vector is usually near the base of SYSROM and has room
20*c978b524SChris Zankel * above it for the ROM store into which the rest of U-Boot is packed.
21*c978b524SChris Zankel * The ROM store also needs to be above any other vectors that are in ROM.
22*c978b524SChris Zankel * If a core has its vectors near the top of ROM, this must be edited.
23*c978b524SChris Zankel *
24*c978b524SChris Zankel * Note that to run C code out of ROM, the processor would have to support
25*c978b524SChris Zankel * 'relocatable' exception vectors and provide a scratch memory for the
26*c978b524SChris Zankel * initial stack. Not all Xtensa processor configurations support that, so
27*c978b524SChris Zankel * we can simplify the boot process and unpack U-Boot to RAM immediately.
28*c978b524SChris Zankel * This, however, requires that memory have been initialized throug some
29*c978b524SChris Zankel * other means (serial ROM, for example) or are initialized early (requiring
30*c978b524SChris Zankel * an assembler function. See start.S for more details)
31*c978b524SChris Zankel */
32*c978b524SChris Zankel
33*c978b524SChris ZankelSECTIONS
34*c978b524SChris Zankel{
35*c978b524SChris Zankel  . = + SIZEOF_HEADERS;
36*c978b524SChris Zankel  SECTION_ResetVector(XCHAL_RESET_VECTOR_VADDR, LMA_EQ_VMA)
37*c978b524SChris Zankel
38*c978b524SChris Zankel  .reloc_table ALIGN(4) : FOLLOWING(.ResetVector.text)
39*c978b524SChris Zankel  {
40*c978b524SChris Zankel    __reloc_table_start = ABSOLUTE(.);
41*c978b524SChris Zankel#if XCHAL_HAVE_WINDOWED
42*c978b524SChris Zankel    RELOCATE2(WindowVectors,text);
43*c978b524SChris Zankel#endif
44*c978b524SChris Zankel    RELOCATE2(KernelExceptionVector,literal);
45*c978b524SChris Zankel    RELOCATE2(KernelExceptionVector,text);
46*c978b524SChris Zankel    RELOCATE2(UserExceptionVector,literal);
47*c978b524SChris Zankel    RELOCATE2(UserExceptionVector,text);
48*c978b524SChris Zankel    RELOCATE2(DoubleExceptionVector,literal);
49*c978b524SChris Zankel    RELOCATE2(DoubleExceptionVector,text);
50*c978b524SChris Zankel    RELOCATE1(text);
51*c978b524SChris Zankel    RELOCATE1(rodata);
52*c978b524SChris Zankel    RELOCATE1(data);
53*c978b524SChris Zankel    RELOCATE1(u_boot_list);
54*c978b524SChris Zankel    __reloc_table_end = ABSOLUTE(.);
55*c978b524SChris Zankel  }
56*c978b524SChris Zankel
57*c978b524SChris Zankel#if XCHAL_HAVE_WINDOWED
58*c978b524SChris Zankel  SECTION_VECTOR(WindowVectors,text,XCHAL_WINDOW_VECTORS_VADDR,
59*c978b524SChris Zankel		 FOLLOWING(.reloc_table))
60*c978b524SChris Zankel  SECTION_VECTOR(KernelExceptionVector,literal,XCHAL_KERNEL_VECTOR_VADDR-8,
61*c978b524SChris Zankel		 FOLLOWING(.WindowVectors.text))
62*c978b524SChris Zankel#else
63*c978b524SChris Zankel  SECTION_VECTOR(KernelExceptionVector,literal,XCHAL_KERNEL_VECTOR_VADDR-8,
64*c978b524SChris Zankel		 FOLLOWING(.reloc_table))
65*c978b524SChris Zankel#endif
66*c978b524SChris Zankel  SECTION_VECTOR(KernelExceptionVector,text,XCHAL_KERNEL_VECTOR_VADDR,
67*c978b524SChris Zankel		 FOLLOWING(.KernelExceptionVector.literal))
68*c978b524SChris Zankel  SECTION_VECTOR(UserExceptionVector,literal,XCHAL_USER_VECTOR_VADDR-8,
69*c978b524SChris Zankel		 FOLLOWING(.KernelExceptionVector.text))
70*c978b524SChris Zankel  SECTION_VECTOR(UserExceptionVector,text,XCHAL_USER_VECTOR_VADDR,
71*c978b524SChris Zankel		 FOLLOWING(.UserExceptionVector.literal))
72*c978b524SChris Zankel  SECTION_VECTOR(DoubleExceptionVector,literal,XCHAL_DOUBLEEXC_VECTOR_VADDR-8,
73*c978b524SChris Zankel		 FOLLOWING(.UserExceptionVector.text))
74*c978b524SChris Zankel  SECTION_VECTOR(DoubleExceptionVector,text,XCHAL_DOUBLEEXC_VECTOR_VADDR,
75*c978b524SChris Zankel		 FOLLOWING(.DoubleExceptionVector.literal))
76*c978b524SChris Zankel
77*c978b524SChris Zankel  __monitor_start = CONFIG_SYS_TEXT_ADDR;
78*c978b524SChris Zankel
79*c978b524SChris Zankel  SECTION_text(CONFIG_SYS_TEXT_ADDR, FOLLOWING(.DoubleExceptionVector.text))
80*c978b524SChris Zankel  SECTION_rodata(ALIGN(16), FOLLOWING(.text))
81*c978b524SChris Zankel  SECTION_u_boot_list(ALIGN(16), FOLLOWING(.rodata))
82*c978b524SChris Zankel  SECTION_data(ALIGN(16), FOLLOWING(.u_boot_list))
83*c978b524SChris Zankel
84*c978b524SChris Zankel  __reloc_end = .;
85*c978b524SChris Zankel  __init_end = .;
86*c978b524SChris Zankel
87*c978b524SChris Zankel  SECTION_bss(__init_end (OVERLAY),)
88*c978b524SChris Zankel
89*c978b524SChris Zankel  __monitor_end = .;
90*c978b524SChris Zankel
91*c978b524SChris Zankel  /*
92*c978b524SChris Zankel   * On many Xtensa boards a region of RAM may be mapped to the ROM address
93*c978b524SChris Zankel   * space to facilitate on-chip-debug, and U-Boot must fit with that region.
94*c978b524SChris Zankel   * The config variables CONFIG_SYS_MONITOR_* define the region.
95*c978b524SChris Zankel   * If U-Boot extends beyond this region it will appear discontiguous in the
96*c978b524SChris Zankel   * address space and is in danger of overwriting itself during unpacking
97*c978b524SChris Zankel   * ("relocation").
98*c978b524SChris Zankel   * This causes U-Boot to crash in a way that is difficult to debug. On some
99*c978b524SChris Zankel   * boards (such as xtav60) the region is small enough that U-Boot will not
100*c978b524SChris Zankel   * fit if compiled entirely with -O0 (a common scenario). To avoid a lengthy
101*c978b524SChris Zankel   * debugging session when this happens, ensure a link-time error occurs.
102*c978b524SChris Zankel   *
103*c978b524SChris Zankel   */
104*c978b524SChris Zankel
105*c978b524SChris Zankel   ASSERT(__monitor_end - __monitor_start <= CONFIG_SYS_MONITOR_LEN,
106*c978b524SChris Zankel          "U-Boot ROM image is too large. Check optimization level.")
107*c978b524SChris Zankel
108*c978b524SChris Zankel  SECTION_xtensa
109*c978b524SChris Zankel  SECTION_debug
110*c978b524SChris Zankel
111*c978b524SChris Zankel  /DISCARD/ : { *(.dynstr*) }
112*c978b524SChris Zankel  /DISCARD/ : { *(.hash*) }
113*c978b524SChris Zankel  /DISCARD/ : { *(.interp) }
114*c978b524SChris Zankel  /DISCARD/ : { *(.got*) }
115*c978b524SChris Zankel  /DISCARD/ : { *(.dynsym) }
116*c978b524SChris Zankel}
117