Mistake on this page?
Report an issue in GitHub or email us
mbed_boot.h
1 /* mbed Microcontroller Library
2  * Copyright (c) 2018-2019 ARM Limited
3  * SPDX-License-Identifier: Apache-2.0
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 #ifndef MBED_BOOT_H
18 #define MBED_BOOT_H
19 
20 #include "mbed_toolchain.h"
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
26 #include "mbed_rtx.h"
27 
28 /** \addtogroup rtos-internal-api */
29 /** @{*/
30 
31 /**
32  * \defgroup boot Boot sequence
33  * Boot sequence overview
34  *
35  * 1. Setup target
36  * - Configure clocks
37  * - Configure watchdog (if applicable)
38  * - Turn on RAM (if applicable)
39  * - Jump to setup toolchain
40  * 2. Setup toolchain
41  * - Initialize RAM
42  * - Initialize standard library
43  * - Call mbed_init
44  * - jump to start rtos
45  * 3. Start RTOS
46  * - Create main thread
47  * - Start scheduler
48  * - main thread calls start mbed
49  * 4. Start mbed
50  * - Call mbed_main
51  * - Call main
52  *
53  * @{
54  */
55 
56 /* Heap limits - only used if set */
57 extern unsigned char *mbed_heap_start;
58 extern uint32_t mbed_heap_size;
59 
60 /* Stack limits */
61 extern unsigned char *mbed_stack_isr_start;
62 extern uint32_t mbed_stack_isr_size;
63 
64 /**
65  * Perform low level init of mbed
66  *
67  * The toolchain calls this function as part of the boot
68  * sequence. This function does the following:
69  * - Sets up NVIC so interrupts can be used
70  * - Calls into the vendor SDK so it can be used
71  * - Initializes the RTOS so it can be used
72  *
73  * Preconditions:
74  * - Target is initialized
75  * - Ram is initialized
76  * - value set for mbed_heap_start
77  * - value set for mbed_heap_size
78  * - value set for mbed_stack_isr_start
79  * - value set for mbed_stack_isr_size
80  *
81  * The following events must not have happened yet:
82  * - global constructors must not be called yet
83  *
84  */
85 void mbed_init(void);
86 
87 /**
88  * Start the main mbed application
89  *
90  * This is the last stage of the boot sequence. This function must be
91  * called only after the RTOS has been fully initialized.
92  * This function does the following:
93  * - Initialize the toolchain
94  * - Run mbed_main
95  * - Run main
96  *
97  * Preconditions:
98  * - The RTOS has been started by a call to mbed_rtos_start
99  *
100  */
101 void mbed_start(void);
102 
103 /**
104  * Perform low level initialization of the RTOS
105  *
106  * Set the RTOS to a known state but don't start the scheduler. After
107  * the RTOS has been initialized it is safe to create RTOS primitives
108  * for file locks or other purposes.
109  *
110  * Preconditions:
111  * - Ram is initialized
112  * - NVIC is setup
113  * - Vendor SDK must be initialized by a call to mbed_sdk_init
114  */
115 void mbed_rtos_init(void);
116 
117 /**
118  * Start the RTOS
119  *
120  * Start the RTOS scheduler and call mbed_start on the
121  * main thread. This function does not return.
122  *
123  * Preconditions:
124  * - RTOS has been initialized by a call to mbed_rtos_init
125  */
126 MBED_NORETURN void mbed_rtos_start(void);
127 
128 /**
129  * Perform toolchain specific initialization
130  *
131  * Initialize locks if this has not been done already
132  * and call global C++ constructors.
133  *
134  * Preconditions:
135  * - The RTOS has been started by a call to mbed_rtos_start
136  */
137 void mbed_toolchain_init(void);
138 
139 /**
140  * SDK hook for running code before ctors or OS
141  *
142  * This is a weak function which can be overridden by a target's
143  * SDK to allow code to run after ram is initialized but before
144  * the OS has been started or constructors have run.
145  *
146  * Preconditions:
147  * - Ram is initialized
148  * - NVIC is setup
149  */
150 void mbed_sdk_init(void);
151 
152 /**
153  * Application hook for running code before main
154  *
155  * This is a weak function which can be overridden by an application
156  * to allow code to run before main is called.
157  *
158  * Preconditions:
159  * - The RTOS has been started by a call to mbed_rtos_start
160  * - The toolchain has been initialized by a call to mbed_toolchain_init
161  */
162 void mbed_main(void);
163 
164 /**@}*/
165 /**@}*/
166 
167 #ifdef __cplusplus
168 }
169 #endif
170 
171 #endif /* MBED_BOOT_H */
MBED_NORETURN void mbed_rtos_start(void)
Start the RTOS.
void mbed_start(void)
Start the main mbed application.
void mbed_toolchain_init(void)
Perform toolchain specific initialization.
void mbed_rtos_init(void)
Perform low level initialization of the RTOS.
void mbed_init(void)
Perform low level init of mbed.
void mbed_main(void)
Application hook for running code before main.
#define MBED_NORETURN
MBED_NORETURN Declare a function that will never return.
void mbed_sdk_init(void)
SDK hook for running code before ctors or OS.
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.