📄 os_q.lst
字号:
325 *
326 * Arguments : none
327 *
328 * Returns : OS_ERR_NONE upon success
329 * OS_ERR_EVENT_TYPE If you didn't pass a pointer to a queue
330 * OS_ERR_PEVENT_NULL If 'pevent' is a NULL pointer
331 *
332 * WARNING : You should use this function with great care because, when to flush the queue, you LOOSE
333 * the references to what the queue entries are pointing to and thus, you could cause
334 * 'memory leaks'. In other words, the data you are pointing to that's being referenced
335 * by the queue entries should, most likely, need to be de-allocated (i.e. freed).
336 *********************************************************************************************************
337 */
338
339 #if OS_Q_FLUSH_EN > 0u
\ In section .text, align 2, keep-with-next
340 INT8U OSQFlush (OS_EVENT *pevent)
341 {
\ OSQFlush:
\ 00000000 70B5 PUSH {R4-R6,LR}
\ 00000002 0400 MOVS R4,R0
342 OS_Q *pq;
343 #if OS_CRITICAL_METHOD == 3u /* Allocate storage for CPU status register */
344 OS_CPU_SR cpu_sr = 0u;
\ 00000004 0026 MOVS R6,#+0
345 #endif
346
347
348
349 #if OS_ARG_CHK_EN > 0u
350 if (pevent == (OS_EVENT *)0) { /* Validate 'pevent' */
351 return (OS_ERR_PEVENT_NULL);
352 }
353 if (pevent->OSEventType != OS_EVENT_TYPE_Q) { /* Validate event block type */
354 return (OS_ERR_EVENT_TYPE);
355 }
356 #endif
357 OS_ENTER_CRITICAL();
\ 00000006 ........ BL OS_CPU_SR_Save
\ 0000000A 0600 MOVS R6,R0
358 pq = (OS_Q *)pevent->OSEventPtr; /* Point to queue storage structure */
\ 0000000C 6068 LDR R0,[R4, #+4]
\ 0000000E 0500 MOVS R5,R0
359 pq->OSQIn = pq->OSQStart;
\ 00000010 6868 LDR R0,[R5, #+4]
\ 00000012 E860 STR R0,[R5, #+12]
360 pq->OSQOut = pq->OSQStart;
\ 00000014 6868 LDR R0,[R5, #+4]
\ 00000016 2861 STR R0,[R5, #+16]
361 pq->OSQEntries = 0u;
\ 00000018 0020 MOVS R0,#+0
\ 0000001A E882 STRH R0,[R5, #+22]
362 OS_EXIT_CRITICAL();
\ 0000001C 3000 MOVS R0,R6
\ 0000001E ........ BL OS_CPU_SR_Restore
363 return (OS_ERR_NONE);
\ 00000022 0020 MOVS R0,#+0
\ 00000024 70BD POP {R4-R6,PC} ;; return
364 }
365 #endif
366
367 /*$PAGE*/
368 /*
369 *********************************************************************************************************
370 * PEND ON A QUEUE FOR A MESSAGE
371 *
372 * Description: This function waits for a message to be sent to a queue
373 *
374 * Arguments : pevent is a pointer to the event control block associated with the desired queue
375 *
376 * timeout is an optional timeout period (in clock ticks). If non-zero, your task will
377 * wait for a message to arrive at the queue up to the amount of time
378 * specified by this argument. If you specify 0, however, your task will wait
379 * forever at the specified queue or, until a message arrives.
380 *
381 * perr is a pointer to where an error message will be deposited. Possible error
382 * messages are:
383 *
384 * OS_ERR_NONE The call was successful and your task received a
385 * message.
386 * OS_ERR_TIMEOUT A message was not received within the specified 'timeout'.
387 * OS_ERR_PEND_ABORT The wait on the queue was aborted.
388 * OS_ERR_EVENT_TYPE You didn't pass a pointer to a queue
389 * OS_ERR_PEVENT_NULL If 'pevent' is a NULL pointer
390 * OS_ERR_PEND_ISR If you called this function from an ISR and the result
391 * would lead to a suspension.
392 * OS_ERR_PEND_LOCKED If you called this function with the scheduler is locked
393 *
394 * Returns : != (void *)0 is a pointer to the message received
395 * == (void *)0 if you received a NULL pointer message or,
396 * if no message was received or,
397 * if 'pevent' is a NULL pointer or,
398 * if you didn't pass a pointer to a queue.
399 *
400 * Note(s) : As of V2.60, this function allows you to receive NULL pointer messages.
401 *********************************************************************************************************
402 */
403
\ In section .text, align 2, keep-with-next
404 void *OSQPend (OS_EVENT *pevent,
405 INT32U timeout,
406 INT8U *perr)
407 {
\ OSQPend:
\ 00000000 2DE9F843 PUSH {R3-R9,LR}
\ 00000004 0400 MOVS R4,R0
\ 00000006 0D00 MOVS R5,R1
\ 00000008 1600 MOVS R6,R2
408 void *pmsg;
409 OS_Q *pq;
410 #if OS_CRITICAL_METHOD == 3u /* Allocate storage for CPU status register */
411 OS_CPU_SR cpu_sr = 0u;
\ 0000000A 5FF00009 MOVS R9,#+0
412 #endif
413
414
415
416 #ifdef OS_SAFETY_CRITICAL
417 if (perr == (INT8U *)0) {
418 OS_SAFETY_CRITICAL_EXCEPTION();
419 return ((void *)0);
420 }
421 #endif
422
423 #if OS_ARG_CHK_EN > 0u
424 if (pevent == (OS_EVENT *)0) { /* Validate 'pevent' */
425 *perr = OS_ERR_PEVENT_NULL;
426 return ((void *)0);
427 }
428 #endif
429 if (pevent->OSEventType != OS_EVENT_TYPE_Q) {/* Validate event block type */
\ 0000000E 2078 LDRB R0,[R4, #+0]
\ 00000010 0228 CMP R0,#+2
\ 00000012 03D0 BEQ.N ??OSQPend_0
430 *perr = OS_ERR_EVENT_TYPE;
\ 00000014 0120 MOVS R0,#+1
\ 00000016 3070 STRB R0,[R6, #+0]
431 return ((void *)0);
\ 00000018 0020 MOVS R0,#+0
\ 0000001A 91E0 B.N ??OSQPend_1
432 }
433 if (OSIntNesting > 0u) { /* See if called from ISR ... */
\ ??OSQPend_0:
\ 0000001C ........ LDR.W R0,??DataTable4
\ 00000020 0078 LDRB R0,[R0, #+0]
\ 00000022 0028 CMP R0,#+0
\ 00000024 03D0 BEQ.N ??OSQPend_2
434 *perr = OS_ERR_PEND_ISR; /* ... can't PEND from an ISR */
\ 00000026 0220 MOVS R0,#+2
\ 00000028 3070 STRB R0,[R6, #+0]
435 return ((void *)0);
\ 0000002A 0020 MOVS R0,#+0
\ 0000002C 88E0 B.N ??OSQPend_1
436 }
437 if (OSLockNesting > 0u) { /* See if called with scheduler locked ... */
\ ??OSQPend_2:
\ 0000002E ........ LDR.W R0,??DataTable4_3
\ 00000032 0078 LDRB R0,[R0, #+0]
\ 00000034 0028 CMP R0,#+0
\ 00000036 03D0 BEQ.N ??OSQPend_3
438 *perr = OS_ERR_PEND_LOCKED; /* ... can't PEND when locked */
\ 00000038 0D20 MOVS R0,#+13
\ 0000003A 3070 STRB R0,[R6, #+0]
439 return ((void *)0);
\ 0000003C 0020 MOVS R0,#+0
\ 0000003E 7FE0 B.N ??OSQPend_1
440 }
441 OS_ENTER_CRITICAL();
\ ??OSQPend_3:
\ 00000040 ........ BL OS_CPU_SR_Save
\ 00000044 8146 MOV R9,R0
442 pq = (OS_Q *)pevent->OSEventPtr; /* Point at queue control block */
\ 00000046 6068 LDR R0,[R4, #+4]
\ 00000048 8046 MOV R8,R0
443 if (pq->OSQEntries > 0u) { /* See if any messages in the queue */
\ 0000004A B8F81600 LDRH R0,[R8, #+22]
\ 0000004E 0028 CMP R0,#+0
\ 00000050 1CD0 BEQ.N ??OSQPend_4
444 pmsg = *pq->OSQOut++; /* Yes, extract oldest message from the queue */
\ 00000052 D8F81000 LDR R0,[R8, #+16]
\ 00000056 011D ADDS R1,R0,#+4
\ 00000058 C8F81010 STR R1,[R8, #+16]
\ 0000005C 0068 LDR R0,[R0, #+0]
\ 0000005E 0700 MOVS R7,R0
445 pq->OSQEntries--; /* Update the number of entries in the queue */
\ 00000060 B8F81600 LDRH R0,[R8, #+22]
\ 00000064 401E SUBS R0,R0,#+1
\ 00000066 A8F81600 STRH R0,[R8, #+22]
446 if (pq->OSQOut == pq->OSQEnd) { /* Wrap OUT pointer if we are at the end of the queue */
\ 0000006A D8F81000 LDR R0,[R8, #+16]
\ 0000006E D8F80810 LDR R1,[R8, #+8]
\ 00000072 8842 CMP R0,R1
\ 00000074 03D1 BNE.N ??OSQPend_5
447 pq->OSQOut = pq->OSQStart;
\ 00000076 D8F80400 LDR R0,[R8, #+4]
\ 0000007A C8F81000 STR R0,[R8, #+16]
448 }
449 OS_EXIT_CRITICAL();
\ ??OSQPend_5:
\ 0000007E 4846 MOV R0,R9
\ 00000080 ........ BL OS_CPU_SR_Restore
450 *perr = OS_ERR_NONE;
\ 00000084 0020 MOVS R0,#+0
\ 00000086 3070 STRB R0,[R6, #+0]
451 return (pmsg); /* Return message received */
\ 00000088 3800 MOVS R0,R7
\ 0000008A 59E0 B.N ??OSQPend_1
452 }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -