2018-05-14 23:55:15 +02:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2014 Freie Universität Berlin, Hinnerk van Bruinehsen
|
2021-01-02 18:40:07 +01:00
|
|
|
* 2021 Gerson Fernando Budke
|
2023-06-22 17:35:36 +02:00
|
|
|
* 2023 Hugues Larrive
|
2018-05-14 23:55:15 +02:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2021-01-02 18:40:07 +01:00
|
|
|
* @ingroup cpu_avr8_common
|
2018-05-14 23:55:15 +02:00
|
|
|
* @{
|
|
|
|
*
|
|
|
|
* @file
|
|
|
|
* @brief Startup code and interrupt vector definition
|
|
|
|
*
|
|
|
|
* @author Hinnerk van Bruinehsen <h.v.bruinehsen@fu-berlin.de>
|
|
|
|
* @author Josua Arndt <jarndt@ias.rwth-aachen.de>
|
|
|
|
* @author Steffen Robertz <steffen.robertz@rwth-aachen.de>
|
2021-01-02 18:40:07 +01:00
|
|
|
* @author Gerson Fernando Budke <nandojve@gmail.com>
|
2023-06-22 17:35:36 +02:00
|
|
|
* @author Hugues Larrive <hugues.larrive@pm.me>
|
2018-05-14 23:55:15 +02:00
|
|
|
* @}
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <avr/interrupt.h>
|
|
|
|
#include <avr/io.h>
|
|
|
|
|
|
|
|
/* For Catchall-Loop */
|
|
|
|
#include "board.h"
|
2018-11-20 09:43:24 +01:00
|
|
|
#ifdef MODULE_PUF_SRAM
|
|
|
|
#include "puf_sram.h"
|
|
|
|
#endif
|
2020-09-15 14:59:29 +02:00
|
|
|
#ifdef MODULE_DBGPIN
|
|
|
|
#include "dbgpin.h"
|
|
|
|
#endif
|
2018-05-14 23:55:15 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief functions for initializing the board, std-lib and kernel
|
|
|
|
*/
|
|
|
|
extern void board_init(void);
|
2021-10-18 17:30:06 +02:00
|
|
|
extern void cpu_init(void);
|
2018-05-14 23:55:15 +02:00
|
|
|
extern void kernel_init(void);
|
|
|
|
extern void __libc_init_array(void);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief This pair of functions hook circumvent the call to main
|
|
|
|
*
|
|
|
|
* avr-libc normally uses the .init9 section for a call to main. This call
|
|
|
|
* seems to be not replaceable without hacking inside the library. We
|
|
|
|
* circumvent the call to main by using section .init7 to call the function
|
2023-06-22 17:35:36 +02:00
|
|
|
* reset_handler which therefore is the real entry point and section .init8
|
2018-05-14 23:55:15 +02:00
|
|
|
* which should never be reached but just in case jumps to exit.
|
|
|
|
* This way there should be no way to call main directly.
|
|
|
|
*/
|
|
|
|
void init7_ovr(void) __attribute__((section(".init7")));
|
|
|
|
void init8_ovr(void) __attribute__((section(".init8")));
|
|
|
|
|
|
|
|
__attribute__((used, naked)) void init7_ovr(void)
|
|
|
|
{
|
2023-06-22 17:35:36 +02:00
|
|
|
#if (FLASHEND <= 0x1FFF)
|
|
|
|
__asm__ ("rjmp reset_handler");
|
|
|
|
#else
|
2018-05-14 23:55:15 +02:00
|
|
|
__asm__ ("call reset_handler");
|
2023-06-22 17:35:36 +02:00
|
|
|
#endif
|
2018-05-14 23:55:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
__attribute__((used, naked)) void init8_ovr(void)
|
|
|
|
{
|
2023-06-22 17:35:36 +02:00
|
|
|
#if (FLASHEND <= 0x1FFF)
|
|
|
|
__asm__ ("rjmp exit");
|
|
|
|
#else
|
2018-05-14 23:55:15 +02:00
|
|
|
__asm__ ("jmp exit");
|
2023-06-22 17:35:36 +02:00
|
|
|
#endif
|
2018-05-14 23:55:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief This function is the entry point after a system reset
|
|
|
|
*
|
|
|
|
* After a system reset, the following steps are necessary and carried out:
|
|
|
|
* 1. initialize the board (sync clock, setup std-IO)
|
|
|
|
* 2. initialize and start RIOTs kernel
|
|
|
|
*/
|
|
|
|
__attribute__((used)) void reset_handler(void)
|
|
|
|
{
|
2018-11-20 09:43:24 +01:00
|
|
|
#ifdef MODULE_PUF_SRAM
|
|
|
|
puf_sram_init((uint8_t *)RAMEND-SEED_RAM_LEN, SEED_RAM_LEN);
|
|
|
|
#endif
|
2020-09-15 14:59:29 +02:00
|
|
|
|
|
|
|
#ifdef MODULE_DBGPIN
|
|
|
|
dbgpin_init();
|
|
|
|
#endif
|
|
|
|
|
2021-09-07 21:07:56 +02:00
|
|
|
/* initialize the CPU */
|
|
|
|
cpu_init();
|
2018-05-14 23:55:15 +02:00
|
|
|
/* initialize the board and startup the kernel */
|
|
|
|
board_init();
|
|
|
|
/* startup the kernel */
|
|
|
|
kernel_init();
|
|
|
|
}
|