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 Pool */ 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_thread.h" 29 #include "tx_timer.h" 30 #include "tx_byte_pool.h" 31 32 33 /**************************************************************************/ 34 /* */ 35 /* FUNCTION RELEASE */ 36 /* */ 37 /* _txe_byte_pool_delete PORTABLE C */ 38 /* 6.1 */ 39 /* AUTHOR */ 40 /* */ 41 /* William E. Lamie, Microsoft Corporation */ 42 /* */ 43 /* DESCRIPTION */ 44 /* */ 45 /* This function checks for errors in the delete byte pool function */ 46 /* call. */ 47 /* */ 48 /* INPUT */ 49 /* */ 50 /* pool_ptr Pointer to pool control block */ 51 /* */ 52 /* OUTPUT */ 53 /* */ 54 /* TX_POOL_ERROR Invalid pool pointer */ 55 /* TX_CALLER_ERROR Invalid caller of this function */ 56 /* status Actual completion status */ 57 /* */ 58 /* CALLS */ 59 /* */ 60 /* _tx_byte_pool_delete Actual byte pool delete function */ 61 /* */ 62 /* CALLED BY */ 63 /* */ 64 /* Application Code */ 65 /* */ 66 /* RELEASE HISTORY */ 67 /* */ 68 /* DATE NAME DESCRIPTION */ 69 /* */ 70 /* 05-19-2020 William E. Lamie Initial Version 6.0 */ 71 /* 09-30-2020 Yuxin Zhou Modified comment(s), */ 72 /* resulting in version 6.1 */ 73 /* */ 74 /**************************************************************************/ _txe_byte_pool_delete(TX_BYTE_POOL * pool_ptr)75UINT _txe_byte_pool_delete(TX_BYTE_POOL *pool_ptr) 76 { 77 78 UINT status; 79 #ifndef TX_TIMER_PROCESS_IN_ISR 80 TX_THREAD *thread_ptr; 81 #endif 82 83 84 #ifndef TX_TIMER_PROCESS_IN_ISR 85 86 /* Default status to success. */ 87 status = TX_SUCCESS; 88 #endif 89 90 /* Check for an invalid byte pool pointer. */ 91 if (pool_ptr == TX_NULL) 92 { 93 94 /* Byte pool pointer is invalid, return appropriate error code. */ 95 status = TX_POOL_ERROR; 96 } 97 98 /* Now check the pool ID. */ 99 else if (pool_ptr -> tx_byte_pool_id != TX_BYTE_POOL_ID) 100 { 101 102 /* Byte pool pointer is invalid, return appropriate error code. */ 103 status = TX_POOL_ERROR; 104 } 105 106 /* Check for interrupt or initialization. */ 107 else if (TX_THREAD_GET_SYSTEM_STATE() != ((ULONG) 0)) 108 { 109 110 /* Invalid caller of this function, return appropriate error code. */ 111 status = TX_CALLER_ERROR; 112 } 113 else 114 { 115 116 #ifndef TX_TIMER_PROCESS_IN_ISR 117 118 /* Pickup thread pointer. */ 119 TX_THREAD_GET_CURRENT(thread_ptr) 120 121 /* Check for invalid caller of this function. First check for a calling thread. */ 122 if (thread_ptr == &_tx_timer_thread) 123 { 124 125 /* Invalid caller of this function, return appropriate error code. */ 126 status = TX_CALLER_ERROR; 127 } 128 129 /* Determine if everything is okay. */ 130 if (status == TX_SUCCESS) 131 { 132 #endif 133 134 /* Call actual byte pool delete function. */ 135 status = _tx_byte_pool_delete(pool_ptr); 136 137 #ifndef TX_TIMER_PROCESS_IN_ISR 138 } 139 #endif 140 } 141 142 /* Return completion status. */ 143 return(status); 144 } 145 146