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