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