📄 os_mbox.s79
字号:
CFI Block cfiBlock7 Using cfiCommon1
CFI Function OSMboxPend
THUMB
// 252 void *OSMboxPend (OS_EVENT *pevent, INT16U timeout, INT8U *err)
// 253 {
OSMboxPend:
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
MOVS R4,R0
MOVS R5,R2
// 254 #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
// 255 OS_CPU_SR cpu_sr;
// 256 #endif
// 257 void *msg;
// 258
// 259
// 260 if (OSIntNesting > 0) { /* See if called from ISR ... */
LDR R0,??DataTable7 ;; OSIntNesting
LDRB R0,[R0, #+0]
CMP R0,#+0
BEQ ??OSMboxPend_0
// 261 *err = OS_ERR_PEND_ISR; /* ... can't PEND from an ISR */
MOVS R0,#+2
B.N ??OSMboxPend_1
// 262 return ((void *)0);
// 263 }
// 264 #if OS_ARG_CHK_EN > 0
// 265 if (pevent == (OS_EVENT *)0) { /* Validate 'pevent' */
??OSMboxPend_0:
CMP R4,#+0
BNE ??OSMboxPend_2
// 266 *err = OS_ERR_PEVENT_NULL;
MOVS R0,#+4
B.N ??OSMboxPend_1
// 267 return ((void *)0);
// 268 }
// 269 #endif
// 270 if (pevent->OSEventType != OS_EVENT_TYPE_MBOX) { /* Validate event block type */
??OSMboxPend_2:
LDRB R0,[R4, #+0]
CMP R0,#+1
BEQ ??OSMboxPend_3
// 271 *err = OS_ERR_EVENT_TYPE;
MOVS R0,#+1
B.N ??OSMboxPend_1
// 272 return ((void *)0);
// 273 }
// 274 OS_ENTER_CRITICAL();
??OSMboxPend_3:
_BLF OS_CPU_SR_Save,??OS_CPU_SR_Save??rT
MOVS R6,R0
// 275 msg = pevent->OSEventPtr;
LDR R7,[R4, #+4]
// 276 if (msg != (void *)0) { /* See if there is already a message */
CMP R7,#+0
BEQ ??OSMboxPend_4
// 277 pevent->OSEventPtr = (void *)0; /* Clear the mailbox */
MOVS R0,#+0
STR R0,[R4, #+4]
// 278 OS_EXIT_CRITICAL();
??OSMboxPend_5:
MOVS R0,R6
_BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
// 279 *err = OS_NO_ERR;
MOVS R0,#+0
STRB R0,[R5, #+0]
// 280 return (msg); /* Return the message received (or NULL) */
MOVS R0,R7
B ??OSMboxPend_6
// 281 }
// 282 OSTCBCur->OSTCBStat |= OS_STAT_MBOX; /* Message not available, task will pend */
??OSMboxPend_4:
LDR R0,??OSMboxPend_7 ;; OSTCBCur
LDR R0,[R0, #+0]
ADDS R0,R0,#+44
LDR R1,??OSMboxPend_7 ;; OSTCBCur
LDR R1,[R1, #+0]
ADDS R1,R1,#+44
LDRB R1,[R1, #+0]
MOVS R2,#+2
ORRS R2,R2,R1
STRB R2,[R0, #+0]
// 283 OSTCBCur->OSTCBDly = timeout; /* Load timeout in TCB */
LDR R0,??OSMboxPend_7 ;; OSTCBCur
LDR R0,[R0, #+0]
MOV R1,SP
LDRH R1,[R1, #+0]
STRH R1,[R0, #+42]
// 284 OS_EventTaskWait(pevent); /* Suspend task until event or timeout occurs */
MOVS R0,R4
_BLF OS_EventTaskWait,??OS_EventTaskWait??rT
// 285 OS_EXIT_CRITICAL();
MOVS R0,R6
_BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
// 286 OS_Sched(); /* Find next highest priority task ready to run */
_BLF OS_Sched,??OS_Sched??rT
// 287 OS_ENTER_CRITICAL();
_BLF OS_CPU_SR_Save,??OS_CPU_SR_Save??rT
MOVS R6,R0
// 288 msg = OSTCBCur->OSTCBMsg;
LDR R0,??OSMboxPend_7 ;; OSTCBCur
LDR R0,[R0, #+0]
LDR R7,[R0, #+32]
// 289 if (msg != (void *)0) { /* See if we were given the message */
CMP R7,#+0
BEQ ??OSMboxPend_8
// 290 OSTCBCur->OSTCBMsg = (void *)0; /* Yes, clear message received */
LDR R0,??OSMboxPend_7 ;; OSTCBCur
LDR R0,[R0, #+0]
MOVS R1,#+0
STR R1,[R0, #+32]
// 291 OSTCBCur->OSTCBStat = OS_STAT_RDY;
LDR R0,??OSMboxPend_7 ;; OSTCBCur
LDR R0,[R0, #+0]
ADDS R0,R0,#+44
STRB R1,[R0, #+0]
// 292 OSTCBCur->OSTCBEventPtr = (OS_EVENT *)0; /* No longer waiting for event */
LDR R0,??OSMboxPend_7 ;; OSTCBCur
LDR R0,[R0, #+0]
STR R1,[R0, #+28]
// 293 OS_EXIT_CRITICAL();
B.N ??OSMboxPend_5
// 294 *err = OS_NO_ERR;
// 295 return (msg); /* Return the message received */
// 296 }
// 297 OS_EventTO(pevent); /* Timed out, Make task ready */
??OSMboxPend_8:
MOVS R0,R4
_BLF OS_EventTO,??OS_EventTO??rT
// 298 OS_EXIT_CRITICAL();
MOVS R0,R6
_BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
// 299 *err = OS_TIMEOUT; /* Indicate that a timeout occured */
MOVS R0,#+10
??OSMboxPend_1:
STRB R0,[R5, #+0]
// 300 return ((void *)0); /* Return a NULL message */
MOVS R0,#+0
??OSMboxPend_6:
ADD SP,SP,#+4
CFI CFA R13+20
POP {R4-R7}
POP {R1}
BX R1 ;; return
Nop
DATA
??OSMboxPend_7:
DC32 OSTCBCur
CFI EndBlock cfiBlock7
// 301 }
RSEG CODE:CODE:NOROOT(2)
DATA
??DataTable7:
DC32 OSIntNesting
RSEG CODE:CODE:NOROOT(2)
CFI Block cfiBlock8 Using cfiCommon0
CFI NoFunction
ARM
??OSMboxPost??rA:
ADD R12,PC,#+1
BX R12
CFI EndBlock cfiBlock8
REQUIRE OSMboxPost
// 302
// 303 /*
// 304 *********************************************************************************************************
// 305 * POST MESSAGE TO A MAILBOX
// 306 *
// 307 * Description: This function sends a message to a mailbox
// 308 *
// 309 * Arguments : pevent is a pointer to the event control block associated with the desired mailbox
// 310 *
// 311 * msg is a pointer to the message to send. You MUST NOT send a NULL pointer.
// 312 *
// 313 * Returns : OS_NO_ERR The call was successful and the message was sent
// 314 * OS_MBOX_FULL If the mailbox already contains a message. You can can only send one
// 315 * message at a time and thus, the message MUST be consumed before you
// 316 * are allowed to send another one.
// 317 * OS_ERR_EVENT_TYPE If you are attempting to post to a non mailbox.
// 318 * OS_ERR_PEVENT_NULL If 'pevent' is a NULL pointer
// 319 * OS_ERR_POST_NULL_PTR If you are attempting to post a NULL pointer
// 320 *********************************************************************************************************
// 321 */
// 322
// 323 #if OS_MBOX_POST_EN > 0
RSEG CODE:CODE:NOROOT(2)
CFI Block cfiBlock9 Using cfiCommon1
CFI Function OSMboxPost
THUMB
// 324 INT8U OSMboxPost (OS_EVENT *pevent, void *msg)
// 325 {
OSMboxPost:
PUSH {R4-R6,LR}
CFI ?RET Frame(CFA, -4)
CFI R6 Frame(CFA, -8)
CFI R5 Frame(CFA, -12)
CFI R4 Frame(CFA, -16)
CFI CFA R13+16
MOVS R4,R0
MOVS R5,R1
// 326 #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
// 327 OS_CPU_SR cpu_sr;
// 328 #endif
// 329
// 330
// 331 #if OS_ARG_CHK_EN > 0
// 332 if (pevent == (OS_EVENT *)0) { /* Validate 'pevent' */
CMP R4,#+0
BNE ??OSMboxPost_0
// 333 return (OS_ERR_PEVENT_NULL);
MOVS R0,#+4
B ??OSMboxPost_1
// 334 }
// 335 if (msg == (void *)0) { /* Make sure we are not posting a NULL pointer */
??OSMboxPost_0:
CMP R5,#+0
BNE ??OSMboxPost_2
// 336 return (OS_ERR_POST_NULL_PTR);
MOVS R0,#+3
B ??OSMboxPost_1
// 337 }
// 338 #endif
// 339 if (pevent->OSEventType != OS_EVENT_TYPE_MBOX) { /* Validate event block type */
??OSMboxPost_2:
LDRB R0,[R4, #+0]
CMP R0,#+1
BEQ ??OSMboxPost_3
// 340 return (OS_ERR_EVENT_TYPE);
MOVS R0,#+1
B ??OSMboxPost_1
// 341 }
// 342 OS_ENTER_CRITICAL();
??OSMboxPost_3:
_BLF OS_CPU_SR_Save,??OS_CPU_SR_Save??rT
MOVS R6,R0
// 343 if (pevent->OSEventGrp != 0x00) { /* See if any task pending on mailbox */
LDRB R0,[R4, #+1]
CMP R0,#+0
BEQ ??OSMboxPost_4
// 344 OS_EventTaskRdy(pevent, msg, OS_STAT_MBOX); /* Ready highest priority task waiting on event */
MOVS R2,#+2
MOVS R1,R5
MOVS R0,R4
_BLF OS_EventTaskRdy,??OS_EventTaskRdy??rT
// 345 OS_EXIT_CRITICAL();
MOVS R0,R6
_BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
// 346 OS_Sched(); /* Find highest priority task ready to run */
_BLF OS_Sched,??OS_Sched??rT
// 347 return (OS_NO_ERR);
B.N ??OSMboxPost_5
// 348 }
// 349 if (pevent->OSEventPtr != (void *)0) { /* Make sure mailbox doesn't already have a msg */
??OSMboxPost_4:
LDR R0,[R4, #+4]
CMP R0,#+0
BEQ ??OSMboxPost_6
// 350 OS_EXIT_CRITICAL();
MOVS R0,R6
_BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
// 351 return (OS_MBOX_FULL);
MOVS R0,#+20
B ??OSMboxPost_1
// 352 }
// 353 pevent->OSEventPtr = msg; /* Place message in mailbox */
??OSMboxPost_6:
STR R5,[R4, #+4]
// 354 OS_EXIT_CRITICAL();
MOVS R0,R6
_BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
// 355 return (OS_NO_ERR);
??OSMboxPost_5:
MOVS R0,#+0
??OSMboxPost_1:
POP {R4-R6}
POP {R1}
BX R1 ;; return
CFI EndBlock cfiBlock9
// 356 }
RSEG CODE:CODE:NOROOT(2)
CFI Block cfiBlock10 Using cfiCommon0
CFI NoFunction
ARM
??OSMboxPostOpt??rA:
ADD R12,PC,#+1
BX R12
CFI EndBlock cfiBlock10
REQUIRE OSMboxPostOpt
// 357 #endif
// 358
// 359
// 360 /*
// 361 *********************************************************************************************************
// 362 * POST MESSAGE TO A MAILBOX
// 363 *
// 364 * Description: This function sends a message to a mailbox
// 365 *
// 366 * Arguments : pevent is a pointer to the event control block associated with the desired mailbox
// 367 *
// 368 * msg is a pointer to the message to send. You MUST NOT send a NULL pointer.
// 369 *
// 370 * opt determines the type of POST performed:
// 371 * OS_POST_OPT_NONE POST to a single waiting task
// 372 * (Identical to OSMboxPost())
// 373 * OS_POST_OPT_BROADCAST POST to ALL tasks that are waiting on the mailbox
// 374 *
// 375 * Returns : OS_NO_ERR The call was successful and the message was sent
// 376 * OS_MBOX_FULL If the mailbox already contains a message. You can can only send one
// 377 * message at a time and thus, the message MUST be consumed before you
// 378 * are allowed to send another one.
// 379 * OS_ERR_EVENT_TYPE If you are attempting to post to a non mailbox.
// 380 * OS_ERR_PEVENT_NULL If 'pevent' is a NULL pointer
// 381 * OS_ERR_POST_NULL_PTR If you are attempting to post a NULL pointer
// 382 *
// 383 * Warning : Interrupts can be disabled for a long time if you do a 'broadcast'. In fact, the
// 384 * interrupt disable time is proportional to the number of tasks waiting on the mailbox.
// 385 *********************************************************************************************************
// 386 */
// 387
// 388 #if OS_MBOX_POST_OPT_EN > 0
RSEG CODE:CODE:NOROOT(2)
CFI Block cfiBlock11 Using cfiCommon1
CFI Function OSMboxPostOpt
THUMB
// 389 INT8U OSMboxPostOpt (OS_EVENT *pevent, void *msg, INT8U opt)
// 390 {
OSMboxPostOpt:
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
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -