📄 os_mutex.s79
字号:
CFI ?RET Frame(CFA, -4)
CFI R7 Frame(CFA, -8)
CFI R6 Frame(CFA, -12)
CFI R5 Frame(CFA, -16)
CFI R4 Frame(CFA, -20)
CFI CFA R13+24
MOVS R4,R0
MOVS R5,R2
// 212 #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
// 213 OS_CPU_SR cpu_sr;
// 214 #endif
// 215 BOOLEAN tasks_waiting;
// 216 INT8U pip;
// 217
// 218
// 219 if (OSIntNesting > 0) { /* See if called from ISR ... */
LDR R0,??DataTable6 ;; OSIntNesting
LDRB R0,[R0, #+0]
CMP R0,#+0
BEQ ??OSMutexDel_0
// 220 *err = OS_ERR_DEL_ISR; /* ... can't DELETE from an ISR */
MOVS R0,#+140
B.N ??OSMutexDel_1
// 221 return (pevent);
// 222 }
// 223 #if OS_ARG_CHK_EN > 0
// 224 if (pevent == (OS_EVENT *)0) { /* Validate 'pevent' */
??OSMutexDel_0:
CMP R4,#+0
BNE ??OSMutexDel_2
// 225 *err = OS_ERR_PEVENT_NULL;
MOVS R0,#+4
STRB R0,[R5, #+0]
// 226 return ((OS_EVENT *)0);
MOVS R0,#+0
B ??OSMutexDel_3
// 227 }
// 228 #endif
// 229 if (pevent->OSEventType != OS_EVENT_TYPE_MUTEX) { /* Validate event block type */
??OSMutexDel_2:
LDRB R0,[R4, #+0]
CMP R0,#+4
BEQ ??OSMutexDel_4
// 230 *err = OS_ERR_EVENT_TYPE;
MOVS R0,#+1
B.N ??OSMutexDel_1
// 231 return (pevent);
// 232 }
// 233 OS_ENTER_CRITICAL();
??OSMutexDel_4:
_BLF OS_CPU_SR_Save,??OS_CPU_SR_Save??rT
MOVS R6,R0
// 234 if (pevent->OSEventGrp != 0x00) { /* See if any tasks waiting on mutex */
LDRB R0,[R4, #+1]
CMP R0,#+0
BEQ ??OSMutexDel_5
// 235 tasks_waiting = TRUE; /* Yes */
MOVS R7,#+1
B ??OSMutexDel_6
// 236 } else {
// 237 tasks_waiting = FALSE; /* No */
??OSMutexDel_5:
MOVS R7,#+0
// 238 }
// 239 switch (opt) {
??OSMutexDel_6:
MOV R0,SP
LDRB R0,[R0, #+0]
CMP R0,#+0
BEQ ??OSMutexDel_7
CMP R0,#+1
BEQ ??OSMutexDel_8
B ??OSMutexDel_9
// 240 case OS_DEL_NO_PEND: /* Delete mutex only if no task waiting */
// 241 if (tasks_waiting == FALSE) {
??OSMutexDel_7:
CMP R7,#+0
BNE ??OSMutexDel_10
// 242 #if OS_EVENT_NAME_SIZE > 1
// 243 pevent->OSEventName[0] = '?'; /* Unknown name */
MOVS R0,#+63
STRB R0,[R4, #+16]
// 244 pevent->OSEventName[1] = OS_ASCII_NUL;
MOVS R0,#+0
STRB R0,[R4, #+17]
// 245 #endif
// 246 pip = (INT8U)(pevent->OSEventCnt >> 8);
// 247 OSTCBPrioTbl[pip] = (OS_TCB *)0; /* Free up the PIP */
LDRH R0,[R4, #+2]
LSLS R0,R0,#+16
LSRS R0,R0,#+24
LSLS R0,R0,#+2
LDR R1,??DataTable10 ;; OSTCBPrioTbl
MOVS R2,#+0
STR R2,[R1, R0]
// 248 pevent->OSEventType = OS_EVENT_TYPE_UNUSED;
STRB R2,[R4, #+0]
// 249 pevent->OSEventPtr = OSEventFreeList; /* Return Event Control Block to free list */
LDR R0,??DataTable12 ;; OSEventFreeList
LDR R0,[R0, #+0]
STR R0,[R4, #+4]
// 250 pevent->OSEventCnt = 0;
STRH R2,[R4, #+2]
// 251 OSEventFreeList = pevent;
LDR R0,??DataTable12 ;; OSEventFreeList
STR R4,[R0, #+0]
// 252 OS_EXIT_CRITICAL();
MOVS R0,R6
_BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
// 253 *err = OS_NO_ERR;
??OSMutexDel_11:
MOVS R0,#+0
STRB R0,[R5, #+0]
// 254 return ((OS_EVENT *)0); /* Mutex has been deleted */
B ??OSMutexDel_3
// 255 } else {
// 256 OS_EXIT_CRITICAL();
??OSMutexDel_10:
MOVS R0,R6
_BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
// 257 *err = OS_ERR_TASK_WAITING;
MOVS R0,#+8
B.N ??OSMutexDel_1
// 258 return (pevent);
// 259 }
// 260
// 261 case OS_DEL_ALWAYS: /* Always delete the mutex */
// 262 while (pevent->OSEventGrp != 0x00) { /* Ready ALL tasks waiting for mutex */
// 263 OS_EventTaskRdy(pevent, (void *)0, OS_STAT_MUTEX);
??OSMutexDel_12:
MOVS R2,#+16
MOVS R1,#+0
MOVS R0,R4
_BLF OS_EventTaskRdy,??OS_EventTaskRdy??rT
// 264 }
??OSMutexDel_8:
LDRB R0,[R4, #+1]
CMP R0,#+0
BNE ??OSMutexDel_12
// 265 #if OS_EVENT_NAME_SIZE > 1
// 266 pevent->OSEventName[0] = '?'; /* Unknown name */
MOVS R0,#+63
STRB R0,[R4, #+16]
// 267 pevent->OSEventName[1] = OS_ASCII_NUL;
MOVS R0,#+0
STRB R0,[R4, #+17]
// 268 #endif
// 269 pip = (INT8U)(pevent->OSEventCnt >> 8);
// 270 OSTCBPrioTbl[pip] = (OS_TCB *)0; /* Free up the PIP */
LDRH R0,[R4, #+2]
LSLS R0,R0,#+16
LSRS R0,R0,#+24
LSLS R0,R0,#+2
LDR R1,??DataTable10 ;; OSTCBPrioTbl
MOVS R2,#+0
STR R2,[R1, R0]
// 271 pevent->OSEventType = OS_EVENT_TYPE_UNUSED;
STRB R2,[R4, #+0]
// 272 pevent->OSEventPtr = OSEventFreeList; /* Return Event Control Block to free list */
LDR R0,??DataTable12 ;; OSEventFreeList
LDR R0,[R0, #+0]
STR R0,[R4, #+4]
// 273 pevent->OSEventCnt = 0;
STRH R2,[R4, #+2]
// 274 OSEventFreeList = pevent; /* Get next free event control block */
LDR R0,??DataTable12 ;; OSEventFreeList
STR R4,[R0, #+0]
// 275 OS_EXIT_CRITICAL();
MOVS R0,R6
_BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
// 276 if (tasks_waiting == TRUE) { /* Reschedule only if task(s) were waiting */
CMP R7,#+1
BNE ??OSMutexDel_11
// 277 OS_Sched(); /* Find highest priority task ready to run */
_BLF OS_Sched,??OS_Sched??rT
// 278 }
// 279 *err = OS_NO_ERR;
??OSMutexDel_13:
B.N ??OSMutexDel_11
// 280 return ((OS_EVENT *)0); /* Mutex has been deleted */
// 281
// 282 default:
// 283 OS_EXIT_CRITICAL();
??OSMutexDel_9:
MOVS R0,R6
_BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
// 284 *err = OS_ERR_INVALID_OPT;
MOVS R0,#+7
??OSMutexDel_1:
STRB R0,[R5, #+0]
// 285 return (pevent);
MOVS R0,R4
??OSMutexDel_3:
ADD SP,SP,#+4
CFI CFA R13+20
POP {R4-R7}
POP {R1}
BX R1 ;; return
CFI EndBlock cfiBlock5
// 286 }
// 287 }
RSEG CODE:CODE:NOROOT(2)
DATA
??DataTable6:
DC32 OSIntNesting
RSEG CODE:CODE:NOROOT(2)
DATA
??DataTable10:
DC32 OSTCBPrioTbl
RSEG CODE:CODE:NOROOT(2)
DATA
??DataTable12:
DC32 OSEventFreeList
RSEG CODE:CODE:NOROOT(2)
CFI Block cfiBlock6 Using cfiCommon0
CFI NoFunction
ARM
??OSMutexPend??rA:
ADD R12,PC,#+1
BX R12
CFI EndBlock cfiBlock6
REQUIRE OSMutexPend
// 288 #endif
// 289
// 290 /*$PAGE*/
// 291 /*
// 292 *********************************************************************************************************
// 293 * PEND ON MUTUAL EXCLUSION SEMAPHORE
// 294 *
// 295 * Description: This function waits for a mutual exclusion semaphore.
// 296 *
// 297 * Arguments : pevent is a pointer to the event control block associated with the desired
// 298 * mutex.
// 299 *
// 300 * timeout is an optional timeout period (in clock ticks). If non-zero, your task will
// 301 * wait for the resource up to the amount of time specified by this argument.
// 302 * If you specify 0, however, your task will wait forever at the specified
// 303 * mutex or, until the resource becomes available.
// 304 *
// 305 * err is a pointer to where an error message will be deposited. Possible error
// 306 * messages are:
// 307 * OS_NO_ERR The call was successful and your task owns the mutex
// 308 * OS_TIMEOUT The mutex was not available within the specified time.
// 309 * OS_ERR_EVENT_TYPE If you didn't pass a pointer to a mutex
// 310 * OS_ERR_PEVENT_NULL 'pevent' is a NULL pointer
// 311 * OS_ERR_PEND_ISR If you called this function from an ISR and the result
// 312 * would lead to a suspension.
// 313 *
// 314 * Returns : none
// 315 *
// 316 * Note(s) : 1) The task that owns the Mutex MUST NOT pend on any other event while it owns the mutex.
// 317 * 2) You MUST NOT change the priority of the task that owns the mutex
// 318 *********************************************************************************************************
// 319 */
RSEG CODE:CODE:NOROOT(2)
CFI Block cfiBlock7 Using cfiCommon1
CFI Function OSMutexPend
THUMB
// 320 void OSMutexPend (OS_EVENT *pevent, INT16U timeout, INT8U *err)
// 321 {
OSMutexPend:
PUSH {R1,R4-R7,LR}
CFI ?RET Frame(CFA, -4)
CFI R7 Frame(CFA, -8)
CFI R6 Frame(CFA, -12)
CFI R5 Frame(CFA, -16)
CFI R4 Frame(CFA, -20)
CFI CFA R13+24
SUB SP,SP,#+4
CFI CFA R13+28
MOVS R4,R0
MOVS R5,R2
// 322 #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
// 323 OS_CPU_SR cpu_sr;
// 324 #endif
// 325 INT8U pip; /* Priority Inheritance Priority (PIP) */
// 326 INT8U mprio; /* Mutex owner priority */
// 327 BOOLEAN rdy; /* Flag indicating task was ready */
// 328 OS_TCB *ptcb;
// 329 OS_EVENT *pevent2;
// 330 INT8U y;
// 331
// 332
// 333 if (OSIntNesting > 0) { /* See if called from ISR ... */
LDR R0,??DataTable13 ;; OSIntNesting
LDRB R0,[R0, #+0]
CMP R0,#+0
BEQ ??OSMutexPend_0
// 334 *err = OS_ERR_PEND_ISR; /* ... can't PEND from an ISR */
MOVS R0,#+2
B.N ??OSMutexPend_1
// 335 return;
// 336 }
// 337 #if OS_ARG_CHK_EN > 0
// 338 if (pevent == (OS_EVENT *)0) { /* Validate 'pevent' */
??OSMutexPend_0:
CMP R4,#+0
BNE ??OSMutexPend_2
// 339 *err = OS_ERR_PEVENT_NULL;
MOVS R0,#+4
B.N ??OSMutexPend_1
// 340 return;
// 341 }
// 342 #endif
// 343 if (pevent->OSEventType != OS_EVENT_TYPE_MUTEX) { /* Validate event block type */
??OSMutexPend_2:
LDRB R0,[R4, #+0]
CMP R0,#+4
BEQ ??OSMutexPend_3
// 344 *err = OS_ERR_EVENT_TYPE;
MOVS R0,#+1
B.N ??OSMutexPend_1
// 345 return;
// 346 }
// 347 OS_ENTER_CRITICAL(); /* Is Mutex available? */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -