📄 os_q.lst
字号:
\ ??OSQAccept_6:
\ 00000056 ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
98 return (pmsg); /* Return message received (or NULL) */
\ 0000005A 2800 MOVS R0,R5
\ 0000005C 70BD POP {R4-R6,PC} ;; return
99 }
100 #endif
101 /*$PAGE*/
102 /*
103 *********************************************************************************************************
104 * CREATE A MESSAGE QUEUE
105 *
106 * Description: This function creates a message queue if free event control blocks are available.
107 *
108 * Arguments : start is a pointer to the base address of the message queue storage area. The
109 * storage area MUST be declared as an array of pointers to 'void' as follows
110 *
111 * void *MessageStorage[size]
112 *
113 * size is the number of elements in the storage area
114 *
115 * Returns : != (OS_EVENT *)0 is a pointer to the event control clock (OS_EVENT) associated with the
116 * created queue
117 * == (OS_EVENT *)0 if no event control blocks were available or an error was detected
118 *********************************************************************************************************
119 */
120
\ In segment CODE, align 4, keep-with-next
121 OS_EVENT *OSQCreate (void **start, INT16U size)
122 {
\ OSQCreate:
\ 00000000 2DE9F043 PUSH {R4-R9,LR}
\ 00000004 8046 MOV R8,R0
\ 00000006 8946 MOV R9,R1
123 OS_EVENT *pevent;
124 OS_Q *pq;
125 #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
126 OS_CPU_SR cpu_sr = 0;
127 #endif
128
129
130
131 if (OSIntNesting > 0) { /* See if called from ISR ... */
\ 00000008 .... LDR.N R0,??DataTable6 ;; OSIntNesting
\ 0000000A 0078 LDRB R0,[R0, #+0]
\ 0000000C 0028 CMP R0,#+0
\ 0000000E 01D0 BEQ.N ??OSQCreate_0
132 return ((OS_EVENT *)0); /* ... can't CREATE from an ISR */
\ 00000010 0020 MOVS R0,#+0
\ 00000012 38E0 B.N ??OSQCreate_1
133 }
134 OS_ENTER_CRITICAL();
\ ??OSQCreate_0:
\ 00000014 ........ _BLF OS_CPU_SR_Save,??OS_CPU_SR_Save??rT
135 pevent = OSEventFreeList; /* Get next free event control block */
\ 00000018 .... LDR.N R4,??DataTable4 ;; OSEventFreeList
\ 0000001A 2168 LDR R1,[R4, #+0]
\ 0000001C 0D00 MOVS R5,R1
136 if (OSEventFreeList != (OS_EVENT *)0) { /* See if pool of free ECB pool was empty */
\ 0000001E 01D0 BEQ.N ??OSQCreate_2
137 OSEventFreeList = (OS_EVENT *)OSEventFreeList->OSEventPtr;
\ 00000020 4968 LDR R1,[R1, #+4]
\ 00000022 2160 STR R1,[R4, #+0]
138 }
139 OS_EXIT_CRITICAL();
\ ??OSQCreate_2:
\ 00000024 ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
140 if (pevent != (OS_EVENT *)0) { /* See if we have an event control block */
\ 00000028 002D CMP R5,#+0
\ 0000002A 2BD0 BEQ.N ??OSQCreate_3
141 OS_ENTER_CRITICAL();
\ 0000002C ........ _BLF OS_CPU_SR_Save,??OS_CPU_SR_Save??rT
142 pq = OSQFreeList; /* Get a free queue control block */
\ 00000030 .... LDR.N R1,??DataTable5 ;; OSQFreeList
\ 00000032 0A68 LDR R2,[R1, #+0]
\ 00000034 1600 MOVS R6,R2
143 if (pq != (OS_Q *)0) { /* Were we able to get a queue control block ? */
\ 00000036 0027 MOVS R7,#+0
\ 00000038 002E CMP R6,#+0
\ 0000003A 1DD0 BEQ.N ??OSQCreate_4
144 OSQFreeList = OSQFreeList->OSQPtr; /* Yes, Adjust free list pointer to next free*/
\ 0000003C 1268 LDR R2,[R2, #+0]
\ 0000003E 0A60 STR R2,[R1, #+0]
145 OS_EXIT_CRITICAL();
\ 00000040 ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
146 pq->OSQStart = start; /* Initialize the queue */
\ 00000044 C6F80480 STR R8,[R6, #+4]
147 pq->OSQEnd = &start[size];
\ 00000048 4846 MOV R0,R9
\ 0000004A 18EB8000 ADDS R0,R8,R0, LSL #+2
\ 0000004E B060 STR R0,[R6, #+8]
148 pq->OSQIn = start;
\ 00000050 C6F80C80 STR R8,[R6, #+12]
149 pq->OSQOut = start;
\ 00000054 C6F81080 STR R8,[R6, #+16]
150 pq->OSQSize = size;
\ 00000058 A6F81490 STRH R9,[R6, #+20]
151 pq->OSQEntries = 0;
\ 0000005C 3800 MOVS R0,R7
\ 0000005E F082 STRH R0,[R6, #+22]
152 pevent->OSEventType = OS_EVENT_TYPE_Q;
\ 00000060 0220 MOVS R0,#+2
\ 00000062 2870 STRB R0,[R5, #+0]
153 pevent->OSEventCnt = 0;
\ 00000064 3800 MOVS R0,R7
\ 00000066 2881 STRH R0,[R5, #+8]
154 pevent->OSEventPtr = pq;
\ 00000068 6E60 STR R6,[R5, #+4]
155 #if OS_EVENT_NAME_SIZE > 1
156 pevent->OSEventName[0] = '?'; /* Unknown name */
\ 0000006A 3F20 MOVS R0,#+63
\ 0000006C E873 STRB R0,[R5, #+15]
157 pevent->OSEventName[1] = OS_ASCII_NUL;
\ 0000006E 2F74 STRB R7,[R5, #+16]
158 #endif
159 OS_EventWaitListInit(pevent); /* Initalize the wait list */
\ 00000070 2800 MOVS R0,R5
\ 00000072 ........ _BLF OS_EventWaitListInit,??OS_EventWaitListInit??rT
\ 00000076 05E0 B.N ??OSQCreate_3
160 } else {
161 pevent->OSEventPtr = (void *)OSEventFreeList; /* No, Return event control block on error */
\ ??OSQCreate_4:
\ 00000078 2168 LDR R1,[R4, #+0]
\ 0000007A 6960 STR R1,[R5, #+4]
162 OSEventFreeList = pevent;
\ 0000007C 2560 STR R5,[R4, #+0]
163 OS_EXIT_CRITICAL();
\ 0000007E ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
164 pevent = (OS_EVENT *)0;
\ 00000082 3D00 MOVS R5,R7
165 }
166 }
167 return (pevent);
\ ??OSQCreate_3:
\ 00000084 2800 MOVS R0,R5
\ ??OSQCreate_1:
\ 00000086 BDE8F083 POP {R4-R9,PC} ;; return
168 }
169 /*$PAGE*/
170 /*
171 *********************************************************************************************************
172 * DELETE A MESSAGE QUEUE
173 *
174 * Description: This function deletes a message queue and readies all tasks pending on the queue.
175 *
176 * Arguments : pevent is a pointer to the event control block associated with the desired
177 * queue.
178 *
179 * opt determines delete options as follows:
180 * opt == OS_DEL_NO_PEND Delete the queue ONLY if no task pending
181 * opt == OS_DEL_ALWAYS Deletes the queue even if tasks are waiting.
182 * In this case, all the tasks pending will be readied.
183 *
184 * perr is a pointer to an error code that can contain one of the following values:
185 * OS_ERR_NONE The call was successful and the queue was deleted
186 * OS_ERR_DEL_ISR If you tried to delete the queue from an ISR
187 * OS_ERR_INVALID_OPT An invalid option was specified
188 * OS_ERR_TASK_WAITING One or more tasks were waiting on the queue
189 * OS_ERR_EVENT_TYPE If you didn't pass a pointer to a queue
190 * OS_ERR_PEVENT_NULL If 'pevent' is a NULL pointer.
191 *
192 * Returns : pevent upon error
193 * (OS_EVENT *)0 if the queue was successfully deleted.
194 *
195 * Note(s) : 1) This function must be used with care. Tasks that would normally expect the presence of
196 * the queue MUST check the return code of OSQPend().
197 * 2) OSQAccept() callers will not know that the intended queue has been deleted unless
198 * they check 'pevent' to see that it's a NULL pointer.
199 * 3) This call can potentially disable interrupts for a long time. The interrupt disable
200 * time is directly proportional to the number of tasks waiting on the queue.
201 * 4) Because ALL tasks pending on the queue will be readied, you MUST be careful in
202 * applications where the queue is used for mutual exclusion because the resource(s)
203 * will no longer be guarded by the queue.
204 * 5) If the storage for the message queue was allocated dynamically (i.e. using a malloc()
205 * type call) then your application MUST release the memory storage by call the counterpart
206 * call of the dynamic allocation scheme used. If the queue storage was created statically
207 * then, the storage can be reused.
208 *********************************************************************************************************
209 */
210
211 #if OS_Q_DEL_EN > 0
\ In segment CODE, align 4, keep-with-next
212 OS_EVENT *OSQDel (OS_EVENT *pevent, INT8U opt, INT8U *perr)
213 {
\ OSQDel:
\ 00000000 2DE9F14F PUSH {R0,R4-R11,LR}
\ 00000004 8DF80010 STRB R1,[SP, #+0]
\ 00000008 0400 MOVS R4,R0
\ 0000000A 1500 MOVS R5,R2
214 BOOLEAN tasks_waiting;
215 OS_EVENT *pevent_return;
216 OS_Q *pq;
217 #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
218 OS_CPU_SR cpu_sr = 0;
219 #endif
220
221
222
223 #if OS_ARG_CHK_EN > 0
224 if (perr == (INT8U *)0) { /* Validate 'perr' */
\ 0000000C 01D1 BNE.N ??OSQDel_0
225 return (pevent);
\ ??OSQDel_1:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -