| 1 |
/* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 |
|
| 3 |
#if ENV_SEPARATE_DATA_AND_BSS |
| 4 |
|
| 5 |
/* |
| 6 |
* Copy .data section content from _data_load to it's linked |
| 7 |
* address. Usually that's inside Cache-As-Ram. |
| 8 |
* This code can be included from 32 bits or 64 bits code. |
| 9 |
* It also preserves registers by using stack. |
| 10 |
*/ |
| 11 |
copy_data_section: |
| 12 |
#if ENV_X86_64 |
| 13 |
push %rcx |
| 14 |
push %rdi |
| 15 |
push %rsi |
| 16 |
#else |
| 17 |
pushl %ecx |
| 18 |
pushl %edi |
| 19 |
pushl %esi |
| 20 |
#endif |
| 21 |
|
| 22 |
movl $(_edata), %ecx |
| 23 |
movl $(_data), %edi |
| 24 |
sub %edi, %ecx |
| 25 |
movl $(_data_load),%esi |
| 26 |
shrl $2, %ecx |
| 27 |
rep movsl |
| 28 |
|
| 29 |
#if ENV_X86_64 |
| 30 |
pop %rsi |
| 31 |
pop %rdi |
| 32 |
pop %rcx |
| 33 |
#else |
| 34 |
popl %esi |
| 35 |
popl %edi |
| 36 |
popl %ecx |
| 37 |
#endif |
| 38 |
|
| 39 |
#endif /* ENV_SEPARATE_DATA_AND_BSS */ |