@@ -173,6 +173,75 @@ typedef enum
173173 OS_STREAM_STATE_WRITABLE = 0x08 , /**< @brief whether the stream is writable */
174174} OS_StreamState_t ;
175175
176+ /**
177+ * @brief A set of events that can be used with event callback routines
178+ */
179+ typedef enum
180+ {
181+ OS_EVENT_RESERVED = 0 , /**< no-op/reserved event id value */
182+
183+ /**
184+ * resource/id has been newly allocated but not yet created.
185+ *
186+ * This event is invoked from WITHIN the locked region, in
187+ * the context of the task which is allocating the resource.
188+ *
189+ * If the handler returns non-success, the error will be returned
190+ * to the caller and the creation process is aborted.
191+ */
192+ OS_EVENT_RESOURCE_ALLOCATED ,
193+
194+ /**
195+ * resource/id has been fully created/finalized.
196+ *
197+ * Invoked outside locked region, in the context
198+ * of the task which created the resource.
199+ *
200+ * Data object is not used, passed as NULL.
201+ *
202+ * Return value is ignored - this is for information purposes only.
203+ */
204+ OS_EVENT_RESOURCE_CREATED ,
205+
206+ /**
207+ * resource/id has been deleted.
208+ *
209+ * Invoked outside locked region, in the context
210+ * of the task which deleted the resource.
211+ *
212+ * Data object is not used, passed as NULL.
213+ *
214+ * Return value is ignored - this is for information purposes only.
215+ */
216+ OS_EVENT_RESOURCE_DELETED ,
217+
218+ /**
219+ * New task is starting.
220+ *
221+ * Invoked outside locked region, in the context
222+ * of the task which is currently starting, before
223+ * the entry point is called.
224+ *
225+ * Data object is not used, passed as NULL.
226+ *
227+ * If the handler returns non-success, task startup is aborted
228+ * and the entry point is not called.
229+ */
230+ OS_EVENT_TASK_STARTUP ,
231+
232+ OS_EVENT_MAX /**< placeholder for end of enum, not used */
233+ } OS_Event_t ;
234+
235+ /**
236+ * @brief A callback routine for event handling.
237+ *
238+ * @param[in] event The event that occurred
239+ * @param[in] object_id The associated object_id, or 0 if not associated with an object
240+ * @param[inout] data An abstract data/context object associated with the event, or NULL.
241+ * @return status Execution status, see @ref OSReturnCodes.
242+ */
243+ typedef int32 (* OS_EventHandler_t )(OS_Event_t event , uint32 object_id , void * data );
244+
176245/**
177246 * @brief For the @ref OS_GetErrorName() function, to ensure
178247 * everyone is making an array of the same length.
@@ -360,7 +429,6 @@ int32 OS_ConvertToArrayIndex (uint32 object_id, uint32 *ArrayIndex);
360429 * @param[in] callback_arg Opaque Argument to pass to callback function
361430 */
362431void OS_ForEachObject (uint32 creator_id , OS_ArgCallback_t callback_ptr , void * callback_arg );
363- /**@}*/
364432
365433/*-------------------------------------------------------------------------------------*/
366434/**
@@ -377,6 +445,26 @@ void OS_ForEachObject (uint32 creator_id, OS_ArgCallback_t callback_pt
377445 */
378446void OS_ForEachObjectOfType (uint32 objtype , uint32 creator_id , OS_ArgCallback_t callback_ptr , void * callback_arg );
379447
448+ /*-------------------------------------------------------------------------------------*/
449+ /**
450+ * @brief Callback routine registration
451+ *
452+ * This hook enables the application code to perform extra platform-specific
453+ * operations on various system events such as resource creation/deletion.
454+ *
455+ * @note Some events are invoked while the resource is "locked" and therefore
456+ * application-defined handlers for these events should not block or attempt
457+ * to access other OSAL resources.
458+ *
459+ * @param[in] handler The application-provided event handler
460+ * @return Execution status, see @ref OSReturnCodes.
461+ * @retval #OS_SUCCESS @copybrief OS_SUCCESS
462+ * @retval #OS_ERROR @copybrief OS_ERROR
463+ */
464+ int32 OS_RegisterEventHandler (OS_EventHandler_t handler );
465+
466+ /**@}*/
467+
380468
381469/** @defgroup OSAPITask OSAL Task APIs
382470 * @{
0 commit comments