Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
mbed-os/platform/mbed_sdk_boot.c@0:fb8047b156bb, 2020-01-15 (annotated)
- Committer:
- rahul_dahiya
- Date:
- Wed Jan 15 15:57:15 2020 +0530
- Revision:
- 0:fb8047b156bb
STM32F7 LWIP
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
rahul_dahiya |
0:fb8047b156bb | 1 | /* mbed Microcontroller Library |
rahul_dahiya |
0:fb8047b156bb | 2 | * Copyright (c) 2017 ARM Limited |
rahul_dahiya |
0:fb8047b156bb | 3 | * |
rahul_dahiya |
0:fb8047b156bb | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
rahul_dahiya |
0:fb8047b156bb | 5 | * you may not use this file except in compliance with the License. |
rahul_dahiya |
0:fb8047b156bb | 6 | * You may obtain a copy of the License at |
rahul_dahiya |
0:fb8047b156bb | 7 | * |
rahul_dahiya |
0:fb8047b156bb | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
rahul_dahiya |
0:fb8047b156bb | 9 | * |
rahul_dahiya |
0:fb8047b156bb | 10 | * Unless required by applicable law or agreed to in writing, software |
rahul_dahiya |
0:fb8047b156bb | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
rahul_dahiya |
0:fb8047b156bb | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
rahul_dahiya |
0:fb8047b156bb | 13 | * See the License for the specific language governing permissions and |
rahul_dahiya |
0:fb8047b156bb | 14 | * limitations under the License. |
rahul_dahiya |
0:fb8047b156bb | 15 | */ |
rahul_dahiya |
0:fb8047b156bb | 16 | |
rahul_dahiya |
0:fb8047b156bb | 17 | #include "mbed_toolchain.h" |
rahul_dahiya |
0:fb8047b156bb | 18 | #include <stdlib.h> |
rahul_dahiya |
0:fb8047b156bb | 19 | #include <stdint.h> |
rahul_dahiya |
0:fb8047b156bb | 20 | #include "cmsis.h" |
rahul_dahiya |
0:fb8047b156bb | 21 | |
rahul_dahiya |
0:fb8047b156bb | 22 | /* This startup is for mbed 2 baremetal. There is no config for RTOS for mbed 2, |
rahul_dahiya |
0:fb8047b156bb | 23 | * therefore we protect this file with MBED_CONF_RTOS_PRESENT |
rahul_dahiya |
0:fb8047b156bb | 24 | * Note: The new consolidated started for mbed OS is in rtos/mbed_boot code file. |
rahul_dahiya |
0:fb8047b156bb | 25 | */ |
rahul_dahiya |
0:fb8047b156bb | 26 | #if !defined(MBED_CONF_RTOS_PRESENT) |
rahul_dahiya |
0:fb8047b156bb | 27 | |
rahul_dahiya |
0:fb8047b156bb | 28 | /* mbed_main is a function that is called before main() |
rahul_dahiya |
0:fb8047b156bb | 29 | * mbed_sdk_init() is also a function that is called before main(), but unlike |
rahul_dahiya |
0:fb8047b156bb | 30 | * mbed_main(), it is not meant for user code, but for the SDK itself to perform |
rahul_dahiya |
0:fb8047b156bb | 31 | * initializations before main() is called. |
rahul_dahiya |
0:fb8047b156bb | 32 | */ |
rahul_dahiya |
0:fb8047b156bb | 33 | MBED_WEAK void mbed_main(void) |
rahul_dahiya |
0:fb8047b156bb | 34 | { |
rahul_dahiya |
0:fb8047b156bb | 35 | |
rahul_dahiya |
0:fb8047b156bb | 36 | } |
rahul_dahiya |
0:fb8047b156bb | 37 | |
rahul_dahiya |
0:fb8047b156bb | 38 | /* This function can be implemented by the target to perform higher level target initialization |
rahul_dahiya |
0:fb8047b156bb | 39 | */ |
rahul_dahiya |
0:fb8047b156bb | 40 | MBED_WEAK void mbed_sdk_init(void) |
rahul_dahiya |
0:fb8047b156bb | 41 | { |
rahul_dahiya |
0:fb8047b156bb | 42 | |
rahul_dahiya |
0:fb8047b156bb | 43 | } |
rahul_dahiya |
0:fb8047b156bb | 44 | |
rahul_dahiya |
0:fb8047b156bb | 45 | MBED_WEAK void software_init_hook_rtos() |
rahul_dahiya |
0:fb8047b156bb | 46 | { |
rahul_dahiya |
0:fb8047b156bb | 47 | // Nothing by default |
rahul_dahiya |
0:fb8047b156bb | 48 | } |
rahul_dahiya |
0:fb8047b156bb | 49 | |
rahul_dahiya |
0:fb8047b156bb | 50 | void mbed_copy_nvic(void) |
rahul_dahiya |
0:fb8047b156bb | 51 | { |
rahul_dahiya |
0:fb8047b156bb | 52 | /* If vector address in RAM is defined, copy and switch to dynamic vectors. Exceptions for M0 which doesn't have |
rahul_dahiya |
0:fb8047b156bb | 53 | VTOR register and for A9 for which CMSIS doesn't define NVIC_SetVector; in both cases target code is |
rahul_dahiya |
0:fb8047b156bb | 54 | responsible for correctly handling the vectors. |
rahul_dahiya |
0:fb8047b156bb | 55 | */ |
rahul_dahiya |
0:fb8047b156bb | 56 | #if !defined(__CORTEX_M0) && !defined(__CORTEX_A9) |
rahul_dahiya |
0:fb8047b156bb | 57 | #ifdef NVIC_RAM_VECTOR_ADDRESS |
rahul_dahiya |
0:fb8047b156bb | 58 | uint32_t *old_vectors = (uint32_t *)SCB->VTOR; |
rahul_dahiya |
0:fb8047b156bb | 59 | uint32_t *vectors = (uint32_t*)NVIC_RAM_VECTOR_ADDRESS; |
rahul_dahiya |
0:fb8047b156bb | 60 | for (int i = 0; i < NVIC_NUM_VECTORS; i++) { |
rahul_dahiya |
0:fb8047b156bb | 61 | vectors[i] = old_vectors[i]; |
rahul_dahiya |
0:fb8047b156bb | 62 | } |
rahul_dahiya |
0:fb8047b156bb | 63 | SCB->VTOR = (uint32_t)NVIC_RAM_VECTOR_ADDRESS; |
rahul_dahiya |
0:fb8047b156bb | 64 | #endif /* NVIC_RAM_VECTOR_ADDRESS */ |
rahul_dahiya |
0:fb8047b156bb | 65 | #endif /* !defined(__CORTEX_M0) && !defined(__CORTEX_A9) */ |
rahul_dahiya |
0:fb8047b156bb | 66 | } |
rahul_dahiya |
0:fb8047b156bb | 67 | |
rahul_dahiya |
0:fb8047b156bb | 68 | /* Toolchain specific main code */ |
rahul_dahiya |
0:fb8047b156bb | 69 | |
rahul_dahiya |
0:fb8047b156bb | 70 | #if defined (__CC_ARM) || (defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 5010060)) |
rahul_dahiya |
0:fb8047b156bb | 71 | |
rahul_dahiya |
0:fb8047b156bb | 72 | int $Super$$main(void); |
rahul_dahiya |
0:fb8047b156bb | 73 | |
rahul_dahiya |
0:fb8047b156bb | 74 | int $Sub$$main(void) |
rahul_dahiya |
0:fb8047b156bb | 75 | { |
rahul_dahiya |
0:fb8047b156bb | 76 | mbed_main(); |
rahul_dahiya |
0:fb8047b156bb | 77 | return $Super$$main(); |
rahul_dahiya |
0:fb8047b156bb | 78 | } |
rahul_dahiya |
0:fb8047b156bb | 79 | |
rahul_dahiya |
0:fb8047b156bb | 80 | void _platform_post_stackheap_init(void) |
rahul_dahiya |
0:fb8047b156bb | 81 | { |
rahul_dahiya |
0:fb8047b156bb | 82 | mbed_copy_nvic(); |
rahul_dahiya |
0:fb8047b156bb | 83 | mbed_sdk_init(); |
rahul_dahiya |
0:fb8047b156bb | 84 | } |
rahul_dahiya |
0:fb8047b156bb | 85 | |
rahul_dahiya |
0:fb8047b156bb | 86 | #elif defined (__GNUC__) |
rahul_dahiya |
0:fb8047b156bb | 87 | |
rahul_dahiya |
0:fb8047b156bb | 88 | extern int __real_main(void); |
rahul_dahiya |
0:fb8047b156bb | 89 | |
rahul_dahiya |
0:fb8047b156bb | 90 | void software_init_hook(void) |
rahul_dahiya |
0:fb8047b156bb | 91 | { |
rahul_dahiya |
0:fb8047b156bb | 92 | mbed_copy_nvic(); |
rahul_dahiya |
0:fb8047b156bb | 93 | mbed_sdk_init(); |
rahul_dahiya |
0:fb8047b156bb | 94 | software_init_hook_rtos(); |
rahul_dahiya |
0:fb8047b156bb | 95 | } |
rahul_dahiya |
0:fb8047b156bb | 96 | |
rahul_dahiya |
0:fb8047b156bb | 97 | |
rahul_dahiya |
0:fb8047b156bb | 98 | int __wrap_main(void) |
rahul_dahiya |
0:fb8047b156bb | 99 | { |
rahul_dahiya |
0:fb8047b156bb | 100 | mbed_main(); |
rahul_dahiya |
0:fb8047b156bb | 101 | return __real_main(); |
rahul_dahiya |
0:fb8047b156bb | 102 | } |
rahul_dahiya |
0:fb8047b156bb | 103 | |
rahul_dahiya |
0:fb8047b156bb | 104 | #elif defined (__ICCARM__) |
rahul_dahiya |
0:fb8047b156bb | 105 | |
rahul_dahiya |
0:fb8047b156bb | 106 | int __low_level_init(void) |
rahul_dahiya |
0:fb8047b156bb | 107 | { |
rahul_dahiya |
0:fb8047b156bb | 108 | mbed_copy_nvic(); |
rahul_dahiya |
0:fb8047b156bb | 109 | return 1; |
rahul_dahiya |
0:fb8047b156bb | 110 | } |
rahul_dahiya |
0:fb8047b156bb | 111 | |
rahul_dahiya |
0:fb8047b156bb | 112 | #endif |
rahul_dahiya |
0:fb8047b156bb | 113 | |
rahul_dahiya |
0:fb8047b156bb | 114 | #endif |