2019-07-25 22:41:08 +02:00
|
|
|
/*
|
|
|
|
* Copyright 2008-2009, Freie Universitaet Berlin (FUB). All rights reserved.
|
|
|
|
*
|
|
|
|
* This file is subject to the terms and conditions of the GNU Lesser
|
|
|
|
* General Public License v2.1. See the file LICENSE in the top level
|
|
|
|
* directory for more details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @ingroup cpu_arm7_common
|
|
|
|
* @{
|
|
|
|
*
|
|
|
|
* @file
|
|
|
|
* @brief Common ARM7 boot up code
|
|
|
|
*
|
|
|
|
* @author Heiko Will <hwill@inf.fu-berlin.de>
|
|
|
|
* @author Michael Baar <michael.baar@fu-berlin.de>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include "thread.h"
|
2019-11-25 01:34:38 +01:00
|
|
|
#ifdef MODULE_PUF_SRAM
|
|
|
|
#include "puf_sram.h"
|
|
|
|
#endif
|
2019-07-25 22:41:08 +02:00
|
|
|
|
|
|
|
#include "log.h"
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
_init_data(void)
|
|
|
|
{
|
|
|
|
extern unsigned int _etext;
|
|
|
|
extern unsigned int _data;
|
|
|
|
extern unsigned int _edata;
|
|
|
|
extern unsigned int __bss_start;
|
|
|
|
extern unsigned int __bss_end;
|
|
|
|
|
|
|
|
register unsigned int *p1;
|
|
|
|
register unsigned int *p2;
|
|
|
|
register unsigned int *p3;
|
|
|
|
|
|
|
|
// initialize data from flash
|
|
|
|
// (linker script ensures that data is 32-bit aligned)
|
|
|
|
p1 = &_etext;
|
|
|
|
p2 = &_data;
|
|
|
|
p3 = &_edata;
|
|
|
|
|
|
|
|
while (p2 < p3) {
|
|
|
|
*p2++ = *p1++;
|
|
|
|
}
|
|
|
|
|
|
|
|
// clear bss
|
|
|
|
// (linker script ensures that bss is 32-bit aligned)
|
|
|
|
p1 = &__bss_start;
|
|
|
|
p2 = &__bss_end;
|
|
|
|
|
|
|
|
while (p1 < p2) {
|
|
|
|
*p1++ = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void bootloader(void)
|
|
|
|
{
|
2019-09-14 14:49:48 +02:00
|
|
|
extern void cpu_init(void);
|
2019-07-25 22:41:08 +02:00
|
|
|
|
|
|
|
/* initialize bss and data */
|
|
|
|
_init_data();
|
|
|
|
|
2019-11-25 01:34:38 +01:00
|
|
|
#ifdef MODULE_PUF_SRAM
|
|
|
|
/* uninitialized heap starts after bss section */
|
|
|
|
extern unsigned int __bss_end;
|
|
|
|
puf_sram_init((uint8_t *) __bss_end, SEED_RAM_LEN);
|
|
|
|
#endif
|
|
|
|
|
2019-09-14 14:49:48 +02:00
|
|
|
/* cpu specific setup of clocks, peripherals */
|
|
|
|
cpu_init();
|
2019-07-25 22:41:08 +02:00
|
|
|
|
|
|
|
#ifdef MODULE_NEWLIB
|
|
|
|
extern void __libc_init_array(void);
|
|
|
|
__libc_init_array();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/** @} */
|