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 /**   Byte Memory                                                         */
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_byte_pool.h"
30 
31 
32 /**************************************************************************/
33 /*                                                                        */
34 /*  FUNCTION                                               RELEASE        */
35 /*                                                                        */
36 /*    _txe_byte_pool_info_get                             PORTABLE C      */
37 /*                                                           6.1          */
38 /*  AUTHOR                                                                */
39 /*                                                                        */
40 /*    William E. Lamie, Microsoft Corporation                             */
41 /*                                                                        */
42 /*  DESCRIPTION                                                           */
43 /*                                                                        */
44 /*    This function checks for errors in the byte pool information get    */
45 /*    service.                                                            */
46 /*                                                                        */
47 /*  INPUT                                                                 */
48 /*                                                                        */
49 /*    pool_ptr                          Pointer to byte pool control block*/
50 /*    name                              Destination for the pool name     */
51 /*    available_bytes                   Number of free bytes in byte pool */
52 /*    fragments                         Number of fragments in byte pool  */
53 /*    first_suspended                   Destination for pointer of first  */
54 /*                                        thread suspended on byte pool   */
55 /*    suspended_count                   Destination for suspended count   */
56 /*    next_pool                         Destination for pointer to next   */
57 /*                                        byte pool on the created list   */
58 /*                                                                        */
59 /*  OUTPUT                                                                */
60 /*                                                                        */
61 /*    TX_POOL_ERROR                     Invalid byte pool pointer         */
62 /*    status                            Completion status                 */
63 /*                                                                        */
64 /*  CALLS                                                                 */
65 /*                                                                        */
66 /*    _tx_byte_pool_info_get            Actual byte pool info get service */
67 /*                                                                        */
68 /*  CALLED BY                                                             */
69 /*                                                                        */
70 /*    Application Code                                                    */
71 /*                                                                        */
72 /*  RELEASE HISTORY                                                       */
73 /*                                                                        */
74 /*    DATE              NAME                      DESCRIPTION             */
75 /*                                                                        */
76 /*  05-19-2020     William E. Lamie         Initial Version 6.0           */
77 /*  09-30-2020     Yuxin Zhou               Modified comment(s),          */
78 /*                                            resulting in version 6.1    */
79 /*                                                                        */
80 /**************************************************************************/
_txe_byte_pool_info_get(TX_BYTE_POOL * pool_ptr,CHAR ** name,ULONG * available_bytes,ULONG * fragments,TX_THREAD ** first_suspended,ULONG * suspended_count,TX_BYTE_POOL ** next_pool)81 UINT  _txe_byte_pool_info_get(TX_BYTE_POOL *pool_ptr, CHAR **name, ULONG *available_bytes,
82                     ULONG *fragments, TX_THREAD **first_suspended,
83                     ULONG *suspended_count, TX_BYTE_POOL **next_pool)
84 {
85 
86 UINT    status;
87 
88 
89     /* Check for an invalid byte pool pointer.  */
90     if (pool_ptr == TX_NULL)
91     {
92 
93         /* Block pool pointer is invalid, return appropriate error code.  */
94         status =  TX_POOL_ERROR;
95     }
96 
97     /* Now check for invalid pool ID.  */
98     else if (pool_ptr -> tx_byte_pool_id != TX_BYTE_POOL_ID)
99     {
100 
101         /* Block pool pointer is invalid, return appropriate error code.  */
102         status =  TX_POOL_ERROR;
103     }
104     else
105     {
106 
107         /* Otherwise, call the actual byte pool information get service.  */
108         status =  _tx_byte_pool_info_get(pool_ptr, name, available_bytes,
109                             fragments, first_suspended, suspended_count, next_pool);
110     }
111 
112     /* Return completion status.  */
113     return(status);
114 }
115 
116