1 /*------------------------------------------------------------------------------------------------*/
2 /* UNICENS V2.1.0-3491 */
3 /* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG. */
5 /* This program is free software: you can redistribute it and/or modify */
6 /* it under the terms of the GNU General Public License as published by */
7 /* the Free Software Foundation, either version 2 of the License, or */
8 /* (at your option) any later version. */
10 /* This program is distributed in the hope that it will be useful, */
11 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
12 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
13 /* GNU General Public License for more details. */
15 /* You should have received a copy of the GNU General Public License */
16 /* along with this program. If not, see <http://www.gnu.org/licenses/>. */
18 /* You may also obtain this software under a propriety license from Microchip. */
19 /* Please contact Microchip for further information. */
20 /*------------------------------------------------------------------------------------------------*/
24 * \brief Include file of the Extended Resource Manager.
26 * \defgroup G_UCS_XRM_STREAM Additional Streaming Port Functions
27 * \brief Additional Streaming Port functions of the Extended Resource Manager.
35 /*------------------------------------------------------------------------------------------------*/
37 /*------------------------------------------------------------------------------------------------*/
41 #include "ucs_ret_pb.h"
43 #include "ucs_xrmpool.h"
44 #include "ucs_class_pb.h"
52 * \cond UCS_INTERNAL_DOC
53 * \addtogroup G_UCS_XRM_INT
57 /*! \def XRM_NUM_RES_HDL_PER_ICM
58 * \brief Maximum number of resource handles per ICM. Depends on the maximum payload of ICMs.
60 #define XRM_NUM_RES_HDL_PER_ICM 22U
62 /*------------------------------------------------------------------------------------------------*/
64 /*------------------------------------------------------------------------------------------------*/
65 /*! \brief Stores data required by XRM during initialization. */
66 typedef struct Xrm_InitData_
68 CBase *base_ptr; /*!< \brief Reference to base instance */
69 CInic *inic_ptr; /*!< \brief Reference to INIC instance */
70 CNetworkManagement *net_ptr; /*!< \brief Reference to Network instance */
71 CRemoteSyncManagement *rsm_ptr; /*!< \brief Reference to a RSM instance */
72 CXrmPool *xrmp_ptr; /*!< \brief Reference to a xrm pool instance */
73 Ucs_Xrm_ResourceDebugCb_t res_debugging_fptr; /*!< \brief Callback function pointer to monitor XRM resources from application */
74 Ucs_Xrm_CheckUnmuteCb_t check_unmute_fptr; /*!< \brief Callback function pointer to signal unmute of devices */
78 /*! \brief Structure that defines a XRM StreamPort configuration */
79 typedef struct Xrm_StreamPort_Config_
81 uint8_t index; /*!< \brief Streaming Port instance */
82 Ucs_Stream_PortOpMode_t op_mode; /*!< \brief Streaming Port Operation mode */
83 Ucs_Stream_PortOption_t port_option; /*!< \brief Streaming Port Options */
84 Ucs_Stream_PortClockMode_t clock_mode; /*!< \brief Stream Port Clock Mode */
85 Ucs_Stream_PortClockDataDelay_t clock_data_delay; /*!< \brief Stream Port Clock Data Delay */
86 Ucs_Xrm_Stream_PortCfgResCb_t result_fptr; /*!< \brief Result callback */
88 } Xrm_StreamPort_Config_t;
90 /*! \brief Result observers used by FBlock INIC Resource Management functions */
91 typedef struct Xrm_Observers_
93 /*! \brief Observer used to monitor internal errors (e.g., INIC BIST Error) */
94 CMaskedObserver internal_error_obs;
95 /*! \brief Observer used to monitor network status infos */
96 CMaskedObserver nw_status_obs;
97 /*! \brief Observer used to monitor ICM tx message object availability */
98 CObserver tx_msg_obj_obs;
99 /*! \brief Observer used for the INIC resource monitor */
100 CObserver resource_monitor_obs;
101 /*! \brief Result observer used for destruction of INIC resources */
102 CSingleObserver resource_destroy_obs;
103 /*! \brief Result observer used for requests of invalid resource handles */
104 CSingleObserver resource_invalid_list_obs;
105 /*! \brief Result observer used for sockets, ports and connections */
106 CSingleObserver std_result_obs;
107 /*! \brief Application callback to signal unmute of devices */
108 Ucs_Xrm_CheckUnmuteCb_t check_unmute_fptr;
109 /*! \brief Callback function pointer used for streaming port configurations */
110 Ucs_Xrm_Stream_PortCfgResCb_t stream_port_config_fptr;
111 /*! \brief Observer to proxy callback stream_port_config_fptr() */
112 CSingleObserver stream_port_config_obs;
113 /*! \brief Callback function pointer used by operation that enables a MOST Port */
114 Ucs_StdResultCb_t most_port_enable_fptr;
115 /*! \brief Observer to proxy callback most_port_enable_port_fptr() */
116 CSingleObserver most_port_enable_obs;
117 /*! \brief Callback function pointer by operation that enables full streaming for a MOST Port*/
118 Ucs_StdResultCb_t most_port_en_full_str_fptr;
119 /*! \brief Observer to proxy callback most_port_en_full_str_fptr() */
120 CSingleObserver most_port_en_full_str_obs;
121 /*! \brief Observer to the SyncLost event in RSM */
122 CObserver rsm_sync_lost_obs;
126 /*! \brief Structure of the Extended Resource Manager class. */
127 typedef struct CExtendedResourceManager_
129 /*!< \brief Jobs list queue */
131 /*! \brief List to temporarily store invalid resource handles */
132 uint16_t inv_resource_handle_list[XRM_NUM_RES_HDL_PER_ICM];
133 /*! \brief Reference to an INIC instance */
135 /*! \brief Reference to a network instance */
136 CNetworkManagement *net_ptr;
137 /*! \brief Reference to a rsm instance */
138 CRemoteSyncManagement *rsm_ptr;
139 /*!< \brief Reference to base instance */
141 /*!< \brief Reference to the xrm pool instance */
143 /*! \brief Reference to the currently processed job */
144 Xrm_Job_t *current_job_ptr;
145 /*! \brief Reference to the currently processed resource object */
146 UCS_XRM_CONST Ucs_Xrm_ResObject_t **current_obj_pptr;
147 /*! \brief Number of invalid handles in list inv_resource_handle_list[] */
148 uint8_t inv_resource_handle_list_size;
149 /*! \brief Current number of destroyed handles in list inv_resource_handle_list[] */
150 uint8_t curr_dest_resource_handle_size;
151 /*! \brief Start index for the current invalid handles index in list inv_resource_handle_list[] */
152 uint8_t inv_resource_handle_index;
153 /*! \brief Service instance to add the Extended Resource Manager to the MNS scheduler */
155 /*! \brief Report result of the Extended Resource Manager. Used to reported status and error
156 * information to the application.
158 Ucs_Xrm_Result_t report_result;
159 /*! \brief Required result observers */
161 /*! \brief Mask that stores queued event */
162 Srv_Event_t queued_event_mask;
163 /*! \brief stores the currently stream port configuration (in process) */
164 Xrm_StreamPort_Config_t current_streamport_config;
165 /*!< \brief Callback function pointer to monitor XRM resources */
166 Ucs_Xrm_ResourceDebugCb_t res_debugging_fptr;
167 /*! \brief Flag to lock the API */
169 /*!< \brief Signal whether this instance is in Remote Control Mode */
170 bool IsInRemoteControlMode;
172 } CExtendedResourceManager;
174 /*------------------------------------------------------------------------------------------------*/
175 /* Prototypes of class CExtendedResourceManager */
176 /*------------------------------------------------------------------------------------------------*/
177 extern void Xrm_Ctor(CExtendedResourceManager *self, Xrm_InitData_t * data_ptr);
178 extern Ucs_Return_t Xrm_Process(CExtendedResourceManager *self,
179 UCS_XRM_CONST Ucs_Xrm_ResObject_t *resource_object_list[],
180 uint16_t most_network_connection_label,
182 Ucs_Xrm_ReportCb_t report_fptr);
183 extern Ucs_Return_t Xrm_Destroy(CExtendedResourceManager *self,
184 UCS_XRM_CONST Ucs_Xrm_ResObject_t *resource_object_list[]);
185 extern Ucs_Return_t Xrm_Stream_SetPortConfig(CExtendedResourceManager *self,
187 Ucs_Stream_PortOpMode_t op_mode,
188 Ucs_Stream_PortOption_t port_option,
189 Ucs_Stream_PortClockMode_t clock_mode,
190 Ucs_Stream_PortClockDataDelay_t clock_data_delay,
191 Ucs_Xrm_Stream_PortCfgResCb_t result_fptr);
192 extern Ucs_Return_t Xrm_Stream_GetPortConfig(CExtendedResourceManager *self,
194 Ucs_Xrm_Stream_PortCfgResCb_t result_fptr);
195 extern Ucs_Return_t Xrm_Most_EnablePort(CExtendedResourceManager *self,
196 uint16_t most_port_handle,
198 Ucs_StdResultCb_t result_fptr);
199 extern Ucs_Return_t Xrm_Most_PortEnFullStr(CExtendedResourceManager *self,
200 uint16_t most_port_handle,
202 Ucs_StdResultCb_t result_fptr);
203 extern void Xrm_SetResourceDebugCbFn(CExtendedResourceManager *self, Ucs_Xrm_ResourceDebugCb_t dbg_cb_fn);
209 #endif /* #ifndef UCS_XRM_H */
216 /*------------------------------------------------------------------------------------------------*/
218 /*------------------------------------------------------------------------------------------------*/