📄 os_mbox.lst
字号:
\ 000000B2 3000 MOVS R0,R6
\ 000000B4 ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
214 *err = OS_ERR_INVALID_OPT;
\ 000000B8 0720 MOVS R0,#+7
\ ??OSMboxDel_1:
\ 000000BA 2870 STRB R0,[R5, #+0]
215 return (pevent);
\ 000000BC 2000 MOVS R0,R4
\ ??OSMboxDel_3:
\ 000000BE 01B0 ADD SP,SP,#+4
\ 000000C0 F0BC POP {R4-R7}
\ 000000C2 02BC POP {R1}
\ 000000C4 0847 BX R1 ;; return
216 }
217 }
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
\ In segment CODE, align 4, keep-with-next
252 void *OSMboxPend (OS_EVENT *pevent, INT16U timeout, INT8U *err)
253 {
\ OSMboxPend:
\ 00000000 F2B5 PUSH {R1,R4-R7,LR}
\ 00000002 0400 MOVS R4,R0
\ 00000004 1500 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 ... */
\ 00000006 .... LDR R0,??DataTable7 ;; OSIntNesting
\ 00000008 0078 LDRB R0,[R0, #+0]
\ 0000000A 0028 CMP R0,#+0
\ 0000000C 01D0 BEQ ??OSMboxPend_0
261 *err = OS_ERR_PEND_ISR; /* ... can't PEND from an ISR */
\ 0000000E 0220 MOVS R0,#+2
\ 00000010 49E0 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:
\ 00000012 002C CMP R4,#+0
\ 00000014 01D1 BNE ??OSMboxPend_2
266 *err = OS_ERR_PEVENT_NULL;
\ 00000016 0420 MOVS R0,#+4
\ 00000018 45E0 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:
\ 0000001A 2078 LDRB R0,[R4, #+0]
\ 0000001C 0128 CMP R0,#+1
\ 0000001E 01D0 BEQ ??OSMboxPend_3
271 *err = OS_ERR_EVENT_TYPE;
\ 00000020 0120 MOVS R0,#+1
\ 00000022 40E0 B.N ??OSMboxPend_1
272 return ((void *)0);
273 }
274 OS_ENTER_CRITICAL();
\ ??OSMboxPend_3:
\ 00000024 ........ _BLF OS_CPU_SR_Save,??OS_CPU_SR_Save??rT
\ 00000028 0600 MOVS R6,R0
275 msg = pevent->OSEventPtr;
\ 0000002A 6768 LDR R7,[R4, #+4]
276 if (msg != (void *)0) { /* See if there is already a message */
\ 0000002C 002F CMP R7,#+0
\ 0000002E 08D0 BEQ ??OSMboxPend_4
277 pevent->OSEventPtr = (void *)0; /* Clear the mailbox */
\ 00000030 0020 MOVS R0,#+0
\ 00000032 6060 STR R0,[R4, #+4]
278 OS_EXIT_CRITICAL();
\ ??OSMboxPend_5:
\ 00000034 3000 MOVS R0,R6
\ 00000036 ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
279 *err = OS_NO_ERR;
\ 0000003A 0020 MOVS R0,#+0
\ 0000003C 2870 STRB R0,[R5, #+0]
280 return (msg); /* Return the message received (or NULL) */
\ 0000003E 3800 MOVS R0,R7
\ 00000040 33E0 B ??OSMboxPend_6
281 }
282 OSTCBCur->OSTCBStat |= OS_STAT_MBOX; /* Message not available, task will pend */
\ ??OSMboxPend_4:
\ 00000042 1C48 LDR R0,??OSMboxPend_7 ;; OSTCBCur
\ 00000044 0068 LDR R0,[R0, #+0]
\ 00000046 2C30 ADDS R0,R0,#+44
\ 00000048 1A49 LDR R1,??OSMboxPend_7 ;; OSTCBCur
\ 0000004A 0968 LDR R1,[R1, #+0]
\ 0000004C 2C31 ADDS R1,R1,#+44
\ 0000004E 0978 LDRB R1,[R1, #+0]
\ 00000050 0222 MOVS R2,#+2
\ 00000052 0A43 ORRS R2,R2,R1
\ 00000054 0270 STRB R2,[R0, #+0]
283 OSTCBCur->OSTCBDly = timeout; /* Load timeout in TCB */
\ 00000056 1748 LDR R0,??OSMboxPend_7 ;; OSTCBCur
\ 00000058 0068 LDR R0,[R0, #+0]
\ 0000005A 6946 MOV R1,SP
\ 0000005C 0988 LDRH R1,[R1, #+0]
\ 0000005E 4185 STRH R1,[R0, #+42]
284 OS_EventTaskWait(pevent); /* Suspend task until event or timeout occurs */
\ 00000060 2000 MOVS R0,R4
\ 00000062 ........ _BLF OS_EventTaskWait,??OS_EventTaskWait??rT
285 OS_EXIT_CRITICAL();
\ 00000066 3000 MOVS R0,R6
\ 00000068 ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
286 OS_Sched(); /* Find next highest priority task ready to run */
\ 0000006C ........ _BLF OS_Sched,??OS_Sched??rT
287 OS_ENTER_CRITICAL();
\ 00000070 ........ _BLF OS_CPU_SR_Save,??OS_CPU_SR_Save??rT
\ 00000074 0600 MOVS R6,R0
288 msg = OSTCBCur->OSTCBMsg;
\ 00000076 0F48 LDR R0,??OSMboxPend_7 ;; OSTCBCur
\ 00000078 0068 LDR R0,[R0, #+0]
\ 0000007A 076A LDR R7,[R0, #+32]
289 if (msg != (void *)0) { /* See if we were given the message */
\ 0000007C 002F CMP R7,#+0
\ 0000007E 0BD0 BEQ ??OSMboxPend_8
290 OSTCBCur->OSTCBMsg = (void *)0; /* Yes, clear message received */
\ 00000080 0C48 LDR R0,??OSMboxPend_7 ;; OSTCBCur
\ 00000082 0068 LDR R0,[R0, #+0]
\ 00000084 0021 MOVS R1,#+0
\ 00000086 0162 STR R1,[R0, #+32]
291 OSTCBCur->OSTCBStat = OS_STAT_RDY;
\ 00000088 0A48 LDR R0,??OSMboxPend_7 ;; OSTCBCur
\ 0000008A 0068 LDR R0,[R0, #+0]
\ 0000008C 2C30 ADDS R0,R0,#+44
\ 0000008E 0170 STRB R1,[R0, #+0]
292 OSTCBCur->OSTCBEventPtr = (OS_EVENT *)0; /* No longer waiting for event */
\ 00000090 0848 LDR R0,??OSMboxPend_7 ;; OSTCBCur
\ 00000092 0068 LDR R0,[R0, #+0]
\ 00000094 C161 STR R1,[R0, #+28]
293 OS_EXIT_CRITICAL();
\ 00000096 CDE7 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:
\ 00000098 2000 MOVS R0,R4
\ 0000009A ........ _BLF OS_EventTO,??OS_EventTO??rT
298 OS_EXIT_CRITICAL();
\ 0000009E 3000 MOVS R0,R6
\ 000000A0 ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
299 *err = OS_TIMEOUT; /* Indicate that a timeout occured */
\ 000000A4 0A20 MOVS R0,#+10
\ ??OSMboxPend_1:
\ 000000A6 2870 STRB R0,[R5, #+0]
300 return ((void *)0); /* Return a NULL message */
\ 000000A8 0020 MOVS R0,#+0
\ ??OSMboxPend_6:
\ 000000AA 01B0 ADD SP,SP,#+4
\ 000000AC F0BC POP {R4-R7}
\ 000000AE 02BC POP {R1}
\ 000000B0 0847 BX R1 ;; return
\ 000000B2 C046 Nop
\ ??OSMboxPend_7:
\ 000000B4 ........ DC32 OSTCBCur
301 }
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 *
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -