Use memcpy and memset instead of custom loop

This commit is contained in:
Felix Kopp 2020-06-13 23:06:13 +02:00
parent 205f7ee342
commit f7c01c4b91
No known key found for this signature in database
GPG key ID: C478BA0A85F75728

View file

@ -28,6 +28,7 @@
#include <stddef.h> #include <stddef.h>
#include <stdint.h> #include <stdint.h>
#include <arch/at91sam3x8e/interrupt.h> #include <arch/at91sam3x8e/interrupt.h>
#include <ardix/string.h>
#include <toolchain.h> #include <toolchain.h>
/* from flash.ld */ /* from flash.ld */
@ -46,19 +47,16 @@ void do_bootstrap(void);
void isr_reset(void) void isr_reset(void)
{ {
uint32_t *src; memcpy(
uint32_t *dest; &_etext,
&_srelocate,
/* copy .data to sram */ (size_t)(&_erelocate) - (size_t)(&_srelocate)
dest = &_etext; );
src = &_srelocate; memset(
while (src < &_erelocate) &_szero,
*dest++ = *src++; 0,
(size_t)(&_ezero) - (size_t)(&_szero)
/** clear .bss */ );
dest = &_szero;
while (dest <= &_ezero)
*dest++ = 0;
/* start the Kernel */ /* start the Kernel */
do_bootstrap(); do_bootstrap();