From f7c01c4b91c36fc0392ca6f6ff9736ef7fae8a1a Mon Sep 17 00:00:00 2001 From: Felix Kopp Date: Sat, 13 Jun 2020 23:06:13 +0200 Subject: [PATCH] Use memcpy and memset instead of custom loop --- arch/at91sam3x8e/startup.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/arch/at91sam3x8e/startup.c b/arch/at91sam3x8e/startup.c index eb1b9b0..e2179e4 100644 --- a/arch/at91sam3x8e/startup.c +++ b/arch/at91sam3x8e/startup.c @@ -28,6 +28,7 @@ #include #include #include +#include #include /* from flash.ld */ @@ -46,19 +47,16 @@ void do_bootstrap(void); void isr_reset(void) { - uint32_t *src; - uint32_t *dest; - - /* copy .data to sram */ - dest = &_etext; - src = &_srelocate; - while (src < &_erelocate) - *dest++ = *src++; - - /** clear .bss */ - dest = &_szero; - while (dest <= &_ezero) - *dest++ = 0; + memcpy( + &_etext, + &_srelocate, + (size_t)(&_erelocate) - (size_t)(&_srelocate) + ); + memset( + &_szero, + 0, + (size_t)(&_ezero) - (size_t)(&_szero) + ); /* start the Kernel */ do_bootstrap();