📄 os_mbox.s79
字号:
// 87 return ((OS_EVENT *)0); /* ... can't CREATE from an ISR */
MOVS R0,#+0
B ??OSMboxCreate_1
// 88 }
// 89 OS_ENTER_CRITICAL();
??OSMboxCreate_0:
_BLF OS_CPU_SR_Save,??OS_CPU_SR_Save??rT
// 90 pevent = OSEventFreeList; /* Get next free event control block */
LDR R1,??DataTable6 ;; OSEventFreeList
LDR R5,[R1, #+0]
// 91 if (OSEventFreeList != (OS_EVENT *)0) { /* See if pool of free ECB pool was empty */
CMP R5,#+0
BEQ ??OSMboxCreate_2
// 92 OSEventFreeList = (OS_EVENT *)OSEventFreeList->OSEventPtr;
LDR R2,[R5, #+4]
STR R2,[R1, #+0]
// 93 }
// 94 OS_EXIT_CRITICAL();
??OSMboxCreate_2:
_BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
// 95 if (pevent != (OS_EVENT *)0) {
CMP R5,#+0
BEQ ??OSMboxCreate_3
// 96 pevent->OSEventType = OS_EVENT_TYPE_MBOX;
MOVS R0,#+1
STRB R0,[R5, #+0]
// 97 pevent->OSEventCnt = 0;
MOVS R0,#+0
STRH R0,[R5, #+2]
// 98 pevent->OSEventPtr = msg; /* Deposit message in event control block */
STR R4,[R5, #+4]
// 99 #if OS_EVENT_NAME_SIZE > 1
// 100 pevent->OSEventName[0] = '?';
MOVS R0,#+63
STRB R0,[R5, #+16]
// 101 pevent->OSEventName[1] = OS_ASCII_NUL;
MOVS R0,#+0
STRB R0,[R5, #+17]
// 102 #endif
// 103 OS_EventWaitListInit(pevent);
MOVS R0,R5
_BLF OS_EventWaitListInit,??OS_EventWaitListInit??rT
// 104 }
// 105 return (pevent); /* Return pointer to event control block */
??OSMboxCreate_3:
MOVS R0,R5
??OSMboxCreate_1:
POP {R4,R5}
POP {R1}
BX R1 ;; return
CFI EndBlock cfiBlock3
// 106 }
RSEG CODE:CODE:NOROOT(2)
CFI Block cfiBlock4 Using cfiCommon0
CFI NoFunction
ARM
??OSMboxDel??rA:
ADD R12,PC,#+1
BX R12
CFI EndBlock cfiBlock4
REQUIRE OSMboxDel
// 107
// 108 /*
// 109 *********************************************************************************************************
// 110 * DELETE A MAIBOX
// 111 *
// 112 * Description: This function deletes a mailbox and readies all tasks pending on the mailbox.
// 113 *
// 114 * Arguments : pevent is a pointer to the event control block associated with the desired
// 115 * mailbox.
// 116 *
// 117 * opt determines delete options as follows:
// 118 * opt == OS_DEL_NO_PEND Delete the mailbox ONLY if no task pending
// 119 * opt == OS_DEL_ALWAYS Deletes the mailbox even if tasks are waiting.
// 120 * In this case, all the tasks pending will be readied.
// 121 *
// 122 * err is a pointer to an error code that can contain one of the following values:
// 123 * OS_NO_ERR The call was successful and the mailbox was deleted
// 124 * OS_ERR_DEL_ISR If you attempted to delete the mailbox from an ISR
// 125 * OS_ERR_INVALID_OPT An invalid option was specified
// 126 * OS_ERR_TASK_WAITING One or more tasks were waiting on the mailbox
// 127 * OS_ERR_EVENT_TYPE If you didn't pass a pointer to a mailbox
// 128 * OS_ERR_PEVENT_NULL If 'pevent' is a NULL pointer.
// 129 *
// 130 * Returns : pevent upon error
// 131 * (OS_EVENT *)0 if the mailbox was successfully deleted.
// 132 *
// 133 * Note(s) : 1) This function must be used with care. Tasks that would normally expect the presence of
// 134 * the mailbox MUST check the return code of OSMboxPend().
// 135 * 2) OSMboxAccept() callers will not know that the intended mailbox has been deleted!
// 136 * 3) This call can potentially disable interrupts for a long time. The interrupt disable
// 137 * time is directly proportional to the number of tasks waiting on the mailbox.
// 138 * 4) Because ALL tasks pending on the mailbox will be readied, you MUST be careful in
// 139 * applications where the mailbox is used for mutual exclusion because the resource(s)
// 140 * will no longer be guarded by the mailbox.
// 141 *********************************************************************************************************
// 142 */
// 143
// 144 #if OS_MBOX_DEL_EN > 0
RSEG CODE:CODE:NOROOT(2)
CFI Block cfiBlock5 Using cfiCommon1
CFI Function OSMboxDel
THUMB
// 145 OS_EVENT *OSMboxDel (OS_EVENT *pevent, INT8U opt, INT8U *err)
// 146 {
OSMboxDel:
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
// 147 #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
// 148 OS_CPU_SR cpu_sr;
// 149 #endif
// 150 BOOLEAN tasks_waiting;
// 151
// 152
// 153 if (OSIntNesting > 0) { /* See if called from ISR ... */
LDR R0,??DataTable7 ;; OSIntNesting
LDRB R0,[R0, #+0]
CMP R0,#+0
BEQ ??OSMboxDel_0
// 154 *err = OS_ERR_DEL_ISR; /* ... can't DELETE from an ISR */
MOVS R0,#+140
B.N ??OSMboxDel_1
// 155 return (pevent);
// 156 }
// 157 #if OS_ARG_CHK_EN > 0
// 158 if (pevent == (OS_EVENT *)0) { /* Validate 'pevent' */
??OSMboxDel_0:
CMP R4,#+0
BNE ??OSMboxDel_2
// 159 *err = OS_ERR_PEVENT_NULL;
MOVS R0,#+4
STRB R0,[R5, #+0]
// 160 return (pevent);
MOVS R0,#+0
B ??OSMboxDel_3
// 161 }
// 162 #endif
// 163 if (pevent->OSEventType != OS_EVENT_TYPE_MBOX) { /* Validate event block type */
??OSMboxDel_2:
LDRB R0,[R4, #+0]
CMP R0,#+1
BEQ ??OSMboxDel_4
// 164 *err = OS_ERR_EVENT_TYPE;
MOVS R0,#+1
B.N ??OSMboxDel_1
// 165 return (pevent);
// 166 }
// 167 OS_ENTER_CRITICAL();
??OSMboxDel_4:
_BLF OS_CPU_SR_Save,??OS_CPU_SR_Save??rT
MOVS R6,R0
// 168 if (pevent->OSEventGrp != 0x00) { /* See if any tasks waiting on mailbox */
LDRB R0,[R4, #+1]
CMP R0,#+0
BEQ ??OSMboxDel_5
// 169 tasks_waiting = TRUE; /* Yes */
MOVS R7,#+1
B ??OSMboxDel_6
// 170 } else {
// 171 tasks_waiting = FALSE; /* No */
??OSMboxDel_5:
MOVS R7,#+0
// 172 }
// 173 switch (opt) {
??OSMboxDel_6:
MOV R0,SP
LDRB R0,[R0, #+0]
CMP R0,#+0
BEQ ??OSMboxDel_7
CMP R0,#+1
BEQ ??OSMboxDel_8
B ??OSMboxDel_9
// 174 case OS_DEL_NO_PEND: /* Delete mailbox only if no task waiting */
// 175 if (tasks_waiting == FALSE) {
??OSMboxDel_7:
CMP R7,#+0
BNE ??OSMboxDel_10
// 176 #if OS_EVENT_NAME_SIZE > 1
// 177 pevent->OSEventName[0] = '?'; /* Unknown name */
MOVS R0,#+63
STRB R0,[R4, #+16]
// 178 pevent->OSEventName[1] = OS_ASCII_NUL;
MOVS R0,#+0
STRB R0,[R4, #+17]
// 179 #endif
// 180 pevent->OSEventType = OS_EVENT_TYPE_UNUSED;
STRB R0,[R4, #+0]
// 181 pevent->OSEventPtr = OSEventFreeList; /* Return Event Control Block to free list */
LDR R0,??DataTable6 ;; OSEventFreeList
LDR R0,[R0, #+0]
STR R0,[R4, #+4]
// 182 pevent->OSEventCnt = 0;
MOVS R0,#+0
STRH R0,[R4, #+2]
// 183 OSEventFreeList = pevent; /* Get next free event control block */
LDR R0,??DataTable6 ;; OSEventFreeList
STR R4,[R0, #+0]
// 184 OS_EXIT_CRITICAL();
MOVS R0,R6
_BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
// 185 *err = OS_NO_ERR;
??OSMboxDel_11:
MOVS R0,#+0
STRB R0,[R5, #+0]
// 186 return ((OS_EVENT *)0); /* Mailbox has been deleted */
B ??OSMboxDel_3
// 187 } else {
// 188 OS_EXIT_CRITICAL();
??OSMboxDel_10:
MOVS R0,R6
_BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
// 189 *err = OS_ERR_TASK_WAITING;
MOVS R0,#+8
B.N ??OSMboxDel_1
// 190 return (pevent);
// 191 }
// 192
// 193 case OS_DEL_ALWAYS: /* Always delete the mailbox */
// 194 while (pevent->OSEventGrp != 0x00) { /* Ready ALL tasks waiting for mailbox */
// 195 OS_EventTaskRdy(pevent, (void *)0, OS_STAT_MBOX);
??OSMboxDel_12:
MOVS R2,#+2
MOVS R1,#+0
MOVS R0,R4
_BLF OS_EventTaskRdy,??OS_EventTaskRdy??rT
// 196 }
??OSMboxDel_8:
LDRB R0,[R4, #+1]
CMP R0,#+0
BNE ??OSMboxDel_12
// 197 #if OS_EVENT_NAME_SIZE > 1
// 198 pevent->OSEventName[0] = '?'; /* Unknown name */
MOVS R0,#+63
STRB R0,[R4, #+16]
// 199 pevent->OSEventName[1] = OS_ASCII_NUL;
MOVS R0,#+0
STRB R0,[R4, #+17]
// 200 #endif
// 201 pevent->OSEventType = OS_EVENT_TYPE_UNUSED;
STRB R0,[R4, #+0]
// 202 pevent->OSEventPtr = OSEventFreeList; /* Return Event Control Block to free list */
LDR R0,??DataTable6 ;; OSEventFreeList
LDR R0,[R0, #+0]
STR R0,[R4, #+4]
// 203 pevent->OSEventCnt = 0;
MOVS R0,#+0
STRH R0,[R4, #+2]
// 204 OSEventFreeList = pevent; /* Get next free event control block */
LDR R0,??DataTable6 ;; OSEventFreeList
STR R4,[R0, #+0]
// 205 OS_EXIT_CRITICAL();
MOVS R0,R6
_BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
// 206 if (tasks_waiting == TRUE) { /* Reschedule only if task(s) were waiting */
CMP R7,#+1
BNE ??OSMboxDel_11
// 207 OS_Sched(); /* Find highest priority task ready to run */
_BLF OS_Sched,??OS_Sched??rT
// 208 }
// 209 *err = OS_NO_ERR;
??OSMboxDel_13:
B.N ??OSMboxDel_11
// 210 return ((OS_EVENT *)0); /* Mailbox has been deleted */
// 211
// 212 default:
// 213 OS_EXIT_CRITICAL();
??OSMboxDel_9:
MOVS R0,R6
_BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
// 214 *err = OS_ERR_INVALID_OPT;
MOVS R0,#+7
??OSMboxDel_1:
STRB R0,[R5, #+0]
// 215 return (pevent);
MOVS R0,R4
??OSMboxDel_3:
ADD SP,SP,#+4
CFI CFA R13+20
POP {R4-R7}
POP {R1}
BX R1 ;; return
CFI EndBlock cfiBlock5
// 216 }
// 217 }
RSEG CODE:CODE:NOROOT(2)
DATA
??DataTable6:
DC32 OSEventFreeList
RSEG CODE:CODE:NOROOT(2)
CFI Block cfiBlock6 Using cfiCommon0
CFI NoFunction
ARM
??OSMboxPend??rA:
ADD R12,PC,#+1
BX R12
CFI EndBlock cfiBlock6
REQUIRE OSMboxPend
// 218 #endif
// 219
// 220
// 221 /*
// 222 *********************************************************************************************************
// 223 * PEND ON MAILBOX FOR A MESSAGE
// 224 *
// 225 * Description: This function waits for a message to be sent to a mailbox
// 226 *
// 227 * Arguments : pevent is a pointer to the event control block associated with the desired mailbox
// 228 *
// 229 * timeout is an optional timeout period (in clock ticks). If non-zero, your task will
// 230 * wait for a message to arrive at the mailbox up to the amount of time
// 231 * specified by this argument. If you specify 0, however, your task will wait
// 232 * forever at the specified mailbox or, until a message arrives.
// 233 *
// 234 * err is a pointer to where an error message will be deposited. Possible error
// 235 * messages are:
// 236 *
// 237 * OS_NO_ERR The call was successful and your task received a
// 238 * message.
// 239 * OS_TIMEOUT A message was not received within the specified timeout
// 240 * OS_ERR_EVENT_TYPE Invalid event type
// 241 * OS_ERR_PEND_ISR If you called this function from an ISR and the result
// 242 * would lead to a suspension.
// 243 * OS_ERR_PEVENT_NULL If 'pevent' is a NULL pointer
// 244 *
// 245 * Returns : != (void *)0 is a pointer to the message received
// 246 * == (void *)0 if no message was received or,
// 247 * if 'pevent' is a NULL pointer or,
// 248 * if you didn't pass the proper pointer to the event control block.
// 249 *********************************************************************************************************
// 250 */
// 251
RSEG CODE:CODE:NOROOT(2)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -