Skip to content

Commit acea241

Browse files
Mahavir JainAnas Nashif
authored andcommitted
kernel: replace .BSS and .DATA setup with standard library calls
Use standard library calls like memset/memcpy for setting up BSS and DATA sections during system initialization, this helps to take advantage of architecture specific optimizations from standard library. Change-Id: Ia72b42aa65b44d1df7c22dd1fbc39a44fa001be9 Signed-off-by: Mahavir Jain <[email protected]>
1 parent a636604 commit acea241

File tree

1 file changed

+5
-14
lines changed

1 file changed

+5
-14
lines changed

kernel/unified/init.c

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include <linker-defs.h>
3535
#include <ksched.h>
3636
#include <version.h>
37+
#include <string.h>
3738

3839
/* kernel build timestamp items */
3940

@@ -133,14 +134,10 @@ extern void idle(void *unused1, void *unused2, void *unused3);
133134
*
134135
* @return N/A
135136
*/
136-
137137
void _bss_zero(void)
138138
{
139-
uint32_t *pos = (uint32_t *)&__bss_start;
140-
141-
for ( ; pos < (uint32_t *)&__bss_end; pos++) {
142-
*pos = 0;
143-
}
139+
memset(&__bss_start, 0,
140+
((uint32_t) &__bss_end - (uint32_t) &__bss_start));
144141
}
145142

146143

@@ -155,14 +152,8 @@ void _bss_zero(void)
155152
*/
156153
void _data_copy(void)
157154
{
158-
uint32_t *pROM, *pRAM;
159-
160-
pROM = (uint32_t *)&__data_rom_start;
161-
pRAM = (uint32_t *)&__data_ram_start;
162-
163-
for ( ; pRAM < (uint32_t *)&__data_ram_end; pROM++, pRAM++) {
164-
*pRAM = *pROM;
165-
}
155+
memcpy(&__data_ram_start, &__data_rom_start,
156+
((uint32_t) &__data_ram_end - (uint32_t) &__data_ram_start));
166157
}
167158
#endif
168159

0 commit comments

Comments
 (0)