📄 os_core.lst
字号:
\ 00000004 0D00 MOVS R5,R1
\ 00000006 1600 MOVS R6,R2
185 INT8U len;
186 #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
187 OS_CPU_SR cpu_sr = 0;
188 #endif
189
190
191
192 #if OS_ARG_CHK_EN > 0
193 if (perr == (INT8U *)0) { /* Validate 'perr' */
194 return;
195 }
196 if (pevent == (OS_EVENT *)0) { /* Is 'pevent' a NULL pointer? */
197 *perr = OS_ERR_PEVENT_NULL;
198 return;
199 }
200 if (pname == (INT8U *)0) { /* Is 'pname' a NULL pointer? */
201 *perr = OS_ERR_PNAME_NULL;
202 return;
203 }
204 #endif
205 if (OSIntNesting > 0) { /* See if trying to call from an ISR */
\ 00000008 .... LDR.N R0,??DataTable1 ;; OSCPUUsage + 2
\ 0000000A 0078 LDRB R0,[R0, #+0]
\ 0000000C 0028 CMP R0,#+0
\ 0000000E 02D0 BEQ.N ??OSEventNameSet_0
206 *perr = OS_ERR_NAME_SET_ISR;
\ 00000010 1220 MOVS R0,#+18
\ 00000012 3070 STRB R0,[R6, #+0]
207 return;
\ 00000014 F0BD POP {R4-R7,PC}
208 }
209 switch (pevent->OSEventType) {
\ ??OSEventNameSet_0:
\ 00000016 2078 LDRB R0,[R4, #+0]
\ 00000018 401E SUBS R0,R0,#+1
\ 0000001A 0328 CMP R0,#+3
\ 0000001C 0DD8 BHI.N ??OSEventNameSet_1
210 case OS_EVENT_TYPE_SEM:
211 case OS_EVENT_TYPE_MUTEX:
212 case OS_EVENT_TYPE_MBOX:
213 case OS_EVENT_TYPE_Q:
214 break;
215
216 default:
217 *perr = OS_ERR_EVENT_TYPE;
218 return;
219 }
220 OS_ENTER_CRITICAL();
\ 0000001E ........ _BLF OS_CPU_SR_Save,??OS_CPU_SR_Save??rT
\ 00000022 0700 MOVS R7,R0
221 len = OS_StrLen(pname); /* Can we fit the string in the storage area? */
\ 00000024 2800 MOVS R0,R5
\ 00000026 ........ BL OS_StrLen
222 if (len > (OS_EVENT_NAME_SIZE - 1)) { /* No */
\ 0000002A 1028 CMP R0,#+16
\ 0000002C 08D3 BCC.N ??OSEventNameSet_2
223 OS_EXIT_CRITICAL();
\ 0000002E 3800 MOVS R0,R7
\ 00000030 ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
224 *perr = OS_ERR_EVENT_NAME_TOO_LONG;
\ 00000034 0B20 MOVS R0,#+11
\ 00000036 3070 STRB R0,[R6, #+0]
225 return;
\ 00000038 F0BD POP {R4-R7,PC}
226 }
\ ??OSEventNameSet_1:
\ 0000003A 0120 MOVS R0,#+1
\ 0000003C 3070 STRB R0,[R6, #+0]
\ 0000003E F0BD POP {R4-R7,PC}
227 (void)OS_StrCopy(pevent->OSEventName, pname); /* Yes, copy name to the event control block */
\ ??OSEventNameSet_2:
\ 00000040 2900 MOVS R1,R5
\ 00000042 0F34 ADDS R4,R4,#+15
\ 00000044 2000 MOVS R0,R4
\ 00000046 ........ BL OS_StrCopy
228 OS_EXIT_CRITICAL();
\ 0000004A 3800 MOVS R0,R7
\ 0000004C ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
229 *perr = OS_ERR_NONE;
\ 00000050 0020 MOVS R0,#+0
\ 00000052 3070 STRB R0,[R6, #+0]
230 }
\ 00000054 F0BD POP {R4-R7,PC} ;; return
231 #endif
232
233 /*$PAGE*/
234 /*
235 *********************************************************************************************************
236 * PEND ON MULTIPLE EVENTS
237 *
238 * Description: This function waits for multiple events. If multiple events are ready at the start of the
239 * pend call, then all available events are returned as ready. If the task must pend on the
240 * multiple events, then only the first posted or aborted event is returned as ready.
241 *
242 * Arguments : pevents_pend is a pointer to a NULL-terminated array of event control blocks to wait for.
243 *
244 * pevents_rdy is a pointer to an array to return which event control blocks are available
245 * or ready. The size of the array MUST be greater than or equal to the size
246 * of the 'pevents_pend' array, including terminating NULL.
247 *
248 * pmsgs_rdy is a pointer to an array to return messages from any available message-type
249 * events. The size of the array MUST be greater than or equal to the size of
250 * the 'pevents_pend' array, excluding the terminating NULL. Since NULL
251 * messages are valid messages, this array cannot be NULL-terminated. Instead,
252 * every available message-type event returns its messages in the 'pmsgs_rdy'
253 * array at the same index as the event is returned in the 'pevents_rdy' array.
254 * All other 'pmsgs_rdy' array indices are filled with NULL messages.
255 *
256 * timeout is an optional timeout period (in clock ticks). If non-zero, your task will
257 * wait for the resources up to the amount of time specified by this argument.
258 * If you specify 0, however, your task will wait forever for the specified
259 * events or, until the resources becomes available (or the events occur).
260 *
261 * perr is a pointer to where an error message will be deposited. Possible error
262 * messages are:
263 *
264 * OS_ERR_NONE The call was successful and your task owns the resources
265 * or, the events you are waiting for occurred; check the
266 * 'pevents_rdy' array for which events are available.
267 * OS_ERR_PEND_ABORT The wait on the events was aborted; check the
268 * 'pevents_rdy' array for which events were aborted.
269 * OS_ERR_TIMEOUT The events were not received within the specified
270 * 'timeout'.
271 * OS_ERR_PEVENT_NULL If 'pevents_pend', 'pevents_rdy', or 'pmsgs_rdy' is a
272 * NULL pointer.
273 * OS_ERR_EVENT_TYPE If you didn't pass a pointer to an array of semaphores,
274 * mailboxes, and/or queues.
275 * OS_ERR_PEND_ISR If you called this function from an ISR and the result
276 * would lead to a suspension.
277 * OS_ERR_PEND_LOCKED If you called this function when the scheduler is locked.
278 *
279 * Returns : > 0 the number of events returned as ready or aborted.
280 * == 0 if no events are returned as ready because of timeout or upon error.
281 *
282 * Notes : 1) a. Validate 'pevents_pend' array as valid OS_EVENTs :
283 *
284 * semaphores, mailboxes, queues
285 *
286 * b. Return ALL available events and messages, if any
287 *
288 * c. Add current task priority as pending to each events's wait list
289 * Performed in OS_EventTaskWaitMulti()
290 *
291 * d. Wait on any of multiple events
292 *
293 * e. Remove current task priority as pending from each events's wait list
294 * Performed in OS_EventTaskRdy(), if events posted or aborted
295 *
296 * f. Return any event posted or aborted, if any
297 * else
298 * Return timeout
299 *
300 * 2) 'pevents_rdy' initialized to NULL PRIOR to all other validation or function handling in
301 * case of any error(s).
302 *********************************************************************************************************
303 */
304 /*$PAGE*/
305 #if ((OS_EVENT_EN) && (OS_EVENT_MULTI_EN > 0))
\ In segment CODE, align 4, keep-with-next
306 INT16U OSEventPendMulti (OS_EVENT **pevents_pend, OS_EVENT **pevents_rdy, void **pmsgs_rdy, INT16U timeout, INT8U *perr)
307 {
\ OSEventPendMulti:
\ 00000000 2DE9F74F PUSH {R0-R2,R4-R11,LR}
\ 00000004 8046 MOV R8,R0
\ 00000006 ADF80230 STRH R3,[SP, #+2]
\ 0000000A 0D00 MOVS R5,R1
\ 0000000C 1600 MOVS R6,R2
\ 0000000E 0C9C LDR R4,[SP, #+48]
308 OS_EVENT **pevents;
309 OS_EVENT *pevent;
310 #if ((OS_Q_EN > 0) && (OS_MAX_QS > 0))
311 OS_Q *pq;
312 #endif
313 BOOLEAN events_rdy;
314 INT16U events_rdy_nbr;
315 INT8U events_stat;
316 #if (OS_CRITICAL_METHOD == 3) /* Allocate storage for CPU status register */
317 OS_CPU_SR cpu_sr = 0;
318 #endif
319
320
321
322 #if (OS_ARG_CHK_EN > 0)
323 if (perr == (INT8U *)0) { /* Validate 'perr' */
324 return (0);
325 }
326 if (pevents_pend == (OS_EVENT **)0) { /* Validate 'pevents_pend' */
327 *perr = OS_ERR_PEVENT_NULL;
328 return (0);
329 }
330 if (pevents_rdy == (OS_EVENT **)0) { /* Validate 'pevents_rdy' */
331 *perr = OS_ERR_PEVENT_NULL;
332 return (0);
333 }
334 if (pmsgs_rdy == (void **)0) { /* Validate 'pmsgs_rdy' */
335 *perr = OS_ERR_PEVENT_NULL;
336 return (0);
337 }
338 #endif
339
340 *pevents_rdy = (OS_EVENT *)0; /* Init array to NULL in case of errors */
\ 00000010 0020 MOVS R0,#+0
\ 00000012 8146 MOV R9,R0
\ 00000014 C5F80090 STR R9,[R5, #+0]
341
342 pevents = pevents_pend;
\ 00000018 4146 MOV R1,R8
343 pevent = *pevents;
\ 0000001A 0F68 LDR R7,[R1, #+0]
\ 0000001C 01E0 B.N ??OSEventPendMulti_0
344 while (pevent != (OS_EVENT *)0) {
345 switch (pevent->OSEventType) { /* Validate event block types */
346 #if (OS_SEM_EN > 0)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -