1 /***************************************************************************
2  * Copyright (c) 2024 Microsoft Corporation
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the MIT License which is available at
6  * https://opensource.org/licenses/MIT.
7  *
8  * SPDX-License-Identifier: MIT
9  **************************************************************************/
10 
11 
12 /**************************************************************************/
13 /**************************************************************************/
14 /**                                                                       */
15 /** ThreadX Component                                                     */
16 /**                                                                       */
17 /**   Queue                                                               */
18 /**                                                                       */
19 /**************************************************************************/
20 /**************************************************************************/
21 
22 #define TX_SOURCE_CODE
23 
24 
25 /* Include necessary system files.  */
26 
27 #include "tx_api.h"
28 #include "tx_trace.h"
29 #include "tx_queue.h"
30 
31 
32 /**************************************************************************/
33 /*                                                                        */
34 /*  FUNCTION                                               RELEASE        */
35 /*                                                                        */
36 /*    _tx_queue_send_notify                               PORTABLE C      */
37 /*                                                           6.1          */
38 /*  AUTHOR                                                                */
39 /*                                                                        */
40 /*    William E. Lamie, Microsoft Corporation                             */
41 /*                                                                        */
42 /*  DESCRIPTION                                                           */
43 /*                                                                        */
44 /*    This function registers an application callback function that is    */
45 /*    called whenever a messages is sent to this queue.                   */
46 /*                                                                        */
47 /*  INPUT                                                                 */
48 /*                                                                        */
49 /*    queue_ptr                             Pointer to queue control block*/
50 /*    queue_send_notify                     Application callback function */
51 /*                                            (TX_NULL disables notify)   */
52 /*                                                                        */
53 /*  OUTPUT                                                                */
54 /*                                                                        */
55 /*    status                                Completion status             */
56 /*                                                                        */
57 /*  CALLS                                                                 */
58 /*                                                                        */
59 /*    None                                                                */
60 /*                                                                        */
61 /*  CALLED BY                                                             */
62 /*                                                                        */
63 /*    Application Code                                                    */
64 /*                                                                        */
65 /*  RELEASE HISTORY                                                       */
66 /*                                                                        */
67 /*    DATE              NAME                      DESCRIPTION             */
68 /*                                                                        */
69 /*  05-19-2020     William E. Lamie         Initial Version 6.0           */
70 /*  09-30-2020     Yuxin Zhou               Modified comment(s),          */
71 /*                                            resulting in version 6.1    */
72 /*                                                                        */
73 /**************************************************************************/
_tx_queue_send_notify(TX_QUEUE * queue_ptr,VOID (* queue_send_notify)(TX_QUEUE * notify_queue_ptr))74 UINT  _tx_queue_send_notify(TX_QUEUE *queue_ptr, VOID (*queue_send_notify)(TX_QUEUE *notify_queue_ptr))
75 {
76 
77 #ifdef TX_DISABLE_NOTIFY_CALLBACKS
78 
79     TX_QUEUE_NOT_USED(queue_ptr);
80     TX_QUEUE_SEND_NOTIFY_NOT_USED(queue_send_notify);
81 
82     /* Feature is not enabled, return error.  */
83     return(TX_FEATURE_NOT_ENABLED);
84 #else
85 
86 TX_INTERRUPT_SAVE_AREA
87 
88 
89     /* Disable interrupts.  */
90     TX_DISABLE
91 
92     /* Make entry in event log.  */
93     TX_TRACE_IN_LINE_INSERT(TX_TRACE_QUEUE_SEND_NOTIFY, queue_ptr, 0, 0, 0, TX_TRACE_QUEUE_EVENTS)
94 
95     /* Make entry in event log.  */
96     TX_EL_QUEUE_SEND_NOTIFY_INSERT
97 
98     /* Setup queue send notification callback function.  */
99     queue_ptr -> tx_queue_send_notify =  queue_send_notify;
100 
101     /* Restore interrupts.  */
102     TX_RESTORE
103 
104     /* Return success to caller.  */
105     return(TX_SUCCESS);
106 #endif
107 }
108 
109