📄 os_mutex.lst
字号:
\ 00000046 2089 LDRH R0,[R4, #+8]
\ 00000048 ........ LDR.W R1,??DataTable7_1
\ 0000004C 0968 LDR R1,[R1, #+0]
\ 0000004E 91F83610 LDRB R1,[R1, #+54]
\ 00000052 0843 ORRS R0,R1,R0
\ 00000054 2081 STRH R0,[R4, #+8]
120 pevent->OSEventPtr = (void *)OSTCBCur; /* Link TCB of task owning Mutex */
\ 00000056 ........ LDR.W R0,??DataTable7_1
\ 0000005A 0068 LDR R0,[R0, #+0]
\ 0000005C 6060 STR R0,[R4, #+4]
121 if ((pcp != OS_PRIO_MUTEX_CEIL_DIS) &&
122 (OSTCBCur->OSTCBPrio <= pcp)) { /* PCP 'must' have a SMALLER prio ... */
\ 0000005E F6B2 UXTB R6,R6 ;; ZeroExt R6,R6,#+24,#+24
\ 00000060 FF2E CMP R6,#+255
\ 00000062 0DD0 BEQ.N ??OSMutexAccept_4
\ 00000064 ........ LDR.W R0,??DataTable7_1
\ 00000068 0068 LDR R0,[R0, #+0]
\ 0000006A 90F83600 LDRB R0,[R0, #+54]
\ 0000006E F6B2 UXTB R6,R6 ;; ZeroExt R6,R6,#+24,#+24
\ 00000070 8642 CMP R6,R0
\ 00000072 05D3 BCC.N ??OSMutexAccept_4
123 OS_EXIT_CRITICAL(); /* ... than current task! */
\ 00000074 3800 MOVS R0,R7
\ 00000076 ........ BL OS_CPU_SR_Restore
124 *perr = OS_ERR_PCP_LOWER;
\ 0000007A 7820 MOVS R0,#+120
\ 0000007C 2870 STRB R0,[R5, #+0]
\ 0000007E 04E0 B.N ??OSMutexAccept_5
125 } else {
126 OS_EXIT_CRITICAL();
\ ??OSMutexAccept_4:
\ 00000080 3800 MOVS R0,R7
\ 00000082 ........ BL OS_CPU_SR_Restore
127 *perr = OS_ERR_NONE;
\ 00000086 0020 MOVS R0,#+0
\ 00000088 2870 STRB R0,[R5, #+0]
128 }
129 return (OS_TRUE);
\ ??OSMutexAccept_5:
\ 0000008A 0120 MOVS R0,#+1
\ 0000008C 05E0 B.N ??OSMutexAccept_1
130 }
131 OS_EXIT_CRITICAL();
\ ??OSMutexAccept_3:
\ 0000008E 3800 MOVS R0,R7
\ 00000090 ........ BL OS_CPU_SR_Restore
132 *perr = OS_ERR_NONE;
\ 00000094 0020 MOVS R0,#+0
\ 00000096 2870 STRB R0,[R5, #+0]
133 return (OS_FALSE);
\ 00000098 0020 MOVS R0,#+0
\ ??OSMutexAccept_1:
\ 0000009A F2BD POP {R1,R4-R7,PC} ;; return
134 }
135 #endif
136
137 /*$PAGE*/
138 /*
139 *********************************************************************************************************
140 * CREATE A MUTUAL EXCLUSION SEMAPHORE
141 *
142 * Description: This function creates a mutual exclusion semaphore.
143 *
144 * Arguments : prio is the priority to use when accessing the mutual exclusion semaphore. In
145 * other words, when the semaphore is acquired and a higher priority task
146 * attempts to obtain the semaphore then the priority of the task owning the
147 * semaphore is raised to this priority. It is assumed that you will specify
148 * a priority that is LOWER in value than ANY of the tasks competing for the
149 * mutex. If the priority is specified as OS_PRIO_MUTEX_CEIL_DIS, then the
150 * priority ceiling promotion is disabled. This way, the tasks accessing the
151 * semaphore do not have their priority promoted.
152 *
153 * perr is a pointer to an error code which will be returned to your application:
154 * OS_ERR_NONE if the call was successful.
155 * OS_ERR_CREATE_ISR if you attempted to create a MUTEX from an ISR
156 * OS_ERR_PRIO_EXIST if a task at the priority ceiling priority
157 * already exist.
158 * OS_ERR_PEVENT_NULL No more event control blocks available.
159 * OS_ERR_PRIO_INVALID if the priority you specify is higher that the
160 * maximum allowed (i.e. > OS_LOWEST_PRIO)
161 *
162 * Returns : != (void *)0 is a pointer to the event control clock (OS_EVENT) associated with the
163 * created mutex.
164 * == (void *)0 if an error is detected.
165 *
166 * Note(s) : 1) The LEAST significant 8 bits of '.OSEventCnt' hold the priority number of the task
167 * owning the mutex or 0xFF if no task owns the mutex.
168 *
169 * 2) The MOST significant 8 bits of '.OSEventCnt' hold the priority number used to
170 * reduce priority inversion or 0xFF (OS_PRIO_MUTEX_CEIL_DIS) if priority ceiling
171 * promotion is disabled.
172 *********************************************************************************************************
173 */
174
\ In section .text, align 2, keep-with-next
175 OS_EVENT *OSMutexCreate (INT8U prio,
176 INT8U *perr)
177 {
\ OSMutexCreate:
\ 00000000 F8B5 PUSH {R3-R7,LR}
\ 00000002 0400 MOVS R4,R0
\ 00000004 0D00 MOVS R5,R1
178 OS_EVENT *pevent;
179 #if OS_CRITICAL_METHOD == 3u /* Allocate storage for CPU status register */
180 OS_CPU_SR cpu_sr = 0u;
\ 00000006 0027 MOVS R7,#+0
181 #endif
182
183
184
185 #ifdef OS_SAFETY_CRITICAL
186 if (perr == (INT8U *)0) {
187 OS_SAFETY_CRITICAL_EXCEPTION();
188 return ((OS_EVENT *)0);
189 }
190 #endif
191
192 #ifdef OS_SAFETY_CRITICAL_IEC61508
193 if (OSSafetyCriticalStartFlag == OS_TRUE) {
194 OS_SAFETY_CRITICAL_EXCEPTION();
195 return ((OS_EVENT *)0);
196 }
197 #endif
198
199 #if OS_ARG_CHK_EN > 0u
200 if (prio != OS_PRIO_MUTEX_CEIL_DIS) {
201 if (prio >= OS_LOWEST_PRIO) { /* Validate PCP */
202 *perr = OS_ERR_PRIO_INVALID;
203 return ((OS_EVENT *)0);
204 }
205 }
206 #endif
207 if (OSIntNesting > 0u) { /* See if called from ISR ... */
\ 00000008 ........ LDR.W R0,??DataTable7
\ 0000000C 0078 LDRB R0,[R0, #+0]
\ 0000000E 0028 CMP R0,#+0
\ 00000010 03D0 BEQ.N ??OSMutexCreate_0
208 *perr = OS_ERR_CREATE_ISR; /* ... can't CREATE mutex from an ISR */
\ 00000012 1020 MOVS R0,#+16
\ 00000014 2870 STRB R0,[R5, #+0]
209 return ((OS_EVENT *)0);
\ 00000016 0020 MOVS R0,#+0
\ 00000018 4AE0 B.N ??OSMutexCreate_1
210 }
211 OS_ENTER_CRITICAL();
\ ??OSMutexCreate_0:
\ 0000001A ........ BL OS_CPU_SR_Save
\ 0000001E 0700 MOVS R7,R0
212 if (prio != OS_PRIO_MUTEX_CEIL_DIS) {
\ 00000020 E4B2 UXTB R4,R4 ;; ZeroExt R4,R4,#+24,#+24
\ 00000022 FF2C CMP R4,#+255
\ 00000024 13D0 BEQ.N ??OSMutexCreate_2
213 if (OSTCBPrioTbl[prio] != (OS_TCB *)0) { /* Mutex priority must not already exist */
\ 00000026 E4B2 UXTB R4,R4 ;; ZeroExt R4,R4,#+24,#+24
\ 00000028 ........ LDR.W R0,??DataTable7_2
\ 0000002C 50F82400 LDR R0,[R0, R4, LSL #+2]
\ 00000030 0028 CMP R0,#+0
\ 00000032 06D0 BEQ.N ??OSMutexCreate_3
214 OS_EXIT_CRITICAL(); /* Task already exist at priority ... */
\ 00000034 3800 MOVS R0,R7
\ 00000036 ........ BL OS_CPU_SR_Restore
215 *perr = OS_ERR_PRIO_EXIST; /* ... ceiling priority */
\ 0000003A 2820 MOVS R0,#+40
\ 0000003C 2870 STRB R0,[R5, #+0]
216 return ((OS_EVENT *)0);
\ 0000003E 0020 MOVS R0,#+0
\ 00000040 36E0 B.N ??OSMutexCreate_1
217 }
218 OSTCBPrioTbl[prio] = OS_TCB_RESERVED; /* Reserve the table entry */
\ ??OSMutexCreate_3:
\ 00000042 E4B2 UXTB R4,R4 ;; ZeroExt R4,R4,#+24,#+24
\ 00000044 ........ LDR.W R0,??DataTable7_2
\ 00000048 0121 MOVS R1,#+1
\ 0000004A 40F82410 STR R1,[R0, R4, LSL #+2]
219 }
220
221 pevent = OSEventFreeList; /* Get next free event control block */
\ ??OSMutexCreate_2:
\ 0000004E ........ LDR.W R0,??DataTable7_3
\ 00000052 0068 LDR R0,[R0, #+0]
\ 00000054 0600 MOVS R6,R0
222 if (pevent == (OS_EVENT *)0) { /* See if an ECB was available */
\ 00000056 002E CMP R6,#+0
\ 00000058 0FD1 BNE.N ??OSMutexCreate_4
223 if (prio != OS_PRIO_MUTEX_CEIL_DIS) {
\ 0000005A E4B2 UXTB R4,R4 ;; ZeroExt R4,R4,#+24,#+24
\ 0000005C FF2C CMP R4,#+255
\ 0000005E 05D0 BEQ.N ??OSMutexCreate_5
224 OSTCBPrioTbl[prio] = (OS_TCB *)0; /* No, Release the table entry */
\ 00000060 E4B2 UXTB R4,R4 ;; ZeroExt R4,R4,#+24,#+24
\ 00000062 ........ LDR.W R0,??DataTable7_2
\ 00000066 0021 MOVS R1,#+0
\ 00000068 40F82410 STR R1,[R0, R4, LSL #+2]
225 }
226 OS_EXIT_CRITICAL();
\ ??OSMutexCreate_5:
\ 0000006C 3800 MOVS R0,R7
\ 0000006E ........ BL OS_CPU_SR_Restore
227 *perr = OS_ERR_PEVENT_NULL; /* No more event control blocks */
\ 00000072 0420 MOVS R0,#+4
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -