📄 os_sem.s79
字号:
// 209 pevent->OSEventPtr = OSEventFreeList; /* Return Event Control Block to free list */
LDR R0,??DataTable6 ;; OSEventFreeList
LDR R0,[R0, #+0]
STR R0,[R4, #+4]
// 210 pevent->OSEventCnt = 0;
MOVS R0,#+0
STRH R0,[R4, #+2]
// 211 OSEventFreeList = pevent; /* Get next free event control block */
LDR R0,??DataTable6 ;; OSEventFreeList
STR R4,[R0, #+0]
// 212 OS_EXIT_CRITICAL();
MOVS R0,R6
_BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
// 213 if (tasks_waiting == TRUE) { /* Reschedule only if task(s) were waiting */
CMP R7,#+1
BNE ??OSSemDel_11
// 214 OS_Sched(); /* Find highest priority task ready to run */
_BLF OS_Sched,??OS_Sched??rT
// 215 }
// 216 *err = OS_NO_ERR;
??OSSemDel_13:
B.N ??OSSemDel_11
// 217 return ((OS_EVENT *)0); /* Semaphore has been deleted */
// 218
// 219 default:
// 220 OS_EXIT_CRITICAL();
??OSSemDel_9:
MOVS R0,R6
_BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
// 221 *err = OS_ERR_INVALID_OPT;
MOVS R0,#+7
??OSSemDel_1:
STRB R0,[R5, #+0]
// 222 return (pevent);
MOVS R0,R4
??OSSemDel_3:
ADD SP,SP,#+4
CFI CFA R13+20
POP {R4-R7}
POP {R1}
BX R1 ;; return
CFI EndBlock cfiBlock5
// 223 }
// 224 }
RSEG CODE:CODE:NOROOT(2)
DATA
??DataTable6:
DC32 OSEventFreeList
RSEG CODE:CODE:NOROOT(2)
CFI Block cfiBlock6 Using cfiCommon0
CFI NoFunction
ARM
??OSSemPend??rA:
ADD R12,PC,#+1
BX R12
CFI EndBlock cfiBlock6
REQUIRE OSSemPend
// 225 #endif
// 226
// 227 /*$PAGE*/
// 228 /*
// 229 *********************************************************************************************************
// 230 * PEND ON SEMAPHORE
// 231 *
// 232 * Description: This function waits for a semaphore.
// 233 *
// 234 * Arguments : pevent is a pointer to the event control block associated with the desired
// 235 * semaphore.
// 236 *
// 237 * timeout is an optional timeout period (in clock ticks). If non-zero, your task will
// 238 * wait for the resource up to the amount of time specified by this argument.
// 239 * If you specify 0, however, your task will wait forever at the specified
// 240 * semaphore or, until the resource becomes available (or the event occurs).
// 241 *
// 242 * err is a pointer to where an error message will be deposited. Possible error
// 243 * messages are:
// 244 *
// 245 * OS_NO_ERR The call was successful and your task owns the resource
// 246 * or, the event you are waiting for occurred.
// 247 * OS_TIMEOUT The semaphore was not received within the specified
// 248 * timeout.
// 249 * OS_ERR_EVENT_TYPE If you didn't pass a pointer to a semaphore.
// 250 * OS_ERR_PEND_ISR If you called this function from an ISR and the result
// 251 * would lead to a suspension.
// 252 * OS_ERR_PEVENT_NULL If 'pevent' is a NULL pointer.
// 253 *
// 254 * Returns : none
// 255 *********************************************************************************************************
// 256 */
// 257
RSEG CODE:CODE:NOROOT(2)
CFI Block cfiBlock7 Using cfiCommon1
CFI Function OSSemPend
THUMB
// 258 void OSSemPend (OS_EVENT *pevent, INT16U timeout, INT8U *err)
// 259 {
OSSemPend:
PUSH {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+20
MOVS R4,R0
MOVS R5,R1
MOVS R6,R2
// 260 #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
// 261 OS_CPU_SR cpu_sr;
// 262 #endif
// 263
// 264
// 265 if (OSIntNesting > 0) { /* See if called from ISR ... */
LDR R0,??DataTable7 ;; OSIntNesting
LDRB R0,[R0, #+0]
CMP R0,#+0
BEQ ??OSSemPend_0
// 266 *err = OS_ERR_PEND_ISR; /* ... can't PEND from an ISR */
MOVS R0,#+2
B.N ??OSSemPend_1
// 267 return;
// 268 }
// 269 #if OS_ARG_CHK_EN > 0
// 270 if (pevent == (OS_EVENT *)0) { /* Validate 'pevent' */
??OSSemPend_0:
CMP R4,#+0
BNE ??OSSemPend_2
// 271 *err = OS_ERR_PEVENT_NULL;
MOVS R0,#+4
B.N ??OSSemPend_1
// 272 return;
// 273 }
// 274 #endif
// 275 if (pevent->OSEventType != OS_EVENT_TYPE_SEM) { /* Validate event block type */
??OSSemPend_2:
LDRB R0,[R4, #+0]
CMP R0,#+3
BEQ ??OSSemPend_3
// 276 *err = OS_ERR_EVENT_TYPE;
MOVS R0,#+1
B.N ??OSSemPend_1
// 277 return;
// 278 }
// 279 OS_ENTER_CRITICAL();
??OSSemPend_3:
_BLF OS_CPU_SR_Save,??OS_CPU_SR_Save??rT
MOVS R7,R0
// 280 if (pevent->OSEventCnt > 0) { /* If sem. is positive, resource available ... */
LDRH R0,[R4, #+2]
CMP R0,#+0
BEQ ??OSSemPend_4
// 281 pevent->OSEventCnt--; /* ... decrement semaphore only if positive. */
SUBS R0,R0,#+1
STRH R0,[R4, #+2]
// 282 OS_EXIT_CRITICAL();
MOVS R0,R7
_BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
// 283 *err = OS_NO_ERR;
MOVS R0,#+0
B.N ??OSSemPend_1
// 284 return;
// 285 }
// 286 /* Otherwise, must wait until event occurs */
// 287 OSTCBCur->OSTCBStat |= OS_STAT_SEM; /* Resource not available, pend on semaphore */
??OSSemPend_4:
LDR R0,??OSSemPend_5 ;; OSTCBCur
LDR R0,[R0, #+0]
ADDS R0,R0,#+44
LDR R1,??OSSemPend_5 ;; OSTCBCur
LDR R1,[R1, #+0]
ADDS R1,R1,#+44
LDRB R1,[R1, #+0]
MOVS R2,#+1
ORRS R2,R2,R1
STRB R2,[R0, #+0]
// 288 OSTCBCur->OSTCBDly = timeout; /* Store pend timeout in TCB */
LDR R0,??OSSemPend_5 ;; OSTCBCur
LDR R0,[R0, #+0]
STRH R5,[R0, #+42]
// 289 OS_EventTaskWait(pevent); /* Suspend task until event or timeout occurs */
MOVS R0,R4
_BLF OS_EventTaskWait,??OS_EventTaskWait??rT
// 290 OS_EXIT_CRITICAL();
MOVS R0,R7
_BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
// 291 OS_Sched(); /* Find next highest priority task ready */
_BLF OS_Sched,??OS_Sched??rT
// 292 OS_ENTER_CRITICAL();
_BLF OS_CPU_SR_Save,??OS_CPU_SR_Save??rT
MOVS R7,R0
// 293 if (OSTCBCur->OSTCBStat & OS_STAT_SEM) { /* Must have timed out if still waiting for event*/
LDR R0,??OSSemPend_5 ;; OSTCBCur
LDR R0,[R0, #+0]
ADDS R0,R0,#+44
LDRB R0,[R0, #+0]
LSLS R0,R0,#+31
BPL ??OSSemPend_6
// 294 OS_EventTO(pevent);
MOVS R0,R4
_BLF OS_EventTO,??OS_EventTO??rT
// 295 OS_EXIT_CRITICAL();
MOVS R0,R7
_BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
// 296 *err = OS_TIMEOUT; /* Indicate that didn't get event within TO */
MOVS R0,#+10
B.N ??OSSemPend_1
// 297 return;
// 298 }
// 299 OSTCBCur->OSTCBEventPtr = (OS_EVENT *)0;
??OSSemPend_6:
LDR R0,??OSSemPend_5 ;; OSTCBCur
LDR R0,[R0, #+0]
MOVS R1,#+0
STR R1,[R0, #+28]
// 300 OS_EXIT_CRITICAL();
MOVS R0,R7
_BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
// 301 *err = OS_NO_ERR;
MOVS R0,#+0
??OSSemPend_1:
STRB R0,[R6, #+0]
// 302 }
POP {R4-R7}
POP {R0}
BX R0 ;; return
DATA
??OSSemPend_5:
DC32 OSTCBCur
CFI EndBlock cfiBlock7
RSEG CODE:CODE:NOROOT(2)
DATA
??DataTable7:
DC32 OSIntNesting
RSEG CODE:CODE:NOROOT(2)
CFI Block cfiBlock8 Using cfiCommon0
CFI NoFunction
ARM
??OSSemPost??rA:
ADD R12,PC,#+1
BX R12
CFI EndBlock cfiBlock8
REQUIRE OSSemPost
// 303 /*$PAGE*/
// 304 /*
// 305 *********************************************************************************************************
// 306 * POST TO A SEMAPHORE
// 307 *
// 308 * Description: This function signals a semaphore
// 309 *
// 310 * Arguments : pevent is a pointer to the event control block associated with the desired
// 311 * semaphore.
// 312 *
// 313 * Returns : OS_NO_ERR The call was successful and the semaphore was signaled.
// 314 * OS_SEM_OVF If the semaphore count exceeded its limit. In other words, you have
// 315 * signalled the semaphore more often than you waited on it with either
// 316 * OSSemAccept() or OSSemPend().
// 317 * OS_ERR_EVENT_TYPE If you didn't pass a pointer to a semaphore
// 318 * OS_ERR_PEVENT_NULL If 'pevent' is a NULL pointer.
// 319 *********************************************************************************************************
// 320 */
// 321
RSEG CODE:CODE:NOROOT(2)
CFI Block cfiBlock9 Using cfiCommon1
CFI Function OSSemPost
THUMB
// 322 INT8U OSSemPost (OS_EVENT *pevent)
// 323 {
OSSemPost:
PUSH {R4,R5,LR}
CFI ?RET Frame(CFA, -4)
CFI R5 Frame(CFA, -8)
CFI R4 Frame(CFA, -12)
CFI CFA R13+12
MOVS R4,R0
// 324 #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
// 325 OS_CPU_SR cpu_sr;
// 326 #endif
// 327
// 328
// 329 #if OS_ARG_CHK_EN > 0
// 330 if (pevent == (OS_EVENT *)0) { /* Validate 'pevent' */
BNE ??OSSemPost_0
// 331 return (OS_ERR_PEVENT_NULL);
MOVS R0,#+4
B ??OSSemPost_1
// 332 }
// 333 #endif
// 334 if (pevent->OSEventType != OS_EVENT_TYPE_SEM) { /* Validate event block type */
??OSSemPost_0:
LDRB R0,[R4, #+0]
CMP R0,#+3
BEQ ??OSSemPost_2
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -