📄 os_q.lst
字号:
292
293 default:
294 OS_EXIT_CRITICAL();
\ ??OSQDel_9:
\ 000001BC 0700B0E1 MOVS R0,R7
\ 000001C0 ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rA
295 *err = OS_ERR_INVALID_OPT;
\ 000001C4 0700A0E3 MOV R0,#+7
\ 000001C8 0000C5E5 STRB R0,[R5, #+0]
296 pevent_return = pevent;
297 break;
298 }
299 return (pevent_return);
\ ??OSQDel_11:
\ 000001CC 0400B0E1 MOVS R0,R4
\ ??OSQDel_1:
\ 000001D0 F081BDE8 POP {R4-R8,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 10402DE9 PUSH {R4,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
329 #endif
330
331
332
333 #if OS_ARG_CHK_EN > 0
334 if (pevent == (OS_EVENT *)0) { /* Validate 'pevent' */
\ 0000000C 000054E3 CMP R4,#+0
\ 00000010 0100001A BNE ??OSQFlush_0
335 return (OS_ERR_PEVENT_NULL);
\ 00000014 0400A0E3 MOV R0,#+4
\ 00000018 0E0000EA B ??OSQFlush_1
336 }
337 if (pevent->OSEventType != OS_EVENT_TYPE_Q) { /* Validate event block type */
\ ??OSQFlush_0:
\ 0000001C 0000D4E5 LDRB R0,[R4, #+0]
\ 00000020 020050E3 CMP R0,#+2
\ 00000024 0100000A BEQ ??OSQFlush_2
338 return (OS_ERR_EVENT_TYPE);
\ 00000028 0100A0E3 MOV R0,#+1
\ 0000002C 090000EA B ??OSQFlush_1
339 }
340 #endif
341 OS_ENTER_CRITICAL();
\ ??OSQFlush_2:
\ 00000030 ........ _BLF OS_CPU_SR_Save,??OS_CPU_SR_Save??rA
342 pq = (OS_Q *)pevent->OSEventPtr; /* Point to queue storage structure */
\ 00000034 041094E5 LDR R1,[R4, #+4]
343 pq->OSQIn = pq->OSQStart;
\ 00000038 042091E5 LDR R2,[R1, #+4]
\ 0000003C 0C2081E5 STR R2,[R1, #+12]
344 pq->OSQOut = pq->OSQStart;
\ 00000040 042091E5 LDR R2,[R1, #+4]
\ 00000044 102081E5 STR R2,[R1, #+16]
345 pq->OSQEntries = 0;
\ 00000048 0020A0E3 MOV R2,#+0
\ 0000004C B621C1E1 STRH R2,[R1, #+22]
346 OS_EXIT_CRITICAL();
\ 00000050 ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rA
347 return (OS_ERR_NONE);
\ 00000054 0000A0E3 MOV R0,#+0
\ ??OSQFlush_1:
\ 00000058 1080BDE8 POP {R4,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 F0402DE9 PUSH {R4-R7,LR}
\ 00000004 0050B0E1 MOVS R5,R0
\ 00000008 0160B0E1 MOVS R6,R1
\ 0000000C 0240B0E1 MOVS R4,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 0070A0E3 MOV R7,#+0
395 #endif
396
397
398
399 #if OS_ARG_CHK_EN > 0
400 if (err == (INT8U *)0) { /* Validate 'err' */
\ 00000014 000054E3 CMP R4,#+0
\ 00000018 0100001A BNE ??OSQPend_0
401 return ((void *)0);
\ 0000001C 0000A0E3 MOV R0,#+0
\ 00000020 750000EA B ??OSQPend_1
402 }
403 if (pevent == (OS_EVENT *)0) { /* Validate 'pevent' */
\ ??OSQPend_0:
\ 00000024 000055E3 CMP R5,#+0
\ 00000028 0300001A BNE ??OSQPend_2
404 *err = OS_ERR_PEVENT_NULL;
\ 0000002C 0400A0E3 MOV R0,#+4
\ 00000030 0000C4E5 STRB R0,[R4, #+0]
405 return ((void *)0);
\ 00000034 0000A0E3 MOV R0,#+0
\ 00000038 6F0000EA B ??OSQPend_1
406 }
407 if (pevent->OSEventType != OS_EVENT_TYPE_Q) {/* Validate event block type */
\ ??OSQPend_2:
\ 0000003C 0000D5E5 LDRB R0,[R5, #+0]
\ 00000040 020050E3 CMP R0,#+2
\ 00000044 0300000A BEQ ??OSQPend_3
408 *err = OS_ERR_EVENT_TYPE;
\ 00000048 0100A0E3 MOV R0,#+1
\ 0000004C 0000C4E5 STRB R0,[R4, #+0]
409 return ((void *)0);
\ 00000050 0000A0E3 MOV R0,#+0
\ 00000054 680000EA B ??OSQPend_1
410 }
411 #endif
412 if (OSIntNesting > 0) { /* See if called from ISR ... */
\ ??OSQPend_3:
\ 00000058 ........ LDR R0,??DataTable19 ;; OSIntNesting
\ 0000005C 0000D0E5 LDRB R0,[R0, #+0]
\ 00000060 010050E3 CMP R0,#+1
\ 00000064 0300003A BCC ??OSQPend_4
413 *err = OS_ERR_PEND_ISR; /* ... can't PEND from an ISR */
\ 00000068 0200A0E3 MOV R0,#+2
\ 0000006C 0000C4E5 STRB R0,[R4, #+0]
414 return ((void *)0);
\ 00000070 0000A0E3 MOV R0,#+0
\ 00000074 600000EA B ??OSQPend_1
415 }
416 if (OSLockNesting > 0) { /* See if called with scheduler locked ... */
\ ??OSQPend_4:
\ 00000078 80019FE5 LDR R0,??OSQPend_5 ;; OSLockNesting
\ 0000007C 0000D0E5 LDRB R0,[R0, #+0]
\ 00000080 010050E3 CMP R0,#+1
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -