1 /**************************************************************************/
2 /*                                                                        */
3 /*       Copyright (c) Microsoft Corporation. All rights reserved.        */
4 /*                                                                        */
5 /*       This software is licensed under the Microsoft Software License   */
6 /*       Terms for Microsoft Azure RTOS. Full text of the license can be  */
7 /*       found in the LICENSE file at https://aka.ms/AzureRTOS_EULA       */
8 /*       and in the root directory of this software.                      */
9 /*                                                                        */
10 /**************************************************************************/
11 
12 
13 /**************************************************************************/
14 /**************************************************************************/
15 /**                                                                       */
16 /** ThreadX Component                                                     */
17 /**                                                                       */
18 /**   Queue                                                               */
19 /**                                                                       */
20 /**************************************************************************/
21 /**************************************************************************/
22 
23 #define TX_SOURCE_CODE
24 
25 
26 /* Include necessary system files.  */
27 
28 #include "tx_api.h"
29 #include "tx_trace.h"
30 #include "tx_queue.h"
31 
32 
33 /**************************************************************************/
34 /*                                                                        */
35 /*  FUNCTION                                               RELEASE        */
36 /*                                                                        */
37 /*    _tx_queue_info_get                                  PORTABLE C      */
38 /*                                                           6.1          */
39 /*  AUTHOR                                                                */
40 /*                                                                        */
41 /*    William E. Lamie, Microsoft Corporation                             */
42 /*                                                                        */
43 /*  DESCRIPTION                                                           */
44 /*                                                                        */
45 /*    This function retrieves information from the specified queue.       */
46 /*                                                                        */
47 /*  INPUT                                                                 */
48 /*                                                                        */
49 /*    queue_ptr                         Pointer to queue control block    */
50 /*    name                              Destination for the queue name    */
51 /*    enqueued                          Destination for enqueued count    */
52 /*    available_storage                 Destination for available storage */
53 /*    first_suspended                   Destination for pointer of first  */
54 /*                                        thread suspended on this queue  */
55 /*    suspended_count                   Destination for suspended count   */
56 /*    next_queue                        Destination for pointer to next   */
57 /*                                        queue on the created list       */
58 /*                                                                        */
59 /*  OUTPUT                                                                */
60 /*                                                                        */
61 /*    status                            Completion status                 */
62 /*                                                                        */
63 /*  CALLS                                                                 */
64 /*                                                                        */
65 /*    None                                                                */
66 /*                                                                        */
67 /*  CALLED BY                                                             */
68 /*                                                                        */
69 /*    Application Code                                                    */
70 /*                                                                        */
71 /*  RELEASE HISTORY                                                       */
72 /*                                                                        */
73 /*    DATE              NAME                      DESCRIPTION             */
74 /*                                                                        */
75 /*  05-19-2020     William E. Lamie         Initial Version 6.0           */
76 /*  09-30-2020     Yuxin Zhou               Modified comment(s),          */
77 /*                                            resulting in version 6.1    */
78 /*                                                                        */
79 /**************************************************************************/
_tx_queue_info_get(TX_QUEUE * queue_ptr,CHAR ** name,ULONG * enqueued,ULONG * available_storage,TX_THREAD ** first_suspended,ULONG * suspended_count,TX_QUEUE ** next_queue)80 UINT  _tx_queue_info_get(TX_QUEUE *queue_ptr, CHAR **name, ULONG *enqueued, ULONG *available_storage,
81                     TX_THREAD **first_suspended, ULONG *suspended_count, TX_QUEUE **next_queue)
82 {
83 
84 TX_INTERRUPT_SAVE_AREA
85 
86 
87     /* Disable interrupts.  */
88     TX_DISABLE
89 
90     /* If trace is enabled, insert this event into the trace buffer.  */
91     TX_TRACE_IN_LINE_INSERT(TX_TRACE_QUEUE_INFO_GET, queue_ptr, 0, 0, 0, TX_TRACE_QUEUE_EVENTS)
92 
93     /* Log this kernel call.  */
94     TX_EL_QUEUE_INFO_GET_INSERT
95 
96     /* Retrieve all the pertinent information and return it in the supplied
97        destinations.  */
98 
99     /* Retrieve the name of the queue.  */
100     if (name != TX_NULL)
101     {
102 
103         *name =  queue_ptr -> tx_queue_name;
104     }
105 
106     /* Retrieve the number of messages currently in the queue.  */
107     if (enqueued != TX_NULL)
108     {
109 
110         *enqueued =  (ULONG) queue_ptr -> tx_queue_enqueued;
111     }
112 
113     /* Retrieve the number of messages that will still fit in the queue.  */
114     if (available_storage != TX_NULL)
115     {
116 
117         *available_storage =  (ULONG) queue_ptr -> tx_queue_available_storage;
118     }
119 
120     /* Retrieve the first thread suspended on this queue.  */
121     if (first_suspended != TX_NULL)
122     {
123 
124         *first_suspended =  queue_ptr -> tx_queue_suspension_list;
125     }
126 
127     /* Retrieve the number of threads suspended on this queue.  */
128     if (suspended_count != TX_NULL)
129     {
130 
131         *suspended_count =  (ULONG) queue_ptr -> tx_queue_suspended_count;
132     }
133 
134     /* Retrieve the pointer to the next queue created.  */
135     if (next_queue != TX_NULL)
136     {
137 
138         *next_queue =  queue_ptr -> tx_queue_created_next;
139     }
140 
141     /* Restore interrupts.  */
142     TX_RESTORE
143 
144     /* Return completion status.  */
145     return(TX_SUCCESS);
146 }
147 
148