📄 os_flag.s79
字号:
// 58 * the flags that are present, set 'wait_type' to:
// 59 *
// 60 * OS_FLAG_WAIT_SET_ANY + OS_FLAG_CONSUME
// 61 *
// 62 * err is a pointer to an error code and can be:
// 63 * OS_NO_ERR No error
// 64 * OS_ERR_EVENT_TYPE You are not pointing to an event flag group
// 65 * OS_FLAG_ERR_WAIT_TYPE You didn't specify a proper 'wait_type' argument.
// 66 * OS_FLAG_INVALID_PGRP You passed a NULL pointer instead of the event flag
// 67 * group handle.
// 68 * OS_FLAG_ERR_NOT_RDY The desired flags you are waiting for are not
// 69 * available.
// 70 *
// 71 * Returns : The flags in the event flag group that made the task ready or, 0 if a timeout or an error
// 72 * occurred.
// 73 *
// 74 * Called from: Task or ISR
// 75 *
// 76 * Note(s) : 1) IMPORTANT, the behavior of this function has changed from PREVIOUS versions. The
// 77 * function NOW returns the flags that were ready INSTEAD of the current state of the
// 78 * event flags.
// 79 *********************************************************************************************************
// 80 */
// 81
// 82 #if OS_FLAG_ACCEPT_EN > 0
RSEG CODE:CODE:NOROOT(2)
CFI Block cfiBlock1 Using cfiCommon1
CFI Function OSFlagAccept
THUMB
// 83 OS_FLAGS OSFlagAccept (OS_FLAG_GRP *pgrp, OS_FLAGS flags, INT8U wait_type, INT8U *err)
// 84 {
OSFlagAccept:
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 R7,R2
MOVS R5,R3
// 85 #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
// 86 OS_CPU_SR cpu_sr;
// 87 #endif
// 88 OS_FLAGS flags_rdy;
// 89 BOOLEAN consume;
// 90
// 91
// 92 #if OS_ARG_CHK_EN > 0
// 93 if (pgrp == (OS_FLAG_GRP *)0) { /* Validate 'pgrp' */
CMP R4,#+0
BNE ??OSFlagAccept_0
// 94 *err = OS_FLAG_INVALID_PGRP;
MOVS R0,#+150
??OSFlagAccept_1:
STRB R0,[R5, #+0]
// 95 return ((OS_FLAGS)0);
MOVS R0,#+0
B ??OSFlagAccept_2
// 96 }
// 97 #endif
// 98 if (pgrp->OSFlagType != OS_EVENT_TYPE_FLAG) { /* Validate event block type */
??OSFlagAccept_0:
LDRB R0,[R4, #+0]
CMP R0,#+5
BEQ ??OSFlagAccept_3
// 99 *err = OS_ERR_EVENT_TYPE;
MOVS R0,#+1
B.N ??OSFlagAccept_1
// 100 return ((OS_FLAGS)0);
// 101 }
// 102 if (wait_type & OS_FLAG_CONSUME) { /* See if we need to consume the flags */
??OSFlagAccept_3:
LSLS R0,R7,#+24
BPL ??OSFlagAccept_4
// 103 wait_type &= ~OS_FLAG_CONSUME;
LSLS R7,R7,#+25
LSRS R7,R7,#+25
// 104 consume = TRUE;
MOVS R6,#+1
B ??OSFlagAccept_5
// 105 } else {
// 106 consume = FALSE;
??OSFlagAccept_4:
MOVS R6,#+0
// 107 }
// 108 /*$PAGE*/
// 109 *err = OS_NO_ERR; /* Assume NO error until proven otherwise. */
??OSFlagAccept_5:
MOVS R0,#+0
STRB R0,[R5, #+0]
// 110 OS_ENTER_CRITICAL();
_BLF OS_CPU_SR_Save,??OS_CPU_SR_Save??rT
// 111 switch (wait_type) {
CMP R7,#+0
BEQ ??OSFlagAccept_6
CMP R7,#+1
BEQ ??OSFlagAccept_7
CMP R7,#+2
BEQ ??OSFlagAccept_8
CMP R7,#+3
BEQ ??OSFlagAccept_9
B ??OSFlagAccept_10
// 112 case OS_FLAG_WAIT_SET_ALL: /* See if all required flags are set */
// 113 flags_rdy = pgrp->OSFlagFlags & flags; /* Extract only the bits we want */
??OSFlagAccept_8:
LDRH R1,[R4, #+8]
MOV R2,SP
LDRH R7,[R2, #+0]
ANDS R7,R7,R1
// 114 if (flags_rdy == flags) { /* Must match ALL the bits that we want */
LDRH R2,[R2, #+0]
CMP R7,R2
BNE ??OSFlagAccept_11
// 115 if (consume == TRUE) { /* See if we need to consume the flags */
??OSFlagAccept_12:
CMP R6,#+1
BNE ??OSFlagAccept_13
// 116 pgrp->OSFlagFlags &= ~flags_rdy; /* Clear ONLY the flags that we wanted */
BICS R1,R1,R7
STRH R1,[R4, #+8]
B ??OSFlagAccept_13
// 117 }
// 118 } else {
// 119 *err = OS_FLAG_ERR_NOT_RDY;
??OSFlagAccept_11:
MOVS R1,#+152
STRB R1,[R5, #+0]
// 120 }
// 121 OS_EXIT_CRITICAL();
??OSFlagAccept_13:
_BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
B ??OSFlagAccept_14
// 122 break;
// 123
// 124 case OS_FLAG_WAIT_SET_ANY:
// 125 flags_rdy = pgrp->OSFlagFlags & flags; /* Extract only the bits we want */
??OSFlagAccept_9:
LDRH R1,[R4, #+8]
MOV R2,SP
LDRH R7,[R2, #+0]
ANDS R7,R7,R1
// 126 if (flags_rdy != (OS_FLAGS)0) { /* See if any flag set */
BEQ ??OSFlagAccept_11
// 127 if (consume == TRUE) { /* See if we need to consume the flags */
B.N ??OSFlagAccept_12
// 128 pgrp->OSFlagFlags &= ~flags_rdy; /* Clear ONLY the flags that we got */
// 129 }
// 130 } else {
// 131 *err = OS_FLAG_ERR_NOT_RDY;
// 132 }
// 133 OS_EXIT_CRITICAL();
// 134 break;
// 135
// 136 #if OS_FLAG_WAIT_CLR_EN > 0
// 137 case OS_FLAG_WAIT_CLR_ALL: /* See if all required flags are cleared */
// 138 flags_rdy = ~pgrp->OSFlagFlags & flags; /* Extract only the bits we want */
??OSFlagAccept_6:
LDRH R1,[R4, #+8]
MOV R2,SP
LDRH R7,[R2, #+0]
BICS R7,R7,R1
// 139 if (flags_rdy == flags) { /* Must match ALL the bits that we want */
LDRH R2,[R2, #+0]
CMP R7,R2
BNE ??OSFlagAccept_11
// 140 if (consume == TRUE) { /* See if we need to consume the flags */
??OSFlagAccept_15:
CMP R6,#+1
BNE ??OSFlagAccept_13
// 141 pgrp->OSFlagFlags |= flags_rdy; /* Set ONLY the flags that we wanted */
MOVS R2,R7
ORRS R2,R2,R1
STRH R2,[R4, #+8]
B ??OSFlagAccept_13
// 142 }
// 143 } else {
// 144 *err = OS_FLAG_ERR_NOT_RDY;
// 145 }
// 146 OS_EXIT_CRITICAL();
// 147 break;
// 148
// 149 case OS_FLAG_WAIT_CLR_ANY:
// 150 flags_rdy = ~pgrp->OSFlagFlags & flags; /* Extract only the bits we want */
??OSFlagAccept_7:
LDRH R1,[R4, #+8]
MOV R2,SP
LDRH R7,[R2, #+0]
BICS R7,R7,R1
// 151 if (flags_rdy != (OS_FLAGS)0) { /* See if any flag cleared */
BEQ ??OSFlagAccept_11
// 152 if (consume == TRUE) { /* See if we need to consume the flags */
B.N ??OSFlagAccept_15
// 153 pgrp->OSFlagFlags |= flags_rdy; /* Set ONLY the flags that we got */
// 154 }
// 155 } else {
// 156 *err = OS_FLAG_ERR_NOT_RDY;
// 157 }
// 158 OS_EXIT_CRITICAL();
// 159 break;
// 160 #endif
// 161
// 162 default:
// 163 OS_EXIT_CRITICAL();
??OSFlagAccept_10:
_BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
// 164 flags_rdy = (OS_FLAGS)0;
MOVS R7,#+0
// 165 *err = OS_FLAG_ERR_WAIT_TYPE;
MOVS R0,#+151
STRB R0,[R5, #+0]
// 166 break;
// 167 }
// 168 return (flags_rdy);
??OSFlagAccept_14:
MOVS R0,R7
??OSFlagAccept_2:
ADD SP,SP,#+4
CFI CFA R13+20
POP {R4-R7}
POP {R1}
BX R1 ;; return
CFI EndBlock cfiBlock1
// 169 }
RSEG CODE:CODE:NOROOT(2)
CFI Block cfiBlock2 Using cfiCommon0
CFI NoFunction
ARM
??OSFlagCreate??rA:
ADD R12,PC,#+1
BX R12
CFI EndBlock cfiBlock2
REQUIRE OSFlagCreate
// 170 #endif
// 171
// 172 /*$PAGE*/
// 173 /*
// 174 *********************************************************************************************************
// 175 * CREATE AN EVENT FLAG
// 176 *
// 177 * Description: This function is called to create an event flag group.
// 178 *
// 179 * Arguments : flags Contains the initial value to store in the event flag group.
// 180 *
// 181 * err is a pointer to an error code which will be returned to your application:
// 182 * OS_NO_ERR if the call was successful.
// 183 * OS_ERR_CREATE_ISR if you attempted to create an Event Flag from an
// 184 * ISR.
// 185 * OS_FLAG_GRP_DEPLETED if there are no more event flag groups
// 186 *
// 187 * Returns : A pointer to an event flag group or a NULL pointer if no more groups are available.
// 188 *
// 189 * Called from: Task ONLY
// 190 *********************************************************************************************************
// 191 */
// 192
RSEG CODE:CODE:NOROOT(2)
CFI Block cfiBlock3 Using cfiCommon1
CFI Function OSFlagCreate
THUMB
// 193 OS_FLAG_GRP *OSFlagCreate (OS_FLAGS flags, INT8U *err)
// 194 {
OSFlagCreate:
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 R5,R0
MOVS R4,R1
// 195 #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
// 196 OS_CPU_SR cpu_sr;
// 197 #endif
// 198 OS_FLAG_GRP *pgrp;
// 199
// 200
// 201 if (OSIntNesting > 0) { /* See if called from ISR ... */
LDR R0,??DataTable2 ;; OSIntNesting
LDRB R0,[R0, #+0]
CMP R0,#+0
BEQ ??OSFlagCreate_0
// 202 *err = OS_ERR_CREATE_ISR; /* ... can't CREATE from an ISR */
MOVS R0,#+141
STRB R0,[R4, #+0]
// 203 return ((OS_FLAG_GRP *)0);
MOVS R0,#+0
B ??OSFlagCreate_1
// 204 }
// 205 OS_ENTER_CRITICAL();
??OSFlagCreate_0:
_BLF OS_CPU_SR_Save,??OS_CPU_SR_Save??rT
// 206 pgrp = OSFlagFreeList; /* Get next free event flag */
LDR R1,??DataTable6 ;; OSFlagFreeList
LDR R6,[R1, #+0]
// 207 if (pgrp != (OS_FLAG_GRP *)0) { /* See if we have event flag groups available */
CMP R6,#+0
BEQ ??OSFlagCreate_2
// 208 /* Adjust free list */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -