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_timer.h" 30 #include "tx_thread.h" 31 #include "tx_queue.h" 32 33 34 /**************************************************************************/ 35 /* */ 36 /* FUNCTION RELEASE */ 37 /* */ 38 /* _txe_queue_delete PORTABLE C */ 39 /* 6.1 */ 40 /* AUTHOR */ 41 /* */ 42 /* William E. Lamie, Microsoft Corporation */ 43 /* */ 44 /* DESCRIPTION */ 45 /* */ 46 /* This function checks for errors in the queue delete function call. */ 47 /* */ 48 /* INPUT */ 49 /* */ 50 /* queue_ptr Pointer to queue control block */ 51 /* */ 52 /* OUTPUT */ 53 /* */ 54 /* TX_QUEUE_ERROR Invalid queue pointer */ 55 /* TX_CALLER_ERROR Invalid caller of this function */ 56 /* status Actual completion status */ 57 /* */ 58 /* CALLS */ 59 /* */ 60 /* _tx_queue_delete Actual queue 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_queue_delete(TX_QUEUE * queue_ptr)75UINT _txe_queue_delete(TX_QUEUE *queue_ptr) 76 { 77 78 UINT status; 79 #ifndef TX_TIMER_PROCESS_IN_ISR 80 TX_THREAD *thread_ptr; 81 #endif 82 83 84 /* Default status to success. */ 85 status = TX_SUCCESS; 86 87 /* Check for an invalid queue pointer. */ 88 if (queue_ptr == TX_NULL) 89 { 90 91 /* Queue pointer is invalid, return appropriate error code. */ 92 status = TX_QUEUE_ERROR; 93 } 94 95 /* Now check for a valid queue ID. */ 96 else if (queue_ptr -> tx_queue_id != TX_QUEUE_ID) 97 { 98 99 /* Queue pointer is invalid, return appropriate error code. */ 100 status = TX_QUEUE_ERROR; 101 } 102 else 103 { 104 105 /* Check for invalid caller of this function. */ 106 107 /* Is the caller an ISR or Initialization? */ 108 if (TX_THREAD_GET_SYSTEM_STATE() != ((ULONG) 0)) 109 { 110 111 /* Invalid caller of this function, return appropriate error code. */ 112 status = TX_CALLER_ERROR; 113 } 114 115 #ifndef TX_TIMER_PROCESS_IN_ISR 116 else 117 { 118 119 /* Pickup thread pointer. */ 120 TX_THREAD_GET_CURRENT(thread_ptr) 121 122 /* Is the caller the system timer thread? */ 123 if (thread_ptr == &_tx_timer_thread) 124 { 125 126 /* Invalid caller of this function, return appropriate error code. */ 127 status = TX_CALLER_ERROR; 128 } 129 } 130 #endif 131 } 132 133 /* Determine if everything is okay. */ 134 if (status == TX_SUCCESS) 135 { 136 137 /* Call actual queue delete function. */ 138 status = _tx_queue_delete(queue_ptr); 139 } 140 141 /* Return completion status. */ 142 return(status); 143 } 144 145