1 /* 2 * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 #ifndef _PICO_RUNTIME_H 8 #define _PICO_RUNTIME_H 9 10 #include "pico.h" 11 12 /** \file runtime.h 13 * \defgroup pico_runtime pico_runtime 14 * \brief Basic runtime support for running pre-main initializers provided by other libraries 15 * 16 * This library aggregates the following other libraries (if available): 17 * 18 * * \ref hardware_uart 19 * * \ref pico_bit_ops 20 * * \ref pico_divider 21 * * \ref pico_double 22 * * \ref pico_int64_ops 23 * * \ref pico_float 24 * * \ref pico_malloc 25 * * \ref pico_mem_ops 26 * * \ref pico_atomic 27 * * \ref pico_cxx_options 28 * * \ref pico_standard_binary_info 29 * * \ref pico_standard_link 30 * * \ref pico_sync 31 * * \ref pico_printf 32 * * \ref pico_crt0 33 * * \ref pico_clib_interface 34 * * \ref pico_stdio 35 */ 36 37 #ifdef __cplusplus 38 extern "C" { 39 #endif 40 41 #ifndef __ASSEMBLER__ 42 /*! \brief Run all the initializations that are usually called by crt0.S before entering main 43 * \ingroup pico_runtime 44 * 45 * This method is useful to set up the runtime after performing a watchdog or powman reboot 46 * via scratch vector. 47 */ 48 void runtime_init(void); 49 50 void runtime_run_initializers(void); 51 void runtime_run_per_core_initializers(void); 52 53 #ifndef PICO_RUNTIME_INIT_FUNC 54 #define PICO_RUNTIME_INIT_FUNC(func, priority_string) uintptr_t __used __attribute__((section(".preinit_array." priority_string))) __pre_init_ ## func = (uintptr_t)(void (*)(void)) (func) 55 #endif 56 #else 57 #ifndef PICO_RUNTIME_INIT_FUNC 58 #define PICO_RUNTIME_INIT_FUNC(func, priority_string) __pre_init func, priority_string 59 #endif 60 #endif 61 #define PICO_RUNTIME_INIT_FUNC_HW(func, priority_string) PICO_RUNTIME_INIT_FUNC(func, priority_string) 62 #define PICO_RUNTIME_INIT_FUNC_RUNTIME(func, priority_string) PICO_RUNTIME_INIT_FUNC(func, priority_string) 63 // priority strings are of the form 00000->99999; we want the per core stuff all at the end, so prefix with ZZZZZ which is clearly after 99999 64 #define PICO_RUNTIME_INIT_FUNC_PER_CORE(func, priority_string) PICO_RUNTIME_INIT_FUNC(func, "ZZZZZ." priority_string) 65 66 #ifdef __cplusplus 67 } 68 #endif 69 70 #endif