📄 os_mutex.lst
字号:
\ 00000114 0000C6E5 STRB R0,[R6, #+0]
205 pevent->OSEventCnt = (INT16U)((INT16U)prio << 8) | OS_MUTEX_AVAILABLE; /* Resource is avail. */
\ 00000118 0400B0E1 MOVS R0,R4
\ 0000011C FF10A0E3 MOV R1,#+255
\ 00000120 000491E1 ORRS R0,R1,R0, LSL #+8
\ 00000124 B800C6E1 STRH R0,[R6, #+8]
206 pevent->OSEventPtr = (void *)0; /* No task owning the mutex */
\ 00000128 0000A0E3 MOV R0,#+0
\ 0000012C 040086E5 STR R0,[R6, #+4]
207 #if OS_EVENT_NAME_SIZE > 1
208 pevent->OSEventName[0] = '?';
\ 00000130 3F00A0E3 MOV R0,#+63
\ 00000134 0F00C6E5 STRB R0,[R6, #+15]
209 pevent->OSEventName[1] = OS_ASCII_NUL;
\ 00000138 0000A0E3 MOV R0,#+0
\ 0000013C 1000C6E5 STRB R0,[R6, #+16]
210 #endif
211 OS_EventWaitListInit(pevent);
\ 00000140 0600B0E1 MOVS R0,R6
\ 00000144 ........ _BLF OS_EventWaitListInit,??OS_EventWaitListInit??rA
212 *err = OS_ERR_NONE;
\ 00000148 0000A0E3 MOV R0,#+0
\ 0000014C 0000C5E5 STRB R0,[R5, #+0]
213 return (pevent);
\ 00000150 0600B0E1 MOVS R0,R6
\ ??OSMutexCreate_1:
\ 00000154 F080BDE8 POP {R4-R7,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 * err 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 *err)
259 {
\ OSMutexDel:
\ 00000000 F24F2DE9 PUSH {R1,R4-R11,LR}
\ 00000004 0040B0E1 MOVS R4,R0
\ 00000008 0250B0E1 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;
\ 0000000C 0000A0E3 MOV R0,#+0
\ 00000010 00B0B0E1 MOVS R11,R0
267 #endif
268
269
270
271 #if OS_ARG_CHK_EN > 0
272 if (err == (INT8U *)0) { /* Validate 'err' */
\ 00000014 000055E3 CMP R5,#+0
\ 00000018 0100001A BNE ??OSMutexDel_0
273 return (pevent);
\ 0000001C 0400B0E1 MOVS R0,R4
\ 00000020 8B0000EA B ??OSMutexDel_1
274 }
275 if (pevent == (OS_EVENT *)0) { /* Validate 'pevent' */
\ ??OSMutexDel_0:
\ 00000024 000054E3 CMP R4,#+0
\ 00000028 0300001A BNE ??OSMutexDel_2
276 *err = OS_ERR_PEVENT_NULL;
\ 0000002C 0400A0E3 MOV R0,#+4
\ 00000030 0000C5E5 STRB R0,[R5, #+0]
277 return (pevent);
\ 00000034 0400B0E1 MOVS R0,R4
\ 00000038 850000EA B ??OSMutexDel_1
278 }
279 #endif
280 if (pevent->OSEventType != OS_EVENT_TYPE_MUTEX) { /* Validate event block type */
\ ??OSMutexDel_2:
\ 0000003C 0000D4E5 LDRB R0,[R4, #+0]
\ 00000040 040050E3 CMP R0,#+4
\ 00000044 0300000A BEQ ??OSMutexDel_3
281 *err = OS_ERR_EVENT_TYPE;
\ 00000048 0100A0E3 MOV R0,#+1
\ 0000004C 0000C5E5 STRB R0,[R5, #+0]
282 return (pevent);
\ 00000050 0400B0E1 MOVS R0,R4
\ 00000054 7E0000EA B ??OSMutexDel_1
283 }
284 if (OSIntNesting > 0) { /* See if called from ISR ... */
\ ??OSMutexDel_3:
\ 00000058 ........ LDR R0,??DataTable47 ;; OSIntNesting
\ 0000005C 0000D0E5 LDRB R0,[R0, #+0]
\ 00000060 010050E3 CMP R0,#+1
\ 00000064 0300003A BCC ??OSMutexDel_4
285 *err = OS_ERR_DEL_ISR; /* ... can't DELETE from an ISR */
\ 00000068 0F00A0E3 MOV R0,#+15
\ 0000006C 0000C5E5 STRB R0,[R5, #+0]
286 return (pevent);
\ 00000070 0400B0E1 MOVS R0,R4
\ 00000074 760000EA B ??OSMutexDel_1
287 }
288 OS_ENTER_CRITICAL();
\ ??OSMutexDel_4:
\ 00000078 ........ _BLF OS_CPU_SR_Save,??OS_CPU_SR_Save??rA
\ 0000007C 00B0B0E1 MOVS R11,R0
289 if (pevent->OSEventGrp != 0) { /* See if any tasks waiting on mutex */
\ 00000080 0A00D4E5 LDRB R0,[R4, #+10]
\ 00000084 000050E3 CMP R0,#+0
\ 00000088 0200000A BEQ ??OSMutexDel_5
290 tasks_waiting = OS_TRUE; /* Yes */
\ 0000008C 0100A0E3 MOV R0,#+1
\ 00000090 0060B0E1 MOVS R6,R0
\ 00000094 010000EA B ??OSMutexDel_6
291 } else {
292 tasks_waiting = OS_FALSE; /* No */
\ ??OSMutexDel_5:
\ 00000098 0000A0E3 MOV R0,#+0
\ 0000009C 0060B0E1 MOVS R6,R0
293 }
294 switch (opt) {
\ ??OSMutexDel_6:
\ 000000A0 0000DDE5 LDRB R0,[SP, #+0]
\ 000000A4 000050E3 CMP R0,#+0
\ 000000A8 0200000A BEQ ??OSMutexDel_7
\ 000000AC 010050E3 CMP R0,#+1
\ 000000B0 2600000A BEQ ??OSMutexDel_8
\ 000000B4 600000EA B ??OSMutexDel_9
295 case OS_DEL_NO_PEND: /* DELETE MUTEX ONLY IF NO TASK WAITING --- */
296 if (tasks_waiting == OS_FALSE) {
\ ??OSMutexDel_7:
\ 000000B8 000056E3 CMP R6,#+0
\ 000000BC 1D00001A BNE ??OSMutexDel_10
297 #if OS_EVENT_NAME_SIZE > 1
298 pevent->OSEventName[0] = '?'; /* Unknown name */
\ 000000C0 3F00A0E3 MOV R0,#+63
\ 000000C4 0F00C4E5 STRB R0,[R4, #+15]
299 pevent->OSEventName[1] = OS_ASCII_NUL;
\ 000000C8 0000A0E3 MOV R0,#+0
\ 000000CC 1000C4E5 STRB R0,[R4, #+16]
300 #endif
301 pip = (INT8U)(pevent->OSEventCnt >> 8);
\ 000000D0 B800D4E1 LDRH R0,[R4, #+8]
\ 000000D4 2004B0E1 LSRS R0,R0,#+8
\ 000000D8 0080B0E1 MOVS R8,R0
302 OSTCBPrioTbl[pip] = (OS_TCB *)0; /* Free up the PIP */
\ 000000DC 0800B0E1 MOVS R0,R8
\ 000000E0 FF0010E2 ANDS R0,R0,#0xFF ;; Zero extend
\ 000000E4 0410A0E3 MOV R1,#+4
\ 000000E8 ........ LDR R2,??DataTable57 ;; OSTCBPrioTbl
\ 000000EC 912020E0 MLA R0,R1,R0,R2
\ 000000F0 0010A0E3 MOV R1,#+0
\ 000000F4 001080E5 STR R1,[R0, #+0]
303 pevent->OSEventType = OS_EVENT_TYPE_UNUSED;
\ 000000F8 0000A0E3 MOV R0,#+0
\ 000000FC 0000C4E5 STRB R0,[R4, #+0]
304 pevent->OSEventPtr = OSEventFreeList; /* Return Event Control Block to free list */
\ 00000100 ........ LDR R0,??DataTable17 ;; OSEventFreeList
\ 00000104 000090E5 LDR R0,[R0, #+0]
\ 00000108 040084E5 STR R0,[R4, #+4]
305 pevent->OSEventCnt = 0;
\ 0000010C 0000A0E3 MOV R0,#+0
\ 00000110 B800C4E1 STRH R0,[R4, #+8]
306 OSEventFreeList = pevent;
\ 00000114 ........ LDR R0,??DataTable17 ;; OSEventFreeList
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -