1d6aed566Sopenharmony_ci /*
2d6aed566Sopenharmony_ci * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
3d6aed566Sopenharmony_ci * Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
4d6aed566Sopenharmony_ci *
5d6aed566Sopenharmony_ci * Redistribution and use in source and binary forms, with or without modification,
6d6aed566Sopenharmony_ci * are permitted provided that the following conditions are met:
7d6aed566Sopenharmony_ci *
8d6aed566Sopenharmony_ci * 1. Redistributions of source code must retain the above copyright notice, this list of
9d6aed566Sopenharmony_ci *    conditions and the following disclaimer.
10d6aed566Sopenharmony_ci *
11d6aed566Sopenharmony_ci * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12d6aed566Sopenharmony_ci *    of conditions and the following disclaimer in the documentation and/or other materials
13d6aed566Sopenharmony_ci *    provided with the distribution.
14d6aed566Sopenharmony_ci *
15d6aed566Sopenharmony_ci * 3. Neither the name of the copyright holder nor the names of its contributors may be used
16d6aed566Sopenharmony_ci *    to endorse or promote products derived from this software without specific prior written
17d6aed566Sopenharmony_ci *    permission.
18d6aed566Sopenharmony_ci *
19d6aed566Sopenharmony_ci * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20d6aed566Sopenharmony_ci * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
21d6aed566Sopenharmony_ci * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22d6aed566Sopenharmony_ci * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
23d6aed566Sopenharmony_ci * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24d6aed566Sopenharmony_ci * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25d6aed566Sopenharmony_ci * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
26d6aed566Sopenharmony_ci * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
27d6aed566Sopenharmony_ci * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
28d6aed566Sopenharmony_ci * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
29d6aed566Sopenharmony_ci * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30d6aed566Sopenharmony_ci */
31d6aed566Sopenharmony_ci
32d6aed566Sopenharmony_ciOUTPUT_FORMAT("elf32-littleriscv", "elf32-littleriscv", "elf32-littleriscv")
33d6aed566Sopenharmony_ciOUTPUT_ARCH("riscv")
34d6aed566Sopenharmony_ciENTRY(_start)
35d6aed566Sopenharmony_ci
36d6aed566Sopenharmony_ciRAM_ADDR_START            = 0x80000000;
37d6aed566Sopenharmony_ciRAM_ADDR_SIZE             = 128M;
38d6aed566Sopenharmony_ciFLASH_LOAD_START          = RAM_ADDR_START;
39d6aed566Sopenharmony_ciFLASH_LOAD_SIZE           = RAM_ADDR_SIZE;
40d6aed566Sopenharmony_ciEXCEPT_STACK_SIZE         = 2K;
41d6aed566Sopenharmony_ciNMI_STACK_SIZE            = 1K;
42d6aed566Sopenharmony_ciSTART_AND_IRQ_STACK_SIZE  = 8K;
43d6aed566Sopenharmony_ci
44d6aed566Sopenharmony_ciMEMORY
45d6aed566Sopenharmony_ci{
46d6aed566Sopenharmony_ci   ram(rwx) : ORIGIN = RAM_ADDR_START, LENGTH = RAM_ADDR_SIZE
47d6aed566Sopenharmony_ci   flash(rwx) : ORIGIN = FLASH_LOAD_START, LENGTH = FLASH_LOAD_SIZE
48d6aed566Sopenharmony_ci}
49d6aed566Sopenharmony_ciSECTIONS
50d6aed566Sopenharmony_ci{
51d6aed566Sopenharmony_ci  .text : ALIGN(0x20)
52d6aed566Sopenharmony_ci  {
53d6aed566Sopenharmony_ci    __text_start = .;
54d6aed566Sopenharmony_ci    . = ALIGN(0x10);
55d6aed566Sopenharmony_ci    *(.start.text)
56d6aed566Sopenharmony_ci    *(.interrupt.*)
57d6aed566Sopenharmony_ci    *(.text .text.*)
58d6aed566Sopenharmony_ci    . = ALIGN(0x20);
59d6aed566Sopenharmony_ci    __rodata_start = .;
60d6aed566Sopenharmony_ci    . = ALIGN(0x10);
61d6aed566Sopenharmony_ci    *(.rodata .rodata.* .srodata .srodata.*)
62d6aed566Sopenharmony_ci    . = ALIGN(0x20);
63d6aed566Sopenharmony_ci    __text_end = .;
64d6aed566Sopenharmony_ci    _hdf_drivers_start = .;
65d6aed566Sopenharmony_ci    KEEP(*(.hdf.driver))
66d6aed566Sopenharmony_ci    _hdf_drivers_end = .;
67d6aed566Sopenharmony_ci  } > ram AT > flash
68d6aed566Sopenharmony_ci  .data : ALIGN(0x20)
69d6aed566Sopenharmony_ci  {
70d6aed566Sopenharmony_ci    __global_pointer$ = . + 0x800;
71d6aed566Sopenharmony_ci    __data_load_start = LOADADDR(.data);
72d6aed566Sopenharmony_ci    __data_start = .;
73d6aed566Sopenharmony_ci    /* preinit_array */
74d6aed566Sopenharmony_ci    . = ALIGN(4);
75d6aed566Sopenharmony_ci    PROVIDE_HIDDEN (__preinit_array_start = .);
76d6aed566Sopenharmony_ci    KEEP (*(.preinit_array))
77d6aed566Sopenharmony_ci    PROVIDE_HIDDEN (__preinit_array_end = .);
78d6aed566Sopenharmony_ci    /* init_array */
79d6aed566Sopenharmony_ci    . = ALIGN(4);
80d6aed566Sopenharmony_ci    PROVIDE_HIDDEN (__init_array_start = .);
81d6aed566Sopenharmony_ci    KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*)))
82d6aed566Sopenharmony_ci    KEEP (*(.init_array))
83d6aed566Sopenharmony_ci    PROVIDE_HIDDEN (__init_array_end = .);
84d6aed566Sopenharmony_ci    /* fini_array */
85d6aed566Sopenharmony_ci    . = ALIGN(4);
86d6aed566Sopenharmony_ci    PROVIDE_HIDDEN (__fini_array_start = .);
87d6aed566Sopenharmony_ci    KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*)))
88d6aed566Sopenharmony_ci    KEEP (*(.fini_array))
89d6aed566Sopenharmony_ci    PROVIDE_HIDDEN (__fini_array_end = .);
90d6aed566Sopenharmony_ci    . = ALIGN(0x10);
91d6aed566Sopenharmony_ci    *(.data .data.* .sdata .sdata.*)
92d6aed566Sopenharmony_ci    . = ALIGN(0x20);
93d6aed566Sopenharmony_ci    __data_end = .;
94d6aed566Sopenharmony_ci    _edata = .;
95d6aed566Sopenharmony_ci  } > ram AT > flash
96d6aed566Sopenharmony_ci  __data_load_size = SIZEOF(.data);
97d6aed566Sopenharmony_ci  /* zInit code and data - will be freed after init */
98d6aed566Sopenharmony_ci  .zInit (.) :
99d6aed566Sopenharmony_ci  {
100d6aed566Sopenharmony_ci    __zinitcall_bsp_start = .;
101d6aed566Sopenharmony_ci    KEEP (*(.zinitcall.bsp0.init))
102d6aed566Sopenharmony_ci    KEEP (*(.zinitcall.bsp1.init))
103d6aed566Sopenharmony_ci    KEEP (*(.zinitcall.bsp2.init))
104d6aed566Sopenharmony_ci    KEEP (*(.zinitcall.bsp3.init))
105d6aed566Sopenharmony_ci    KEEP (*(.zinitcall.bsp4.init))
106d6aed566Sopenharmony_ci    __zinitcall_bsp_end = .;
107d6aed566Sopenharmony_ci    . = ALIGN(4);
108d6aed566Sopenharmony_ci    __zinitcall_device_start = .;
109d6aed566Sopenharmony_ci    KEEP (*(.zinitcall.device0.init))
110d6aed566Sopenharmony_ci    KEEP (*(.zinitcall.device1.init))
111d6aed566Sopenharmony_ci    KEEP (*(.zinitcall.device2.init))
112d6aed566Sopenharmony_ci    KEEP (*(.zinitcall.device3.init))
113d6aed566Sopenharmony_ci    KEEP (*(.zinitcall.device4.init))
114d6aed566Sopenharmony_ci    __zinitcall_device_end = .;
115d6aed566Sopenharmony_ci    . = ALIGN(4);
116d6aed566Sopenharmony_ci    __zinitcall_core_start = .;
117d6aed566Sopenharmony_ci    KEEP (*(.zinitcall.core0.init))
118d6aed566Sopenharmony_ci    KEEP (*(.zinitcall.core1.init))
119d6aed566Sopenharmony_ci    KEEP (*(.zinitcall.core2.init))
120d6aed566Sopenharmony_ci    KEEP (*(.zinitcall.core3.init))
121d6aed566Sopenharmony_ci    KEEP (*(.zinitcall.core4.init))
122d6aed566Sopenharmony_ci    __zinitcall_core_end = .;
123d6aed566Sopenharmony_ci    . = ALIGN(4);
124d6aed566Sopenharmony_ci    __zinitcall_sys_service_start = .;
125d6aed566Sopenharmony_ci    KEEP (*(.zinitcall.sys.service0.init))
126d6aed566Sopenharmony_ci    KEEP (*(.zinitcall.sys.service1.init))
127d6aed566Sopenharmony_ci    KEEP (*(.zinitcall.sys.service2.init))
128d6aed566Sopenharmony_ci    KEEP (*(.zinitcall.sys.service3.init))
129d6aed566Sopenharmony_ci    KEEP (*(.zinitcall.sys.service4.init))
130d6aed566Sopenharmony_ci    __zinitcall_sys_service_end = .;
131d6aed566Sopenharmony_ci    . = ALIGN(4);
132d6aed566Sopenharmony_ci    __zinitcall_sys_feature_start = .;
133d6aed566Sopenharmony_ci    KEEP (*(.zinitcall.sys.feature0.init))
134d6aed566Sopenharmony_ci    KEEP (*(.zinitcall.sys.feature1.init))
135d6aed566Sopenharmony_ci    KEEP (*(.zinitcall.sys.feature2.init))
136d6aed566Sopenharmony_ci    KEEP (*(.zinitcall.sys.feature3.init))
137d6aed566Sopenharmony_ci    KEEP (*(.zinitcall.sys.feature4.init))
138d6aed566Sopenharmony_ci    __zinitcall_sys_feature_end = .;
139d6aed566Sopenharmony_ci    . = ALIGN(4);
140d6aed566Sopenharmony_ci    __zinitcall_run_start = .;
141d6aed566Sopenharmony_ci    KEEP (*(.zinitcall.run0.init))
142d6aed566Sopenharmony_ci    KEEP (*(.zinitcall.run1.init))
143d6aed566Sopenharmony_ci    KEEP (*(.zinitcall.run2.init))
144d6aed566Sopenharmony_ci    KEEP (*(.zinitcall.run3.init))
145d6aed566Sopenharmony_ci    KEEP (*(.zinitcall.run4.init))
146d6aed566Sopenharmony_ci    __zinitcall_run_end = .;
147d6aed566Sopenharmony_ci    . = ALIGN(4);
148d6aed566Sopenharmony_ci    __zinitcall_app_service_start = .;
149d6aed566Sopenharmony_ci    KEEP (*(.zinitcall.app.service0.init))
150d6aed566Sopenharmony_ci    KEEP (*(.zinitcall.app.service1.init))
151d6aed566Sopenharmony_ci    KEEP (*(.zinitcall.app.service2.init))
152d6aed566Sopenharmony_ci    KEEP (*(.zinitcall.app.service3.init))
153d6aed566Sopenharmony_ci    KEEP (*(.zinitcall.app.service4.init))
154d6aed566Sopenharmony_ci    __zinitcall_app_service_end = .;
155d6aed566Sopenharmony_ci    . = ALIGN(4);
156d6aed566Sopenharmony_ci    __zinitcall_app_feature_start = .;
157d6aed566Sopenharmony_ci    KEEP (*(.zinitcall.app.feature0.init))
158d6aed566Sopenharmony_ci    KEEP (*(.zinitcall.app.feature1.init))
159d6aed566Sopenharmony_ci    KEEP (*(.zinitcall.app.feature2.init))
160d6aed566Sopenharmony_ci    KEEP (*(.zinitcall.app.feature3.init))
161d6aed566Sopenharmony_ci    KEEP (*(.zinitcall.app.feature4.init))
162d6aed566Sopenharmony_ci    __zinitcall_app_feature_end = .;
163d6aed566Sopenharmony_ci    . = ALIGN(4);
164d6aed566Sopenharmony_ci    __zinitcall_test_start = .;
165d6aed566Sopenharmony_ci    KEEP (*(.zinitcall.test0.init))
166d6aed566Sopenharmony_ci    KEEP (*(.zinitcall.test1.init))
167d6aed566Sopenharmony_ci    KEEP (*(.zinitcall.test2.init))
168d6aed566Sopenharmony_ci    KEEP (*(.zinitcall.test3.init))
169d6aed566Sopenharmony_ci    KEEP (*(.zinitcall.test4.init))
170d6aed566Sopenharmony_ci    __zinitcall_test_end = .;
171d6aed566Sopenharmony_ci    . = ALIGN(4);
172d6aed566Sopenharmony_ci    __zinitcall_exit_start = .;
173d6aed566Sopenharmony_ci    KEEP (*(.zinitcall.exit0.init))
174d6aed566Sopenharmony_ci    KEEP (*(.zinitcall.exit1.init))
175d6aed566Sopenharmony_ci    KEEP (*(.zinitcall.exit2.init))
176d6aed566Sopenharmony_ci    KEEP (*(.zinitcall.exit3.init))
177d6aed566Sopenharmony_ci    KEEP (*(.zinitcall.exit4.init))
178d6aed566Sopenharmony_ci    __zinitcall_exit_end = .;
179d6aed566Sopenharmony_ci    . = ALIGN(4);
180d6aed566Sopenharmony_ci  } > ram
181d6aed566Sopenharmony_ci  .bss (NOLOAD): ALIGN(0x20)
182d6aed566Sopenharmony_ci  {
183d6aed566Sopenharmony_ci    __bss_start = .;
184d6aed566Sopenharmony_ci    . = ALIGN(0x10);
185d6aed566Sopenharmony_ci    *(.kernel.bss*)
186d6aed566Sopenharmony_ci    *(.bss.* .sbss.*)
187d6aed566Sopenharmony_ci    . = ALIGN(0x20);
188d6aed566Sopenharmony_ci    __bss_end = .;
189d6aed566Sopenharmony_ci  } > ram
190d6aed566Sopenharmony_ci  .stack (NOLOAD): ALIGN(0x40)
191d6aed566Sopenharmony_ci  {
192d6aed566Sopenharmony_ci    __stack_bootom = .;
193d6aed566Sopenharmony_ci    . += EXCEPT_STACK_SIZE;
194d6aed566Sopenharmony_ci    __except_stack_top = .;
195d6aed566Sopenharmony_ci    . += START_AND_IRQ_STACK_SIZE;
196d6aed566Sopenharmony_ci    __start_and_irq_stack_top = .;
197d6aed566Sopenharmony_ci  } > ram
198d6aed566Sopenharmony_ci
199d6aed566Sopenharmony_ci  .heap (NOLOAD): ALIGN(0x40)
200d6aed566Sopenharmony_ci  {
201d6aed566Sopenharmony_ci    __heap_start = .;
202d6aed566Sopenharmony_ci  } > ram
203d6aed566Sopenharmony_ci
204d6aed566Sopenharmony_ci  __heap_size = RAM_ADDR_SIZE - (__heap_start - __text_start);
205d6aed566Sopenharmony_ci  _end = .;
206d6aed566Sopenharmony_ci  end = .;
207d6aed566Sopenharmony_ci}
208