1 /* 2 * Copyright (c) 2014-2016, Freescale Semiconductor, Inc. 3 * Copyright 2016-2019 NXP 4 * All rights reserved. 5 * 6 * 7 * SPDX-License-Identifier: BSD-3-Clause 8 */ 9 10 #ifndef MCMGR_INTERNAL_CORE_API_H 11 #define MCMGR_INTERNAL_CORE_API_H 12 13 /*! 14 * @addtogroup mcmgr_internal 15 * @{ 16 */ 17 18 /*! @brief Type definition of structure with event handler and data. */ 19 typedef struct _mcmgr_event 20 { 21 /*! @brief Pointer to callback function. */ 22 mcmgr_event_callback_t callback; 23 /*! @brief Context data for callback. */ 24 void *callbackData; 25 } mcmgr_event_t; 26 27 /*! @brief Type definition of structure which contains informations and functions for one core. */ 28 typedef struct _mcmgr_core_info 29 { 30 mcmgr_core_type_t coreType; 31 char *coreName; 32 } mcmgr_core_info_t; 33 34 /*! @brief Type definition of possible core states. */ 35 typedef enum _mcmgr_core_state 36 { 37 kMCMGR_ResetCoreState = 0, 38 kMCMGR_StartupGettingLowCoreState, 39 kMCMGR_StartupGettingHighCoreState, 40 kMCMGR_RunningCoreState, 41 } mcmgr_core_state_t; 42 43 /*! @brief Type definition of structure which contains status information for a core. */ 44 typedef struct _mcmgr_core_context 45 { 46 /*! @brief Current state of the core. */ 47 mcmgr_core_state_t state; 48 /*! @brief Startup data, if state >= kMCMGR_RunningCoreState */ 49 uint32_t startupData; 50 } mcmgr_core_context_t; 51 52 /*! @brief Type definition of structure with system informations */ 53 typedef struct _mcmgr_system_info 54 { 55 /*! @brief Count of cores in the system. */ 56 uint32_t coreCount; 57 /*! @brief Count of memory regions in the system. */ 58 uint32_t memRegCount; 59 /*! @brief Array of core informations. */ 60 const mcmgr_core_info_t *cores; 61 } mcmgr_system_info_t; 62 63 /*! 64 * @brief Structure of mcmgr_system_info_t 65 * 66 * This structure contains all informations about device and all cores. 67 * Should be defined and initialized in device specific file. 68 */ 69 extern const mcmgr_system_info_t g_mcmgrSystem; 70 71 /*! 72 * @brief Array of mcmgr_event_t 73 * 74 * This array contains registred callbacks for event handling. 75 */ 76 extern mcmgr_event_t MCMGR_eventTable[]; 77 78 /*! 79 * @brief Array of mcmgr_core_context_t 80 * 81 * This array contains runtime context for each core in the system. 82 */ 83 extern volatile mcmgr_core_context_t s_mcmgrCoresContext[]; 84 85 /*! 86 * @brief Internal platform-specific early MCMGR initialize function, 87 * usually called during the startup. 88 * 89 * @param[in] coreNum Current core number. 90 * 91 * @return kStatus_MCMGR_Success on success or kStatus_MCMGR_Error on failure. 92 */ 93 mcmgr_status_t mcmgr_early_init_internal(mcmgr_core_t coreNum); 94 95 /*! 96 * @brief Internal platform-specific late MCMGR initialize function. 97 * 98 * @param[in] coreNum Current core number. 99 * 100 * @return kStatus_MCMGR_Success on success or kStatus_MCMGR_Error on failure. 101 */ 102 mcmgr_status_t mcmgr_late_init_internal(mcmgr_core_t coreNum); 103 104 /*! 105 * @brief Internal platform-specific start core function. 106 * 107 * @param[in] coreNum Enum of the core to be started. 108 * @param[in] bootAddress Boot address of the core to be started application. 109 * 110 * @return kStatus_MCMGR_Success on success or kStatus_MCMGR_Error on failure. 111 */ 112 mcmgr_status_t mcmgr_start_core_internal(mcmgr_core_t coreNum, void *bootAddress); 113 114 /*! 115 * @brief Internal platform-specific function to get startup data 116 * 117 * This function read startup data provided by the master core. 118 * Use only on the slave core during the startup. 119 * 120 * @param[in] coreNum Current core number. 121 * @param[out] startupData Data to read by this function. 122 * 123 * @return kStatus_MCMGR_Success on success or kStatus_MCMGR_Error on failure. 124 */ 125 mcmgr_status_t mcmgr_get_startup_data_internal(mcmgr_core_t coreNum, uint32_t *startupData); 126 127 /*! 128 * @brief Internal platform-specific stop core function. 129 * 130 * This function causes a selected core to halt code execution. 131 * 132 * @param[in] coreNum Enum of core to be stopped. 133 * 134 * @return kStatus_MCMGR_Success on success or kStatus_MCMGR_Error on failure. 135 */ 136 mcmgr_status_t mcmgr_stop_core_internal(mcmgr_core_t coreNum); 137 138 /*! 139 * @brief Internal platform-specific get property of the CPU core function. 140 * 141 * This function provides the property of the CPU core. 142 * 143 * @param[in] coreNum Enum of core. 144 * @param[in] property Requested property type. 145 * @param[in,out] value Parameter for value of property. 146 * @param[in,out] length Parameter for size of property value in bytes. 147 * 148 * @return kStatus_MCMGR_Success on success or kStatus_MCMGR_Error on failure. 149 */ 150 mcmgr_status_t mcmgr_get_core_property_internal(mcmgr_core_t coreNum, 151 mcmgr_core_property_t property, 152 void *value, 153 uint32_t *length); 154 155 /*! 156 * @brief Internal platform-specific function for remote core notification. 157 * 158 * This function notifies other core about occured event. 159 * 160 * @param[in] remoteData 32-bit data with event code and event data encoded. 161 * @param[in] forcedWrite Set to TRUE when the check for previous sent data consuption is required, 162 * set to FALSE othervise. 163 * 164 * @return kStatus_MCMGR_Success on success or kStatus_MCMGR_Error on failure. 165 */ 166 mcmgr_status_t mcmgr_trigger_event_internal(uint32_t remoteData, bool forcedWrite); 167 168 /*! 169 * @brief Internal platform-specific function to get current CPU core. 170 * 171 * This function returns enum of current core. 172 * 173 * @return Enum of current core. 174 */ 175 mcmgr_core_t mcmgr_get_current_core_internal(void); 176 177 /*! @} */ 178 179 #endif 180