📄 os_flag.s43
字号:
MOV 4(R11),R13
XOR #-1,R13
AND R14,R13
; 446. if (flags_rdy == flags) { /* Must match ALL the bits that we want */
CMP R13,R14
JNE (?0141)
; 447. if (consume == TRUE) { /* See if we need to consume the flags */
CMP.B #1,R9
JNE (?0143)
; 448. pgrp->OSFlagFlags |= flags_rdy; /* Set ONLY the flags that we wanted */
BIS R13,4(R11)
?0143:
; 449. }
; 450. flags_cur = pgrp->OSFlagFlags; /* Will return the state of the group */
MOV 4(R11),R12
; 451. OS_EXIT_CRITICAL(); /* Yes, condition met, return to caller */
EINT
; 452. *err = OS_NO_ERR;
MOV.B #0,0(R8)
; 453. return (flags_cur);
; 454. } else { /* Block task until events occur or timeout */
JMP (?0152)
?0141:
; 455. OS_FlagBlock(pgrp, &node, flags, wait_type, timeout);
PUSH R12
PUSH.B R10
PUSH R14
MOV SP,R14
ADD #6,R14
MOV R11,R12
CALL #OS_FlagBlock
ADD #6,SP
; 456. OS_EXIT_CRITICAL();
EINT
; 457. }
; 458. break;
JMP (?0128)
?0144:
; 459.
; 460. case OS_FLAG_WAIT_CLR_ANY:
; 461. flags_rdy = ~pgrp->OSFlagFlags & flags; /* Extract only the bits we want */
MOV 4(R11),R13
XOR #-1,R13
AND R14,R13
; 462. if (flags_rdy != (OS_FLAGS)0) { /* See if any flag cleared */
JEQ (?0146)
; 463. if (consume == TRUE) { /* See if we need to consume the flags */
CMP.B #1,R9
JNE (?0148)
; 464. pgrp->OSFlagFlags |= flags_rdy; /* Set ONLY the flags that we got */
BIS R13,4(R11)
?0148:
; 465. }
; 466. flags_cur = pgrp->OSFlagFlags; /* Will return the state of the group */
MOV 4(R11),R12
; 467. OS_EXIT_CRITICAL(); /* Yes, condition met, return to caller */
EINT
; 468. *err = OS_NO_ERR;
MOV.B #0,0(R8)
; 469. return (flags_cur);
; 470. } else { /* Block task until events occur or timeout */
JMP (?0152)
?0146:
; 471. OS_FlagBlock(pgrp, &node, flags, wait_type, timeout);
PUSH R12
PUSH.B R10
PUSH R14
MOV SP,R14
ADD #6,R14
MOV R11,R12
CALL #OS_FlagBlock
ADD #6,SP
; 472. OS_EXIT_CRITICAL();
EINT
; 473. }
; 474. break;
JMP (?0128)
?0149:
; 475. #endif
; 476.
; 477. default:
; 478. OS_EXIT_CRITICAL();
EINT
; 479. flags_cur = (OS_FLAGS)0;
MOV #0,R12
; 480. *err = OS_FLAG_ERR_WAIT_TYPE;
MOV.B #151,0(R8)
; 481. return (flags_cur);
; 482. }
JMP (?0152)
?0128:
; 483. OS_Sched(); /* Find next HPT ready to run */
CALL #OS_Sched
; 484. OS_ENTER_CRITICAL();
DINT
; 485. if (OSTCBCur->OSTCBStat & OS_STAT_FLAG) { /* Have we timed-out? */
MOV &OSTCBCur,R12
BIT.B #32,28(R12)
JEQ (?0151)
; 486. OS_FlagUnlink(&node);
MOV SP,R12
CALL #OS_FlagUnlink
; 487. OSTCBCur->OSTCBStat = OS_STAT_RDY; /* Yes, make task ready-to-run */
MOV &OSTCBCur,R12
MOV.B #0,28(R12)
; 488. OS_EXIT_CRITICAL();
EINT
; 489. flags_cur = (OS_FLAGS)0;
MOV #0,R12
; 490. *err = OS_TIMEOUT; /* Indicate that we timed-out waiting */
MOV.B #10,0(R8)
; 491. } else {
JMP (?0152)
?0151:
; 492. if (consume == TRUE) { /* See if we need to consume the flags */
CMP.B #1,R9
JNE (?0155)
; 493. switch (wait_type) {
CMP #4,R10
JC (?0155)
ADD R10,R10
BR ?0219(R10)
?0219:
DW ?0157
DW ?0157
DW ?0156
DW ?0156
?0156:
; 494. case OS_FLAG_WAIT_SET_ALL:
; 495. case OS_FLAG_WAIT_SET_ANY: /* Clear ONLY the flags we got */
; 496. pgrp->OSFlagFlags &= ~OSTCBCur->OSTCBFlagsRdy;
MOV &OSTCBCur,R12
MOV 24(R12),R12
XOR #-1,R12
AND R12,4(R11)
; 497. break;
JMP (?0155)
?0157:
; 498.
; 499. #if OS_FLAG_WAIT_CLR_EN > 0
; 500. case OS_FLAG_WAIT_CLR_ALL:
; 501. case OS_FLAG_WAIT_CLR_ANY: /* Set ONLY the flags we got */
; 502. pgrp->OSFlagFlags |= OSTCBCur->OSTCBFlagsRdy;
MOV &OSTCBCur,R12
BIS 24(R12),4(R11)
; 503. break;
?0155:
; 504. #endif
; 505. }
; 506. }
; 507. flags_cur = pgrp->OSFlagFlags;
MOV 4(R11),R12
; 508. OS_EXIT_CRITICAL();
EINT
; 509. *err = OS_NO_ERR; /* Event(s) must have occurred */
MOV.B #0,0(R8)
?0152:
; 510. }
; 511. return (flags_cur);
; 512. }
ADD #12,SP
POP R9
POP R8
POP R11
POP R10
RET
OSFlagPost:
; 513. /*$PAGE*/
; 514. /*
; 515. *********************************************************************************************************
; 516. * POST EVENT FLAG BIT(S)
; 517. *
; 518. * Description: This function is called to set or clear some bits in an event flag group. The bits to
; 519. * set or clear are specified by a 'bit mask'.
; 520. *
; 521. * Arguments : pgrp is a pointer to the desired event flag group.
; 522. *
; 523. * flags If 'opt' (see below) is OS_FLAG_SET, each bit that is set in 'flags' will
; 524. * set the corresponding bit in the event flag group. e.g. to set bits 0, 4
; 525. * and 5 you would set 'flags' to:
; 526. *
; 527. * 0x31 (note, bit 0 is least significant bit)
; 528. *
; 529. * If 'opt' (see below) is OS_FLAG_CLR, each bit that is set in 'flags' will
; 530. * CLEAR the corresponding bit in the event flag group. e.g. to clear bits 0,
; 531. * 4 and 5 you would specify 'flags' as:
; 532. *
; 533. * 0x31 (note, bit 0 is least significant bit)
; 534. *
; 535. * opt indicates whether the flags will be:
; 536. * set (OS_FLAG_SET) or
; 537. * cleared (OS_FLAG_CLR)
; 538. *
; 539. * err is a pointer to an error code and can be:
; 540. * OS_NO_ERR The call was successfull
; 541. * OS_FLAG_INVALID_PGRP You passed a NULL pointer
; 542. * OS_ERR_EVENT_TYPE You are not pointing to an event flag group
; 543. * OS_FLAG_INVALID_OPT You specified an invalid option
; 544. *
; 545. * Returns : the new value of the event flags bits that are still set.
; 546. *
; 547. * Called From: Task or ISR
; 548. *
; 549. * WARNING(s) : 1) The execution time of this function depends on the number of tasks waiting on the event
; 550. * flag group.
; 551. * 2) The amount of time interrupts are DISABLED depends on the number of tasks waiting on
; 552. * the event flag group.
; 553. *********************************************************************************************************
; 554. */
; 555. OS_FLAGS OSFlagPost (OS_FLAG_GRP *pgrp, OS_FLAGS flags, INT8U opt, INT8U *err)
; 556. {
PUSH R10
PUSH R11
PUSH R8
PUSH R9
MOV R12,R10
MOV.B 10(SP),R12
MOV 12(SP),R11
; 557. #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
; 558. OS_CPU_SR cpu_sr;
; 559. #endif
; 560. OS_FLAG_NODE *pnode;
; 561. BOOLEAN sched;
; 562. OS_FLAGS flags_cur;
; 563. OS_FLAGS flags_rdy;
; 564.
; 565.
; 566. #if OS_ARG_CHK_EN > 0
; 567. if (pgrp == (OS_FLAG_GRP *)0) { /* Validate 'pgrp' */
CMP #0,R10
JNE (?0160)
; 568. *err = OS_FLAG_INVALID_PGRP;
MOV.B #150,0(R11)
; 569. return ((OS_FLAGS)0);
MOV #0,R12
; 570. }
JMP (?0193)
?0160:
; 571. if (pgrp->OSFlagType != OS_EVENT_TYPE_FLAG) { /* Make sure we are pointing to an event flag grp */
MOV.B #5,R13
CMP.B @R10,R13
JEQ (?0162)
; 572. *err = OS_ERR_EVENT_TYPE;
MOV.B #1,0(R11)
; 573. return ((OS_FLAGS)0);
MOV #0,R12
; 574. }
JMP (?0193)
?0162:
; 575. #endif
; 576. /*$PAGE*/
; 577. OS_ENTER_CRITICAL();
DINT
; 578. switch (opt) {
SUB.B #0,R12
JEQ (?0164)
SUB.B #1,R12
JEQ (?0165)
JMP (?0166)
?0164:
; 579. case OS_FLAG_CLR:
; 580. pgrp->OSFlagFlags &= ~flags; /* Clear the flags specified in the group */
XOR #-1,R14
AND R14,4(R10)
; 581. break;
JMP (?0163)
?0165:
; 582.
; 583. case OS_FLAG_SET:
; 584. pgrp->OSFlagFlags |= flags; /* Set the flags specified in the group */
BIS R14,4(R10)
; 585. break;
JMP (?0163)
?0166:
; 586.
; 587. default:
; 588. OS_EXIT_CRITICAL(); /* INVALID option */
EINT
; 589. *err = OS_FLAG_INVALID_OPT;
MOV.B #153,0(R11)
; 590. return ((OS_FLAGS)0);
MOV #0,R12
; 591. }
JMP (?0193)
?0163:
; 592. sched = FALSE; /* Indicate that we don't need rescheduling */
MOV.B #0,R9
; 593. pnode = (OS_FLAG_NODE *)pgrp->OSFlagWaitList;
MOV 2(R10),R8
?0168:
; 594. while (pnode != (OS_FLAG_NODE *)0) { /* Go through all tasks waiting on event flag(s) */
CMP #0,R8
JEQ (?0167)
; 595. switch (pnode->OSFlagNodeWaitType) {
MOV.B 10(R8),R12
CMP #4,R12
JC (?0190)
ADD R12,R12
BR ?0220(R12)
?0220:
DW ?0181
DW ?0186
DW ?0171
DW ?0176
?0171:
; 596. case OS_FLAG_WAIT_SET_ALL: /* See if all req. flags are set for current node */
; 597. flags_rdy = pgrp->OSFlagFlags & pnode->OSFlagNodeFlags;
MOV 4(R10),R14
AND 8(R8),R14
; 598. if (flags_rdy == pnode->OSFlagNodeFlags) {
CMP 8(R8),R14
JNE (?0190)
; 599. if (OS_FlagTaskRdy(pnode, flags_rdy) == TRUE) { /* Make task RTR, event(s) Rx'd */
MOV R8,R12
CALL #OS_FlagTaskRdy
CMP.B #1,R12
JNE (?0190)
; 600. sched = TRUE; /* When done we will reschedule */
MOV.B #1,R9
; 601. }
; 602. }
; 603. break;
JMP (?0190)
?0176:
; 604.
; 605. case OS_FLAG_WAIT_SET_ANY: /* See if any flag set */
; 606. flags_rdy = pgrp->OSFlagFlags & pnode->OSFlagNodeFlags;
MOV 4(R10),R14
AND 8(R8),R14
; 607. if (flags_rdy != (OS_FLAGS)0) {
JEQ (?0190)
; 608. if (OS_FlagTaskRdy(pnode, flags_rdy) == TRUE) { /* Make task RTR, event(s) Rx'd */
MOV R8,R12
CALL #OS_FlagTaskRdy
CMP.B #1,R12
JNE (?0190)
; 609. sched = TRUE; /* When done we will reschedule */
MOV.B #1,R9
; 610. }
; 611. }
; 612. break;
JMP (?0190)
?0181:
; 613.
; 614. #if OS_FLAG_WAIT_CLR_EN > 0
; 615. case OS_FLAG_WAIT_CLR_ALL: /* See if all req. flags are set for current node */
; 616. flags_rdy = ~pgrp->OSFlagFlags & pnode->OSFlagNodeFlags;
MOV 4(R10),R14
XOR #-1,R14
AND 8(R8),R14
; 617. if (flags_rdy == pnode->OSFlagNodeFlags) {
CMP 8(R8),R14
JNE (?0190)
; 618. if (OS_FlagTaskRdy(pnode, flags_rdy) == TRUE) { /* Make task RTR, event(s) Rx'd */
MOV R8,R12
CALL #OS_FlagTaskRdy
CMP.B #1,R12
JNE (?0190)
; 619. sched = TRUE; /* When done we will reschedule */
MOV.B #1,R9
; 620. }
; 621. }
; 622. break;
JMP (?0190)
?0186:
; 623.
; 624. case OS_FLAG_WAIT_CLR_ANY: /* See if any flag set */
; 625. flags_rdy = ~pgrp->OSFlagFlags & pnode->OSFlagNodeFlags;
MOV 4(R10),R14
XOR #-1,R14
AND 8(R8),R14
; 626. if (flags_rdy != (OS_FLAGS)0) {
JEQ (?0190)
; 627. if (OS_FlagTaskRdy(pnode, flags_rdy) == TRUE) { /* Make task RTR, event(s) Rx'd */
MOV R8,R12
CALL #OS_FlagTaskRdy
CMP.B #1,R12
JNE (?0190)
; 628. sched = TRUE; /* When done we will reschedule */
MOV.B #1,R9
?0190:
; 629. }
; 630. }
; 631. break;
; 632. #endif
; 633. }
; 634. pnode = (OS_FLAG_NODE *)pnode->OSFlagNodeNext; /* Point to next task waiting for event flag(s) */
MOV @R8,R8
JMP (?0168)
?0167:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -