v2.0.0
runtime_init.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2024 Raspberry Pi (Trading) Ltd.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#ifndef _PICO_RUNTIME_INITS_H
8#define _PICO_RUNTIME_INITS_H
9
10#include "pico.h"
11#include "pico/runtime.h"
12
13#ifdef __cplusplus
14extern "C" {
15#endif
16
53// must have no dependency on any other initialization code
54#define PICO_RUNTIME_INIT_EARLIEST "00001"
55
56// -----------------------------------------------------------------------------------------------
57// Reset of global bootrom state (can be skipped if boot path was via bootrom); not used on RP2040
58// -----------------------------------------------------------------------------------------------
59// PICO_CONFIG: PICO_RUNTIME_SKIP_INIT_BOOTROM_RESET, Skip calling of `runtime_init_bootrom_reset` function during runtime init, type=bool, default=1 on RP2040, group=pico_runtime_init
60// PICO_CONFIG: PICO_RUNTIME_NO_INIT_BOOTROM_RESET, Do not include SDK implementation of `runtime_init_bootrom_reset` function, type=bool, default=1 on RP2040, group=pico_runtime_init
61
62#ifndef PICO_RUNTIME_INIT_BOOTROM_RESET
63#define PICO_RUNTIME_INIT_BOOTROM_RESET "00050"
64#endif
65
66#ifndef PICO_RUNTIME_SKIP_INIT_BOOTROM_RESET
67#if PICO_RP2040 || (!LIB_PICO_MULTICORE && PICO_NO_FLASH)
68#define PICO_RUNTIME_SKIP_INIT_BOOTROM_RESET 1
69#endif
70#endif
71
72#ifndef PICO_RUNTIME_NO_INIT_BOOTROM_RESET
73#if PICO_RP2040 || (!LIB_PICO_MULTICORE && PICO_NO_FLASH)
74#define PICO_RUNTIME_NO_INIT_BOOTROM_RESET 1
75#endif
76#endif
77
78#ifndef __ASSEMBLER__
79void runtime_init_bootrom_reset(void);
80#endif
81
82// ---------------------------------------------------------------------------------------
83// Non-boot core eset of bootrom state, not needed if only using core 0 not used on RP2040
84// ---------------------------------------------------------------------------------------
85#ifndef PICO_RUNTIME_INIT_PER_CORE_BOOTROM_RESET
86#define PICO_RUNTIME_INIT_PER_CORE_BOOTROM_RESET "00051"
87#endif
88
89// PICO_CONFIG: PICO_RUNTIME_SKIP_INIT_PER_CORE_BOOTROM_RESET, Skip calling of `runtime_init_per_core_bootrom_reset` function during per-core init, type=bool, default=1 on RP2040, group=pico_runtime_init
90// PICO_CONFIG: PICO_RUNTIME_NO_INIT_PER_CORE_BOOTROM_RESET, Do not include SDK implementation of `runtime_init_per_core_bootrom_reset` function, type=bool, default=1 on RP2040, group=pico_runtime_init
91#ifndef PICO_RUNTIME_SKIP_INIT_PER_CORE_BOOTROM_RESET
92#if PICO_RP2040
93#define PICO_RUNTIME_SKIP_INIT_PER_CORE_BOOTROM_RESET 1
94#endif
95#endif
96
97#ifndef PICO_RUNTIME_NO_INIT_PER_CORE_BOOTROM_RESET
98#if PICO_RP2040
99#define PICO_RUNTIME_NO_INIT_PER_CORE_BOOTROM_RESET 1
100#endif
101#endif
102
103#ifndef __ASSEMBLER__
104void runtime_init_per_core_bootrom_reset(void);
105#endif
106
107// ---------------------------
108// Hazard3 processor IRQ setup
109// ---------------------------
110
111// PICO_CONFIG: PICO_RUNTIME_SKIP_INIT_PER_CORE_H3_IRQ_REGISTERS, Skip calling of `runtime_init_per_core_h3_irq_registers` function during per-core init, type=bool, default=1 on non RISC-V, group=pico_runtime_init
112
113#ifndef PICO_RUNTIME_INIT_PER_CORE_H3_IRQ_REGISTERS
114#define PICO_RUNTIME_INIT_PER_CORE_H3_IRQ_REGISTERS "00060"
115#endif
116
117#ifndef PICO_RUNTIME_SKIP_INIT_PER_CORE_H3_IRQ_REGISTERS
118#ifndef __riscv
119#define PICO_RUNTIME_SKIP_INIT_PER_CORE_H3_IRQ_REGISTERS 1
120#endif
121#endif
122
123// -------------------------------
124// Earliest resets (no clocks yet)
125// -------------------------------
126#ifndef PICO_RUNTIME_INIT_EARLY_RESETS
127#define PICO_RUNTIME_INIT_EARLY_RESETS "00100"
128#endif
129
130// PICO_CONFIG: PICO_RUNTIME_SKIP_INIT_EARLY_RESETS, Skip calling of `runtime_init_early_resets` function during runtime init, type=bool, default=1 on RP2040, group=pico_runtime_init
131// PICO_CONFIG: PICO_RUNTIME_NO_INIT_EARLY_RESETS, Do not include SDK implementation of `runtime_init_early_resets` function, type=bool, default=1 on RP2040, group=pico_runtime_init
132#ifndef PICO_RUNTIME_SKIP_INIT_EARLY_RESETS
133#define PICO_RUNTIME_SKIP_INIT_EARLY_RESETS 0
134#endif
135
136#ifndef PICO_RUNTIME_NO_INIT_EARLY_RESETS
137#define PICO_RUNTIME_NO_INIT_EARLY_RESETS 0
138#endif
139
140#ifndef __ASSEMBLER__
141void runtime_init_early_resets(void);
142#endif
143
144// --------------
145// USB power down
146// --------------
147// PICO_CONFIG: PICO_RUNTIME_SKIP_INIT_USB_POWER_DOWN, Skip calling of `runtime_init_usb_power_down` function during runtime init, type=bool, default=0, group=pico_runtime_init
148// PICO_CONFIG: PICO_RUNTIME_NO_INIT_USB_POWER_DOWN, Do not include SDK implementation of `runtime_init_usb_power_down` function, type=bool, default=0, group=pico_runtime_init
149
150#ifndef PICO_RUNTIME_INIT_USB_POWER_DOWN
151#define PICO_RUNTIME_INIT_USB_POWER_DOWN "00101"
152#endif
153
154#ifndef PICO_RUNTIME_SKIP_INIT_USB_POWER_DOWN
155#define PICO_RUNTIME_SKIP_INIT_USB_POWER_DOWN 0
156#endif
157
158#ifndef PICO_RUNTIME_NO_INIT_USB_POWER_DOWN
159#define PICO_RUNTIME_NO_INIT_USB_POWER_DOWN 0
160#endif
161
162#ifndef __ASSEMBLER__
163void runtime_init_usb_power_down(void);
164#endif
165
166// ------------------------------------
167// per core co-processor initialization
168// ------------------------------------
169
170// PICO_CONFIG: PICO_RUNTIME_SKIP_INIT_PER_CORE_ENABLE_COPROCESSORS, Skip calling of `runtime_init_per_core_enable_coprocessors` function during per-core init, type=bool, default=1 on RP2040 or RISC-V, group=pico_runtime_init
171// PICO_CONFIG: PICO_RUNTIME_NO_INIT_PER_CORE_ENABLE_COPROCESSORS, Do not include SDK implementation of `runtime_init_per_core_enable_coprocessors` function, type=bool, default=1 on RP2040 or RISC-V, group=pico_runtime_init
172
173#ifndef PICO_RUNTIME_INIT_PER_CORE_ENABLE_COPROCESSORS
174#define PICO_RUNTIME_INIT_PER_CORE_ENABLE_COPROCESSORS "00200"
175#endif
176
177#ifndef PICO_RUNTIME_SKIP_INIT_PER_CORE_ENABLE_COPROCESSORS
178#if PICO_RP2040 || defined(__riscv)
179#define PICO_RUNTIME_SKIP_INIT_PER_CORE_ENABLE_COPROCESSORS 1
180#endif
181#endif
182
183#ifndef PICO_RUNTIME_NO_INIT_PER_CORE_ENABLE_COPROCESSORS
184#if PICO_RP2040 || defined(__riscv)
185#define PICO_RUNTIME_NO_INIT_PER_CORE_ENABLE_COPROCESSORS 1
186#endif
187#endif
188
189#ifndef __ASSEMBLER__
190void runtime_init_per_core_enable_coprocessors(void);
191#endif
192
193// AEABI init; this initialization is auto-injected byte pico_aeebi_mem_ops if present
194#ifndef PICO_RUNTIME_INIT_AEABI_MEM_OPS
195// on RP2040 we need to get memcpy and memset hooked up to bootrom
196#define PICO_RUNTIME_INIT_AEABI_MEM_OPS "00300"
197#endif
198
199// AEABI init; this initialization is auto-injected byte pico_aeebi_bit_ops if present
200#ifndef PICO_RUNTIME_INIT_AEABI_BIT_OPS
201#define PICO_RUNTIME_INIT_AEABI_BIT_OPS "00275"
202#endif
203
204// AEABI init; this initialization is auto-injected byte pico_aeebi_float if present
205#ifndef PICO_RUNTIME_INIT_AEABI_FLOAT
206#define PICO_RUNTIME_INIT_AEABI_FLOAT "00350"
207#endif
208
209// AEABI init; this initialization is auto-injected byte pico_aeebi_double if present
210#ifndef PICO_RUNTIME_INIT_AEABI_DOUBLE
211#define PICO_RUNTIME_INIT_AEABI_DOUBLE "00350"
212#endif
213
214// ------------------------
215// Initialization of clocks
216// ------------------------
217// PICO_CONFIG: PICO_RUNTIME_SKIP_INIT_CLOCKS, Skip calling of `runtime_init_clocks` function during runtime init, type=bool, default=0, group=pico_runtime_init
218// PICO_CONFIG: PICO_RUNTIME_NO_INIT_CLOCKS, Do not include SDK implementation of `runtime_init_clocks` function, type=bool, default=0, group=pico_runtime_init
219
220#ifndef PICO_RUNTIME_INIT_CLOCKS
221// on RP2040 we need some of the AEABI init by this point to do clock math
222#define PICO_RUNTIME_INIT_CLOCKS "00500"
223#endif
224
225#ifndef PICO_RUNTIME_SKIP_INIT_CLOCKS
226#define PICO_RUNTIME_SKIP_INIT_CLOCKS 0
227#endif
228
229#ifndef PICO_RUNTIME_NO_INIT_CLOCKS
230#define PICO_RUNTIME_NO_INIT_CLOCKS 0
231#endif
232#ifndef __ASSEMBLER__
233void runtime_init_clocks(void);
234
240 static inline void clocks_init(void) {
241 // backwards compatibility with earlier SDK
242 runtime_init_clocks();
243}
244#endif
245
246// ----------------------------------------
247// Remaining h/w initialization post clocks
248// ----------------------------------------
249#ifndef PICO_RUNTIME_INIT_POST_CLOCK_RESETS
250#define PICO_RUNTIME_INIT_POST_CLOCK_RESETS "00600"
251#endif
252
253// PICO_RUNTIME_INIT_POST_CLOCKS_RESETS defaults to 0
254#ifndef __ASSEMBLER__
255void runtime_init_post_clock_resets(void);
256#endif
257
258// ----------------------------------------
259// RP2040 IE disable for GPIO 26-29
260// ----------------------------------------
261
262// PICO_CONFIG: PICO_RUNTIME_SKIP_INIT_RP2040_GPIO_IE_DISABLE, Skip calling of `runtime_init_rp2040_gpio_ie_disable` function during runtime init, type=bool, default=0 on RP2040, group=pico_runtime_init
263// PICO_CONFIG: PICO_RUNTIME_NO_INIT_RP2040_GPIO_IE_DISABLE, Do not include SDK implementation of `runtime_init_rp2040_gpio_ie_disable` function, type=bool, default=0 on RP2040, group=pico_runtime_init
264
265#ifndef PICO_RUNTIME_INIT_RP2040_GPIO_IE_DISABLE
266#define PICO_RUNTIME_INIT_RP2040_GPIO_IE_DISABLE "00700"
267#endif
268
269#ifndef PICO_RUNTIME_SKIP_INIT_RP2040_GPIO_IE_DISABLE
270#if !PICO_RP2040 || PICO_IE_26_29_UNCHANGED_ON_RESET
271#define PICO_RUNTIME_SKIP_INIT_RP2040_GPIO_IE_DISABLE 1
272#endif
273#endif
274#ifndef PICO_RUNTIME_NO_INIT_RP2040_GPIO_IE_DISABLE
275#if !PICO_RP2040
276#define PICO_RUNTIME_NO_INIT_RP2040_GPIO_IE_DISABLE 1
277#endif
278#endif
279
280#ifndef __ASSEMBLER__
281void runtime_init_rp2040_gpio_ie_disable(void);
282#endif
283
284// -----------------------------
285// Reset all spin SIO spin locks
286// -----------------------------
287
288// PICO_CONFIG: PICO_RUNTIME_SKIP_INIT_SPIN_LOCKS_RESET, Skip calling of `runtime_init_spin_locks_reset` function during runtime init, type=bool, default=0, group=pico_runtime_init
289// PICO_CONFIG: PICO_RUNTIME_NO_INIT_SPIN_LOCKS_RESET, Do not include SDK implementation of `runtime_init_spin_locks_reset` function, type=bool, default=0, group=pico_runtime_init
290
291#ifndef PICO_RUNTIME_INIT_SPIN_LOCKS_RESET
292// clearing of all spin locks
293#define PICO_RUNTIME_INIT_SPIN_LOCKS_RESET "01000"
294#endif
295
296#ifndef PICO_RUNTIME_SKIP_INIT_SPIN_LOCKS_RESET
297#define PICO_RUNTIME_SKIP_INIT_SPIN_LOCKS_RESET 0
298#endif
299
300#ifndef PICO_RUNTIME_NO_INIT_SPIN_LOCKS_RESET
301#define PICO_RUNTIME_NO_INIT_SPIN_LOCKS_RESET 0
302#endif
303
304#ifndef __ASSEMBLER__
305void runtime_init_spin_locks_reset(void);
306#endif
307
308// -----------------------------
309// Reset all bootram boot locks
310// -----------------------------
311
312// PICO_CONFIG: PICO_RUNTIME_SKIP_INIT_BOOT_LOCKS_RESET, Skip calling of `runtime_init_boot_locks_reset` function during runtime init, type=bool, default=0, group=pico_runtime_init
313
314#ifndef PICO_RUNTIME_INIT_BOOT_LOCKS_RESET
315// clearing of all spin locks
316#define PICO_RUNTIME_INIT_BOOT_LOCKS_RESET "01000"
317#endif
318
319#ifndef PICO_RUNTIME_SKIP_INIT_BOOT_LOCKS_RESET
320#define PICO_RUNTIME_SKIP_INIT_BOOT_LOCKS_RESET 0
321#endif
322#ifndef __ASSEMBLER__
323void runtime_init_boot_locks_reset(void);
324#endif
325
326// ------------------------------
327// Enable bootrom locking support
328// ------------------------------
329// PICO_CONFIG: PICO_RUNTIME_SKIP_INIT_BOOTROM_LOCKING_ENABLE, Skip calling of `runtime_init_bootrom_locking_enable` function during runtime init, type=bool, default=0, group=pico_runtime_init
330#ifndef PICO_RUNTIME_INIT_BOOTROM_LOCKING_ENABLE
331// clearing of all spin locks
332#define PICO_RUNTIME_INIT_BOOTROM_LOCKING_ENABLE "01010"
333#endif
334
335#ifndef PICO_RUNTIME_SKIP_INIT_BOOTROM_LOCKING_ENABLE
336#define PICO_RUNTIME_SKIP_INIT_BOOTROM_LOCKING_ENABLE 0
337#endif
338
339#ifndef __ASSEMBLER__
340void runtime_init_bootrom_locking_enable(void);
341#endif
342
343// PICO_RUNTIME_INIT_MUTEX is registered automatically by pico_sync
344// PICO_CONFIG: PICO_RUNTIME_SKIP_INIT_MUTEX, Skip calling of `runtime_init_mutex` function during runtime init, type=bool, default=0, group=pico_runtime_init
345// PICO_CONFIG: PICO_RUNTIME_NO_INIT_MUTEX, Do not include SDK implementation of `runtime_init_mutex` function, type=bool, default=0, group=pico_runtime_init
346
347#ifndef PICO_RUNTIME_INIT_MUTEX
348// depends on SPIN_LOCKS
349// initialize auto_init mutexes
350#define PICO_RUNTIME_INIT_MUTEX "01100"
351#endif
352
353#ifndef PICO_RUNTIME_SKIP_INIT_MUTEX
354#define PICO_RUNTIME_SKIP_INIT_MUTEX 0
355#endif
356
357#ifndef PICO_RUNTIME_NO_INIT_MUTEX
358#define PICO_RUNTIME_NO_INIT_MUTEX 0
359#endif
360
361// ------------------------------------------------------------
362// Initialization of IRQs, added by hardware_irq
363// ------------------------------------------------------------
364
365#ifndef PICO_RUNTIME_INIT_PER_CORE_IRQ_PRIORITIES
366#define PICO_RUNTIME_INIT_PER_CORE_IRQ_PRIORITIES "01200"
367#endif
368
369// PICO_RUNTIME_SKIP_INIT_PER_CORE_TLS_SETUP defaults to 0
370#ifndef PICO_RUNTIME_INIT_PER_CORE_TLS_SETUP
371#define PICO_RUNTIME_INIT_PER_CORE_TLS_SETUP "10060"
372#endif
373
374// PICO_CONFIG: PICO_RUNTIME_SKIP_INIT_INSTALL_RAM_VECTOR_TABLE, Skip calling of `runtime_init_install_ram_vector_table` function during runtime init, type=bool, default=0 unless RISC-V or RAM binary, group=pico_runtime_init
375// PICO_CONFIG: PICO_RUNTIME_NO_INIT_INSTALL_RAM_VECTOR_TABLE, Do not include SDK implementation of `runtime_init_install_ram_vector_table` function, type=bool, default=0 unless RISC-V or RAM binary, group=pico_runtime_init
376#ifndef PICO_RUNTIME_INIT_INSTALL_RAM_VECTOR_TABLE
377#define PICO_RUNTIME_INIT_INSTALL_RAM_VECTOR_TABLE "10080"
378#endif
379
380// ------------------------------------------------------
381// Copy of ROM vector table to RAM; not used on RISC-V or
382// no_flash which has a RAM vector table anyway
383// ------------------------------------------------------
384
385#ifndef PICO_RUNTIME_SKIP_INIT_INSTALL_RAM_VECTOR_TABLE
386#if PICO_NO_RAM_VECTOR_TABLE || PICO_NO_FLASH || defined(__riscv)
387#define PICO_RUNTIME_SKIP_INIT_INSTALL_RAM_VECTOR_TABLE 1
388#endif
389#endif
390
391#ifndef PICO_RUNTIME_NO_INIT_INSTALL_RAM_VECTOR_TABLE
392#if PICO_NO_RAM_VECTOR_TABLE || PICO_NO_FLASH || defined(__riscv)
393#define PICO_RUNTIME_NO_INIT_INSTALL_RAM_VECTOR_TABLE 1
394#endif
395#endif
396
397// ------------------------------------------------------------
398// Default alarm pool initialization, added by pico_time unless
399// PICO_TIME_DEFAULT_ALARM_POOL_DISABLED == 1
400// ------------------------------------------------------------
401#ifndef PICO_RUNTIME_INIT_DEFAULT_ALARM_POOL
402#define PICO_RUNTIME_INIT_DEFAULT_ALARM_POOL "11000"
403#endif
404
405// PICO_CONFIG: PICO_RUNTIME_SKIP_INIT_DEFAULT_ALARM_POOL, Skip calling of `runtime_init_default_alarm_pool` function during runtime init, type=bool, default=1 if `PICO_TIME_DEFAULT_ALARM_POOL_DISABLED` is 1, group=pico_runtime_init
406// PICO_CONFIG: PICO_RUNTIME_NO_INIT_DEFAULT_ALARM_POOL, Do not include SDK implementation of `runtime_init_default_alarm_pool` function, type=bool, default=1 if `PICO_TIME_DEFAULT_ALARM_POOL_DISABLED` is , group=pico_runtime_init
407#ifndef PICO_RUNTIME_SKIP_INIT_DEFAULT_ALARM_POOL
408#if PICO_TIME_DEFAULT_ALARM_POOL_DISABLED
409#define PICO_RUNTIME_SKIP_INIT_DEFAULT_ALARM_POOL 1
410#endif
411#endif
412
413#ifndef PICO_RUNTIME_NO_INIT_DEFAULT_ALARM_POOL
414#if PICO_TIME_DEFAULT_ALARM_POOL_DISABLED
415#define PICO_RUNTIME_NO_INIT_DEFAULT_ALARM_POOL 1
416#endif
417#endif
418
419// ------------------------------------------------------------------------------------------------
420// stack guard; these are a special case as they take a parameter; however the normal defines apply
421// ------------------------------------------------------------------------------------------------
422
423// PICO_CONFIG: PICO_RUNTIME_SKIP_INIT_PER_CORE_INSTALL_STACK_GUARD, Skip calling of `runtime_init_per_core_install_stack_guard` function during runtime init, type=bool, default=1 unless `PICO_USE_STACK_GUARDS` is 1, group=pico_runtime_init
424// PICO_CONFIG: PICO_RUNTIME_NO_INIT_PER_CORE_INSTALL_STACK_GUARD, Do not include SDK implementation of `runtime_init_per_core_install_stack_guard` function, type=bool, default=1 unless `PICO_USE_STACK_GUARDS` is 1, group=pico_runtime_init
425
426#ifndef PICO_RUNTIME_INIT_PER_CORE_INSTALL_STACK_GUARD
427#define PICO_RUNTIME_INIT_PER_CORE_INSTALL_STACK_GUARD "10050"
428#endif
429
430#ifndef PICO_RUNTIME_SKIP_INIT_PER_CORE_INSTALL_STACK_GUARD
431#if !PICO_USE_STACK_GUARDS
432#define PICO_RUNTIME_SKIP_INIT_PER_CORE_INSTALL_STACK_GUARD 1
433#endif
434#endif
435
436#ifndef PICO_RUNTIME_NO_INIT_PER_CORE_INSTALL_STACK_GUARD
437#if !PICO_USE_STACK_GUARDS
438#define PICO_RUNTIME_NO_INIT_PER_CORE_INSTALL_STACK_GUARD 1
439#endif
440#endif
441
442#ifndef __ASSEMBLER__
443void runtime_init_per_core_install_stack_guard(void *stack_bottom);
444// backwards compatibility
445static __force_inline void runtime_install_stack_guard(void *stack_bottom) {
446 runtime_init_per_core_install_stack_guard(stack_bottom);
447}
448
449#endif
450
451#ifdef __cplusplus
452}
453#endif
454
455#endif
__force_inline
#define __force_inline
Attribute to force inlining of a function regardless of optimization level.
Definition: compiler.h:125
clocks_init
static void clocks_init(void)
Initialise the clock hardware.
Definition: runtime_init.h:240
pico.h
runtime.h
runtime_init_clocks
void runtime_init_clocks(void)
Definition: runtime_init_clocks.c:38