📄 os_q.lst
字号:
##############################################################################
# #
# IAR ARM ANSI C/C++ Compiler V4.40A/W32 EVALUATION 21/Jul/2006 16:27:54 #
# Copyright 1999-2005 IAR Systems. All rights reserved. #
# Time limited license: 22 days left #
# #
# Cpu mode = interwork #
# Endian = little #
# Stack alignment = 4 #
# Source file = E:\Project\ucos-ii\spi\uCOS-II\os_q.c #
# Command line = E:\Project\ucos-ii\spi\uCOS-II\os_q.c -lCN #
# E:\Project\ucos-ii\spi\Debug\List\ -lA #
# E:\Project\ucos-ii\spi\Debug\List\ -o #
# E:\Project\ucos-ii\spi\Debug\Obj\ -s9 --no_cse #
# --no_unroll --no_inline --no_code_motion --no_tbaa #
# --no_clustering --no_scheduling --debug --cpu_mode #
# thumb --endian little --cpu ARM7TDMI-S #
# --stack_align 4 --interwork -e --fpu None #
# --dlib_config "e:\Program Files\IAR #
# Systems\Embedded Workbench 4.0 #
# Evaluation\ARM\LIB\dl4tptinl8n.h" -I #
# E:\Project\ucos-ii\spi\ -I #
# E:\Project\ucos-ii\spi\App\ -I #
# E:\Project\ucos-ii\spi\ARM\ -I #
# E:\Project\ucos-ii\spi\BSP\ -I #
# E:\Project\ucos-ii\spi\uCOS-II\ -I "e:\Program #
# Files\IAR Systems\Embedded Workbench 4.0 #
# Evaluation\ARM\INC\" #
# List file = E:\Project\ucos-ii\spi\Debug\List\os_q.lst #
# Object file = E:\Project\ucos-ii\spi\Debug\Obj\os_q.r79 #
# #
# #
##############################################################################
E:\Project\ucos-ii\spi\uCOS-II\os_q.c
1 /*
2 *********************************************************************************************************
3 * uC/OS-II
4 * The Real-Time Kernel
5 * MESSAGE QUEUE MANAGEMENT
6 *
7 * (c) Copyright 1992-2003, Jean J. Labrosse, Weston, FL
8 * All Rights Reserved
9 *
10 * File : OS_Q.C
11 * By : Jean J. Labrosse
12 *********************************************************************************************************
13 */
14
15 #ifndef OS_MASTER_FILE
16 #include <ucos_ii.h>
17 #endif
18
19 #if (OS_Q_EN > 0) && (OS_MAX_QS > 0)
20 /*
21 *********************************************************************************************************
22 * ACCEPT MESSAGE FROM QUEUE
23 *
24 * Description: This function checks the queue to see if a message is available. Unlike OSQPend(),
25 * OSQAccept() does not suspend the calling task if a message is not available.
26 *
27 * Arguments : pevent is a pointer to the event control block
28 *
29 * err is a pointer to where an error message will be deposited. Possible error
30 * messages are:
31 *
32 * OS_NO_ERR The call was successful and your task received a
33 * message.
34 * OS_ERR_EVENT_TYPE You didn't pass a pointer to a queue
35 * OS_ERR_PEVENT_NULL If 'pevent' is a NULL pointer
36 * OS_Q_EMPTY The queue did not contain any messages
37 *
38 * Returns : != (void *)0 is the message in the queue if one is available. The message is removed
39 * from the so the next time OSQAccept() is called, the queue will contain
40 * one less entry.
41 * == (void *)0 if you received a NULL pointer message
42 * if the queue is empty or,
43 * if 'pevent' is a NULL pointer or,
44 * if you passed an invalid event type
45 *
46 * Note(s) : As of V2.60, you can now pass NULL pointers through queues. Because of this, the argument
47 * 'err' has been added to the API to tell you about the outcome of the call.
48 *********************************************************************************************************
49 */
50
51 #if OS_Q_ACCEPT_EN > 0
\ In segment CODE, align 4, keep-with-next
52 void *OSQAccept (OS_EVENT *pevent, INT8U *err)
53 {
\ OSQAccept:
\ 00000000 30B5 PUSH {R4,R5,LR}
\ 00000002 0500 MOVS R5,R0
\ 00000004 0C00 MOVS R4,R1
54 #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
55 OS_CPU_SR cpu_sr;
56 #endif
57 void *msg;
58 OS_Q *pq;
59
60
61 #if OS_ARG_CHK_EN > 0
62 if (pevent == (OS_EVENT *)0) { /* Validate 'pevent' */
\ 00000006 002D CMP R5,#+0
\ 00000008 03D1 BNE ??OSQAccept_0
63 *err = OS_ERR_PEVENT_NULL;
\ 0000000A 0420 MOVS R0,#+4
\ ??OSQAccept_1:
\ 0000000C 2070 STRB R0,[R4, #+0]
64 return ((void *)0);
\ 0000000E 0020 MOVS R0,#+0
\ 00000010 1FE0 B ??OSQAccept_2
65 }
66 #endif
67 if (pevent->OSEventType != OS_EVENT_TYPE_Q) {/* Validate event block type */
\ ??OSQAccept_0:
\ 00000012 2878 LDRB R0,[R5, #+0]
\ 00000014 0228 CMP R0,#+2
\ 00000016 01D0 BEQ ??OSQAccept_3
68 *err = OS_ERR_EVENT_TYPE;
\ 00000018 0120 MOVS R0,#+1
\ 0000001A F7E7 B.N ??OSQAccept_1
69 return ((void *)0);
70 }
71 OS_ENTER_CRITICAL();
\ ??OSQAccept_3:
\ 0000001C ........ _BLF OS_CPU_SR_Save,??OS_CPU_SR_Save??rT
72 pq = (OS_Q *)pevent->OSEventPtr; /* Point at queue control block */
\ 00000020 6968 LDR R1,[R5, #+4]
73 if (pq->OSQEntries > 0) { /* See if any messages in the queue */
\ 00000022 CA8A LDRH R2,[R1, #+22]
\ 00000024 002A CMP R2,#+0
\ 00000026 0ED0 BEQ ??OSQAccept_4
74 msg = *pq->OSQOut++; /* Yes, extract oldest message from the queue */
\ 00000028 0A69 LDR R2,[R1, #+16]
\ 0000002A 131D ADDS R3,R2,#+4
\ 0000002C 0B61 STR R3,[R1, #+16]
\ 0000002E 1568 LDR R5,[R2, #+0]
75 pq->OSQEntries--; /* Update the number of entries in the queue */
\ 00000030 CA8A LDRH R2,[R1, #+22]
\ 00000032 521E SUBS R2,R2,#+1
\ 00000034 CA82 STRH R2,[R1, #+22]
76 if (pq->OSQOut == pq->OSQEnd) { /* Wrap OUT pointer if we are at the end of the queue */
\ 00000036 1A00 MOVS R2,R3
\ 00000038 8B68 LDR R3,[R1, #+8]
\ 0000003A 9A42 CMP R2,R3
\ 0000003C 01D1 BNE ??OSQAccept_5
77 pq->OSQOut = pq->OSQStart;
\ 0000003E 4A68 LDR R2,[R1, #+4]
\ 00000040 0A61 STR R2,[R1, #+16]
78 }
79 *err = OS_NO_ERR;
\ ??OSQAccept_5:
\ 00000042 0021 MOVS R1,#+0
\ 00000044 01E0 B ??OSQAccept_6
80 } else {
81 *err = OS_Q_EMPTY;
\ ??OSQAccept_4:
\ 00000046 1F21 MOVS R1,#+31
82 msg = (void *)0; /* Queue is empty */
\ 00000048 0025 MOVS R5,#+0
\ ??OSQAccept_6:
\ 0000004A 2170 STRB R1,[R4, #+0]
83 }
84 OS_EXIT_CRITICAL();
\ 0000004C ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
85 return (msg); /* Return message received (or NULL) */
\ 00000050 2800 MOVS R0,R5
\ ??OSQAccept_2:
\ 00000052 30BC POP {R4,R5}
\ 00000054 02BC POP {R1}
\ 00000056 0847 BX R1 ;; return
86 }
87 #endif
88 /*$PAGE*/
89 /*
90 *********************************************************************************************************
91 * CREATE A MESSAGE QUEUE
92 *
93 * Description: This function creates a message queue if free event control blocks are available.
94 *
95 * Arguments : start is a pointer to the base address of the message queue storage area. The
96 * storage area MUST be declared as an array of pointers to 'void' as follows
97 *
98 * void *MessageStorage[size]
99 *
100 * size is the number of elements in the storage area
101 *
102 * Returns : != (OS_EVENT *)0 is a pointer to the event control clock (OS_EVENT) associated with the
103 * created queue
104 * == (OS_EVENT *)0 if no event control blocks were available or an error was detected
105 *********************************************************************************************************
106 */
107
\ In segment CODE, align 4, keep-with-next
108 OS_EVENT *OSQCreate (void **start, INT16U size)
109 {
\ OSQCreate:
\ 00000000 F0B5 PUSH {R4-R7,LR}
\ 00000002 0400 MOVS R4,R0
\ 00000004 0D00 MOVS R5,R1
110 #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
111 OS_CPU_SR cpu_sr;
112 #endif
113 OS_EVENT *pevent;
114 OS_Q *pq;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -