📄 os_mutex.lst
字号:
206 pevent->OSEventPtr = (void *)0; /* No task owning the mutex */
\ 0000007C 7760 STR R7,[R6, #+4]
207 #if OS_EVENT_NAME_SIZE > 1
208 pevent->OSEventName[0] = '?';
\ 0000007E 3F20 MOVS R0,#+63
\ 00000080 F073 STRB R0,[R6, #+15]
209 pevent->OSEventName[1] = OS_ASCII_NUL;
\ 00000082 3800 MOVS R0,R7
\ 00000084 3074 STRB R0,[R6, #+16]
210 #endif
211 OS_EventWaitListInit(pevent);
\ 00000086 3000 MOVS R0,R6
\ 00000088 ........ _BLF OS_EventWaitListInit,??OS_EventWaitListInit??rT
212 *perr = OS_ERR_NONE;
\ 0000008C 2F70 STRB R7,[R5, #+0]
213 return (pevent);
\ 0000008E 3000 MOVS R0,R6
\ ??OSMutexCreate_1:
\ 00000090 BDE8F081 POP {R4-R8,PC} ;; return
214 }
215
216 /*$PAGE*/
217 /*
218 *********************************************************************************************************
219 * DELETE A MUTEX
220 *
221 * Description: This function deletes a mutual exclusion semaphore and readies all tasks pending on the it.
222 *
223 * Arguments : pevent is a pointer to the event control block associated with the desired mutex.
224 *
225 * opt determines delete options as follows:
226 * opt == OS_DEL_NO_PEND Delete mutex ONLY if no task pending
227 * opt == OS_DEL_ALWAYS Deletes the mutex even if tasks are waiting.
228 * In this case, all the tasks pending will be readied.
229 *
230 * perr is a pointer to an error code that can contain one of the following values:
231 * OS_ERR_NONE The call was successful and the mutex was deleted
232 * OS_ERR_DEL_ISR If you attempted to delete the MUTEX from an ISR
233 * OS_ERR_INVALID_OPT An invalid option was specified
234 * OS_ERR_TASK_WAITING One or more tasks were waiting on the mutex
235 * OS_ERR_EVENT_TYPE If you didn't pass a pointer to a mutex
236 * OS_ERR_PEVENT_NULL If 'pevent' is a NULL pointer.
237 *
238 * Returns : pevent upon error
239 * (OS_EVENT *)0 if the mutex was successfully deleted.
240 *
241 * Note(s) : 1) This function must be used with care. Tasks that would normally expect the presence of
242 * the mutex MUST check the return code of OSMutexPend().
243 *
244 * 2) This call can potentially disable interrupts for a long time. The interrupt disable
245 * time is directly proportional to the number of tasks waiting on the mutex.
246 *
247 * 3) Because ALL tasks pending on the mutex will be readied, you MUST be careful because the
248 * resource(s) will no longer be guarded by the mutex.
249 *
250 * 4) IMPORTANT: In the 'OS_DEL_ALWAYS' case, we assume that the owner of the Mutex (if there
251 * is one) is ready-to-run and is thus NOT pending on another kernel object or
252 * has delayed itself. In other words, if a task owns the mutex being deleted,
253 * that task will be made ready-to-run at its original priority.
254 *********************************************************************************************************
255 */
256
257 #if OS_MUTEX_DEL_EN
\ In segment CODE, align 4, keep-with-next
258 OS_EVENT *OSMutexDel (OS_EVENT *pevent, INT8U opt, INT8U *perr)
259 {
\ OSMutexDel:
\ 00000000 2DE9F14F PUSH {R0,R4-R11,LR}
\ 00000004 8DF80010 STRB R1,[SP, #+0]
\ 00000008 0400 MOVS R4,R0
\ 0000000A 1500 MOVS R5,R2
260 BOOLEAN tasks_waiting;
261 OS_EVENT *pevent_return;
262 INT8U pip; /* Priority inheritance priority */
263 INT8U prio;
264 OS_TCB *ptcb;
265 #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
266 OS_CPU_SR cpu_sr = 0;
267 #endif
268
269
270
271 #if OS_ARG_CHK_EN > 0
272 if (perr == (INT8U *)0) { /* Validate 'perr' */
\ 0000000C 01D1 BNE.N ??OSMutexDel_0
273 return (pevent);
\ ??OSMutexDel_1:
\ 0000000E 2000 MOVS R0,R4
\ 00000010 7AE0 B.N ??OSMutexDel_2
274 }
275 if (pevent == (OS_EVENT *)0) { /* Validate 'pevent' */
\ ??OSMutexDel_0:
\ 00000012 002C CMP R4,#+0
\ 00000014 03D1 BNE.N ??OSMutexDel_3
276 *perr = OS_ERR_PEVENT_NULL;
\ 00000016 0420 MOVS R0,#+4
\ 00000018 2870 STRB R0,[R5, #+0]
277 return (pevent);
\ 0000001A 0020 MOVS R0,#+0
\ 0000001C 74E0 B.N ??OSMutexDel_2
278 }
279 #endif
280 if (pevent->OSEventType != OS_EVENT_TYPE_MUTEX) { /* Validate event block type */
\ ??OSMutexDel_3:
\ 0000001E 0126 MOVS R6,#+1
\ 00000020 2078 LDRB R0,[R4, #+0]
\ 00000022 0428 CMP R0,#+4
\ 00000024 01D0 BEQ.N ??OSMutexDel_4
281 *perr = OS_ERR_EVENT_TYPE;
\ 00000026 2E70 STRB R6,[R5, #+0]
\ 00000028 F1E7 B.N ??OSMutexDel_1
282 return (pevent);
283 }
284 if (OSIntNesting > 0) { /* See if called from ISR ... */
\ ??OSMutexDel_4:
\ 0000002A .... LDR.N R0,??DataTable5 ;; OSIntNesting
\ 0000002C 0078 LDRB R0,[R0, #+0]
\ 0000002E 0028 CMP R0,#+0
\ 00000030 02D0 BEQ.N ??OSMutexDel_5
285 *perr = OS_ERR_DEL_ISR; /* ... can't DELETE from an ISR */
\ 00000032 0F20 MOVS R0,#+15
\ 00000034 2870 STRB R0,[R5, #+0]
\ 00000036 EAE7 B.N ??OSMutexDel_1
286 return (pevent);
287 }
288 OS_ENTER_CRITICAL();
\ ??OSMutexDel_5:
\ 00000038 ........ _BLF OS_CPU_SR_Save,??OS_CPU_SR_Save??rT
\ 0000003C 8046 MOV R8,R0
289 if (pevent->OSEventGrp != 0) { /* See if any tasks waiting on mutex */
\ 0000003E 0020 MOVS R0,#+0
\ 00000040 8146 MOV R9,R0
\ 00000042 A07A LDRB R0,[R4, #+10]
\ 00000044 0028 CMP R0,#+0
\ 00000046 01D0 BEQ.N ??OSMutexDel_6
290 tasks_waiting = OS_TRUE; /* Yes */
\ 00000048 B246 MOV R10,R6
\ 0000004A 00E0 B.N ??OSMutexDel_7
291 } else {
292 tasks_waiting = OS_FALSE; /* No */
\ ??OSMutexDel_6:
\ 0000004C CA46 MOV R10,R9
293 }
294 switch (opt) {
\ ??OSMutexDel_7:
\ 0000004E .... LDR.N R6,??DataTable6 ;; OSEventFreeList
\ 00000050 .... LDR.N R7,??DataTable7 ;; OSTCBPrioTbl
\ 00000052 3F20 MOVS R0,#+63
\ 00000054 8346 MOV R11,R0
\ 00000056 9DF80000 LDRB R0,[SP, #+0]
\ 0000005A 0028 CMP R0,#+0
\ 0000005C 02D0 BEQ.N ??OSMutexDel_8
\ 0000005E 0128 CMP R0,#+1
\ 00000060 1CD0 BEQ.N ??OSMutexDel_9
\ 00000062 4BE0 B.N ??OSMutexDel_10
295 case OS_DEL_NO_PEND: /* DELETE MUTEX ONLY IF NO TASK WAITING --- */
296 if (tasks_waiting == OS_FALSE) {
\ ??OSMutexDel_8:
\ 00000064 5046 MOV R0,R10
\ 00000066 0028 CMP R0,#+0
\ 00000068 11D1 BNE.N ??OSMutexDel_11
297 #if OS_EVENT_NAME_SIZE > 1
298 pevent->OSEventName[0] = '?'; /* Unknown name */
\ 0000006A 84F80FB0 STRB R11,[R4, #+15]
299 pevent->OSEventName[1] = OS_ASCII_NUL;
\ 0000006E 2074 STRB R0,[R4, #+16]
300 #endif
301 pip = (INT8U)(pevent->OSEventCnt >> 8);
302 OSTCBPrioTbl[pip] = (OS_TCB *)0; /* Free up the PIP */
\ 00000070 2089 LDRH R0,[R4, #+8]
\ 00000072 000A LSRS R0,R0,#+8
\ 00000074 47F82090 STR R9,[R7, R0, LSL #+2]
303 pevent->OSEventType = OS_EVENT_TYPE_UNUSED;
\ 00000078 4846 MOV R0,R9
\ 0000007A 2070 STRB R0,[R4, #+0]
304 pevent->OSEventPtr = OSEventFreeList; /* Return Event Control Block to free list */
\ 0000007C 3068 LDR R0,[R6, #+0]
\ 0000007E 6060 STR R0,[R4, #+4]
305 pevent->OSEventCnt = 0;
\ 00000080 4846 MOV R0,R9
\ 00000082 2081 STRH R0,[R4, #+8]
306 OSEventFreeList = pevent;
\ 00000084 3460 STR R4,[R6, #+0]
307 OS_EXIT_CRITICAL();
\ 00000086 4046 MOV R0,R8
\ 00000088 ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
\ 0000008C 33E0 B.N ??OSMutexDel_12
308 *perr = OS_ERR_NONE;
309 pevent_return = (OS_EVENT *)0; /* Mutex has been deleted */
310 } else {
311 OS_EXIT_CRITICAL();
\ ??OSMutexDel_11:
\ 0000008E 4046 MOV R0,R8
\ 00000090 ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
312 *perr = OS_ERR_TASK_WAITING;
\ 00000094 4920 MOVS R0,#+73
\ 00000096 2870 STRB R0,[R5, #+0]
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -