📄 os_q.lst
字号:
\ 0232 1C420000 MOV &OSTCBCur,R12
\ 0236 8C4E1A00 MOV R14,26(R12)
360 OS_EventTaskWait(pevent); /* Suspend task until event or timeout occurs */
\ 023A 0C4A MOV R10,R12
\ 023C B0120000 CALL #OS_EventTaskWait
361 OS_EXIT_CRITICAL();
\ 0240 32D2 EINT
362 OS_Sched(); /* Find next highest priority task ready to run */
\ 0242 B0120000 CALL #OS_Sched
363 OS_ENTER_CRITICAL();
\ 0246 32C2 DINT
364 msg = OSTCBCur->OSTCBMsg;
\ 0248 1D420000 MOV &OSTCBCur,R13
\ 024C 1C4D1400 MOV 20(R13),R12
365 if (msg != (void *)0) { /* Did we get a message? */
\ 0250 0C93 CMP #0,R12
\ 0252 1024 JEQ (?0115)
366 OSTCBCur->OSTCBMsg = (void *)0; /* Extract message from TCB (Put there by QPost) */
\ 0254 1D420000 MOV &OSTCBCur,R13
\ 0258 8D431400 MOV #0,20(R13)
367 OSTCBCur->OSTCBStat = OS_STAT_RDY;
\ 025C 1D420000 MOV &OSTCBCur,R13
\ 0260 CD431C00 MOV.B #0,28(R13)
368 OSTCBCur->OSTCBEventPtr = (OS_EVENT *)0; /* No longer waiting for event */
\ 0264 1D420000 MOV &OSTCBCur,R13
\ 0268 8D431200 MOV #0,18(R13)
369 OS_EXIT_CRITICAL();
\ 026C 32D2 EINT
370 *err = OS_NO_ERR;
\ 026E CB430000 MOV.B #0,0(R11)
371 return (msg); /* Return message received */
372 }
\ 0272 083C JMP (?0116)
\ 0274 ?0115:
373 OS_EventTO(pevent); /* Timed out */
\ 0274 0C4A MOV R10,R12
\ 0276 B0120000 CALL #OS_EventTO
374 OS_EXIT_CRITICAL();
\ 027A 32D2 EINT
375 *err = OS_TIMEOUT; /* Indicate a timeout occured */
\ 027C FB400A00 MOV.B #10,0(R11)
\ 0280 0000
376 return ((void *)0); /* No message received */
\ 0282 0C43 MOV #0,R12
377 }
\ 0284 ?0116:
\ 0284 3B41 POP R11
\ 0286 3A41 POP R10
\ 0288 3041 RET
\ 028A OSQPost:
378 /*$PAGE*/
379 /*
380 *********************************************************************************************************
381 * POST MESSAGE TO A QUEUE
382 *
383 * Description: This function sends a message to a queue
384 *
385 * Arguments : pevent is a pointer to the event control block associated with the desired queue
386 *
387 * msg is a pointer to the message to send. You MUST NOT send a NULL pointer.
388 *
389 * Returns : OS_NO_ERR The call was successful and the message was sent
390 * OS_Q_FULL If the queue cannot accept any more messages because it is full.
391 * OS_ERR_EVENT_TYPE If you didn't pass a pointer to a queue.
392 * OS_ERR_PEVENT_NULL If 'pevent' is a NULL pointer
393 * OS_ERR_POST_NULL_PTR If you are attempting to post a NULL pointer
394 *********************************************************************************************************
395 */
396
397 #if OS_Q_POST_EN > 0
398 INT8U OSQPost (OS_EVENT *pevent, void *msg)
399 {
400 #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
401 OS_CPU_SR cpu_sr;
402 #endif
403 OS_Q *pq;
404
405
406 #if OS_ARG_CHK_EN > 0
407 if (pevent == (OS_EVENT *)0) { /* Validate 'pevent' */
\ 028A 0C93 CMP #0,R12
\ 028C 0220 JNE (?0118)
408 return (OS_ERR_PEVENT_NULL);
\ 028E 6C42 MOV.B #4,R12
409 }
\ 0290 3041 RET
\ 0292 ?0118:
410 if (msg == (void *)0) { /* Make sure we are not posting a NULL pointer */
\ 0292 0E93 CMP #0,R14
\ 0294 0320 JNE (?0120)
411 return (OS_ERR_POST_NULL_PTR);
\ 0296 7C400300 MOV.B #3,R12
412 }
\ 029A 3041 RET
\ 029C ?0120:
413 if (pevent->OSEventType != OS_EVENT_TYPE_Q) { /* Validate event block type */
\ 029C 6D43 MOV.B #2,R13
\ 029E 6D9C CMP.B @R12,R13
\ 02A0 0224 JEQ (?0122)
414 return (OS_ERR_EVENT_TYPE);
\ 02A2 5C43 MOV.B #1,R12
415 }
\ 02A4 3041 RET
\ 02A6 ?0122:
416 #endif
417 OS_ENTER_CRITICAL();
\ 02A6 32C2 DINT
418 if (pevent->OSEventGrp != 0x00) { /* See if any task pending on queue */
\ 02A8 CC930100 CMP.B #0,1(R12)
\ 02AC 0A24 JEQ (?0124)
419 OS_EventTaskRdy(pevent, msg, OS_STAT_Q); /* Ready highest priority task waiting on event */
\ 02AE 70120400 PUSH.B #4
\ 02B2 B0120000 CALL #OS_EventTaskRdy
\ 02B6 2153 ADD #2,SP
420 OS_EXIT_CRITICAL();
\ 02B8 32D2 EINT
421 OS_Sched(); /* Find highest priority task ready to run */
\ 02BA B0120000 CALL #OS_Sched
422 return (OS_NO_ERR);
\ 02BE 4C43 MOV.B #0,R12
423 }
\ 02C0 3041 RET
\ 02C2 ?0124:
424 pq = (OS_Q *)pevent->OSEventPtr; /* Point to queue control block */
\ 02C2 1D4C0400 MOV 4(R12),R13
425 if (pq->OSQEntries >= pq->OSQSize) { /* Make sure queue is not full */
\ 02C6 9D9D0A00 CMP 10(R13),12(R13)
\ 02CA 0C00
\ 02CC 0428 JNC (?0126)
426 OS_EXIT_CRITICAL();
\ 02CE 32D2 EINT
427 return (OS_Q_FULL);
\ 02D0 7C401E00 MOV.B #30,R12
428 }
\ 02D4 3041 RET
\ 02D6 ?0126:
429 *pq->OSQIn++ = msg; /* Insert message into queue */
\ 02D6 1C4D0600 MOV 6(R13),R12
\ 02DA AD530600 ADD #2,6(R13)
\ 02DE 8C4E0000 MOV R14,0(R12)
430 pq->OSQEntries++; /* Update the nbr of entries in the queue */
\ 02E2 9D530C00 ADD #1,12(R13)
431 if (pq->OSQIn == pq->OSQEnd) { /* Wrap IN ptr if we are at end of queue */
\ 02E6 9D9D0600 CMP 6(R13),4(R13)
\ 02EA 0400
\ 02EC 0320 JNE (?0128)
432 pq->OSQIn = pq->OSQStart;
\ 02EE 9D4D0200 MOV 2(R13),6(R13)
\ 02F2 0600
\ 02F4 ?0128:
433 }
434 OS_EXIT_CRITICAL();
\ 02F4 32D2 EINT
435 return (OS_NO_ERR);
\ 02F6 4C43 MOV.B #0,R12
436 }
\ 02F8 3041 RET
\ 02FA OSQPostFront:
437 #endif
438 /*$PAGE*/
439 /*
440 *********************************************************************************************************
441 * POST MESSAGE TO THE FRONT OF A QUEUE
442 *
443 * Description: This function sends a message to a queue but unlike OSQPost(), the message is posted at
444 * the front instead of the end of the queue. Using OSQPostFront() allows you to send
445 * 'priority' messages.
446 *
447 * Arguments : pevent is a pointer to the event control block associated with the desired queue
448 *
449 * msg is a pointer to the message to send. You MUST NOT send a NULL pointer.
450 *
451 * Returns : OS_NO_ERR The call was successful and the message was sent
452 * OS_Q_FULL If the queue cannot accept any more messages because it is full.
453 * OS_ERR_EVENT_TYPE If you didn't pass a pointer to a queue.
454 * OS_ERR_PEVENT_NULL If 'pevent' is a NULL pointer
455 * OS_ERR_POST_NULL_PTR If you are attempting to post to a non queue.
456 *********************************************************************************************************
457 */
458
459 #if OS_Q_POST_FRONT_EN > 0
460 INT8U OSQPostFront (OS_EVENT *pevent, void *msg)
461 {
462 #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
463 OS_CPU_SR cpu_sr;
464 #endif
465 OS_Q *pq;
466
467
468 #if OS_ARG_CHK_EN > 0
469 if (pevent == (OS_EVENT *)0) { /* Validate 'pevent' */
\ 02FA 0C93 CMP #0,R12
\ 02FC 0220 JNE (?0131)
470 return (OS_ERR_PEVENT_NULL);
\ 02FE 6C42 MOV.B #4,R12
471 }
\ 0300 3041 RET
\ 0302 ?0131:
472 if (msg == (void *)0) { /* Make sure we are not posting a NULL pointer */
\ 0302 0E93 CMP #0,R14
\ 0304 0320 JNE (?0133)
473 return (OS_ERR_POST_NULL_PTR);
\ 0306 7C400300 MOV.B #3,R12
474 }
\ 030A 3041 RET
\ 030C ?0133:
475 if (pevent->OSEventType != OS_EVENT_TYPE_Q) { /* Validate event block type */
\ 030C 6D43 MOV.B #2,R13
\ 030E 6D9C CMP.B @R12,R13
\ 0310 0224 JEQ (?0135)
476 return (OS_ERR_EVENT_TYPE);
\ 0312 5C43 MOV.B #1,R12
477 }
\ 0314 3041 RET
\ 0316 ?0135:
478 #endif
479 OS_ENTER_CRITICAL();
\ 0316 32C2 DINT
480 if (pevent->OSEventGrp != 0x00) { /* See if any task pending on queue */
\ 0318 CC930100 CMP.B #0,1(R12)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -