Skip to content

Commit

Permalink
Copy .data section from ROM
Browse files Browse the repository at this point in the history
  • Loading branch information
embeddedden committed Jun 23, 2017
1 parent 7d4417d commit 6f93c27
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 13 deletions.
21 changes: 21 additions & 0 deletions c/src/lib/libbsp/riscv32/hifive1/start/start.S
Expand Up @@ -112,6 +112,27 @@ _loop_clear_bss:
j _loop_clear_bss
nop
_end_clear_bss:


/* Copy data */
la t0, _copy_start
la t1, _copy_end
la t3, __data_start_rom

_loop_copy_data:
bge t0, t1, _end_copy_data
addi t0, t0, 1
addi t3, t3, 1
lb t4, 0(t3)
sb t4, 0(t0)
j _loop_copy_data
nop
_end_copy_data:


nop
nop


call boot_card
nop
Expand Down
33 changes: 20 additions & 13 deletions c/src/lib/libbsp/riscv32/hifive1/startup/linkcmds
Expand Up @@ -124,6 +124,10 @@ SECTIONS {
KEEP (*(.fini))
. = ALIGN(8);
bsp_section_text_end = .;
PROVIDE (__etext = .);
PROVIDE (_etext = .);
PROVIDE (etext = .);

} > REGION_TEXT AT > REGION_TEXT_LOAD
bsp_section_text_size = bsp_section_text_end - bsp_section_text_begin;
bsp_section_text_load_begin = LOADADDR (.text);
Expand Down Expand Up @@ -304,34 +308,37 @@ SECTIONS {
KEEP (*(SORT(.rtemsroset.*)))
. = ALIGN(8);
bsp_section_rodata_end = .;
__data_start_rom = .;
} > REGION_RODATA AT > REGION_RODATA_LOAD
bsp_section_rodata_size = bsp_section_rodata_end - bsp_section_rodata_begin;
bsp_section_rodata_load_begin = LOADADDR (.rodata);
bsp_section_rodata_load_end = bsp_section_rodata_load_begin + bsp_section_rodata_size;

.rwbarrier : {
. = ALIGN(8);
. = ALIGN (bsp_section_rwbarrier_align);
} > REGION_DATA AT > REGION_DATA

.data : {

.data : AT (__data_start_rom) {
. = ALIGN(8);
bsp_section_data_begin = .;
*(.data .data.* .gnu.linkonce.d.*)
PROVIDE (_copy_start = .);
*(.data .data.* .gnu.linkonce.d.* .data1)
SORT(CONSTRUCTORS)
} > REGION_DATA AT > REGION_DATA_LOAD
.data1 : {
*(.data1)
} > REGION_DATA AT > REGION_DATA_LOAD
.rtemsrwset : {
} > REGION_DATA
.rtemsrwset : AT (__data_start_rom + SIZEOF (.data)) {
KEEP (*(SORT(.rtemsrwset.*)))
. = ALIGN(8);
bsp_section_data_end = .;
} > REGION_DATA AT > REGION_DATA_LOAD

} > REGION_DATA
bsp_section_data_size = bsp_section_data_end - bsp_section_data_begin;
bsp_section_data_load_begin = LOADADDR (.data);
bsp_section_data_load_end = bsp_section_data_load_begin + bsp_section_data_size;

.rwbarrier : AT (__data_start_rom + SIZEOF (.data) + SIZEOF (.rtemsrwset)) {
. = ALIGN(8);
. = ALIGN (bsp_section_rwbarrier_align);
bsp_section_data_end = .;
PROVIDE (_copy_end = .);
} > REGION_DATA

.bss : {
. = ALIGN(8);
bsp_section_bss_begin = .;
Expand Down

0 comments on commit 6f93c27

Please sign in to comment.