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 /** Semaphore */
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_semaphore.h"
30
31
32 /**************************************************************************/
33 /* */
34 /* FUNCTION RELEASE */
35 /* */
36 /* _txe_semaphore_ceiling_put 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 semaphore ceiling put */
45 /* function call. */
46 /* */
47 /* INPUT */
48 /* */
49 /* semaphore_ptr Pointer to semaphore */
50 /* ceiling Maximum value of semaphore */
51 /* */
52 /* OUTPUT */
53 /* */
54 /* TX_SEMAPHORE_ERROR Invalid semaphore pointer */
55 /* TX_INVALID_CEILING Invalid semaphore ceiling */
56 /* status Actual completion status */
57 /* */
58 /* CALLS */
59 /* */
60 /* _tx_semaphore_ceiling_put Actual semaphore ceiling put */
61 /* function */
62 /* */
63 /* CALLED BY */
64 /* */
65 /* Application Code */
66 /* */
67 /* RELEASE HISTORY */
68 /* */
69 /* DATE NAME DESCRIPTION */
70 /* */
71 /* 05-19-2020 William E. Lamie Initial Version 6.0 */
72 /* 09-30-2020 Yuxin Zhou Modified comment(s), */
73 /* resulting in version 6.1 */
74 /* */
75 /**************************************************************************/
_txe_semaphore_ceiling_put(TX_SEMAPHORE * semaphore_ptr,ULONG ceiling)76 UINT _txe_semaphore_ceiling_put(TX_SEMAPHORE *semaphore_ptr, ULONG ceiling)
77 {
78
79 UINT status;
80
81
82 /* Check for an invalid semaphore pointer. */
83 if (semaphore_ptr == TX_NULL)
84 {
85
86 /* Semaphore pointer is invalid, return appropriate error code. */
87 status = TX_SEMAPHORE_ERROR;
88 }
89
90 /* Now check for a valid semaphore ID. */
91 else if (semaphore_ptr -> tx_semaphore_id != TX_SEMAPHORE_ID)
92 {
93
94 /* Semaphore pointer is invalid, return appropriate error code. */
95 status = TX_SEMAPHORE_ERROR;
96 }
97
98 /* Determine if the ceiling is valid - must be greater than 1. */
99 else if (ceiling == ((ULONG) 0))
100 {
101
102 /* Invalid ceiling, return error. */
103 status = TX_INVALID_CEILING;
104 }
105 else
106 {
107
108 /* Call actual semaphore ceiling put function. */
109 status = _tx_semaphore_ceiling_put(semaphore_ptr, ceiling);
110 }
111
112 /* Return completion status. */
113 return(status);
114 }
115
116