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 /*    _tx_byte_pool_prioritize                            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 prioritize call.   */
44 /*                                                                        */
45 /*  INPUT                                                                 */
46 /*                                                                        */
47 /*    pool_ptr                          Pointer to pool control block     */
48 /*                                                                        */
49 /*  OUTPUT                                                                */
50 /*                                                                        */
51 /*    status                            Completion status                 */
52 /*                                                                        */
53 /*  CALLS                                                                 */
54 /*                                                                        */
55 /*    _tx_byte_pool_prioritize         Actual byte pool prioritize        */
56 /*                                        function                        */
57 /*                                                                        */
58 /*  CALLED BY                                                             */
59 /*                                                                        */
60 /*    Application Code                                                    */
61 /*                                                                        */
62 /*  RELEASE HISTORY                                                       */
63 /*                                                                        */
64 /*    DATE              NAME                      DESCRIPTION             */
65 /*                                                                        */
66 /*  05-19-2020     William E. Lamie         Initial Version 6.0           */
67 /*  09-30-2020     Yuxin Zhou               Modified comment(s),          */
68 /*                                            resulting in version 6.1    */
69 /*                                                                        */
70 /**************************************************************************/
_txe_byte_pool_prioritize(TX_BYTE_POOL * pool_ptr)71 UINT  _txe_byte_pool_prioritize(TX_BYTE_POOL *pool_ptr)
72 {
73 
74 UINT        status;
75 
76 
77     /* Check for an invalid byte memory pool pointer.  */
78     if (pool_ptr == TX_NULL)
79     {
80 
81         /* Byte pool pointer is invalid, return appropriate error code.  */
82         status =  TX_POOL_ERROR;
83     }
84 
85     /* Now check for invalid pool ID.  */
86     else if (pool_ptr -> tx_byte_pool_id != TX_BYTE_POOL_ID)
87     {
88 
89         /* Byte pool pointer is invalid, return appropriate error code.  */
90         status =  TX_POOL_ERROR;
91     }
92     else
93     {
94 
95         /* Call actual byte pool prioritize function.  */
96         status =  _tx_byte_pool_prioritize(pool_ptr);
97     }
98 
99     /* Return completion status.  */
100     return(status);
101 }
102 
103