📄 os_q.lst
字号:
296 pevent_return = pevent;
\ 000001F4 0A70B0E1 MOVS R7,R10
297 break;
298 }
299 return (pevent_return);
\ ??OSQDel_11:
\ 000001F8 0700B0E1 MOVS R0,R7
\ ??OSQDel_1:
\ 000001FC F087BDE8 POP {R4-R10,PC} ;; return
300 }
301 #endif
302
303 /*$PAGE*/
304 /*
305 *********************************************************************************************************
306 * FLUSH QUEUE
307 *
308 * Description : This function is used to flush the contents of the message queue.
309 *
310 * Arguments : none
311 *
312 * Returns : OS_ERR_NONE upon success
313 * OS_ERR_EVENT_TYPE If you didn't pass a pointer to a queue
314 * OS_ERR_PEVENT_NULL If 'pevent' is a NULL pointer
315 *
316 * WARNING : You should use this function with great care because, when to flush the queue, you LOOSE
317 * the references to what the queue entries are pointing to and thus, you could cause
318 * 'memory leaks'. In other words, the data you are pointing to that's being referenced
319 * by the queue entries should, most likely, need to be de-allocated (i.e. freed).
320 *********************************************************************************************************
321 */
322
323 #if OS_Q_FLUSH_EN > 0
\ In segment CODE, align 4, keep-with-next
324 INT8U OSQFlush (OS_EVENT *pevent)
325 {
\ OSQFlush:
\ 00000000 70402DE9 PUSH {R4-R6,LR}
\ 00000004 0040B0E1 MOVS R4,R0
326 OS_Q *pq;
327 #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
328 OS_CPU_SR cpu_sr = 0;
\ 00000008 0000A0E3 MOV R0,#+0
\ 0000000C 0060B0E1 MOVS R6,R0
329 #endif
330
331
332
333 #if OS_ARG_CHK_EN > 0
334 if (pevent == (OS_EVENT *)0) { /* Validate 'pevent' */
\ 00000010 000054E3 CMP R4,#+0
\ 00000014 0100001A BNE ??OSQFlush_0
335 return (OS_ERR_PEVENT_NULL);
\ 00000018 0400A0E3 MOV R0,#+4
\ 0000001C 110000EA B ??OSQFlush_1
336 }
337 if (pevent->OSEventType != OS_EVENT_TYPE_Q) { /* Validate event block type */
\ ??OSQFlush_0:
\ 00000020 0000D4E5 LDRB R0,[R4, #+0]
\ 00000024 020050E3 CMP R0,#+2
\ 00000028 0100000A BEQ ??OSQFlush_2
338 return (OS_ERR_EVENT_TYPE);
\ 0000002C 0100A0E3 MOV R0,#+1
\ 00000030 0C0000EA B ??OSQFlush_1
339 }
340 #endif
341 OS_ENTER_CRITICAL();
\ ??OSQFlush_2:
\ 00000034 ........ _BLF OS_CPU_SR_Save,??OS_CPU_SR_Save??rA
\ 00000038 0060B0E1 MOVS R6,R0
342 pq = (OS_Q *)pevent->OSEventPtr; /* Point to queue storage structure */
\ 0000003C 040094E5 LDR R0,[R4, #+4]
\ 00000040 0050B0E1 MOVS R5,R0
343 pq->OSQIn = pq->OSQStart;
\ 00000044 040095E5 LDR R0,[R5, #+4]
\ 00000048 0C0085E5 STR R0,[R5, #+12]
344 pq->OSQOut = pq->OSQStart;
\ 0000004C 040095E5 LDR R0,[R5, #+4]
\ 00000050 100085E5 STR R0,[R5, #+16]
345 pq->OSQEntries = 0;
\ 00000054 0000A0E3 MOV R0,#+0
\ 00000058 B601C5E1 STRH R0,[R5, #+22]
346 OS_EXIT_CRITICAL();
\ 0000005C 0600B0E1 MOVS R0,R6
\ 00000060 ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rA
347 return (OS_ERR_NONE);
\ 00000064 0000A0E3 MOV R0,#+0
\ ??OSQFlush_1:
\ 00000068 7080BDE8 POP {R4-R6,PC} ;; return
348 }
349 #endif
350
351 /*$PAGE*/
352 /*
353 *********************************************************************************************************
354 * PEND ON A QUEUE FOR A MESSAGE
355 *
356 * Description: This function waits for a message to be sent to a queue
357 *
358 * Arguments : pevent is a pointer to the event control block associated with the desired queue
359 *
360 * timeout is an optional timeout period (in clock ticks). If non-zero, your task will
361 * wait for a message to arrive at the queue up to the amount of time
362 * specified by this argument. If you specify 0, however, your task will wait
363 * forever at the specified queue or, until a message arrives.
364 *
365 * err is a pointer to where an error message will be deposited. Possible error
366 * messages are:
367 *
368 * OS_ERR_NONE The call was successful and your task received a
369 * message.
370 * OS_ERR_TIMEOUT A message was not received within the specified 'timeout'.
371 * OS_ERR_PEND_ABORT The wait on the queue was aborted.
372 * OS_ERR_EVENT_TYPE You didn't pass a pointer to a queue
373 * OS_ERR_PEVENT_NULL If 'pevent' is a NULL pointer
374 * OS_ERR_PEND_ISR If you called this function from an ISR and the result
375 * would lead to a suspension.
376 * OS_ERR_PEND_LOCKED If you called this function with the scheduler is locked
377 *
378 * Returns : != (void *)0 is a pointer to the message received
379 * == (void *)0 if you received a NULL pointer message or,
380 * if no message was received or,
381 * if 'pevent' is a NULL pointer or,
382 * if you didn't pass a pointer to a queue.
383 *
384 * Note(s) : As of V2.60, this function allows you to receive NULL pointer messages.
385 *********************************************************************************************************
386 */
387
\ In segment CODE, align 4, keep-with-next
388 void *OSQPend (OS_EVENT *pevent, INT16U timeout, INT8U *err)
389 {
\ OSQPend:
\ 00000000 F0472DE9 PUSH {R4-R10,LR}
\ 00000004 0040B0E1 MOVS R4,R0
\ 00000008 0150B0E1 MOVS R5,R1
\ 0000000C 0260B0E1 MOVS R6,R2
390 void *msg;
391 OS_Q *pq;
392 INT8U pend_stat;
393 #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
394 OS_CPU_SR cpu_sr = 0;
\ 00000010 0000A0E3 MOV R0,#+0
\ 00000014 00A0B0E1 MOVS R10,R0
395 #endif
396
397
398
399 #if OS_ARG_CHK_EN > 0
400 if (err == (INT8U *)0) { /* Validate 'err' */
\ 00000018 000056E3 CMP R6,#+0
\ 0000001C 0100001A BNE ??OSQPend_0
401 return ((void *)0);
\ 00000020 0000A0E3 MOV R0,#+0
\ 00000024 7A0000EA B ??OSQPend_1
402 }
403 if (pevent == (OS_EVENT *)0) { /* Validate 'pevent' */
\ ??OSQPend_0:
\ 00000028 000054E3 CMP R4,#+0
\ 0000002C 0300001A BNE ??OSQPend_2
404 *err = OS_ERR_PEVENT_NULL;
\ 00000030 0400A0E3 MOV R0,#+4
\ 00000034 0000C6E5 STRB R0,[R6, #+0]
405 return ((void *)0);
\ 00000038 0000A0E3 MOV R0,#+0
\ 0000003C 740000EA B ??OSQPend_1
406 }
407 if (pevent->OSEventType != OS_EVENT_TYPE_Q) {/* Validate event block type */
\ ??OSQPend_2:
\ 00000040 0000D4E5 LDRB R0,[R4, #+0]
\ 00000044 020050E3 CMP R0,#+2
\ 00000048 0300000A BEQ ??OSQPend_3
408 *err = OS_ERR_EVENT_TYPE;
\ 0000004C 0100A0E3 MOV R0,#+1
\ 00000050 0000C6E5 STRB R0,[R6, #+0]
409 return ((void *)0);
\ 00000054 0000A0E3 MOV R0,#+0
\ 00000058 6D0000EA B ??OSQPend_1
410 }
411 #endif
412 if (OSIntNesting > 0) { /* See if called from ISR ... */
\ ??OSQPend_3:
\ 0000005C ........ LDR R0,??DataTable19 ;; OSIntNesting
\ 00000060 0000D0E5 LDRB R0,[R0, #+0]
\ 00000064 010050E3 CMP R0,#+1
\ 00000068 0300003A BCC ??OSQPend_4
413 *err = OS_ERR_PEND_ISR; /* ... can't PEND from an ISR */
\ 0000006C 0200A0E3 MOV R0,#+2
\ 00000070 0000C6E5 STRB R0,[R6, #+0]
414 return ((void *)0);
\ 00000074 0000A0E3 MOV R0,#+0
\ 00000078 650000EA B ??OSQPend_1
415 }
416 if (OSLockNesting > 0) { /* See if called with scheduler locked ... */
\ ??OSQPend_4:
\ 0000007C 94019FE5 LDR R0,??OSQPend_5 ;; OSLockNesting
\ 00000080 0000D0E5 LDRB R0,[R0, #+0]
\ 00000084 010050E3 CMP R0,#+1
\ 00000088 0300003A BCC ??OSQPend_6
417 *err = OS_ERR_PEND_LOCKED; /* ... can't PEND when locked */
\ 0000008C 0D00A0E3 MOV R0,#+13
\ 00000090 0000C6E5 STRB R0,[R6, #+0]
418 return ((void *)0);
\ 00000094 0000A0E3 MOV R0,#+0
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -