blob: 333f9b7dd1762a270ad98649b7d8b43a7c7b12bf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
/*
* Arm SCP/MCP Software
* Copyright (c) 2015-2020, Arm Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <cmsis_compiler.h>
#include <fwk_arch.h>
#include <fwk_assert.h>
#include <fwk_macros.h>
#include <fmw_cmsis.h>
#include <stdbool.h>
#include <stdint.h>
extern int arch_nvic_init(const struct fwk_arch_interrupt_driver **driver);
extern int arch_mm_init(struct fwk_arch_mm_data *data);
#if defined(__ARMCC_VERSION)
/*
* Standard library backend functions required by Arm Compiler 6.
*/
/* Platform-dependent backend for the assert() macro */
void __aeabi_assert(const char *expr, const char *file, int line)
{
fwk_trap();
}
#elif defined(__NEWLIB__)
/*
* Standard library backend functions required by newlib[-nano].
*/
/* Platform-dependent backend for the assert() macro */
void __assert_func(
const char *file,
int line,
const char *function,
const char *assertion)
{
fwk_trap();
}
/* Platform-dependent backend for the _Exit() function */
void _exit(int status)
{
while (true)
__WFI();
}
#endif
static const struct fwk_arch_init_driver arch_init_driver = {
.mm = arch_mm_init,
.interrupt = arch_nvic_init,
};
static void arch_init_ccr(void)
{
/*
* Set up the Configuration Control Register (CCR) in the System Control
* Block (1) by setting the following flag bits:
*
* DIV_0_TRP [4]: Enable trapping on division by zero.
* STKALIGN [9]: Enable automatic DWORD stack-alignment on exception
* entry (2).
*
* All other bits are left in their default state.
*
* (1) ARM® v7-M Architecture Reference Manual, section B3.2.8.
* (2) ARM® v7-M Architecture Reference Manual, section B1.5.7.
*/
SCB->CCR |= SCB_CCR_DIV_0_TRP_Msk;
SCB->CCR |= SCB_CCR_STKALIGN_Msk;
}
int main(void)
{
arch_init_ccr();
return fwk_arch_init(&arch_init_driver);
}
|